aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/animator/SkBoundable.cpp
blob: e784e9f6d0e1f3b46da941952c1e4c63f1eda879 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55

/*
 * Copyright 2006 The Android Open Source Project
 *
 * Use of this source code is governed by a BSD-style license that can be
 * found in the LICENSE file.
 */


#include "SkBoundable.h"
#include "SkAnimateMaker.h"
#include "SkCanvas.h"

SkBoundable::SkBoundable() {
    clearBounds();
    fBounds.fTop = 0;
    fBounds.fRight = 0;
    fBounds.fBottom = 0;
}

void SkBoundable::clearBounder() {
    fBounds.fLeft = 0x7fff;
}

void SkBoundable::getBounds(SkRect* rect) {
    SkASSERT(rect);
    if (fBounds.fLeft == (int16_t)0x8000U) {
        INHERITED::getBounds(rect);
        return;
    }
    rect->fLeft = SkIntToScalar(fBounds.fLeft);
    rect->fTop = SkIntToScalar(fBounds.fTop);
    rect->fRight = SkIntToScalar(fBounds.fRight);
    rect->fBottom = SkIntToScalar(fBounds.fBottom);
}

void SkBoundable::enableBounder() {
    fBounds.fLeft = 0;
}


SkBoundableAuto::SkBoundableAuto(SkBoundable* boundable,
        SkAnimateMaker& maker) : fBoundable(boundable), fMaker(maker) {
    if (fBoundable->hasBounds()) {
//        fMaker.fCanvas->setBounder(&maker.fDisplayList);
        fMaker.fDisplayList.fBounds.setEmpty();
    }
}

SkBoundableAuto::~SkBoundableAuto() {
    if (fBoundable->hasBounds() == false)
        return;
//    fMaker.fCanvas->setBounder(nullptr);
    fBoundable->setBounds(fMaker.fDisplayList.fBounds);
}