Chromium Code Reviews| Index: src/gpu/GrImageIDTextureAdjuster.cpp |
| diff --git a/src/gpu/GrImageIDTextureAdjuster.cpp b/src/gpu/GrImageIDTextureAdjuster.cpp |
| index 525223cf7773470025de2981d4f43d57cd4d3202..321a42a3053d37e94905d3f8df59b31247080bf6 100644 |
| --- a/src/gpu/GrImageIDTextureAdjuster.cpp |
| +++ b/src/gpu/GrImageIDTextureAdjuster.cpp |
| @@ -7,10 +7,12 @@ |
| #include "GrImageIDTextureAdjuster.h" |
| +#include "GrContext.h" |
| +#include "GrGpuResourcePriv.h" |
| #include "SkBitmap.h" |
| #include "SkGrPriv.h" |
| #include "SkImage_Base.h" |
| - |
| +#include "SkPixelRef.h" |
| GrBitmapTextureAdjuster::GrBitmapTextureAdjuster(const SkBitmap* bmp) |
| : INHERITED(bmp->getTexture(), SkIRect::MakeWH(bmp->width(), bmp->height())) |
| @@ -52,3 +54,46 @@ void GrImageTextureAdjuster::makeCopyKey(const CopyParams& params, GrUniqueKey* |
| void GrImageTextureAdjuster::didCacheCopy(const GrUniqueKey& copyKey) { |
| // We don't currently have a mechanism for notifications on Images! |
| } |
| + |
| +////////////////////////////////////////////////////////////////////////////// |
| + |
| +GrBitmapTextureMaker::GrBitmapTextureMaker(GrContext* context, const SkBitmap& bitmap) |
| + : INHERITED(context, bitmap.width(), bitmap.height()) |
| + , fBitmap(bitmap) |
|
robertphillips
2015/11/18 13:58:35
prev line for the '{' ?
bsalomon
2015/11/18 18:05:37
Done.
|
| +{ |
| + SkASSERT(!bitmap.getTexture()); |
| + if (!bitmap.isVolatile()) { |
| + SkIPoint origin = bitmap.pixelRefOrigin(); |
| + SkIRect subset = SkIRect::MakeXYWH(origin.fX, origin.fY, bitmap.width(), |
| + bitmap.height()); |
| + GrMakeKeyFromImageID(&fOriginalKey, bitmap.pixelRef()->getGenerationID(), subset); |
| + } |
| +} |
| + |
| +GrTexture* GrBitmapTextureMaker::refOriginalTexture() { |
| + GrTexture* tex; |
| + |
| + if (fOriginalKey.isValid()) { |
| + tex = this->context()->textureProvider()->findAndRefTextureByUniqueKey(fOriginalKey); |
| + if (tex) { |
| + return tex; |
| + } |
| + } |
| + |
| + tex = GrUploadBitmapToTexture(this->context(), fBitmap); |
| + if (tex && fOriginalKey.isValid()) { |
| + tex->resourcePriv().setUniqueKey(fOriginalKey); |
| + GrInstallBitmapUniqueKeyInvalidator(fOriginalKey, fBitmap.pixelRef()); |
| + } |
| + return tex; |
| +} |
| + |
| +void GrBitmapTextureMaker::makeCopyKey(const CopyParams& copyParams, GrUniqueKey* copyKey) { |
| + if (fOriginalKey.isValid()) { |
| + MakeCopyKeyFromOrigKey(fOriginalKey, copyParams, copyKey); |
| + } |
| +} |
| + |
| +void GrBitmapTextureMaker::didCacheCopy(const GrUniqueKey& copyKey) { |
| + GrInstallBitmapUniqueKeyInvalidator(copyKey, fBitmap.pixelRef()); |
| +} |