• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 GrVertexBuffer_DEFINED
12 #define GrVertexBuffer_DEFINED
13 
14 #include "GrGeometryBuffer.h"
15 
16 class GrVertexBuffer : public GrGeometryBuffer {
17 public:
ComputeScratchKey(size_t size,bool dynamic,GrScratchKey * key)18     static void ComputeScratchKey(size_t size, bool dynamic, GrScratchKey* key) {
19         static const GrScratchKey::ResourceType kType = GrScratchKey::GenerateResourceType();
20 
21         GrScratchKey::Builder builder(key, kType, 2);
22 
23         builder[0] = SkToUInt(size);
24         builder[1] = dynamic ? 1 : 0;
25     }
26 
27 protected:
GrVertexBuffer(GrGpu * gpu,size_t gpuMemorySize,bool dynamic,bool cpuBacked)28     GrVertexBuffer(GrGpu* gpu, size_t gpuMemorySize, bool dynamic, bool cpuBacked)
29         : INHERITED(gpu, gpuMemorySize, dynamic, cpuBacked) {
30         // We currently only make buffers scratch if they're both pow2 sized and not cpuBacked.
31         if (!cpuBacked && SkIsPow2(gpuMemorySize)) {
32             GrScratchKey key;
33             ComputeScratchKey(gpuMemorySize, dynamic, &key);
34             this->setScratchKey(key);
35         }
36     }
37 
38 private:
39     typedef GrGeometryBuffer INHERITED;
40 };
41 
42 #endif
43