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

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

Issue 1709163003: Add wrapBackendTextureAsRenderTarget API (Closed) Base URL: https://chromium.googlesource.com/skia.git@master
Patch Set: fix test Created 4 years, 10 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') | 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 "GrResourceProvider.h"
10 #include "SkCanvas.h" 11 #include "SkCanvas.h"
11 #include "SkGpuDevice.h" 12 #include "SkGpuDevice.h"
12 #include "SkImage_Base.h" 13 #include "SkImage_Base.h"
13 #include "SkImage_Gpu.h" 14 #include "SkImage_Gpu.h"
14 #include "SkImagePriv.h" 15 #include "SkImagePriv.h"
15 #include "SkSurface_Base.h" 16 #include "SkSurface_Base.h"
16 17
17 #if SK_SUPPORT_GPU 18 #if SK_SUPPORT_GPU
18 19
19 SkSurface_Gpu::SkSurface_Gpu(SkGpuDevice* device) 20 SkSurface_Gpu::SkSurface_Gpu(SkGpuDevice* device)
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 SkTextureImageApplyBudgetedDecision(image); 102 SkTextureImageApplyBudgetedDecision(image);
102 } else if (kDiscard_ContentChangeMode == mode) { 103 } else if (kDiscard_ContentChangeMode == mode) {
103 this->SkSurface_Gpu::onDiscard(); 104 this->SkSurface_Gpu::onDiscard();
104 } 105 }
105 } 106 }
106 107
107 void SkSurface_Gpu::onDiscard() { 108 void SkSurface_Gpu::onDiscard() {
108 fDevice->accessRenderTarget()->discard(); 109 fDevice->accessRenderTarget()->discard();
109 } 110 }
110 111
112 void SkSurface_Gpu::onPrepareForExternalIO() {
113 fDevice->accessRenderTarget()->prepareForExternalIO();
114 }
115
111 /////////////////////////////////////////////////////////////////////////////// 116 ///////////////////////////////////////////////////////////////////////////////
112 117
113 SkSurface* SkSurface::NewRenderTargetDirect(GrRenderTarget* target, const SkSurf aceProps* props) { 118 SkSurface* SkSurface::NewRenderTargetDirect(GrRenderTarget* target, const SkSurf aceProps* props) {
114 SkAutoTUnref<SkGpuDevice> device( 119 SkAutoTUnref<SkGpuDevice> device(
115 SkGpuDevice::Create(target, props, SkGpuDevice::kUninit_InitContents)); 120 SkGpuDevice::Create(target, props, SkGpuDevice::kUninit_InitContents));
116 if (!device) { 121 if (!device) {
117 return nullptr; 122 return nullptr;
118 } 123 }
119 return new SkSurface_Gpu(device); 124 return new SkSurface_Gpu(device);
120 } 125 }
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 return nullptr; 168 return nullptr;
164 } 169 }
165 SkAutoTUnref<SkGpuDevice> device(SkGpuDevice::Create(rt, props, 170 SkAutoTUnref<SkGpuDevice> device(SkGpuDevice::Create(rt, props,
166 SkGpuDevice::kUninit_In itContents)); 171 SkGpuDevice::kUninit_In itContents));
167 if (!device) { 172 if (!device) {
168 return nullptr; 173 return nullptr;
169 } 174 }
170 return new SkSurface_Gpu(device); 175 return new SkSurface_Gpu(device);
171 } 176 }
172 177
178 SkSurface* SkSurface::NewFromBackendTextureAsRenderTarget(GrContext* context,
179 const GrBackendTexture Desc& desc,
180 const SkSurfaceProps* props) {
181 if (nullptr == context) {
182 return nullptr;
183 }
184 SkAutoTUnref<GrRenderTarget> rt(
185 context->resourceProvider()->wrapBackendTextureAsRenderTarget(desc)) ;
186 if (!rt) {
187 return nullptr;
188 }
189 SkAutoTUnref<SkGpuDevice> device(SkGpuDevice::Create(rt, props,
190 SkGpuDevice::kUninit_In itContents));
191 if (!device) {
192 return nullptr;
193 }
194 return new SkSurface_Gpu(device);
195 }
196
173 #endif 197 #endif
OLDNEW
« no previous file with comments | « src/image/SkSurface_Gpu.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698