gfx/skia/trunk/src/images/SkPageFlipper.cpp

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/gfx/skia/trunk/src/images/SkPageFlipper.cpp	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,76 @@
     1.4 +
     1.5 +/*
     1.6 + * Copyright 2008 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 "SkPageFlipper.h"
    1.14 +
    1.15 +SkPageFlipper::SkPageFlipper() {
    1.16 +    fWidth = 0;
    1.17 +    fHeight = 0;
    1.18 +    fDirty0 = &fDirty0Storage;
    1.19 +    fDirty1 = &fDirty1Storage;
    1.20 +
    1.21 +    fDirty0->setEmpty();
    1.22 +    fDirty1->setEmpty();
    1.23 +}
    1.24 +
    1.25 +SkPageFlipper::SkPageFlipper(int width, int height) {
    1.26 +    fWidth = width;
    1.27 +    fHeight = height;
    1.28 +    fDirty0 = &fDirty0Storage;
    1.29 +    fDirty1 = &fDirty1Storage;
    1.30 +
    1.31 +    fDirty0->setRect(0, 0, width, height);
    1.32 +    fDirty1->setEmpty();
    1.33 +}
    1.34 +
    1.35 +void SkPageFlipper::resize(int width, int height) {
    1.36 +    fWidth = width;
    1.37 +    fHeight = height;
    1.38 +
    1.39 +    // this is the opposite of the constructors
    1.40 +    fDirty1->setRect(0, 0, width, height);
    1.41 +    fDirty0->setEmpty();
    1.42 +}
    1.43 +
    1.44 +void SkPageFlipper::inval() {
    1.45 +    fDirty1->setRect(0, 0, fWidth, fHeight);
    1.46 +}
    1.47 +
    1.48 +void SkPageFlipper::inval(const SkIRect& rect) {
    1.49 +    SkIRect r;
    1.50 +    r.set(0, 0, fWidth, fHeight);
    1.51 +    if (r.intersect(rect)) {
    1.52 +        fDirty1->op(r, SkRegion::kUnion_Op);
    1.53 +    }
    1.54 +}
    1.55 +
    1.56 +void SkPageFlipper::inval(const SkRegion& rgn) {
    1.57 +    SkRegion r;
    1.58 +    r.setRect(0, 0, fWidth, fHeight);
    1.59 +    if (r.op(rgn, SkRegion::kIntersect_Op)) {
    1.60 +        fDirty1->op(r, SkRegion::kUnion_Op);
    1.61 +    }
    1.62 +}
    1.63 +
    1.64 +void SkPageFlipper::inval(const SkRect& rect, bool antialias) {
    1.65 +    SkIRect r;
    1.66 +    rect.round(&r);
    1.67 +    if (antialias) {
    1.68 +        r.inset(-1, -1);
    1.69 +    }
    1.70 +    this->inval(r);
    1.71 +}
    1.72 +
    1.73 +const SkRegion& SkPageFlipper::update(SkRegion* copyBits) {
    1.74 +    // Copy over anything new from page0 that isn't dirty in page1
    1.75 +    copyBits->op(*fDirty0, *fDirty1, SkRegion::kDifference_Op);
    1.76 +    SkTSwap<SkRegion*>(fDirty0, fDirty1);
    1.77 +    fDirty1->setEmpty();
    1.78 +    return *fDirty0;
    1.79 +}

mercurial