gfx/skia/trunk/src/gpu/effects/GrBicubicEffect.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 2013 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 GrBicubicTextureEffect_DEFINED
     9 #define GrBicubicTextureEffect_DEFINED
    11 #include "GrSingleTextureEffect.h"
    12 #include "GrTextureDomain.h"
    13 #include "GrDrawEffect.h"
    14 #include "gl/GrGLEffect.h"
    15 #include "GrTBackendEffectFactory.h"
    17 class GrGLBicubicEffect;
    19 class GrBicubicEffect : public GrSingleTextureEffect {
    20 public:
    21     enum {
    22         kFilterTexelPad = 2, // Given a src rect in texels to be filtered, this number of
    23                              // surrounding texels are needed by the kernel in x and y.
    24     };
    25     virtual ~GrBicubicEffect();
    27     static const char* Name() { return "Bicubic"; }
    28     const float* coefficients() const { return fCoefficients; }
    30     typedef GrGLBicubicEffect GLEffect;
    32     virtual const GrBackendEffectFactory& getFactory() const SK_OVERRIDE;
    33     virtual void getConstantColorComponents(GrColor* color, uint32_t* validFlags) const SK_OVERRIDE;
    35     const GrTextureDomain& domain() const { return fDomain; }
    37     /**
    38      * Create a simple filter effect with custom bicubic coefficients and optional domain.
    39      */
    40     static GrEffectRef* Create(GrTexture* tex, const SkScalar coefficients[16],
    41                                const SkRect* domain = NULL) {
    42         if (NULL == domain) {
    43             static const SkShader::TileMode kTileModes[] = { SkShader::kClamp_TileMode,
    44                                                              SkShader::kClamp_TileMode };
    45             return Create(tex, coefficients, MakeDivByTextureWHMatrix(tex), kTileModes);
    46         } else {
    47             AutoEffectUnref effect(SkNEW_ARGS(GrBicubicEffect, (tex, coefficients,
    48                                                                 MakeDivByTextureWHMatrix(tex),
    49                                                                 *domain)));
    50             return CreateEffectRef(effect);
    51         }
    52     }
    54     /**
    55      * Create a Mitchell filter effect with specified texture matrix and x/y tile modes.
    56      */
    57     static GrEffectRef* Create(GrTexture* tex, const SkMatrix& matrix,
    58                                SkShader::TileMode tileModes[2]) {
    59         return Create(tex, gMitchellCoefficients, matrix, tileModes);
    60     }
    62     /**
    63      * Create a filter effect with custom bicubic coefficients, the texture matrix, and the x/y
    64      * tilemodes.
    65      */
    66     static GrEffectRef* Create(GrTexture* tex, const SkScalar coefficients[16],
    67                                const SkMatrix& matrix, const SkShader::TileMode tileModes[2]) {
    68         AutoEffectUnref effect(SkNEW_ARGS(GrBicubicEffect, (tex, coefficients, matrix, tileModes)));
    69         return CreateEffectRef(effect);
    70     }
    72     /**
    73      * Create a Mitchell filter effect with a texture matrix and a domain.
    74      */
    75     static GrEffectRef* Create(GrTexture* tex, const SkMatrix& matrix, const SkRect& domain) {
    76         AutoEffectUnref effect(SkNEW_ARGS(GrBicubicEffect, (tex, gMitchellCoefficients, matrix,
    77                                                             domain)));
    78         return CreateEffectRef(effect);
    79     }
    81 private:
    82     GrBicubicEffect(GrTexture*, const SkScalar coefficients[16],
    83                     const SkMatrix &matrix, const SkShader::TileMode tileModes[2]);
    84     GrBicubicEffect(GrTexture*, const SkScalar coefficients[16],
    85                     const SkMatrix &matrix, const SkRect& domain);
    86     virtual bool onIsEqual(const GrEffect&) const SK_OVERRIDE;
    88     float           fCoefficients[16];
    89     GrTextureDomain fDomain;
    91     GR_DECLARE_EFFECT_TEST;
    93     static const SkScalar gMitchellCoefficients[16];
    95     typedef GrSingleTextureEffect INHERITED;
    96 };
    98 #endif

mercurial