Index: src/image/SkImage_Gpu.cpp |
=================================================================== |
--- src/image/SkImage_Gpu.cpp (revision 10357) |
+++ src/image/SkImage_Gpu.cpp (working copy) |
@@ -17,7 +17,7 @@ |
public: |
SK_DECLARE_INST_COUNT(SkImage_Gpu) |
- SkImage_Gpu(GrTexture*); |
+ explicit SkImage_Gpu(const SkBitmap&); |
virtual ~SkImage_Gpu(); |
virtual void onDraw(SkCanvas*, SkScalar x, SkScalar y, const SkPaint*) SK_OVERRIDE; |
@@ -28,12 +28,9 @@ |
return false; |
} |
- GrTexture* getTexture() { return fTexture; } |
+ GrTexture* getTexture() { return fBitmap.getTexture(); } |
- void setTexture(GrTexture* texture); |
- |
private: |
- GrTexture* fTexture; |
SkBitmap fBitmap; |
typedef SkImage_Base INHERITED; |
@@ -43,18 +40,13 @@ |
/////////////////////////////////////////////////////////////////////////////// |
-SkImage_Gpu::SkImage_Gpu(GrTexture* texture) |
- : INHERITED(texture->width(), texture->height()) |
- , fTexture(texture) { |
- |
- SkASSERT(NULL != fTexture); |
- fTexture->ref(); |
- fBitmap.setConfig(SkBitmap::kARGB_8888_Config, fTexture->width(), fTexture->height()); |
- fBitmap.setPixelRef(SkNEW_ARGS(SkGrPixelRef, (fTexture)))->unref(); |
+SkImage_Gpu::SkImage_Gpu(const SkBitmap& bitmap) |
+ : INHERITED(bitmap.width(), bitmap.height()) |
+ , fBitmap(bitmap) { |
+ SkASSERT(NULL != fBitmap.getTexture()); |
} |
SkImage_Gpu::~SkImage_Gpu() { |
- SkSafeUnref(fTexture); |
} |
void SkImage_Gpu::onDraw(SkCanvas* canvas, SkScalar x, SkScalar y, |
@@ -68,33 +60,19 @@ |
} |
GrTexture* SkImage_Gpu::onGetTexture() { |
- return fTexture; |
+ return fBitmap.getTexture(); |
} |
-void SkImage_Gpu::setTexture(GrTexture* texture) { |
- |
- if (texture == fTexture) { |
- return; |
- } |
- |
- SkRefCnt_SafeAssign(fTexture, texture); |
- fBitmap.setPixelRef(new SkGrPixelRef(texture))->unref(); |
-} |
- |
/////////////////////////////////////////////////////////////////////////////// |
-SkImage* SkImage::NewTexture(GrTexture* texture) { |
- if (NULL == texture) { |
+SkImage* SkImage::NewTexture(const SkBitmap& bitmap) { |
+ if (NULL == bitmap.getTexture()) { |
return NULL; |
} |
- return SkNEW_ARGS(SkImage_Gpu, (texture)); |
+ return SkNEW_ARGS(SkImage_Gpu, (bitmap)); |
} |
GrTexture* SkTextureImageGetTexture(SkImage* image) { |
return ((SkImage_Gpu*)image)->getTexture(); |
} |
- |
-void SkTextureImageSetTexture(SkImage* image, GrTexture* texture) { |
- ((SkImage_Gpu*)image)->setTexture(texture); |
-} |