当前位置: 首页>>代码示例>>C++>>正文


C++ SkRect::offsetTo方法代码示例

本文整理汇总了C++中SkRect::offsetTo方法的典型用法代码示例。如果您正苦于以下问题:C++ SkRect::offsetTo方法的具体用法?C++ SkRect::offsetTo怎么用?C++ SkRect::offsetTo使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SkRect的用法示例。


在下文中一共展示了SkRect::offsetTo方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: onDraw

    void onDraw(SkCanvas* canvas) override {
        canvas->drawARGB(255, 0, 0, 0);

        SkRect r = SkRect::MakeXYWH(16.5f, 16.5f, 96.0f, 96.0f);

        SkPaint p0;
        p0.setColor(SK_ColorWHITE);
        p0.setAntiAlias(true);

        canvas->drawRect(r, p0);

        r = SkRect::MakeXYWH(3.5f, 3.5f, 59.0f, 59.0f);

        // UL corner: replace white with green with a tight tolerance
        SkPaint p1;
        p1.setColor(SK_ColorGREEN);
        p1.setAntiAlias(true);
        p1.setXfermode(SkAvoidXfermode::Create(SK_ColorWHITE,
                                               5,
                                               SkAvoidXfermode::kTargetColor_Mode))->unref();

        canvas->drawRect(r, p1);

        r.offsetTo(65.5f, 3.5f);

        // UR corner: draw red everywhere except white with a tight tolerance
        SkPaint p2;
        p2.setColor(SK_ColorRED);
        p2.setAntiAlias(true);
        p2.setXfermode(SkAvoidXfermode::Create(SK_ColorWHITE,
                                               250,
                                               SkAvoidXfermode::kAvoidColor_Mode))->unref();

        canvas->drawRect(r, p2);

        r.offsetTo(3.5f, 65.5f);

        // LL corner: replace white with blue with a loose tolerance
        SkPaint p3;
        p3.setColor(SK_ColorBLUE);
        p3.setAntiAlias(true);
        p3.setXfermode(SkAvoidXfermode::Create(SK_ColorWHITE,
                                               250,
                                               SkAvoidXfermode::kTargetColor_Mode))->unref();

        canvas->drawRect(r, p3);

        r.offsetTo(65.5f, 65.5f);

        // LR corner: draw yellow everywhere except white with a loose tolerance
        SkPaint p4;
        p4.setColor(SK_ColorYELLOW);
        p4.setAntiAlias(true);
        p4.setXfermode(SkAvoidXfermode::Create(SK_ColorWHITE,
                                               5,
                                               SkAvoidXfermode::kAvoidColor_Mode))->unref();

        canvas->drawRect(r, p4);
    }
开发者ID:YangchenVR,项目名称:skia,代码行数:59,代码来源:avoidxfermode3.cpp

示例2: onDraw

    void onDraw(SkCanvas* canvas) override {
        canvas->drawBitmap(fBM, 0, 0);

        SkRect r = SkRect::MakeIWH(64, 64);

        // UL corner: replace white with black with a tight tolerance
        SkPaint p1;
        p1.setColor(SK_ColorBLACK);
        p1.setXfermode(SkAvoidXfermode::Create(SK_ColorWHITE,
                                               5,
                                               SkAvoidXfermode::kTargetColor_Mode))->unref();

        canvas->drawRect(r, p1);

        r.offsetTo(64, 0.0f);

        // UR corner: draw black everywhere except white with a tight tolerance
        SkPaint p2;
        p2.setColor(SK_ColorBLACK);
        p2.setXfermode(SkAvoidXfermode::Create(SK_ColorWHITE,
                                               250,
                                               SkAvoidXfermode::kAvoidColor_Mode))->unref();

        canvas->drawRect(r, p2);

        r.offsetTo(0.0f, 64);

        // LL corner: replace red with blue with a loose tolerance
        SkPaint p3;
        p3.setColor(SK_ColorBLUE);
        p3.setXfermode(SkAvoidXfermode::Create(SK_ColorRED,
                                               250,
                                               SkAvoidXfermode::kTargetColor_Mode))->unref();

        canvas->drawRect(r, p3);

        r.offsetTo(64, 64);

        // LR corner: draw black everywhere except red with a loose tolerance
        SkPaint p4;
        p4.setColor(SK_ColorBLACK);
        p4.setXfermode(SkAvoidXfermode::Create(SK_ColorRED,
                                               5,
                                               SkAvoidXfermode::kAvoidColor_Mode))->unref();

        canvas->drawRect(r, p4);
    }
开发者ID:colemancda,项目名称:skia,代码行数:47,代码来源:avoidxfermode.cpp

