Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(21)

Unified Diff: tools/viewer/sk_app/win/GLWindowContext_win.cpp

Issue 2169543002: Use Windowing system-specific WindowContext factories. (Closed) Base URL: https://chromium.googlesource.com/skia.git@master
Patch Set: more xlib Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tools/viewer/sk_app/win/GLWindowContext_win.h ('k') | tools/viewer/sk_app/win/VulkanWindowContext_win.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/viewer/sk_app/win/GLWindowContext_win.cpp
diff --git a/tools/viewer/sk_app/win/GLWindowContext_win.cpp b/tools/viewer/sk_app/win/GLWindowContext_win.cpp
index 0694db308ff59736be165d38b6184f0418ebd96a..eca8829d3d747f25831e5a9c6d40cafda81827ca 100644
--- a/tools/viewer/sk_app/win/GLWindowContext_win.cpp
+++ b/tools/viewer/sk_app/win/GLWindowContext_win.cpp
@@ -6,51 +6,53 @@
* found in the LICENSE file.
*/
-#include "GLWindowContext_win.h"
-
+#include "WindowContextFactory_win.h"
#include <GL/gl.h>
// windows stuff
#include "win/SkWGL.h"
-#include "Window_win.h"
-namespace sk_app {
+#include "../GLWindowContext.h"
-// platform-dependent create
-GLWindowContext* GLWindowContext::Create(void* platformData, const DisplayParams& params) {
- GLWindowContext_win* ctx = new GLWindowContext_win(platformData, params);
- if (!ctx->isValid()) {
- delete ctx;
- return nullptr;
- }
- return ctx;
-}
+using sk_app::GLWindowContext;
+using sk_app::DisplayParams;
+
+namespace {
+
+class GLWindowContext_win : public GLWindowContext {
+public:
+ GLWindowContext_win(HWND, const DisplayParams&);
+ ~GLWindowContext_win() override;
+
+protected:
+ void onSwapBuffers() override;
+
+ void onInitializeContext() override;
+ void onDestroyContext() override;
+
+private:
+ HWND fHWND;
+ HGLRC fHGLRC;
+};
-GLWindowContext_win::GLWindowContext_win(void* platformData, const DisplayParams& params)
- : GLWindowContext(platformData, params)
- , fHWND(0)
+GLWindowContext_win::GLWindowContext_win(HWND wnd, const DisplayParams& params)
+ : GLWindowContext(params)
+ , fHWND(wnd)
, fHGLRC(NULL) {
// any config code here (particularly for msaa)?
- this->initializeContext(platformData, params);
+ this->initializeContext();
}
GLWindowContext_win::~GLWindowContext_win() {
this->destroyContext();
}
-void GLWindowContext_win::onInitializeContext(void* platformData, const DisplayParams& params) {
-
- ContextPlatformData_win* winPlatformData =
- reinterpret_cast<ContextPlatformData_win*>(platformData);
-
- if (winPlatformData) {
- fHWND = winPlatformData->fHWnd;
- }
+void GLWindowContext_win::onInitializeContext() {
HDC dc = GetDC(fHWND);
- fHGLRC = SkCreateWGLContext(dc, params.fMSAASampleCount, params.fDeepColor,
+ fHGLRC = SkCreateWGLContext(dc, fDisplayParams.fMSAASampleCount, fDisplayParams.fDeepColor,
kGLPreferCompatibilityProfile_SkWGLContextRequest);
if (NULL == fHGLRC) {
return;
@@ -107,4 +109,19 @@ void GLWindowContext_win::onSwapBuffers() {
}
-} //namespace sk_app
+} // anonymous namespace
+
+namespace sk_app {
+namespace window_context_factory {
+
+WindowContext* NewGLForWin(HWND wnd, const DisplayParams& params) {
+ GLWindowContext_win* ctx = new GLWindowContext_win(wnd, params);
+ if (!ctx->isValid()) {
+ delete ctx;
+ return nullptr;
+ }
+ return ctx;
+}
+
+} // namespace window_context_factory
+} // namespace sk_app
« no previous file with comments | « tools/viewer/sk_app/win/GLWindowContext_win.h ('k') | tools/viewer/sk_app/win/VulkanWindowContext_win.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698