michael@0: michael@0: /* michael@0: * Copyright 2006 The Android Open Source Project michael@0: * michael@0: * Use of this source code is governed by a BSD-style license that can be michael@0: * found in the LICENSE file. michael@0: */ michael@0: michael@0: michael@0: #include "SkBoundable.h" michael@0: #include "SkAnimateMaker.h" michael@0: #include "SkCanvas.h" michael@0: michael@0: SkBoundable::SkBoundable() { michael@0: clearBounds(); michael@0: fBounds.fTop = 0; michael@0: fBounds.fRight = 0; michael@0: fBounds.fBottom = 0; michael@0: } michael@0: michael@0: void SkBoundable::clearBounder() { michael@0: fBounds.fLeft = 0x7fff; michael@0: } michael@0: michael@0: void SkBoundable::getBounds(SkRect* rect) { michael@0: SkASSERT(rect); michael@0: if (fBounds.fLeft == (int16_t)0x8000U) { michael@0: INHERITED::getBounds(rect); michael@0: return; michael@0: } michael@0: rect->fLeft = SkIntToScalar(fBounds.fLeft); michael@0: rect->fTop = SkIntToScalar(fBounds.fTop); michael@0: rect->fRight = SkIntToScalar(fBounds.fRight); michael@0: rect->fBottom = SkIntToScalar(fBounds.fBottom); michael@0: } michael@0: michael@0: void SkBoundable::enableBounder() { michael@0: fBounds.fLeft = 0; michael@0: } michael@0: michael@0: michael@0: SkBoundableAuto::SkBoundableAuto(SkBoundable* boundable, michael@0: SkAnimateMaker& maker) : fBoundable(boundable), fMaker(maker) { michael@0: if (fBoundable->hasBounds()) { michael@0: fMaker.fCanvas->setBounder(&maker.fDisplayList); michael@0: fMaker.fDisplayList.fBounds.setEmpty(); michael@0: } michael@0: } michael@0: michael@0: SkBoundableAuto::~SkBoundableAuto() { michael@0: if (fBoundable->hasBounds() == false) michael@0: return; michael@0: fMaker.fCanvas->setBounder(NULL); michael@0: fBoundable->setBounds(fMaker.fDisplayList.fBounds); michael@0: }