gfx/skia/trunk/src/core/SkBBoxHierarchyRecord.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 2012 Google Inc.
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 #include "SkBBoxHierarchyRecord.h"
michael@0 10 #include "SkPictureStateTree.h"
michael@0 11
michael@0 12 SkBBoxHierarchyRecord::SkBBoxHierarchyRecord(const SkISize& size,
michael@0 13 uint32_t recordFlags,
michael@0 14 SkBBoxHierarchy* h)
michael@0 15 : INHERITED(size, recordFlags) {
michael@0 16 fStateTree = SkNEW(SkPictureStateTree);
michael@0 17 fBoundingHierarchy = h;
michael@0 18 fBoundingHierarchy->ref();
michael@0 19 fBoundingHierarchy->setClient(this);
michael@0 20 }
michael@0 21
michael@0 22 void SkBBoxHierarchyRecord::handleBBox(const SkRect& bounds) {
michael@0 23 SkIRect r;
michael@0 24 bounds.roundOut(&r);
michael@0 25 SkPictureStateTree::Draw* draw = fStateTree->appendDraw(this->writeStream().bytesWritten());
michael@0 26 fBoundingHierarchy->insert(draw, r, true);
michael@0 27 }
michael@0 28
michael@0 29 void SkBBoxHierarchyRecord::willSave(SaveFlags flags) {
michael@0 30 fStateTree->appendSave();
michael@0 31 this->INHERITED::willSave(flags);
michael@0 32 }
michael@0 33
michael@0 34 SkCanvas::SaveLayerStrategy SkBBoxHierarchyRecord::willSaveLayer(const SkRect* bounds,
michael@0 35 const SkPaint* paint,
michael@0 36 SaveFlags flags) {
michael@0 37 fStateTree->appendSaveLayer(this->writeStream().bytesWritten());
michael@0 38 return this->INHERITED::willSaveLayer(bounds, paint, flags);
michael@0 39 }
michael@0 40
michael@0 41 void SkBBoxHierarchyRecord::willRestore() {
michael@0 42 fStateTree->appendRestore();
michael@0 43 this->INHERITED::willRestore();
michael@0 44 }
michael@0 45
michael@0 46 void SkBBoxHierarchyRecord::didTranslate(SkScalar dx, SkScalar dy) {
michael@0 47 fStateTree->appendTransform(getTotalMatrix());
michael@0 48 INHERITED::didTranslate(dx, dy);
michael@0 49 }
michael@0 50
michael@0 51 void SkBBoxHierarchyRecord::didScale(SkScalar sx, SkScalar sy) {
michael@0 52 fStateTree->appendTransform(getTotalMatrix());
michael@0 53 INHERITED::didScale(sx, sy);
michael@0 54 }
michael@0 55
michael@0 56 void SkBBoxHierarchyRecord::didRotate(SkScalar degrees) {
michael@0 57 fStateTree->appendTransform(getTotalMatrix());
michael@0 58 INHERITED::didRotate(degrees);
michael@0 59 }
michael@0 60
michael@0 61 void SkBBoxHierarchyRecord::didSkew(SkScalar sx, SkScalar sy) {
michael@0 62 fStateTree->appendTransform(getTotalMatrix());
michael@0 63 INHERITED::didSkew(sx, sy);
michael@0 64 }
michael@0 65
michael@0 66 void SkBBoxHierarchyRecord::didConcat(const SkMatrix& matrix) {
michael@0 67 fStateTree->appendTransform(getTotalMatrix());
michael@0 68 INHERITED::didConcat(matrix);
michael@0 69 }
michael@0 70
michael@0 71 void SkBBoxHierarchyRecord::didSetMatrix(const SkMatrix& matrix) {
michael@0 72 fStateTree->appendTransform(getTotalMatrix());
michael@0 73 INHERITED::didSetMatrix(matrix);
michael@0 74 }
michael@0 75
michael@0 76 void SkBBoxHierarchyRecord::onClipRect(const SkRect& rect,
michael@0 77 SkRegion::Op op,
michael@0 78 ClipEdgeStyle edgeStyle) {
michael@0 79 fStateTree->appendClip(this->writeStream().bytesWritten());
michael@0 80 this->INHERITED::onClipRect(rect, op, edgeStyle);
michael@0 81 }
michael@0 82
michael@0 83 void SkBBoxHierarchyRecord::onClipRegion(const SkRegion& region,
michael@0 84 SkRegion::Op op) {
michael@0 85 fStateTree->appendClip(this->writeStream().bytesWritten());
michael@0 86 this->INHERITED::onClipRegion(region, op);
michael@0 87 }
michael@0 88
michael@0 89 void SkBBoxHierarchyRecord::onClipPath(const SkPath& path,
michael@0 90 SkRegion::Op op,
michael@0 91 ClipEdgeStyle edgeStyle) {
michael@0 92 fStateTree->appendClip(this->writeStream().bytesWritten());
michael@0 93 this->INHERITED::onClipPath(path, op, edgeStyle);
michael@0 94 }
michael@0 95
michael@0 96 void SkBBoxHierarchyRecord::onClipRRect(const SkRRect& rrect,
michael@0 97 SkRegion::Op op,
michael@0 98 ClipEdgeStyle edgeStyle) {
michael@0 99 fStateTree->appendClip(this->writeStream().bytesWritten());
michael@0 100 this->INHERITED::onClipRRect(rrect, op, edgeStyle);
michael@0 101 }
michael@0 102
michael@0 103 bool SkBBoxHierarchyRecord::shouldRewind(void* data) {
michael@0 104 // SkBBoxHierarchy::rewindInserts is called by SkPicture after the
michael@0 105 // SkPicture has rewound its command stream. To match that rewind in the
michael@0 106 // BBH, we rewind all draws that reference commands that were recorded
michael@0 107 // past the point to which the SkPicture has rewound, which is given by
michael@0 108 // writeStream().bytesWritten().
michael@0 109 SkPictureStateTree::Draw* draw = static_cast<SkPictureStateTree::Draw*>(data);
michael@0 110 return draw->fOffset >= writeStream().bytesWritten();
michael@0 111 }

mercurial