OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 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 GrTypesPriv_DEFINED | 8 #ifndef GrTypesPriv_DEFINED |
9 #define GrTypesPriv_DEFINED | 9 #define GrTypesPriv_DEFINED |
10 | 10 |
11 #include "GrTypes.h" | 11 #include "GrTypes.h" |
| 12 #include "SkRect.h" |
12 #include "SkRefCnt.h" | 13 #include "SkRefCnt.h" |
13 | 14 |
14 /** | 15 /** |
15 * Types of shader-language-specific boxed variables we can create. (Currently
only GrGLShaderVars, | 16 * Types of shader-language-specific boxed variables we can create. (Currently
only GrGLShaderVars, |
16 * but should be applicable to other shader languages.) | 17 * but should be applicable to other shader languages.) |
17 */ | 18 */ |
18 enum GrSLType { | 19 enum GrSLType { |
19 kVoid_GrSLType, | 20 kVoid_GrSLType, |
20 kFloat_GrSLType, | 21 kFloat_GrSLType, |
21 kVec2f_GrSLType, | 22 kVec2f_GrSLType, |
(...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
412 | 413 |
413 /** | 414 /** |
414 * Indicates the type of pending IO operations that can be recorded for gpu reso
urces. | 415 * Indicates the type of pending IO operations that can be recorded for gpu reso
urces. |
415 */ | 416 */ |
416 enum GrIOType { | 417 enum GrIOType { |
417 kRead_GrIOType, | 418 kRead_GrIOType, |
418 kWrite_GrIOType, | 419 kWrite_GrIOType, |
419 kRW_GrIOType | 420 kRW_GrIOType |
420 }; | 421 }; |
421 | 422 |
| 423 struct GrScissorState { |
| 424 GrScissorState() : fEnabled(false) {} |
| 425 GrScissorState(const SkIRect& rect) : fEnabled(true), fRect(rect) {} |
| 426 void setDisabled() { fEnabled = false; } |
| 427 void set(const SkIRect& rect) { fRect = rect; fEnabled = true; } |
| 428 bool SK_WARN_UNUSED_RESULT intersect(const SkIRect& rect) { |
| 429 if (!fEnabled) { |
| 430 this->set(rect); |
| 431 return true; |
| 432 } |
| 433 return fRect.intersect(rect); |
| 434 } |
| 435 bool operator==(const GrScissorState& other) const { |
| 436 return fEnabled == other.fEnabled && |
| 437 (false == fEnabled || fRect == other.fRect); |
| 438 } |
| 439 bool operator!=(const GrScissorState& other) const { return !(*this == other
); } |
| 440 |
| 441 bool enabled() const { return fEnabled; } |
| 442 const SkIRect& rect() const { return fRect; } |
| 443 |
| 444 private: |
| 445 bool fEnabled; |
| 446 SkIRect fRect; |
| 447 }; |
| 448 |
422 /** | 449 /** |
423 * Indicates the type of data that a GPU buffer will be used for. | 450 * Indicates the type of data that a GPU buffer will be used for. |
424 */ | 451 */ |
425 enum GrBufferType { | 452 enum GrBufferType { |
426 kVertex_GrBufferType, | 453 kVertex_GrBufferType, |
427 kIndex_GrBufferType, | 454 kIndex_GrBufferType, |
428 kTexel_GrBufferType, | 455 kTexel_GrBufferType, |
429 kDrawIndirect_GrBufferType, | 456 kDrawIndirect_GrBufferType, |
430 kXferCpuToGpu_GrBufferType, | 457 kXferCpuToGpu_GrBufferType, |
431 kXferGpuToCpu_GrBufferType, | 458 kXferGpuToCpu_GrBufferType, |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
476 /** Holder destroys the backend object. */ | 503 /** Holder destroys the backend object. */ |
477 kOwned = true | 504 kOwned = true |
478 }; | 505 }; |
479 | 506 |
480 template <typename T> T * const * sk_sp_address_as_pointer_address(sk_sp<T> cons
t * sp) { | 507 template <typename T> T * const * sk_sp_address_as_pointer_address(sk_sp<T> cons
t * sp) { |
481 static_assert(sizeof(T*) == sizeof(sk_sp<T>), "sk_sp not expected size."); | 508 static_assert(sizeof(T*) == sizeof(sk_sp<T>), "sk_sp not expected size."); |
482 return reinterpret_cast<T * const *>(sp); | 509 return reinterpret_cast<T * const *>(sp); |
483 } | 510 } |
484 | 511 |
485 #endif | 512 #endif |
OLD | NEW |