gfx/skia/trunk/include/gpu/SkGpuDevice.h

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 2010 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
michael@0 11 #ifndef SkGpuDevice_DEFINED
michael@0 12 #define SkGpuDevice_DEFINED
michael@0 13
michael@0 14 #include "SkGr.h"
michael@0 15 #include "SkBitmap.h"
michael@0 16 #include "SkBitmapDevice.h"
michael@0 17 #include "SkPicture.h"
michael@0 18 #include "SkRegion.h"
michael@0 19 #include "GrContext.h"
michael@0 20
michael@0 21 struct SkDrawProcs;
michael@0 22 struct GrSkDrawProcs;
michael@0 23
michael@0 24 class GrTextContext;
michael@0 25
michael@0 26 /**
michael@0 27 * Subclass of SkBitmapDevice, which directs all drawing to the GrGpu owned by the
michael@0 28 * canvas.
michael@0 29 */
michael@0 30 class SK_API SkGpuDevice : public SkBitmapDevice {
michael@0 31 public:
michael@0 32
michael@0 33 /**
michael@0 34 * Creates an SkGpuDevice from a GrSurface. This will fail if the surface is not a render
michael@0 35 * target. The caller owns a ref on the returned device.
michael@0 36 */
michael@0 37 static SkGpuDevice* Create(GrSurface* surface);
michael@0 38
michael@0 39 /**
michael@0 40 * New device that will create an offscreen renderTarget based on the
michael@0 41 * ImageInfo and sampleCount. The device's storage will not
michael@0 42 * count against the GrContext's texture cache budget. The device's pixels
michael@0 43 * will be uninitialized. On failure, returns NULL.
michael@0 44 */
michael@0 45 static SkGpuDevice* Create(GrContext*, const SkImageInfo&, int sampleCount);
michael@0 46
michael@0 47 #ifdef SK_SUPPORT_LEGACY_COMPATIBLEDEVICE_CONFIG
michael@0 48 /**
michael@0 49 * New device that will create an offscreen renderTarget based on the
michael@0 50 * config, width, height, and sampleCount. The device's storage will not
michael@0 51 * count against the GrContext's texture cache budget. The device's pixels
michael@0 52 * will be uninitialized. TODO: This can fail, replace with a factory function.
michael@0 53 */
michael@0 54 SkGpuDevice(GrContext*, SkBitmap::Config, int width, int height, int sampleCount = 0);
michael@0 55 #endif
michael@0 56
michael@0 57 /**
michael@0 58 * DEPRECATED -- need to make this private, call Create(surface)
michael@0 59 * New device that will render to the specified renderTarget.
michael@0 60 */
michael@0 61 SkGpuDevice(GrContext*, GrRenderTarget*);
michael@0 62
michael@0 63 /**
michael@0 64 * DEPRECATED -- need to make this private, call Create(surface)
michael@0 65 * New device that will render to the texture (as a rendertarget).
michael@0 66 * The GrTexture's asRenderTarget() must be non-NULL or device will not
michael@0 67 * function.
michael@0 68 */
michael@0 69 SkGpuDevice(GrContext*, GrTexture*);
michael@0 70
michael@0 71 virtual ~SkGpuDevice();
michael@0 72
michael@0 73 GrContext* context() const { return fContext; }
michael@0 74
michael@0 75 virtual GrRenderTarget* accessRenderTarget() SK_OVERRIDE;
michael@0 76
michael@0 77 // overrides from SkBaseDevice
michael@0 78 virtual int width() const SK_OVERRIDE {
michael@0 79 return NULL == fRenderTarget ? 0 : fRenderTarget->width();
michael@0 80 }
michael@0 81 virtual int height() const SK_OVERRIDE {
michael@0 82 return NULL == fRenderTarget ? 0 : fRenderTarget->height();
michael@0 83 }
michael@0 84 virtual bool isOpaque() const SK_OVERRIDE {
michael@0 85 return NULL == fRenderTarget ? false
michael@0 86 : kRGB_565_GrPixelConfig == fRenderTarget->config();
michael@0 87 }
michael@0 88 virtual SkBitmap::Config config() const SK_OVERRIDE;
michael@0 89
michael@0 90 virtual void clear(SkColor color) SK_OVERRIDE;
michael@0 91 #ifdef SK_SUPPORT_LEGACY_WRITEPIXELSCONFIG
michael@0 92 virtual void writePixels(const SkBitmap& bitmap, int x, int y,
michael@0 93 SkCanvas::Config8888 config8888) SK_OVERRIDE;
michael@0 94 #endif
michael@0 95 virtual void drawPaint(const SkDraw&, const SkPaint& paint) SK_OVERRIDE;
michael@0 96 virtual void drawPoints(const SkDraw&, SkCanvas::PointMode mode, size_t count,
michael@0 97 const SkPoint[], const SkPaint& paint) SK_OVERRIDE;
michael@0 98 virtual void drawRect(const SkDraw&, const SkRect& r,
michael@0 99 const SkPaint& paint) SK_OVERRIDE;
michael@0 100 virtual void drawRRect(const SkDraw&, const SkRRect& r,
michael@0 101 const SkPaint& paint) SK_OVERRIDE;
michael@0 102 virtual void drawOval(const SkDraw&, const SkRect& oval,
michael@0 103 const SkPaint& paint) SK_OVERRIDE;
michael@0 104 virtual void drawPath(const SkDraw&, const SkPath& path,
michael@0 105 const SkPaint& paint, const SkMatrix* prePathMatrix,
michael@0 106 bool pathIsMutable) SK_OVERRIDE;
michael@0 107 virtual void drawBitmap(const SkDraw&, const SkBitmap& bitmap,
michael@0 108 const SkMatrix&, const SkPaint&) SK_OVERRIDE;
michael@0 109 virtual void drawBitmapRect(const SkDraw&, const SkBitmap&,
michael@0 110 const SkRect* srcOrNull, const SkRect& dst,
michael@0 111 const SkPaint& paint,
michael@0 112 SkCanvas::DrawBitmapRectFlags flags) SK_OVERRIDE;
michael@0 113 virtual void drawSprite(const SkDraw&, const SkBitmap& bitmap,
michael@0 114 int x, int y, const SkPaint& paint);
michael@0 115 virtual void drawText(const SkDraw&, const void* text, size_t len,
michael@0 116 SkScalar x, SkScalar y, const SkPaint&) SK_OVERRIDE;
michael@0 117 virtual void drawPosText(const SkDraw&, const void* text, size_t len,
michael@0 118 const SkScalar pos[], SkScalar constY,
michael@0 119 int scalarsPerPos, const SkPaint&) SK_OVERRIDE;
michael@0 120 virtual void drawTextOnPath(const SkDraw&, const void* text, size_t len,
michael@0 121 const SkPath& path, const SkMatrix* matrix,
michael@0 122 const SkPaint&) SK_OVERRIDE;
michael@0 123 virtual void drawVertices(const SkDraw&, SkCanvas::VertexMode, int vertexCount,
michael@0 124 const SkPoint verts[], const SkPoint texs[],
michael@0 125 const SkColor colors[], SkXfermode* xmode,
michael@0 126 const uint16_t indices[], int indexCount,
michael@0 127 const SkPaint&) SK_OVERRIDE;
michael@0 128 virtual void drawDevice(const SkDraw&, SkBaseDevice*, int x, int y,
michael@0 129 const SkPaint&) SK_OVERRIDE;
michael@0 130 virtual bool filterTextFlags(const SkPaint&, TextFlags*) SK_OVERRIDE;
michael@0 131
michael@0 132 virtual void flush() SK_OVERRIDE;
michael@0 133
michael@0 134 virtual void onAttachToCanvas(SkCanvas* canvas) SK_OVERRIDE;
michael@0 135 virtual void onDetachFromCanvas() SK_OVERRIDE;
michael@0 136
michael@0 137 /**
michael@0 138 * Make's this device's rendertarget current in the underlying 3D API.
michael@0 139 * Also implicitly flushes.
michael@0 140 */
michael@0 141 virtual void makeRenderTargetCurrent();
michael@0 142
michael@0 143 virtual bool canHandleImageFilter(const SkImageFilter*) SK_OVERRIDE;
michael@0 144 virtual bool filterImage(const SkImageFilter*, const SkBitmap&,
michael@0 145 const SkImageFilter::Context&,
michael@0 146 SkBitmap*, SkIPoint*) SK_OVERRIDE;
michael@0 147
michael@0 148 class SkAutoCachedTexture; // used internally
michael@0 149
michael@0 150
michael@0 151 protected:
michael@0 152 virtual bool onReadPixels(const SkBitmap&, int x, int y, SkCanvas::Config8888) SK_OVERRIDE;
michael@0 153 virtual bool onWritePixels(const SkImageInfo&, const void*, size_t, int, int) SK_OVERRIDE;
michael@0 154
michael@0 155 /** PRIVATE / EXPERIMENTAL -- do not call */
michael@0 156 virtual void EXPERIMENTAL_optimize(SkPicture* picture) SK_OVERRIDE;
michael@0 157 /** PRIVATE / EXPERIMENTAL -- do not call */
michael@0 158 virtual bool EXPERIMENTAL_drawPicture(const SkPicture& picture) SK_OVERRIDE;
michael@0 159
michael@0 160 private:
michael@0 161 GrContext* fContext;
michael@0 162
michael@0 163 GrSkDrawProcs* fDrawProcs;
michael@0 164
michael@0 165 GrClipData fClipData;
michael@0 166
michael@0 167 GrTextContext* fMainTextContext;
michael@0 168 GrTextContext* fFallbackTextContext;
michael@0 169
michael@0 170 // state for our render-target
michael@0 171 GrRenderTarget* fRenderTarget;
michael@0 172 bool fNeedClear;
michael@0 173
michael@0 174 // called from rt and tex cons
michael@0 175 void initFromRenderTarget(GrContext*, GrRenderTarget*, bool cached);
michael@0 176
michael@0 177 // used by createCompatibleDevice
michael@0 178 SkGpuDevice(GrContext*, GrTexture* texture, bool needClear);
michael@0 179
michael@0 180 virtual SkBaseDevice* onCreateDevice(const SkImageInfo&, Usage) SK_OVERRIDE;
michael@0 181
michael@0 182 virtual SkSurface* newSurface(const SkImageInfo&) SK_OVERRIDE;
michael@0 183
michael@0 184 // sets the render target, clip, and matrix on GrContext. Use forceIdenity to override
michael@0 185 // SkDraw's matrix and draw in device coords.
michael@0 186 void prepareDraw(const SkDraw&, bool forceIdentity);
michael@0 187
michael@0 188 /**
michael@0 189 * Implementation for both drawBitmap and drawBitmapRect.
michael@0 190 */
michael@0 191 void drawBitmapCommon(const SkDraw&,
michael@0 192 const SkBitmap& bitmap,
michael@0 193 const SkRect* srcRectPtr,
michael@0 194 const SkSize* dstSizePtr, // ignored iff srcRectPtr == NULL
michael@0 195 const SkPaint&,
michael@0 196 SkCanvas::DrawBitmapRectFlags flags);
michael@0 197
michael@0 198 /**
michael@0 199 * Helper functions called by drawBitmapCommon. By the time these are called the SkDraw's
michael@0 200 * matrix, clip, and the device's render target has already been set on GrContext.
michael@0 201 */
michael@0 202
michael@0 203 // The tileSize and clippedSrcRect will be valid only if true is returned.
michael@0 204 bool shouldTileBitmap(const SkBitmap& bitmap,
michael@0 205 const GrTextureParams& sampler,
michael@0 206 const SkRect* srcRectPtr,
michael@0 207 int maxTileSize,
michael@0 208 int* tileSize,
michael@0 209 SkIRect* clippedSrcRect) const;
michael@0 210 void internalDrawBitmap(const SkBitmap&,
michael@0 211 const SkRect&,
michael@0 212 const GrTextureParams& params,
michael@0 213 const SkPaint& paint,
michael@0 214 SkCanvas::DrawBitmapRectFlags flags,
michael@0 215 bool bicubic);
michael@0 216 void drawTiledBitmap(const SkBitmap& bitmap,
michael@0 217 const SkRect& srcRect,
michael@0 218 const SkIRect& clippedSrcRect,
michael@0 219 const GrTextureParams& params,
michael@0 220 const SkPaint& paint,
michael@0 221 SkCanvas::DrawBitmapRectFlags flags,
michael@0 222 int tileSize,
michael@0 223 bool bicubic);
michael@0 224
michael@0 225 static SkPicture::AccelData::Key ComputeAccelDataKey();
michael@0 226
michael@0 227 typedef SkBitmapDevice INHERITED;
michael@0 228 };
michael@0 229
michael@0 230 #endif

mercurial