OLD | NEW |
---|---|
(Empty) | |
1 /* | |
2 * Copyright 2016 Google Inc. | |
3 * | |
4 * Use of this source code is governed by a BSD-style license that can be | |
5 * found in the LICENSE file. | |
6 */ | |
7 | |
8 #ifndef GrBufferAccess_DEFINED | |
9 #define GrBufferAccess_DEFINED | |
10 | |
11 #include "GrBuffer.h" | |
12 #include "GrGpuResourceRef.h" | |
13 | |
14 /** | |
15 * Used to represent a texel buffer that will be read in a GrProcessor. It holds a GrBuffer along | |
16 * with an associated offset and texel config. | |
17 */ | |
18 class GrBufferAccess : public SkNoncopyable { | |
19 public: | |
20 /** | |
21 * Must be initialized before adding to a GrProcessor's buffer access list. | |
22 */ | |
23 void reset(intptr_t offsetInBytes, GrPixelConfig texelConfig, GrBuffer* buff er, | |
24 GrShaderFlags visibility = kFragment_GrShaderFlag) { | |
25 fOffsetInBytes = offsetInBytes; | |
26 fTexelConfig = texelConfig; | |
27 fBuffer.set(SkRef(buffer), kRead_GrIOType); | |
28 fVisibility = visibility; | |
29 } | |
30 | |
31 bool operator==(const GrBufferAccess& that) const { | |
32 return fOffsetInBytes == that.fOffsetInBytes && | |
33 fTexelConfig == that.fTexelConfig && | |
34 this->buffer() == that.buffer() && | |
35 fVisibility == that.fVisibility; | |
36 } | |
37 | |
38 bool operator!=(const GrBufferAccess& other) const { return !(*this == other ); } | |
bsalomon
2016/04/11 16:51:38
other->that? just for consistency with op==
Chris Dalton
2016/04/11 19:48:18
Done.
| |
39 | |
40 intptr_t offsetInBytes() const { return fOffsetInBytes; } | |
41 GrPixelConfig texelConfig() const { return fTexelConfig; } | |
42 GrBuffer* buffer() const { return fBuffer.get(); } | |
43 GrShaderFlags visibility() const { return fVisibility; } | |
44 | |
45 /** | |
46 * For internal use by GrProcessor. | |
47 */ | |
48 const GrGpuResourceRef* getProgramBuffer() const { return &fBuffer;} | |
49 | |
50 private: | |
51 intptr_t fOffsetInBytes; | |
52 GrPixelConfig fTexelConfig; | |
53 GrTGpuResourceRef<GrBuffer> fBuffer; | |
54 GrShaderFlags fVisibility; | |
55 | |
56 typedef SkNoncopyable INHERITED; | |
57 }; | |
58 | |
59 #endif | |
OLD | NEW |