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 "SkCanvas.h" | 10 #include "SkCanvas.h" |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 } | 78 } |
79 | 79 |
80 SkImage* SkSurface_Gpu::onNewImageSnapshot(Budgeted budgeted) { | 80 SkImage* SkSurface_Gpu::onNewImageSnapshot(Budgeted budgeted) { |
81 const SkImageInfo info = fDevice->imageInfo(); | 81 const SkImageInfo info = fDevice->imageInfo(); |
82 SkImage* image = nullptr; | 82 SkImage* image = nullptr; |
83 GrTexture* tex = fDevice->accessRenderTarget()->asTexture(); | 83 GrTexture* tex = fDevice->accessRenderTarget()->asTexture(); |
84 if (tex) { | 84 if (tex) { |
85 image = new SkImage_Gpu(info.width(), info.height(), kNeedNewImageUnique
ID, | 85 image = new SkImage_Gpu(info.width(), info.height(), kNeedNewImageUnique
ID, |
86 info.alphaType(), tex, budgeted); | 86 info.alphaType(), tex, budgeted); |
87 } | 87 } |
88 if (image) { | |
89 as_IB(image)->initWithProps(this->props()); | |
90 } | |
91 return image; | 88 return image; |
92 } | 89 } |
93 | 90 |
94 // Create a new render target and, if necessary, copy the contents of the old | 91 // Create a new render target and, if necessary, copy the contents of the old |
95 // render target into it. Note that this flushes the SkGpuDevice but | 92 // render target into it. Note that this flushes the SkGpuDevice but |
96 // doesn't force an OpenGL flush. | 93 // doesn't force an OpenGL flush. |
97 void SkSurface_Gpu::onCopyOnWrite(ContentChangeMode mode) { | 94 void SkSurface_Gpu::onCopyOnWrite(ContentChangeMode mode) { |
98 GrRenderTarget* rt = fDevice->accessRenderTarget(); | 95 GrRenderTarget* rt = fDevice->accessRenderTarget(); |
99 // are we sharing our render target with the image? Note this call should ne
ver create a new | 96 // are we sharing our render target with the image? Note this call should ne
ver create a new |
100 // image because onCopyOnWrite is only called when there is a cached image. | 97 // image because onCopyOnWrite is only called when there is a cached image. |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
166 } | 163 } |
167 SkAutoTUnref<SkGpuDevice> device(SkGpuDevice::Create(rt, props, | 164 SkAutoTUnref<SkGpuDevice> device(SkGpuDevice::Create(rt, props, |
168 SkGpuDevice::kUninit_In
itContents)); | 165 SkGpuDevice::kUninit_In
itContents)); |
169 if (!device) { | 166 if (!device) { |
170 return nullptr; | 167 return nullptr; |
171 } | 168 } |
172 return new SkSurface_Gpu(device); | 169 return new SkSurface_Gpu(device); |
173 } | 170 } |
174 | 171 |
175 #endif | 172 #endif |
OLD | NEW |