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

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

Issue 393093003: Mojo: Move sample_app out from namespace mojo (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Landing Created 6 years, 5 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
« no previous file with comments | « mojo/examples/sample_app/gles2_client_impl.cc ('k') | mojo/examples/sample_app/spinning_cube.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "mojo/examples/sample_app/gles2_client_impl.h" 8 #include "mojo/examples/sample_app/gles2_client_impl.h"
9 #include "mojo/public/cpp/application/application_connection.h" 9 #include "mojo/public/cpp/application/application_connection.h"
10 #include "mojo/public/cpp/application/application_delegate.h" 10 #include "mojo/public/cpp/application/application_delegate.h"
11 #include "mojo/public/cpp/application/application_impl.h" 11 #include "mojo/public/cpp/application/application_impl.h"
12 #include "mojo/public/cpp/gles2/gles2.h" 12 #include "mojo/public/cpp/gles2/gles2.h"
13 #include "mojo/public/cpp/system/core.h" 13 #include "mojo/public/cpp/system/core.h"
14 #include "mojo/public/cpp/system/macros.h" 14 #include "mojo/public/cpp/system/macros.h"
15 #include "mojo/public/cpp/utility/run_loop.h" 15 #include "mojo/public/cpp/utility/run_loop.h"
16 #include "mojo/public/interfaces/service_provider/service_provider.mojom.h" 16 #include "mojo/public/interfaces/service_provider/service_provider.mojom.h"
17 #include "mojo/services/public/interfaces/native_viewport/native_viewport.mojom. h" 17 #include "mojo/services/public/interfaces/native_viewport/native_viewport.mojom. h"
18 18
19 namespace mojo {
20 namespace examples { 19 namespace examples {
21 20
22 class SampleApp : public ApplicationDelegate, public NativeViewportClient { 21 class SampleApp : public mojo::ApplicationDelegate,
22 public mojo::NativeViewportClient {
23 public: 23 public:
24 SampleApp() {} 24 SampleApp() {}
25 25
26 virtual ~SampleApp() { 26 virtual ~SampleApp() {
27 // TODO(darin): Fix shutdown so we don't need to leak this. 27 // TODO(darin): Fix shutdown so we don't need to leak this.
28 MOJO_ALLOW_UNUSED GLES2ClientImpl* leaked = gles2_client_.release(); 28 MOJO_ALLOW_UNUSED GLES2ClientImpl* leaked = gles2_client_.release();
29 } 29 }
30 30
31 virtual void Initialize(ApplicationImpl* app) MOJO_OVERRIDE { 31 virtual void Initialize(mojo::ApplicationImpl* app) MOJO_OVERRIDE {
32 app->ConnectToService("mojo:mojo_native_viewport_service", &viewport_); 32 app->ConnectToService("mojo:mojo_native_viewport_service", &viewport_);
33 viewport_.set_client(this); 33 viewport_.set_client(this);
34 34
35 RectPtr rect(Rect::New()); 35 mojo::RectPtr rect(mojo::Rect::New());
36 rect->x = 10; 36 rect->x = 10;
37 rect->y = 10; 37 rect->y = 10;
38 rect->width = 800; 38 rect->width = 800;
39 rect->height = 600; 39 rect->height = 600;
40 viewport_->Create(rect.Pass()); 40 viewport_->Create(rect.Pass());
41 viewport_->Show(); 41 viewport_->Show();
42 42
43 CommandBufferPtr command_buffer; 43 mojo::CommandBufferPtr command_buffer;
44 viewport_->CreateGLES2Context(Get(&command_buffer)); 44 viewport_->CreateGLES2Context(Get(&command_buffer));
45 gles2_client_.reset(new GLES2ClientImpl(command_buffer.Pass())); 45 gles2_client_.reset(new GLES2ClientImpl(command_buffer.Pass()));
46 } 46 }
47 47
48 virtual void OnCreated() MOJO_OVERRIDE { 48 virtual void OnCreated() MOJO_OVERRIDE {
49 } 49 }
50 50
51 virtual void OnDestroyed( 51 virtual void OnDestroyed(
52 const mojo::Callback<void()>& callback) MOJO_OVERRIDE { 52 const mojo::Callback<void()>& callback) MOJO_OVERRIDE {
53 RunLoop::current()->Quit(); 53 mojo::RunLoop::current()->Quit();
54 callback.Run(); 54 callback.Run();
55 } 55 }
56 56
57 virtual void OnBoundsChanged(RectPtr bounds) MOJO_OVERRIDE { 57 virtual void OnBoundsChanged(mojo::RectPtr bounds) MOJO_OVERRIDE {
58 assert(bounds); 58 assert(bounds);
59 SizePtr size(Size::New()); 59 mojo::SizePtr size(mojo::Size::New());
60 size->width = bounds->width; 60 size->width = bounds->width;
61 size->height = bounds->height; 61 size->height = bounds->height;
62 gles2_client_->SetSize(*size); 62 gles2_client_->SetSize(*size);
63 } 63 }
64 64
65 virtual void OnEvent(EventPtr event, 65 virtual void OnEvent(mojo::EventPtr event,
66 const Callback<void()>& callback) MOJO_OVERRIDE { 66 const mojo::Callback<void()>& callback) MOJO_OVERRIDE {
67 assert(event); 67 assert(event);
68 if (event->location) 68 if (event->location)
69 gles2_client_->HandleInputEvent(*event); 69 gles2_client_->HandleInputEvent(*event);
70 callback.Run(); 70 callback.Run();
71 } 71 }
72 72
73 private: 73 private:
74 mojo::GLES2Initializer gles2; 74 mojo::GLES2Initializer gles2;
75 scoped_ptr<GLES2ClientImpl> gles2_client_; 75 scoped_ptr<GLES2ClientImpl> gles2_client_;
76 NativeViewportPtr viewport_; 76 mojo::NativeViewportPtr viewport_;
77 77
78 DISALLOW_COPY_AND_ASSIGN(SampleApp); 78 DISALLOW_COPY_AND_ASSIGN(SampleApp);
79 }; 79 };
80 80
81 } // namespace examples 81 } // namespace examples
82 82
83 namespace mojo {
84
83 // static 85 // static
84 ApplicationDelegate* ApplicationDelegate::Create() { 86 ApplicationDelegate* ApplicationDelegate::Create() {
85 return new examples::SampleApp(); 87 return new examples::SampleApp();
86 } 88 }
87 89
88 } // namespace mojo 90 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/examples/sample_app/gles2_client_impl.cc ('k') | mojo/examples/sample_app/spinning_cube.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698