OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2011 Google Inc. | 3 * Copyright 2011 Google Inc. |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
7 */ | 7 */ |
8 | 8 |
9 | 9 |
10 #ifndef GrStencil_DEFINED | 10 #ifndef GrStencil_DEFINED |
11 #define GrStencil_DEFINED | 11 #define GrStencil_DEFINED |
12 | 12 |
13 #include "GrTypes.h" | 13 #include "GrTypes.h" |
14 #include "SkRegion.h" | 14 #include "SkRegion.h" |
15 | 15 |
| 16 class GrProcessorKeyBuilder; |
| 17 |
16 /** | 18 /** |
17 * Gr uses the stencil buffer to implement complex clipping inside the | 19 * Gr uses the stencil buffer to implement complex clipping inside the |
18 * GrDrawTarget class. The GrDrawTarget makes a subset of the stencil buffer | 20 * GrDrawTarget class. The GrDrawTarget makes a subset of the stencil buffer |
19 * bits available for other uses by external code (clients). Client code can | 21 * bits available for other uses by external code (clients). Client code can |
20 * modify these bits. GrDrawTarget will ignore ref, mask, and writemask bits | 22 * modify these bits. GrDrawTarget will ignore ref, mask, and writemask bits |
21 * provided by clients that overlap the bits used to implement clipping. | 23 * provided by clients that overlap the bits used to implement clipping. |
22 * | 24 * |
23 * When code outside the GrDrawTarget class uses the stencil buffer the contract | 25 * When code outside the GrDrawTarget class uses the stencil buffer the contract |
24 * is as follows: | 26 * is as follows: |
25 * | 27 * |
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
278 void invalidate() { | 280 void invalidate() { |
279 // write an illegal value to the first member | 281 // write an illegal value to the first member |
280 fPassOps[0] = kStencilOpCount; | 282 fPassOps[0] = kStencilOpCount; |
281 fFlags = 0; | 283 fFlags = 0; |
282 } | 284 } |
283 | 285 |
284 bool isValid() const { | 286 bool isValid() const { |
285 return fPassOps[0] < kStencilOpCount; | 287 return fPassOps[0] < kStencilOpCount; |
286 } | 288 } |
287 | 289 |
| 290 void genKey(GrProcessorKeyBuilder* b) const; |
| 291 |
288 bool operator == (const GrStencilSettings& s) const { | 292 bool operator == (const GrStencilSettings& s) const { |
289 static const size_t gCompareSize = sizeof(GrStencilSettings) - | 293 static const size_t gCompareSize = sizeof(GrStencilSettings) - |
290 sizeof(fFlags); | 294 sizeof(fFlags); |
291 SkASSERT((const char*)&fFlags + sizeof(fFlags) == | 295 SkASSERT((const char*)&fFlags + sizeof(fFlags) == |
292 (const char*)this + sizeof(GrStencilSettings)); | 296 (const char*)this + sizeof(GrStencilSettings)); |
293 if (this->isDisabled() & s.isDisabled()) { // using & not && | 297 if (this->isDisabled() & s.isDisabled()) { // using & not && |
294 return true; | 298 return true; |
295 } | 299 } |
296 return 0 == memcmp(this, &s, gCompareSize); | 300 return 0 == memcmp(this, &s, gCompareSize); |
297 } | 301 } |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
390 *GR_CONST_STENCIL_SETTINGS_PTR_FROM_STRUCT_PTR(&(NAME ## _STRUCT)); | 394 *GR_CONST_STENCIL_SETTINGS_PTR_FROM_STRUCT_PTR(&(NAME ## _STRUCT)); |
391 | 395 |
392 | 396 |
393 #define GR_STATIC_CONST_SAME_STENCIL(NAME, \ | 397 #define GR_STATIC_CONST_SAME_STENCIL(NAME, \ |
394 PASS_OP, FAIL_OP, FUNC, MASK, REF, WRITE_MASK) \ | 398 PASS_OP, FAIL_OP, FUNC, MASK, REF, WRITE_MASK) \ |
395 GR_STATIC_CONST_STENCIL(NAME, (PASS_OP), (PASS_OP), (FAIL_OP), \ | 399 GR_STATIC_CONST_STENCIL(NAME, (PASS_OP), (PASS_OP), (FAIL_OP), \ |
396 (FAIL_OP), (FUNC), (FUNC), (MASK), (MASK), (REF), (REF), (WRITE_MASK), \ | 400 (FAIL_OP), (FUNC), (FUNC), (MASK), (MASK), (REF), (REF), (WRITE_MASK), \ |
397 (WRITE_MASK)) | 401 (WRITE_MASK)) |
398 | 402 |
399 #endif | 403 #endif |
OLD | NEW |