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

Unified Diff: mojo/examples/compositor_app/compositor_app.cc

Issue 607233002: Nukes NativeViewportClient::OnCreated (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix build Created 6 years, 3 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 | « no previous file | mojo/examples/pepper_container_app/pepper_container_app.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/examples/compositor_app/compositor_app.cc
diff --git a/mojo/examples/compositor_app/compositor_app.cc b/mojo/examples/compositor_app/compositor_app.cc
index 0a7607bd2d62d521d91e4335d83067afd487dd57..2bbd97cd09813f56bbb5d235949dcc11778cc0cc 100644
--- a/mojo/examples/compositor_app/compositor_app.cc
+++ b/mojo/examples/compositor_app/compositor_app.cc
@@ -5,7 +5,9 @@
#include <stdio.h>
#include <string>
+#include "base/bind.h"
#include "base/macros.h"
+#include "base/memory/weak_ptr.h"
#include "mojo/application/application_runner_chromium.h"
#include "mojo/examples/compositor_app/compositor_host.h"
#include "mojo/public/c/system/main.h"
@@ -22,32 +24,26 @@ namespace examples {
class SampleApp : public ApplicationDelegate, public NativeViewportClient {
public:
- SampleApp() {}
+ SampleApp() : weak_factory_(this) {}
virtual ~SampleApp() {}
virtual void Initialize(ApplicationImpl* app) OVERRIDE {
app->ConnectToService("mojo:mojo_native_viewport_service", &viewport_);
viewport_.set_client(this);
- viewport_->Create(Size::From(gfx::Size(800, 600)));
+ viewport_->Create(Size::From(gfx::Size(800, 600)),
+ base::Bind(&SampleApp::OnCreatedNativeViewport,
+ weak_factory_.GetWeakPtr()));
viewport_->Show();
// TODO(jamesr): Should be mojo:mojo_gpu_service
app->ConnectToService("mojo:mojo_native_viewport_service", &gpu_service_);
}
- virtual void OnCreated(uint64_t native_viewport_id) OVERRIDE {
- CommandBufferPtr cb;
- // TODO(jamesr): Output to a surface instead.
- gpu_service_->CreateOnscreenGLES2Context(
- native_viewport_id, Size::From(gfx::Size(800, 600)), Get(&cb));
- host_.reset(new CompositorHost(cb.PassMessagePipe()));
- }
-
virtual void OnDestroyed() OVERRIDE { base::MessageLoop::current()->Quit(); }
- virtual void OnBoundsChanged(SizePtr bounds) OVERRIDE {
+ virtual void OnSizeChanged(SizePtr size) OVERRIDE {
if (host_)
- host_->SetSize(bounds.To<gfx::Size>());
+ host_->SetSize(size.To<gfx::Size>());
}
virtual void OnEvent(EventPtr event,
@@ -56,9 +52,20 @@ class SampleApp : public ApplicationDelegate, public NativeViewportClient {
}
private:
+ void OnCreatedNativeViewport(uint64_t native_viewport_id) {
+ CommandBufferPtr cb;
+ // TODO(jamesr): Output to a surface instead.
+ gpu_service_->CreateOnscreenGLES2Context(
+ native_viewport_id, Size::From(gfx::Size(800, 600)), Get(&cb));
+ host_.reset(new CompositorHost(cb.PassMessagePipe()));
+ }
+
+
NativeViewportPtr viewport_;
GpuPtr gpu_service_;
scoped_ptr<CompositorHost> host_;
+ base::WeakPtrFactory<SampleApp> weak_factory_;
+
DISALLOW_COPY_AND_ASSIGN(SampleApp);
};
« no previous file with comments | « no previous file | mojo/examples/pepper_container_app/pepper_container_app.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698