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

Unified Diff: src/image/SkSurface_Gpu.cpp

Issue 872543002: Take budgeted param when snapping new image. (Closed) Base URL: https://skia.googlesource.com/skia.git@budgeted
Patch Set: Address comment and rebase Created 5 years, 11 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 | « src/image/SkSurface_Gpu.h ('k') | src/image/SkSurface_Raster.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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();
}
« no previous file with comments | « src/image/SkSurface_Gpu.h ('k') | src/image/SkSurface_Raster.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698