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

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.

michael@0 1
michael@0 2 /*
michael@0 3 * Copyright 2008 The Android Open Source Project
michael@0 4 *
michael@0 5 * Use of this source code is governed by a BSD-style license that can be
michael@0 6 * found in the LICENSE file.
michael@0 7 */
michael@0 8
michael@0 9
michael@0 10 #include "SkPageFlipper.h"
michael@0 11
michael@0 12 SkPageFlipper::SkPageFlipper() {
michael@0 13 fWidth = 0;
michael@0 14 fHeight = 0;
michael@0 15 fDirty0 = &fDirty0Storage;
michael@0 16 fDirty1 = &fDirty1Storage;
michael@0 17
michael@0 18 fDirty0->setEmpty();
michael@0 19 fDirty1->setEmpty();
michael@0 20 }
michael@0 21
michael@0 22 SkPageFlipper::SkPageFlipper(int width, int height) {
michael@0 23 fWidth = width;
michael@0 24 fHeight = height;
michael@0 25 fDirty0 = &fDirty0Storage;
michael@0 26 fDirty1 = &fDirty1Storage;
michael@0 27
michael@0 28 fDirty0->setRect(0, 0, width, height);
michael@0 29 fDirty1->setEmpty();
michael@0 30 }
michael@0 31
michael@0 32 void SkPageFlipper::resize(int width, int height) {
michael@0 33 fWidth = width;
michael@0 34 fHeight = height;
michael@0 35
michael@0 36 // this is the opposite of the constructors
michael@0 37 fDirty1->setRect(0, 0, width, height);
michael@0 38 fDirty0->setEmpty();
michael@0 39 }
michael@0 40
michael@0 41 void SkPageFlipper::inval() {
michael@0 42 fDirty1->setRect(0, 0, fWidth, fHeight);
michael@0 43 }
michael@0 44
michael@0 45 void SkPageFlipper::inval(const SkIRect& rect) {
michael@0 46 SkIRect r;
michael@0 47 r.set(0, 0, fWidth, fHeight);
michael@0 48 if (r.intersect(rect)) {
michael@0 49 fDirty1->op(r, SkRegion::kUnion_Op);
michael@0 50 }
michael@0 51 }
michael@0 52
michael@0 53 void SkPageFlipper::inval(const SkRegion& rgn) {
michael@0 54 SkRegion r;
michael@0 55 r.setRect(0, 0, fWidth, fHeight);
michael@0 56 if (r.op(rgn, SkRegion::kIntersect_Op)) {
michael@0 57 fDirty1->op(r, SkRegion::kUnion_Op);
michael@0 58 }
michael@0 59 }
michael@0 60
michael@0 61 void SkPageFlipper::inval(const SkRect& rect, bool antialias) {
michael@0 62 SkIRect r;
michael@0 63 rect.round(&r);
michael@0 64 if (antialias) {
michael@0 65 r.inset(-1, -1);
michael@0 66 }
michael@0 67 this->inval(r);
michael@0 68 }
michael@0 69
michael@0 70 const SkRegion& SkPageFlipper::update(SkRegion* copyBits) {
michael@0 71 // Copy over anything new from page0 that isn't dirty in page1
michael@0 72 copyBits->op(*fDirty0, *fDirty1, SkRegion::kDifference_Op);
michael@0 73 SkTSwap<SkRegion*>(fDirty0, fDirty1);
michael@0 74 fDirty1->setEmpty();
michael@0 75 return *fDirty0;
michael@0 76 }

mercurial