blob: 3c62cd61ca7f3c7e7dff63149cecb97d52dd890d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
/*
* Copyright 2010 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#ifndef GrVertexBuffer_DEFINED
#define GrVertexBuffer_DEFINED
#include "GrGeometryBuffer.h"
class GrVertexBuffer : public GrGeometryBuffer {
public:
static void ComputeScratchKey(size_t size, bool dynamic, GrScratchKey* key) {
static const GrScratchKey::ResourceType kType = GrScratchKey::GenerateResourceType();
GrScratchKey::Builder builder(key, kType, 2);
builder[0] = SkToUInt(size);
builder[1] = dynamic ? 1 : 0;
}
protected:
GrVertexBuffer(GrGpu* gpu, size_t gpuMemorySize, bool dynamic, bool cpuBacked)
: INHERITED(gpu, gpuMemorySize, dynamic, cpuBacked) {
// We currently only make buffers scratch if they're both pow2 sized and not cpuBacked.
if (!cpuBacked && SkIsPow2(gpuMemorySize)) {
GrScratchKey key;
ComputeScratchKey(gpuMemorySize, dynamic, &key);
this->setScratchKey(key);
}
}
private:
typedef GrGeometryBuffer INHERITED;
};
#endif
|