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

Side by Side Diff: mojo/examples/compositor_app/compositor_app.cc

Issue 131153007: Send size to NativeViewportClient::OnCreated instead of GLES2Client::DidCreateContext (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase, fix various issues Created 6 years, 10 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <stdio.h> 5 #include <stdio.h>
6 #include <string> 6 #include <string>
7 7
8 #include "base/message_loop/message_loop.h" 8 #include "base/message_loop/message_loop.h"
9 #include "mojo/examples/compositor_app/compositor_host.h" 9 #include "mojo/examples/compositor_app/compositor_host.h"
10 #include "mojo/examples/compositor_app/gles2_client_impl.h" 10 #include "mojo/examples/compositor_app/gles2_client_impl.h"
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 44
45 virtual void AcceptConnection(ScopedMessagePipeHandle handle) MOJO_OVERRIDE { 45 virtual void AcceptConnection(ScopedMessagePipeHandle handle) MOJO_OVERRIDE {
46 NOTREACHED() << "SampleApp can't be connected to."; 46 NOTREACHED() << "SampleApp can't be connected to.";
47 } 47 }
48 48
49 private: 49 private:
50 class NativeViewportClientImpl : public NativeViewportClient { 50 class NativeViewportClientImpl : public NativeViewportClient {
51 public: 51 public:
52 explicit NativeViewportClientImpl(ScopedMessagePipeHandle viewport_handle) 52 explicit NativeViewportClientImpl(ScopedMessagePipeHandle viewport_handle)
53 : viewport_(viewport_handle.Pass(), this) { 53 : viewport_(viewport_handle.Pass(), this) {
54 AllocationScope allocation;
54 viewport_->Create(gfx::Rect(10, 10, 800, 600)); 55 viewport_->Create(gfx::Rect(10, 10, 800, 600));
55 viewport_->Show(); 56 viewport_->Show();
56 ScopedMessagePipeHandle gles2_handle; 57 ScopedMessagePipeHandle gles2_handle;
57 ScopedMessagePipeHandle gles2_client_handle; 58 ScopedMessagePipeHandle gles2_client_handle;
58 CreateMessagePipe(&gles2_handle, &gles2_client_handle); 59 CreateMessagePipe(&gles2_handle, &gles2_client_handle);
59 60
60 gles2_client_.reset(new GLES2ClientImpl( 61 gles2_client_.reset(new GLES2ClientImpl(
61 gles2_handle.Pass(), 62 gles2_handle.Pass(),
62 base::Bind(&NativeViewportClientImpl::DidCreateContext, 63 base::Bind(&NativeViewportClientImpl::DidCreateContext,
63 base::Unretained(this)))); 64 base::Unretained(this))));
64 viewport_->CreateGLES2Context(gles2_client_handle.Pass()); 65 viewport_->CreateGLES2Context(gles2_client_handle.Pass());
65 host_.reset(new CompositorHost(gles2_client_.get())); 66 host_.reset(new CompositorHost(gles2_client_.get()));
66 } 67 }
67 68
68 void DidCreateContext(gfx::Size viewport_size) { 69 void DidCreateContext() {
69 host_->DidCreateContext(viewport_size); 70 host_->DidCreateContext();
70 } 71 }
71 72
72 virtual ~NativeViewportClientImpl() {} 73 virtual ~NativeViewportClientImpl() {}
73 74
74 virtual void OnCreated() MOJO_OVERRIDE { 75 virtual void OnCreated() MOJO_OVERRIDE {
75 } 76 }
76 77
77 virtual void OnDestroyed() MOJO_OVERRIDE { 78 virtual void OnDestroyed() MOJO_OVERRIDE {
78 base::MessageLoop::current()->Quit(); 79 base::MessageLoop::current()->Quit();
79 } 80 }
80 81
81 virtual void OnBoundsChanged(const Rect& bounds) MOJO_OVERRIDE { 82 virtual void OnBoundsChanged(const Rect& bounds) MOJO_OVERRIDE {
83 host_->SetSize(bounds.size());
82 } 84 }
83 85
84 virtual void OnEvent(const Event& event) MOJO_OVERRIDE { 86 virtual void OnEvent(const Event& event) MOJO_OVERRIDE {
85 if (!event.location().is_null()) { 87 if (!event.location().is_null()) {
86 viewport_->AckEvent(event); 88 viewport_->AckEvent(event);
87 } 89 }
88 } 90 }
89 91
90 private: 92 private:
91 scoped_ptr<GLES2ClientImpl> gles2_client_; 93 scoped_ptr<GLES2ClientImpl> gles2_client_;
(...skipping 11 matching lines...) Expand all
103 MojoHandle shell_handle) { 105 MojoHandle shell_handle) {
104 base::MessageLoop loop; 106 base::MessageLoop loop;
105 mojo::GLES2Initializer gles2; 107 mojo::GLES2Initializer gles2;
106 108
107 mojo::examples::SampleApp app( 109 mojo::examples::SampleApp app(
108 mojo::MakeScopedHandle(mojo::MessagePipeHandle(shell_handle)).Pass()); 110 mojo::MakeScopedHandle(mojo::MessagePipeHandle(shell_handle)).Pass());
109 loop.Run(); 111 loop.Run();
110 112
111 return MOJO_RESULT_OK; 113 return MOJO_RESULT_OK;
112 } 114 }
OLDNEW
« no previous file with comments | « mojo/examples/aura_demo/root_window_host_mojo.cc ('k') | mojo/examples/compositor_app/compositor_host.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698