aboutsummaryrefslogtreecommitdiffhomepage
path: root/tools/sk_app/WindowContext.h
diff options
context:
space:
mode:
authorGravatar Brian Osman <brianosman@google.com>2017-11-21 13:18:02 -0500
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-11-21 18:37:19 +0000
commiteff04b5ec287e0fee0d44207c10d2d11f7eade8a (patch)
treeea2cf00ea329c81611536aaa9a9f1eca47c67e9a /tools/sk_app/WindowContext.h
parent2aa09dbe8aced37aa6bb285e62df45deb0e81650 (diff)
Remove SampleApp and convert HelloWorld to sk_app
There is still a large amount of views code that could be trimmed down, but which is used to implement samples (in viewer). Seemed simpler to remove some of this code in pieces. Bug: skia: Change-Id: Ia3415060d03c8de604a154e3dc38379b754daab6 Reviewed-on: https://skia-review.googlesource.com/72801 Commit-Queue: Brian Osman <brianosman@google.com> Reviewed-by: Jim Van Verth <jvanverth@google.com> Reviewed-by: Brian Salomon <bsalomon@google.com>
Diffstat (limited to 'tools/sk_app/WindowContext.h')
-rw-r--r--tools/sk_app/WindowContext.h76
1 files changed, 76 insertions, 0 deletions
diff --git a/tools/sk_app/WindowContext.h b/tools/sk_app/WindowContext.h
new file mode 100644
index 0000000000..cd4c357e20
--- /dev/null
+++ b/tools/sk_app/WindowContext.h
@@ -0,0 +1,76 @@
+/*
+ * 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 WindowContext_DEFINED
+#define WindowContext_DEFINED
+
+#include "DisplayParams.h"
+#include "GrContext.h"
+#include "GrTypes.h"
+#include "SkRefCnt.h"
+#include "SkSurfaceProps.h"
+
+class SkSurface;
+class GrRenderTarget;
+
+namespace sk_app {
+
+class WindowContext {
+public:
+ WindowContext(const DisplayParams& params)
+ : fContext(nullptr)
+ , fDisplayParams(params)
+ , fSurfaceProps(SkSurfaceProps::kLegacyFontHost_InitType)
+ , fSampleCount(0)
+ , fStencilBits(0) {}
+
+ virtual ~WindowContext() {}
+
+ virtual sk_sp<SkSurface> getBackbufferSurface() = 0;
+
+ virtual void swapBuffers() = 0;
+
+ virtual bool isValid() = 0;
+
+ virtual void resize(int w, int h) = 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;
+ GrContext* getGrContext() const { return fContext.get(); }
+
+ int width() const { return fWidth; }
+ int height() const { return fHeight; }
+ int sampleCount() const { return fSampleCount; }
+ int stencilBits() const { return fStencilBits; }
+
+protected:
+ virtual bool isGpuContext() { return true; }
+
+ sk_sp<GrContext> fContext;
+
+ int fWidth;
+ int fHeight;
+ DisplayParams fDisplayParams;
+ GrPixelConfig fPixelConfig;
+ SkSurfaceProps fSurfaceProps;
+
+ // parameters obtained from the native window
+ // Note that the platform .cpp file is responsible for
+ // initializing fSampleCount and fStencilBits!
+ int fSampleCount;
+ int fStencilBits;
+};
+
+} // namespace sk_app
+
+#endif