| OLD | NEW |
| 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/bind.h" | 8 #include "base/bind.h" |
| 9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "examples/spinning_cube/gles2_client_impl.h" | 10 #include "examples/spinning_cube/gles2_client_impl.h" |
| (...skipping 23 matching lines...) Expand all Loading... |
| 34 | 34 |
| 35 void Initialize(mojo::ApplicationImpl* app) override { | 35 void Initialize(mojo::ApplicationImpl* app) override { |
| 36 app->ConnectToService("mojo:native_viewport_service", &viewport_); | 36 app->ConnectToService("mojo:native_viewport_service", &viewport_); |
| 37 viewport_.set_error_handler(this); | 37 viewport_.set_error_handler(this); |
| 38 | 38 |
| 39 SetEventDispatcher(); | 39 SetEventDispatcher(); |
| 40 | 40 |
| 41 mojo::SizePtr size(mojo::Size::New()); | 41 mojo::SizePtr size(mojo::Size::New()); |
| 42 size->width = 800; | 42 size->width = 800; |
| 43 size->height = 600; | 43 size->height = 600; |
| 44 |
| 45 auto requested_configuration = mojo::SurfaceConfiguration::New(); |
| 46 requested_configuration->depth_bits = 16; |
| 47 |
| 44 viewport_->Create( | 48 viewport_->Create( |
| 45 size.Clone(), | 49 size.Clone(), requested_configuration.Pass(), |
| 46 base::Bind(&SpinningCubeApp::OnMetricsChanged, base::Unretained(this))); | 50 base::Bind(&SpinningCubeApp::OnMetricsChanged, base::Unretained(this))); |
| 47 viewport_->Show(); | 51 viewport_->Show(); |
| 48 mojo::ContextProviderPtr onscreen_context_provider; | 52 mojo::ContextProviderPtr onscreen_context_provider; |
| 49 viewport_->GetContextProvider(GetProxy(&onscreen_context_provider)); | 53 viewport_->GetContextProvider(GetProxy(&onscreen_context_provider)); |
| 50 | 54 |
| 51 gles2_client_.reset(new GLES2ClientImpl(onscreen_context_provider.Pass())); | 55 gles2_client_.reset(new GLES2ClientImpl(onscreen_context_provider.Pass())); |
| 52 gles2_client_->SetSize(*size); | 56 gles2_client_->SetSize(*size); |
| 53 } | 57 } |
| 54 | 58 |
| 55 void OnMetricsChanged(mojo::ViewportMetricsPtr metrics) { | 59 void OnMetricsChanged(mojo::ViewportMetricsPtr metrics) { |
| (...skipping 28 matching lines...) Expand all Loading... |
| 84 | 88 |
| 85 DISALLOW_COPY_AND_ASSIGN(SpinningCubeApp); | 89 DISALLOW_COPY_AND_ASSIGN(SpinningCubeApp); |
| 86 }; | 90 }; |
| 87 | 91 |
| 88 } // namespace examples | 92 } // namespace examples |
| 89 | 93 |
| 90 MojoResult MojoMain(MojoHandle application_request) { | 94 MojoResult MojoMain(MojoHandle application_request) { |
| 91 mojo::ApplicationRunner runner(new examples::SpinningCubeApp); | 95 mojo::ApplicationRunner runner(new examples::SpinningCubeApp); |
| 92 return runner.Run(application_request); | 96 return runner.Run(application_request); |
| 93 } | 97 } |
| OLD | NEW |