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

Side by Side Diff: src/gpu/GrIndexBuffer.h

Issue 1139753002: Refactor GrBufferAllocPools to use resource cache (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Clean up Created 5 years, 7 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
OLDNEW
1 1
2 /* 2 /*
3 * Copyright 2010 Google Inc. 3 * Copyright 2010 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 10
11 #ifndef GrIndexBuffer_DEFINED 11 #ifndef GrIndexBuffer_DEFINED
12 #define GrIndexBuffer_DEFINED 12 #define GrIndexBuffer_DEFINED
13 13
14 #include "GrGeometryBuffer.h" 14 #include "GrGeometryBuffer.h"
15 15
16
16 class GrIndexBuffer : public GrGeometryBuffer { 17 class GrIndexBuffer : public GrGeometryBuffer {
17 public: 18 public:
19 static void ComputeScratchKey(size_t size, bool dynamic, GrScratchKey* key) {
20 static const GrScratchKey::ResourceType kType = GrScratchKey::GenerateRe sourceType();
21
22 GrScratchKey::Builder builder(key, kType, 2);
23
24 SkASSERT(size <= SK_MaxU32);
25 builder[0] = size;
26 builder[1] = dynamic ? 1 : 0;
27 }
28
18 /** 29 /**
19 * Retrieves the maximum number of quads that could be rendered 30 * Retrieves the maximum number of quads that could be rendered
20 * from the index buffer (using kTriangles_GrPrimitiveType). 31 * from the index buffer (using kTriangles_GrPrimitiveType).
21 * @return the maximum number of quads using full size of index buffer. 32 * @return the maximum number of quads using full size of index buffer.
22 */ 33 */
23 int maxQuads() const { 34 int maxQuads() const {
24 return static_cast<int>(this->gpuMemorySize() / (sizeof(uint16_t) * 6)); 35 return static_cast<int>(this->gpuMemorySize() / (sizeof(uint16_t) * 6));
25 } 36 }
26 protected: 37 protected:
27 GrIndexBuffer(GrGpu* gpu, size_t gpuMemorySize, bool dynamic, bool cpuBacked ) 38 GrIndexBuffer(GrGpu* gpu, size_t gpuMemorySize, bool dynamic, bool cpuBacked )
28 : INHERITED(gpu, gpuMemorySize, dynamic, cpuBacked) {} 39 : INHERITED(gpu, gpuMemorySize, dynamic, cpuBacked) {
40 GrScratchKey key;
41 ComputeScratchKey(gpuMemorySize, dynamic, &key);
42 this->setScratchKey(key);
43 }
44
29 private: 45 private:
30 typedef GrGeometryBuffer INHERITED; 46 typedef GrGeometryBuffer INHERITED;
31 }; 47 };
32 48
33 #endif 49 #endif
OLDNEW
« no previous file with comments | « src/gpu/GrDrawTarget.cpp ('k') | src/gpu/GrLayerCache.cpp » ('j') | src/gpu/GrResourceProvider.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698