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

     1 /*
     2  * Copyright 2012 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 #include "GrSimpleTextureEffect.h"
     9 #include "gl/GrGLEffect.h"
    10 #include "gl/GrGLSL.h"
    11 #include "gl/GrGLTexture.h"
    12 #include "GrTBackendEffectFactory.h"
    13 #include "GrTexture.h"
    15 class GrGLSimpleTextureEffect : public GrGLEffect {
    16 public:
    17     GrGLSimpleTextureEffect(const GrBackendEffectFactory& factory, const GrDrawEffect&)
    18         : INHERITED (factory) {
    19     }
    21     virtual void emitCode(GrGLShaderBuilder* builder,
    22                           const GrDrawEffect& drawEffect,
    23                           EffectKey key,
    24                           const char* outputColor,
    25                           const char* inputColor,
    26                           const TransformedCoordsArray& coords,
    27                           const TextureSamplerArray& samplers) SK_OVERRIDE {
    28         builder->fsCodeAppendf("\t%s = ", outputColor);
    29         builder->fsAppendTextureLookupAndModulate(inputColor,
    30                                                   samplers[0],
    31                                                   coords[0].c_str(),
    32                                                   coords[0].type());
    33         builder->fsCodeAppend(";\n");
    34     }
    36 private:
    37     typedef GrGLEffect INHERITED;
    38 };
    40 ///////////////////////////////////////////////////////////////////////////////
    42 void GrSimpleTextureEffect::getConstantColorComponents(GrColor* color, uint32_t* validFlags) const {
    43     this->updateConstantColorComponentsForModulation(color, validFlags);
    44 }
    46 const GrBackendEffectFactory& GrSimpleTextureEffect::getFactory() const {
    47     return GrTBackendEffectFactory<GrSimpleTextureEffect>::getInstance();
    48 }
    50 ///////////////////////////////////////////////////////////////////////////////
    52 GR_DEFINE_EFFECT_TEST(GrSimpleTextureEffect);
    54 GrEffectRef* GrSimpleTextureEffect::TestCreate(SkRandom* random,
    55                                                GrContext*,
    56                                                const GrDrawTargetCaps&,
    57                                                GrTexture* textures[]) {
    58     int texIdx = random->nextBool() ? GrEffectUnitTest::kSkiaPMTextureIdx :
    59                                       GrEffectUnitTest::kAlphaTextureIdx;
    60     static const SkShader::TileMode kTileModes[] = {
    61         SkShader::kClamp_TileMode,
    62         SkShader::kRepeat_TileMode,
    63         SkShader::kMirror_TileMode,
    64     };
    65     SkShader::TileMode tileModes[] = {
    66         kTileModes[random->nextULessThan(SK_ARRAY_COUNT(kTileModes))],
    67         kTileModes[random->nextULessThan(SK_ARRAY_COUNT(kTileModes))],
    68     };
    69     GrTextureParams params(tileModes, random->nextBool() ? GrTextureParams::kBilerp_FilterMode :
    70                                                            GrTextureParams::kNone_FilterMode);
    72     static const GrCoordSet kCoordSets[] = {
    73         kLocal_GrCoordSet,
    74         kPosition_GrCoordSet
    75     };
    76     GrCoordSet coordSet = kCoordSets[random->nextULessThan(GR_ARRAY_COUNT(kCoordSets))];
    78     const SkMatrix& matrix = GrEffectUnitTest::TestMatrix(random);
    79     return GrSimpleTextureEffect::Create(textures[texIdx], matrix, coordSet);
    80 }

mercurial