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

Side by Side Diff: src/image/SkSurface_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, 4 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/image/SkImage_Gpu.cpp ('k') | tests/SurfaceTest.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2012 Google Inc. 2 * Copyright 2012 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "SkSurface_Base.h" 8 #include "SkSurface_Base.h"
9 #include "SkImagePriv.h" 9 #include "SkImagePriv.h"
10 #include "SkCanvas.h" 10 #include "SkCanvas.h"
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 return SkNEW_ARGS(SkCanvas, (fDevice)); 65 return SkNEW_ARGS(SkCanvas, (fDevice));
66 } 66 }
67 67
68 SkSurface* SkSurface_Gpu::onNewSurface(const SkImage::Info& info) { 68 SkSurface* SkSurface_Gpu::onNewSurface(const SkImage::Info& info) {
69 GrRenderTarget* rt = fDevice->accessRenderTarget(); 69 GrRenderTarget* rt = fDevice->accessRenderTarget();
70 int sampleCount = rt->numSamples(); 70 int sampleCount = rt->numSamples();
71 return SkSurface::NewRenderTarget(fDevice->context(), info, sampleCount); 71 return SkSurface::NewRenderTarget(fDevice->context(), info, sampleCount);
72 } 72 }
73 73
74 SkImage* SkSurface_Gpu::onNewImageSnapshot() { 74 SkImage* SkSurface_Gpu::onNewImageSnapshot() {
75 75 return SkImage::NewTexture(fDevice->accessBitmap(false));
76 GrRenderTarget* rt = fDevice->accessRenderTarget();
77
78 return SkImage::NewTexture(rt->asTexture());
79 } 76 }
80 77
81 void SkSurface_Gpu::onDraw(SkCanvas* canvas, SkScalar x, SkScalar y, 78 void SkSurface_Gpu::onDraw(SkCanvas* canvas, SkScalar x, SkScalar y,
82 const SkPaint* paint) { 79 const SkPaint* paint) {
83 canvas->drawBitmap(fDevice->accessBitmap(false), x, y, paint); 80 canvas->drawBitmap(fDevice->accessBitmap(false), x, y, paint);
84 } 81 }
85 82
86 // Create a new SkGpuDevice and, if necessary, copy the contents of the old 83 // Create a new SkGpuDevice and, if necessary, copy the contents of the old
87 // device into it. Note that this flushes the SkGpuDevice but 84 // device into it. Note that this flushes the SkGpuDevice but
88 // doesn't force an OpenGL flush. 85 // doesn't force an OpenGL flush.
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 desc.fConfig = SkBitmapConfig2GrPixelConfig(config); 129 desc.fConfig = SkBitmapConfig2GrPixelConfig(config);
133 desc.fSampleCnt = sampleCount; 130 desc.fSampleCnt = sampleCount;
134 131
135 SkAutoTUnref<GrTexture> tex(ctx->createUncachedTexture(desc, NULL, 0)); 132 SkAutoTUnref<GrTexture> tex(ctx->createUncachedTexture(desc, NULL, 0));
136 if (NULL == tex) { 133 if (NULL == tex) {
137 return NULL; 134 return NULL;
138 } 135 }
139 136
140 return SkNEW_ARGS(SkSurface_Gpu, (ctx, tex->asRenderTarget())); 137 return SkNEW_ARGS(SkSurface_Gpu, (ctx, tex->asRenderTarget()));
141 } 138 }
OLDNEW
« no previous file with comments | « src/image/SkImage_Gpu.cpp ('k') | tests/SurfaceTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698