gfx/skia/trunk/src/gpu/GrPathRendererChain.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 2011 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  */
    10 #include "GrPathRendererChain.h"
    12 #include "GrContext.h"
    13 #include "GrDefaultPathRenderer.h"
    14 #include "GrDrawTargetCaps.h"
    15 #include "GrGpu.h"
    17 GrPathRendererChain::GrPathRendererChain(GrContext* context)
    18     : fInit(false)
    19     , fOwner(context) {
    20 }
    22 GrPathRendererChain::~GrPathRendererChain() {
    23     for (int i = 0; i < fChain.count(); ++i) {
    24         fChain[i]->unref();
    25     }
    26 }
    28 GrPathRenderer* GrPathRendererChain::addPathRenderer(GrPathRenderer* pr) {
    29     fChain.push_back() = pr;
    30     pr->ref();
    31     return pr;
    32 }
    34 GrPathRenderer* GrPathRendererChain::getPathRenderer(const SkPath& path,
    35                                                      const SkStrokeRec& stroke,
    36                                                      const GrDrawTarget* target,
    37                                                      DrawType drawType,
    38                                                      StencilSupport* stencilSupport) {
    39     if (!fInit) {
    40         this->init();
    41     }
    42     bool antiAlias = (kColorAntiAlias_DrawType == drawType ||
    43                       kStencilAndColorAntiAlias_DrawType == drawType);
    45     GR_STATIC_ASSERT(GrPathRenderer::kNoSupport_StencilSupport <
    46                      GrPathRenderer::kStencilOnly_StencilSupport);
    47     GR_STATIC_ASSERT(GrPathRenderer::kStencilOnly_StencilSupport <
    48                      GrPathRenderer::kNoRestriction_StencilSupport);
    49     GrPathRenderer::StencilSupport minStencilSupport;
    50     if (kStencilOnly_DrawType == drawType) {
    51         minStencilSupport = GrPathRenderer::kStencilOnly_StencilSupport;
    52     } else if (kStencilAndColor_DrawType == drawType ||
    53                kStencilAndColorAntiAlias_DrawType == drawType) {
    54         minStencilSupport = GrPathRenderer::kNoRestriction_StencilSupport;
    55     } else {
    56         minStencilSupport = GrPathRenderer::kNoSupport_StencilSupport;
    57     }
    60     for (int i = 0; i < fChain.count(); ++i) {
    61         if (fChain[i]->canDrawPath(path, stroke, target, antiAlias)) {
    62             if (GrPathRenderer::kNoSupport_StencilSupport != minStencilSupport) {
    63                 GrPathRenderer::StencilSupport support = fChain[i]->getStencilSupport(path,
    64                                                                                       stroke,
    65                                                                                       target);
    66                 if (support < minStencilSupport) {
    67                     continue;
    68                 } else if (NULL != stencilSupport) {
    69                     *stencilSupport = support;
    70                 }
    71             }
    72             return fChain[i];
    73         }
    74     }
    75     return NULL;
    76 }
    78 void GrPathRendererChain::init() {
    79     SkASSERT(!fInit);
    80     GrGpu* gpu = fOwner->getGpu();
    81     bool twoSided = gpu->caps()->twoSidedStencilSupport();
    82     bool wrapOp = gpu->caps()->stencilWrapOpsSupport();
    83     GrPathRenderer::AddPathRenderers(fOwner, this);
    84     this->addPathRenderer(SkNEW_ARGS(GrDefaultPathRenderer,
    85                                      (twoSided, wrapOp)))->unref();
    86     fInit = true;
    87 }

mercurial