summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-06-07 08:17:42 +0000
committersky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-06-07 08:17:42 +0000
commit6929154213ec00236e4e123d63ff1f88f458391e (patch)
tree3e6354f008c0eaed7cb06faf61a0fbefa57b0fc6
parentbe32d87d0e255ed03bae17ddefa0a6559765975c (diff)
downloadchromium_src-6929154213ec00236e4e123d63ff1f88f458391e.zip
chromium_src-6929154213ec00236e4e123d63ff1f88f458391e.tar.gz
chromium_src-6929154213ec00236e4e123d63ff1f88f458391e.tar.bz2
Moves common view_manager related aura files to mojo/aura
I'm going to use these files in other examples. I refactored the code slightly to update compositor via a delegate. This way the code can easily (hopefully) be used by view_manager_lib related code. I'm also making aura::Env extend base::SupportsUserData so that consumers can add arbitrary key/value pairs to Env. BUG=365012 TEST=none R=ben@chromium.org Review URL: https://codereview.chromium.org/314113011 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@275638 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--mojo/aura/DEPS1
-rw-r--r--mojo/aura/context_factory_mojo.cc (renamed from mojo/examples/aura_demo/context_factory_view_manager.cc)102
-rw-r--r--mojo/aura/context_factory_mojo.h (renamed from mojo/examples/aura_demo/context_factory_view_manager.h)22
-rw-r--r--mojo/aura/window_tree_host_mojo.cc161
-rw-r--r--mojo/aura/window_tree_host_mojo.h (renamed from mojo/examples/aura_demo/window_tree_host_view_manager.h)29
-rw-r--r--mojo/aura/window_tree_host_mojo_delegate.h24
-rw-r--r--mojo/examples/aura_demo/aura_demo.cc85
-rw-r--r--mojo/examples/aura_demo/window_tree_host_view_manager.cc96
-rw-r--r--mojo/mojo.gyp5
-rw-r--r--mojo/mojo_examples.gypi4
-rw-r--r--ui/aura/env.h3
11 files changed, 318 insertions, 214 deletions
diff --git a/mojo/aura/DEPS b/mojo/aura/DEPS
index 698be88..ad60823 100644
--- a/mojo/aura/DEPS
+++ b/mojo/aura/DEPS
@@ -1,5 +1,6 @@
include_rules = [
"+cc",
+ "+skia",
"+ui/aura",
"+ui/compositor",
"+ui/events",
diff --git a/mojo/examples/aura_demo/context_factory_view_manager.cc b/mojo/aura/context_factory_mojo.cc
index 46596c3..6b2b709 100644
--- a/mojo/examples/aura_demo/context_factory_view_manager.cc
+++ b/mojo/aura/context_factory_mojo.cc
@@ -2,19 +2,17 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "mojo/examples/aura_demo/context_factory_view_manager.h"
+#include "mojo/aura/context_factory_mojo.h"
#include "base/bind.h"
#include "cc/output/output_surface.h"
#include "cc/output/software_output_device.h"
#include "cc/resources/shared_bitmap_manager.h"
-#include "mojo/services/public/interfaces/view_manager/view_manager.mojom.h"
+#include "mojo/aura/window_tree_host_mojo.h"
#include "skia/ext/platform_canvas.h"
#include "ui/compositor/reflector.h"
-#include "ui/gfx/codec/png_codec.h"
namespace mojo {
-namespace examples {
namespace {
void FreeSharedBitmap(cc::SharedBitmap* shared_bitmap) {
@@ -23,77 +21,26 @@ void FreeSharedBitmap(cc::SharedBitmap* shared_bitmap) {
void IgnoreSharedBitmap(cc::SharedBitmap* shared_bitmap) {}
-bool CreateMapAndDupSharedBuffer(size_t size,
- void** memory,
- ScopedSharedBufferHandle* handle,
- ScopedSharedBufferHandle* duped) {
- MojoResult result = CreateSharedBuffer(NULL, size, handle);
- if (result != MOJO_RESULT_OK)
- return false;
- DCHECK(handle->is_valid());
-
- result = DuplicateBuffer(handle->get(), NULL, duped);
- if (result != MOJO_RESULT_OK)
- return false;
- DCHECK(duped->is_valid());
-
- result = MapBuffer(
- handle->get(), 0, size, memory, MOJO_MAP_BUFFER_FLAG_NONE);
- if (result != MOJO_RESULT_OK)
- return false;
- DCHECK(*memory);
-
- return true;
-}
-
class SoftwareOutputDeviceViewManager : public cc::SoftwareOutputDevice {
public:
- explicit SoftwareOutputDeviceViewManager(
- view_manager::IViewManager* view_manager,
- uint32_t view_id)
- : view_manager_(view_manager),
- view_id_(view_id) {
+ explicit SoftwareOutputDeviceViewManager(ui::Compositor* compositor)
+ : compositor_(compositor) {
}
virtual ~SoftwareOutputDeviceViewManager() {}
// cc::SoftwareOutputDevice:
virtual void EndPaint(cc::SoftwareFrameData* frame_data) OVERRIDE {
- SetViewContents();
+ WindowTreeHostMojo* window_tree_host =
+ WindowTreeHostMojo::ForCompositor(compositor_);
+ DCHECK(window_tree_host);
+ window_tree_host->SetContents(
+ skia::GetTopDevice(*canvas_)->accessBitmap(true));
SoftwareOutputDevice::EndPaint(frame_data);
}
private:
- void OnSetViewContentsDone(bool value) {
- VLOG(1) << "SoftwareOutputDeviceManager::OnSetViewContentsDone " << value;
- DCHECK(value);
- }
-
- void SetViewContents() {
- std::vector<unsigned char> data;
- gfx::PNGCodec::EncodeBGRASkBitmap(
- skia::GetTopDevice(*canvas_)->accessBitmap(true), false, &data);
-
- void* memory = NULL;
- ScopedSharedBufferHandle duped;
- bool result = CreateMapAndDupSharedBuffer(data.size(),
- &memory,
- &shared_state_handle_,
- &duped);
- if (!result)
- return;
-
- memcpy(memory, &data[0], data.size());
-
- view_manager_->SetViewContents(
- view_id_, duped.Pass(), static_cast<uint32_t>(data.size()),
- base::Bind(&SoftwareOutputDeviceViewManager::OnSetViewContentsDone,
- base::Unretained(this)));
- }
-
- view_manager::IViewManager* view_manager_;
- const uint32_t view_id_;
- ScopedSharedBufferHandle shared_state_handle_;
+ ui::Compositor* compositor_;
DISALLOW_COPY_AND_ASSIGN(SoftwareOutputDeviceViewManager);
};
@@ -145,50 +92,45 @@ class TestSharedBitmapManager : public cc::SharedBitmapManager {
} // namespace
-ContextFactoryViewManager::ContextFactoryViewManager(
- view_manager::IViewManager* view_manager,
- uint32_t view_id)
- : view_manager_(view_manager),
- view_id_(view_id),
- shared_bitmap_manager_(new TestSharedBitmapManager()) {
+ContextFactoryMojo::ContextFactoryMojo()
+ : shared_bitmap_manager_(new TestSharedBitmapManager()) {
}
-ContextFactoryViewManager::~ContextFactoryViewManager() {}
+ContextFactoryMojo::~ContextFactoryMojo() {}
-scoped_ptr<cc::OutputSurface> ContextFactoryViewManager::CreateOutputSurface(
+scoped_ptr<cc::OutputSurface> ContextFactoryMojo::CreateOutputSurface(
ui::Compositor* compositor,
bool software_fallback) {
scoped_ptr<cc::SoftwareOutputDevice> output_device(
- new SoftwareOutputDeviceViewManager(view_manager_, view_id_));
+ new SoftwareOutputDeviceViewManager(compositor));
return make_scoped_ptr(new cc::OutputSurface(output_device.Pass()));
}
-scoped_refptr<ui::Reflector> ContextFactoryViewManager::CreateReflector(
+scoped_refptr<ui::Reflector> ContextFactoryMojo::CreateReflector(
ui::Compositor* mirroed_compositor,
ui::Layer* mirroring_layer) {
return new ui::Reflector();
}
-void ContextFactoryViewManager::RemoveReflector(
+void ContextFactoryMojo::RemoveReflector(
scoped_refptr<ui::Reflector> reflector) {
}
scoped_refptr<cc::ContextProvider>
-ContextFactoryViewManager::SharedMainThreadContextProvider() {
+ContextFactoryMojo::SharedMainThreadContextProvider() {
return scoped_refptr<cc::ContextProvider>(NULL);
}
-void ContextFactoryViewManager::RemoveCompositor(ui::Compositor* compositor) {}
+void ContextFactoryMojo::RemoveCompositor(ui::Compositor* compositor) {}
-bool ContextFactoryViewManager::DoesCreateTestContexts() { return false; }
+bool ContextFactoryMojo::DoesCreateTestContexts() { return false; }
-cc::SharedBitmapManager* ContextFactoryViewManager::GetSharedBitmapManager() {
+cc::SharedBitmapManager* ContextFactoryMojo::GetSharedBitmapManager() {
return shared_bitmap_manager_.get();
}
-base::MessageLoopProxy* ContextFactoryViewManager::GetCompositorMessageLoop() {
+base::MessageLoopProxy* ContextFactoryMojo::GetCompositorMessageLoop() {
return NULL;
}
-} // namespace examples
} // namespace mojo
diff --git a/mojo/examples/aura_demo/context_factory_view_manager.h b/mojo/aura/context_factory_mojo.h
index c74da16..800afa7 100644
--- a/mojo/examples/aura_demo/context_factory_view_manager.h
+++ b/mojo/aura/context_factory_mojo.h
@@ -2,22 +2,17 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef MOJO_EXAMPLES_AURA_DEMO_CONTEXT_FACTORY_VIEW_MANAGER_H_
-#define MOJO_EXAMPLES_AURA_DEMO_CONTEXT_FACTORY_VIEW_MANAGER_H_
+#ifndef MOJO_AURA_CONTEXT_FACTORY_MOJO_H_
+#define MOJO_AURA_CONTEXT_FACTORY_MOJO_H_
#include "ui/compositor/compositor.h"
namespace mojo {
-namespace view_manager {
-class IViewManager;
-}
-namespace examples {
-class ContextFactoryViewManager : public ui::ContextFactory {
+class ContextFactoryMojo : public ui::ContextFactory {
public:
- ContextFactoryViewManager(view_manager::IViewManager* view_manager,
- uint32_t view_id);
- virtual ~ContextFactoryViewManager();
+ ContextFactoryMojo();
+ virtual ~ContextFactoryMojo();
private:
// ContextFactory:
@@ -35,14 +30,11 @@ class ContextFactoryViewManager : public ui::ContextFactory {
virtual cc::SharedBitmapManager* GetSharedBitmapManager() OVERRIDE;
virtual base::MessageLoopProxy* GetCompositorMessageLoop() OVERRIDE;
- view_manager::IViewManager* view_manager_;
- const uint32_t view_id_;
scoped_ptr<cc::SharedBitmapManager> shared_bitmap_manager_;
- DISALLOW_COPY_AND_ASSIGN(ContextFactoryViewManager);
+ DISALLOW_COPY_AND_ASSIGN(ContextFactoryMojo);
};
-} // namespace examples
} // namespace mojo
-#endif // MOJO_EXAMPLES_AURA_DEMO_CONTEXT_FACTORY_VIEW_MANAGER_H_
+#endif // MOJO_AURA_CONTEXT_FACTORY_MOJO_H_
diff --git a/mojo/aura/window_tree_host_mojo.cc b/mojo/aura/window_tree_host_mojo.cc
new file mode 100644
index 0000000..9a51f2e
--- /dev/null
+++ b/mojo/aura/window_tree_host_mojo.cc
@@ -0,0 +1,161 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "mojo/aura/window_tree_host_mojo.h"
+
+#include <vector>
+
+#include "mojo/aura/window_tree_host_mojo_delegate.h"
+#include "ui/aura/env.h"
+#include "ui/aura/window.h"
+#include "ui/aura/window_event_dispatcher.h"
+#include "ui/events/event.h"
+#include "ui/events/event_constants.h"
+
+namespace mojo {
+namespace {
+
+const char kTreeHostsKey[] = "tree_hosts";
+
+typedef std::vector<WindowTreeHostMojo*> Managers;
+
+class TreeHosts : public base::SupportsUserData::Data {
+ public:
+ TreeHosts() {}
+ virtual ~TreeHosts() {}
+
+ static TreeHosts* Get() {
+ TreeHosts* hosts = static_cast<TreeHosts*>(
+ aura::Env::GetInstance()->GetUserData(kTreeHostsKey));
+ if (!hosts) {
+ hosts = new TreeHosts;
+ aura::Env::GetInstance()->SetUserData(kTreeHostsKey, hosts);
+ }
+ return hosts;
+ }
+
+ void Add(WindowTreeHostMojo* manager) {
+ managers_.push_back(manager);
+ }
+
+ void Remove(WindowTreeHostMojo* manager) {
+ Managers::iterator i = std::find(managers_.begin(), managers_.end(),
+ manager);
+ DCHECK(i != managers_.end());
+ managers_.erase(i);
+ }
+
+ const std::vector<WindowTreeHostMojo*> managers() const {
+ return managers_;
+ }
+
+ private:
+ Managers managers_;
+
+ DISALLOW_COPY_AND_ASSIGN(TreeHosts);
+};
+
+} // namespace
+
+////////////////////////////////////////////////////////////////////////////////
+// WindowTreeHostMojo, public:
+
+WindowTreeHostMojo::WindowTreeHostMojo(const gfx::Rect& bounds,
+ WindowTreeHostMojoDelegate* delegate)
+ : bounds_(bounds),
+ delegate_(delegate) {
+ CreateCompositor(GetAcceleratedWidget());
+
+ TreeHosts::Get()->Add(this);
+}
+
+WindowTreeHostMojo::~WindowTreeHostMojo() {
+ TreeHosts::Get()->Remove(this);
+ DestroyCompositor();
+ DestroyDispatcher();
+}
+
+// static
+WindowTreeHostMojo* WindowTreeHostMojo::ForCompositor(
+ ui::Compositor* compositor) {
+ const Managers& managers = TreeHosts::Get()->managers();
+ for (size_t i = 0; i < managers.size(); ++i) {
+ if (managers[i]->compositor() == compositor)
+ return managers[i];
+ }
+ return NULL;
+}
+
+void WindowTreeHostMojo::SetContents(const SkBitmap& contents) {
+ delegate_->CompositorContentsChanged(contents);
+}
+
+////////////////////////////////////////////////////////////////////////////////
+// WindowTreeHostMojo, aura::WindowTreeHost implementation:
+
+ui::EventSource* WindowTreeHostMojo::GetEventSource() {
+ return this;
+}
+
+gfx::AcceleratedWidget WindowTreeHostMojo::GetAcceleratedWidget() {
+ NOTIMPLEMENTED() << "GetAcceleratedWidget";
+ return gfx::kNullAcceleratedWidget;
+}
+
+void WindowTreeHostMojo::Show() {
+ window()->Show();
+}
+
+void WindowTreeHostMojo::Hide() {
+}
+
+gfx::Rect WindowTreeHostMojo::GetBounds() const {
+ return bounds_;
+}
+
+void WindowTreeHostMojo::SetBounds(const gfx::Rect& bounds) {
+}
+
+gfx::Point WindowTreeHostMojo::GetLocationOnNativeScreen() const {
+ return gfx::Point(0, 0);
+}
+
+void WindowTreeHostMojo::SetCapture() {
+ NOTIMPLEMENTED();
+}
+
+void WindowTreeHostMojo::ReleaseCapture() {
+ NOTIMPLEMENTED();
+}
+
+void WindowTreeHostMojo::PostNativeEvent(
+ const base::NativeEvent& native_event) {
+ NOTIMPLEMENTED();
+}
+
+void WindowTreeHostMojo::OnDeviceScaleFactorChanged(
+ float device_scale_factor) {
+ NOTIMPLEMENTED();
+}
+
+void WindowTreeHostMojo::SetCursorNative(gfx::NativeCursor cursor) {
+ NOTIMPLEMENTED();
+}
+
+void WindowTreeHostMojo::MoveCursorToNative(const gfx::Point& location) {
+ NOTIMPLEMENTED();
+}
+
+void WindowTreeHostMojo::OnCursorVisibilityChangedNative(bool show) {
+ NOTIMPLEMENTED();
+}
+
+////////////////////////////////////////////////////////////////////////////////
+// WindowTreeHostMojo, ui::EventSource implementation:
+
+ui::EventProcessor* WindowTreeHostMojo::GetEventProcessor() {
+ return dispatcher();
+}
+
+} // namespace mojo
diff --git a/mojo/examples/aura_demo/window_tree_host_view_manager.h b/mojo/aura/window_tree_host_mojo.h
index f22cdb6..fe5ca77 100644
--- a/mojo/examples/aura_demo/window_tree_host_view_manager.h
+++ b/mojo/aura/window_tree_host_mojo.h
@@ -9,17 +9,31 @@
#include "ui/events/event_source.h"
#include "ui/gfx/geometry/rect.h"
+class SkBitmap;
+
+namespace ui {
+class Compositor;
+}
+
namespace mojo {
-namespace examples {
-class WindowTreeHostViewManager : public aura::WindowTreeHost,
- public ui::EventSource {
+class WindowTreeHostMojoDelegate;
+
+class WindowTreeHostMojo : public aura::WindowTreeHost, public ui::EventSource {
public:
- explicit WindowTreeHostViewManager(const gfx::Rect& bounds);
- virtual ~WindowTreeHostViewManager();
+ WindowTreeHostMojo(const gfx::Rect& bounds,
+ WindowTreeHostMojoDelegate* delegate);
+ virtual ~WindowTreeHostMojo();
+
+ // Returns the WindowTreeHostMojo for the specified compositor.
+ static WindowTreeHostMojo* ForCompositor(ui::Compositor* compositor);
const gfx::Rect& bounds() const { return bounds_; }
+ // Sets the contents to show in this WindowTreeHost. This forwards to the
+ // delegate.
+ void SetContents(const SkBitmap& contents);
+
private:
// WindowTreeHost:
virtual ui::EventSource* GetEventSource() OVERRIDE;
@@ -42,10 +56,11 @@ class WindowTreeHostViewManager : public aura::WindowTreeHost,
gfx::Rect bounds_;
- DISALLOW_COPY_AND_ASSIGN(WindowTreeHostViewManager);
+ WindowTreeHostMojoDelegate* delegate_;
+
+ DISALLOW_COPY_AND_ASSIGN(WindowTreeHostMojo);
};
-} // namespace examples
} // namespace mojo
#endif // MOJO_EXAMPLES_AURA_DEMO_WINDOW_TREE_HOST_VIEW_MANAGER_H_
diff --git a/mojo/aura/window_tree_host_mojo_delegate.h b/mojo/aura/window_tree_host_mojo_delegate.h
new file mode 100644
index 0000000..9ab13b2
--- /dev/null
+++ b/mojo/aura/window_tree_host_mojo_delegate.h
@@ -0,0 +1,24 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef MOJO_EXAMPLES_AURA_DEMO_WINDOW_TREE_HOST_VIEW_MANAGER_DELEGATE_H_
+#define MOJO_EXAMPLES_AURA_DEMO_WINDOW_TREE_HOST_VIEW_MANAGER_DELEGATE_H_
+
+class SkBitmap;
+
+namespace mojo {
+
+class WindowTreeHostMojoDelegate {
+ public:
+ // Invoked when the contents of the composite associated with the
+ // WindowTreeHostMojo are updated.
+ virtual void CompositorContentsChanged(const SkBitmap& bitmap) = 0;
+
+ protected:
+ virtual ~WindowTreeHostMojoDelegate() {}
+};
+
+} // namespace mojo
+
+#endif // MOJO_EXAMPLES_AURA_DEMO_WINDOW_TREE_HOST_VIEW_MANAGER_DELEGATE_H_
diff --git a/mojo/examples/aura_demo/aura_demo.cc b/mojo/examples/aura_demo/aura_demo.cc
index 675704f..d40a1ce 100644
--- a/mojo/examples/aura_demo/aura_demo.cc
+++ b/mojo/examples/aura_demo/aura_demo.cc
@@ -6,9 +6,10 @@
#include <string>
#include "base/bind.h"
+#include "mojo/aura/context_factory_mojo.h"
#include "mojo/aura/screen_mojo.h"
-#include "mojo/examples/aura_demo/context_factory_view_manager.h"
-#include "mojo/examples/aura_demo/window_tree_host_view_manager.h"
+#include "mojo/aura/window_tree_host_mojo.h"
+#include "mojo/aura/window_tree_host_mojo_delegate.h"
#include "mojo/public/cpp/application/application.h"
#include "mojo/public/cpp/system/core.h"
#include "mojo/public/interfaces/service_provider/service_provider.mojom.h"
@@ -21,10 +22,39 @@
#include "ui/aura/window_delegate.h"
#include "ui/base/hit_test.h"
#include "ui/gfx/canvas.h"
+#include "ui/gfx/codec/png_codec.h"
namespace mojo {
namespace examples {
+void OnSetViewContentsDone(bool value) {
+ VLOG(1) << "OnSetViewContentsDone " << value;
+ DCHECK(value);
+}
+
+bool CreateMapAndDupSharedBuffer(size_t size,
+ void** memory,
+ ScopedSharedBufferHandle* handle,
+ ScopedSharedBufferHandle* duped) {
+ MojoResult result = CreateSharedBuffer(NULL, size, handle);
+ if (result != MOJO_RESULT_OK)
+ return false;
+ DCHECK(handle->is_valid());
+
+ result = DuplicateBuffer(handle->get(), NULL, duped);
+ if (result != MOJO_RESULT_OK)
+ return false;
+ DCHECK(duped->is_valid());
+
+ result = MapBuffer(
+ handle->get(), 0, size, memory, MOJO_MAP_BUFFER_FLAG_NONE);
+ if (result != MOJO_RESULT_OK)
+ return false;
+ DCHECK(*memory);
+
+ return true;
+}
+
// Trivial WindowDelegate implementation that draws a colored background.
class DemoWindowDelegate : public aura::WindowDelegate {
public:
@@ -156,22 +186,28 @@ class IViewManagerClientImpl
DISALLOW_COPY_AND_ASSIGN(IViewManagerClientImpl);
};
-class AuraDemo : public Application {
+class AuraDemo : public Application, public WindowTreeHostMojoDelegate {
public:
- AuraDemo() {
+ AuraDemo()
+ : view_manager_(NULL),
+ window1_(NULL),
+ window2_(NULL),
+ window21_(NULL),
+ view_id_(0) {
AddService<IViewManagerClientImpl>(this);
}
virtual ~AuraDemo() {}
- void SetRoot(view_manager::IViewManager* view_manager, uint32_t node_id) {
- context_factory_.reset(
- new ContextFactoryViewManager(view_manager, node_id));
+ void SetRoot(view_manager::IViewManager* view_manager, uint32_t view_id) {
aura::Env::CreateInstance(true);
+ view_manager_ = view_manager;
+ view_id_ = view_id;
+ context_factory_.reset(new ContextFactoryMojo);
aura::Env::GetInstance()->set_context_factory(context_factory_.get());
screen_.reset(ScreenMojo::Create());
gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_NATIVE, screen_.get());
- window_tree_host_.reset(new WindowTreeHostViewManager(gfx::Rect(800, 600)));
+ window_tree_host_.reset(new WindowTreeHostMojo(gfx::Rect(800, 600), this));
window_tree_host_->InitHost();
window_tree_client_.reset(
@@ -201,25 +237,52 @@ class AuraDemo : public Application {
window_tree_host_->Show();
}
+ // WindowTreeHostMojoDelegate:
+ virtual void CompositorContentsChanged(const SkBitmap& bitmap) OVERRIDE {
+ std::vector<unsigned char> data;
+ gfx::PNGCodec::EncodeBGRASkBitmap(bitmap, false, &data);
+
+ void* memory = NULL;
+ ScopedSharedBufferHandle duped;
+ bool result = CreateMapAndDupSharedBuffer(data.size(),
+ &memory,
+ &shared_state_handle_,
+ &duped);
+ if (!result)
+ return;
+
+ memcpy(memory, &data[0], data.size());
+
+ view_manager_->SetViewContents(
+ view_id_, duped.Pass(), static_cast<uint32_t>(data.size()),
+ base::Bind(&OnSetViewContentsDone));
+ }
+
virtual void Initialize() OVERRIDE {
}
- scoped_ptr<ContextFactoryViewManager> context_factory_;
+ scoped_ptr<DemoWindowTreeClient> window_tree_client_;
- scoped_ptr<ScreenMojo> screen_;
+ scoped_ptr<ui::ContextFactory> context_factory_;
- scoped_ptr<DemoWindowTreeClient> window_tree_client_;
+ scoped_ptr<ScreenMojo> screen_;
scoped_ptr<DemoWindowDelegate> delegate1_;
scoped_ptr<DemoWindowDelegate> delegate2_;
scoped_ptr<DemoWindowDelegate> delegate21_;
+ view_manager::IViewManager* view_manager_;
+
aura::Window* window1_;
aura::Window* window2_;
aura::Window* window21_;
+ uint32_t view_id_;
+
scoped_ptr<aura::WindowTreeHost> window_tree_host_;
+ ScopedSharedBufferHandle shared_state_handle_;
+
DISALLOW_COPY_AND_ASSIGN(AuraDemo);
};
diff --git a/mojo/examples/aura_demo/window_tree_host_view_manager.cc b/mojo/examples/aura_demo/window_tree_host_view_manager.cc
deleted file mode 100644
index 030e51a..0000000
--- a/mojo/examples/aura_demo/window_tree_host_view_manager.cc
+++ /dev/null
@@ -1,96 +0,0 @@
-// Copyright 2014 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "mojo/examples/aura_demo/window_tree_host_view_manager.h"
-
-#include "ui/aura/window.h"
-#include "ui/aura/window_event_dispatcher.h"
-#include "ui/events/event.h"
-#include "ui/events/event_constants.h"
-
-namespace mojo {
-namespace examples {
-
-////////////////////////////////////////////////////////////////////////////////
-// WindowTreeHostViewManager, public:
-
-WindowTreeHostViewManager::WindowTreeHostViewManager(const gfx::Rect& bounds)
- : bounds_(bounds) {
- CreateCompositor(GetAcceleratedWidget());
-}
-
-WindowTreeHostViewManager::~WindowTreeHostViewManager() {
- DestroyCompositor();
- DestroyDispatcher();
-}
-
-////////////////////////////////////////////////////////////////////////////////
-// WindowTreeHostViewManager, aura::WindowTreeHost implementation:
-
-ui::EventSource* WindowTreeHostViewManager::GetEventSource() {
- return this;
-}
-
-gfx::AcceleratedWidget WindowTreeHostViewManager::GetAcceleratedWidget() {
- NOTIMPLEMENTED() << "GetAcceleratedWidget";
- return gfx::kNullAcceleratedWidget;
-}
-
-void WindowTreeHostViewManager::Show() {
- window()->Show();
-}
-
-void WindowTreeHostViewManager::Hide() {
-}
-
-gfx::Rect WindowTreeHostViewManager::GetBounds() const {
- return bounds_;
-}
-
-void WindowTreeHostViewManager::SetBounds(const gfx::Rect& bounds) {
-}
-
-gfx::Point WindowTreeHostViewManager::GetLocationOnNativeScreen() const {
- return gfx::Point(0, 0);
-}
-
-void WindowTreeHostViewManager::SetCapture() {
- NOTIMPLEMENTED();
-}
-
-void WindowTreeHostViewManager::ReleaseCapture() {
- NOTIMPLEMENTED();
-}
-
-void WindowTreeHostViewManager::PostNativeEvent(
- const base::NativeEvent& native_event) {
- NOTIMPLEMENTED();
-}
-
-void WindowTreeHostViewManager::OnDeviceScaleFactorChanged(
- float device_scale_factor) {
- NOTIMPLEMENTED();
-}
-
-void WindowTreeHostViewManager::SetCursorNative(gfx::NativeCursor cursor) {
- NOTIMPLEMENTED();
-}
-
-void WindowTreeHostViewManager::MoveCursorToNative(const gfx::Point& location) {
- NOTIMPLEMENTED();
-}
-
-void WindowTreeHostViewManager::OnCursorVisibilityChangedNative(bool show) {
- NOTIMPLEMENTED();
-}
-
-////////////////////////////////////////////////////////////////////////////////
-// WindowTreeHostViewManager, ui::EventSource implementation:
-
-ui::EventProcessor* WindowTreeHostViewManager::GetEventProcessor() {
- return dispatcher();
-}
-
-} // namespace examples
-} // namespace mojo
diff --git a/mojo/mojo.gyp b/mojo/mojo.gyp
index 6fccf62..9786298 100644
--- a/mojo/mojo.gyp
+++ b/mojo/mojo.gyp
@@ -898,8 +898,13 @@
'mojo_native_viewport_bindings',
],
'sources': [
+ 'aura/context_factory_mojo.cc',
+ 'aura/context_factory_mojo.h',
'aura/screen_mojo.cc',
'aura/screen_mojo.h',
+ 'aura/window_tree_host_mojo.cc',
+ 'aura/window_tree_host_mojo.h',
+ 'aura/window_tree_host_mojo_delegate.h',
],
},
],
diff --git a/mojo/mojo_examples.gypi b/mojo/mojo_examples.gypi
index 58d18ee..d3365ef 100644
--- a/mojo/mojo_examples.gypi
+++ b/mojo/mojo_examples.gypi
@@ -212,10 +212,6 @@
'mojo_view_manager_bindings',
],
'sources': [
- 'examples/aura_demo/context_factory_view_manager.cc',
- 'examples/aura_demo/context_factory_view_manager.h',
- 'examples/aura_demo/window_tree_host_view_manager.cc',
- 'examples/aura_demo/window_tree_host_view_manager.h',
'examples/aura_demo/aura_demo.cc',
'public/cpp/application/lib/mojo_main_chromium.cc',
],
diff --git a/ui/aura/env.h b/ui/aura/env.h
index fc83ac8..a4f6766 100644
--- a/ui/aura/env.h
+++ b/ui/aura/env.h
@@ -7,6 +7,7 @@
#include "base/memory/scoped_ptr.h"
#include "base/observer_list.h"
+#include "base/supports_user_data.h"
#include "ui/aura/aura_export.h"
#include "ui/events/event_handler.h"
#include "ui/events/event_target.h"
@@ -28,7 +29,7 @@ class Window;
class WindowTreeHost;
// A singleton object that tracks general state within Aura.
-class AURA_EXPORT Env : public ui::EventTarget {
+class AURA_EXPORT Env : public ui::EventTarget, public base::SupportsUserData {
public:
// Creates the single Env instance (if it hasn't been created yet). If
// |create_event_source| is true a PlatformEventSource is created.