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

Unified Diff: examples/sky_compositor_app/sky_compositor_app.cc

Issue 1239963003: Remove //services/sky (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « examples/sky_compositor_app/BUILD.gn ('k') | services/sky/OWNERS » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: examples/sky_compositor_app/sky_compositor_app.cc
diff --git a/examples/sky_compositor_app/sky_compositor_app.cc b/examples/sky_compositor_app/sky_compositor_app.cc
deleted file mode 100644
index cbda07be322e1149005d91af74cb9cb15f26c801..0000000000000000000000000000000000000000
--- a/examples/sky_compositor_app/sky_compositor_app.cc
+++ /dev/null
@@ -1,115 +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 "base/macros.h"
-#include "mojo/application/application_runner_chromium.h"
-#include "mojo/public/c/system/main.h"
-#include "mojo/public/cpp/application/application_connection.h"
-#include "mojo/public/cpp/application/application_delegate.h"
-#include "mojo/public/cpp/application/application_impl.h"
-#include "mojo/services/view_manager/public/cpp/view.h"
-#include "mojo/services/view_manager/public/cpp/view_manager.h"
-#include "mojo/services/view_manager/public/cpp/view_manager_client_factory.h"
-#include "mojo/services/view_manager/public/cpp/view_manager_delegate.h"
-#include "services/sky/compositor/layer.h"
-#include "services/sky/compositor/layer_host.h"
-#include "services/sky/compositor/rasterizer_ganesh.h"
-#include "third_party/skia/include/core/SkCanvas.h"
-
-namespace examples {
-namespace {
-
-gfx::Size ToSize(const mojo::Rect& rect) {
- return gfx::Size(rect.width, rect.height);
-}
-
-int RadiusAt(base::TimeDelta delta) {
- return 50 + (delta.InMilliseconds() % 6000) * 100 / 6000;
-}
-}
-
-class SkyCompositorApp : public mojo::ApplicationDelegate,
- public mojo::ViewManagerDelegate,
- public sky::LayerClient,
- public sky::LayerHostClient {
- public:
- SkyCompositorApp() : shell_(nullptr), view_(nullptr) {}
- ~SkyCompositorApp() override {}
-
- void Initialize(mojo::ApplicationImpl* app) override {
- shell_ = app->shell();
- view_manager_client_factory_.reset(
- new mojo::ViewManagerClientFactory(app->shell(), this));
- }
-
- bool ConfigureIncomingConnection(
- mojo::ApplicationConnection* connection) override {
- connection->AddService(view_manager_client_factory_.get());
- return true;
- }
-
- void OnEmbed(mojo::View* root,
- mojo::InterfaceRequest<mojo::ServiceProvider> services,
- mojo::ServiceProviderPtr exposed_services) override {
- view_ = root;
- base_time_ = base::TimeTicks::Now();
-
- layer_host_.reset(new sky::LayerHost(this));
- root_layer_ = make_scoped_refptr(new sky::Layer(this));
- root_layer_->set_rasterizer(
- make_scoped_ptr(new sky::RasterizerGanesh(layer_host_.get())));
- layer_host_->SetRootLayer(root_layer_);
- layer_host_->SetNeedsAnimate();
- }
-
- void OnViewManagerDisconnected(mojo::ViewManager* view_manager) override {
- mojo::ApplicationImpl::Terminate();
- }
-
- private:
- // sky::LayerHostClient
- mojo::Shell* GetShell() override { return shell_; }
-
- void BeginFrame(base::TimeTicks frame_time) override {
- root_layer_->SetSize(ToSize(view_->bounds()));
- layer_host_->SetNeedsAnimate();
- }
-
- void OnSurfaceIdAvailable(mojo::SurfaceIdPtr surface_id) override {
- view_->SetSurfaceId(surface_id.Pass());
- }
-
- // sky::LayerClient
- void PaintContents(SkCanvas* canvas, const gfx::Rect& clip) override {
- base::TimeTicks frame_time = base::TimeTicks::Now();
- printf("Frame delta: %f\n",
- (frame_time - last_frame_time_).InMillisecondsF());
- last_frame_time_ = frame_time;
-
- canvas->clear(SK_ColorGREEN);
- SkPaint paint;
- paint.setColor(SK_ColorBLUE);
- paint.setFlags(SkPaint::kAntiAlias_Flag);
- canvas->drawCircle(50, 100, RadiusAt(frame_time - base_time_), paint);
- }
-
- mojo::Shell* shell_;
- scoped_ptr<mojo::ViewManagerClientFactory> view_manager_client_factory_;
- mojo::View* view_;
-
- scoped_ptr<sky::LayerHost> layer_host_;
- scoped_refptr<sky::Layer> root_layer_;
-
- base::TimeTicks base_time_;
- base::TimeTicks last_frame_time_;
-
- DISALLOW_COPY_AND_ASSIGN(SkyCompositorApp);
-};
-
-} // namespace examples
-
-MojoResult MojoMain(MojoHandle handle) {
- mojo::ApplicationRunnerChromium runner(new examples::SkyCompositorApp);
- return runner.Run(handle);
-}
« no previous file with comments | « examples/sky_compositor_app/BUILD.gn ('k') | services/sky/OWNERS » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698