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