gfx/gl/SkiaGLGlue.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
-rwxr-xr-x

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++; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40; -*- */
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 #include "mozilla/RefPtr.h"
michael@0 7
michael@0 8 #ifdef USE_SKIA_GPU
michael@0 9
michael@0 10 #include "GLContext.h"
michael@0 11 #include "skia/GrGLInterface.h"
michael@0 12 #include "skia/GrContext.h"
michael@0 13
michael@0 14 namespace mozilla {
michael@0 15 namespace gl {
michael@0 16
michael@0 17 class SkiaGLGlue : public GenericAtomicRefCounted
michael@0 18 {
michael@0 19 public:
michael@0 20 MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(SkiaGLGlue)
michael@0 21 SkiaGLGlue(GLContext* context);
michael@0 22 GLContext* GetGLContext() const { return mGLContext.get(); }
michael@0 23 GrContext* GetGrContext() const { return mGrContext.get(); }
michael@0 24
michael@0 25 protected:
michael@0 26 virtual ~SkiaGLGlue() {
michael@0 27 /*
michael@0 28 * These members have inter-dependencies, but do not keep each other alive, so
michael@0 29 * destruction order is very important here: mGrContext uses mGrGLInterface, and
michael@0 30 * through it, uses mGLContext
michael@0 31 */
michael@0 32 mGrContext = nullptr;
michael@0 33 mGrGLInterface = nullptr;
michael@0 34 mGLContext = nullptr;
michael@0 35 }
michael@0 36
michael@0 37 private:
michael@0 38 RefPtr<GLContext> mGLContext;
michael@0 39 SkRefPtr<GrGLInterface> mGrGLInterface;
michael@0 40 SkRefPtr<GrContext> mGrContext;
michael@0 41 };
michael@0 42
michael@0 43 }
michael@0 44 }
michael@0 45
michael@0 46 #else
michael@0 47
michael@0 48 class GrContext;
michael@0 49
michael@0 50 namespace mozilla {
michael@0 51 namespace gl {
michael@0 52
michael@0 53 class GLContext;
michael@0 54
michael@0 55 class SkiaGLGlue : public GenericAtomicRefCounted
michael@0 56 {
michael@0 57 public:
michael@0 58 SkiaGLGlue(GLContext* context);
michael@0 59 GLContext* GetGLContext() const { return nullptr; }
michael@0 60 GrContext* GetGrContext() const { return nullptr; }
michael@0 61 };
michael@0 62 }
michael@0 63 }
michael@0 64
michael@0 65 #endif

mercurial