| OLD | NEW |
| 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 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 82 // are we sharing our render target with the image? | 82 // are we sharing our render target with the image? |
| 83 SkASSERT(this->getCachedImage()); | 83 SkASSERT(this->getCachedImage()); |
| 84 if (rt->asTexture() == SkTextureImageGetTexture(this->getCachedImage())) { | 84 if (rt->asTexture() == SkTextureImageGetTexture(this->getCachedImage())) { |
| 85 // We call createCompatibleDevice because it uses the texture cache. Thi
s isn't | 85 // We call createCompatibleDevice because it uses the texture cache. Thi
s isn't |
| 86 // necessarily correct (http://skbug.com/2252), but never using the cach
e causes | 86 // necessarily correct (http://skbug.com/2252), but never using the cach
e causes |
| 87 // a Chromium regression. (http://crbug.com/344020) | 87 // a Chromium regression. (http://crbug.com/344020) |
| 88 SkGpuDevice* newDevice = static_cast<SkGpuDevice*>( | 88 SkGpuDevice* newDevice = static_cast<SkGpuDevice*>( |
| 89 fDevice->createCompatibleDevice(fDevice->imageInfo())); | 89 fDevice->createCompatibleDevice(fDevice->imageInfo())); |
| 90 SkAutoTUnref<SkGpuDevice> aurd(newDevice); | 90 SkAutoTUnref<SkGpuDevice> aurd(newDevice); |
| 91 if (kRetain_ContentChangeMode == mode) { | 91 if (kRetain_ContentChangeMode == mode) { |
| 92 fDevice->context()->copyTexture(rt->asTexture(), newDevice->accessRe
nderTarget()); | 92 fDevice->context()->copySurface(newDevice->accessRenderTarget(), rt-
>asTexture()); |
| 93 } | 93 } |
| 94 SkASSERT(this->getCachedCanvas()); | 94 SkASSERT(this->getCachedCanvas()); |
| 95 SkASSERT(this->getCachedCanvas()->getDevice() == fDevice); | 95 SkASSERT(this->getCachedCanvas()->getDevice() == fDevice); |
| 96 | 96 |
| 97 this->getCachedCanvas()->setRootDevice(newDevice); | 97 this->getCachedCanvas()->setRootDevice(newDevice); |
| 98 SkRefCnt_SafeAssign(fDevice, newDevice); | 98 SkRefCnt_SafeAssign(fDevice, newDevice); |
| 99 } else if (kDiscard_ContentChangeMode == mode) { | 99 } else if (kDiscard_ContentChangeMode == mode) { |
| 100 this->SkSurface_Gpu::onDiscard(); | 100 this->SkSurface_Gpu::onDiscard(); |
| 101 } | 101 } |
| 102 } | 102 } |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 149 desc.fSampleCnt = sampleCount; | 149 desc.fSampleCnt = sampleCount; |
| 150 | 150 |
| 151 SkAutoTUnref<GrTexture> tex(ctx->lockAndRefScratchTexture(desc, GrContext::k
Exact_ScratchTexMatch)); | 151 SkAutoTUnref<GrTexture> tex(ctx->lockAndRefScratchTexture(desc, GrContext::k
Exact_ScratchTexMatch)); |
| 152 | 152 |
| 153 if (NULL == tex) { | 153 if (NULL == tex) { |
| 154 return NULL; | 154 return NULL; |
| 155 } | 155 } |
| 156 | 156 |
| 157 return SkNEW_ARGS(SkSurface_Gpu, (tex->asRenderTarget(), true, props, true))
; | 157 return SkNEW_ARGS(SkSurface_Gpu, (tex->asRenderTarget(), true, props, true))
; |
| 158 } | 158 } |
| OLD | NEW |