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

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

Issue 695813003: Add class GrGLTextureRenderTarget for GL texture/rendertarget objects (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: forgot to save file Created 6 years, 1 month 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
OLDNEW
1 1
2 /* 2 /*
3 * Copyright 2011 Google Inc. 3 * Copyright 2011 Google Inc.
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 8
9 #include "GrContext.h" 9 #include "GrContext.h"
10 10
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after
248 return GrDistanceFieldTextContext::Create(this, leakyProperties, enableDista nceFieldFonts); 248 return GrDistanceFieldTextContext::Create(this, leakyProperties, enableDista nceFieldFonts);
249 } 249 }
250 250
251 //////////////////////////////////////////////////////////////////////////////// 251 ////////////////////////////////////////////////////////////////////////////////
252 252
253 GrTexture* GrContext::findAndRefTexture(const GrSurfaceDesc& desc, 253 GrTexture* GrContext::findAndRefTexture(const GrSurfaceDesc& desc,
254 const GrCacheID& cacheID, 254 const GrCacheID& cacheID,
255 const GrTextureParams* params) { 255 const GrTextureParams* params) {
256 GrResourceKey resourceKey = GrTexturePriv::ComputeKey(fGpu, params, desc, ca cheID); 256 GrResourceKey resourceKey = GrTexturePriv::ComputeKey(fGpu, params, desc, ca cheID);
257 GrGpuResource* resource = fResourceCache->find(resourceKey); 257 GrGpuResource* resource = fResourceCache->find(resourceKey);
258 SkSafeRef(resource); 258 if (resource) {
259 return static_cast<GrTexture*>(resource); 259 resource->ref();
260 return static_cast<GrSurface*>(resource)->asTexture();
261 } else {
262 return NULL;
263 }
260 } 264 }
261 265
262 bool GrContext::isTextureInCache(const GrSurfaceDesc& desc, 266 bool GrContext::isTextureInCache(const GrSurfaceDesc& desc,
263 const GrCacheID& cacheID, 267 const GrCacheID& cacheID,
264 const GrTextureParams* params) const { 268 const GrTextureParams* params) const {
265 GrResourceKey resourceKey = GrTexturePriv::ComputeKey(fGpu, params, desc, ca cheID); 269 GrResourceKey resourceKey = GrTexturePriv::ComputeKey(fGpu, params, desc, ca cheID);
266 return fResourceCache->hasKey(resourceKey); 270 return fResourceCache->hasKey(resourceKey);
267 } 271 }
268 272
269 void GrContext::addStencilBuffer(GrStencilBuffer* sb) { 273 void GrContext::addStencilBuffer(GrStencilBuffer* sb) {
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
464 if (calledDuringFlush) { 468 if (calledDuringFlush) {
465 scratchFlags = GrResourceCache2::kRequireNoPendingIO_ScratchFlag ; 469 scratchFlags = GrResourceCache2::kRequireNoPendingIO_ScratchFlag ;
466 } else if (!(desc->fFlags & kRenderTarget_GrSurfaceFlag)) { 470 } else if (!(desc->fFlags & kRenderTarget_GrSurfaceFlag)) {
467 // If it is not a render target then it will most likely be popu lated by 471 // If it is not a render target then it will most likely be popu lated by
468 // writePixels() which will trigger a flush if the texture has p ending IO. 472 // writePixels() which will trigger a flush if the texture has p ending IO.
469 scratchFlags = GrResourceCache2::kPreferNoPendingIO_ScratchFlag; 473 scratchFlags = GrResourceCache2::kPreferNoPendingIO_ScratchFlag;
470 } 474 }
471 GrGpuResource* resource = fResourceCache2->findAndRefScratchResource (key, scratchFlags); 475 GrGpuResource* resource = fResourceCache2->findAndRefScratchResource (key, scratchFlags);
472 if (resource) { 476 if (resource) {
473 fResourceCache->makeResourceMRU(resource); 477 fResourceCache->makeResourceMRU(resource);
474 return static_cast<GrTexture*>(resource); 478 return static_cast<GrSurface*>(resource)->asTexture();
475 } 479 }
476 480
477 if (kExact_ScratchTexMatch == match) { 481 if (kExact_ScratchTexMatch == match) {
478 break; 482 break;
479 } 483 }
480 // We had a cache miss and we are in approx mode, relax the fit of t he flags. 484 // We had a cache miss and we are in approx mode, relax the fit of t he flags.
481 485
482 // We no longer try to reuse textures that were previously used as r ender targets in 486 // We no longer try to reuse textures that were previously used as r ender targets in
483 // situations where no RT is needed; doing otherwise can confuse the video driver and 487 // situations where no RT is needed; doing otherwise can confuse the video driver and
484 // cause significant performance problems in some cases. 488 // cause significant performance problems in some cases.
(...skipping 1297 matching lines...) Expand 10 before | Expand all | Expand 10 after
1782 fResourceCache->printStats(); 1786 fResourceCache->printStats();
1783 } 1787 }
1784 #endif 1788 #endif
1785 1789
1786 #if GR_GPU_STATS 1790 #if GR_GPU_STATS
1787 const GrContext::GPUStats* GrContext::gpuStats() const { 1791 const GrContext::GPUStats* GrContext::gpuStats() const {
1788 return fGpu->gpuStats(); 1792 return fGpu->gpuStats();
1789 } 1793 }
1790 #endif 1794 #endif
1791 1795
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698