Sat, 03 Jan 2015 20:18:00 +0100
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 2012 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 "GrStencilAndCoverPathRenderer.h" |
michael@0 | 11 | #include "GrContext.h" |
michael@0 | 12 | #include "GrDrawTargetCaps.h" |
michael@0 | 13 | #include "GrGpu.h" |
michael@0 | 14 | #include "GrPath.h" |
michael@0 | 15 | #include "SkStrokeRec.h" |
michael@0 | 16 | |
michael@0 | 17 | GrPathRenderer* GrStencilAndCoverPathRenderer::Create(GrContext* context) { |
michael@0 | 18 | SkASSERT(NULL != context); |
michael@0 | 19 | SkASSERT(NULL != context->getGpu()); |
michael@0 | 20 | if (context->getGpu()->caps()->pathRenderingSupport()) { |
michael@0 | 21 | return SkNEW_ARGS(GrStencilAndCoverPathRenderer, (context->getGpu())); |
michael@0 | 22 | } else { |
michael@0 | 23 | return NULL; |
michael@0 | 24 | } |
michael@0 | 25 | } |
michael@0 | 26 | |
michael@0 | 27 | GrStencilAndCoverPathRenderer::GrStencilAndCoverPathRenderer(GrGpu* gpu) { |
michael@0 | 28 | SkASSERT(gpu->caps()->pathRenderingSupport()); |
michael@0 | 29 | fGpu = gpu; |
michael@0 | 30 | gpu->ref(); |
michael@0 | 31 | } |
michael@0 | 32 | |
michael@0 | 33 | GrStencilAndCoverPathRenderer::~GrStencilAndCoverPathRenderer() { |
michael@0 | 34 | fGpu->unref(); |
michael@0 | 35 | } |
michael@0 | 36 | |
michael@0 | 37 | bool GrStencilAndCoverPathRenderer::canDrawPath(const SkPath& path, |
michael@0 | 38 | const SkStrokeRec& stroke, |
michael@0 | 39 | const GrDrawTarget* target, |
michael@0 | 40 | bool antiAlias) const { |
michael@0 | 41 | return !stroke.isHairlineStyle() && |
michael@0 | 42 | !antiAlias && // doesn't do per-path AA, relies on the target having MSAA |
michael@0 | 43 | NULL != target->getDrawState().getRenderTarget()->getStencilBuffer() && |
michael@0 | 44 | target->getDrawState().getStencil().isDisabled(); |
michael@0 | 45 | } |
michael@0 | 46 | |
michael@0 | 47 | GrPathRenderer::StencilSupport GrStencilAndCoverPathRenderer::onGetStencilSupport( |
michael@0 | 48 | const SkPath&, |
michael@0 | 49 | const SkStrokeRec& , |
michael@0 | 50 | const GrDrawTarget*) const { |
michael@0 | 51 | return GrPathRenderer::kStencilOnly_StencilSupport; |
michael@0 | 52 | } |
michael@0 | 53 | |
michael@0 | 54 | void GrStencilAndCoverPathRenderer::onStencilPath(const SkPath& path, |
michael@0 | 55 | const SkStrokeRec& stroke, |
michael@0 | 56 | GrDrawTarget* target) { |
michael@0 | 57 | SkASSERT(!path.isInverseFillType()); |
michael@0 | 58 | SkAutoTUnref<GrPath> p(fGpu->getContext()->createPath(path, stroke)); |
michael@0 | 59 | target->stencilPath(p, path.getFillType()); |
michael@0 | 60 | } |
michael@0 | 61 | |
michael@0 | 62 | bool GrStencilAndCoverPathRenderer::onDrawPath(const SkPath& path, |
michael@0 | 63 | const SkStrokeRec& stroke, |
michael@0 | 64 | GrDrawTarget* target, |
michael@0 | 65 | bool antiAlias) { |
michael@0 | 66 | SkASSERT(!antiAlias); |
michael@0 | 67 | SkASSERT(!stroke.isHairlineStyle()); |
michael@0 | 68 | |
michael@0 | 69 | GrDrawState* drawState = target->drawState(); |
michael@0 | 70 | SkASSERT(drawState->getStencil().isDisabled()); |
michael@0 | 71 | |
michael@0 | 72 | SkAutoTUnref<GrPath> p(fGpu->getContext()->createPath(path, stroke)); |
michael@0 | 73 | |
michael@0 | 74 | if (path.isInverseFillType()) { |
michael@0 | 75 | GR_STATIC_CONST_SAME_STENCIL(kInvertedStencilPass, |
michael@0 | 76 | kZero_StencilOp, |
michael@0 | 77 | kZero_StencilOp, |
michael@0 | 78 | // We know our rect will hit pixels outside the clip and the user bits will be 0 |
michael@0 | 79 | // outside the clip. So we can't just fill where the user bits are 0. We also need to |
michael@0 | 80 | // check that the clip bit is set. |
michael@0 | 81 | kEqualIfInClip_StencilFunc, |
michael@0 | 82 | 0xffff, |
michael@0 | 83 | 0x0000, |
michael@0 | 84 | 0xffff); |
michael@0 | 85 | |
michael@0 | 86 | *drawState->stencil() = kInvertedStencilPass; |
michael@0 | 87 | } else { |
michael@0 | 88 | GR_STATIC_CONST_SAME_STENCIL(kStencilPass, |
michael@0 | 89 | kZero_StencilOp, |
michael@0 | 90 | kZero_StencilOp, |
michael@0 | 91 | kNotEqual_StencilFunc, |
michael@0 | 92 | 0xffff, |
michael@0 | 93 | 0x0000, |
michael@0 | 94 | 0xffff); |
michael@0 | 95 | |
michael@0 | 96 | *drawState->stencil() = kStencilPass; |
michael@0 | 97 | } |
michael@0 | 98 | |
michael@0 | 99 | target->drawPath(p, path.getFillType()); |
michael@0 | 100 | |
michael@0 | 101 | target->drawState()->stencil()->setDisabled(); |
michael@0 | 102 | return true; |
michael@0 | 103 | } |