Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(25)

Unified Diff: src/image/SkImage_Gpu.cpp

Issue 20354003: Make SkImage_Gpu share it's pixelref with the surface to prevent premature return to scratch pool. (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « include/core/SkImage.h ('k') | src/image/SkSurface_Gpu.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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);
-}
« no previous file with comments | « include/core/SkImage.h ('k') | src/image/SkSurface_Gpu.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698