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" | |
13 #include "SkRefCnt.h" | 12 #include "SkRefCnt.h" |
14 | 13 |
15 /** | 14 /** |
16 * Types of shader-language-specific boxed variables we can create. (Currently
only GrGLShaderVars, | 15 * Types of shader-language-specific boxed variables we can create. (Currently
only GrGLShaderVars, |
17 * but should be applicable to other shader languages.) | 16 * but should be applicable to other shader languages.) |
18 */ | 17 */ |
19 enum GrSLType { | 18 enum GrSLType { |
20 kVoid_GrSLType, | 19 kVoid_GrSLType, |
21 kFloat_GrSLType, | 20 kFloat_GrSLType, |
22 kVec2f_GrSLType, | 21 kVec2f_GrSLType, |
(...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
413 | 412 |
414 /** | 413 /** |
415 * Indicates the type of pending IO operations that can be recorded for gpu reso
urces. | 414 * Indicates the type of pending IO operations that can be recorded for gpu reso
urces. |
416 */ | 415 */ |
417 enum GrIOType { | 416 enum GrIOType { |
418 kRead_GrIOType, | 417 kRead_GrIOType, |
419 kWrite_GrIOType, | 418 kWrite_GrIOType, |
420 kRW_GrIOType | 419 kRW_GrIOType |
421 }; | 420 }; |
422 | 421 |
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 | |
449 /** | 422 /** |
450 * Indicates the type of data that a GPU buffer will be used for. | 423 * Indicates the type of data that a GPU buffer will be used for. |
451 */ | 424 */ |
452 enum GrBufferType { | 425 enum GrBufferType { |
453 kVertex_GrBufferType, | 426 kVertex_GrBufferType, |
454 kIndex_GrBufferType, | 427 kIndex_GrBufferType, |
455 kTexel_GrBufferType, | 428 kTexel_GrBufferType, |
456 kDrawIndirect_GrBufferType, | 429 kDrawIndirect_GrBufferType, |
457 kXferCpuToGpu_GrBufferType, | 430 kXferCpuToGpu_GrBufferType, |
458 kXferGpuToCpu_GrBufferType, | 431 kXferGpuToCpu_GrBufferType, |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
503 /** Holder destroys the backend object. */ | 476 /** Holder destroys the backend object. */ |
504 kOwned = true | 477 kOwned = true |
505 }; | 478 }; |
506 | 479 |
507 template <typename T> T * const * sk_sp_address_as_pointer_address(sk_sp<T> cons
t * sp) { | 480 template <typename T> T * const * sk_sp_address_as_pointer_address(sk_sp<T> cons
t * sp) { |
508 static_assert(sizeof(T*) == sizeof(sk_sp<T>), "sk_sp not expected size."); | 481 static_assert(sizeof(T*) == sizeof(sk_sp<T>), "sk_sp not expected size."); |
509 return reinterpret_cast<T * const *>(sp); | 482 return reinterpret_cast<T * const *>(sp); |
510 } | 483 } |
511 | 484 |
512 #endif | 485 #endif |
OLD | NEW |