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

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

Issue 414013005: Merge GrGpuObject and GrCacheable. (Closed) Base URL: https://skia.googlesource.com/skia.git@uniqueid
Patch Set: Address comments Created 6 years, 4 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/GrCacheable.cpp ('k') | src/gpu/GrGpu.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 /* 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 9
10 #include "GrContext.h" 10 #include "GrContext.h"
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after
250 return SkNEW_ARGS(GrDistanceFieldTextContext, (this, leakyProperties, 250 return SkNEW_ARGS(GrDistanceFieldTextContext, (this, leakyProperties,
251 enableDistanceFieldFonts)); 251 enableDistanceFieldFonts));
252 } 252 }
253 253
254 //////////////////////////////////////////////////////////////////////////////// 254 ////////////////////////////////////////////////////////////////////////////////
255 255
256 GrTexture* GrContext::findAndRefTexture(const GrTextureDesc& desc, 256 GrTexture* GrContext::findAndRefTexture(const GrTextureDesc& desc,
257 const GrCacheID& cacheID, 257 const GrCacheID& cacheID,
258 const GrTextureParams* params) { 258 const GrTextureParams* params) {
259 GrResourceKey resourceKey = GrTextureImpl::ComputeKey(fGpu, params, desc, ca cheID); 259 GrResourceKey resourceKey = GrTextureImpl::ComputeKey(fGpu, params, desc, ca cheID);
260 GrCacheable* resource = fResourceCache->find(resourceKey); 260 GrGpuObject* resource = fResourceCache->find(resourceKey);
261 SkSafeRef(resource); 261 SkSafeRef(resource);
262 return static_cast<GrTexture*>(resource); 262 return static_cast<GrTexture*>(resource);
263 } 263 }
264 264
265 bool GrContext::isTextureInCache(const GrTextureDesc& desc, 265 bool GrContext::isTextureInCache(const GrTextureDesc& desc,
266 const GrCacheID& cacheID, 266 const GrCacheID& cacheID,
267 const GrTextureParams* params) const { 267 const GrTextureParams* params) const {
268 GrResourceKey resourceKey = GrTextureImpl::ComputeKey(fGpu, params, desc, ca cheID); 268 GrResourceKey resourceKey = GrTextureImpl::ComputeKey(fGpu, params, desc, ca cheID);
269 return fResourceCache->hasKey(resourceKey); 269 return fResourceCache->hasKey(resourceKey);
270 } 270 }
271 271
272 void GrContext::addStencilBuffer(GrStencilBuffer* sb) { 272 void GrContext::addStencilBuffer(GrStencilBuffer* sb) {
273 ASSERT_OWNED_RESOURCE(sb); 273 ASSERT_OWNED_RESOURCE(sb);
274 274
275 GrResourceKey resourceKey = GrStencilBuffer::ComputeKey(sb->width(), 275 GrResourceKey resourceKey = GrStencilBuffer::ComputeKey(sb->width(),
276 sb->height(), 276 sb->height(),
277 sb->numSamples()); 277 sb->numSamples());
278 fResourceCache->addResource(resourceKey, sb); 278 fResourceCache->addResource(resourceKey, sb);
279 } 279 }
280 280
281 GrStencilBuffer* GrContext::findStencilBuffer(int width, int height, 281 GrStencilBuffer* GrContext::findStencilBuffer(int width, int height,
282 int sampleCnt) { 282 int sampleCnt) {
283 GrResourceKey resourceKey = GrStencilBuffer::ComputeKey(width, 283 GrResourceKey resourceKey = GrStencilBuffer::ComputeKey(width,
284 height, 284 height,
285 sampleCnt); 285 sampleCnt);
286 GrCacheable* resource = fResourceCache->find(resourceKey); 286 GrGpuObject* resource = fResourceCache->find(resourceKey);
287 return static_cast<GrStencilBuffer*>(resource); 287 return static_cast<GrStencilBuffer*>(resource);
288 } 288 }
289 289
290 static void stretch_image(void* dst, 290 static void stretch_image(void* dst,
291 int dstW, 291 int dstW,
292 int dstH, 292 int dstH,
293 const void* src, 293 const void* src,
294 int srcW, 294 int srcW,
295 int srcH, 295 int srcH,
296 size_t bpp) { 296 size_t bpp) {
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
464 464
465 GrTextureDesc desc = inDesc; 465 GrTextureDesc desc = inDesc;
466 466
467 if (kApprox_ScratchTexMatch == match) { 467 if (kApprox_ScratchTexMatch == match) {
468 // bin by pow2 with a reasonable min 468 // bin by pow2 with a reasonable min
469 static const int MIN_SIZE = 16; 469 static const int MIN_SIZE = 16;
470 desc.fWidth = SkTMax(MIN_SIZE, GrNextPow2(desc.fWidth)); 470 desc.fWidth = SkTMax(MIN_SIZE, GrNextPow2(desc.fWidth));
471 desc.fHeight = SkTMax(MIN_SIZE, GrNextPow2(desc.fHeight)); 471 desc.fHeight = SkTMax(MIN_SIZE, GrNextPow2(desc.fHeight));
472 } 472 }
473 473
474 GrCacheable* resource = NULL; 474 GrGpuObject* resource = NULL;
475 int origWidth = desc.fWidth; 475 int origWidth = desc.fWidth;
476 int origHeight = desc.fHeight; 476 int origHeight = desc.fHeight;
477 477
478 do { 478 do {
479 GrResourceKey key = GrTextureImpl::ComputeScratchKey(desc); 479 GrResourceKey key = GrTextureImpl::ComputeScratchKey(desc);
480 // Ensure we have exclusive access to the texture so future 'find' calls don't return it 480 // Ensure we have exclusive access to the texture so future 'find' calls don't return it
481 resource = fResourceCache->find(key, GrResourceCache::kHide_OwnershipFla g); 481 resource = fResourceCache->find(key, GrResourceCache::kHide_OwnershipFla g);
482 if (NULL != resource) { 482 if (NULL != resource) {
483 resource->ref(); 483 resource->ref();
484 break; 484 break;
(...skipping 1411 matching lines...) Expand 10 before | Expand all | Expand 10 after
1896 if (NULL != path && path->isEqualTo(inPath, stroke)) { 1896 if (NULL != path && path->isEqualTo(inPath, stroke)) {
1897 path->ref(); 1897 path->ref();
1898 } else { 1898 } else {
1899 path = fGpu->createPath(inPath, stroke); 1899 path = fGpu->createPath(inPath, stroke);
1900 fResourceCache->purgeAsNeeded(1, path->gpuMemorySize()); 1900 fResourceCache->purgeAsNeeded(1, path->gpuMemorySize());
1901 fResourceCache->addResource(resourceKey, path); 1901 fResourceCache->addResource(resourceKey, path);
1902 } 1902 }
1903 return path; 1903 return path;
1904 } 1904 }
1905 1905
1906 void GrContext::addResourceToCache(const GrResourceKey& resourceKey, GrCacheable * resource) { 1906 void GrContext::addResourceToCache(const GrResourceKey& resourceKey, GrGpuObject * resource) {
1907 fResourceCache->purgeAsNeeded(1, resource->gpuMemorySize()); 1907 fResourceCache->purgeAsNeeded(1, resource->gpuMemorySize());
1908 fResourceCache->addResource(resourceKey, resource); 1908 fResourceCache->addResource(resourceKey, resource);
1909 } 1909 }
1910 1910
1911 GrCacheable* GrContext::findAndRefCachedResource(const GrResourceKey& resourceKe y) { 1911 GrGpuObject* GrContext::findAndRefCachedResource(const GrResourceKey& resourceKe y) {
1912 GrCacheable* resource = fResourceCache->find(resourceKey); 1912 GrGpuObject* resource = fResourceCache->find(resourceKey);
1913 SkSafeRef(resource); 1913 SkSafeRef(resource);
1914 return resource; 1914 return resource;
1915 } 1915 }
1916 1916
1917 void GrContext::addGpuTraceMarker(const GrGpuTraceMarker* marker) { 1917 void GrContext::addGpuTraceMarker(const GrGpuTraceMarker* marker) {
1918 fGpu->addGpuTraceMarker(marker); 1918 fGpu->addGpuTraceMarker(marker);
1919 if (NULL != fDrawBuffer) { 1919 if (NULL != fDrawBuffer) {
1920 fDrawBuffer->addGpuTraceMarker(marker); 1920 fDrawBuffer->addGpuTraceMarker(marker);
1921 } 1921 }
1922 } 1922 }
1923 1923
1924 void GrContext::removeGpuTraceMarker(const GrGpuTraceMarker* marker) { 1924 void GrContext::removeGpuTraceMarker(const GrGpuTraceMarker* marker) {
1925 fGpu->removeGpuTraceMarker(marker); 1925 fGpu->removeGpuTraceMarker(marker);
1926 if (NULL != fDrawBuffer) { 1926 if (NULL != fDrawBuffer) {
1927 fDrawBuffer->removeGpuTraceMarker(marker); 1927 fDrawBuffer->removeGpuTraceMarker(marker);
1928 } 1928 }
1929 } 1929 }
1930 1930
1931 /////////////////////////////////////////////////////////////////////////////// 1931 ///////////////////////////////////////////////////////////////////////////////
1932 #if GR_CACHE_STATS 1932 #if GR_CACHE_STATS
1933 void GrContext::printCacheStats() const { 1933 void GrContext::printCacheStats() const {
1934 fResourceCache->printStats(); 1934 fResourceCache->printStats();
1935 } 1935 }
1936 #endif 1936 #endif
OLDNEW
« no previous file with comments | « src/gpu/GrCacheable.cpp ('k') | src/gpu/GrGpu.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698