Index: src/gpu/GrImageIDTextureAdjuster.cpp |
diff --git a/src/gpu/GrImageIDTextureAdjuster.cpp b/src/gpu/GrImageIDTextureAdjuster.cpp |
index 525223cf7773470025de2981d4f43d57cd4d3202..c37c02277589c2b0f4a543cee7b46b068a21aea4 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,45 @@ 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) { |
+ 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()); |
+} |