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_Gpu.h" | 8 #include "SkSurface_Gpu.h" |
9 | 9 |
10 #include "GrGpuResourceCacheAccess.h" | 10 #include "GrGpuResourcePriv.h" |
11 #include "SkCanvas.h" | 11 #include "SkCanvas.h" |
12 #include "SkGpuDevice.h" | 12 #include "SkGpuDevice.h" |
13 #include "SkImage_Base.h" | 13 #include "SkImage_Base.h" |
14 #include "SkImagePriv.h" | 14 #include "SkImagePriv.h" |
15 #include "SkSurface_Base.h" | 15 #include "SkSurface_Base.h" |
16 | 16 |
17 #if SK_SUPPORT_GPU | 17 #if SK_SUPPORT_GPU |
18 | 18 |
19 /////////////////////////////////////////////////////////////////////////////// | 19 /////////////////////////////////////////////////////////////////////////////// |
20 | 20 |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 // device into it. Note that this flushes the SkGpuDevice but | 63 // device into it. Note that this flushes the SkGpuDevice but |
64 // doesn't force an OpenGL flush. | 64 // doesn't force an OpenGL flush. |
65 void SkSurface_Gpu::onCopyOnWrite(ContentChangeMode mode) { | 65 void SkSurface_Gpu::onCopyOnWrite(ContentChangeMode mode) { |
66 GrRenderTarget* rt = fDevice->accessRenderTarget(); | 66 GrRenderTarget* rt = fDevice->accessRenderTarget(); |
67 // are we sharing our render target with the image? Note this call should ne
ver create a new | 67 // are we sharing our render target with the image? Note this call should ne
ver create a new |
68 // image because onCopyOnWrite is only called when there is a cached image. | 68 // image because onCopyOnWrite is only called when there is a cached image. |
69 SkImage* image = this->getCachedImage(kNo_Budgeted); | 69 SkImage* image = this->getCachedImage(kNo_Budgeted); |
70 SkASSERT(image); | 70 SkASSERT(image); |
71 if (rt->asTexture() == SkTextureImageGetTexture(image)) { | 71 if (rt->asTexture() == SkTextureImageGetTexture(image)) { |
72 GrRenderTarget* oldRT = this->fDevice->accessRenderTarget(); | 72 GrRenderTarget* oldRT = this->fDevice->accessRenderTarget(); |
73 SkSurface::Budgeted budgeted = oldRT->cacheAccess().isBudgeted() ? kYes_
Budgeted : | 73 SkSurface::Budgeted budgeted = oldRT->resourcePriv().isBudgeted() ? kYes
_Budgeted : |
74 kNo_B
udgeted; | 74 kNo_
Budgeted; |
75 SkAutoTUnref<SkGpuDevice> newDevice( | 75 SkAutoTUnref<SkGpuDevice> newDevice( |
76 SkGpuDevice::Create(oldRT->getContext(), budgeted, fDevice->imageInf
o(), | 76 SkGpuDevice::Create(oldRT->getContext(), budgeted, fDevice->imageInf
o(), |
77 oldRT->numSamples(), &this->props(), 0)); | 77 oldRT->numSamples(), &this->props(), 0)); |
78 if (kRetain_ContentChangeMode == mode && !oldRT->wasDestroyed() && newDe
vice) { | 78 if (kRetain_ContentChangeMode == mode && !oldRT->wasDestroyed() && newDe
vice) { |
79 oldRT->getContext()->copySurface(newDevice->accessRenderTarget(), ol
dRT); | 79 oldRT->getContext()->copySurface(newDevice->accessRenderTarget(), ol
dRT); |
80 } | 80 } |
81 | 81 |
82 SkASSERT(this->getCachedCanvas()); | 82 SkASSERT(this->getCachedCanvas()); |
83 SkASSERT(this->getCachedCanvas()->getDevice() == fDevice); | 83 SkASSERT(this->getCachedCanvas()->getDevice() == fDevice); |
84 | 84 |
(...skipping 24 matching lines...) Expand all Loading... |
109 int sampleCount, const SkSurfaceProps* pro
ps) { | 109 int sampleCount, const SkSurfaceProps* pro
ps) { |
110 SkAutoTUnref<SkGpuDevice> device(SkGpuDevice::Create(ctx, budgeted, info, sa
mpleCount, props, | 110 SkAutoTUnref<SkGpuDevice> device(SkGpuDevice::Create(ctx, budgeted, info, sa
mpleCount, props, |
111 SkGpuDevice::kNeedClear
_Flag)); | 111 SkGpuDevice::kNeedClear
_Flag)); |
112 if (!device) { | 112 if (!device) { |
113 return NULL; | 113 return NULL; |
114 } | 114 } |
115 return SkNEW_ARGS(SkSurface_Gpu, (device)); | 115 return SkNEW_ARGS(SkSurface_Gpu, (device)); |
116 } | 116 } |
117 | 117 |
118 #endif | 118 #endif |
OLD | NEW |