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 | * Copyright 2011 Google Inc. |
michael@0 | 3 | * |
michael@0 | 4 | * Use of this source code is governed by a BSD-style license that can be |
michael@0 | 5 | * found in the LICENSE file. |
michael@0 | 6 | */ |
michael@0 | 7 | |
michael@0 | 8 | #ifndef GrRenderTarget_DEFINED |
michael@0 | 9 | #define GrRenderTarget_DEFINED |
michael@0 | 10 | |
michael@0 | 11 | #include "GrSurface.h" |
michael@0 | 12 | #include "SkRect.h" |
michael@0 | 13 | |
michael@0 | 14 | class GrStencilBuffer; |
michael@0 | 15 | class GrTexture; |
michael@0 | 16 | |
michael@0 | 17 | /** |
michael@0 | 18 | * GrRenderTarget represents a 2D buffer of pixels that can be rendered to. |
michael@0 | 19 | * A context's render target is set by setRenderTarget(). Render targets are |
michael@0 | 20 | * created by a createTexture with the kRenderTarget_TextureFlag flag. |
michael@0 | 21 | * Additionally, GrContext provides methods for creating GrRenderTargets |
michael@0 | 22 | * that wrap externally created render targets. |
michael@0 | 23 | */ |
michael@0 | 24 | class GrRenderTarget : public GrSurface { |
michael@0 | 25 | public: |
michael@0 | 26 | SK_DECLARE_INST_COUNT(GrRenderTarget) |
michael@0 | 27 | |
michael@0 | 28 | // GrResource overrides |
michael@0 | 29 | virtual size_t sizeInBytes() const SK_OVERRIDE; |
michael@0 | 30 | |
michael@0 | 31 | // GrSurface overrides |
michael@0 | 32 | /** |
michael@0 | 33 | * @return the texture associated with the render target, may be NULL. |
michael@0 | 34 | */ |
michael@0 | 35 | virtual GrTexture* asTexture() SK_OVERRIDE { return fTexture; } |
michael@0 | 36 | virtual const GrTexture* asTexture() const SK_OVERRIDE { return fTexture; } |
michael@0 | 37 | |
michael@0 | 38 | /** |
michael@0 | 39 | * @return this render target. |
michael@0 | 40 | */ |
michael@0 | 41 | virtual GrRenderTarget* asRenderTarget() SK_OVERRIDE { return this; } |
michael@0 | 42 | virtual const GrRenderTarget* asRenderTarget() const SK_OVERRIDE { |
michael@0 | 43 | return this; |
michael@0 | 44 | } |
michael@0 | 45 | |
michael@0 | 46 | virtual bool readPixels(int left, int top, int width, int height, |
michael@0 | 47 | GrPixelConfig config, |
michael@0 | 48 | void* buffer, |
michael@0 | 49 | size_t rowBytes = 0, |
michael@0 | 50 | uint32_t pixelOpsFlags = 0) SK_OVERRIDE; |
michael@0 | 51 | |
michael@0 | 52 | virtual void writePixels(int left, int top, int width, int height, |
michael@0 | 53 | GrPixelConfig config, |
michael@0 | 54 | const void* buffer, |
michael@0 | 55 | size_t rowBytes = 0, |
michael@0 | 56 | uint32_t pixelOpsFlags = 0) SK_OVERRIDE; |
michael@0 | 57 | |
michael@0 | 58 | // GrRenderTarget |
michael@0 | 59 | /** |
michael@0 | 60 | * If this RT is multisampled, this is the multisample buffer |
michael@0 | 61 | * @return the 3D API's handle to this object (e.g. FBO ID in OpenGL) |
michael@0 | 62 | */ |
michael@0 | 63 | virtual GrBackendObject getRenderTargetHandle() const = 0; |
michael@0 | 64 | |
michael@0 | 65 | /** |
michael@0 | 66 | * If this RT is multisampled, this is the buffer it is resolved to. |
michael@0 | 67 | * Otherwise, same as getRenderTargetHandle(). |
michael@0 | 68 | * (In GL a separate FBO ID is used for the MSAA and resolved buffers) |
michael@0 | 69 | * @return the 3D API's handle to this object (e.g. FBO ID in OpenGL) |
michael@0 | 70 | */ |
michael@0 | 71 | virtual GrBackendObject getRenderTargetResolvedHandle() const = 0; |
michael@0 | 72 | |
michael@0 | 73 | /** |
michael@0 | 74 | * @return true if the surface is multisampled, false otherwise |
michael@0 | 75 | */ |
michael@0 | 76 | bool isMultisampled() const { return 0 != fDesc.fSampleCnt; } |
michael@0 | 77 | |
michael@0 | 78 | /** |
michael@0 | 79 | * @return the number of samples-per-pixel or zero if non-MSAA. |
michael@0 | 80 | */ |
michael@0 | 81 | int numSamples() const { return fDesc.fSampleCnt; } |
michael@0 | 82 | |
michael@0 | 83 | /** |
michael@0 | 84 | * Call to indicate the multisample contents were modified such that the |
michael@0 | 85 | * render target needs to be resolved before it can be used as texture. Gr |
michael@0 | 86 | * tracks this for its own drawing and thus this only needs to be called |
michael@0 | 87 | * when the render target has been modified outside of Gr. This has no |
michael@0 | 88 | * effect on wrapped backend render targets. |
michael@0 | 89 | * |
michael@0 | 90 | * @param rect a rect bounding the area needing resolve. NULL indicates |
michael@0 | 91 | * the whole RT needs resolving. |
michael@0 | 92 | */ |
michael@0 | 93 | void flagAsNeedingResolve(const SkIRect* rect = NULL); |
michael@0 | 94 | |
michael@0 | 95 | /** |
michael@0 | 96 | * Call to override the region that needs to be resolved. |
michael@0 | 97 | */ |
michael@0 | 98 | void overrideResolveRect(const SkIRect rect); |
michael@0 | 99 | |
michael@0 | 100 | /** |
michael@0 | 101 | * Call to indicate that GrRenderTarget was externally resolved. This may |
michael@0 | 102 | * allow Gr to skip a redundant resolve step. |
michael@0 | 103 | */ |
michael@0 | 104 | void flagAsResolved() { fResolveRect.setLargestInverted(); } |
michael@0 | 105 | |
michael@0 | 106 | /** |
michael@0 | 107 | * @return true if the GrRenderTarget requires MSAA resolving |
michael@0 | 108 | */ |
michael@0 | 109 | bool needsResolve() const { return !fResolveRect.isEmpty(); } |
michael@0 | 110 | |
michael@0 | 111 | /** |
michael@0 | 112 | * Returns a rect bounding the region needing resolving. |
michael@0 | 113 | */ |
michael@0 | 114 | const SkIRect& getResolveRect() const { return fResolveRect; } |
michael@0 | 115 | |
michael@0 | 116 | /** |
michael@0 | 117 | * If the render target is multisampled this will perform a multisample |
michael@0 | 118 | * resolve. Any pending draws to the target are first flushed. This only |
michael@0 | 119 | * applies to render targets that are associated with GrTextures. After the |
michael@0 | 120 | * function returns the GrTexture will contain the resolved pixels. |
michael@0 | 121 | */ |
michael@0 | 122 | void resolve(); |
michael@0 | 123 | |
michael@0 | 124 | // a MSAA RT may require explicit resolving , it may auto-resolve (e.g. FBO |
michael@0 | 125 | // 0 in GL), or be unresolvable because the client didn't give us the |
michael@0 | 126 | // resolve destination. |
michael@0 | 127 | enum ResolveType { |
michael@0 | 128 | kCanResolve_ResolveType, |
michael@0 | 129 | kAutoResolves_ResolveType, |
michael@0 | 130 | kCantResolve_ResolveType, |
michael@0 | 131 | }; |
michael@0 | 132 | virtual ResolveType getResolveType() const = 0; |
michael@0 | 133 | |
michael@0 | 134 | /** |
michael@0 | 135 | * GrStencilBuffer is not part of the public API. |
michael@0 | 136 | */ |
michael@0 | 137 | GrStencilBuffer* getStencilBuffer() const { return fStencilBuffer; } |
michael@0 | 138 | void setStencilBuffer(GrStencilBuffer* stencilBuffer); |
michael@0 | 139 | |
michael@0 | 140 | protected: |
michael@0 | 141 | GrRenderTarget(GrGpu* gpu, |
michael@0 | 142 | bool isWrapped, |
michael@0 | 143 | GrTexture* texture, |
michael@0 | 144 | const GrTextureDesc& desc) |
michael@0 | 145 | : INHERITED(gpu, isWrapped, desc) |
michael@0 | 146 | , fStencilBuffer(NULL) |
michael@0 | 147 | , fTexture(texture) { |
michael@0 | 148 | fResolveRect.setLargestInverted(); |
michael@0 | 149 | } |
michael@0 | 150 | |
michael@0 | 151 | // override of GrResource |
michael@0 | 152 | virtual void onAbandon() SK_OVERRIDE; |
michael@0 | 153 | virtual void onRelease() SK_OVERRIDE; |
michael@0 | 154 | |
michael@0 | 155 | private: |
michael@0 | 156 | friend class GrTexture; |
michael@0 | 157 | // called by ~GrTexture to remove the non-ref'ed back ptr. |
michael@0 | 158 | void owningTextureDestroyed() { |
michael@0 | 159 | SkASSERT(NULL != fTexture); |
michael@0 | 160 | fTexture = NULL; |
michael@0 | 161 | } |
michael@0 | 162 | |
michael@0 | 163 | GrStencilBuffer* fStencilBuffer; |
michael@0 | 164 | GrTexture* fTexture; // not ref'ed |
michael@0 | 165 | |
michael@0 | 166 | SkIRect fResolveRect; |
michael@0 | 167 | |
michael@0 | 168 | typedef GrSurface INHERITED; |
michael@0 | 169 | }; |
michael@0 | 170 | |
michael@0 | 171 | #endif |