aboutsummaryrefslogtreecommitdiffhomepage
path: root/tools/viewer/sk_app/WindowContext.h
diff options
context:
space:
mode:
authorGravatar jvanverth <jvanverth@google.com>2016-05-17 12:15:48 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2016-05-17 12:15:48 -0700
commit56a11e4d6f3d436a3c2497c9c9e71a117d78a93f (patch)
tree5a05d0b16a03b28d47e1f4b9cfe71b941baff140 /tools/viewer/sk_app/WindowContext.h
parentc5fd5c41abd1e50293643c40e11e1f62cd22d3e9 (diff)
Add OpenGL context to Viewer.
Diffstat (limited to 'tools/viewer/sk_app/WindowContext.h')
-rw-r--r--tools/viewer/sk_app/WindowContext.h34
1 files changed, 29 insertions, 5 deletions
diff --git a/tools/viewer/sk_app/WindowContext.h b/tools/viewer/sk_app/WindowContext.h
index d48e38e746..1fd921afb2 100644
--- a/tools/viewer/sk_app/WindowContext.h
+++ b/tools/viewer/sk_app/WindowContext.h
@@ -9,30 +9,54 @@
#include "DisplayParams.h"
#include "GrTypes.h"
+#include "SkRefCnt.h"
+#include "SkSurfaceProps.h"
+class GrContext;
class SkSurface;
+class GrRenderTarget;
namespace sk_app {
-// TODO: fill this out with an interface
class WindowContext {
public:
+ WindowContext() : fContext(nullptr)
+ , fSurfaceProps(SkSurfaceProps::kLegacyFontHost_InitType) {}
+
virtual ~WindowContext() {}
- virtual SkSurface* getBackbufferSurface() = 0;
+ virtual sk_sp<SkSurface> getBackbufferSurface() = 0;
virtual void swapBuffers() = 0;
- virtual bool makeCurrent() = 0;
-
virtual bool isValid() = 0;
virtual void resize(uint32_t w, uint32_t h) = 0;
- virtual const DisplayParams& getDisplayParams() = 0;
+ const DisplayParams& getDisplayParams() { return fDisplayParams; }
virtual void setDisplayParams(const DisplayParams& params) = 0;
+ SkSurfaceProps getSurfaceProps() const { return fSurfaceProps; }
+ void setSurfaceProps(const SkSurfaceProps& props) {
+ fSurfaceProps = props;
+ }
+
virtual GrBackendContext getBackendContext() = 0;
+
+ sk_sp<SkSurface> createRenderSurface(sk_sp<GrRenderTarget>, int colorBits);
+ void presentRenderSurface(sk_sp<SkSurface> renderSurface, sk_sp<GrRenderTarget> rt,
+ int colorBits);
+
+protected:
+ virtual bool isGpuContext() { return true; }
+
+ GrContext* fContext;
+
+ int fWidth;
+ int fHeight;
+ DisplayParams fDisplayParams;
+ GrPixelConfig fPixelConfig;
+ SkSurfaceProps fSurfaceProps;
};
} // namespace sk_app