gfx/skia/trunk/src/gpu/effects/GrConvexPolyEffect.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.

     1 /*
     2  * Copyright 2014 Google Inc.
     3  *
     4  * Use of this source code is governed by a BSD-style license that can be
     5  * found in the LICENSE file.
     6  */
     8 #ifndef GrConvexPolyEffect_DEFINED
     9 #define GrConvexPolyEffect_DEFINED
    11 #include "GrDrawTargetCaps.h"
    12 #include "GrEffect.h"
    13 #include "GrTypesPriv.h"
    15 class GrGLConvexPolyEffect;
    16 class SkPath;
    18 /**
    19  * An effect that renders a convex polygon. It is intended to be used as a coverage effect.
    20  * Bounding geometry is rendered and the effect computes coverage based on the fragment's
    21  * position relative to the polygon.
    22  */
    23 class GrConvexPolyEffect : public GrEffect {
    24 public:
    25     enum {
    26         kMaxEdges = 8,
    27     };
    29     /**
    30      * edges is a set of n edge equations where n is limited to kMaxEdges. It contains 3*n values.
    31      * The edges should form a convex polygon. The positive half-plane is considered to be the
    32      * inside. The equations should be normalized such that the first two coefficients are a unit
    33      * 2d vector.
    34      *
    35      * Currently the edges are specified in device space. In the future we may prefer to specify
    36      * them in src space. There are a number of ways this could be accomplished but we'd probably
    37      * have to modify the effect/shaderbuilder interface to make it possible (e.g. give access
    38      * to the view matrix or untransformed positions in the fragment shader).
    39      */
    40     static GrEffectRef* Create(GrEffectEdgeType edgeType, int n, const SkScalar edges[]) {
    41         if (n <= 0 || n > kMaxEdges || kHairlineAA_GrEffectEdgeType == edgeType) {
    42             return NULL;
    43         }
    44         return CreateEffectRef(AutoEffectUnref(SkNEW_ARGS(GrConvexPolyEffect,
    45                                                           (edgeType, n, edges))));
    46     }
    48     /**
    49      * Creates an effect that clips against the path. If the path is not a convex polygon, is
    50      * inverse filled, or has too many edges, this will return NULL. If offset is non-NULL, then
    51      * the path is translated by the vector.
    52      */
    53     static GrEffectRef* Create(GrEffectEdgeType, const SkPath&, const SkVector* offset = NULL);
    55     /**
    56      * Creates an effect that fills inside the rect with AA edges..
    57      */
    58     static GrEffectRef* Create(GrEffectEdgeType, const SkRect&);
    60     virtual ~GrConvexPolyEffect();
    62     static const char* Name() { return "ConvexPoly"; }
    64     GrEffectEdgeType getEdgeType() const { return fEdgeType; }
    66     int getEdgeCount() const { return fEdgeCount; }
    68     const SkScalar* getEdges() const { return fEdges; }
    70     typedef GrGLConvexPolyEffect GLEffect;
    72     virtual void getConstantColorComponents(GrColor* color, uint32_t* validFlags) const SK_OVERRIDE;
    74     virtual const GrBackendEffectFactory& getFactory() const SK_OVERRIDE;
    76 private:
    77     GrConvexPolyEffect(GrEffectEdgeType edgeType, int n, const SkScalar edges[]);
    79     virtual bool onIsEqual(const GrEffect& other) const SK_OVERRIDE;
    81     GrEffectEdgeType    fEdgeType;
    82     int                 fEdgeCount;
    83     SkScalar            fEdges[3 * kMaxEdges];
    85     GR_DECLARE_EFFECT_TEST;
    87     typedef GrEffect INHERITED;
    88 };
    91 #endif

mercurial