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 15 matching lines...) Expand all Loading... |
26 fDevice->unref(); | 26 fDevice->unref(); |
27 } | 27 } |
28 | 28 |
29 GrBackendObject SkSurface_Gpu::onGetTextureHandle(TextureHandleAccess access) { | 29 GrBackendObject SkSurface_Gpu::onGetTextureHandle(TextureHandleAccess access) { |
30 GrRenderTarget* rt = fDevice->accessRenderTarget(); | 30 GrRenderTarget* rt = fDevice->accessRenderTarget(); |
31 switch (access) { | 31 switch (access) { |
32 case kFlushRead_TextureHandleAccess: | 32 case kFlushRead_TextureHandleAccess: |
33 rt->prepareForExternalRead(); // todo: rename to prepareForExterna
lAccess() | 33 rt->prepareForExternalRead(); // todo: rename to prepareForExterna
lAccess() |
34 break; | 34 break; |
35 case kFlushWrite_TextureHandleAccess: | 35 case kFlushWrite_TextureHandleAccess: |
| 36 case kDiscardWrite_TextureHandleAccess: |
| 37 // for now we don't special-case on Discard, but we may in the futur
e. |
36 this->notifyContentWillChange(kRetain_ContentChangeMode); | 38 this->notifyContentWillChange(kRetain_ContentChangeMode); |
37 rt->flushWrites(); | 39 rt->flushWrites(); |
38 break; | 40 break; |
39 case kDiscardWrite_TextureHandleAccess: | |
40 this->notifyContentWillChange(kDiscard_ContentChangeMode); | |
41 rt->discard(); | |
42 break; | |
43 } | 41 } |
44 return rt->asTexture()->getTextureHandle(); | 42 return rt->asTexture()->getTextureHandle(); |
45 } | 43 } |
46 | 44 |
47 SkCanvas* SkSurface_Gpu::onNewCanvas() { | 45 SkCanvas* SkSurface_Gpu::onNewCanvas() { |
48 SkCanvas::InitFlags flags = SkCanvas::kDefault_InitFlags; | 46 SkCanvas::InitFlags flags = SkCanvas::kDefault_InitFlags; |
49 // When we think this works... | 47 // When we think this works... |
50 // flags |= SkCanvas::kConservativeRasterClip_InitFlag; | 48 // flags |= SkCanvas::kConservativeRasterClip_InitFlag; |
51 | 49 |
52 return SkNEW_ARGS(SkCanvas, (fDevice, flags)); | 50 return SkNEW_ARGS(SkCanvas, (fDevice, flags)); |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
134 } | 132 } |
135 SkAutoTUnref<SkGpuDevice> device(SkGpuDevice::Create(surface->asRenderTarget
(), props, | 133 SkAutoTUnref<SkGpuDevice> device(SkGpuDevice::Create(surface->asRenderTarget
(), props, |
136 SkGpuDevice::kUninit_In
itContents)); | 134 SkGpuDevice::kUninit_In
itContents)); |
137 if (!device) { | 135 if (!device) { |
138 return NULL; | 136 return NULL; |
139 } | 137 } |
140 return SkNEW_ARGS(SkSurface_Gpu, (device)); | 138 return SkNEW_ARGS(SkSurface_Gpu, (device)); |
141 } | 139 } |
142 | 140 |
143 #endif | 141 #endif |
OLD | NEW |