gfx/skia/trunk/include/utils/SkLayer.h

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 2010 The Android Open Source Project
     4  *
     5  * Use of this source code is governed by a BSD-style license that can be
     6  * found in the LICENSE file.
     7  */
    10 #ifndef SkLayer_DEFINED
    11 #define SkLayer_DEFINED
    13 #include "SkRefCnt.h"
    14 #include "SkTDArray.h"
    15 #include "SkColor.h"
    16 #include "SkMatrix.h"
    17 #include "SkPoint.h"
    18 #include "SkRect.h"
    19 #include "SkSize.h"
    21 class SkCanvas;
    23 class SkLayer : public SkRefCnt {
    25 public:
    26     SK_DECLARE_INST_COUNT(SkLayer)
    28     SkLayer();
    29     SkLayer(const SkLayer&);
    30     virtual ~SkLayer();
    32     bool isInheritFromRootTransform() const;
    33     SkScalar getOpacity() const { return m_opacity; }
    34     const SkSize& getSize() const { return m_size; }
    35     const SkPoint& getPosition() const { return m_position; }
    36     const SkPoint& getAnchorPoint() const { return m_anchorPoint; }
    37     const SkMatrix& getMatrix() const { return fMatrix; }
    38     const SkMatrix& getChildrenMatrix() const { return fChildrenMatrix; }
    40     SkScalar getWidth() const { return m_size.width(); }
    41     SkScalar getHeight() const { return m_size.height(); }
    43     void setInheritFromRootTransform(bool);
    44     void setOpacity(SkScalar opacity) { m_opacity = opacity; }
    45     void setSize(SkScalar w, SkScalar h) { m_size.set(w, h); }
    46     void setPosition(SkScalar x, SkScalar y) { m_position.set(x, y); }
    47     void setAnchorPoint(SkScalar x, SkScalar y) { m_anchorPoint.set(x, y); }
    48     void setMatrix(const SkMatrix&);
    49     void setChildrenMatrix(const SkMatrix&);
    51     // children
    53     /** Return the number of layers in our child list.
    54      */
    55     int countChildren() const;
    57     /** Return the child at the specified index (starting at 0). This does not
    58         affect the reference count of the child.
    59      */
    60     SkLayer* getChild(int index) const;
    62     /** Add this layer to our child list at the end (top-most), and ref() it.
    63         If it was already in another hierarchy, remove it from that list.
    64         Return the new child.
    65      */
    66     SkLayer* addChild(SkLayer* child);
    68     /** Remove this layer from its parent's list (or do nothing if it has no
    69         parent.) If it had a parent, then unref() is called.
    70      */
    71     void detachFromParent();
    73     /** Remove, and unref(), all of the layers in our child list.
    74      */
    75     void removeChildren();
    77     /** Return our parent layer, or NULL if we have none.
    78      */
    79     SkLayer* getParent() const { return fParent; }
    81     /** Return the root layer in this hiearchy. If this layer is the root
    82         (i.e. has no parent), then this returns itself.
    83      */
    84     SkLayer* getRootLayer() const;
    86     // coordinate system transformations
    88     /** Return, in matrix, the matix transfomations that are applied locally
    89         when this layer draws (i.e. its position and matrix/anchorPoint).
    90         This does not include the childrenMatrix, since that is only applied
    91         after this layer draws (but before its children draw).
    92      */
    93     void getLocalTransform(SkMatrix* matrix) const;
    95     /** Return, in matrix, the concatenation of transforms that are applied
    96         from this layer's root parent to the layer itself.
    97         This is the matrix that is applied to the layer during drawing.
    98      */
    99     void localToGlobal(SkMatrix* matrix) const;
   101     // paint method
   103     void draw(SkCanvas*, SkScalar opacity);
   104     void draw(SkCanvas* canvas) {
   105         this->draw(canvas, SK_Scalar1);
   106     }
   108 protected:
   109     virtual void onDraw(SkCanvas*, SkScalar opacity);
   111 private:
   112     enum Flags {
   113         kInheritFromRootTransform_Flag = 0x01
   114     };
   116     SkLayer*    fParent;
   117     SkScalar    m_opacity;
   118     SkSize      m_size;
   119     SkPoint     m_position;
   120     SkPoint     m_anchorPoint;
   121     SkMatrix    fMatrix;
   122     SkMatrix    fChildrenMatrix;
   123     uint32_t    fFlags;
   125     SkTDArray<SkLayer*> m_children;
   127     typedef SkRefCnt INHERITED;
   128 };
   130 #endif

mercurial