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

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

Issue 1210303003: add getTextureHandle to SkSurface (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 5 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
« include/core/SkSurface.h ('K') | « src/image/SkSurface_Gpu.h ('k') | 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_Gpu.h" 8 #include "SkSurface_Gpu.h"
9 9
10 #include "SkCanvas.h" 10 #include "SkCanvas.h"
11 #include "SkGpuDevice.h" 11 #include "SkGpuDevice.h"
12 #include "SkImage_Base.h" 12 #include "SkImage_Base.h"
13 #include "SkImage_Gpu.h" 13 #include "SkImage_Gpu.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 SkSurface_Gpu::SkSurface_Gpu(SkGpuDevice* device) 20 SkSurface_Gpu::SkSurface_Gpu(SkGpuDevice* device)
21 : INHERITED(device->width(), device->height(), &device->surfaceProps()) 21 : INHERITED(device->width(), device->height(), &device->surfaceProps())
22 , fDevice(SkRef(device)) { 22 , fDevice(SkRef(device)) {
23 } 23 }
24 24
25 SkSurface_Gpu::~SkSurface_Gpu() { 25 SkSurface_Gpu::~SkSurface_Gpu() {
26 fDevice->unref(); 26 fDevice->unref();
27 } 27 }
28 28
29 GrBackendObject SkSurface_Gpu::onGetTextureHandle(ContentChangeMode mode) {
Justin Novosad 2015/06/26 21:33:15 Where in this method does the genID get bumped? AP
reed1 2015/06/27 17:56:12 New enum supports read and write access. We are n
30 GrRenderTarget* rt = fDevice->accessRenderTarget();
31 switch (mode) {
32 case kDiscard_ContentChangeMode:
33 rt->discard();
Justin Novosad 2015/06/26 21:33:15 What is the use case for this?
reed1 2015/06/27 17:56:12 Enum has changed, but the idea is to have 2 write
34 break;
35 case kRetain_ContentChangeMode:
36 rt->prepareForExternalRead(); // todo: rename to prepareForExterna lAccess()
37 break;
38 }
39 return rt->asTexture()->getTextureHandle();
40 }
41
29 SkCanvas* SkSurface_Gpu::onNewCanvas() { 42 SkCanvas* SkSurface_Gpu::onNewCanvas() {
30 SkCanvas::InitFlags flags = SkCanvas::kDefault_InitFlags; 43 SkCanvas::InitFlags flags = SkCanvas::kDefault_InitFlags;
31 // When we think this works... 44 // When we think this works...
32 // flags |= SkCanvas::kConservativeRasterClip_InitFlag; 45 // flags |= SkCanvas::kConservativeRasterClip_InitFlag;
33 46
34 return SkNEW_ARGS(SkCanvas, (fDevice, flags)); 47 return SkNEW_ARGS(SkCanvas, (fDevice, flags));
35 } 48 }
36 49
37 SkSurface* SkSurface_Gpu::onNewSurface(const SkImageInfo& info) { 50 SkSurface* SkSurface_Gpu::onNewSurface(const SkImageInfo& info) {
38 GrRenderTarget* rt = fDevice->accessRenderTarget(); 51 GrRenderTarget* rt = fDevice->accessRenderTarget();
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 } 129 }
117 SkAutoTUnref<SkGpuDevice> device(SkGpuDevice::Create(surface->asRenderTarget (), props, 130 SkAutoTUnref<SkGpuDevice> device(SkGpuDevice::Create(surface->asRenderTarget (), props,
118 SkGpuDevice::kUninit_In itContents)); 131 SkGpuDevice::kUninit_In itContents));
119 if (!device) { 132 if (!device) {
120 return NULL; 133 return NULL;
121 } 134 }
122 return SkNEW_ARGS(SkSurface_Gpu, (device)); 135 return SkNEW_ARGS(SkSurface_Gpu, (device));
123 } 136 }
124 137
125 #endif 138 #endif
OLDNEW
« include/core/SkSurface.h ('K') | « src/image/SkSurface_Gpu.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698