gfx/layers/CopyableCanvasLayer.h

Tue, 06 Jan 2015 21:39:09 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Tue, 06 Jan 2015 21:39:09 +0100
branch
TOR_BUG_9701
changeset 8
97036ab72558
permissions
-rw-r--r--

Conditionally force memory storage according to privacy.thirdparty.isolate;
This solves Tor bug #9701, complying with disk avoidance documented in
https://www.torproject.org/projects/torbrowser/design/#disk-avoidance.

michael@0 1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
michael@0 2 * This Source Code Form is subject to the terms of the Mozilla Public
michael@0 3 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 5
michael@0 6 #ifndef GFX_COPYABLECANVASLAYER_H
michael@0 7 #define GFX_COPYABLECANVASLAYER_H
michael@0 8
michael@0 9 #include <stdint.h> // for uint32_t
michael@0 10 #include "GLContextTypes.h" // for GLContext
michael@0 11 #include "Layers.h" // for CanvasLayer, etc
michael@0 12 #include "gfxContext.h" // for gfxContext, etc
michael@0 13 #include "gfxTypes.h"
michael@0 14 #include "gfxPlatform.h" // for gfxImageFormat
michael@0 15 #include "mozilla/Assertions.h" // for MOZ_ASSERT, etc
michael@0 16 #include "mozilla/Preferences.h" // for Preferences
michael@0 17 #include "mozilla/RefPtr.h" // for RefPtr
michael@0 18 #include "mozilla/gfx/2D.h" // for DrawTarget
michael@0 19 #include "mozilla/mozalloc.h" // for operator delete, etc
michael@0 20 #include "nsAutoPtr.h" // for nsRefPtr
michael@0 21 #include "nsISupportsImpl.h" // for MOZ_COUNT_CTOR, etc
michael@0 22
michael@0 23 namespace mozilla {
michael@0 24
michael@0 25 namespace gfx {
michael@0 26 class SurfaceStream;
michael@0 27 class SharedSurface;
michael@0 28 class SurfaceFactory;
michael@0 29 }
michael@0 30
michael@0 31 namespace layers {
michael@0 32
michael@0 33 class CanvasClientWebGL;
michael@0 34
michael@0 35 /**
michael@0 36 * A shared CanvasLayer implementation that supports copying
michael@0 37 * its contents into a gfxASurface using UpdateSurface.
michael@0 38 */
michael@0 39 class CopyableCanvasLayer : public CanvasLayer
michael@0 40 {
michael@0 41 public:
michael@0 42 CopyableCanvasLayer(LayerManager* aLayerManager, void *aImplData);
michael@0 43 virtual ~CopyableCanvasLayer();
michael@0 44
michael@0 45 virtual void Initialize(const Data& aData);
michael@0 46
michael@0 47 virtual bool IsDataValid(const Data& aData);
michael@0 48
michael@0 49 protected:
michael@0 50 void UpdateTarget(gfx::DrawTarget* aDestTarget = nullptr);
michael@0 51
michael@0 52 RefPtr<gfx::SourceSurface> mSurface;
michael@0 53 nsRefPtr<mozilla::gl::GLContext> mGLContext;
michael@0 54 mozilla::RefPtr<mozilla::gfx::DrawTarget> mDrawTarget;
michael@0 55
michael@0 56 RefPtr<gfx::SurfaceStream> mStream;
michael@0 57
michael@0 58 uint32_t mCanvasFramebuffer;
michael@0 59
michael@0 60 bool mIsGLAlphaPremult;
michael@0 61 bool mNeedsYFlip;
michael@0 62
michael@0 63 RefPtr<gfx::DataSourceSurface> mCachedTempSurface;
michael@0 64 gfx::IntSize mCachedSize;
michael@0 65 gfx::SurfaceFormat mCachedFormat;
michael@0 66
michael@0 67 gfx::DataSourceSurface* GetTempSurface(const gfx::IntSize& aSize,
michael@0 68 const gfx::SurfaceFormat aFormat);
michael@0 69
michael@0 70 void DiscardTempSurface();
michael@0 71 };
michael@0 72
michael@0 73 }
michael@0 74 }
michael@0 75
michael@0 76 #endif

mercurial