Index: src/image/SkSurface_Gpu.cpp |
diff --git a/src/image/SkSurface_Gpu.cpp b/src/image/SkSurface_Gpu.cpp |
index 6cd741d149e77ac0af4dd119beb5f7660f74fda4..34aec2b7bbb0c43ba29779be2c47f2ab3677266a 100644 |
--- a/src/image/SkSurface_Gpu.cpp |
+++ b/src/image/SkSurface_Gpu.cpp |
@@ -44,9 +44,10 @@ SkSurface* SkSurface_Gpu::onNewSurface(const SkImageInfo& info) { |
&this->props()); |
} |
-SkImage* SkSurface_Gpu::onNewImageSnapshot() { |
+SkImage* SkSurface_Gpu::onNewImageSnapshot(Budgeted budgeted) { |
const int sampleCount = fDevice->accessRenderTarget()->numSamples(); |
- SkImage* image = SkNewImageFromBitmapTexture(fDevice->accessBitmap(false), sampleCount); |
+ SkImage* image = SkNewImageFromBitmapTexture(fDevice->accessBitmap(false), sampleCount, |
+ budgeted); |
if (image) { |
as_IB(image)->initWithProps(this->props()); |
} |
@@ -63,9 +64,11 @@ void SkSurface_Gpu::onDraw(SkCanvas* canvas, SkScalar x, SkScalar y, |
// doesn't force an OpenGL flush. |
void SkSurface_Gpu::onCopyOnWrite(ContentChangeMode mode) { |
GrRenderTarget* rt = fDevice->accessRenderTarget(); |
- // are we sharing our render target with the image? |
- SkASSERT(this->getCachedImage()); |
- if (rt->asTexture() == SkTextureImageGetTexture(this->getCachedImage())) { |
+ // are we sharing our render target with the image? Note this call should never create a new |
+ // image because onCopyOnWrite is only called when there is a cached image. |
+ SkImage* image = this->getCachedImage(kNo_Budgeted); |
+ SkASSERT(image); |
+ if (rt->asTexture() == SkTextureImageGetTexture(image)) { |
GrRenderTarget* oldRT = this->fDevice->accessRenderTarget(); |
SkSurface::Budgeted budgeted = oldRT->cacheAccess().isBudgeted() ? kYes_Budgeted : |
kNo_Budgeted; |
@@ -82,10 +85,7 @@ void SkSurface_Gpu::onCopyOnWrite(ContentChangeMode mode) { |
this->getCachedCanvas()->setRootDevice(newDevice); |
SkRefCnt_SafeAssign(fDevice, newDevice.get()); |
- // For now we always treat the image snapshots as budgeted. We could make newImageSnapshot |
- // take a Budgeted param. |
- oldRT->cacheAccess().makeBudgeted(); |
- |
+ SkTextureImageApplyBudgetedDecision(image); |
} else if (kDiscard_ContentChangeMode == mode) { |
this->SkSurface_Gpu::onDiscard(); |
} |