gfx/gl/SkiaGLGlue.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/gfx/gl/SkiaGLGlue.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,65 @@
     1.4 +/* -*- Mode: c++; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40; -*- */
     1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.6 +* License, v. 2.0. If a copy of the MPL was not distributed with this
     1.7 +* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.8 +
     1.9 +#include "mozilla/RefPtr.h"
    1.10 +
    1.11 +#ifdef USE_SKIA_GPU
    1.12 +
    1.13 +#include "GLContext.h"
    1.14 +#include "skia/GrGLInterface.h"
    1.15 +#include "skia/GrContext.h"
    1.16 +
    1.17 +namespace mozilla {
    1.18 +namespace gl {
    1.19 +
    1.20 +class SkiaGLGlue : public GenericAtomicRefCounted
    1.21 +{
    1.22 +public:
    1.23 +  MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(SkiaGLGlue)
    1.24 +  SkiaGLGlue(GLContext* context);
    1.25 +  GLContext* GetGLContext() const { return mGLContext.get(); }
    1.26 +  GrContext* GetGrContext() const { return mGrContext.get(); }
    1.27 +
    1.28 +protected:
    1.29 +  virtual ~SkiaGLGlue() {
    1.30 +    /*
    1.31 +     * These members have inter-dependencies, but do not keep each other alive, so
    1.32 +     * destruction order is very important here: mGrContext uses mGrGLInterface, and
    1.33 +     * through it, uses mGLContext
    1.34 +     */
    1.35 +    mGrContext = nullptr;
    1.36 +    mGrGLInterface = nullptr;
    1.37 +    mGLContext = nullptr;
    1.38 +  }
    1.39 +
    1.40 +private:
    1.41 +  RefPtr<GLContext> mGLContext;
    1.42 +  SkRefPtr<GrGLInterface> mGrGLInterface;
    1.43 +  SkRefPtr<GrContext> mGrContext;
    1.44 +};
    1.45 +
    1.46 +}
    1.47 +}
    1.48 +
    1.49 +#else
    1.50 +
    1.51 +class GrContext;
    1.52 +
    1.53 +namespace mozilla {
    1.54 +namespace gl {
    1.55 +
    1.56 +class GLContext;
    1.57 +
    1.58 +class SkiaGLGlue : public GenericAtomicRefCounted
    1.59 +{
    1.60 +public:
    1.61 +  SkiaGLGlue(GLContext* context);
    1.62 +  GLContext* GetGLContext() const { return nullptr; }
    1.63 +  GrContext* GetGrContext() const { return nullptr; }
    1.64 +};
    1.65 +}
    1.66 +}
    1.67 +
    1.68 +#endif
    1.69 \ No newline at end of file

mercurial