gfx/skia/skia/include/gpu/gl/angle/SkANGLEGLContext.h
author Lee Salzman <lsalzman@mozilla.com>
Tue, 09 Feb 2016 13:38:06 -0500
changeset 283697 159e0a5a653f2789e0c9b94f41501a4a44f7cb34
parent 276855 aa380501527094672fd84092655f82e62c504482
permissions -rw-r--r--
Bug 1246756 - part 3 - update Skia to m49 branch. r=jrmuizel


/*
 * Copyright 2012 Google Inc.
 *
 * Use of this source code is governed by a BSD-style license that can be
 * found in the LICENSE file.
 */
#ifndef SkANGLEGLContext_DEFINED
#define SkANGLEGLContext_DEFINED

#if SK_ANGLE

#include "gl/SkGLContext.h"

class SkANGLEGLContext : public SkGLContext {
public:
    ~SkANGLEGLContext() override;
#ifdef SK_BUILD_FOR_WIN
    static SkANGLEGLContext* CreateDirectX() {
        SkANGLEGLContext* ctx = new SkANGLEGLContext(false);
        if (!ctx->isValid()) {
            delete ctx;
            return NULL;
        }
        return ctx;
    }
#endif
    static SkANGLEGLContext* CreateOpenGL() {
        SkANGLEGLContext* ctx = new SkANGLEGLContext(true);
        if (!ctx->isValid()) {
            delete ctx;
            return NULL;
        }
        return ctx;
    }

    GrEGLImage texture2DToEGLImage(GrGLuint texID) const override;
    void destroyEGLImage(GrEGLImage) const override;
    GrGLuint eglImageToExternalTexture(GrEGLImage) const override;
    SkGLContext* createNew() const override;

    // The param is an EGLNativeDisplayType and the return is an EGLDispay.
    static void* GetD3DEGLDisplay(void* nativeDisplay, bool useGLBackend);

private:
    SkANGLEGLContext(bool preferGLBackend);
    void destroyGLContext();

    void onPlatformMakeCurrent() const override;
    void onPlatformSwapBuffers() const override;
    GrGLFuncPtr onPlatformGetProcAddress(const char* name) const override;

    void* fContext;
    void* fDisplay;
    void* fSurface;
    bool  fIsGLBackend;
};

#endif

#endif