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

Unified Diff: mojo/services/native_viewport/native_viewport_win.cc

Issue 59513005: Hook up GL Command buffer on Windows too (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Eliminate base dependency Created 7 years, 1 month 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 | « mojo/examples/sample_app/sample_app.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/services/native_viewport/native_viewport_win.cc
diff --git a/mojo/services/native_viewport/native_viewport_win.cc b/mojo/services/native_viewport/native_viewport_win.cc
index 85ef0130685e304fba06c38d6c7e43fcb4a85de6..3654cb7d24a2cded07a08809c3394eda4a748e28 100644
--- a/mojo/services/native_viewport/native_viewport_win.cc
+++ b/mojo/services/native_viewport/native_viewport_win.cc
@@ -3,6 +3,10 @@
// found in the LICENSE file.
#include "mojo/services/native_viewport/native_viewport.h"
+
+#include "base/bind.h"
+#include "gpu/command_buffer/client/gl_in_process_context.h"
+#include "gpu/command_buffer/client/gles2_implementation.h"
#include "ui/events/event.h"
#include "ui/gfx/win/window_impl.h"
@@ -32,6 +36,7 @@ class NativeViewportWin : public gfx::WindowImpl,
BEGIN_MSG_MAP_EX(NativeViewportWin)
MESSAGE_RANGE_HANDLER_EX(WM_MOUSEFIRST, WM_MOUSELAST, OnMouseRange)
+ MSG_WM_CREATE(OnCreate)
MSG_WM_PAINT(OnPaint)
MSG_WM_SIZE(OnSize)
MSG_WM_DESTROY(OnDestroy)
@@ -45,6 +50,19 @@ class NativeViewportWin : public gfx::WindowImpl,
SetMsgHandled(handled);
return 0;
}
+ LRESULT OnCreate(CREATESTRUCT* create_struct) {
+ RECT cr;
+ GetClientRect(hwnd(), &cr);
+ gpu::GLInProcessContextAttribs attribs;
+ gl_context_.reset(gpu::GLInProcessContext::CreateContext(
+ false, hwnd(), gfx::Size(cr.right - cr.left, cr.bottom - cr.top),
+ false, attribs, gfx::PreferDiscreteGpu));
+ gl_context_->SetContextLostCallback(base::Bind(
+ &NativeViewportWin::OnGLContextLost, base::Unretained(this)));
+
+ delegate_->OnGLContextAvailable(gl_context_->GetImplementation());
+ return 0;
+ }
void OnPaint(HDC) {
RECT cr;
GetClientRect(hwnd(), &cr);
@@ -65,7 +83,13 @@ class NativeViewportWin : public gfx::WindowImpl,
delegate_->OnDestroyed();
}
+ void OnGLContextLost() {
+ gl_context_.reset();
+ delegate_->OnGLContextLost();
+ }
+
NativeViewportDelegate* delegate_;
+ scoped_ptr<gpu::GLInProcessContext> gl_context_;
DISALLOW_COPY_AND_ASSIGN(NativeViewportWin);
};
« no previous file with comments | « mojo/examples/sample_app/sample_app.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698