示例3: onDraw

    void onDraw(SkCanvas* canvas) override {
        canvas->drawBitmap(fBM, 0, 0);

        SkRect r = SkRect::MakeIWH(256, 256);

        // Negate the red channel of the dst (via the ancillary color) but leave
        // the green & blue channels alone
        SkPaint p1;
        p1.setColor(SK_ColorBLACK); // noop
        p1.setXfermode(SkPixelXorXfermode::Create(0x7FFF0000))->unref();

        canvas->drawRect(r, p1);

        r.offsetTo(256.0f, 0.0f);

        // Negate the dst color via the src color
        SkPaint p2;
        p2.setColor(SK_ColorWHITE);
        p2.setXfermode(SkPixelXorXfermode::Create(SK_ColorBLACK))->unref(); // noop

        canvas->drawRect(r, p2);

        r.offsetTo(0.0f, 256.0f);

        // Just return the original color
        SkPaint p3;
        p3.setColor(SK_ColorBLACK); // noop
        p3.setXfermode(SkPixelXorXfermode::Create(SK_ColorBLACK))->unref(); // noop

        canvas->drawRect(r, p3);

        r.offsetTo(256.0f, 256.0f);

        // Negate the red & green channels (via the ancillary color) but leave
        // the blue channel alone
        SkPaint p4;
        p4.setColor(SK_ColorBLACK); // noop
        p4.setXfermode(SkPixelXorXfermode::Create(SK_ColorYELLOW))->unref();

        canvas->drawRect(r, p4);
    }
开发者ID:YangchenVR,项目名称:skia,代码行数:41,代码来源:pixelxorxfermode.cpp

示例4: GaussianBlur


//.........这里部分代码省略.........
                             i < scaleFactorY ? 0.5f : 1.0f);

        SkAutoTUnref<GrDrawContext> dstDrawContext(
                                             context->drawContext(dstTexture->asRenderTarget()));
        if (!dstDrawContext) {
            return nullptr;
        }
        dstDrawContext->fillRectToRect(clip, paint, SkMatrix::I(), dstRect, srcRect);

        srcDrawContext.swap(dstDrawContext);
        srcRect = dstRect;
        srcTexture = dstTexture;
        SkTSwap(dstTexture, tempTexture);
        localSrcBounds = srcRect;
    }

    // For really small blurs (certainly no wider than 5x5 on desktop gpus) it is faster to just
    // launch a single non separable kernel vs two launches
    srcRect = localDstBounds;
    if (sigmaX > 0.0f && sigmaY > 0.0f &&
            (2 * radiusX + 1) * (2 * radiusY + 1) <= MAX_KERNEL_SIZE) {
        // We shouldn't be scaling because this is a small size blur
        SkASSERT((1 == scaleFactorX) && (1 == scaleFactorY));

        SkAutoTUnref<GrDrawContext> dstDrawContext(
                                             context->drawContext(dstTexture->asRenderTarget()));
        if (!dstDrawContext) {
            return nullptr;
        }
        convolve_gaussian_2d(dstDrawContext, clip, srcRect, srcOffset,
                             srcTexture, radiusX, radiusY, sigmaX, sigmaY, srcBounds);

        srcDrawContext.swap(dstDrawContext);
        srcRect.offsetTo(0, 0);
        srcTexture = dstTexture;
        SkTSwap(dstTexture, tempTexture);

    } else {
        scale_rect(&srcRect, 1.0f / scaleFactorX, 1.0f / scaleFactorY);
        srcRect.roundOut(&srcRect);
        const SkIRect srcIRect = srcRect.roundOut();
        if (sigmaX > 0.0f) {
            if (scaleFactorX > 1) {
                // TODO: if we pass in the source draw context we don't need this here
                if (!srcDrawContext) {
                    srcDrawContext.reset(context->drawContext(srcTexture->asRenderTarget()));
                    if (!srcDrawContext) {
                        return nullptr;
                    }        
                }

                // Clear out a radius to the right of the srcRect to prevent the
                // X convolution from reading garbage.
                clearRect = SkIRect::MakeXYWH(srcIRect.fRight, srcIRect.fTop,
                                              radiusX, srcIRect.height());
                srcDrawContext->clear(&clearRect, 0x0, false);
            }

            SkAutoTUnref<GrDrawContext> dstDrawContext(
                                             context->drawContext(dstTexture->asRenderTarget()));
            if (!dstDrawContext) {
                return nullptr;
            }
            convolve_gaussian(dstDrawContext, clip, srcRect,
                              srcTexture, Gr1DKernelEffect::kX_Direction, radiusX, sigmaX,
                              srcBounds, srcOffset);
开发者ID:keinvo,项目名称:skia,代码行数:67,代码来源:SkGpuBlurUtils.cpp


注:本文中的SkRect::offsetTo方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。