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

Side by Side Diff: src/image/SkSurface_Gpu.cpp

Issue 141443009: use new instead of createCompatibleDevice, since we know the subclass we want (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 6 years, 10 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 | « no previous file | no next file » | 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 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 } 78 }
79 79
80 // Create a new SkGpuDevice and, if necessary, copy the contents of the old 80 // Create a new SkGpuDevice and, if necessary, copy the contents of the old
81 // device into it. Note that this flushes the SkGpuDevice but 81 // device into it. Note that this flushes the SkGpuDevice but
82 // doesn't force an OpenGL flush. 82 // doesn't force an OpenGL flush.
83 void SkSurface_Gpu::onCopyOnWrite(ContentChangeMode mode) { 83 void SkSurface_Gpu::onCopyOnWrite(ContentChangeMode mode) {
84 GrRenderTarget* rt = fDevice->accessRenderTarget(); 84 GrRenderTarget* rt = fDevice->accessRenderTarget();
85 // are we sharing our render target with the image? 85 // are we sharing our render target with the image?
86 SkASSERT(NULL != this->getCachedImage()); 86 SkASSERT(NULL != this->getCachedImage());
87 if (rt->asTexture() == SkTextureImageGetTexture(this->getCachedImage())) { 87 if (rt->asTexture() == SkTextureImageGetTexture(this->getCachedImage())) {
88 SkGpuDevice* newDevice = static_cast<SkGpuDevice*>( 88 SkAutoTUnref<SkGpuDevice> newDevice(SkNEW_ARGS(SkGpuDevice,
89 fDevice->createCompatibleDevice(fDevice->config(), fDevice->width(), 89 (fDevice->context(), fDevice->config(), fDevice->width(),
90 fDevice->height(), fDevice->isOpaque())); 90 fDevice->height(), rt->numSamples())));
91 SkAutoTUnref<SkGpuDevice> aurd(newDevice); 91
92 if (kRetain_ContentChangeMode == mode) { 92 if (kRetain_ContentChangeMode == mode) {
93 fDevice->context()->copyTexture(rt->asTexture(), 93 fDevice->context()->copyTexture(rt->asTexture(),
94 reinterpret_cast<GrRenderTarget*>(newDevice->accessRenderTarget( ))); 94 reinterpret_cast<GrRenderTarget*>(newDevice->accessRenderTarget( )));
95 } 95 }
96 SkASSERT(NULL != this->getCachedCanvas()); 96 SkASSERT(NULL != this->getCachedCanvas());
97 SkASSERT(this->getCachedCanvas()->getDevice() == fDevice); 97 SkASSERT(this->getCachedCanvas()->getDevice() == fDevice);
98 this->getCachedCanvas()->setDevice(newDevice); 98 this->getCachedCanvas()->setDevice(newDevice);
99 SkRefCnt_SafeAssign(fDevice, newDevice); 99 SkRefCnt_SafeAssign(fDevice, newDevice.get());
100 } 100 }
101 } 101 }
102 102
103 /////////////////////////////////////////////////////////////////////////////// 103 ///////////////////////////////////////////////////////////////////////////////
104 104
105 SkSurface* SkSurface::NewRenderTargetDirect(GrRenderTarget* target) { 105 SkSurface* SkSurface::NewRenderTargetDirect(GrRenderTarget* target) {
106 if (NULL == target) { 106 if (NULL == target) {
107 return NULL; 107 return NULL;
108 } 108 }
109 return SkNEW_ARGS(SkSurface_Gpu, (target)); 109 return SkNEW_ARGS(SkSurface_Gpu, (target));
(...skipping 21 matching lines...) Expand all
131 desc.fConfig = SkBitmapConfig2GrPixelConfig(config); 131 desc.fConfig = SkBitmapConfig2GrPixelConfig(config);
132 desc.fSampleCnt = sampleCount; 132 desc.fSampleCnt = sampleCount;
133 133
134 SkAutoTUnref<GrTexture> tex(ctx->createUncachedTexture(desc, NULL, 0)); 134 SkAutoTUnref<GrTexture> tex(ctx->createUncachedTexture(desc, NULL, 0));
135 if (NULL == tex) { 135 if (NULL == tex) {
136 return NULL; 136 return NULL;
137 } 137 }
138 138
139 return SkNEW_ARGS(SkSurface_Gpu, (tex->asRenderTarget())); 139 return SkNEW_ARGS(SkSurface_Gpu, (tex->asRenderTarget()));
140 } 140 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698