[examples] Remove Skia-based examples
This CL removes a number of Skia-based examples to reduce our
dependencies on Skia.
Tests: Just removing code.
Change-Id: I9a2f244079d21ed12e635cec95e966adc3cbdc7b
diff --git a/BUILD.gn b/BUILD.gn
index 51116b3..d3afc27 100644
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -17,7 +17,6 @@
"//topaz/app/spinning_cube",
"//topaz/bin/fidlgen_dart:install(//build/toolchain:host_x64)",
"//topaz/bin/system_dashboard",
- "//topaz/bin/ui/skottie_viewer:package",
"//topaz/bin/userpicker_base_shell",
"//topaz/examples/fidl/compiler",
"//topaz/examples/fidl/echo_client_async_dart",
@@ -27,11 +26,7 @@
"//topaz/examples/mediaplayer/mediaplayer_flutter",
"//topaz/examples/mine_digger",
"//topaz/examples/ui/button_flutter",
- "//topaz/examples/ui/intl_client_demo",
- "//topaz/examples/ui/jank:package",
"//topaz/examples/ui/localized_mod",
- "//topaz/examples/ui/noodles",
- "//topaz/examples/ui/paint:package",
"//topaz/examples/ui/simple_flutter",
"//topaz/lib/story_shell/examples/example_manual_relationships",
"//topaz/public/dart/fuchsia_inspect/examples/inspect_mod",
diff --git a/bin/ui/skottie_viewer/BUILD.gn b/bin/ui/skottie_viewer/BUILD.gn
deleted file mode 100644
index 0ac5871..0000000
--- a/bin/ui/skottie_viewer/BUILD.gn
+++ /dev/null
@@ -1,64 +0,0 @@
-# Copyright 2018 The Fuchsia Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-import("//build/fidl/fidl.gni")
-import("//build/package.gni")
-
-fidl("skottie_loader") {
- # TODO(fxb/35879): Remove lint exclusions by fixing known FIDL lint violations in this target
- excluded_checks = [ "string-bounds-not-specified" ]
-
- name = "fuchsia.skia.skottie"
-
- sources = [
- "skottie_loader.fidl",
- ]
-
- public_deps = [
- "//zircon/system/fidl/fuchsia-mem",
- ]
-}
-
-executable("skottie_viewer") {
- output_name = "skottie_viewer"
-
- sources = [
- "main.cc",
- "view.cc",
- "view.h",
- ]
-
- deps = [
- ":skottie_loader",
- "//garnet/public/lib/fsl",
- "//garnet/public/lib/ui/base_view/cpp",
- "//sdk/fidl/fuchsia.images",
- "//sdk/lib/fidl/cpp",
- "//sdk/lib/sys/cpp",
- "//sdk/lib/ui/scenic/cpp",
- "//third_party/skia/modules/skottie",
- "//topaz/examples/ui/lib:skia_view",
- "//zircon/public/lib/async-loop-cpp",
- "//zircon/public/lib/async-loop-default",
- "//zircon/public/lib/trace-provider-with-fdio",
- "//zircon/system/fidl/fuchsia-mem",
- ]
-}
-
-package("package") {
- package_name = "skottie_viewer"
-
- deps = [
- ":skottie_viewer",
- ]
-
- binary = "skottie_viewer"
-
- meta = [
- {
- path = rebase_path("meta/skottie_viewer.cmx")
- dest = "skottie_viewer.cmx"
- },
- ]
-}
diff --git a/bin/ui/skottie_viewer/README.md b/bin/ui/skottie_viewer/README.md
deleted file mode 100644
index a29e7ca..0000000
--- a/bin/ui/skottie_viewer/README.md
+++ /dev/null
@@ -1,10 +0,0 @@
-# Skottie Animations Viewer Component
-
-This directory contains skottie_viewer, a component that provides a view to
-display animations loaded from Lottie JSON..
-
-## USAGE
-
-This program should not be run directly.
-
-Use launch instead.
diff --git a/bin/ui/skottie_viewer/main.cc b/bin/ui/skottie_viewer/main.cc
deleted file mode 100644
index 543a250..0000000
--- a/bin/ui/skottie_viewer/main.cc
+++ /dev/null
@@ -1,30 +0,0 @@
-// Copyright 2018 The Fuchsia 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 <lib/async-loop/cpp/loop.h>
-#include <lib/async-loop/default.h>
-#include <lib/ui/base_view/cpp/view_provider_component.h>
-#include <trace-provider/provider.h>
-
-#include "src/lib/fxl/command_line.h"
-#include "src/lib/fxl/log_settings_command_line.h"
-#include "topaz/bin/ui/skottie_viewer/view.h"
-
-int main(int argc, const char** argv) {
- auto command_line = fxl::CommandLineFromArgcArgv(argc, argv);
- if (!fxl::SetLogSettingsFromCommandLine(command_line))
- return 1;
-
- async::Loop loop(&kAsyncLoopConfigAttachToCurrentThread);
- trace::TraceProviderWithFdio trace_provider(loop.dispatcher());
-
- scenic::ViewProviderComponent component(
- [](scenic::ViewContext view_context) {
- return std::make_unique<skottie::View>(std::move(view_context));
- },
- &loop);
-
- loop.Run();
- return 0;
-}
diff --git a/bin/ui/skottie_viewer/meta/skottie_viewer.cmx b/bin/ui/skottie_viewer/meta/skottie_viewer.cmx
deleted file mode 100644
index 65ac6fb..0000000
--- a/bin/ui/skottie_viewer/meta/skottie_viewer.cmx
+++ /dev/null
@@ -1,14 +0,0 @@
-{
- "program": {
- "binary": "bin/app"
- },
- "sandbox": {
- "services": [
- "fuchsia.sys.Environment",
- "fuchsia.sys.Launcher",
- "fuchsia.tracing.provider.Registry",
- "fuchsia.ui.policy.Presenter",
- "fuchsia.ui.scenic.Scenic"
- ]
- }
-}
diff --git a/bin/ui/skottie_viewer/skottie_loader.fidl b/bin/ui/skottie_viewer/skottie_loader.fidl
deleted file mode 100644
index 2dda694..0000000
--- a/bin/ui/skottie_viewer/skottie_loader.fidl
+++ /dev/null
@@ -1,42 +0,0 @@
-// Copyright 2018 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-library fuchsia.skia.skottie;
-
-using fuchsia.mem;
-
-// Provides load status and animation duration on successful load.
-struct Status {
- bool error;
- string? message;
- uint32 duration;
-};
-
-// Defines additional options used during `Load`.
-struct Options {
- uint32 background_color;
- bool loop;
- bool autoplay;
-};
-
-// Defines the player interface to control the animation. It is returned upon
-// successful load of the animation.
-protocol Player {
- // Seek to position `t` where 0 <= t <= 1.
- Seek(float32 t);
- // Play and stop at `t` = 1 if `loop` = false.
- Play();
- // Pause player.
- Pause();
-};
-
-[Discoverable]
-// Skottie loader exported by `ViewProvider` to load skottie JSON animations
-// into views created from it.
-protocol Loader {
- // Load the snapshot from the Vmo buffer payload. Returns a callback with
- // `Player` controller and load status `Status`. `player` is null if loading
- // failed.
- Load(fuchsia.mem.Buffer payload, Options options) -> (Status status, Player? player);
-};
diff --git a/bin/ui/skottie_viewer/view.cc b/bin/ui/skottie_viewer/view.cc
deleted file mode 100644
index 314a139..0000000
--- a/bin/ui/skottie_viewer/view.cc
+++ /dev/null
@@ -1,125 +0,0 @@
-// Copyright 2018 The Fuchsia 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 "topaz/bin/ui/skottie_viewer/view.h"
-
-#include <lib/fsl/vmo/vector.h>
-
-#include "src/lib/fxl/logging.h"
-#include "third_party/skia/include/core/SkColor.h"
-
-namespace skottie {
-
-constexpr float kSecondsPerNanosecond = .000'000'001f;
-
-View::View(scenic::ViewContext view_context)
- : SkiaView(std::move(view_context), "Skottie View"), player_binding_(this) {
- outgoing_services().AddService(loader_bindings_.GetHandler(this));
-}
-
-void View::Load(fuchsia::mem::Buffer payload,
- fuchsia::skia::skottie::Options options,
- LoadCallback callback) {
- std::vector<uint8_t> data;
- if (!fsl::VectorFromVmo(payload, &data)) {
- FXL_LOG(ERROR) << "VectorFromVmo failed";
- return;
- }
-
- start_time_ = 0L;
- background_color_ = options.background_color;
- loop_ = options.loop;
- playing_ = options.autoplay;
-
- class Logger final : public skottie::Logger {
- public:
- // |skottie::Logger|
- void log(skottie::Logger::Level level, const char message[],
- const char json[]) override {
- error_ = error_ || level == skottie::Logger::Level::kError;
- buffer_ << message << (json ? json : "") << std::endl;
- }
-
- bool has_errors() { return error_; }
- std::string log() { return buffer_.str(); }
-
- private:
- bool error_;
- std::ostringstream buffer_;
- };
-
- auto logger = sk_make_sp<Logger>();
- skottie::Animation::Builder builder;
- animation_ = builder.setLogger(logger).make(
- reinterpret_cast<const char*>(data.data()), data.size());
-
- fuchsia::skia::skottie::Status status;
- status.error = logger->has_errors();
- status.message = logger->log();
-
- fidl::InterfaceHandle<fuchsia::skia::skottie::Player> player;
- if (animation_) {
- duration_ = animation_->duration();
- status.duration = animation_->duration();
- player_binding_.Bind(player.NewRequest());
- }
-
- callback(std::move(status), std::move(player));
-}
-
-void View::Seek(float t) {
- position_ = t;
- start_time_ = 0L;
- InvalidateScene();
-}
-
-void View::Play() {
- playing_ = true;
- InvalidateScene();
-}
-
-void View::Pause() {
- playing_ = false;
- InvalidateScene();
-}
-
-void View::OnSceneInvalidated(
- fuchsia::images::PresentationInfo presentation_info) {
- if (animation_ && playing_) {
- SkCanvas* canvas = AcquireCanvas();
- if (!canvas)
- return;
-
- uint64_t presentation_time = presentation_info.presentation_time;
- if (!start_time_) {
- start_time_ = presentation_time;
- }
-
- float d = animation_->duration();
- float t = (presentation_time - start_time_) * kSecondsPerNanosecond +
- position_ * animation_->duration();
- animation_->seek(std::fmod(t, d) / d);
-
- canvas->clear(background_color_);
-
- Draw(canvas);
-
- ReleaseAndSwapCanvas();
-
- // Animate.
- InvalidateScene();
- }
-}
-
-void View::Draw(SkCanvas* canvas) {
- FXL_DCHECK(animation_);
-
- const auto rect =
- SkRect::MakeSize(SkSize::Make(logical_size().x, logical_size().y));
-
- SkAutoCanvasRestore acr(canvas, true);
- animation_->render(canvas, &rect);
-}
-
-} // namespace skottie
diff --git a/bin/ui/skottie_viewer/view.h b/bin/ui/skottie_viewer/view.h
deleted file mode 100644
index 13b8624..0000000
--- a/bin/ui/skottie_viewer/view.h
+++ /dev/null
@@ -1,66 +0,0 @@
-// Copyright 2017 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef TOPAZ_BIN_UI_SKOTTIE_VIEWER_VIEW_H_
-#define TOPAZ_BIN_UI_SKOTTIE_VIEWER_VIEW_H_
-
-#include <fuchsia/images/cpp/fidl.h>
-#include <fuchsia/mem/cpp/fidl.h>
-#include <fuchsia/skia/skottie/cpp/fidl.h>
-#include <lib/fidl/cpp/binding_set.h>
-#include <lib/sys/cpp/component_context.h>
-
-#include "examples/ui/lib/skia_view.h"
-#include "src/lib/fxl/macros.h"
-//#if defined(SK_ENABLE_SKOTTIE)
-#include "third_party/skia/modules/skottie/include/Skottie.h"
-//#endif
-namespace skottie {
-
-// A view that plays Skottie animations.
-class View final : public scenic::SkiaView,
- public fuchsia::skia::skottie::Loader,
- public fuchsia::skia::skottie::Player {
- public:
- View(scenic::ViewContext view_context);
- ~View() override = default;
-
- // |scenic::BaseView|
- void OnSceneInvalidated(
- fuchsia::images::PresentationInfo presentation_info) override;
-
- // |fuchsia::skia::skottie::Loader|
- virtual void Load(fuchsia::mem::Buffer payload,
- fuchsia::skia::skottie::Options options,
- LoadCallback callback) override;
-
- // |fuchsia::skia::skottie::Player|
- virtual void Seek(float t) override;
- virtual void Play() override;
- virtual void Pause() override;
-
- private:
- fidl::BindingSet<fuchsia::skia::skottie::Loader> loader_bindings_;
- fidl::Binding<fuchsia::skia::skottie::Player> player_binding_;
- fuchsia::skia::skottie::PlayerPtr player_;
- component::ServiceNamespace service_namespace_;
-
- // Render the animation to the canvas.
- void Draw(SkCanvas* canvas);
-
- uint64_t start_time_ = 0u;
- float position_ = 0.f;
- float duration_ = 0.f;
- SkColor background_color_ = SK_ColorBLACK;
- bool playing_ = false;
- bool loop_ = true;
-
- sk_sp<skottie::Animation> animation_;
-
- FXL_DISALLOW_COPY_AND_ASSIGN(View);
-};
-
-} // namespace skottie
-
-#endif // TOPAZ_BIN_UI_SKOTTIE_VIEWER_VIEW_H_
diff --git a/examples/ui/intl_client_demo/BUILD.gn b/examples/ui/intl_client_demo/BUILD.gn
deleted file mode 100644
index fb7f2db..0000000
--- a/examples/ui/intl_client_demo/BUILD.gn
+++ /dev/null
@@ -1,51 +0,0 @@
-# Copyright 2019 The Fuchsia Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-import("//build/package.gni")
-
-executable("bin") {
- output_name = "intl_client_demo"
-
- sources = [
- "intl_client_demo_view.cc",
- "intl_client_demo_view.h",
- "main.cc",
- ]
-
- deps = [
- "//garnet/public/lib/fsl",
- "//garnet/public/lib/ui/base_view/cpp",
- "//sdk/fidl/fuchsia.intl",
- "//sdk/fidl/fuchsia.ui.scenic",
- "//sdk/fidl/fuchsia.ui.views",
- "//sdk/lib/fidl/cpp",
- "//src/lib/fidl_fuchsia_intl_ext/cpp",
- "//src/lib/fxl",
- "//third_party/skia",
- "//topaz/examples/ui/lib:skia_fonts",
- "//topaz/examples/ui/lib:skia_view",
- "//zircon/public/lib/async-loop-cpp",
- "//zircon/public/lib/async-loop-default",
- "//zircon/public/lib/trace-provider-with-fdio",
- ]
-}
-
-package("intl_client_demo") {
- deps = [
- ":bin",
- ]
-
- binaries = [
- {
- name = "intl_client_demo"
- },
- ]
-
- meta = [
- {
- path = rebase_path("meta/intl_client_demo.cmx")
- dest = "intl_client_demo.cmx"
- },
- ]
-}
diff --git a/examples/ui/intl_client_demo/OWNERS b/examples/ui/intl_client_demo/OWNERS
deleted file mode 100644
index 8ef7760..0000000
--- a/examples/ui/intl_client_demo/OWNERS
+++ /dev/null
@@ -1,5 +0,0 @@
-fmil@google.com
-jeffbrown@google.com
-kpozin@google.com
-shayba@google.com
-viktard@google.com
diff --git a/examples/ui/intl_client_demo/README.md b/examples/ui/intl_client_demo/README.md
deleted file mode 100644
index 98dcbb5..0000000
--- a/examples/ui/intl_client_demo/README.md
+++ /dev/null
@@ -1,33 +0,0 @@
-# IntlClientDemo
-
-This is a simple example of a visual mod that is a client of
-[`fuchsia.intl.PropertyProvider`](../../../../sdk/fidl/fuchsia.intl/property_provider.fidl),
-whose `Locale` can be set at launch and while the mod is running.
-
-`intl_client_demo` renders its view using Skia. Currently, it simply displays
-the provided locale ID in a large font in the middle of the view.
-
-## Instructions
-
-1. Build a Fuchsia workstation target with `kitchen_sink`.
-
- Example:
- ```bash
- $ fx set-petal topaz
- $ fx set workstation.chromebook-x64 --with //bundles:kitchen_sink
- $ fx serve
- ```
-
-2. Boot the device.
-
-3. Start a new session:
-
- ```bash
- $ fx shell sessionctl login_guest
- ```
-
-4. Launch the module:
-
- ```bash
- $ fx shell sessionctl add_mod intl_client_demo
- ```
diff --git a/examples/ui/intl_client_demo/intl_client_demo_view.cc b/examples/ui/intl_client_demo/intl_client_demo_view.cc
deleted file mode 100644
index 778759d..0000000
--- a/examples/ui/intl_client_demo/intl_client_demo_view.cc
+++ /dev/null
@@ -1,126 +0,0 @@
-// Copyright 2019 The Fuchsia 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 "intl_client_demo_view.h"
-
-#include "src/lib/fidl_fuchsia_intl_ext/cpp/fidl_ext.h"
-#include "src/lib/fxl/logging.h"
-#include "third_party/skia/include/core/SkFont.h"
-#include "third_party/skia/include/core/SkPaint.h"
-
-namespace examples {
-
-namespace {
-constexpr SkScalar kTextSize = 30;
-
-// Return the first locale ID in the given profile, or "[none]" if the
-// profile is invalid.
-const std::string GetFirstLocale(const fuchsia::intl::Profile& profile) {
- if (profile.has_locales()) {
- return profile.locales()[0].id;
- }
- return "[none]";
-}
-
-} // namespace
-
-IntlClientDemoView::IntlClientDemoView(scenic::ViewContext view_context)
- : SkiaView(std::move(view_context), "ViewConfig Demo"),
- font_loader_(
- component_context()->svc()->Connect<fuchsia::fonts::Provider>()),
- intl_property_provider_client_(
- component_context()
- ->svc()
- ->Connect<fuchsia::intl::PropertyProvider>()) {
- // Asynchronously load the font we need in order to render text.
- fuchsia::fonts::TypefaceRequest font_request{};
- font_request.set_query(std::move(fuchsia::fonts::TypefaceQuery{}.set_family(
- fuchsia::fonts::FamilyName{.name = "Roboto"})));
- font_loader_.LoadFont(std::move(font_request),
- [this](sk_sp<SkTypeface> typeface) {
- if (!typeface) {
- FXL_LOG(ERROR) << "Failed to load font";
- return;
- }
- FXL_LOG(INFO) << "Loaded font";
- typeface_ = std::move(typeface);
- InvalidateScene();
- });
- intl_property_provider_client_.events().OnChange = [this]() {
- FetchIntlProfile();
- };
- // Load the initial profile.
- FetchIntlProfile();
-}
-
-void IntlClientDemoView::FetchIntlProfile() {
- intl_property_provider_client_->GetProfile(
- [this](fuchsia::intl::Profile new_profile) {
- SetIntlProfile(std::move(new_profile));
- });
-}
-
-void IntlClientDemoView::SetIntlProfile(fuchsia::intl::Profile new_profile) {
- FXL_LOG(INFO) << "Got a new intl Profile";
- if (intl_profile_ != new_profile) {
- intl_profile_ = std::move(new_profile);
- InvalidateScene();
- }
-}
-
-void IntlClientDemoView::OnPropertiesChanged(
- fuchsia::ui::gfx::ViewProperties old_properties) {
- InvalidateScene();
-}
-
-void IntlClientDemoView::OnSceneInvalidated(
- fuchsia::images::PresentationInfo presentation_info) {
- if (!typeface_) {
- FXL_LOG(ERROR) << "No typeface loaded";
- return;
- }
-
- SkCanvas* canvas = AcquireCanvas();
- if (!canvas) {
- FXL_LOG(ERROR) << "Couldn't acquire canvas";
- return;
- }
-
- Draw(canvas);
- ReleaseAndSwapCanvas();
- // If we want to animate, add a call to InvalidateScene() here.
-}
-
-void IntlClientDemoView::Draw(SkCanvas* canvas) {
- canvas->clear(SkColorSetRGB(180, 200, 200));
-
- SkPaint text_paint;
- text_paint.setColor(SK_ColorBLACK);
- text_paint.setAntiAlias(true);
- text_paint.setStyle(SkPaint::kFill_Style);
-
- SkFont font;
- font.setSize(kTextSize);
- font.setTypeface(typeface_);
-
- std::vector<std::string> lines = {"Locale:", GetFirstLocale(intl_profile_)};
-
- // Start 1/3 of the way from the top.
- float v_offset = logical_size().y / 3.0;
- SkRect text_bounds{};
-
- for (const auto& line : lines) {
- font.measureText(line.c_str(), line.size(), SkTextEncoding::kUTF8,
- &text_bounds);
-
- // Draw the text horizontally centered on the screen.
- canvas->drawSimpleText(line.c_str(), line.size(), SkTextEncoding::kUTF8,
- (logical_size().x - text_bounds.width()) / 2,
- v_offset, font, text_paint);
-
- v_offset += (text_bounds.height() * 1.5);
- }
-}
-
-} // namespace examples
diff --git a/examples/ui/intl_client_demo/intl_client_demo_view.h b/examples/ui/intl_client_demo/intl_client_demo_view.h
deleted file mode 100644
index 0dc442d..0000000
--- a/examples/ui/intl_client_demo/intl_client_demo_view.h
+++ /dev/null
@@ -1,50 +0,0 @@
-// Copyright 2019 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef TOPAZ_EXAMPLES_UI_INTL_CLIENT_DEMO_INTL_CLIENT_DEMO_VIEW_H_
-#define TOPAZ_EXAMPLES_UI_INTL_CLIENT_DEMO_INTL_CLIENT_DEMO_VIEW_H_
-
-#include "examples/ui/lib/skia_font_loader.h"
-#include "examples/ui/lib/skia_view.h"
-#include "src/lib/fxl/logging.h"
-#include "third_party/skia/include/core/SkCanvas.h"
-#include "third_party/skia/include/core/SkColor.h"
-#include "third_party/skia/include/core/SkRect.h"
-#include "third_party/skia/include/core/SkTypeface.h"
-
-namespace examples {
-
-// A simple implementation of |BaseView| and |SkiaView|.
-//
-// Uses Skia to display its current locale ID as text in the middle of the view.
-class IntlClientDemoView : public scenic::SkiaView {
- public:
- IntlClientDemoView(scenic::ViewContext view_context);
-
- private:
- void FetchIntlProfile();
-
- void SetIntlProfile(fuchsia::intl::Profile new_profile);
-
- void OnPropertiesChanged(
- fuchsia::ui::gfx::ViewProperties old_properties) override;
-
- // |scenic::BaseView|
- void OnSceneInvalidated(
- fuchsia::images::PresentationInfo presentation_info) override;
-
- // Draw a solid background and some centered text.
- void Draw(SkCanvas* canvas);
-
- scenic::SkiaFontLoader font_loader_;
- sk_sp<SkTypeface> typeface_;
-
- fuchsia::intl::PropertyProviderPtr intl_property_provider_client_;
- // The current profile
- fuchsia::intl::Profile intl_profile_;
-};
-
-} // namespace examples
-
-#endif // TOPAZ_EXAMPLES_UI_INTL_CLIENT_DEMO_INTL_CLIENT_DEMO_VIEW_H_
diff --git a/examples/ui/intl_client_demo/main.cc b/examples/ui/intl_client_demo/main.cc
deleted file mode 100644
index bc357e5..0000000
--- a/examples/ui/intl_client_demo/main.cc
+++ /dev/null
@@ -1,36 +0,0 @@
-// Copyright 2019 The Fuchsia 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 <lib/async-loop/cpp/loop.h>
-#include <lib/async-loop/default.h>
-#include <lib/trace-provider/provider.h>
-#include <lib/ui/base_view/cpp/view_provider_component.h>
-
-#include "intl_client_demo_view.h"
-#include "src/lib/fxl/command_line.h"
-#include "src/lib/fxl/log_settings_command_line.h"
-int main(int argc, const char** argv) {
- async::Loop loop(&kAsyncLoopConfigAttachToCurrentThread);
- trace::TraceProviderWithFdio trace_provider(loop.dispatcher());
-
- auto command_line = fxl::CommandLineFromArgcArgv(argc, argv);
- if (!fxl::SetLogSettingsFromCommandLine(command_line)) {
- return 1;
- }
-
- FXL_LOG(INFO) << "Creating ViewProviderComponent";
- scenic::ViewProviderComponent component(
- [](scenic::ViewContext view_context) {
- FXL_LOG(INFO) << "Calling ViewFactory";
- auto view = std::make_unique<examples::IntlClientDemoView>(
- std::move(view_context));
- FXL_LOG(INFO) << "Constructed IntlClientDemoView";
- return view;
- },
- &loop);
-
- loop.Run();
- FXL_LOG(INFO) << "Reached end of main";
- return 0;
-}
diff --git a/examples/ui/intl_client_demo/meta/intl_client_demo.cmx b/examples/ui/intl_client_demo/meta/intl_client_demo.cmx
deleted file mode 100644
index 02a5345..0000000
--- a/examples/ui/intl_client_demo/meta/intl_client_demo.cmx
+++ /dev/null
@@ -1,15 +0,0 @@
-{
- "program": {
- "binary": "bin/intl_client_demo"
- },
- "sandbox": {
- "services": [
- "fuchsia.fonts.Provider",
- "fuchsia.intl.PropertyProvider",
- "fuchsia.logger.LogSink",
- "fuchsia.tracing.provider.Registry",
- "fuchsia.ui.policy.Presenter",
- "fuchsia.ui.scenic.Scenic"
- ]
- }
-}
diff --git a/examples/ui/jank/BUILD.gn b/examples/ui/jank/BUILD.gn
deleted file mode 100644
index 9f31aa3..0000000
--- a/examples/ui/jank/BUILD.gn
+++ /dev/null
@@ -1,47 +0,0 @@
-# Copyright 2016 The Fuchsia Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-import("//build/package.gni")
-
-executable("jank") {
- output_name = "jank_view"
-
- sources = [
- "jank_view.cc",
- "jank_view.h",
- "main.cc",
- ]
-
- deps = [
- "//garnet/public/lib/ui/base_view/cpp",
- "//sdk/fidl/fuchsia.fonts",
- "//sdk/fidl/fuchsia.images",
- "//sdk/fidl/fuchsia.ui.input",
- "//sdk/lib/fidl/cpp",
- "//src/lib/fxl",
- "//third_party/skia",
- "//topaz/examples/ui/lib:skia_fonts",
- "//topaz/examples/ui/lib:skia_view",
- "//zircon/public/lib/async-loop-cpp",
- "//zircon/public/lib/async-loop-default",
- "//zircon/public/lib/trace-provider-with-fdio",
- ]
-}
-
-package("package") {
- package_name = "jank"
-
- deps = [
- ":jank",
- ]
-
- binary = "jank_view"
-
- meta = [
- {
- path = rebase_path("../meta/ui_example.cmx")
- dest = "jank.cmx"
- },
- ]
-}
diff --git a/examples/ui/jank/README.md b/examples/ui/jank/README.md
deleted file mode 100644
index 6233389..0000000
--- a/examples/ui/jank/README.md
+++ /dev/null
@@ -1,9 +0,0 @@
-# Scenic Jank Test Example
-
-This directory contains a simple application whose sole purpose is to
-misbehave and produce broken behavior. Buttons in the application trigger
-various functions such as stalling or crashing the app.
-
-## USAGE
-
- launch jank_view
diff --git a/examples/ui/jank/jank_view.cc b/examples/ui/jank/jank_view.cc
deleted file mode 100644
index 8858157..0000000
--- a/examples/ui/jank/jank_view.cc
+++ /dev/null
@@ -1,139 +0,0 @@
-// Copyright 2016 The Fuchsia 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 "topaz/examples/ui/jank/jank_view.h"
-
-#include <unistd.h>
-
-#include <string>
-
-#include "src/lib/fxl/logging.h"
-#include "src/lib/fxl/macros.h"
-#include "src/lib/fxl/time/time_delta.h"
-
-namespace examples {
-
-namespace {
-constexpr SkScalar kButtonWidth = 300;
-constexpr SkScalar kButtonHeight = 24;
-constexpr SkScalar kTextSize = 10;
-constexpr SkScalar kMargin = 10;
-} // namespace
-
-const JankView::Button JankView::kButtons[] = {
- {"Hang for 10 seconds", Action::kHang10},
- {"Stutter for 30 seconds", Action::kStutter30},
- {"Crash!", Action::kCrash},
-};
-
-JankView::JankView(scenic::ViewContext view_context,
- fuchsia::fonts::ProviderPtr font_provider)
- : SkiaView(std::move(view_context), "Jank"),
- font_loader_(std::move(font_provider)) {
- font_loader_.LoadDefaultFont([this](sk_sp<SkTypeface> typeface) {
- FXL_CHECK(typeface); // TODO(jeffbrown): Fail gracefully.
- typeface_ = std::move(typeface);
- InvalidateScene();
- });
-}
-
-void JankView::OnSceneInvalidated(
- fuchsia::images::PresentationInfo presentation_info) {
- if (!typeface_)
- return;
-
- SkCanvas* canvas = AcquireCanvas();
- if (!canvas)
- return;
- DrawContent(canvas);
- ReleaseAndSwapCanvas();
-
- // Stutter if needed.
- if (stutter_end_time_ > fxl::TimePoint::Now())
- sleep(2);
-
- // Animate.
- InvalidateScene();
-}
-
-void JankView::DrawContent(SkCanvas* canvas) {
- SkScalar hsv[3] = {
- static_cast<SkScalar>(
- fmod(fxl::TimePoint::Now().ToEpochDelta().ToSecondsF() * 60, 360.)),
- 1, 1};
- canvas->clear(SkHSVToColor(hsv));
-
- SkScalar x = kMargin;
- SkScalar y = kMargin;
- for (const auto& button : kButtons) {
- DrawButton(canvas, button.label,
- SkRect::MakeXYWH(x, y, kButtonWidth, kButtonHeight));
- y += kButtonHeight + kMargin;
- }
-}
-
-void JankView::DrawButton(SkCanvas* canvas, const char* label,
- const SkRect& bounds) {
- SkPaint boxPaint;
- boxPaint.setColor(SkColorSetRGB(200, 200, 200));
- canvas->drawRect(bounds, boxPaint);
- boxPaint.setColor(SkColorSetRGB(40, 40, 40));
- boxPaint.setStyle(SkPaint::kStroke_Style);
- canvas->drawRect(bounds, boxPaint);
-
- SkRect textBounds;
- SkFont textFont;
- textFont.setTypeface(typeface_);
- textFont.setSize(kTextSize);
- textFont.measureText(label, strlen(label), SkTextEncoding::kUTF8,
- &textBounds);
-
- SkPaint textPaint;
- textPaint.setColor(SK_ColorBLACK);
- textPaint.setAntiAlias(true);
- canvas->drawSimpleText(label, strlen(label), SkTextEncoding::kUTF8,
- bounds.centerX() - textBounds.centerX(),
- bounds.centerY() - textBounds.centerY(), textFont,
- textPaint);
-}
-
-void JankView::OnInputEvent(fuchsia::ui::input::InputEvent event) {
- if (event.is_pointer()) {
- const fuchsia::ui::input::PointerEvent& pointer = event.pointer();
- if (pointer.phase == fuchsia::ui::input::PointerEventPhase::DOWN) {
- SkScalar x = pointer.x;
- SkScalar y = pointer.y;
- if (x >= kMargin && x <= kButtonWidth + kMargin) {
- int index = (y - kMargin) / (kButtonHeight + kMargin);
- if (index >= 0 &&
- size_t(index) < sizeof(kButtons) / sizeof(kButtons[0]) &&
- y < (kButtonHeight + kMargin) * (index + 1))
- OnClick(kButtons[index]);
- return;
- }
- }
- }
-}
-
-void JankView::OnClick(const Button& button) {
- switch (button.action) {
- case Action::kHang10: {
- sleep(10);
- break;
- }
-
- case Action::kStutter30: {
- stutter_end_time_ =
- fxl::TimePoint::Now() + fxl::TimeDelta::FromSeconds(30);
- break;
- }
-
- case Action::kCrash: {
- abort();
- break;
- }
- }
-}
-
-} // namespace examples
diff --git a/examples/ui/jank/jank_view.h b/examples/ui/jank/jank_view.h
deleted file mode 100644
index 16b7ccf..0000000
--- a/examples/ui/jank/jank_view.h
+++ /dev/null
@@ -1,63 +0,0 @@
-// Copyright 2016 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef TOPAZ_EXAMPLES_UI_JANK_JANK_VIEW_H_
-#define TOPAZ_EXAMPLES_UI_JANK_JANK_VIEW_H_
-
-#include <fuchsia/fonts/cpp/fidl.h>
-#include <fuchsia/images/cpp/fidl.h>
-#include <fuchsia/ui/input/cpp/fidl.h>
-
-#include "examples/ui/lib/skia_font_loader.h"
-#include "examples/ui/lib/skia_view.h"
-#include "src/lib/fxl/macros.h"
-#include "src/lib/fxl/time/time_point.h"
-#include "third_party/skia/include/core/SkCanvas.h"
-#include "third_party/skia/include/core/SkColor.h"
-#include "third_party/skia/include/core/SkFont.h"
-#include "third_party/skia/include/core/SkRect.h"
-#include "third_party/skia/include/core/SkTypeface.h"
-
-namespace examples {
-
-class JankView : public scenic::SkiaView {
- public:
- JankView(scenic::ViewContext view_context,
- fuchsia::fonts::ProviderPtr font_provider);
- ~JankView() override = default;
-
- private:
- enum class Action {
- kHang10,
- kStutter30,
- kCrash,
- };
-
- struct Button {
- const char* label;
- Action action;
- };
-
- static const Button kButtons[];
-
- // |scenic::BaseView|
- void OnSceneInvalidated(
- fuchsia::images::PresentationInfo presentation_info) override;
- void OnInputEvent(fuchsia::ui::input::InputEvent event) override;
-
- void DrawContent(SkCanvas* canvas);
- void DrawButton(SkCanvas* canvas, const char* label, const SkRect& bounds);
- void OnClick(const Button& button);
-
- scenic::SkiaFontLoader font_loader_;
- sk_sp<SkTypeface> typeface_;
-
- fxl::TimePoint stutter_end_time_;
-
- FXL_DISALLOW_COPY_AND_ASSIGN(JankView);
-};
-
-} // namespace examples
-
-#endif // TOPAZ_EXAMPLES_UI_JANK_JANK_VIEW_H_
diff --git a/examples/ui/jank/main.cc b/examples/ui/jank/main.cc
deleted file mode 100644
index 4e60952..0000000
--- a/examples/ui/jank/main.cc
+++ /dev/null
@@ -1,33 +0,0 @@
-// Copyright 2017 The Fuchsia 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 <lib/async-loop/cpp/loop.h>
-#include <lib/async-loop/default.h>
-#include <lib/trace-provider/provider.h>
-#include <lib/ui/base_view/cpp/view_provider_component.h>
-
-#include "src/lib/fxl/command_line.h"
-#include "src/lib/fxl/log_settings_command_line.h"
-#include "topaz/examples/ui/jank/jank_view.h"
-
-int main(int argc, const char** argv) {
- async::Loop loop(&kAsyncLoopConfigAttachToCurrentThread);
- trace::TraceProviderWithFdio trace_provider(loop.dispatcher());
-
- auto command_line = fxl::CommandLineFromArgcArgv(argc, argv);
- if (!fxl::SetLogSettingsFromCommandLine(command_line))
- return 1;
-
- scenic::ViewProviderComponent component(
- [](scenic::ViewContext view_context) {
- auto font_provider = view_context.component_context->svc()
- ->Connect<fuchsia::fonts::Provider>();
- return std::make_unique<examples::JankView>(std::move(view_context),
- std::move(font_provider));
- },
- &loop);
-
- loop.Run();
- return 0;
-}
diff --git a/examples/ui/lib/BUILD.gn b/examples/ui/lib/BUILD.gn
deleted file mode 100644
index 11b8a6e..0000000
--- a/examples/ui/lib/BUILD.gn
+++ /dev/null
@@ -1,106 +0,0 @@
-# Copyright 2017 The Fuchsia Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-config("config") {
- include_dirs = [ "//topaz" ]
-}
-
-source_set("scenic_skia") {
- sources = [
- "host_canvas_cycler.cc",
- "host_canvas_cycler.h",
- "host_surfaces.cc",
- "host_surfaces.h",
- "image_info.cc",
- "image_info.h",
- ]
-
- public_deps = [
- "//sdk/lib/ui/scenic/cpp",
- "//src/lib/fxl",
- "//src/lib/ui/scenic/cpp",
- "//third_party/skia",
- ]
-
- public_configs = [ ":config" ]
-}
-
-group("skia") {
- public_deps = [
- ":skia_fonts",
- ":skia_type_converters",
- ":skia_vmo",
- ]
-}
-
-source_set("skia_fonts") {
- sources = [
- "skia_font_loader.cc",
- "skia_font_loader.h",
- ]
-
- public_deps = [
- "//sdk/fidl/fuchsia.fonts",
- "//zircon/public/lib/fit",
- ]
-
- deps = [
- ":skia_type_converters",
- ":skia_vmo",
- "//src/lib/fxl",
- "//third_party/skia",
- ]
-
- public_configs = [ ":config" ]
-}
-
-source_set("skia_type_converters") {
- sources = [
- "type_converters.cc",
- "type_converters.h",
- ]
-
- public_deps = [
- "//garnet/public/lib/fsl",
- "//sdk/fidl/fuchsia.math",
- "//third_party/skia",
- ]
-
- public_configs = [ ":config" ]
-}
-
-source_set("skia_vmo") {
- sources = [
- "skia_vmo_data.cc",
- "skia_vmo_data.h",
- ]
-
- public_deps = [
- "//garnet/public/lib/fsl",
- "//src/lib/fxl",
- "//third_party/skia",
- "//zircon/public/lib/zx",
- ]
-
- deps = [
- "//zircon/public/lib/trace",
- ]
-
- public_configs = [ ":config" ]
-}
-
-source_set("skia_view") {
- sources = [
- "skia_view.cc",
- "skia_view.h",
- ]
-
- public_deps = [
- ":scenic_skia",
- "//garnet/public/lib/ui/base_view/cpp",
- "//third_party/skia",
- ]
-
- public_configs = [ ":config" ]
-}
diff --git a/examples/ui/lib/host_canvas_cycler.cc b/examples/ui/lib/host_canvas_cycler.cc
deleted file mode 100644
index 53acbf9..0000000
--- a/examples/ui/lib/host_canvas_cycler.cc
+++ /dev/null
@@ -1,74 +0,0 @@
-// Copyright 2017 The Fuchsia 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 "examples/ui/lib/host_canvas_cycler.h"
-
-#include "src/lib/fxl/logging.h"
-
-namespace scenic {
-namespace skia {
-
-HostCanvasCycler::HostCanvasCycler(scenic::Session* session)
- : EntityNode(session),
- content_node_(session),
- content_material_(session),
- surface_pool_(session, kNumBuffers) {
- content_node_.SetMaterial(content_material_);
- AddChild(content_node_);
-}
-
-HostCanvasCycler::~HostCanvasCycler() = default;
-
-SkCanvas* HostCanvasCycler::AcquireCanvas(float logical_width,
- float logical_height, float scale_x,
- float scale_y) {
- FXL_DCHECK(!acquired_surface_);
-
- // Update the surface pool and content shape.
- fuchsia::images::ImageInfo image_info;
- image_info.width = logical_width * scale_x;
- image_info.height = logical_height * scale_y;
- image_info.stride = image_info.width * 4u;
- image_info.pixel_format = fuchsia::images::PixelFormat::BGRA_8;
- image_info.color_space = fuchsia::images::ColorSpace::SRGB;
- image_info.tiling = fuchsia::images::Tiling::LINEAR;
- reconfigured_ = surface_pool_.Configure(&image_info);
-
- // Acquire the surface.
- acquired_surface_ = surface_pool_.GetSkSurface(surface_index_);
- FXL_DCHECK(acquired_surface_);
- logical_width_ = logical_width;
- logical_height_ = logical_height;
-
- SkCanvas* canvas = acquired_surface_->getCanvas();
- canvas->save();
- canvas->scale(scale_x, scale_y);
- return canvas;
-}
-
-void HostCanvasCycler::ReleaseAndSwapCanvas() {
- FXL_DCHECK(acquired_surface_);
-
- acquired_surface_->getCanvas()->restoreToCount(1);
- acquired_surface_->flush();
- acquired_surface_.reset();
-
- const scenic_util::HostImage* image = surface_pool_.GetImage(surface_index_);
- FXL_DCHECK(image);
- content_material_.SetTexture(*image);
-
- if (reconfigured_) {
- scenic::Rectangle content_rect(content_node_.session(), logical_width_,
- logical_height_);
- content_node_.SetShape(content_rect);
- reconfigured_ = false;
- }
-
- // TODO(SCN-145): Define an |InvalidateOp| on |Image| instead.
- surface_pool_.DiscardImage(surface_index_);
- surface_index_ = (surface_index_ + 1) % kNumBuffers;
-}
-
-} // namespace skia
-} // namespace scenic
diff --git a/examples/ui/lib/host_canvas_cycler.h b/examples/ui/lib/host_canvas_cycler.h
deleted file mode 100644
index 18e6fdd..0000000
--- a/examples/ui/lib/host_canvas_cycler.h
+++ /dev/null
@@ -1,50 +0,0 @@
-// Copyright 2017 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef LIB_UI_SCENIC_SKIA_HOST_CANVAS_CYCLER_H_
-#define LIB_UI_SCENIC_SKIA_HOST_CANVAS_CYCLER_H_
-
-#include "examples/ui/lib/host_surfaces.h"
-#include "third_party/skia/include/core/SkCanvas.h"
-
-namespace scenic {
-namespace skia {
-
-// Creates a node which presents double-buffered content drawn to a Skia canvas
-// using software rendering.
-class HostCanvasCycler : public EntityNode {
- public:
- HostCanvasCycler(Session* session);
- ~HostCanvasCycler();
-
- HostCanvasCycler(const HostCanvasCycler&) = delete;
- HostCanvasCycler& operator=(const HostCanvasCycler&) = delete;
-
- // Acquires a canvas for rendering.
- // At most one canvas can be acquired at a time.
- // The client is responsible for clearing the canvas.
- SkCanvas* AcquireCanvas(float logical_width, float logical_height,
- float scale_x, float scale_y);
-
- // Releases the canvas most recently acquired using |AcquireCanvas()|.
- // Sets the content node's texture to be backed by the canvas.
- void ReleaseAndSwapCanvas();
-
- private:
- static constexpr uint32_t kNumBuffers = 2u;
-
- ShapeNode content_node_;
- Material content_material_;
- HostSkSurfacePool surface_pool_;
- sk_sp<SkSurface> acquired_surface_;
- bool reconfigured_ = false;
- uint32_t surface_index_ = 0u;
- float logical_width_ = 0.f;
- float logical_height_ = 0.f;
-};
-
-} // namespace skia
-} // namespace scenic
-
-#endif // LIB_UI_SCENIC_SKIA_HOST_CANVAS_CYCLER_H_
diff --git a/examples/ui/lib/host_surfaces.cc b/examples/ui/lib/host_surfaces.cc
deleted file mode 100644
index 566b498..0000000
--- a/examples/ui/lib/host_surfaces.cc
+++ /dev/null
@@ -1,84 +0,0 @@
-// Copyright 2017 The Fuchsia 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 "examples/ui/lib/host_surfaces.h"
-
-#include "examples/ui/lib/image_info.h"
-#include "src/lib/fxl/logging.h"
-
-namespace scenic {
-namespace skia {
-namespace {
-
-// Keeps the HostData alive until skia calls us back in DestroySurfaceContext.
-//
-// If the ref pointer for HostData would allow us to AddRef/Release manually, we
-// would not need to allocate this object on the heap to keep the HostData
-// alive. Hopefully a future fit::ref_ptr will replace std::shared_ptr and let
-// us avoid the heap allocation.
-class SurfaceContext {
- public:
- explicit SurfaceContext(std::shared_ptr<scenic_util::HostData> data)
- : data_(std::move(data)) {}
-
- private:
- std::shared_ptr<scenic_util::HostData> data_;
-};
-
-void DestroySurfaceContext(void* pixels, void* context) {
- delete static_cast<SurfaceContext*>(context);
-}
-
-} // namespace
-
-sk_sp<SkSurface> MakeSkSurface(const scenic_util::HostImage& image) {
- return MakeSkSurface(image.info(), image.data(), image.memory_offset());
-}
-
-sk_sp<SkSurface> MakeSkSurface(const fuchsia::images::ImageInfo& image_info,
- std::shared_ptr<scenic_util::HostData> data,
- off_t memory_offset) {
- return MakeSkSurface(MakeSkImageInfo(image_info), image_info.stride,
- std::move(data), memory_offset);
-}
-
-sk_sp<SkSurface> MakeSkSurface(SkImageInfo image_info, size_t row_bytes,
- std::shared_ptr<scenic_util::HostData> data,
- off_t memory_offset) {
- return SkSurface::MakeRasterDirectReleaseProc(
- image_info, static_cast<uint8_t*>(data->ptr()) + memory_offset, row_bytes,
- &DestroySurfaceContext, new SurfaceContext(data));
-}
-
-HostSkSurfacePool::HostSkSurfacePool(Session* session, uint32_t num_images)
- : image_pool_(session, num_images), surface_ptrs_(num_images) {}
-
-HostSkSurfacePool::~HostSkSurfacePool() = default;
-
-bool HostSkSurfacePool::Configure(
- const fuchsia::images::ImageInfo* image_info) {
- if (!image_pool_.Configure(std::move(image_info)))
- return false;
-
- for (uint32_t i = 0; i < num_images(); i++)
- surface_ptrs_[i].reset();
- return true;
-}
-
-sk_sp<SkSurface> HostSkSurfacePool::GetSkSurface(uint32_t index) {
- FXL_DCHECK(index < num_images());
-
- if (surface_ptrs_[index])
- return surface_ptrs_[index];
-
- const scenic_util::HostImage* image = image_pool_.GetImage(index);
- if (!image)
- return nullptr;
-
- surface_ptrs_[index] = MakeSkSurface(*image);
- return surface_ptrs_[index];
-}
-
-} // namespace skia
-} // namespace scenic
diff --git a/examples/ui/lib/host_surfaces.h b/examples/ui/lib/host_surfaces.h
deleted file mode 100644
index bdb60e6..0000000
--- a/examples/ui/lib/host_surfaces.h
+++ /dev/null
@@ -1,80 +0,0 @@
-// Copyright 2017 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef LIB_UI_SCENIC_SKIA_HOST_SURFACES_H_
-#define LIB_UI_SCENIC_SKIA_HOST_SURFACES_H_
-
-#include "src/lib/ui/scenic/cpp/host_memory.h"
-#include "third_party/skia/include/core/SkSurface.h"
-
-namespace scenic {
-namespace skia {
-
-// Creates a Skia surface backed by host-accessible shared memory associated
-// with an image resource.
-sk_sp<SkSurface> MakeSkSurface(const scenic_util::HostImage& image);
-
-// Creates a Skia surface backed by host-accessible shared memory.
-sk_sp<SkSurface> MakeSkSurface(const fuchsia::images::ImageInfo& image_info,
- std::shared_ptr<scenic_util::HostData> data,
- off_t memory_offset);
-sk_sp<SkSurface> MakeSkSurface(SkImageInfo image_info, size_t row_bytes,
- std::shared_ptr<scenic_util::HostData> data,
- off_t memory_offset);
-
-// Represents a pool of Skia surfaces and image resources backed by
-// host-accessible shared memory bound to a session. All images in the pool
-// must have the same layout.
-class HostSkSurfacePool {
- public:
- // Creates a pool which can supply up to |num_images| images on demand.
- explicit HostSkSurfacePool(Session* session, uint32_t num_images);
- ~HostSkSurfacePool();
-
- HostSkSurfacePool(const HostSkSurfacePool&) = delete;
- HostSkSurfacePool& operator=(const HostSkSurfacePool&) = delete;
-
- // The number of images which this pool can manage.
- uint32_t num_images() const { return image_pool_.num_images(); }
-
- // Gets information about the images in the pool, or nullptr if the
- // pool is not configured.
- const fuchsia::images::ImageInfo* image_info() const {
- return image_pool_.image_info();
- }
-
- // Sets the image information for images in the pool.
- // Previously created images are released but their memory may be reused.
- // If |image_info| is nullptr, the pool reverts to an non-configured state;
- // all images are released but the memory is retained for recycling.
- // Returns true if the configuration changed.
- bool Configure(const fuchsia::images::ImageInfo* image_info);
-
- // Gets the surface backed by the image with the specified index.
- // The |index| must be between 0 and |num_images() - 1|.
- // The returned pointer is valid until the image is discarded or the
- // pool is reconfigured. Returns nullptr if the pool is not configured.
- sk_sp<SkSurface> GetSkSurface(uint32_t index);
-
- // Gets the image with the specified index.
- // The |index| must be between 0 and |num_images() - 1|.
- // The returned pointer is valid until the image is discarded or the
- // pool is reconfigured. Returns nullptr if the pool is not configured.
- const scenic_util::HostImage* GetImage(uint32_t index) {
- return image_pool_.GetImage(index);
- }
-
- // Discards the image with the specified index but recycles its memory.
- // The |index| must be between 0 and |num_images() - 1|.
- void DiscardImage(uint32_t index) { image_pool_.DiscardImage(index); }
-
- private:
- scenic_util::HostImagePool image_pool_;
- std::vector<sk_sp<SkSurface>> surface_ptrs_;
-};
-
-} // namespace skia
-} // namespace scenic
-
-#endif // LIB_UI_SCENIC_SKIA_HOST_SURFACES_H_
diff --git a/examples/ui/lib/image_info.cc b/examples/ui/lib/image_info.cc
deleted file mode 100644
index 48099c2..0000000
--- a/examples/ui/lib/image_info.cc
+++ /dev/null
@@ -1,31 +0,0 @@
-// Copyright 2017 The Fuchsia 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 "examples/ui/lib/image_info.h"
-
-#include "src/lib/fxl/logging.h"
-
-namespace scenic {
-namespace skia {
-
-SkImageInfo MakeSkImageInfo(const fuchsia::images::ImageInfo& image_info) {
- FXL_DCHECK(image_info.tiling == fuchsia::images::Tiling::LINEAR);
-
- switch (image_info.pixel_format) {
- case fuchsia::images::PixelFormat::BGRA_8:
- return SkImageInfo::Make(image_info.width, image_info.height,
- kBGRA_8888_SkColorType, kOpaque_SkAlphaType);
- case fuchsia::images::PixelFormat::YUY2:
- case fuchsia::images::PixelFormat::NV12:
- case fuchsia::images::PixelFormat::YV12:
- FXL_CHECK(false) << "Not implemented: "
- << static_cast<int>(image_info.pixel_format);
- return SkImageInfo();
- }
-
- FXL_NOTREACHED();
-}
-
-} // namespace skia
-} // namespace scenic
diff --git a/examples/ui/lib/image_info.h b/examples/ui/lib/image_info.h
deleted file mode 100644
index 83c5f67..0000000
--- a/examples/ui/lib/image_info.h
+++ /dev/null
@@ -1,21 +0,0 @@
-// Copyright 2017 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef LIB_UI_SCENIC_SKIA_IMAGE_INFO_H_
-#define LIB_UI_SCENIC_SKIA_IMAGE_INFO_H_
-
-#include <fuchsia/images/cpp/fidl.h>
-
-#include "third_party/skia/include/core/SkImageInfo.h"
-
-namespace scenic {
-namespace skia {
-
-// Creates Skia image information from a |fuchsia::images::ImageInfo| object.
-SkImageInfo MakeSkImageInfo(const fuchsia::images::ImageInfo& image_info);
-
-} // namespace skia
-} // namespace scenic
-
-#endif // LIB_UI_SCENIC_SKIA_IMAGE_INFO_H_
diff --git a/examples/ui/lib/skia_font_loader.cc b/examples/ui/lib/skia_font_loader.cc
deleted file mode 100644
index 7e3cebf..0000000
--- a/examples/ui/lib/skia_font_loader.cc
+++ /dev/null
@@ -1,51 +0,0 @@
-// Copyright 2016 The Fuchsia 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 "examples/ui/lib/skia_font_loader.h"
-
-#include <utility>
-
-#include "examples/ui/lib/skia_vmo_data.h"
-#include "third_party/skia/include/core/SkFontMgr.h"
-
-namespace scenic {
-
-SkiaFontLoader::SkiaFontLoader(fuchsia::fonts::ProviderPtr font_provider)
- : font_provider_(std::move(font_provider)) {}
-
-SkiaFontLoader::~SkiaFontLoader() {}
-
-void SkiaFontLoader::LoadFont(fuchsia::fonts::TypefaceRequest request,
- FontCallback callback) {
- // TODO(jeffbrown): Handle errors in case the font provider itself dies.
- font_provider_->GetTypeface(
- std::move(request), [callback = std::move(callback)](
- fuchsia::fonts::TypefaceResponse response) {
- if (!response.IsEmpty()) {
- fuchsia::mem::Buffer buffer{};
- response.buffer().Clone(&buffer);
- fsl::SizedVmo vmo;
- if (!fsl::SizedVmo::FromTransport(std::move(buffer), &vmo)) {
- callback(nullptr);
- return;
- }
- sk_sp<SkData> font_data = MakeSkDataFromVMO(vmo);
- if (font_data) {
- callback(
- SkFontMgr::RefDefault()->makeFromData(std::move(font_data)));
- return;
- }
- }
- callback(nullptr);
- });
-}
-
-void SkiaFontLoader::LoadDefaultFont(FontCallback callback) {
- fuchsia::fonts::TypefaceRequest request{};
- request.set_query(std::move(fuchsia::fonts::TypefaceQuery{}.set_family(
- fuchsia::fonts::FamilyName{.name = "Roboto"})));
- LoadFont(std::move(request), std::move(callback));
-}
-
-} // namespace scenic
diff --git a/examples/ui/lib/skia_font_loader.h b/examples/ui/lib/skia_font_loader.h
deleted file mode 100644
index 4f93882..0000000
--- a/examples/ui/lib/skia_font_loader.h
+++ /dev/null
@@ -1,42 +0,0 @@
-// Copyright 2016 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef TOPAZ_EXAMPLES_UI_LIB_SKIA_FONT_LOADER_H_
-#define TOPAZ_EXAMPLES_UI_LIB_SKIA_FONT_LOADER_H_
-
-#include <fuchsia/fonts/cpp/fidl.h>
-#include <lib/fit/function.h>
-
-#include <functional>
-
-#include "src/lib/fxl/macros.h"
-#include "third_party/skia/include/core/SkTypeface.h"
-
-namespace scenic {
-
-// Loads fonts from a font provider.
-class SkiaFontLoader {
- public:
- using FontCallback = fit::function<void(sk_sp<SkTypeface>)>;
-
- SkiaFontLoader(fuchsia::fonts::ProviderPtr font_provider);
- ~SkiaFontLoader();
-
- // Loads the requested font and invokes the callback when done.
- // If the request fails, the callback will receive a null typeface.
- void LoadFont(fuchsia::fonts::TypefaceRequest request, FontCallback callback);
-
- // Loads the default font and invokes the callback when done.
- // If the request fails, the callback will receive a null typeface.
- void LoadDefaultFont(FontCallback callback);
-
- private:
- fuchsia::fonts::ProviderPtr font_provider_;
-
- FXL_DISALLOW_COPY_AND_ASSIGN(SkiaFontLoader);
-};
-
-} // namespace scenic
-
-#endif // TOPAZ_EXAMPLES_UI_LIB_SKIA_FONT_LOADER_H_
diff --git a/examples/ui/lib/skia_view.cc b/examples/ui/lib/skia_view.cc
deleted file mode 100644
index 380ab5e..0000000
--- a/examples/ui/lib/skia_view.cc
+++ /dev/null
@@ -1,30 +0,0 @@
-// Copyright 2017 The Fuchsia 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 "examples/ui/lib/skia_view.h"
-
-namespace scenic {
-
-SkiaView::SkiaView(scenic::ViewContext view_context, const std::string& label)
- : BaseView(std::move(view_context), label), canvas_cycler_(session()) {
- root_node().AddChild(canvas_cycler_);
-}
-
-SkCanvas* SkiaView::AcquireCanvas() {
- if (!has_logical_size() || !has_metrics())
- return nullptr;
-
- SkCanvas* canvas = canvas_cycler_.AcquireCanvas(
- logical_size().x, logical_size().y, metrics().scale_x, metrics().scale_y);
- if (!canvas)
- return canvas;
-
- canvas_cycler_.SetTranslation(logical_size().x * .5f, logical_size().y * .5f,
- 0.f);
- return canvas;
-}
-
-void SkiaView::ReleaseAndSwapCanvas() { canvas_cycler_.ReleaseAndSwapCanvas(); }
-
-} // namespace scenic
diff --git a/examples/ui/lib/skia_view.h b/examples/ui/lib/skia_view.h
deleted file mode 100644
index d4af1bc..0000000
--- a/examples/ui/lib/skia_view.h
+++ /dev/null
@@ -1,52 +0,0 @@
-// Copyright 2017 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef TOPAZ_EXAMPLES_UI_LIB_SKIA_VIEW_H_
-#define TOPAZ_EXAMPLES_UI_LIB_SKIA_VIEW_H_
-
-#include <lib/ui/base_view/cpp/base_view.h>
-
-#include "examples/ui/lib/host_canvas_cycler.h"
-#include "src/lib/fxl/logging.h"
-#include "src/lib/fxl/macros.h"
-
-namespace scenic {
-
-// Abstract base class for views which use Skia software rendering to a
-// single full-size surface.
-class SkiaView : public scenic::BaseView {
- public:
- SkiaView(scenic::ViewContext view_context, const std::string& label);
- ~SkiaView() override = default;
-
- // Acquires a canvas for rendering.
- // At most one canvas can be acquired at a time.
- // The client is responsible for clearing the canvas.
- // Returns nullptr if the view does not have a size.
- //
- // The returned canvas uses the view's logical coordinate system but is
- // backed by a surface with the same |physical_size()| as the view.
- // In other words any content which the view draws into the canvas will
- // automatically be scaled according to the view's |metrics()|.
- SkCanvas* AcquireCanvas();
-
- // Releases the canvas most recently acquired using |AcquireCanvas()|.
- // Sets the view's content texture to be backed by the canvas.
- void ReleaseAndSwapCanvas();
-
- protected:
- // |scenic::SessionListener|
- void OnScenicError(std::string error) override {
- FXL_LOG(ERROR) << "Scenic Error " << error;
- }
-
- private:
- scenic::skia::HostCanvasCycler canvas_cycler_;
-
- FXL_DISALLOW_COPY_AND_ASSIGN(SkiaView);
-};
-
-} // namespace scenic
-
-#endif // TOPAZ_EXAMPLES_UI_LIB_SKIA_VIEW_H_
diff --git a/examples/ui/lib/skia_vmo_data.cc b/examples/ui/lib/skia_vmo_data.cc
deleted file mode 100644
index 795381d..0000000
--- a/examples/ui/lib/skia_vmo_data.cc
+++ /dev/null
@@ -1,59 +0,0 @@
-// Copyright 2016 The Fuchsia 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 "examples/ui/lib/skia_vmo_data.h"
-
-#include <lib/zx/vmar.h>
-#include <trace/event.h>
-
-#include <atomic>
-
-#include "src/lib/fxl/logging.h"
-
-static_assert(sizeof(size_t) == sizeof(uint64_t),
- "Fuchsia should always be 64-bit");
-
-namespace scenic {
-namespace {
-
-std::atomic<int32_t> g_count;
-
-void TraceCount(int32_t delta) {
- int32_t count = g_count.fetch_add(delta, std::memory_order_relaxed) + delta;
- TRACE_COUNTER("gfx", "SkDataVmo", 0u, "count", count);
-}
-
-void UnmapMemory(const void* buffer, void* context) {
- const uint64_t size = reinterpret_cast<uint64_t>(context);
- zx_status_t status =
- zx::vmar::root_self()->unmap(reinterpret_cast<uintptr_t>(buffer), size);
- FXL_CHECK(status == ZX_OK);
- TraceCount(-1);
-}
-
-} // namespace
-
-sk_sp<SkData> MakeSkDataFromVMO(const fsl::SizedVmo& vmo) {
- uint64_t size = vmo.size();
- uintptr_t buffer = 0u;
- zx_status_t status = zx::vmar::root_self()->map(0, vmo.vmo(), 0u, size,
- ZX_VM_PERM_READ, &buffer);
- if (status != ZX_OK)
- return nullptr;
-
- sk_sp<SkData> data =
- SkData::MakeWithProc(reinterpret_cast<void*>(buffer), size, &UnmapMemory,
- reinterpret_cast<void*>(size));
- if (!data) {
- FXL_LOG(ERROR) << "Could not create SkData";
- status = zx::vmar::root_self()->unmap(buffer, size);
- FXL_CHECK(status == ZX_OK);
- return nullptr;
- }
-
- TraceCount(1);
- return data;
-}
-
-} // namespace scenic
diff --git a/examples/ui/lib/skia_vmo_data.h b/examples/ui/lib/skia_vmo_data.h
deleted file mode 100644
index 696bff5..0000000
--- a/examples/ui/lib/skia_vmo_data.h
+++ /dev/null
@@ -1,20 +0,0 @@
-// Copyright 2016 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef TOPAZ_EXAMPLES_UI_LIB_SKIA_VMO_DATA_H_
-#define TOPAZ_EXAMPLES_UI_LIB_SKIA_VMO_DATA_H_
-
-#include "lib/fsl/vmo/sized_vmo.h"
-#include "third_party/skia/include/core/SkData.h"
-
-namespace scenic {
-
-// Makes an |SkData| object backed by a virtual memory object which is mapped
-// read only. Does not take ownership of the handle.
-// Returns nullptr on failure.
-sk_sp<SkData> MakeSkDataFromVMO(const fsl::SizedVmo& vmo);
-
-} // namespace scenic
-
-#endif // TOPAZ_EXAMPLES_UI_LIB_SKIA_VMO_DATA_H_
diff --git a/examples/ui/lib/type_converters.cc b/examples/ui/lib/type_converters.cc
deleted file mode 100644
index b7e749a..0000000
--- a/examples/ui/lib/type_converters.cc
+++ /dev/null
@@ -1,145 +0,0 @@
-// Copyright 2016 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 "examples/ui/lib/type_converters.h"
-
-namespace fidl {
-
-SkIPoint TypeConverter<SkIPoint, fuchsia::math::Point>::Convert(
- const fuchsia::math::Point& input) {
- return SkIPoint::Make(input.x, input.y);
-}
-
-fuchsia::math::Point TypeConverter<fuchsia::math::Point, SkIPoint>::Convert(
- const SkIPoint& input) {
- fuchsia::math::Point output;
- output.x = input.x();
- output.y = input.y();
- return output;
-}
-
-SkPoint TypeConverter<SkPoint, fuchsia::math::PointF>::Convert(
- const fuchsia::math::PointF& input) {
- return SkPoint::Make(input.x, input.y);
-}
-
-fuchsia::math::PointF TypeConverter<fuchsia::math::PointF, SkPoint>::Convert(
- const SkPoint& input) {
- fuchsia::math::PointF output;
- output.x = input.x();
- output.y = input.y();
- return output;
-}
-
-SkIRect TypeConverter<SkIRect, fuchsia::math::Rect>::Convert(
- const fuchsia::math::Rect& input) {
- return SkIRect::MakeXYWH(input.x, input.y, input.width, input.height);
-}
-
-fuchsia::math::Rect TypeConverter<fuchsia::math::Rect, SkIRect>::Convert(
- const SkIRect& input) {
- fuchsia::math::Rect output;
- output.x = input.x();
- output.y = input.y();
- output.width = input.width();
- output.height = input.height();
- return output;
-}
-
-SkRect TypeConverter<SkRect, fuchsia::math::RectF>::Convert(
- const fuchsia::math::RectF& input) {
- return SkRect::MakeXYWH(input.x, input.y, input.width, input.height);
-}
-
-fuchsia::math::RectF TypeConverter<fuchsia::math::RectF, SkRect>::Convert(
- const SkRect& input) {
- fuchsia::math::RectF output;
- output.x = input.x();
- output.y = input.y();
- output.width = input.width();
- output.height = input.height();
- return output;
-}
-
-SkRRect TypeConverter<SkRRect, fuchsia::math::RRectF>::Convert(
- const fuchsia::math::RRectF& input) {
- SkVector radii[4] = {
- {input.top_left_radius_x, input.top_left_radius_y},
- {input.top_right_radius_x, input.top_right_radius_y},
- {input.bottom_left_radius_x, input.bottom_left_radius_y},
- {input.bottom_right_radius_x, input.bottom_right_radius_y}};
- SkRRect output;
- output.setRectRadii(
- SkRect::MakeXYWH(input.x, input.y, input.width, input.height), radii);
- return output;
-}
-
-fuchsia::math::RRectF TypeConverter<fuchsia::math::RRectF, SkRRect>::Convert(
- const SkRRect& input) {
- fuchsia::math::RRectF output;
- output.x = input.rect().x();
- output.y = input.rect().y();
- output.width = input.rect().width();
- output.height = input.rect().height();
- output.top_left_radius_x = input.radii(SkRRect::kUpperLeft_Corner).x();
- output.top_left_radius_y = input.radii(SkRRect::kUpperLeft_Corner).y();
- output.top_right_radius_x = input.radii(SkRRect::kUpperRight_Corner).x();
- output.top_right_radius_y = input.radii(SkRRect::kUpperRight_Corner).y();
- output.bottom_left_radius_x = input.radii(SkRRect::kLowerLeft_Corner).x();
- output.bottom_left_radius_y = input.radii(SkRRect::kLowerLeft_Corner).y();
- output.bottom_right_radius_x = input.radii(SkRRect::kLowerRight_Corner).x();
- output.bottom_right_radius_y = input.radii(SkRRect::kLowerRight_Corner).y();
- return output;
-}
-
-SkMatrix TypeConverter<SkMatrix, fuchsia::math::Transform>::Convert(
- const fuchsia::math::Transform& input) {
- // Drop 3D components during conversion from 4x4 to 3x3.
- const auto& m = input.matrix;
- SkMatrix output;
- output.setAll(m[0], m[1], m[3],
- m[4], m[5], m[7],
- m[12], m[13], m[15]);
- return output;
-}
-
-fuchsia::math::Transform TypeConverter<fuchsia::math::Transform, SkMatrix>::Convert(
- const SkMatrix& input) {
- // Expand 3x3 to 4x4.
- fuchsia::math::Transform output;
- float* m = output.matrix.data();
- m[0] = input[0];
- m[1] = input[1];
- m[2] = 0.f;
- m[3] = input[2];
- m[4] = input[3];
- m[5] = input[4];
- m[6] = 0.f;
- m[7] = input[5];
- m[8] = 0.f;
- m[9] = 0.f;
- m[10] = 1.f;
- m[11] = 0.f;
- m[12] = input[6];
- m[13] = input[7];
- m[14] = 0.f;
- m[15] = input[8];
- return output;
-}
-
-SkMatrix44 TypeConverter<SkMatrix44, fuchsia::math::Transform>::Convert(
- const fuchsia::math::Transform& input) {
- SkMatrix44 output(SkMatrix44::kUninitialized_Constructor);
- output.setRowMajorf(input.matrix.data());
- return output;
-}
-
-fuchsia::math::Transform TypeConverter<fuchsia::math::Transform, SkMatrix44>::Convert(
- const SkMatrix44& input) {
- fuchsia::math::Transform output;
- input.asRowMajorf(output.matrix.data());
- return output;
-}
-
-} // namespace fidl
diff --git a/examples/ui/lib/type_converters.h b/examples/ui/lib/type_converters.h
deleted file mode 100644
index 0c17d82..0000000
--- a/examples/ui/lib/type_converters.h
+++ /dev/null
@@ -1,88 +0,0 @@
-// Copyright 2016 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.
-
-#ifndef LIB_UI_SKIA_TYPE_CONVERTERS_H_
-#define LIB_UI_SKIA_TYPE_CONVERTERS_H_
-
-#include <fuchsia/math/cpp/fidl.h>
-
-#include "lib/fsl/types/type_converters.h"
-#include "third_party/skia/include/core/SkMatrix.h"
-#include "third_party/skia/include/core/SkMatrix44.h"
-#include "third_party/skia/include/core/SkPoint.h"
-#include "third_party/skia/include/core/SkRRect.h"
-#include "third_party/skia/include/core/SkRect.h"
-
-// The TypeConverter template is defined in the fxl namespace.
-namespace fidl {
-
-template <>
-struct TypeConverter<SkIPoint, fuchsia::math::Point> {
- static SkIPoint Convert(const fuchsia::math::Point& input);
-};
-template <>
-struct TypeConverter<fuchsia::math::Point, SkIPoint> {
- static fuchsia::math::Point Convert(const SkIPoint& input);
-};
-
-template <>
-struct TypeConverter<SkPoint, fuchsia::math::PointF> {
- static SkPoint Convert(const fuchsia::math::PointF& input);
-};
-template <>
-struct TypeConverter<fuchsia::math::PointF, SkPoint> {
- static fuchsia::math::PointF Convert(const SkPoint& input);
-};
-
-template <>
-struct TypeConverter<SkIRect, fuchsia::math::Rect> {
- static SkIRect Convert(const fuchsia::math::Rect& input);
-};
-template <>
-struct TypeConverter<fuchsia::math::Rect, SkIRect> {
- static fuchsia::math::Rect Convert(const SkIRect& input);
-};
-
-template <>
-struct TypeConverter<SkRect, fuchsia::math::RectF> {
- static SkRect Convert(const fuchsia::math::RectF& input);
-};
-template <>
-struct TypeConverter<fuchsia::math::RectF, SkRect> {
- static fuchsia::math::RectF Convert(const SkRect& input);
-};
-
-template <>
-struct TypeConverter<SkRRect, fuchsia::math::RRectF> {
- static SkRRect Convert(const fuchsia::math::RRectF& input);
-};
-template <>
-struct TypeConverter<fuchsia::math::RRectF, SkRRect> {
- static fuchsia::math::RRectF Convert(const SkRRect& input);
-};
-
-// Note: This transformation is lossy since Transform is 4x4 whereas
-// SkMatrix is only 3x3 so we drop the 3rd row and column.
-template <>
-struct TypeConverter<SkMatrix, fuchsia::math::Transform> {
- static SkMatrix Convert(const fuchsia::math::Transform& input);
-};
-template <>
-struct TypeConverter<fuchsia::math::Transform, SkMatrix> {
- static fuchsia::math::Transform Convert(const SkMatrix& input);
-};
-
-// Note: This transformation is lossless.
-template <>
-struct TypeConverter<SkMatrix44, fuchsia::math::Transform> {
- static SkMatrix44 Convert(const fuchsia::math::Transform& input);
-};
-template <>
-struct TypeConverter<fuchsia::math::Transform, SkMatrix44> {
- static fuchsia::math::Transform Convert(const SkMatrix44& input);
-};
-
-} // namespace fidl
-
-#endif // LIB_UI_SKIA_TYPE_CONVERTERS_H_
diff --git a/examples/ui/meta/ui_example.cmx b/examples/ui/meta/ui_example.cmx
deleted file mode 100644
index c982616..0000000
--- a/examples/ui/meta/ui_example.cmx
+++ /dev/null
@@ -1,15 +0,0 @@
-{
- "program": {
- "binary": "bin/app"
- },
- "sandbox": {
- "services": [
- "fuchsia.fonts.Provider",
- "fuchsia.sys.Environment",
- "fuchsia.sys.Launcher",
- "fuchsia.tracing.provider.Registry",
- "fuchsia.ui.policy.Presenter",
- "fuchsia.ui.scenic.Scenic"
- ]
- }
-}
diff --git a/examples/ui/noodles/BUILD.gn b/examples/ui/noodles/BUILD.gn
deleted file mode 100644
index 35614c8..0000000
--- a/examples/ui/noodles/BUILD.gn
+++ /dev/null
@@ -1,42 +0,0 @@
-# Copyright 2015 The Fuchsia Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-import("//build/package.gni")
-
-executable("bin") {
- output_name = "noodles"
-
- sources = [
- "main.cc",
- "noodles_view.cc",
- "noodles_view.h",
- ]
-
- deps = [
- "//garnet/public/lib/ui/base_view/cpp",
- "//sdk/fidl/fuchsia.images",
- "//sdk/lib/fidl/cpp",
- "//src/lib/fxl",
- "//third_party/skia",
- "//topaz/examples/ui/lib:skia_view",
- "//zircon/public/lib/async-loop-cpp",
- "//zircon/public/lib/async-loop-default",
- "//zircon/public/lib/trace-provider-with-fdio",
- ]
-}
-
-package("noodles") {
- deps = [
- ":bin",
- ]
-
- binary = "noodles"
-
- meta = [
- {
- path = rebase_path("../meta/ui_example.cmx")
- dest = "noodles.cmx"
- },
- ]
-}
diff --git a/examples/ui/noodles/README.md b/examples/ui/noodles/README.md
deleted file mode 100644
index fdc651e..0000000
--- a/examples/ui/noodles/README.md
+++ /dev/null
@@ -1,8 +0,0 @@
-# Scenic Skia Rendering Example
-
-This directory contains a simple application which draws a Lissajous figure
-using Skia.
-
-## USAGE
-
- launch noodles_view
diff --git a/examples/ui/noodles/main.cc b/examples/ui/noodles/main.cc
deleted file mode 100644
index dd7b14b..0000000
--- a/examples/ui/noodles/main.cc
+++ /dev/null
@@ -1,30 +0,0 @@
-// Copyright 2015 The Fuchsia 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 <lib/async-loop/cpp/loop.h>
-#include <lib/async-loop/default.h>
-#include <lib/trace-provider/provider.h>
-#include <lib/ui/base_view/cpp/view_provider_component.h>
-
-#include "src/lib/fxl/command_line.h"
-#include "src/lib/fxl/log_settings_command_line.h"
-#include "topaz/examples/ui/noodles/noodles_view.h"
-
-int main(int argc, const char** argv) {
- async::Loop loop(&kAsyncLoopConfigAttachToCurrentThread);
- trace::TraceProviderWithFdio trace_provider(loop.dispatcher());
-
- auto command_line = fxl::CommandLineFromArgcArgv(argc, argv);
- if (!fxl::SetLogSettingsFromCommandLine(command_line))
- return 1;
-
- scenic::ViewProviderComponent component(
- [](scenic::ViewContext view_context) {
- return std::make_unique<examples::NoodlesView>(std::move(view_context));
- },
- &loop);
-
- loop.Run();
- return 0;
-}
diff --git a/examples/ui/noodles/noodles_view.cc b/examples/ui/noodles/noodles_view.cc
deleted file mode 100644
index d5c8e97..0000000
--- a/examples/ui/noodles/noodles_view.cc
+++ /dev/null
@@ -1,89 +0,0 @@
-// Copyright 2015 The Fuchsia 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 "topaz/examples/ui/noodles/noodles_view.h"
-
-#include <math.h>
-
-#include <cstdlib>
-#include <utility>
-
-#include "src/lib/fxl/logging.h"
-#include "third_party/skia/include/core/SkCanvas.h"
-#include "third_party/skia/include/core/SkColor.h"
-#include "third_party/skia/include/core/SkImageInfo.h"
-#include "third_party/skia/include/core/SkPath.h"
-
-namespace examples {
-
-namespace {
-constexpr float kSecondsBetweenChanges = 10.f;
-constexpr float kSpeed = 1.f;
-constexpr float kSecondsPerNanosecond = .000'000'001f;
-
-void Lissajous(SkPath* path, double ax, double ay, int wx, int wy, double p) {
- uint32_t segments = ceil(fabs(ax) + fabs(ay)) / 2u + 1u;
- for (uint32_t i = 0; i < segments; ++i) {
- double t = M_PI * 2.0 * i / segments;
- double x = ax * sin(t * wx);
- double y = ay * sin(t * wy + p);
- if (i == 0u)
- path->moveTo(x, y);
- else
- path->lineTo(x, y);
- }
- path->close();
-}
-} // namespace
-
-NoodlesView::NoodlesView(scenic::ViewContext view_context)
- : SkiaView(std::move(view_context), "Noodles") {}
-
-void NoodlesView::OnSceneInvalidated(
- fuchsia::images::PresentationInfo presentation_info) {
- SkCanvas* canvas = AcquireCanvas();
- if (!canvas)
- return;
-
- // Update the animation state.
- uint64_t presentation_time = presentation_info.presentation_time;
- if (!start_time_ ||
- presentation_time - start_time_ >= ZX_SEC(kSecondsBetweenChanges)) {
- start_time_ = presentation_time;
- wx_ = rand() % 9 + 1;
- wy_ = rand() % 9 + 1;
- }
- const float phase =
- (presentation_time - start_time_) * kSecondsPerNanosecond * kSpeed;
- Draw(canvas, phase);
- ReleaseAndSwapCanvas();
-
- // Animate.
- InvalidateScene();
-}
-
-void NoodlesView::Draw(SkCanvas* canvas, float phase) {
- constexpr int count = 4;
- constexpr int padding = 1;
-
- canvas->clear(SK_ColorBLACK);
-
- double cx = logical_size().x * 0.5;
- double cy = logical_size().y * 0.5;
- canvas->translate(cx, cy);
-
- for (int i = 0; i < count; i++, phase += 0.1) {
- SkPaint paint;
- SkScalar hsv[3] = {static_cast<SkScalar>(fmod(phase * 120, 360)), 1, 1};
- paint.setColor(SkHSVToColor(hsv));
- paint.setStyle(SkPaint::kStroke_Style);
- paint.setAntiAlias(true);
-
- SkPath path;
- Lissajous(&path, cx - padding, cy - padding, wx_, wy_, phase);
- canvas->drawPath(path, paint);
- }
-}
-
-} // namespace examples
diff --git a/examples/ui/noodles/noodles_view.h b/examples/ui/noodles/noodles_view.h
deleted file mode 100644
index ca7f0bd..0000000
--- a/examples/ui/noodles/noodles_view.h
+++ /dev/null
@@ -1,41 +0,0 @@
-// Copyright 2015 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef TOPAZ_EXAMPLES_UI_NOODLES_NOODLES_VIEW_H_
-#define TOPAZ_EXAMPLES_UI_NOODLES_NOODLES_VIEW_H_
-
-#include <fuchsia/images/cpp/fidl.h>
-
-#include "examples/ui/lib/skia_view.h"
-#include "src/lib/fxl/macros.h"
-
-class SkCanvas;
-
-namespace examples {
-
-class Frame;
-class Rasterizer;
-
-class NoodlesView : public scenic::SkiaView {
- public:
- NoodlesView(scenic::ViewContext view_context);
- ~NoodlesView() override = default;
-
- private:
- // |scenic::BaseView|
- void OnSceneInvalidated(
- fuchsia::images::PresentationInfo presentation_info) override;
-
- void Draw(SkCanvas* canvas, float t);
-
- uint64_t start_time_ = 0u;
- int wx_ = 0;
- int wy_ = 0;
-
- FXL_DISALLOW_COPY_AND_ASSIGN(NoodlesView);
-};
-
-} // namespace examples
-
-#endif // TOPAZ_EXAMPLES_UI_NOODLES_NOODLES_VIEW_H_
diff --git a/examples/ui/paint/BUILD.gn b/examples/ui/paint/BUILD.gn
deleted file mode 100644
index 84de1c0..0000000
--- a/examples/ui/paint/BUILD.gn
+++ /dev/null
@@ -1,46 +0,0 @@
-# Copyright 2016 The Fuchsia Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-import("//build/package.gni")
-
-executable("paint") {
- output_name = "paint_view"
-
- sources = [
- "main.cc",
- "paint_view.cc",
- "paint_view.h",
- ]
-
- deps = [
- "//garnet/public/lib/ui/base_view/cpp",
- "//sdk/fidl/fuchsia.images",
- "//sdk/fidl/fuchsia.ui.input",
- "//sdk/lib/fidl/cpp",
- "//src/lib/fxl",
- "//third_party/skia",
- "//topaz/examples/ui/lib:skia_view",
- "//zircon/public/lib/async-loop-cpp",
- "//zircon/public/lib/async-loop-default",
- "//zircon/public/lib/hid",
- "//zircon/public/lib/trace-provider-with-fdio",
- ]
-}
-
-package("package") {
- package_name = "paint"
-
- deps = [
- ":paint",
- ]
-
- binary = "paint_view"
-
- meta = [
- {
- path = rebase_path("../meta/ui_example.cmx")
- dest = "paint.cmx"
- },
- ]
-}
diff --git a/examples/ui/paint/README.md b/examples/ui/paint/README.md
deleted file mode 100644
index b5579c4..0000000
--- a/examples/ui/paint/README.md
+++ /dev/null
@@ -1,8 +0,0 @@
-# Scenic Paint Example
-
-This directory contains a basic paint application using Skia to demonstrate
-input usage.
-
-## USAGE
-
- launch paint_view
diff --git a/examples/ui/paint/main.cc b/examples/ui/paint/main.cc
deleted file mode 100644
index 210e9b3..0000000
--- a/examples/ui/paint/main.cc
+++ /dev/null
@@ -1,29 +0,0 @@
-// Copyright 2017 The Fuchsia 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 <lib/async-loop/cpp/loop.h>
-#include <lib/async-loop/default.h>
-#include <lib/trace-provider/provider.h>
-#include <lib/ui/base_view/cpp/view_provider_component.h>
-
-#include "src/lib/fxl/command_line.h"
-#include "src/lib/fxl/log_settings_command_line.h"
-#include "topaz/examples/ui/paint/paint_view.h"
-int main(int argc, const char** argv) {
- async::Loop loop(&kAsyncLoopConfigAttachToCurrentThread);
- trace::TraceProviderWithFdio trace_provider(loop.dispatcher());
-
- auto command_line = fxl::CommandLineFromArgcArgv(argc, argv);
- if (!fxl::SetLogSettingsFromCommandLine(command_line))
- return 1;
-
- scenic::ViewProviderComponent component(
- [](scenic::ViewContext view_context) {
- return std::make_unique<examples::PaintView>(std::move(view_context));
- },
- &loop);
-
- loop.Run();
- return 0;
-}
diff --git a/examples/ui/paint/paint_view.cc b/examples/ui/paint/paint_view.cc
deleted file mode 100644
index 477254c..0000000
--- a/examples/ui/paint/paint_view.cc
+++ /dev/null
@@ -1,104 +0,0 @@
-// Copyright 2016 The Fuchsia 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 "topaz/examples/ui/paint/paint_view.h"
-
-#include <hid/usages.h>
-
-#include "src/lib/fxl/logging.h"
-#include "src/lib/fxl/macros.h"
-#include "third_party/skia/include/core/SkColor.h"
-#include "third_party/skia/include/core/SkRect.h"
-
-namespace examples {
-
-PaintView::PaintView(scenic::ViewContext view_context)
- : SkiaView(std::move(view_context), "Paint") {}
-
-void PaintView::OnSceneInvalidated(
- fuchsia::images::PresentationInfo presentation_info) {
- SkCanvas* canvas = AcquireCanvas();
- if (!canvas)
- return;
-
- DrawContent(canvas);
- ReleaseAndSwapCanvas();
-}
-
-void PaintView::DrawContent(SkCanvas* canvas) {
- canvas->clear(SK_ColorWHITE);
-
- SkPaint paint;
- paint.setColor(0xFFFF00FF);
- paint.setAntiAlias(true);
- paint.setStyle(SkPaint::kStroke_Style);
- paint.setStrokeWidth(SkIntToScalar(3));
-
- for (auto path : paths_) {
- canvas->drawPath(path, paint);
- }
-
- paint.setColor(SK_ColorBLUE);
- for (auto iter = points_.begin(); iter != points_.end(); ++iter) {
- if (!iter->second.empty()) {
- canvas->drawPath(CurrentPath(iter->first), paint);
- }
- }
-}
-
-SkPath PaintView::CurrentPath(uint32_t pointer_id) {
- SkPath path;
- if (points_.count(pointer_id)) {
- uint32_t count = 0;
- for (auto point : points_.at(pointer_id)) {
- if (count++ == 0) {
- path.moveTo(point);
- } else {
- path.lineTo(point);
- }
- }
- }
- return path;
-}
-
-void PaintView::OnInputEvent(fuchsia::ui::input::InputEvent event) {
- if (event.is_pointer()) {
- const fuchsia::ui::input::PointerEvent& pointer = event.pointer();
- uint32_t pointer_id = pointer.device_id * 32 + pointer.pointer_id;
- switch (pointer.phase) {
- case fuchsia::ui::input::PointerEventPhase::DOWN:
- case fuchsia::ui::input::PointerEventPhase::MOVE:
- // On down + move, keep appending points to the path being built
- // For mouse only draw if left button is pressed
- if (pointer.type == fuchsia::ui::input::PointerEventType::TOUCH ||
- pointer.type == fuchsia::ui::input::PointerEventType::STYLUS ||
- (pointer.type == fuchsia::ui::input::PointerEventType::MOUSE &&
- pointer.buttons & fuchsia::ui::input::kMousePrimaryButton)) {
- if (!points_.count(pointer_id)) {
- points_[pointer_id] = std::vector<SkPoint>();
- }
- points_.at(pointer_id).push_back(SkPoint::Make(pointer.x, pointer.y));
- }
- break;
- case fuchsia::ui::input::PointerEventPhase::UP:
- // Path is done, add it to the list of paths and reset the list of
- // points
- paths_.push_back(CurrentPath(pointer_id));
- points_.erase(pointer_id);
- break;
- default:
- break;
- }
- } else if (event.is_keyboard()) {
- const fuchsia::ui::input::KeyboardEvent& keyboard = event.keyboard();
- if (keyboard.hid_usage == HID_USAGE_KEY_ESC) {
- // clear
- paths_.clear();
- }
- }
-
- InvalidateScene();
-}
-
-} // namespace examples
diff --git a/examples/ui/paint/paint_view.h b/examples/ui/paint/paint_view.h
deleted file mode 100644
index c510267..0000000
--- a/examples/ui/paint/paint_view.h
+++ /dev/null
@@ -1,43 +0,0 @@
-// Copyright 2016 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef TOPAZ_EXAMPLES_UI_PAINT_PAINT_VIEW_H_
-#define TOPAZ_EXAMPLES_UI_PAINT_PAINT_VIEW_H_
-
-#include <fuchsia/images/cpp/fidl.h>
-#include <fuchsia/ui/input/cpp/fidl.h>
-
-#include <map>
-#include <vector>
-
-#include "examples/ui/lib/skia_view.h"
-#include "src/lib/fxl/macros.h"
-#include "third_party/skia/include/core/SkCanvas.h"
-#include "third_party/skia/include/core/SkPath.h"
-
-namespace examples {
-
-class PaintView : public scenic::SkiaView {
- public:
- PaintView(scenic::ViewContext view_context);
- ~PaintView() override = default;
-
- private:
- // |scenic::BaseView|
- void OnSceneInvalidated(
- fuchsia::images::PresentationInfo presentation_info) override;
- void OnInputEvent(fuchsia::ui::input::InputEvent event) override;
-
- void DrawContent(SkCanvas* canvas);
- SkPath CurrentPath(uint32_t pointer_id);
-
- std::map<uint32_t, std::vector<SkPoint>> points_;
- std::vector<SkPath> paths_;
-
- FXL_DISALLOW_COPY_AND_ASSIGN(PaintView);
-};
-
-} // namespace examples
-
-#endif // TOPAZ_EXAMPLES_UI_PAINT_PAINT_VIEW_H_
diff --git a/examples/ui/text_flutter/README.md b/examples/ui/text_flutter/README.md
deleted file mode 100644
index 5bf582c..0000000
--- a/examples/ui/text_flutter/README.md
+++ /dev/null
@@ -1,8 +0,0 @@
-# Text Input Example for Flutter
-
-## Usage
-
-```shell
-$ present_view fuchsia-pkg://fuchsia.com/text_flutter#meta/text_flutter.cmx
-```
-
diff --git a/public/dart/widgets/BUILD.gn b/public/dart/widgets/BUILD.gn
index df36bb5..c483ecb 100644
--- a/public/dart/widgets/BUILD.gn
+++ b/public/dart/widgets/BUILD.gn
@@ -46,7 +46,6 @@
"//sdk/fidl/fuchsia.ui.views",
"//third_party/dart-pkg/git/flutter/packages/flutter",
"//third_party/dart-pkg/pub/flutter_image",
- "//topaz/bin/ui/skottie_viewer:skottie_loader",
"//topaz/public/dart/fidl",
"//topaz/public/dart/fuchsia_logger",
"//topaz/public/dart/fuchsia_scenic_flutter",