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.

michael@0 1
michael@0 2 /*
michael@0 3 * Copyright 2011 Google Inc.
michael@0 4 *
michael@0 5 * Use of this source code is governed by a BSD-style license that can be
michael@0 6 * found in the LICENSE file.
michael@0 7 */
michael@0 8
michael@0 9
michael@0 10 #include "GrPathRendererChain.h"
michael@0 11
michael@0 12 #include "GrContext.h"
michael@0 13 #include "GrDefaultPathRenderer.h"
michael@0 14 #include "GrDrawTargetCaps.h"
michael@0 15 #include "GrGpu.h"
michael@0 16
michael@0 17 GrPathRendererChain::GrPathRendererChain(GrContext* context)
michael@0 18 : fInit(false)
michael@0 19 , fOwner(context) {
michael@0 20 }
michael@0 21
michael@0 22 GrPathRendererChain::~GrPathRendererChain() {
michael@0 23 for (int i = 0; i < fChain.count(); ++i) {
michael@0 24 fChain[i]->unref();
michael@0 25 }
michael@0 26 }
michael@0 27
michael@0 28 GrPathRenderer* GrPathRendererChain::addPathRenderer(GrPathRenderer* pr) {
michael@0 29 fChain.push_back() = pr;
michael@0 30 pr->ref();
michael@0 31 return pr;
michael@0 32 }
michael@0 33
michael@0 34 GrPathRenderer* GrPathRendererChain::getPathRenderer(const SkPath& path,
michael@0 35 const SkStrokeRec& stroke,
michael@0 36 const GrDrawTarget* target,
michael@0 37 DrawType drawType,
michael@0 38 StencilSupport* stencilSupport) {
michael@0 39 if (!fInit) {
michael@0 40 this->init();
michael@0 41 }
michael@0 42 bool antiAlias = (kColorAntiAlias_DrawType == drawType ||
michael@0 43 kStencilAndColorAntiAlias_DrawType == drawType);
michael@0 44
michael@0 45 GR_STATIC_ASSERT(GrPathRenderer::kNoSupport_StencilSupport <
michael@0 46 GrPathRenderer::kStencilOnly_StencilSupport);
michael@0 47 GR_STATIC_ASSERT(GrPathRenderer::kStencilOnly_StencilSupport <
michael@0 48 GrPathRenderer::kNoRestriction_StencilSupport);
michael@0 49 GrPathRenderer::StencilSupport minStencilSupport;
michael@0 50 if (kStencilOnly_DrawType == drawType) {
michael@0 51 minStencilSupport = GrPathRenderer::kStencilOnly_StencilSupport;
michael@0 52 } else if (kStencilAndColor_DrawType == drawType ||
michael@0 53 kStencilAndColorAntiAlias_DrawType == drawType) {
michael@0 54 minStencilSupport = GrPathRenderer::kNoRestriction_StencilSupport;
michael@0 55 } else {
michael@0 56 minStencilSupport = GrPathRenderer::kNoSupport_StencilSupport;
michael@0 57 }
michael@0 58
michael@0 59
michael@0 60 for (int i = 0; i < fChain.count(); ++i) {
michael@0 61 if (fChain[i]->canDrawPath(path, stroke, target, antiAlias)) {
michael@0 62 if (GrPathRenderer::kNoSupport_StencilSupport != minStencilSupport) {
michael@0 63 GrPathRenderer::StencilSupport support = fChain[i]->getStencilSupport(path,
michael@0 64 stroke,
michael@0 65 target);
michael@0 66 if (support < minStencilSupport) {
michael@0 67 continue;
michael@0 68 } else if (NULL != stencilSupport) {
michael@0 69 *stencilSupport = support;
michael@0 70 }
michael@0 71 }
michael@0 72 return fChain[i];
michael@0 73 }
michael@0 74 }
michael@0 75 return NULL;
michael@0 76 }
michael@0 77
michael@0 78 void GrPathRendererChain::init() {
michael@0 79 SkASSERT(!fInit);
michael@0 80 GrGpu* gpu = fOwner->getGpu();
michael@0 81 bool twoSided = gpu->caps()->twoSidedStencilSupport();
michael@0 82 bool wrapOp = gpu->caps()->stencilWrapOpsSupport();
michael@0 83 GrPathRenderer::AddPathRenderers(fOwner, this);
michael@0 84 this->addPathRenderer(SkNEW_ARGS(GrDefaultPathRenderer,
michael@0 85 (twoSided, wrapOp)))->unref();
michael@0 86 fInit = true;
michael@0 87 }

mercurial