2016-05-20 13:01:06 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Copyright 2016 Google Inc.
|
|
|
|
*
|
|
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
|
|
* found in the LICENSE file.
|
|
|
|
*/
|
|
|
|
#ifndef GLWindowContext_DEFINED
|
|
|
|
#define GLWindowContext_DEFINED
|
|
|
|
|
|
|
|
|
2019-04-23 17:05:21 +00:00
|
|
|
#include "include/gpu/gl/GrGLInterface.h"
|
2016-05-20 13:01:06 +00:00
|
|
|
|
2019-04-23 17:05:21 +00:00
|
|
|
#include "include/core/SkRefCnt.h"
|
|
|
|
#include "include/core/SkSurface.h"
|
2016-05-20 13:01:06 +00:00
|
|
|
|
2019-04-23 17:05:21 +00:00
|
|
|
#include "tools/sk_app/WindowContext.h"
|
2016-05-20 13:01:06 +00:00
|
|
|
|
|
|
|
namespace sk_app {
|
|
|
|
|
|
|
|
class GLWindowContext : public WindowContext {
|
|
|
|
public:
|
|
|
|
sk_sp<SkSurface> getBackbufferSurface() override;
|
|
|
|
|
|
|
|
bool isValid() override { return SkToBool(fBackendContext.get()); }
|
|
|
|
|
2016-07-27 15:50:12 +00:00
|
|
|
void resize(int w, int h) override;
|
2016-05-20 13:01:06 +00:00
|
|
|
void swapBuffers() override;
|
|
|
|
|
|
|
|
void setDisplayParams(const DisplayParams& params) override;
|
|
|
|
|
|
|
|
protected:
|
2016-07-26 19:02:50 +00:00
|
|
|
GLWindowContext(const DisplayParams&);
|
|
|
|
// This should be called by subclass constructor. It is also called when window/display
|
|
|
|
// parameters change. This will in turn call onInitializeContext().
|
|
|
|
void initializeContext();
|
2017-08-17 18:37:06 +00:00
|
|
|
virtual sk_sp<const GrGLInterface> onInitializeContext() = 0;
|
2016-07-26 19:02:50 +00:00
|
|
|
|
|
|
|
// This should be called by subclass destructor. It is also called when window/display
|
|
|
|
// parameters change prior to initializing a new GL context. This will in turn call
|
|
|
|
// onDestroyContext().
|
2016-05-20 13:01:06 +00:00
|
|
|
void destroyContext();
|
|
|
|
virtual void onDestroyContext() = 0;
|
2016-07-26 19:02:50 +00:00
|
|
|
|
2016-05-20 13:01:06 +00:00
|
|
|
virtual void onSwapBuffers() = 0;
|
|
|
|
|
2016-11-03 20:26:13 +00:00
|
|
|
sk_sp<const GrGLInterface> fBackendContext;
|
|
|
|
sk_sp<SkSurface> fSurface;
|
2016-05-20 13:01:06 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace sk_app
|
|
|
|
|
|
|
|
#endif
|