michael@0: /* -*- Mode: c++; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40; -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #include "mozilla/RefPtr.h" michael@0: michael@0: #ifdef USE_SKIA_GPU michael@0: michael@0: #include "GLContext.h" michael@0: #include "skia/GrGLInterface.h" michael@0: #include "skia/GrContext.h" michael@0: michael@0: namespace mozilla { michael@0: namespace gl { michael@0: michael@0: class SkiaGLGlue : public GenericAtomicRefCounted michael@0: { michael@0: public: michael@0: MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(SkiaGLGlue) michael@0: SkiaGLGlue(GLContext* context); michael@0: GLContext* GetGLContext() const { return mGLContext.get(); } michael@0: GrContext* GetGrContext() const { return mGrContext.get(); } michael@0: michael@0: protected: michael@0: virtual ~SkiaGLGlue() { michael@0: /* michael@0: * These members have inter-dependencies, but do not keep each other alive, so michael@0: * destruction order is very important here: mGrContext uses mGrGLInterface, and michael@0: * through it, uses mGLContext michael@0: */ michael@0: mGrContext = nullptr; michael@0: mGrGLInterface = nullptr; michael@0: mGLContext = nullptr; michael@0: } michael@0: michael@0: private: michael@0: RefPtr mGLContext; michael@0: SkRefPtr mGrGLInterface; michael@0: SkRefPtr mGrContext; michael@0: }; michael@0: michael@0: } michael@0: } michael@0: michael@0: #else michael@0: michael@0: class GrContext; michael@0: michael@0: namespace mozilla { michael@0: namespace gl { michael@0: michael@0: class GLContext; michael@0: michael@0: class SkiaGLGlue : public GenericAtomicRefCounted michael@0: { michael@0: public: michael@0: SkiaGLGlue(GLContext* context); michael@0: GLContext* GetGLContext() const { return nullptr; } michael@0: GrContext* GetGrContext() const { return nullptr; } michael@0: }; michael@0: } michael@0: } michael@0: michael@0: #endif