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

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

Issue 707493002: Use GrResourceCache2 to service content key lookups (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: move #ifdef SK_SUPPORT_GPU 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
« no previous file with comments | « src/core/SkTMultiMap.h ('k') | src/gpu/GrGpu.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 /* 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 248
249 return GrDistanceFieldTextContext::Create(this, leakyProperties, enableDista nceFieldFonts); 249 return GrDistanceFieldTextContext::Create(this, leakyProperties, enableDista nceFieldFonts);
250 } 250 }
251 251
252 //////////////////////////////////////////////////////////////////////////////// 252 ////////////////////////////////////////////////////////////////////////////////
253 253
254 GrTexture* GrContext::findAndRefTexture(const GrSurfaceDesc& desc, 254 GrTexture* GrContext::findAndRefTexture(const GrSurfaceDesc& desc,
255 const GrCacheID& cacheID, 255 const GrCacheID& cacheID,
256 const GrTextureParams* params) { 256 const GrTextureParams* params) {
257 GrResourceKey resourceKey = GrTexturePriv::ComputeKey(fGpu, params, desc, ca cheID); 257 GrResourceKey resourceKey = GrTexturePriv::ComputeKey(fGpu, params, desc, ca cheID);
258 GrGpuResource* resource = fResourceCache->find(resourceKey); 258
259 GrGpuResource* resource = this->findAndRefCachedResource(resourceKey);
259 if (resource) { 260 if (resource) {
260 resource->ref(); 261 SkASSERT(static_cast<GrSurface*>(resource)->asTexture());
261 return static_cast<GrSurface*>(resource)->asTexture(); 262 return static_cast<GrSurface*>(resource)->asTexture();
262 } else {
263 return NULL;
264 } 263 }
264 return NULL;
265 } 265 }
266 266
267 bool GrContext::isTextureInCache(const GrSurfaceDesc& desc, 267 bool GrContext::isTextureInCache(const GrSurfaceDesc& desc,
268 const GrCacheID& cacheID, 268 const GrCacheID& cacheID,
269 const GrTextureParams* params) const { 269 const GrTextureParams* params) const {
270 GrResourceKey resourceKey = GrTexturePriv::ComputeKey(fGpu, params, desc, ca cheID); 270 GrResourceKey resourceKey = GrTexturePriv::ComputeKey(fGpu, params, desc, ca cheID);
271 return fResourceCache->hasKey(resourceKey); 271 return fResourceCache2->hasContentKey(resourceKey);
272 } 272 }
273 273
274 void GrContext::addStencilBuffer(GrStencilBuffer* sb) { 274 void GrContext::addStencilBuffer(GrStencilBuffer* sb) {
275 ASSERT_OWNED_RESOURCE(sb); 275 ASSERT_OWNED_RESOURCE(sb);
276 276
277 GrResourceKey resourceKey = GrStencilBuffer::ComputeKey(sb->width(), 277 GrResourceKey resourceKey = GrStencilBuffer::ComputeKey(sb->width(),
278 sb->height(), 278 sb->height(),
279 sb->numSamples()); 279 sb->numSamples());
280 fResourceCache->addResource(resourceKey, sb); 280 fResourceCache->addResource(resourceKey, sb);
281 } 281 }
282 282
283 GrStencilBuffer* GrContext::findStencilBuffer(int width, int height, 283 GrStencilBuffer* GrContext::findAndRefStencilBuffer(int width, int height, int s ampleCnt) {
284 int sampleCnt) { 284 GrResourceKey resourceKey = GrStencilBuffer::ComputeKey(width, height, sampl eCnt);
285 GrResourceKey resourceKey = GrStencilBuffer::ComputeKey(width, 285 GrGpuResource* resource = this->findAndRefCachedResource(resourceKey);
286 height,
287 sampleCnt);
288 GrGpuResource* resource = fResourceCache->find(resourceKey);
289 return static_cast<GrStencilBuffer*>(resource); 286 return static_cast<GrStencilBuffer*>(resource);
290 } 287 }
291 288
292 static void stretch_image(void* dst, 289 static void stretch_image(void* dst,
293 int dstW, 290 int dstW,
294 int dstH, 291 int dstH,
295 const void* src, 292 const void* src,
296 int srcW, 293 int srcW,
297 int srcH, 294 int srcH,
298 size_t bpp) { 295 size_t bpp) {
(...skipping 1449 matching lines...) Expand 10 before | Expand all | Expand 10 after
1748 } else { 1745 } else {
1749 return NULL; 1746 return NULL;
1750 } 1747 }
1751 } 1748 }
1752 1749
1753 void GrContext::addResourceToCache(const GrResourceKey& resourceKey, GrGpuResour ce* resource) { 1750 void GrContext::addResourceToCache(const GrResourceKey& resourceKey, GrGpuResour ce* resource) {
1754 fResourceCache->addResource(resourceKey, resource); 1751 fResourceCache->addResource(resourceKey, resource);
1755 } 1752 }
1756 1753
1757 GrGpuResource* GrContext::findAndRefCachedResource(const GrResourceKey& resource Key) { 1754 GrGpuResource* GrContext::findAndRefCachedResource(const GrResourceKey& resource Key) {
1758 GrGpuResource* resource = fResourceCache->find(resourceKey); 1755 GrGpuResource* resource = fResourceCache2->findAndRefContentResource(resourc eKey);
1759 SkSafeRef(resource); 1756 if (resource) {
1757 fResourceCache->makeResourceMRU(resource);
1758 }
1760 return resource; 1759 return resource;
1761 } 1760 }
1762 1761
1763 void GrContext::addGpuTraceMarker(const GrGpuTraceMarker* marker) { 1762 void GrContext::addGpuTraceMarker(const GrGpuTraceMarker* marker) {
1764 fGpu->addGpuTraceMarker(marker); 1763 fGpu->addGpuTraceMarker(marker);
1765 if (fDrawBuffer) { 1764 if (fDrawBuffer) {
1766 fDrawBuffer->addGpuTraceMarker(marker); 1765 fDrawBuffer->addGpuTraceMarker(marker);
1767 } 1766 }
1768 } 1767 }
1769 1768
(...skipping 10 matching lines...) Expand all
1780 fResourceCache->printStats(); 1779 fResourceCache->printStats();
1781 } 1780 }
1782 #endif 1781 #endif
1783 1782
1784 #if GR_GPU_STATS 1783 #if GR_GPU_STATS
1785 const GrContext::GPUStats* GrContext::gpuStats() const { 1784 const GrContext::GPUStats* GrContext::gpuStats() const {
1786 return fGpu->gpuStats(); 1785 return fGpu->gpuStats();
1787 } 1786 }
1788 #endif 1787 #endif
1789 1788
OLDNEW
« no previous file with comments | « src/core/SkTMultiMap.h ('k') | src/gpu/GrGpu.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698