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

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

Issue 1825393002: Consolidate GPU buffer implementations (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: asserts Created 4 years, 9 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/GrGpu.cpp ('k') | src/gpu/GrMesh.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1
2 /*
3 * Copyright 2010 Google Inc.
4 *
5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file.
7 */
8
9
10
11 #ifndef GrIndexBuffer_DEFINED
12 #define GrIndexBuffer_DEFINED
13
14 #include "GrGeometryBuffer.h"
15
16
17 class GrIndexBuffer : public GrGeometryBuffer {
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
28 /**
29 * Retrieves the maximum number of quads that could be rendered
30 * from the index buffer (using kTriangles_GrPrimitiveType).
31 * @return the maximum number of quads using full size of index buffer.
32 */
33 int maxQuads() const {
34 return static_cast<int>(this->gpuMemorySize() / (sizeof(uint16_t) * 6));
35 }
36 protected:
37 GrIndexBuffer(GrGpu* gpu, size_t gpuMemorySize, bool dynamic, bool cpuBacked )
38 : INHERITED(gpu, gpuMemorySize, dynamic, cpuBacked) {
39 // We currently only make buffers scratch if they're both pow2 sized and not cpuBacked.
40 if (!cpuBacked && SkIsPow2(gpuMemorySize)) {
41 GrScratchKey key;
42 ComputeScratchKey(gpuMemorySize, dynamic, &key);
43 this->setScratchKey(key);
44 }
45 }
46
47 private:
48 typedef GrGeometryBuffer INHERITED;
49 };
50
51 #endif
OLDNEW
« no previous file with comments | « src/gpu/GrGpu.cpp ('k') | src/gpu/GrMesh.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698