gfx/skia/trunk/src/animator/SkBoundable.cpp

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/gfx/skia/trunk/src/animator/SkBoundable.cpp	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,55 @@
     1.4 +
     1.5 +/*
     1.6 + * Copyright 2006 The Android Open Source Project
     1.7 + *
     1.8 + * Use of this source code is governed by a BSD-style license that can be
     1.9 + * found in the LICENSE file.
    1.10 + */
    1.11 +
    1.12 +
    1.13 +#include "SkBoundable.h"
    1.14 +#include "SkAnimateMaker.h"
    1.15 +#include "SkCanvas.h"
    1.16 +
    1.17 +SkBoundable::SkBoundable() {
    1.18 +    clearBounds();
    1.19 +    fBounds.fTop = 0;
    1.20 +    fBounds.fRight = 0;
    1.21 +    fBounds.fBottom = 0;
    1.22 +}
    1.23 +
    1.24 +void SkBoundable::clearBounder() {
    1.25 +    fBounds.fLeft = 0x7fff;
    1.26 +}
    1.27 +
    1.28 +void SkBoundable::getBounds(SkRect* rect) {
    1.29 +    SkASSERT(rect);
    1.30 +    if (fBounds.fLeft == (int16_t)0x8000U) {
    1.31 +        INHERITED::getBounds(rect);
    1.32 +        return;
    1.33 +    }
    1.34 +    rect->fLeft = SkIntToScalar(fBounds.fLeft);
    1.35 +    rect->fTop = SkIntToScalar(fBounds.fTop);
    1.36 +    rect->fRight = SkIntToScalar(fBounds.fRight);
    1.37 +    rect->fBottom = SkIntToScalar(fBounds.fBottom);
    1.38 +}
    1.39 +
    1.40 +void SkBoundable::enableBounder() {
    1.41 +    fBounds.fLeft = 0;
    1.42 +}
    1.43 +
    1.44 +
    1.45 +SkBoundableAuto::SkBoundableAuto(SkBoundable* boundable,
    1.46 +        SkAnimateMaker& maker) : fBoundable(boundable), fMaker(maker) {
    1.47 +    if (fBoundable->hasBounds()) {
    1.48 +        fMaker.fCanvas->setBounder(&maker.fDisplayList);
    1.49 +        fMaker.fDisplayList.fBounds.setEmpty();
    1.50 +    }
    1.51 +}
    1.52 +
    1.53 +SkBoundableAuto::~SkBoundableAuto() {
    1.54 +    if (fBoundable->hasBounds() == false)
    1.55 +        return;
    1.56 +    fMaker.fCanvas->setBounder(NULL);
    1.57 +    fBoundable->setBounds(fMaker.fDisplayList.fBounds);
    1.58 +}

mercurial