diff options
author | Brian Salomon <bsalomon@google.com> | 2017-08-18 13:05:54 +0000 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2017-08-18 13:06:00 +0000 |
commit | ceef4fb5c498003be77a32a46cedfbf5da22a274 (patch) | |
tree | fcde095e8fc750e58522fb4dcf6415fce28fbe39 /src/gpu/SkGpuDevice.cpp | |
parent | 3fd295550f8c4fecd4bc61ce916738d49310eb67 (diff) |
Revert "Add GrTextureOp and use to implement SkGpuDevice::drawImage[Rect]() when possible"
This reverts commit 3fd295550f8c4fecd4bc61ce916738d49310eb67.
Reason for revert: breaking things
Original change's description:
> Add GrTextureOp and use to implement SkGpuDevice::drawImage[Rect]() when possible
>
> This op draws a texture rectangle in src over blending with no edge antialiasing. It less powerful than NonAAFillRectOp/GrPaint but has less CPU overhead.
>
> Change-Id: Ia6107bb67c1c2a83de14c665aff64b0de2750fba
> Reviewed-on: https://skia-review.googlesource.com/33802
> Commit-Queue: Brian Salomon <bsalomon@google.com>
> Reviewed-by: Robert Phillips <robertphillips@google.com>
TBR=djsollen@google.com,bsalomon@google.com,robertphillips@google.com,brianosman@google.com
Change-Id: I9cdbeeac15b17d2d6b3385560ed826397c0373c6
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://skia-review.googlesource.com/36220
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Brian Salomon <bsalomon@google.com>
Diffstat (limited to 'src/gpu/SkGpuDevice.cpp')
-rw-r--r-- | src/gpu/SkGpuDevice.cpp | 91 |
1 files changed, 45 insertions, 46 deletions
diff --git a/src/gpu/SkGpuDevice.cpp b/src/gpu/SkGpuDevice.cpp index 0cf2ae5893..2d024b014b 100644 --- a/src/gpu/SkGpuDevice.cpp +++ b/src/gpu/SkGpuDevice.cpp @@ -6,6 +6,7 @@ */ #include "SkGpuDevice.h" + #include "GrBitmapTextureMaker.h" #include "GrBlurUtils.h" #include "GrContext.h" @@ -758,8 +759,10 @@ bool SkGpuDevice::shouldTileImage(const SkImage* image, const SkRect* srcRectPtr const SkMatrix& viewMatrix, const SkMatrix& srcToDstRect) const { ASSERT_SINGLE_OWNER - // If image is explicitly texture backed then we shouldn't get here. - SkASSERT(!image->isTextureBacked()); + // if image is explictly texture backed then just use the texture + if (image->isTextureBacked()) { + return false; + } GrSamplerParams params; bool doBicubic; @@ -840,7 +843,7 @@ void SkGpuDevice::drawBitmap(const SkBitmap& bitmap, } GrBitmapTextureMaker maker(fContext.get(), bitmap); this->drawTextureProducer(&maker, nullptr, nullptr, SkCanvas::kStrict_SrcRectConstraint, - viewMatrix, paint); + viewMatrix, this->clip(), paint); } // This method outsets 'iRect' by 'outset' all around and then clamps its extents to @@ -1199,7 +1202,7 @@ void SkGpuDevice::drawBitmapRect(const SkBitmap& bitmap, } } GrBitmapTextureMaker maker(fContext.get(), bitmap); - this->drawTextureProducer(&maker, src, dst, constraint, this->ctm(), paint); + this->drawTextureProducer(&maker, src, dst, constraint, this->ctm(), this->clip(), paint); } sk_sp<SkSpecialImage> SkGpuDevice::makeSpecial(const SkBitmap& bitmap) { @@ -1286,50 +1289,52 @@ void SkGpuDevice::drawDevice(SkBaseDevice* device, this->drawSpecial(srcImg.get(), left, top, paint, nullptr, SkMatrix::I()); } -void SkGpuDevice::drawImage(const SkImage* image, SkScalar x, SkScalar y, const SkPaint& paint) { +void SkGpuDevice::drawImage(const SkImage* image, SkScalar x, SkScalar y, + const SkPaint& paint) { ASSERT_SINGLE_OWNER SkMatrix viewMatrix = this->ctm(); viewMatrix.preTranslate(x, y); uint32_t pinnedUniqueID; + if (sk_sp<GrTextureProxy> proxy = as_IB(image)->refPinnedTextureProxy(&pinnedUniqueID)) { - this->drawPinnedTextureProxy(std::move(proxy), pinnedUniqueID, as_IB(image)->colorSpace(), - image->alphaType(), nullptr, nullptr, - SkCanvas::kFast_SrcRectConstraint, viewMatrix, paint); + GrTextureAdjuster adjuster(this->context(), std::move(proxy), + image->alphaType(), image->bounds(), + pinnedUniqueID, as_IB(image)->onImageInfo().colorSpace()); + this->drawTextureProducer(&adjuster, nullptr, nullptr, SkCanvas::kFast_SrcRectConstraint, + viewMatrix, this->clip(), paint); return; - } - SkBitmap bm; - if (this->shouldTileImage(image, nullptr, SkCanvas::kFast_SrcRectConstraint, - paint.getFilterQuality(), viewMatrix, SkMatrix::I())) { - // only support tiling as bitmap at the moment, so force raster-version - if (!as_IB(image)->getROPixels(&bm, fRenderTargetContext->getColorSpace())) { - return; + } else { + SkBitmap bm; + if (this->shouldTileImage(image, nullptr, SkCanvas::kFast_SrcRectConstraint, + paint.getFilterQuality(), this->ctm(), SkMatrix::I())) { + // only support tiling as bitmap at the moment, so force raster-version + if (!as_IB(image)->getROPixels(&bm, fRenderTargetContext->getColorSpace())) { + return; + } + this->drawBitmap(bm, x, y, paint); + } else if (image->isLazyGenerated()) { + GrImageTextureMaker maker(fContext.get(), image, SkImage::kAllow_CachingHint); + this->drawTextureProducer(&maker, nullptr, nullptr, SkCanvas::kFast_SrcRectConstraint, + viewMatrix, this->clip(), paint); + } else if (as_IB(image)->getROPixels(&bm, fRenderTargetContext->getColorSpace())) { + GrBitmapTextureMaker maker(fContext.get(), bm); + this->drawTextureProducer(&maker, nullptr, nullptr, SkCanvas::kFast_SrcRectConstraint, + viewMatrix, this->clip(), paint); } - this->drawBitmap(bm, x, y, paint); - return; - } - if (image->isLazyGenerated()) { - GrImageTextureMaker maker(fContext.get(), image, SkImage::kAllow_CachingHint); - this->drawTextureMaker(&maker, image->width(), image->height(), nullptr, nullptr, - SkCanvas::kFast_SrcRectConstraint, viewMatrix, paint); - return; - } - if (as_IB(image)->getROPixels(&bm, fRenderTargetContext->getColorSpace())) { - GrBitmapTextureMaker maker(fContext.get(), bm); - this->drawTextureMaker(&maker, image->width(), image->height(), nullptr, nullptr, - SkCanvas::kFast_SrcRectConstraint, viewMatrix, paint); } } -void SkGpuDevice::drawImageRect(const SkImage* image, const SkRect* src, const SkRect& dst, - const SkPaint& paint, SkCanvas::SrcRectConstraint constraint) { +void SkGpuDevice::drawImageRect(const SkImage* image, const SkRect* src, + const SkRect& dst, const SkPaint& paint, + SkCanvas::SrcRectConstraint constraint) { ASSERT_SINGLE_OWNER uint32_t pinnedUniqueID; - if (!src || src->contains(image->bounds())) { - constraint = SkCanvas::kFast_SrcRectConstraint; - } if (sk_sp<GrTextureProxy> proxy = as_IB(image)->refPinnedTextureProxy(&pinnedUniqueID)) { - this->drawPinnedTextureProxy(std::move(proxy), pinnedUniqueID, as_IB(image)->colorSpace(), - image->alphaType(), src, &dst, constraint, this->ctm(), paint); + GrTextureAdjuster adjuster(this->context(), std::move(proxy), + image->alphaType(), image->bounds(), pinnedUniqueID, + as_IB(image)->onImageInfo().colorSpace()); + this->drawTextureProducer(&adjuster, src, &dst, constraint, this->ctm(), this->clip(), + paint); return; } SkBitmap bm; @@ -1343,18 +1348,12 @@ void SkGpuDevice::drawImageRect(const SkImage* image, const SkRect* src, const S return; } this->drawBitmapRect(bm, src, dst, paint, constraint); - return; - } - if (image->isLazyGenerated()) { + } else if (image->isLazyGenerated()) { GrImageTextureMaker maker(fContext.get(), image, SkImage::kAllow_CachingHint); - this->drawTextureMaker(&maker, image->width(), image->height(), src, &dst, constraint, - this->ctm(), paint); - return; - } - if (as_IB(image)->getROPixels(&bm, fRenderTargetContext->getColorSpace())) { + this->drawTextureProducer(&maker, src, &dst, constraint, this->ctm(), this->clip(), paint); + } else if (as_IB(image)->getROPixels(&bm, fRenderTargetContext->getColorSpace())) { GrBitmapTextureMaker maker(fContext.get(), bm); - this->drawTextureMaker(&maker, image->width(), image->height(), src, &dst, constraint, - this->ctm(), paint); + this->drawTextureProducer(&maker, src, &dst, constraint, this->ctm(), this->clip(), paint); } } @@ -1374,7 +1373,7 @@ void SkGpuDevice::drawProducerNine(GrTextureProducer* producer, SkRect srcR, dstR; while (iter.next(&srcR, &dstR)) { this->drawTextureProducer(producer, &srcR, &dstR, SkCanvas::kStrict_SrcRectConstraint, - this->ctm(), paint); + this->ctm(), this->clip(), paint); } return; } |