epoger@google.com | ec3ed6a | 2011-07-28 14:26:00 +0000 | [diff] [blame] | 1 | |
| 2 | /* |
| 3 | * Copyright 2006 The Android Open Source Project |
| 4 | * |
| 5 | * Use of this source code is governed by a BSD-style license that can be |
| 6 | * found in the LICENSE file. |
| 7 | */ |
| 8 | |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 9 | |
| 10 | #include "SkBoundable.h" |
| 11 | #include "SkAnimateMaker.h" |
| 12 | #include "SkCanvas.h" |
| 13 | |
| 14 | SkBoundable::SkBoundable() { |
| 15 | clearBounds(); |
| 16 | fBounds.fTop = 0; |
| 17 | fBounds.fRight = 0; |
| 18 | fBounds.fBottom = 0; |
| 19 | } |
| 20 | |
| 21 | void SkBoundable::clearBounder() { |
| 22 | fBounds.fLeft = 0x7fff; |
| 23 | } |
| 24 | |
| 25 | void SkBoundable::getBounds(SkRect* rect) { |
| 26 | SkASSERT(rect); |
| 27 | if (fBounds.fLeft == (int16_t)0x8000U) { |
| 28 | INHERITED::getBounds(rect); |
| 29 | return; |
| 30 | } |
| 31 | rect->fLeft = SkIntToScalar(fBounds.fLeft); |
| 32 | rect->fTop = SkIntToScalar(fBounds.fTop); |
| 33 | rect->fRight = SkIntToScalar(fBounds.fRight); |
| 34 | rect->fBottom = SkIntToScalar(fBounds.fBottom); |
| 35 | } |
| 36 | |
| 37 | void SkBoundable::enableBounder() { |
| 38 | fBounds.fLeft = 0; |
| 39 | } |
| 40 | |
| 41 | |
rmistry@google.com | d6176b0 | 2012-08-23 18:14:13 +0000 | [diff] [blame] | 42 | SkBoundableAuto::SkBoundableAuto(SkBoundable* boundable, |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 43 | SkAnimateMaker& maker) : fBoundable(boundable), fMaker(maker) { |
| 44 | if (fBoundable->hasBounds()) { |
reed | 868074b | 2014-06-03 10:53:59 -0700 | [diff] [blame] | 45 | // fMaker.fCanvas->setBounder(&maker.fDisplayList); |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 46 | fMaker.fDisplayList.fBounds.setEmpty(); |
| 47 | } |
| 48 | } |
| 49 | |
| 50 | SkBoundableAuto::~SkBoundableAuto() { |
| 51 | if (fBoundable->hasBounds() == false) |
| 52 | return; |
halcanary | 96fcdcc | 2015-08-27 07:41:13 -0700 | [diff] [blame] | 53 | // fMaker.fCanvas->setBounder(nullptr); |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 54 | fBoundable->setBounds(fMaker.fDisplayList.fBounds); |
| 55 | } |