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

Side by Side Diff: include/gpu/GrBuffer.h

Issue 1862043002: Refactor to separate backend object lifecycle and GpuResource budget decision (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: fix unrelated GrBuffer::onGpuMemorySize() lack of override keyword compile error Created 4 years, 8 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 | « bench/GrResourceCacheBench.cpp ('k') | include/gpu/GrGpuResource.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 * Copyright 2016 Google Inc. 2 * Copyright 2016 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #ifndef GrBuffer_DEFINED 8 #ifndef GrBuffer_DEFINED
9 #define GrBuffer_DEFINED 9 #define GrBuffer_DEFINED
10 10
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 */ 103 */
104 bool updateData(const void* src, size_t srcSizeInBytes) { 104 bool updateData(const void* src, size_t srcSizeInBytes) {
105 SkASSERT(!this->isMapped()); 105 SkASSERT(!this->isMapped());
106 SkASSERT(srcSizeInBytes <= fGpuMemorySize); 106 SkASSERT(srcSizeInBytes <= fGpuMemorySize);
107 return this->onUpdateData(src, srcSizeInBytes); 107 return this->onUpdateData(src, srcSizeInBytes);
108 } 108 }
109 109
110 protected: 110 protected:
111 GrBuffer(GrGpu* gpu, size_t gpuMemorySize, GrBufferType intendedType, 111 GrBuffer(GrGpu* gpu, size_t gpuMemorySize, GrBufferType intendedType,
112 GrAccessPattern accessPattern, bool cpuBacked) 112 GrAccessPattern accessPattern, bool cpuBacked)
113 : INHERITED(gpu, kCached_LifeCycle), 113 : INHERITED(gpu),
114 fMapPtr(nullptr), 114 fMapPtr(nullptr),
115 fGpuMemorySize(gpuMemorySize), // TODO: Zero for cpu backed buffers? 115 fGpuMemorySize(gpuMemorySize), // TODO: Zero for cpu backed buffers?
116 fAccessPattern(accessPattern), 116 fAccessPattern(accessPattern),
117 fCPUBacked(cpuBacked) { 117 fCPUBacked(cpuBacked),
118 fIntendedType(intendedType) {
119 }
120
121 void computeScratchKey(GrScratchKey* key) const override {
118 if (!fCPUBacked && SkIsPow2(fGpuMemorySize) && kDynamic_GrAccessPattern == fAccessPattern) { 122 if (!fCPUBacked && SkIsPow2(fGpuMemorySize) && kDynamic_GrAccessPattern == fAccessPattern) {
119 GrScratchKey key; 123 ComputeScratchKeyForDynamicBuffer(fGpuMemorySize, fIntendedType, key );
120 ComputeScratchKeyForDynamicBuffer(fGpuMemorySize, intendedType, &key );
121 this->setScratchKey(key);
122 } 124 }
123 } 125 }
124 126
125 void* fMapPtr; 127 void* fMapPtr;
126 128
127 private: 129 private:
128 virtual size_t onGpuMemorySize() const { return fGpuMemorySize; } 130 size_t onGpuMemorySize() const override { return fGpuMemorySize; }
129 131
130 virtual void onMap() = 0; 132 virtual void onMap() = 0;
131 virtual void onUnmap() = 0; 133 virtual void onUnmap() = 0;
132 virtual bool onUpdateData(const void* src, size_t srcSizeInBytes) = 0; 134 virtual bool onUpdateData(const void* src, size_t srcSizeInBytes) = 0;
133 135
134 size_t fGpuMemorySize; 136 size_t fGpuMemorySize;
135 GrAccessPattern fAccessPattern; 137 GrAccessPattern fAccessPattern;
136 bool fCPUBacked; 138 bool fCPUBacked;
137 139 GrBufferType fIntendedType;
138 typedef GrGpuResource INHERITED; 140 typedef GrGpuResource INHERITED;
139 }; 141 };
140 142
141 #endif 143 #endif
OLDNEW
« no previous file with comments | « bench/GrResourceCacheBench.cpp ('k') | include/gpu/GrGpuResource.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698