gfx/skia/trunk/src/image/SkSurface_Base.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 * 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 #ifndef SkSurface_Base_DEFINED
michael@0 9 #define SkSurface_Base_DEFINED
michael@0 10
michael@0 11 #include "SkSurface.h"
michael@0 12 #include "SkCanvas.h"
michael@0 13
michael@0 14 class SkSurface_Base : public SkSurface {
michael@0 15 public:
michael@0 16 SkSurface_Base(int width, int height);
michael@0 17 explicit SkSurface_Base(const SkImageInfo&);
michael@0 18 virtual ~SkSurface_Base();
michael@0 19
michael@0 20 /**
michael@0 21 * Allocate a canvas that will draw into this surface. We will cache this
michael@0 22 * canvas, to return the same object to the caller multiple times. We
michael@0 23 * take ownership, and will call unref() on the canvas when we go out of
michael@0 24 * scope.
michael@0 25 */
michael@0 26 virtual SkCanvas* onNewCanvas() = 0;
michael@0 27
michael@0 28 virtual SkSurface* onNewSurface(const SkImageInfo&) = 0;
michael@0 29
michael@0 30 /**
michael@0 31 * Allocate an SkImage that represents the current contents of the surface.
michael@0 32 * This needs to be able to outlive the surface itself (if need be), and
michael@0 33 * must faithfully represent the current contents, even if the surface
michael@0 34 * is chaged after this calle (e.g. it is drawn to via its canvas).
michael@0 35 */
michael@0 36 virtual SkImage* onNewImageSnapshot() = 0;
michael@0 37
michael@0 38 /**
michael@0 39 * Default implementation:
michael@0 40 *
michael@0 41 * image = this->newImageSnapshot();
michael@0 42 * if (image) {
michael@0 43 * image->draw(canvas, ...);
michael@0 44 * image->unref();
michael@0 45 * }
michael@0 46 */
michael@0 47 virtual void onDraw(SkCanvas*, SkScalar x, SkScalar y, const SkPaint*);
michael@0 48
michael@0 49 /**
michael@0 50 * If the surface is about to change, we call this so that our subclass
michael@0 51 * can optionally fork their backend (copy-on-write) in case it was
michael@0 52 * being shared with the cachedImage.
michael@0 53 */
michael@0 54 virtual void onCopyOnWrite(ContentChangeMode) = 0;
michael@0 55
michael@0 56 inline SkCanvas* getCachedCanvas();
michael@0 57 inline SkImage* getCachedImage();
michael@0 58
michael@0 59 // called by SkSurface to compute a new genID
michael@0 60 uint32_t newGenerationID();
michael@0 61
michael@0 62 private:
michael@0 63 SkCanvas* fCachedCanvas;
michael@0 64 SkImage* fCachedImage;
michael@0 65
michael@0 66 void aboutToDraw(ContentChangeMode mode);
michael@0 67 friend class SkCanvas;
michael@0 68 friend class SkSurface;
michael@0 69
michael@0 70 inline void installIntoCanvasForDirtyNotification();
michael@0 71
michael@0 72 typedef SkSurface INHERITED;
michael@0 73 };
michael@0 74
michael@0 75 SkCanvas* SkSurface_Base::getCachedCanvas() {
michael@0 76 if (NULL == fCachedCanvas) {
michael@0 77 fCachedCanvas = this->onNewCanvas();
michael@0 78 this->installIntoCanvasForDirtyNotification();
michael@0 79 }
michael@0 80 return fCachedCanvas;
michael@0 81 }
michael@0 82
michael@0 83 SkImage* SkSurface_Base::getCachedImage() {
michael@0 84 if (NULL == fCachedImage) {
michael@0 85 fCachedImage = this->onNewImageSnapshot();
michael@0 86 this->installIntoCanvasForDirtyNotification();
michael@0 87 }
michael@0 88 return fCachedImage;
michael@0 89 }
michael@0 90
michael@0 91 void SkSurface_Base::installIntoCanvasForDirtyNotification() {
michael@0 92 if (NULL != fCachedCanvas) {
michael@0 93 fCachedCanvas->setSurfaceBase(this);
michael@0 94 }
michael@0 95 }
michael@0 96
michael@0 97 #endif

mercurial