Example #1
0
    EffectsView() {
        size_t i;
        const float pts[] = {
            0, 0,
            10, 0,
            10, 5,
            20, -5,
            10, -15,
            10, -10,
            0, -10
        };
        fPath.moveTo(pts[0], pts[1]);
        for (i = 2; i < SK_ARRAY_COUNT(pts); i += 2) {
            fPath.lineTo(pts[i], pts[i+1]);
        }

        for (i = 0; i < SK_ARRAY_COUNT(gPaintProcs); i++) {
            fPaint[i].setAntiAlias(true);
            fPaint[i].setColor(COLOR);
            gPaintProcs[i](&fPaint[i]);
        }

        SkColorMatrix cm;
        cm.setRotate(SkColorMatrix::kG_Axis, 180);
        cm.setIdentity();

        this->setBGColor(0xFFDDDDDD);
    }
Example #2
0
SkColorFilter* SkColorFilter::CreateLightingFilter(SkColor mul, SkColor add) {
    SkColorMatrix matrix;
    matrix.setScale(byte_to_scale(SkColorGetR(mul)),
                    byte_to_scale(SkColorGetG(mul)),
                    byte_to_scale(SkColorGetB(mul)),
                    1);
    matrix.postTranslate(SkIntToScalar(SkColorGetR(add)),
                         SkIntToScalar(SkColorGetG(add)),
                         SkIntToScalar(SkColorGetB(add)),
                         0);
    return SkColorMatrixFilter::Create(matrix);
}
Example #3
0
static SkColorFilter* make_cf1() {
    SkColorMatrix cm;
    cm.setSaturation(0.75f);
    SkAutoTUnref<SkColorFilter> a(SkColorMatrixFilter::Create(cm));
    // CreateComposedFilter will try to concat these two matrices, resulting in a single
    // filter (which is good for speed). For this test, we want to force a real compose of
    // these two, so our inner filter has a scale-up, which disables the optimization of
    // combining the two matrices.
    cm.setScale(1.1f, 0.9f, 1);
    SkAutoTUnref<SkColorFilter> b(SkColorMatrixFilter::Create(cm));
    return SkColorFilter::CreateComposeFilter(a, b);
}
void SkColorMatrix::postRotate(Axis axis, SkScalar degrees)
{
    SkColorMatrix tmp;
    tmp.setRotate(axis, degrees);
    this->postConcat(tmp);
}
Example #5
0
    virtual void onDraw(SkCanvas* canvas) {
        this->init();

        SkPaint paint;
        SkColorMatrix matrix;
        SkColorMatrixFilter* filter = new SkColorMatrixFilter();
        paint.setColorFilter(filter)->unref();

        matrix.setIdentity();
        filter->setMatrix(matrix);
        canvas->drawBitmap(fBitmap, 0, 0, &paint);

        matrix.setRotate(SkColorMatrix::kR_Axis, 90);
        filter->setMatrix(matrix);
        canvas->drawBitmap(fBitmap, 80, 0, &paint);

        matrix.setRotate(SkColorMatrix::kG_Axis, 90);
        filter->setMatrix(matrix);
        canvas->drawBitmap(fBitmap, 160, 0, &paint);

        matrix.setRotate(SkColorMatrix::kB_Axis, 90);
        filter->setMatrix(matrix);
        canvas->drawBitmap(fBitmap, 240, 0, &paint);

        matrix.setSaturation(SkFloatToScalar(0.0f));
        filter->setMatrix(matrix);
        canvas->drawBitmap(fBitmap, 0, 80, &paint);

        matrix.setSaturation(SkFloatToScalar(0.5f));
        filter->setMatrix(matrix);
        canvas->drawBitmap(fBitmap, 80, 80, &paint);

        matrix.setSaturation(SkFloatToScalar(1.0f));
        filter->setMatrix(matrix);
        canvas->drawBitmap(fBitmap, 160, 80, &paint);

        matrix.setSaturation(SkFloatToScalar(2.0f));
        filter->setMatrix(matrix);
        canvas->drawBitmap(fBitmap, 240, 80, &paint);

        matrix.setRGB2YUV();
        filter->setMatrix(matrix);
        canvas->drawBitmap(fBitmap, 0, 160, &paint);

        matrix.setYUV2RGB();
        filter->setMatrix(matrix);
        canvas->drawBitmap(fBitmap, 80, 160, &paint);

        SkScalar s1 = SK_Scalar1;
        SkScalar s255 = SkIntToScalar(255);
        // Move red into alpha, set color to white
        SkScalar data[20] = {
            0,  0, 0, 0, s255,
            0,  0, 0, 0, s255,
            0,  0, 0, 0, s255,
            s1, 0, 0, 0, 0,
        };

        filter->setArray(data);
        canvas->drawBitmap(fBitmap, 160, 160, &paint);
    }
