Index: content/child/child_thread_impl.cc |
diff --git a/content/child/child_thread_impl.cc b/content/child/child_thread_impl.cc |
index be915a08df82b9be4e991680f17a9c066617e54b..dbbd97ae90999219b8a498a1a27baf00311841c5 100644 |
--- a/content/child/child_thread_impl.cc |
+++ b/content/child/child_thread_impl.cc |
@@ -8,6 +8,7 @@ |
#include <string> |
+#include "base/process/process_handle.h" |
#include "base/allocator/allocator_extension.h" |
#include "base/base_switches.h" |
#include "base/basictypes.h" |
@@ -29,6 +30,11 @@ |
#include "base/thread_task_runner_handle.h" |
#include "base/threading/thread_local.h" |
#include "base/tracked_objects.h" |
+#include "components/mus/public/cpp/window.h" |
+#include "components/mus/public/cpp/window_observer.h" |
+#include "components/mus/public/cpp/window_surface.h" |
+#include "components/mus/public/cpp/window_tree_connection.h" |
+#include "components/mus/public/cpp/window_tree_delegate.h" |
#include "components/tracing/child_trace_message_filter.h" |
#include "content/child/child_discardable_shared_memory_manager.h" |
#include "content/child/child_gpu_memory_buffer_manager.h" |
@@ -61,6 +67,9 @@ |
#include "ipc/ipc_sync_channel.h" |
#include "ipc/ipc_sync_message_filter.h" |
#include "ipc/mojo/ipc_channel_mojo.h" |
+#include "mojo/application/public/cpp/application_impl.h" |
+#include "mojo/converters/geometry/geometry_type_converters.h" |
+#include "mojo/converters/surfaces/surfaces_utils.h" |
#if defined(TCMALLOC_TRACE_MEMORY_SUPPORTED) |
#include "third_party/tcmalloc/chromium/src/gperftools/heap-profiler.h" |
@@ -277,6 +286,72 @@ void QuitClosure::PostQuitFromNonMainThread() { |
base::LazyInstance<QuitClosure> g_quit_closure = LAZY_INSTANCE_INITIALIZER; |
#endif |
+class WindowTreeDelegateImpl : public mus::WindowTreeDelegate, |
+ public mus::WindowObserver { |
+ public: |
+ WindowTreeDelegateImpl() {} |
+ ~WindowTreeDelegateImpl() override {} |
+ |
+ private: |
+ // WindowTreeDelegateImpl: |
+ void OnEmbed(mus::Window* root) override { |
+ root->AddObserver(this); |
+ fprintf(stderr, ">>>%s root: %p\n", __PRETTY_FUNCTION__, root); |
Fady Samuel
2015/11/24 04:42:38
Move this to RenderWidgetViewMus and revert the re
|
+ surface_ = root->RequestSurface(mus::mojom::SURFACE_TYPE_DEFAULT); |
+ surface_->BindToThread(); |
+ |
+ const gfx::Rect bounds(root->bounds()); |
+ fprintf(stderr, ">>>%s bounds(%d, %d, %d, %d)\n", __PRETTY_FUNCTION__, |
+ bounds.x(), bounds.y(), bounds.width(), bounds.height()); |
+ mus::mojom::PassPtr pass = mojo::CreateDefaultPass(1, bounds); |
+ mus::mojom::CompositorFramePtr frame = mus::mojom::CompositorFrame::New(); |
+ |
+ // TODO(rjkroege): Support device scale factor in PDF viewer |
+ mus::mojom::CompositorFrameMetadataPtr meta = |
+ mus::mojom::CompositorFrameMetadata::New(); |
+ meta->device_scale_factor = 1.0f; |
+ frame->metadata = meta.Pass(); |
+ |
+ frame->resources.resize(0u); |
+ |
+ pass->quads.resize(0u); |
+ pass->shared_quad_states.push_back(mojo::CreateDefaultSQS(bounds.size())); |
+ |
+ mus::mojom::QuadPtr quad = mus::mojom::Quad::New(); |
+ quad->material = mus::mojom::MATERIAL_SOLID_COLOR; |
+ quad->rect = mojo::Rect::From(bounds); |
+ quad->opaque_rect = mojo::Rect::New(); |
+ quad->visible_rect = mojo::Rect::From(bounds); |
+ quad->needs_blending = false; |
+ quad->shared_quad_state_index = 0u; |
+ |
+ mus::mojom::SolidColorQuadStatePtr color_state = |
+ mus::mojom::SolidColorQuadState::New(); |
+ color_state->color = mus::mojom::Color::New(); |
+ color_state->color->rgba = 0xff00ff00; |
+ color_state->force_anti_aliasing_off = false; |
+ |
+ quad->solid_color_quad_state = color_state.Pass(); |
+ pass->quads.push_back(quad.Pass()); |
+ frame->passes.push_back(pass.Pass()); |
+ surface_->SubmitCompositorFrame(frame.Pass(), mojo::Closure()); |
+ } |
+ |
+ void OnUnembed() override {} |
+ |
+ void OnWindowBoundsChanged(mus::Window* window, |
+ const gfx::Rect& old_bounds, |
+ const gfx::Rect& new_bounds) override { |
+ // TODO(fsamuel): Update the size of the child content here. |
+ } |
+ |
+ void OnConnectionLost(mus::WindowTreeConnection* connection) override { |
+ delete this; |
+ } |
+ |
+ scoped_ptr<mus::WindowSurface> surface_; |
+}; |
+ |
} // namespace |
ChildThread* ChildThread::Get() { |
@@ -567,6 +642,24 @@ void ChildThreadImpl::OnChannelError() { |
base::MessageLoop::current()->QuitWhenIdle(); |
} |
+bool ChildThreadImpl::ConfigureIncomingConnection( |
+ mojo::ApplicationConnection* connection) { |
+ // TODO(fsamuel): This doens't belong here. We should have this elsewhere. |
+ fprintf(stderr, ">>>>>INCOMING CONNECTION %s!!!\n", |
+ connection->GetRemoteApplicationURL().c_str()); |
+ connection->AddService<mus::mojom::WindowTreeClient>(this); |
+ return true; |
+} |
+ |
+void ChildThreadImpl::Create( |
+ mojo::ApplicationConnection* connection, |
+ mojo::InterfaceRequest<mus::mojom::WindowTreeClient> request) { |
+ fprintf(stderr, ">>>>>WINDOW TREE CLIENT!!!\n"); |
+ mus::WindowTreeConnection::Create( |
+ new WindowTreeDelegateImpl, request.Pass(), |
+ mus::WindowTreeConnection::CreateType::DONT_WAIT_FOR_EMBED); |
+} |
+ |
bool ChildThreadImpl::Send(IPC::Message* msg) { |
DCHECK(base::MessageLoop::current() == message_loop()); |
if (!channel_) { |
@@ -727,7 +820,12 @@ void ChildThreadImpl::OnBindExternalMojoShellHandle( |
mojo_shell_channel_init_.Init(handle, GetIOTaskRunner()); |
DCHECK(message_pipe.is_valid()); |
MojoShellConnectionImpl::CreateWithMessagePipe(message_pipe.Pass()); |
+ fprintf(stderr, "[%d] >>>%s url: %s\n", base::GetCurrentProcId(), |
+ __PRETTY_FUNCTION__, |
+ MojoShellConnection::Get()->GetApplication()->url().c_str()); |
+ MojoShellConnection::Get()->AddListener(this); |
#endif // defined(MOJO_SHELL_CLIENT) |
+ Send(new MojoHostMsg_MojoReady()); |
} |
#if defined(USE_TCMALLOC) |