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

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

Issue 1220733007: add ability to get FBO ID to Surface (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: mac warning 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
« no previous file with comments | « src/image/SkSurface_Gpu.h ('k') | tests/SurfaceTest.cpp » ('j') | 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(TextureHandleAccess access) { 29 static GrRenderTarget* prepare_rt_for_external_access(SkSurface_Gpu* surface,
30 GrRenderTarget* rt = fDevice->accessRenderTarget(); 30 SkSurface::BackendHandleAc cess access) {
31 GrRenderTarget* rt = surface->getDevice()->accessRenderTarget();
31 switch (access) { 32 switch (access) {
32 case kFlushRead_TextureHandleAccess: 33 case SkSurface::kFlushRead_BackendHandleAccess:
33 break; 34 break;
34 case kFlushWrite_TextureHandleAccess: 35 case SkSurface::kFlushWrite_BackendHandleAccess:
35 case kDiscardWrite_TextureHandleAccess: 36 case SkSurface::kDiscardWrite_BackendHandleAccess:
36 // for now we don't special-case on Discard, but we may in the futur e. 37 // for now we don't special-case on Discard, but we may in the futur e.
37 this->notifyContentWillChange(kRetain_ContentChangeMode); 38 surface->notifyContentWillChange(SkSurface::kRetain_ContentChangeMod e);
38 // legacy: need to dirty the bitmap's genID in our device (curse it) 39 // legacy: need to dirty the bitmap's genID in our device (curse it)
39 fDevice->fLegacyBitmap.notifyPixelsChanged(); 40 surface->getDevice()->accessBitmap(false).notifyPixelsChanged();
40 break; 41 break;
41 } 42 }
42 rt->prepareForExternalIO(); 43 rt->prepareForExternalIO();
43 return rt->asTexture()->getTextureHandle(); 44 return rt;
45 }
46
47 GrBackendObject SkSurface_Gpu::onGetTextureHandle(BackendHandleAccess access) {
48 GrRenderTarget* rt = prepare_rt_for_external_access(this, access);
49 GrTexture* texture = rt->asTexture();
50 if (texture) {
51 return texture->getTextureHandle();
52 }
53 return 0;
54 }
55
56 bool SkSurface_Gpu::onGetRenderTargetHandle(GrBackendObject* obj, BackendHandleA ccess access) {
57 GrRenderTarget* rt = prepare_rt_for_external_access(this, access);
58 *obj = rt->getRenderTargetHandle();
59 return true;
44 } 60 }
45 61
46 SkCanvas* SkSurface_Gpu::onNewCanvas() { 62 SkCanvas* SkSurface_Gpu::onNewCanvas() {
47 SkCanvas::InitFlags flags = SkCanvas::kDefault_InitFlags; 63 SkCanvas::InitFlags flags = SkCanvas::kDefault_InitFlags;
48 // When we think this works... 64 // When we think this works...
49 // flags |= SkCanvas::kConservativeRasterClip_InitFlag; 65 // flags |= SkCanvas::kConservativeRasterClip_InitFlag;
50 66
51 return SkNEW_ARGS(SkCanvas, (fDevice, flags)); 67 return SkNEW_ARGS(SkCanvas, (fDevice, flags));
52 } 68 }
53 69
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 } 167 }
152 SkAutoTUnref<SkGpuDevice> device(SkGpuDevice::Create(rt, props, 168 SkAutoTUnref<SkGpuDevice> device(SkGpuDevice::Create(rt, props,
153 SkGpuDevice::kUninit_In itContents)); 169 SkGpuDevice::kUninit_In itContents));
154 if (!device) { 170 if (!device) {
155 return NULL; 171 return NULL;
156 } 172 }
157 return SkNEW_ARGS(SkSurface_Gpu, (device)); 173 return SkNEW_ARGS(SkSurface_Gpu, (device));
158 } 174 }
159 175
160 #endif 176 #endif
OLDNEW
« no previous file with comments | « src/image/SkSurface_Gpu.h ('k') | tests/SurfaceTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698