Example #6
0
    virtual void onDraw(SkCanvas* canvas) {
        this->init();

        SkPaint paint;
        SkColorMatrix matrix;

        paint.setXfermodeMode(SkXfermode::kSrc_Mode);
        const SkBitmap bmps[] = { fSolidBitmap, fTransparentBitmap };

        for (size_t i = 0; i < SK_ARRAY_COUNT(bmps); ++i) {
            matrix.setIdentity();
            setColorMatrix(&paint, matrix);
            canvas->drawBitmap(bmps[i], 0, 0, &paint);

            matrix.setRotate(SkColorMatrix::kR_Axis, 90);
            setColorMatrix(&paint, matrix);
            canvas->drawBitmap(bmps[i], 80, 0, &paint);

            matrix.setRotate(SkColorMatrix::kG_Axis, 90);
            setColorMatrix(&paint, matrix);
            canvas->drawBitmap(bmps[i], 160, 0, &paint);

            matrix.setRotate(SkColorMatrix::kB_Axis, 90);
            setColorMatrix(&paint, matrix);
            canvas->drawBitmap(bmps[i], 240, 0, &paint);

            matrix.setSaturation(0.0f);
            setColorMatrix(&paint, matrix);
            canvas->drawBitmap(bmps[i], 0, 80, &paint);

            matrix.setSaturation(0.5f);
            setColorMatrix(&paint, matrix);
            canvas->drawBitmap(bmps[i], 80, 80, &paint);

            matrix.setSaturation(1.0f);
            setColorMatrix(&paint, matrix);
            canvas->drawBitmap(bmps[i], 160, 80, &paint);

            matrix.setSaturation(2.0f);
            setColorMatrix(&paint, matrix);
            canvas->drawBitmap(bmps[i], 240, 80, &paint);

            matrix.setRGB2YUV();
            setColorMatrix(&paint, matrix);
            canvas->drawBitmap(bmps[i], 0, 160, &paint);

            matrix.setYUV2RGB();
            setColorMatrix(&paint, matrix);
            canvas->drawBitmap(bmps[i], 80, 160, &paint);

            SkScalar s1 = SK_Scalar1;
            SkScalar s255 = SkIntToScalar(255);
            // Move red into alpha, set color to white
            SkScalar data[20] = {
                0,  0, 0, 0, s255,
                0,  0, 0, 0, s255,
                0,  0, 0, 0, s255,
                s1, 0, 0, 0, 0,
            };

            setArray(&paint, data);
            canvas->drawBitmap(bmps[i], 160, 160, &paint);

            canvas->translate(0, 240);
        }
    }
Example #7
0
static SkColorFilter* make_cf0() {
    SkColorMatrix cm;
    cm.setSaturation(0.75f);
    return SkColorMatrixFilter::Create(cm);
}
Example #8
0
static sk_sp<SkColorFilter> make_cf0() {
    SkColorMatrix cm;
    cm.setSaturation(0.75f);
    return SkColorFilter::MakeMatrixFilterRowMajor255(cm.fMat);
}