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

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

Issue 608883003: GrResourceCache2 manages scratch texture. (Closed) Base URL: https://skia.googlesource.com/skia.git@surfimpl
Patch Set: remove todo Created 6 years, 2 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/GrDrawState.h ('k') | src/gpu/GrGpuResourceRef.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 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 GrIORef::~GrIORef() { 14 template<typename D> GrIORef<D>::~GrIORef() {
15 SkASSERT(0 == fRefCnt); 15 SkASSERT(0 == fRefCnt);
16 SkASSERT(0 == fPendingReads); 16 SkASSERT(0 == fPendingReads);
17 SkASSERT(0 == fPendingWrites); 17 SkASSERT(0 == fPendingWrites);
18 // Set to invalid values. 18 // Set to invalid values.
19 SkDEBUGCODE(fRefCnt = fPendingReads = fPendingWrites = -10;) 19 SkDEBUGCODE(fRefCnt = fPendingReads = fPendingWrites = -10;)
20 } 20 }
21 21
22 /////////////////////////////////////////////////////////////////////////////// 22 ///////////////////////////////////////////////////////////////////////////////
23 23
24 static inline GrResourceCache2* get_resource_cache2(GrGpu* gpu) { 24 static inline GrResourceCache2* get_resource_cache2(GrGpu* gpu) {
25 SkASSERT(gpu); 25 SkASSERT(gpu);
26 SkASSERT(gpu->getContext()); 26 SkASSERT(gpu->getContext());
27 SkASSERT(gpu->getContext()->getResourceCache2()); 27 SkASSERT(gpu->getContext()->getResourceCache2());
28 return gpu->getContext()->getResourceCache2(); 28 return gpu->getContext()->getResourceCache2();
29 } 29 }
30 30
31 static inline GrResourceCache* get_resource_cache(GrGpu* gpu) {
32 SkASSERT(gpu);
33 SkASSERT(gpu->getContext());
34 SkASSERT(gpu->getContext()->getResourceCache());
35 return gpu->getContext()->getResourceCache();
36 }
37
31 GrGpuResource::GrGpuResource(GrGpu* gpu, bool isWrapped) 38 GrGpuResource::GrGpuResource(GrGpu* gpu, bool isWrapped)
32 : fGpu(gpu) 39 : fGpu(gpu)
33 , fCacheEntry(NULL) 40 , fCacheEntry(NULL)
34 , fUniqueID(CreateUniqueID()) 41 , fUniqueID(CreateUniqueID())
35 , fScratchKey(GrResourceKey::NullScratchKey()) { 42 , fScratchKey(GrResourceKey::NullScratchKey()) {
36 if (isWrapped) { 43 if (isWrapped) {
37 fFlags = kWrapped_FlagBit; 44 fFlags = kWrapped_FlagBit;
38 } else { 45 } else {
39 fFlags = 0; 46 fFlags = 0;
40 } 47 }
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 } 81 }
75 82
76 GrContext* GrGpuResource::getContext() { 83 GrContext* GrGpuResource::getContext() {
77 if (fGpu) { 84 if (fGpu) {
78 return fGpu->getContext(); 85 return fGpu->getContext();
79 } else { 86 } else {
80 return NULL; 87 return NULL;
81 } 88 }
82 } 89 }
83 90
91 void GrGpuResource::notifyIsPurgable() const {
92 if (fCacheEntry && !this->wasDestroyed()) {
93 get_resource_cache(fGpu)->notifyPurgable(this);
94 }
95 }
96
84 void GrGpuResource::setScratchKey(const GrResourceKey& scratchKey) { 97 void GrGpuResource::setScratchKey(const GrResourceKey& scratchKey) {
85 SkASSERT(fScratchKey.isNullScratch()); 98 SkASSERT(fScratchKey.isNullScratch());
86 SkASSERT(scratchKey.isScratch()); 99 SkASSERT(scratchKey.isScratch());
87 SkASSERT(!scratchKey.isNullScratch()); 100 SkASSERT(!scratchKey.isNullScratch());
88 fScratchKey = scratchKey; 101 fScratchKey = scratchKey;
89 } 102 }
90 103
91 uint32_t GrGpuResource::CreateUniqueID() { 104 uint32_t GrGpuResource::CreateUniqueID() {
92 static int32_t gUniqueID = SK_InvalidUniqueID; 105 static int32_t gUniqueID = SK_InvalidUniqueID;
93 uint32_t id; 106 uint32_t id;
94 do { 107 do {
95 id = static_cast<uint32_t>(sk_atomic_inc(&gUniqueID) + 1); 108 id = static_cast<uint32_t>(sk_atomic_inc(&gUniqueID) + 1);
96 } while (id == SK_InvalidUniqueID); 109 } while (id == SK_InvalidUniqueID);
97 return id; 110 return id;
98 } 111 }
OLDNEW
« no previous file with comments | « src/gpu/GrDrawState.h ('k') | src/gpu/GrGpuResourceRef.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698