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

Unified Diff: src/image/SkSurface_Gpu.cpp

Issue 13195002: Unit test improvements to fully validate the SkImage contract (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Created 7 years, 8 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/SkImage_Picture.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/image/SkSurface_Gpu.cpp
===================================================================
--- src/image/SkSurface_Gpu.cpp (revision 8614)
+++ src/image/SkSurface_Gpu.cpp (working copy)
@@ -83,31 +83,24 @@
canvas->drawBitmap(fDevice->accessBitmap(false), x, y, paint);
}
-// Copy the contents of the SkGpuDevice into a new texture and give that
-// texture to the SkImage. Note that this flushes the SkGpuDevice but
+// Create a new SkGpuDevice and, if necessary, copy the contents of the old
+// device into it. Note that this flushes the SkGpuDevice but
// doesn't force an OpenGL flush.
-void SkSurface_Gpu::onCopyOnWrite(SkImage* image, SkCanvas*) {
+void SkSurface_Gpu::onCopyOnWrite(SkImage* image, SkCanvas* canvas) {
GrRenderTarget* rt = (GrRenderTarget*) fDevice->accessRenderTarget();
// are we sharing our render target with the image?
if (rt->asTexture() == SkTextureImageGetTexture(image)) {
- GrTextureDesc desc;
- // copyTexture requires a render target as the destination
- desc.fFlags = kRenderTarget_GrTextureFlagBit;
- desc.fWidth = fDevice->width();
- desc.fHeight = fDevice->height();
- desc.fConfig = SkBitmapConfig2GrPixelConfig(fDevice->config());
- desc.fSampleCnt = 0;
-
- SkAutoTUnref<GrTexture> tex(fDevice->context()->createUncachedTexture(desc, NULL, 0));
- if (NULL == tex) {
- SkTextureImageSetTexture(image, NULL);
- return;
- }
-
- fDevice->context()->copyTexture(rt->asTexture(), tex->asRenderTarget());
-
- SkTextureImageSetTexture(image, tex);
+ SkGpuDevice* newDevice = static_cast<SkGpuDevice*>(
+ fDevice->createCompatibleDevice(fDevice->config(), fDevice->width(),
+ fDevice->height(), fDevice->isOpaque()));
+ SkAutoTUnref<SkGpuDevice> aurd(newDevice);
+ fDevice->context()->copyTexture(rt->asTexture(),
+ (GrRenderTarget*)newDevice->accessRenderTarget());
+ SkASSERT(NULL != canvas);
+ SkASSERT(canvas->getDevice() == fDevice);
+ canvas->setDevice(newDevice);
+ SkRefCnt_SafeAssign(fDevice, newDevice);
}
}
« no previous file with comments | « src/image/SkImage_Picture.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698