Index: src/gpu/SkGpuDevice.cpp |
diff --git a/src/gpu/SkGpuDevice.cpp b/src/gpu/SkGpuDevice.cpp |
index 20e5afef9fc613bad1a5187f52fd13581072cbb1..86c24373618e7df50098e0e4f6c8ab24485f7bea 100644 |
--- a/src/gpu/SkGpuDevice.cpp |
+++ b/src/gpu/SkGpuDevice.cpp |
@@ -67,8 +67,7 @@ enum { kDefaultImageFilterCacheSize = 32 * 1024 * 1024 }; |
/////////////////////////////////////////////////////////////////////////////// |
-// Helper for turning a bitmap into a texture. If the bitmap is GrTexture backed this |
-// just accesses the backing GrTexture. Otherwise, it creates a cached texture |
+// Helper for turning a bitmap into a texture. It creates a cached texture |
// representation and releases it in the destructor. |
class AutoBitmapTexture : public SkNoncopyable { |
bsalomon
2016/07/22 18:06:49
Can we just replace this whole thing with
sk_sp<G
reed1
2016/07/22 21:46:35
Done.
|
public: |
@@ -87,15 +86,9 @@ public: |
const SkBitmap& bitmap, |
const GrTextureParams& params, |
SkSourceGammaTreatment gammaTreatment) { |
- // Either get the texture directly from the bitmap, or else use the cache and |
- // remember to unref it. |
- if (GrTexture* bmpTexture = bitmap.getTexture()) { |
- fTexture.reset(nullptr); |
- return bmpTexture; |
- } else { |
- fTexture.reset(GrRefCachedBitmapTexture(context, bitmap, params, gammaTreatment)); |
- return fTexture.get(); |
- } |
+ // Use the cache and remember to unref it. |
+ fTexture.reset(GrRefCachedBitmapTexture(context, bitmap, params, gammaTreatment)); |
+ return fTexture.get(); |
} |
private: |
@@ -836,11 +829,6 @@ bool SkGpuDevice::shouldTileBitmap(const SkBitmap& bitmap, |
int* tileSize, |
SkIRect* clippedSrcRect) const { |
ASSERT_SINGLE_OWNER |
- // if bitmap is explictly texture backed then just use the texture |
- if (bitmap.getTexture()) { |
- return false; |
- } |
- |
return this->shouldTileImageID(bitmap.getGenerationID(), bitmap.getSubset(), viewMatrix, params, |
srcRectPtr, maxTileSize, tileSize, clippedSrcRect); |
} |
@@ -887,13 +875,7 @@ void SkGpuDevice::drawBitmap(const SkDraw& origDraw, |
CHECK_SHOULD_DRAW(origDraw); |
SkMatrix viewMatrix; |
viewMatrix.setConcat(*origDraw.fMatrix, m); |
- if (bitmap.getTexture()) { |
- GrBitmapTextureAdjuster adjuster(&bitmap); |
- // We can use kFast here because we know texture-backed bitmaps don't support extractSubset. |
- this->drawTextureProducer(&adjuster, nullptr, nullptr, SkCanvas::kFast_SrcRectConstraint, |
- viewMatrix, fClip, paint); |
- return; |
- } |
+ |
int maxTileSize = fContext->caps()->maxTileSize(); |
// The tile code path doesn't currently support AA, so if the paint asked for aa and we could |
@@ -1092,9 +1074,8 @@ void SkGpuDevice::internalDrawBitmap(const SkBitmap& bitmap, |
bitmap.height() <= fContext->caps()->maxTextureSize()); |
// Unless the bitmap is inherently texture-backed, we should be respecting the max tile size |
bsalomon
2016/07/22 18:06:49
Modify comment to remove language about texture-ba
reed1
2016/07/22 21:46:35
Done.
|
// by the time we get here. |
- SkASSERT(bitmap.getTexture() || |
- (bitmap.width() <= fContext->caps()->maxTileSize() && |
- bitmap.height() <= fContext->caps()->maxTileSize())); |
+ SkASSERT(bitmap.width() <= fContext->caps()->maxTileSize() && |
+ bitmap.height() <= fContext->caps()->maxTileSize()); |
GrTexture* texture; |
SkSourceGammaTreatment gammaTreatment = this->surfaceProps().isGammaCorrect() |
@@ -1192,8 +1173,8 @@ void SkGpuDevice::drawSprite(const SkDraw& draw, const SkBitmap& bitmap, |
return; |
} |
- sk_sp<GrTexture> texture = sk_ref_sp(bitmap.getTexture()); |
- if (!texture) { |
+ sk_sp<GrTexture> texture; |
+ { |
SkAutoLockPixels alp(bitmap, true); |
if (!bitmap.readyToDraw()) { |
return; |
@@ -1282,12 +1263,7 @@ void SkGpuDevice::drawBitmapRect(const SkDraw& draw, const SkBitmap& bitmap, |
const SkPaint& paint, SkCanvas::SrcRectConstraint constraint) { |
ASSERT_SINGLE_OWNER |
CHECK_SHOULD_DRAW(draw); |
- if (bitmap.getTexture()) { |
- GrBitmapTextureAdjuster adjuster(&bitmap); |
- this->drawTextureProducer(&adjuster, src, &origDst, constraint, *draw.fMatrix, fClip, |
- paint); |
- return; |
- } |
+ |
// The src rect is inferred to be the bmp bounds if not provided. Otherwise, the src rect must |
// be clipped to the bmp bounds. To determine tiling parameters we need the filter mode which |
// in turn requires knowing the src-to-dst mapping. If the src was clipped to the bmp bounds |
@@ -1366,8 +1342,6 @@ void SkGpuDevice::drawBitmapRect(const SkDraw& draw, const SkBitmap& bitmap, |
} |
sk_sp<SkSpecialImage> SkGpuDevice::makeSpecial(const SkBitmap& bitmap) { |
- SkASSERT(!bitmap.getTexture()); |
- |
SkAutoLockPixels alp(bitmap, true); |
if (!bitmap.readyToDraw()) { |
return nullptr; |
@@ -1576,13 +1550,8 @@ void SkGpuDevice::drawImageNine(const SkDraw& draw, const SkImage* image, |
void SkGpuDevice::drawBitmapNine(const SkDraw& draw, const SkBitmap& bitmap, const SkIRect& center, |
const SkRect& dst, const SkPaint& paint) { |
ASSERT_SINGLE_OWNER |
- if (bitmap.getTexture()) { |
- GrBitmapTextureAdjuster adjuster(&bitmap); |
- this->drawProducerNine(draw, &adjuster, center, dst, paint); |
- } else { |
- GrBitmapTextureMaker maker(fContext, bitmap); |
- this->drawProducerNine(draw, &maker, center, dst, paint); |
- } |
+ GrBitmapTextureMaker maker(fContext, bitmap); |
+ this->drawProducerNine(draw, &maker, center, dst, paint); |
} |
/////////////////////////////////////////////////////////////////////////////// |