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.

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

mercurial