OLD | NEW |
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 builder[0] = SkToUInt(size); |
| 25 builder[1] = dynamic ? 1 : 0; |
| 26 } |
| 27 |
18 /** | 28 /** |
19 * Retrieves the maximum number of quads that could be rendered | 29 * Retrieves the maximum number of quads that could be rendered |
20 * from the index buffer (using kTriangles_GrPrimitiveType). | 30 * from the index buffer (using kTriangles_GrPrimitiveType). |
21 * @return the maximum number of quads using full size of index buffer. | 31 * @return the maximum number of quads using full size of index buffer. |
22 */ | 32 */ |
23 int maxQuads() const { | 33 int maxQuads() const { |
24 return static_cast<int>(this->gpuMemorySize() / (sizeof(uint16_t) * 6)); | 34 return static_cast<int>(this->gpuMemorySize() / (sizeof(uint16_t) * 6)); |
25 } | 35 } |
26 protected: | 36 protected: |
27 GrIndexBuffer(GrGpu* gpu, size_t gpuMemorySize, bool dynamic, bool cpuBacked
) | 37 GrIndexBuffer(GrGpu* gpu, size_t gpuMemorySize, bool dynamic, bool cpuBacked
) |
28 : INHERITED(gpu, gpuMemorySize, dynamic, cpuBacked) {} | 38 : INHERITED(gpu, gpuMemorySize, dynamic, cpuBacked) { |
| 39 GrScratchKey key; |
| 40 ComputeScratchKey(gpuMemorySize, dynamic, &key); |
| 41 this->setScratchKey(key); |
| 42 } |
| 43 |
29 private: | 44 private: |
30 typedef GrGeometryBuffer INHERITED; | 45 typedef GrGeometryBuffer INHERITED; |
31 }; | 46 }; |
32 | 47 |
33 #endif | 48 #endif |
OLD | NEW |