Chromium Code Reviews| Index: src/gpu/SkGpuDevice.cpp |
| diff --git a/src/gpu/SkGpuDevice.cpp b/src/gpu/SkGpuDevice.cpp |
| index 6a317d5edc057a36aa9a090c26152a42bb4f25fb..b18a6e051a10449da196aa31e4a722e6433e71ae 100644 |
| --- a/src/gpu/SkGpuDevice.cpp |
| +++ b/src/gpu/SkGpuDevice.cpp |
| @@ -13,6 +13,7 @@ |
| #include "GrFontScaler.h" |
| #include "GrGpu.h" |
| #include "GrGpuResourcePriv.h" |
| +#include "GrImageIDTextureAdjuster.h" |
| #include "GrLayerHoister.h" |
| #include "GrRecordReplaceDraw.h" |
| #include "GrStrokeInfo.h" |
| @@ -841,13 +842,26 @@ void SkGpuDevice::drawBitmap(const SkDraw& origDraw, |
| const SkBitmap& bitmap, |
| const SkMatrix& m, |
| const SkPaint& paint) { |
| + |
| + GrTexture* texture = bitmap.getTexture(); |
| + if (texture) { |
| + CHECK_SHOULD_DRAW(origDraw); |
| + bool alphaBitmap = kAlpha_8_SkColorType == bitmap.colorType(); |
| + GrBitmapTextureAdjuster adjuster(&bitmap); |
| + SkMatrix viewMatrix; |
| + viewMatrix.setConcat(*origDraw.fMatrix, m); |
| + this->drawTextureAdjuster(&adjuster, alphaBitmap, nullptr, nullptr, |
| + SkCanvas::kFast_SrcRectConstraint, viewMatrix, fClip, paint); |
| + return; |
| + } |
| SkMatrix concat; |
| SkTCopyOnFirstWrite<SkDraw> draw(origDraw); |
| if (!m.isIdentity()) { |
| concat.setConcat(*draw->fMatrix, m); |
| draw.writable()->fMatrix = &concat; |
| } |
| - this->drawBitmapCommon(*draw, bitmap, nullptr, nullptr, paint, SkCanvas::kStrict_SrcRectConstraint); |
| + this->drawBitmapCommon(*draw, bitmap, nullptr, nullptr, paint, |
| + SkCanvas::kStrict_SrcRectConstraint); |
| } |
| // This method outsets 'iRect' by 'outset' all around and then clamps its extents to |
| @@ -1184,7 +1198,7 @@ void SkGpuDevice::drawTiledBitmap(const SkBitmap& bitmap, |
| const SkRect& srcRect, |
| const SkIRect& clippedSrcIRect, |
| const GrTextureParams& params, |
| - const SkPaint& paint, |
| + const SkPaint& origPaint, |
| SkCanvas::SrcRectConstraint constraint, |
| int tileSize, |
| bool bicubic) { |
| @@ -1193,6 +1207,15 @@ void SkGpuDevice::drawTiledBitmap(const SkBitmap& bitmap, |
| // at each tile in cases where 'bitmap' holds an SkDiscardablePixelRef that |
| // is larger than the limit of the discardable memory pool. |
| SkAutoLockPixels alp(bitmap); |
| + |
| + const SkPaint* paint = &origPaint; |
| + SkPaint tempPaint; |
| + if (origPaint.isAntiAlias() && !fRenderTarget->isUnifiedMultisampled()) { |
| + // Drop antialiasing to avoid seams at tile boundaries. |
| + tempPaint = origPaint; |
| + tempPaint.setAntiAlias(false); |
| + paint = &tempPaint; |
| + } |
| SkRect clippedSrcRect = SkRect::Make(clippedSrcIRect); |
| int nx = bitmap.width() / tileSize; |
| @@ -1254,7 +1277,7 @@ void SkGpuDevice::drawTiledBitmap(const SkBitmap& bitmap, |
| viewM, |
| tileR, |
| paramsTemp, |
| - paint, |
| + *paint, |
| constraint, |
| bicubic, |
| needsTextureDomain); |
| @@ -1482,6 +1505,16 @@ void SkGpuDevice::drawSprite(const SkDraw& draw, const SkBitmap& bitmap, |
| void SkGpuDevice::drawBitmapRect(const SkDraw& origDraw, const SkBitmap& bitmap, |
| const SkRect* src, const SkRect& dst, |
| const SkPaint& paint, SkCanvas::SrcRectConstraint constraint) { |
|
robertphillips
2015/11/06 20:54:51
What is 'bm' here for ?
bsalomon
2015/11/09 19:35:22
Done.
|
| + SkBitmap bm; |
| + if (GrTexture* tex = bitmap.getTexture()) { |
| + CHECK_SHOULD_DRAW(origDraw); |
|
robertphillips
2015/11/06 20:54:51
v.low priority: Should we make the other sites use
bsalomon
2015/11/09 19:35:22
Done.
|
| + bool alphaOnly = GrPixelConfigIsAlphaOnly(tex->config()); |
| + GrBitmapTextureAdjuster adjuster(&bitmap); |
| + this->drawTextureAdjuster(&adjuster, alphaOnly, src, &dst, constraint, *origDraw.fMatrix, |
| + fClip, paint); |
| + return; |
| + } |
| + |
| SkMatrix matrix; |
| SkRect bitmapBounds, tmpSrc; |
| @@ -1643,7 +1676,14 @@ void SkGpuDevice::drawImage(const SkDraw& draw, const SkImage* image, SkScalar x |
| const SkPaint& paint) { |
| SkBitmap bm; |
| if (GrTexture* tex = as_IB(image)->peekTexture()) { |
| - GrWrapTextureInBitmap(tex, image->width(), image->height(), image->isOpaque(), &bm); |
| + CHECK_SHOULD_DRAW(draw); |
| + SkMatrix viewMatrix = *draw.fMatrix; |
| + viewMatrix.preTranslate(x, y); |
| + bool alphaBitmap = GrPixelConfigIsAlphaOnly(tex->config()); |
| + GrImageTextureAdjuster adjuster(as_IB(image)); |
|
robertphillips
2015/11/06 20:54:51
xtra ' ' ?
bsalomon
2015/11/09 19:35:22
Done.
|
| + this->drawTextureAdjuster(&adjuster , alphaBitmap, nullptr, nullptr, |
| + SkCanvas::kFast_SrcRectConstraint, viewMatrix, fClip, paint); |
| + return; |
| } else { |
| if (this->shouldTileImage(image, nullptr, SkCanvas::kFast_SrcRectConstraint, |
| paint.getFilterQuality(), *draw.fMatrix)) { |
| @@ -1665,21 +1705,24 @@ void SkGpuDevice::drawImageRect(const SkDraw& draw, const SkImage* image, const |
| SkCanvas::SrcRectConstraint constraint) { |
| SkBitmap bm; |
| if (GrTexture* tex = as_IB(image)->peekTexture()) { |
| - GrWrapTextureInBitmap(tex, image->width(), image->height(), image->isOpaque(), &bm); |
| + CHECK_SHOULD_DRAW(draw); |
| + GrImageTextureAdjuster adjuster(as_IB(image)); |
| + bool alphaBitmap = GrPixelConfigIsAlphaOnly(tex->config()); |
| + this->drawTextureAdjuster(&adjuster, alphaBitmap, src, &dst, constraint, *draw.fMatrix, |
| + fClip, paint); |
| + return; |
| + } |
|
robertphillips
2015/11/06 20:54:51
mv 'bm' down to here ?
bsalomon
2015/11/09 19:35:22
Done.
|
| + SkMatrix viewMatrix = *draw.fMatrix; |
| + viewMatrix.preScale(dst.width() / (src ? src->width() : image->width()), |
| + dst.height() / (src ? src->height() : image->height())); |
| + if (this->shouldTileImage(image, src, constraint, paint.getFilterQuality(), viewMatrix)) { |
| + // only support tiling as bitmap at the moment, so force raster-version |
| + if (!as_IB(image)->getROPixels(&bm)) { |
| + return; |
| + } |
| } else { |
| - SkMatrix viewMatrix = *draw.fMatrix; |
| - viewMatrix.preScale(dst.width() / (src ? src->width() : image->width()), |
| - dst.height() / (src ? src->height() : image->height())); |
| - |
| - if (this->shouldTileImage(image, src, constraint, paint.getFilterQuality(), viewMatrix)) { |
| - // only support tiling as bitmap at the moment, so force raster-version |
| - if (!as_IB(image)->getROPixels(&bm)) { |
| - return; |
| - } |
| - } else { |
| - if (!wrap_as_bm(this->context(), image, &bm)) { |
| - return; |
| - } |
| + if (!wrap_as_bm(this->context(), image, &bm)) { |
| + return; |
| } |
| } |
| this->drawBitmapRect(draw, bm, src, dst, paint, constraint); |