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

Side by Side Diff: src/gpu/GrGpu.cpp

Issue 1709163003: Add wrapBackendTextureAsRenderTarget API (Closed) Base URL: https://chromium.googlesource.com/skia.git@master
Patch Set: fix test Created 4 years, 9 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/gpu/GrGpu.h ('k') | src/gpu/GrResourceProvider.h » ('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 2010 Google Inc. 2 * Copyright 2010 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 8
9 #include "GrGpu.h" 9 #include "GrGpu.h"
10 10
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 159
160 GrTexture* GrGpu::wrapBackendTexture(const GrBackendTextureDesc& desc, GrWrapOwn ership ownership) { 160 GrTexture* GrGpu::wrapBackendTexture(const GrBackendTextureDesc& desc, GrWrapOwn ership ownership) {
161 this->handleDirtyContext(); 161 this->handleDirtyContext();
162 if (!this->caps()->isConfigTexturable(desc.fConfig)) { 162 if (!this->caps()->isConfigTexturable(desc.fConfig)) {
163 return nullptr; 163 return nullptr;
164 } 164 }
165 if ((desc.fFlags & kRenderTarget_GrBackendTextureFlag) && 165 if ((desc.fFlags & kRenderTarget_GrBackendTextureFlag) &&
166 !this->caps()->isConfigRenderable(desc.fConfig, desc.fSampleCnt > 0)) { 166 !this->caps()->isConfigRenderable(desc.fConfig, desc.fSampleCnt > 0)) {
167 return nullptr; 167 return nullptr;
168 } 168 }
169 int maxSize = this->caps()->maxTextureSize();
170 if (desc.fWidth > maxSize || desc.fHeight > maxSize) {
171 return nullptr;
172 }
169 GrTexture* tex = this->onWrapBackendTexture(desc, ownership); 173 GrTexture* tex = this->onWrapBackendTexture(desc, ownership);
170 if (nullptr == tex) { 174 if (nullptr == tex) {
171 return nullptr; 175 return nullptr;
172 } 176 }
173 // TODO: defer this and attach dynamically 177 // TODO: defer this and attach dynamically
174 GrRenderTarget* tgt = tex->asRenderTarget(); 178 GrRenderTarget* tgt = tex->asRenderTarget();
175 if (tgt && !fContext->resourceProvider()->attachStencilAttachment(tgt)) { 179 if (tgt && !fContext->resourceProvider()->attachStencilAttachment(tgt)) {
176 tex->unref(); 180 tex->unref();
177 return nullptr; 181 return nullptr;
178 } else { 182 } else {
179 return tex; 183 return tex;
180 } 184 }
181 } 185 }
182 186
183 GrRenderTarget* GrGpu::wrapBackendRenderTarget(const GrBackendRenderTargetDesc& desc, 187 GrRenderTarget* GrGpu::wrapBackendRenderTarget(const GrBackendRenderTargetDesc& desc,
184 GrWrapOwnership ownership) { 188 GrWrapOwnership ownership) {
185 if (!this->caps()->isConfigRenderable(desc.fConfig, desc.fSampleCnt > 0)) { 189 if (!this->caps()->isConfigRenderable(desc.fConfig, desc.fSampleCnt > 0)) {
186 return nullptr; 190 return nullptr;
187 } 191 }
188 this->handleDirtyContext(); 192 this->handleDirtyContext();
189 return this->onWrapBackendRenderTarget(desc, ownership); 193 return this->onWrapBackendRenderTarget(desc, ownership);
190 } 194 }
191 195
196 GrRenderTarget* GrGpu::wrapBackendTextureAsRenderTarget(const GrBackendTextureDe sc& desc,
197 GrWrapOwnership ownershi p) {
198 this->handleDirtyContext();
199 if (!(desc.fFlags & kRenderTarget_GrBackendTextureFlag)) {
200 return nullptr;
201 }
202 if (!this->caps()->isConfigRenderable(desc.fConfig, desc.fSampleCnt > 0)) {
203 return nullptr;
204 }
205 int maxSize = this->caps()->maxTextureSize();
206 if (desc.fWidth > maxSize || desc.fHeight > maxSize) {
207 return nullptr;
208 }
209 return this->onWrapBackendTextureAsRenderTarget(desc, ownership);
210 }
211
192 GrVertexBuffer* GrGpu::createVertexBuffer(size_t size, bool dynamic) { 212 GrVertexBuffer* GrGpu::createVertexBuffer(size_t size, bool dynamic) {
193 this->handleDirtyContext(); 213 this->handleDirtyContext();
194 GrVertexBuffer* vb = this->onCreateVertexBuffer(size, dynamic); 214 GrVertexBuffer* vb = this->onCreateVertexBuffer(size, dynamic);
195 if (!this->caps()->reuseScratchBuffers()) { 215 if (!this->caps()->reuseScratchBuffers()) {
196 vb->resourcePriv().removeScratchKey(); 216 vb->resourcePriv().removeScratchKey();
197 } 217 }
198 return vb; 218 return vb;
199 } 219 }
200 220
201 GrIndexBuffer* GrGpu::createIndexBuffer(size_t size, bool dynamic) { 221 GrIndexBuffer* GrGpu::createIndexBuffer(size_t size, bool dynamic) {
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
378 } 398 }
379 399
380 GrVertices::Iterator iter; 400 GrVertices::Iterator iter;
381 const GrNonInstancedVertices* verts = iter.init(vertices); 401 const GrNonInstancedVertices* verts = iter.init(vertices);
382 do { 402 do {
383 this->onDraw(args, *verts); 403 this->onDraw(args, *verts);
384 fStats.incNumDraws(); 404 fStats.incNumDraws();
385 } while ((verts = iter.next())); 405 } while ((verts = iter.next()));
386 } 406 }
387 407
OLDNEW
« no previous file with comments | « src/gpu/GrGpu.h ('k') | src/gpu/GrResourceProvider.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698