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 |
(...skipping 407 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
418 kRead_GrIOType, | 418 kRead_GrIOType, |
419 kWrite_GrIOType, | 419 kWrite_GrIOType, |
420 kRW_GrIOType | 420 kRW_GrIOType |
421 }; | 421 }; |
422 | 422 |
423 struct GrScissorState { | 423 struct GrScissorState { |
424 GrScissorState() : fEnabled(false) {} | 424 GrScissorState() : fEnabled(false) {} |
425 GrScissorState(const SkIRect& rect) : fEnabled(true), fRect(rect) {} | 425 GrScissorState(const SkIRect& rect) : fEnabled(true), fRect(rect) {} |
426 void setDisabled() { fEnabled = false; } | 426 void setDisabled() { fEnabled = false; } |
427 void set(const SkIRect& rect) { fRect = rect; fEnabled = true; } | 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 } |
428 bool operator==(const GrScissorState& other) const { | 435 bool operator==(const GrScissorState& other) const { |
429 return fEnabled == other.fEnabled && | 436 return fEnabled == other.fEnabled && |
430 (false == fEnabled || fRect == other.fRect); | 437 (false == fEnabled || fRect == other.fRect); |
431 } | 438 } |
432 bool operator!=(const GrScissorState& other) const { return !(*this == other
); } | 439 bool operator!=(const GrScissorState& other) const { return !(*this == other
); } |
433 | 440 |
434 bool enabled() const { return fEnabled; } | 441 bool enabled() const { return fEnabled; } |
435 const SkIRect& rect() const { return fRect; } | 442 const SkIRect& rect() const { return fRect; } |
436 | 443 |
437 private: | 444 private: |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
496 /** Holder destroys the backend object. */ | 503 /** Holder destroys the backend object. */ |
497 kOwned = true | 504 kOwned = true |
498 }; | 505 }; |
499 | 506 |
500 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) { |
501 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."); |
502 return reinterpret_cast<T * const *>(sp); | 509 return reinterpret_cast<T * const *>(sp); |
503 } | 510 } |
504 | 511 |
505 #endif | 512 #endif |
OLD | NEW |