summaryrefslogtreecommitdiffstats
path: root/mojo/services/native_viewport
diff options
context:
space:
mode:
authorabarth@chromium.org <abarth@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-11-28 10:13:15 +0000
committerabarth@chromium.org <abarth@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-11-28 10:13:15 +0000
commit9bb669dd6178b407ee0c4f0cd776696b239ebe82 (patch)
treeea7bff834660aae9cd3348c95c1bc2406d949f2f /mojo/services/native_viewport
parent3a131e88f4f9d1cca96237a93323314cbe9520b6 (diff)
downloadchromium_src-9bb669dd6178b407ee0c4f0cd776696b239ebe82.zip
chromium_src-9bb669dd6178b407ee0c4f0cd776696b239ebe82.tar.gz
chromium_src-9bb669dd6178b407ee0c4f0cd776696b239ebe82.tar.bz2
[Mojo] Introduce gles2 service
This CL introduces a Mojo service for GLES2 and uses that service to better structure the sample_app's use of GL. The implementation of the service lives in mojo/services/gles2 and currently creates an in-process command buffer. The implementation of the client lives in public/bindings/gles2_client, which wires up the command buffer to gles2_c_lib. When using public/bindings/gles2_client, Mojo applications can now use GL via the normal C API. BUG=none Review URL: https://codereview.chromium.org/93163002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@237756 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'mojo/services/native_viewport')
-rw-r--r--mojo/services/native_viewport/DEPS3
-rw-r--r--mojo/services/native_viewport/native_viewport.mojom4
-rw-r--r--mojo/services/native_viewport/native_viewport_impl.cc39
-rw-r--r--mojo/services/native_viewport/native_viewport_impl.h7
4 files changed, 25 insertions, 28 deletions
diff --git a/mojo/services/native_viewport/DEPS b/mojo/services/native_viewport/DEPS
index 39917a2..6e465aa 100644
--- a/mojo/services/native_viewport/DEPS
+++ b/mojo/services/native_viewport/DEPS
@@ -1,6 +1,5 @@
include_rules = [
- "+base",
- "+gpu/command_buffer/client",
+ "+mojo/services/gles2",
"+ui/events",
"+ui/gfx",
]
diff --git a/mojo/services/native_viewport/native_viewport.mojom b/mojo/services/native_viewport/native_viewport.mojom
index 6bd750c..bd43b93 100644
--- a/mojo/services/native_viewport/native_viewport.mojom
+++ b/mojo/services/native_viewport/native_viewport.mojom
@@ -8,14 +8,12 @@ module mojo {
interface NativeViewport {
void Open();
void Close();
+ void CreateGLES2Context(handle gles2_client);
};
[Peer=NativeViewport]
interface NativeViewportClient {
void DidOpen();
-
- // Rather than send a uint64, we should send an opaque handle to a GL service.
- void DidCreateGLContext(uint64 gl);
};
}
diff --git a/mojo/services/native_viewport/native_viewport_impl.cc b/mojo/services/native_viewport/native_viewport_impl.cc
index cfd1070..80c1afa 100644
--- a/mojo/services/native_viewport/native_viewport_impl.cc
+++ b/mojo/services/native_viewport/native_viewport_impl.cc
@@ -4,13 +4,8 @@
#include "mojo/services/native_viewport/native_viewport_impl.h"
-#include <limits>
-
-#include "base/bind.h"
#include "base/message_loop/message_loop.h"
-#include "base/strings/stringprintf.h"
-#include "gpu/command_buffer/client/gl_in_process_context.h"
-#include "gpu/command_buffer/client/gles2_implementation.h"
+#include "mojo/services/gles2/gles2_impl.h"
#include "mojo/services/native_viewport/native_viewport.h"
#include "ui/events/event.h"
@@ -20,6 +15,7 @@ namespace services {
NativeViewportImpl::NativeViewportImpl(shell::Context* context,
ScopedMessagePipeHandle pipe)
: context_(context),
+ widget_(gfx::kNullAcceleratedWidget),
client_(pipe.Pass()) {
client_.SetPeer(this);
}
@@ -34,31 +30,32 @@ void NativeViewportImpl::Open() {
}
void NativeViewportImpl::Close() {
+ gles2_.reset();
DCHECK(native_viewport_);
native_viewport_->Close();
}
+void NativeViewportImpl::CreateGLES2Context(mojo::Handle gles2_client) {
+ ScopedMessagePipeHandle handle;
+ handle.reset(MessagePipeHandle(gles2_client.value()));
+ gles2_.reset(new GLES2Impl(handle.Pass()));
+ CreateGLES2ContextIfNeeded();
+}
+
+void NativeViewportImpl::CreateGLES2ContextIfNeeded() {
+ if (widget_ == gfx::kNullAcceleratedWidget || !gles2_)
+ return;
+ gles2_->CreateContext(widget_, native_viewport_->GetSize());
+}
+
bool NativeViewportImpl::OnEvent(ui::Event* event) {
return false;
}
void NativeViewportImpl::OnAcceleratedWidgetAvailable(
gfx::AcceleratedWidget widget) {
- gfx::Size size = native_viewport_->GetSize();
- gpu::GLInProcessContextAttribs attribs;
- gl_context_.reset(gpu::GLInProcessContext::CreateContext(
- false, widget, size, false, attribs, gfx::PreferDiscreteGpu));
- gl_context_->SetContextLostCallback(base::Bind(
- &NativeViewportImpl::OnGLContextLost, base::Unretained(this)));
-
- gpu::gles2::GLES2Interface* gl = gl_context_->GetImplementation();
- // TODO(abarth): Instead of drawing green, we want to send the context over
- // pipe_ somehow.
- uint64_t encoded_gl = static_cast<uint64_t>(reinterpret_cast<uintptr_t>(gl));
- client_->DidCreateGLContext(encoded_gl);
-}
-
-void NativeViewportImpl::OnGLContextLost() {
+ widget_ = widget;
+ CreateGLES2ContextIfNeeded();
}
void NativeViewportImpl::OnResized(const gfx::Size& size) {
diff --git a/mojo/services/native_viewport/native_viewport_impl.h b/mojo/services/native_viewport/native_viewport_impl.h
index ace476b..9a90d91 100644
--- a/mojo/services/native_viewport/native_viewport_impl.h
+++ b/mojo/services/native_viewport/native_viewport_impl.h
@@ -18,6 +18,7 @@ class GLInProcessContext;
namespace mojo {
namespace services {
+class GLES2Impl;
class NativeViewportImpl : public NativeViewportStub,
public NativeViewportDelegate {
@@ -28,6 +29,7 @@ class NativeViewportImpl : public NativeViewportStub,
virtual void Open() OVERRIDE;
virtual void Close() OVERRIDE;
+ virtual void CreateGLES2Context(mojo::Handle gles2_client) OVERRIDE;
private:
// Overridden from services::NativeViewportDelegate:
@@ -37,11 +39,12 @@ class NativeViewportImpl : public NativeViewportStub,
virtual bool OnEvent(ui::Event* event) OVERRIDE;
virtual void OnDestroyed() OVERRIDE;
- void OnGLContextLost();
+ void CreateGLES2ContextIfNeeded();
shell::Context* context_;
+ gfx::AcceleratedWidget widget_;
scoped_ptr<services::NativeViewport> native_viewport_;
- scoped_ptr<gpu::GLInProcessContext> gl_context_;
+ scoped_ptr<GLES2Impl> gles2_;
RemotePtr<NativeViewportClient> client_;