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

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

Issue 510053003: Make textures register with GrResourceCache2 as scratch. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: add new h file to git repo Created 6 years, 3 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/GrBinHashKey.h ('k') | src/gpu/GrMurmur3HashKey.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 "GrGpuResource.h" 10 #include "GrGpuResource.h"
11 #include "GrResourceCache2.h" 11 #include "GrResourceCache2.h"
12 #include "GrGpu.h" 12 #include "GrGpu.h"
13 13
14 static inline GrResourceCache2* get_resource_cache2(GrGpu* gpu) { 14 static inline GrResourceCache2* get_resource_cache2(GrGpu* gpu) {
15 SkASSERT(NULL != gpu); 15 SkASSERT(NULL != gpu);
16 SkASSERT(NULL != gpu->getContext()); 16 SkASSERT(NULL != gpu->getContext());
17 SkASSERT(NULL != gpu->getContext()->getResourceCache2()); 17 SkASSERT(NULL != gpu->getContext()->getResourceCache2());
18 return gpu->getContext()->getResourceCache2(); 18 return gpu->getContext()->getResourceCache2();
19 } 19 }
20 20
21 GrGpuResource::GrGpuResource(GrGpu* gpu, bool isWrapped) 21 GrGpuResource::GrGpuResource(GrGpu* gpu, bool isWrapped)
22 : fGpu(gpu) 22 : fGpu(gpu)
23 , fRefCnt(1) 23 , fRefCnt(1)
24 , fCacheEntry(NULL) 24 , fCacheEntry(NULL)
25 , fUniqueID(CreateUniqueID()) { 25 , fUniqueID(CreateUniqueID())
26 , fScratchKey(GrResourceKey::NullScratchKey()) {
26 if (isWrapped) { 27 if (isWrapped) {
27 fFlags = kWrapped_FlagBit; 28 fFlags = kWrapped_FlagBit;
28 } else { 29 } else {
29 fFlags = 0; 30 fFlags = 0;
30 } 31 }
31 } 32 }
32 33
33 void GrGpuResource::registerWithCache() { 34 void GrGpuResource::registerWithCache() {
34 get_resource_cache2(fGpu)->insertResource(this); 35 get_resource_cache2(fGpu)->insertResource(this);
35 } 36 }
(...skipping 29 matching lines...) Expand all
65 } 66 }
66 67
67 GrContext* GrGpuResource::getContext() { 68 GrContext* GrGpuResource::getContext() {
68 if (NULL != fGpu) { 69 if (NULL != fGpu) {
69 return fGpu->getContext(); 70 return fGpu->getContext();
70 } else { 71 } else {
71 return NULL; 72 return NULL;
72 } 73 }
73 } 74 }
74 75
76 void GrGpuResource::setScratchKey(const GrResourceKey& scratchKey) {
77 SkASSERT(fScratchKey.isNullScratch());
78 SkASSERT(scratchKey.isScratch());
79 SkASSERT(!scratchKey.isNullScratch());
80 fScratchKey = scratchKey;
81 }
82
75 uint32_t GrGpuResource::CreateUniqueID() { 83 uint32_t GrGpuResource::CreateUniqueID() {
76 static int32_t gUniqueID = SK_InvalidUniqueID; 84 static int32_t gUniqueID = SK_InvalidUniqueID;
77 uint32_t id; 85 uint32_t id;
78 do { 86 do {
79 id = static_cast<uint32_t>(sk_atomic_inc(&gUniqueID) + 1); 87 id = static_cast<uint32_t>(sk_atomic_inc(&gUniqueID) + 1);
80 } while (id == SK_InvalidUniqueID); 88 } while (id == SK_InvalidUniqueID);
81 return id; 89 return id;
82 } 90 }
OLDNEW
« no previous file with comments | « src/gpu/GrBinHashKey.h ('k') | src/gpu/GrMurmur3HashKey.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698