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 2012 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 | |
michael@0 | 9 | #ifndef GrSurface_DEFINED |
michael@0 | 10 | #define GrSurface_DEFINED |
michael@0 | 11 | |
michael@0 | 12 | #include "GrTypes.h" |
michael@0 | 13 | #include "GrResource.h" |
michael@0 | 14 | #include "SkRect.h" |
michael@0 | 15 | |
michael@0 | 16 | class GrTexture; |
michael@0 | 17 | class GrRenderTarget; |
michael@0 | 18 | struct SkImageInfo; |
michael@0 | 19 | |
michael@0 | 20 | class GrSurface : public GrResource { |
michael@0 | 21 | public: |
michael@0 | 22 | SK_DECLARE_INST_COUNT(GrSurface); |
michael@0 | 23 | |
michael@0 | 24 | /** |
michael@0 | 25 | * Retrieves the width of the surface. |
michael@0 | 26 | * |
michael@0 | 27 | * @return the width in texels |
michael@0 | 28 | */ |
michael@0 | 29 | int width() const { return fDesc.fWidth; } |
michael@0 | 30 | |
michael@0 | 31 | /** |
michael@0 | 32 | * Retrieves the height of the surface. |
michael@0 | 33 | * |
michael@0 | 34 | * @return the height in texels |
michael@0 | 35 | */ |
michael@0 | 36 | int height() const { return fDesc.fHeight; } |
michael@0 | 37 | |
michael@0 | 38 | /** |
michael@0 | 39 | * Helper that gets the width and height of the surface as a bounding rectangle. |
michael@0 | 40 | */ |
michael@0 | 41 | void getBoundsRect(SkRect* rect) const { rect->setWH(SkIntToScalar(this->width()), |
michael@0 | 42 | SkIntToScalar(this->height())); } |
michael@0 | 43 | |
michael@0 | 44 | GrSurfaceOrigin origin() const { |
michael@0 | 45 | SkASSERT(kTopLeft_GrSurfaceOrigin == fDesc.fOrigin || kBottomLeft_GrSurfaceOrigin == fDesc.fOrigin); |
michael@0 | 46 | return fDesc.fOrigin; |
michael@0 | 47 | } |
michael@0 | 48 | |
michael@0 | 49 | /** |
michael@0 | 50 | * Retrieves the pixel config specified when the surface was created. |
michael@0 | 51 | * For render targets this can be kUnknown_GrPixelConfig |
michael@0 | 52 | * if client asked us to render to a target that has a pixel |
michael@0 | 53 | * config that isn't equivalent with one of our configs. |
michael@0 | 54 | */ |
michael@0 | 55 | GrPixelConfig config() const { return fDesc.fConfig; } |
michael@0 | 56 | |
michael@0 | 57 | /** |
michael@0 | 58 | * Return the descriptor describing the surface |
michael@0 | 59 | */ |
michael@0 | 60 | const GrTextureDesc& desc() const { return fDesc; } |
michael@0 | 61 | |
michael@0 | 62 | void asImageInfo(SkImageInfo*) const; |
michael@0 | 63 | |
michael@0 | 64 | /** |
michael@0 | 65 | * @return the texture associated with the surface, may be NULL. |
michael@0 | 66 | */ |
michael@0 | 67 | virtual GrTexture* asTexture() = 0; |
michael@0 | 68 | virtual const GrTexture* asTexture() const = 0; |
michael@0 | 69 | |
michael@0 | 70 | /** |
michael@0 | 71 | * @return the render target underlying this surface, may be NULL. |
michael@0 | 72 | */ |
michael@0 | 73 | virtual GrRenderTarget* asRenderTarget() = 0; |
michael@0 | 74 | virtual const GrRenderTarget* asRenderTarget() const = 0; |
michael@0 | 75 | |
michael@0 | 76 | /** |
michael@0 | 77 | * Checks whether this GrSurface refers to the same GPU object as other. This |
michael@0 | 78 | * catches the case where a GrTexture and GrRenderTarget refer to the same |
michael@0 | 79 | * GPU memory. |
michael@0 | 80 | */ |
michael@0 | 81 | bool isSameAs(const GrSurface* other) const { |
michael@0 | 82 | const GrRenderTarget* thisRT = this->asRenderTarget(); |
michael@0 | 83 | if (NULL != thisRT) { |
michael@0 | 84 | return thisRT == other->asRenderTarget(); |
michael@0 | 85 | } else { |
michael@0 | 86 | const GrTexture* thisTex = this->asTexture(); |
michael@0 | 87 | SkASSERT(NULL != thisTex); // We must be one or the other |
michael@0 | 88 | return thisTex == other->asTexture(); |
michael@0 | 89 | } |
michael@0 | 90 | } |
michael@0 | 91 | |
michael@0 | 92 | /** |
michael@0 | 93 | * Reads a rectangle of pixels from the surface. |
michael@0 | 94 | * @param left left edge of the rectangle to read (inclusive) |
michael@0 | 95 | * @param top top edge of the rectangle to read (inclusive) |
michael@0 | 96 | * @param width width of rectangle to read in pixels. |
michael@0 | 97 | * @param height height of rectangle to read in pixels. |
michael@0 | 98 | * @param config the pixel config of the destination buffer |
michael@0 | 99 | * @param buffer memory to read the rectangle into. |
michael@0 | 100 | * @param rowBytes number of bytes between consecutive rows. Zero means rows are tightly |
michael@0 | 101 | * packed. |
michael@0 | 102 | * @param pixelOpsFlags See the GrContext::PixelOpsFlags enum. |
michael@0 | 103 | * |
michael@0 | 104 | * @return true if the read succeeded, false if not. The read can fail because of an unsupported |
michael@0 | 105 | * pixel config. |
michael@0 | 106 | */ |
michael@0 | 107 | virtual bool readPixels(int left, int top, int width, int height, |
michael@0 | 108 | GrPixelConfig config, |
michael@0 | 109 | void* buffer, |
michael@0 | 110 | size_t rowBytes = 0, |
michael@0 | 111 | uint32_t pixelOpsFlags = 0) = 0; |
michael@0 | 112 | |
michael@0 | 113 | /** |
michael@0 | 114 | * Copy the src pixels [buffer, rowbytes, pixelconfig] into the surface at the specified |
michael@0 | 115 | * rectangle. |
michael@0 | 116 | * @param left left edge of the rectangle to write (inclusive) |
michael@0 | 117 | * @param top top edge of the rectangle to write (inclusive) |
michael@0 | 118 | * @param width width of rectangle to write in pixels. |
michael@0 | 119 | * @param height height of rectangle to write in pixels. |
michael@0 | 120 | * @param config the pixel config of the source buffer |
michael@0 | 121 | * @param buffer memory to read the rectangle from. |
michael@0 | 122 | * @param rowBytes number of bytes between consecutive rows. Zero means rows are tightly |
michael@0 | 123 | * packed. |
michael@0 | 124 | * @param pixelOpsFlags See the GrContext::PixelOpsFlags enum. |
michael@0 | 125 | */ |
michael@0 | 126 | virtual void writePixels(int left, int top, int width, int height, |
michael@0 | 127 | GrPixelConfig config, |
michael@0 | 128 | const void* buffer, |
michael@0 | 129 | size_t rowBytes = 0, |
michael@0 | 130 | uint32_t pixelOpsFlags = 0) = 0; |
michael@0 | 131 | |
michael@0 | 132 | /** |
michael@0 | 133 | * Write the contents of the surface to a PNG. Returns true if successful. |
michael@0 | 134 | * @param filename Full path to desired file |
michael@0 | 135 | */ |
michael@0 | 136 | bool savePixels(const char* filename); |
michael@0 | 137 | |
michael@0 | 138 | protected: |
michael@0 | 139 | GrSurface(GrGpu* gpu, bool isWrapped, const GrTextureDesc& desc) |
michael@0 | 140 | : INHERITED(gpu, isWrapped) |
michael@0 | 141 | , fDesc(desc) { |
michael@0 | 142 | } |
michael@0 | 143 | |
michael@0 | 144 | GrTextureDesc fDesc; |
michael@0 | 145 | |
michael@0 | 146 | private: |
michael@0 | 147 | typedef GrResource INHERITED; |
michael@0 | 148 | }; |
michael@0 | 149 | |
michael@0 | 150 | #endif // GrSurface_DEFINED |