30bc88ccd5
Refactor SkGLContext to be actually extendable. Before, non-trivial subclass would need to destroy the GL connection upon running the destructor. However, the base class would run GL commands in its own destructor (with destroyed GL connection) Refactor so that SkGLContext subclass object creation is completely done by the factory function. If the factory function returns a non-NULL ptr, it means the context is usable. The destruction is done with the destructor instead of virtual function called upon destruction. Make the destructors not to call virtual functions, for clarity. Remove custom 1x1 FBO setup code from the base class. It appears not to be used anymore. BUG=skia:2992 Review URL: https://codereview.chromium.org/640283004
48 lines
979 B
C++
48 lines
979 B
C++
|
|
/*
|
|
* 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 "SkGLContext.h"
|
|
|
|
#include <GLES2/gl2.h>
|
|
#include <EGL/egl.h>
|
|
|
|
class SkANGLEGLContext : public SkGLContext {
|
|
public:
|
|
virtual ~SkANGLEGLContext() SK_OVERRIDE;
|
|
virtual void makeCurrent() const SK_OVERRIDE;
|
|
virtual void swapBuffers() const SK_OVERRIDE;
|
|
|
|
static SkANGLEGLContext* Create(GrGLStandard forcedGpuAPI) {
|
|
if (kGL_GrGLStandard == forcedGpuAPI) {
|
|
return NULL;
|
|
}
|
|
SkANGLEGLContext* ctx = SkNEW(SkANGLEGLContext);
|
|
if (!ctx->isValid()) {
|
|
SkDELETE(ctx);
|
|
return NULL;
|
|
}
|
|
return ctx;
|
|
}
|
|
|
|
private:
|
|
SkANGLEGLContext();
|
|
void destroyGLContext();
|
|
|
|
EGLContext fContext;
|
|
EGLDisplay fDisplay;
|
|
EGLSurface fSurface;
|
|
};
|
|
|
|
#endif
|
|
|
|
#endif
|