Delete the Surfaces service.
This service has been superceded by the Mozart compositor.
BUG=
Review URL: https://codereview.chromium.org/1534693002 .
diff --git a/examples/bitmap_uploader/BUILD.gn b/examples/bitmap_uploader/BUILD.gn
deleted file mode 100644
index 9d21e86..0000000
--- a/examples/bitmap_uploader/BUILD.gn
+++ /dev/null
@@ -1,30 +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.
-
-source_set("bitmap_uploader") {
- sources = [
- "bitmap_uploader.cc",
- "bitmap_uploader.h",
- ]
-
- public_deps = [
- "//base",
- "//mojo/public/c/gpu",
- "//mojo/services/gpu/interfaces",
- "//mojo/services/surfaces/interfaces",
- ]
- deps = [
- "//mojo/application",
- "//mojo/public/cpp/bindings:bindings",
- "//mojo/public/interfaces/application",
- "//mojo/services/geometry/cpp",
- "//mojo/services/geometry/interfaces",
- "//mojo/services/input_events/interfaces",
- "//mojo/services/surfaces/cpp",
- "//mojo/services/surfaces/interfaces:surface_id",
- "//mojo/services/view_manager/cpp",
- "//mojo/services/view_manager/interfaces",
- "//ui/gfx/geometry",
- ]
-}
diff --git a/examples/bitmap_uploader/bitmap_uploader.cc b/examples/bitmap_uploader/bitmap_uploader.cc
deleted file mode 100644
index f1fd4b1..0000000
--- a/examples/bitmap_uploader/bitmap_uploader.cc
+++ /dev/null
@@ -1,276 +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 "examples/bitmap_uploader/bitmap_uploader.h"
-
-#ifndef GL_GLEXT_PROTOTYPES
-#define GL_GLEXT_PROTOTYPES
-#endif // GL_GLEXT_PROTOTYPES
-
-#include <GLES2/gl2.h>
-#include <GLES2/gl2extmojo.h>
-#include <MGL/mgl.h>
-
-#include "base/bind.h"
-#include "mojo/public/cpp/application/connect.h"
-#include "mojo/public/interfaces/application/shell.mojom.h"
-#include "mojo/services/geometry/cpp/geometry_util.h"
-#include "mojo/services/surfaces/cpp/surfaces_utils.h"
-#include "mojo/services/view_manager/cpp/lib/view_manager_client_impl.h"
-#include "ui/gfx/geometry/rect.h"
-
-#define TRANSPARENT_COLOR 0x00000000
-
-namespace mojo {
-
-namespace {
-void LostContext(void*) {
- DCHECK(false);
-}
-
-}
-
-BitmapUploader::BitmapUploader(View* view)
- : view_(view),
- color_(TRANSPARENT_COLOR),
- width_(0),
- height_(0),
- format_(BGRA),
- next_resource_id_(1u),
- id_namespace_(0u),
- local_id_(0u),
- returner_binding_(this) {
-}
-
-void BitmapUploader::Init(Shell* shell) {
- ServiceProviderPtr surfaces_service_provider;
- shell->ConnectToApplication("mojo:surfaces_service",
- GetProxy(&surfaces_service_provider), nullptr);
- ConnectToService(surfaces_service_provider.get(), &surface_);
- surface_->GetIdNamespace(
- base::Bind(&BitmapUploader::SetIdNamespace, base::Unretained(this)));
- mojo::ResourceReturnerPtr returner_ptr;
- returner_binding_.Bind(GetProxy(&returner_ptr));
- surface_->SetResourceReturner(returner_ptr.Pass());
-
- ServiceProviderPtr gpu_service_provider;
- shell->ConnectToApplication("mojo:native_viewport_service",
- GetProxy(&gpu_service_provider), nullptr);
- ConnectToService(gpu_service_provider.get(), &gpu_service_);
-
- CommandBufferPtr gles2_client;
- gpu_service_->CreateOffscreenGLES2Context(GetProxy(&gles2_client));
- mgl_context_ = MGLCreateContext(
- MGL_API_VERSION_GLES2,
- gles2_client.PassInterface().PassHandle().release().value(),
- MGL_NO_CONTEXT, &LostContext, nullptr,
- Environment::GetDefaultAsyncWaiter());
- MGLMakeCurrent(mgl_context_);
-}
-
-BitmapUploader::~BitmapUploader() {
- MGLDestroyContext(mgl_context_);
-}
-
-void BitmapUploader::SetColor(uint32_t color) {
- if (color_ == color)
- return;
- color_ = color;
- if (surface_)
- Upload();
-}
-
-void BitmapUploader::SetBitmap(int width,
- int height,
- scoped_ptr<std::vector<unsigned char>> data,
- Format format) {
- width_ = width;
- height_ = height;
- bitmap_ = data.Pass();
- format_ = format;
- if (surface_)
- Upload();
-}
-
-void BitmapUploader::Upload() {
- Size size;
- size.width = view_->bounds().width;
- size.height = view_->bounds().height;
- if (!size.width || !size.height) {
- view_->SetSurfaceId(SurfaceId::New());
- return;
- }
- if (id_namespace_ == 0u) // Can't generate a qualified ID yet.
- return;
-
- if (size != surface_size_) {
- if (local_id_ != 0u) {
- surface_->DestroySurface(local_id_);
- }
- local_id_++;
- surface_->CreateSurface(local_id_);
- surface_size_ = size;
- auto qualified_id = SurfaceId::New();
- qualified_id->id_namespace = id_namespace_;
- qualified_id->local = local_id_;
- view_->SetSurfaceId(qualified_id.Pass());
- }
-
- Rect bounds;
- bounds.width = size.width;
- bounds.height = size.height;
- PassPtr pass = CreateDefaultPass(1, bounds);
- FramePtr frame = Frame::New();
- frame->resources.resize(0u);
-
- pass->quads.resize(0u);
- pass->shared_quad_states.push_back(CreateDefaultSQS(size));
-
- MGLMakeCurrent(mgl_context_);
- if (bitmap_.get()) {
- Size bitmap_size;
- bitmap_size.width = width_;
- bitmap_size.height = height_;
- GLuint texture_id = BindTextureForSize(bitmap_size);
- glTexSubImage2D(GL_TEXTURE_2D,
- 0,
- 0,
- 0,
- bitmap_size.width,
- bitmap_size.height,
- TextureFormat(),
- GL_UNSIGNED_BYTE,
- &((*bitmap_)[0]));
-
- GLbyte mailbox[GL_MAILBOX_SIZE_CHROMIUM];
- glGenMailboxCHROMIUM(mailbox);
- glProduceTextureCHROMIUM(GL_TEXTURE_2D, mailbox);
- GLuint sync_point = glInsertSyncPointCHROMIUM();
-
- TransferableResourcePtr resource = TransferableResource::New();
- resource->id = next_resource_id_++;
- resource_to_texture_id_map_[resource->id] = texture_id;
- resource->format = mojo::ResourceFormat::RGBA_8888;
- resource->filter = GL_LINEAR;
- resource->size = bitmap_size.Clone();
- MailboxHolderPtr mailbox_holder = MailboxHolder::New();
- mailbox_holder->mailbox = Mailbox::New();
- for (int i = 0; i < GL_MAILBOX_SIZE_CHROMIUM; ++i)
- mailbox_holder->mailbox->name.push_back(mailbox[i]);
- mailbox_holder->texture_target = GL_TEXTURE_2D;
- mailbox_holder->sync_point = sync_point;
- resource->mailbox_holder = mailbox_holder.Pass();
- resource->is_repeated = false;
- resource->is_software = false;
-
- QuadPtr quad = Quad::New();
- quad->material = Material::TEXTURE_CONTENT;
-
- RectPtr rect = Rect::New();
- if (width_ <= size.width && height_ <= size.height) {
- rect->width = width_;
- rect->height = height_;
- } else {
- // The source bitmap is larger than the viewport. Resize it while
- // maintaining the aspect ratio.
- float width_ratio = static_cast<float>(width_) / size.width;
- float height_ratio = static_cast<float>(height_) / size.height;
- if (width_ratio > height_ratio) {
- rect->width = size.width;
- rect->height = height_ / width_ratio;
- } else {
- rect->height = size.height;
- rect->width = width_ / height_ratio;
- }
- }
- quad->rect = rect.Clone();
- quad->opaque_rect = rect.Clone();
- quad->visible_rect = rect.Clone();
- quad->needs_blending = true;
- quad->shared_quad_state_index = 0u;
-
- TextureQuadStatePtr texture_state = TextureQuadState::New();
- texture_state->resource_id = resource->id;
- texture_state->premultiplied_alpha = true;
- texture_state->uv_top_left = PointF::New();
- texture_state->uv_bottom_right = PointF::New();
- texture_state->uv_bottom_right->x = 1.f;
- texture_state->uv_bottom_right->y = 1.f;
- texture_state->background_color = Color::New();
- texture_state->background_color->rgba = TRANSPARENT_COLOR;
- for (int i = 0; i < 4; ++i)
- texture_state->vertex_opacity.push_back(1.f);
- texture_state->flipped = false;
-
- frame->resources.push_back(resource.Pass());
- quad->texture_quad_state = texture_state.Pass();
- pass->quads.push_back(quad.Pass());
- }
-
- if (color_ != TRANSPARENT_COLOR) {
- QuadPtr quad = Quad::New();
- quad->material = Material::SOLID_COLOR;
- quad->rect = bounds.Clone();
- quad->opaque_rect = Rect::New();
- quad->visible_rect = bounds.Clone();
- quad->needs_blending = true;
- quad->shared_quad_state_index = 0u;
-
- SolidColorQuadStatePtr color_state = SolidColorQuadState::New();
- color_state->color = Color::New();
- color_state->color->rgba = color_;
- color_state->force_anti_aliasing_off = false;
-
- quad->solid_color_quad_state = color_state.Pass();
- pass->quads.push_back(quad.Pass());
- }
-
- frame->passes.push_back(pass.Pass());
-
- surface_->SubmitFrame(local_id_, frame.Pass(), mojo::Closure());
-}
-
-void BitmapUploader::SetIdNamespace(uint32_t id_namespace) {
- id_namespace_ = id_namespace;
- if (color_ != TRANSPARENT_COLOR || bitmap_.get())
- Upload();
-}
-
-void BitmapUploader::ReturnResources(Array<ReturnedResourcePtr> resources) {
- MGLMakeCurrent(mgl_context_);
- // TODO(jamesr): Recycle.
- for (size_t i = 0; i < resources.size(); ++i) {
- ReturnedResourcePtr resource = resources[i].Pass();
- DCHECK_EQ(1, resource->count);
- glWaitSyncPointCHROMIUM(resource->sync_point);
- uint32_t texture_id = resource_to_texture_id_map_[resource->id];
- DCHECK_NE(0u, texture_id);
- resource_to_texture_id_map_.erase(resource->id);
- glDeleteTextures(1, &texture_id);
- }
-}
-
-uint32_t BitmapUploader::BindTextureForSize(const Size size) {
- // TODO(jamesr): Recycle textures.
- GLuint texture = 0u;
- glGenTextures(1, &texture);
- glBindTexture(GL_TEXTURE_2D, texture);
- glTexImage2D(GL_TEXTURE_2D,
- 0,
- TextureFormat(),
- size.width,
- size.height,
- 0,
- TextureFormat(),
- GL_UNSIGNED_BYTE,
- 0);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
- return texture;
-}
-
-uint32_t BitmapUploader::TextureFormat() {
- return format_ == BGRA ? GL_BGRA_EXT : GL_RGBA;
-}
-
-} // namespace mojo
diff --git a/examples/bitmap_uploader/bitmap_uploader.h b/examples/bitmap_uploader/bitmap_uploader.h
deleted file mode 100644
index e07791a..0000000
--- a/examples/bitmap_uploader/bitmap_uploader.h
+++ /dev/null
@@ -1,78 +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.
-
-#ifndef EXAMPLES_BITMAP_UPLOADER_BITMAP_UPLOADER_H_
-#define EXAMPLES_BITMAP_UPLOADER_BITMAP_UPLOADER_H_
-
-#include <MGL/mgl_types.h>
-
-#include "base/callback.h"
-#include "base/containers/hash_tables.h"
-#include "base/memory/scoped_ptr.h"
-#include "mojo/public/cpp/bindings/binding.h"
-#include "mojo/services/geometry/interfaces/geometry.mojom.h"
-#include "mojo/services/gpu/interfaces/gpu.mojom.h"
-#include "mojo/services/surfaces/interfaces/surface_id.mojom.h"
-#include "mojo/services/surfaces/interfaces/surfaces.mojom.h"
-
-namespace mojo {
-class Shell;
-class View;
-
-// BitmapUploader is useful if you want to draw a bitmap or color in a View.
-class BitmapUploader : public ResourceReturner {
- public:
- explicit BitmapUploader(View* view);
- ~BitmapUploader() override;
-
- void Init(Shell* shell);
-
- // Sets the color which is RGBA.
- void SetColor(uint32_t color);
-
- enum Format {
- RGBA, // Pixel layout on Android.
- BGRA, // Pixel layout everywhere else.
- };
-
- // Sets a bitmap.
- void SetBitmap(int width,
- int height,
- scoped_ptr<std::vector<unsigned char>> data,
- Format format);
-
- private:
- void Upload();
- uint32_t BindTextureForSize(const Size size);
- uint32_t TextureFormat();
-
- void SetIdNamespace(uint32_t id_namespace);
-
- // ResourceReturner implementation.
- void ReturnResources(Array<ReturnedResourcePtr> resources) override;
-
- View* view_;
- GpuPtr gpu_service_;
- MGLContext mgl_context_;
-
- Size size_;
- uint32_t color_;
- int width_;
- int height_;
- Format format_;
- scoped_ptr<std::vector<unsigned char>> bitmap_;
- SurfacePtr surface_;
- Size surface_size_;
- uint32_t next_resource_id_;
- uint32_t id_namespace_;
- uint32_t local_id_;
- base::hash_map<uint32_t, uint32_t> resource_to_texture_id_map_;
- mojo::Binding<mojo::ResourceReturner> returner_binding_;
-
- DISALLOW_COPY_AND_ASSIGN(BitmapUploader);
-};
-
-} // namespace mojo
-
-#endif // EXAMPLES_BITMAP_UPLOADER_BITMAP_UPLOADER_H_
diff --git a/examples/surfaces_app/BUILD.gn b/examples/surfaces_app/BUILD.gn
deleted file mode 100644
index 25a0b86..0000000
--- a/examples/surfaces_app/BUILD.gn
+++ /dev/null
@@ -1,142 +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.
-
-import("//mojo/public/mojo_application.gni")
-import("//mojo/public/tools/bindings/mojom.gni")
-
-group("surfaces_app") {
- deps = [
- ":child_app",
- ":child_gl_app",
- ":parent_app",
- ]
-}
-
-mojo_native_application("parent_app") {
- output_name = "surfaces_app"
-
- deps = [
- ":bindings",
- ":util",
- "//base",
- "//cc",
- "//cc/surfaces",
- "//cc/surfaces:surface_id",
- "//skia",
- "//ui/gfx",
- "//ui/gfx/geometry",
- "//mojo/application",
- "//mojo/common",
- "//mojo/converters/geometry",
- "//mojo/converters/surfaces",
- "//mojo/environment:chromium",
- "//mojo/public/cpp/system",
- "//mojo/services/geometry/interfaces",
- "//mojo/services/gpu/interfaces",
- "//mojo/services/native_viewport/interfaces",
- "//mojo/services/surfaces/interfaces",
- ]
-
- sources = [
- "embedder.cc",
- "embedder.h",
- "surfaces_app.cc",
- ]
-}
-
-mojo_native_application("child_app") {
- output_name = "surfaces_child_app"
-
- deps = [
- ":bindings",
- ":util",
- "//base",
- "//cc",
- "//cc/surfaces",
- "//cc/surfaces:surface_id",
- "//mojo/application",
- "//mojo/common",
- "//mojo/converters/geometry",
- "//mojo/converters/surfaces",
- "//mojo/environment:chromium",
- "//mojo/public/cpp/bindings",
- "//mojo/services/geometry/interfaces",
- "//mojo/services/surfaces/interfaces",
- "//mojo/services/surfaces/interfaces:surface_id",
- "//skia",
- "//ui/gfx",
- "//ui/gfx/geometry",
- ]
-
- sources = [
- "child_app.cc",
- "child_impl.cc",
- "child_impl.h",
- ]
-}
-
-mojo_native_application("child_gl_app") {
- output_name = "surfaces_child_gl_app"
-
- deps = [
- ":bindings",
- ":util",
- "//base",
- "//cc",
- "//cc/surfaces",
- "//cc/surfaces:surface_id",
- "//examples/spinning_cube:lib",
- "//gpu/command_buffer/common",
- "//mojo/application",
- "//mojo/common",
- "//mojo/converters/geometry",
- "//mojo/converters/surfaces",
- "//mojo/environment:chromium",
- "//mojo/public/c/gpu",
- "//mojo/public/cpp/bindings",
- "//mojo/public/cpp/environment",
- "//mojo/public/cpp/system",
- "//mojo/services/geometry/interfaces",
- "//mojo/services/gpu/interfaces",
- "//mojo/services/surfaces/interfaces",
- "//mojo/services/surfaces/interfaces:surface_id",
- "//skia",
- "//ui/gfx",
- "//ui/gfx/geometry",
- ]
-
- sources = [
- "child_gl_app.cc",
- "child_gl_impl.cc",
- "child_gl_impl.h",
- ]
-}
-
-source_set("util") {
- deps = [
- "//cc",
- "//skia",
- "//ui/gfx",
- "//ui/gfx/geometry",
- ]
-
- sources = [
- "surfaces_util.cc",
- "surfaces_util.h",
- ]
-}
-
-mojom("bindings") {
- deps = [
- "//mojo/services/geometry/interfaces",
- "//mojo/services/surfaces/interfaces",
- "//mojo/services/surfaces/interfaces:surface_id",
- ]
-
- import_dirs = [ get_path_info("../../mojo/services", "abspath") ]
-
- sources = [
- "child.mojom",
- ]
-}
diff --git a/examples/surfaces_app/child.mojom b/examples/surfaces_app/child.mojom
deleted file mode 100644
index 78392d0..0000000
--- a/examples/surfaces_app/child.mojom
+++ /dev/null
@@ -1,13 +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.
-
-import "mojo/services/geometry/interfaces/geometry.mojom";
-import "mojo/services/surfaces/interfaces/quads.mojom";
-import "mojo/services/surfaces/interfaces/surface_id.mojom";
-
-[ServiceName="Child"]
-interface Child {
- ProduceFrame(mojo.Color color, mojo.Size size) =>
- (mojo.SurfaceId id);
-};
diff --git a/examples/surfaces_app/child_app.cc b/examples/surfaces_app/child_app.cc
deleted file mode 100644
index 1429223..0000000
--- a/examples/surfaces_app/child_app.cc
+++ /dev/null
@@ -1,51 +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 "examples/surfaces_app/child_impl.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/public/cpp/bindings/string.h"
-
-namespace mojo {
-namespace examples {
-
-class ChildApp : public ApplicationDelegate, public InterfaceFactory<Child> {
- public:
- ChildApp() {}
- ~ChildApp() override {}
-
- void Initialize(ApplicationImpl* app) override {
- surfaces_service_connection_ =
- app->ConnectToApplication("mojo:surfaces_service");
- }
-
- // ApplicationDelegate implementation.
- bool ConfigureIncomingConnection(ApplicationConnection* connection) override {
- connection->AddService(this);
- return true;
- }
-
- // InterfaceFactory<Child> implementation.
- void Create(ApplicationConnection* connection,
- InterfaceRequest<Child> request) override {
- new ChildImpl(surfaces_service_connection_, request.Pass());
- }
-
- private:
- ApplicationConnection* surfaces_service_connection_;
-
- DISALLOW_COPY_AND_ASSIGN(ChildApp);
-};
-
-} // namespace examples
-} // namespace mojo
-
-MojoResult MojoMain(MojoHandle application_request) {
- mojo::ApplicationRunnerChromium runner(new mojo::examples::ChildApp);
- return runner.Run(application_request);
-}
diff --git a/examples/surfaces_app/child_gl_app.cc b/examples/surfaces_app/child_gl_app.cc
deleted file mode 100644
index 029fbfc..0000000
--- a/examples/surfaces_app/child_gl_app.cc
+++ /dev/null
@@ -1,60 +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 "base/threading/platform_thread.h"
-#include "examples/surfaces_app/child_gl_impl.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/public/cpp/bindings/string.h"
-#include "mojo/services/gpu/interfaces/gpu.mojom.h"
-
-namespace mojo {
-namespace examples {
-
-class ChildGLApp : public ApplicationDelegate, public InterfaceFactory<Child> {
- public:
- ChildGLApp() {}
- ~ChildGLApp() override {}
-
- void Initialize(ApplicationImpl* app) override {
- surfaces_service_connection_ =
- app->ConnectToApplication("mojo:surfaces_service");
- // TODO(jamesr): Should be mojo:gpu_service
- app->ConnectToService("mojo:native_viewport_service", &gpu_service_);
- }
-
- // ApplicationDelegate implementation.
- bool ConfigureIncomingConnection(
- ApplicationConnection* connection) override {
- connection->AddService(this);
- return true;
- }
-
- // InterfaceFactory<Child> implementation.
- void Create(ApplicationConnection* connection,
- InterfaceRequest<Child> request) override {
- CommandBufferPtr command_buffer;
- gpu_service_->CreateOffscreenGLES2Context(GetProxy(&command_buffer));
- new ChildGLImpl(surfaces_service_connection_, command_buffer.Pass(),
- request.Pass());
- }
-
- private:
- ApplicationConnection* surfaces_service_connection_;
- GpuPtr gpu_service_;
-
- DISALLOW_COPY_AND_ASSIGN(ChildGLApp);
-};
-
-} // namespace examples
-} // namespace mojo
-
-MojoResult MojoMain(MojoHandle application_request) {
- mojo::ApplicationRunnerChromium runner(new mojo::examples::ChildGLApp);
- return runner.Run(application_request);
-}
diff --git a/examples/surfaces_app/child_gl_impl.cc b/examples/surfaces_app/child_gl_impl.cc
deleted file mode 100644
index c1ec508..0000000
--- a/examples/surfaces_app/child_gl_impl.cc
+++ /dev/null
@@ -1,207 +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 "examples/surfaces_app/child_gl_impl.h"
-
-#ifndef GL_GLEXT_PROTOTYPES
-#define GL_GLEXT_PROTOTYPES
-#endif
-
-#include <GLES2/gl2ext.h>
-#include <GLES2/gl2extmojo.h>
-#include <MGL/mgl.h>
-
-#include "base/bind.h"
-#include "base/message_loop/message_loop.h"
-#include "cc/output/compositor_frame.h"
-#include "cc/output/delegated_frame_data.h"
-#include "cc/quads/render_pass.h"
-#include "cc/quads/texture_draw_quad.h"
-#include "examples/surfaces_app/surfaces_util.h"
-#include "gpu/command_buffer/common/mailbox.h"
-#include "gpu/command_buffer/common/mailbox_holder.h"
-#include "mojo/converters/geometry/geometry_type_converters.h"
-#include "mojo/converters/surfaces/surfaces_type_converters.h"
-#include "mojo/public/cpp/application/application_connection.h"
-#include "mojo/public/cpp/environment/environment.h"
-#include "mojo/services/surfaces/interfaces/surface_id.mojom.h"
-#include "mojo/services/surfaces/interfaces/surfaces.mojom.h"
-#include "ui/gfx/rect.h"
-#include "ui/gfx/transform.h"
-
-namespace mojo {
-namespace examples {
-
-using cc::RenderPass;
-using cc::RenderPassId;
-using cc::TextureDrawQuad;
-using cc::DelegatedFrameData;
-using cc::CompositorFrame;
-
-static void ContextLostThunk(void*) {
- LOG(FATAL) << "Context lost";
-}
-
-ChildGLImpl::ChildGLImpl(ApplicationConnection* surfaces_service_connection,
- CommandBufferPtr command_buffer,
- InterfaceRequest<Child> request)
- : id_namespace_(0u),
- local_id_(1u),
- start_time_(base::TimeTicks::Now()),
- next_resource_id_(1),
- returner_binding_(this),
- binding_(this, request.Pass()) {
- surfaces_service_connection->ConnectToService(&surface_);
- surface_->GetIdNamespace(
- base::Bind(&ChildGLImpl::SetIdNamespace, base::Unretained(this)));
- ResourceReturnerPtr returner_ptr;
- returner_binding_.Bind(GetProxy(&returner_ptr));
- surface_->SetResourceReturner(returner_ptr.Pass());
- context_ = MGLCreateContext(
- MGL_API_VERSION_GLES2,
- command_buffer.PassInterface().PassHandle().release().value(),
- MGL_NO_CONTEXT, &ContextLostThunk, this,
- Environment::GetDefaultAsyncWaiter());
- DCHECK(context_);
- MGLMakeCurrent(context_);
-}
-
-ChildGLImpl::~ChildGLImpl() {
- MGLDestroyContext(context_);
- surface_->DestroySurface(local_id_);
-}
-
-void ChildGLImpl::ProduceFrame(ColorPtr color,
- SizePtr size,
- const ProduceCallback& callback) {
- color_ = color.To<SkColor>();
- size_ = size.To<gfx::Size>();
- cube_.Init();
- cube_.set_size(size_.width(), size_.height());
- cube_.set_color(
- SkColorGetR(color_), SkColorGetG(color_), SkColorGetB(color_));
- surface_->CreateSurface(local_id_);
- produce_callback_ = callback;
- if (id_namespace_ != 0u)
- RunProduceCallback();
- Draw();
-}
-
-void ChildGLImpl::SetIdNamespace(uint32_t id_namespace) {
- id_namespace_ = id_namespace;
- if (!produce_callback_.is_null())
- RunProduceCallback();
- produce_callback_.reset();
-}
-
-void ChildGLImpl::RunProduceCallback() {
- auto id = SurfaceId::New();
- id->id_namespace = id_namespace_;
- id->local = local_id_;
- produce_callback_.Run(id.Pass());
-}
-
-void ChildGLImpl::ReturnResources(Array<ReturnedResourcePtr> resources) {
- for (size_t i = 0; i < resources.size(); ++i) {
- cc::ReturnedResource res = resources[i].To<cc::ReturnedResource>();
- GLuint returned_texture = id_to_tex_map_[res.id];
- glDeleteTextures(1, &returned_texture);
- }
-}
-
-void ChildGLImpl::Draw() {
- // First, generate a GL texture and draw the cube into it.
- GLuint texture = 0u;
- glGenTextures(1, &texture);
- glBindTexture(GL_TEXTURE_2D, texture);
- glTexImage2D(GL_TEXTURE_2D,
- 0,
- GL_RGBA,
- size_.width(),
- size_.height(),
- 0,
- GL_RGBA,
- GL_UNSIGNED_BYTE,
- 0);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
- GLuint fbo = 0u;
- glGenFramebuffers(1, &fbo);
- glBindFramebuffer(GL_FRAMEBUFFER, fbo);
- GLuint depth_buffer = 0u;
- glGenRenderbuffers(1, &depth_buffer);
- glBindRenderbuffer(GL_RENDERBUFFER, depth_buffer);
- glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT16, size_.width(),
- size_.height());
- glFramebufferTexture2D(
- GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture, 0);
- glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT,
- GL_RENDERBUFFER, depth_buffer);
- DCHECK_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_COMPLETE),
- glCheckFramebufferStatus(GL_FRAMEBUFFER));
- glClearColor(1, 0, 0, 0.5);
- cube_.UpdateForTimeDelta(0.16f);
- cube_.Draw();
- glDeleteFramebuffers(1, &fbo);
- glDeleteRenderbuffers(1, &depth_buffer);
-
- // Then, put the texture into a mailbox.
- gpu::Mailbox mailbox = gpu::Mailbox::Generate();
- glProduceTextureCHROMIUM(GL_TEXTURE_2D, mailbox.name);
- GLuint sync_point = glInsertSyncPointCHROMIUM();
- gpu::MailboxHolder holder(mailbox, GL_TEXTURE_2D, sync_point);
-
- // Then, put the mailbox into a TransferableResource
- cc::TransferableResource resource;
- resource.id = next_resource_id_++;
- id_to_tex_map_[resource.id] = texture;
- resource.format = cc::RGBA_8888;
- resource.filter = GL_LINEAR;
- resource.size = size_;
- resource.mailbox_holder = holder;
- resource.is_repeated = false;
- resource.is_software = false;
-
- gfx::Rect rect(size_);
- RenderPassId id(1, 1);
- scoped_ptr<RenderPass> pass = RenderPass::Create();
- pass->SetNew(id, rect, rect, gfx::Transform());
-
- CreateAndAppendSimpleSharedQuadState(pass.get(), gfx::Transform(), size_);
-
- TextureDrawQuad* texture_quad =
- pass->CreateAndAppendDrawQuad<TextureDrawQuad>();
- float vertex_opacity[4] = {1.0f, 1.0f, 0.2f, 1.0f};
- const bool premultiplied_alpha = true;
- const bool flipped = false;
- const bool nearest_neighbor = false;
- texture_quad->SetNew(pass->shared_quad_state_list.back(),
- rect,
- rect,
- rect,
- resource.id,
- premultiplied_alpha,
- gfx::PointF(),
- gfx::PointF(1.f, 1.f),
- SK_ColorBLUE,
- vertex_opacity,
- flipped,
- nearest_neighbor);
-
- scoped_ptr<DelegatedFrameData> delegated_frame_data(new DelegatedFrameData);
- delegated_frame_data->render_pass_list.push_back(pass.Pass());
- delegated_frame_data->resource_list.push_back(resource);
-
- scoped_ptr<CompositorFrame> frame(new CompositorFrame);
- frame->delegated_frame_data = delegated_frame_data.Pass();
-
- surface_->SubmitFrame(local_id_, mojo::Frame::From(*frame), mojo::Closure());
-
- base::MessageLoop::current()->PostDelayedTask(
- FROM_HERE,
- base::Bind(&ChildGLImpl::Draw, base::Unretained(this)),
- base::TimeDelta::FromMilliseconds(50));
-}
-
-} // namespace examples
-} // namespace mojo
diff --git a/examples/surfaces_app/child_gl_impl.h b/examples/surfaces_app/child_gl_impl.h
deleted file mode 100644
index 752d227..0000000
--- a/examples/surfaces_app/child_gl_impl.h
+++ /dev/null
@@ -1,74 +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.
-
-#ifndef EXAMPLES_SURFACES_APP_CHILD_GL_IMPL_H_
-#define EXAMPLES_SURFACES_APP_CHILD_GL_IMPL_H_
-
-#include <GLES2/gl2.h>
-#include <MGL/mgl_types.h>
-
-#include "base/containers/hash_tables.h"
-#include "base/macros.h"
-#include "base/memory/scoped_ptr.h"
-#include "base/time/time.h"
-#include "examples/spinning_cube/spinning_cube.h"
-#include "examples/surfaces_app/child.mojom.h"
-#include "mojo/public/cpp/bindings/string.h"
-#include "mojo/public/cpp/bindings/strong_binding.h"
-#include "mojo/services/gpu/interfaces/command_buffer.mojom.h"
-#include "mojo/services/surfaces/interfaces/surface_id.mojom.h"
-#include "mojo/services/surfaces/interfaces/surfaces.mojom.h"
-#include "third_party/skia/include/core/SkColor.h"
-#include "ui/gfx/size.h"
-
-namespace mojo {
-
-class ApplicationConnection;
-
-namespace examples {
-
-// Simple example of a child app using surfaces + GL.
-class ChildGLImpl : public Child, public ResourceReturner {
- public:
- ChildGLImpl(ApplicationConnection* surfaces_service_connection,
- CommandBufferPtr command_buffer,
- InterfaceRequest<Child> request);
- ~ChildGLImpl() override;
-
- private:
- using ProduceCallback = mojo::Callback<void(SurfaceIdPtr id)>;
-
- // Child implementation.
- void ProduceFrame(ColorPtr color,
- SizePtr size,
- const ProduceCallback& callback) override;
-
- // ResourceReturner implementation
- void ReturnResources(Array<ReturnedResourcePtr> resources) override;
-
- void SetIdNamespace(uint32_t id_namespace);
- void Draw();
- void RunProduceCallback();
-
- SkColor color_;
- gfx::Size size_;
- SurfacePtr surface_;
- MGLContext context_;
- uint32_t id_namespace_;
- uint32_t local_id_;
- ::examples::SpinningCube cube_;
- base::TimeTicks start_time_;
- uint32_t next_resource_id_;
- base::hash_map<uint32_t, GLuint> id_to_tex_map_;
- ProduceCallback produce_callback_;
- Binding<ResourceReturner> returner_binding_;
- StrongBinding<Child> binding_;
-
- DISALLOW_COPY_AND_ASSIGN(ChildGLImpl);
-};
-
-} // namespace examples
-} // namespace mojo
-
-#endif // EXAMPLES_SURFACES_APP_CHILD_GL_IMPL_H_
diff --git a/examples/surfaces_app/child_impl.cc b/examples/surfaces_app/child_impl.cc
deleted file mode 100644
index e3f3611..0000000
--- a/examples/surfaces_app/child_impl.cc
+++ /dev/null
@@ -1,83 +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 "examples/surfaces_app/child_impl.h"
-
-#include "base/bind.h"
-#include "cc/output/compositor_frame.h"
-#include "cc/output/delegated_frame_data.h"
-#include "cc/quads/render_pass.h"
-#include "cc/quads/solid_color_draw_quad.h"
-#include "examples/surfaces_app/surfaces_util.h"
-#include "mojo/converters/geometry/geometry_type_converters.h"
-#include "mojo/converters/surfaces/surfaces_type_converters.h"
-#include "mojo/public/cpp/application/application_connection.h"
-#include "mojo/services/surfaces/interfaces/surface_id.mojom.h"
-#include "mojo/services/surfaces/interfaces/surfaces.mojom.h"
-#include "ui/gfx/rect.h"
-#include "ui/gfx/transform.h"
-
-namespace mojo {
-namespace examples {
-
-using cc::RenderPass;
-using cc::RenderPassId;
-using cc::DrawQuad;
-using cc::SolidColorDrawQuad;
-using cc::DelegatedFrameData;
-using cc::CompositorFrame;
-
-static const uint32_t kLocalId = 1u;
-
-ChildImpl::ChildImpl(ApplicationConnection* surfaces_service_connection,
- InterfaceRequest<Child> request)
- : id_namespace_(0u), binding_(this, request.Pass()) {
- surfaces_service_connection->ConnectToService(&surface_);
- surface_->GetIdNamespace(
- base::Bind(&ChildImpl::SetIdNamespace, base::Unretained(this)));
- surface_.WaitForIncomingResponse(); // Wait for ID namespace to arrive.
- DCHECK_NE(0u, id_namespace_);
-}
-
-ChildImpl::~ChildImpl() {
- surface_->DestroySurface(kLocalId);
-}
-
-void ChildImpl::SetIdNamespace(uint32_t id_namespace) {
- id_namespace_ = id_namespace;
-}
-
-void ChildImpl::ProduceFrame(ColorPtr color,
- SizePtr size_ptr,
- const ProduceCallback& callback) {
- gfx::Size size = size_ptr.To<gfx::Size>();
- gfx::Rect rect(size);
- RenderPassId id(1, 1);
- scoped_ptr<RenderPass> pass = RenderPass::Create();
- pass->SetNew(id, rect, rect, gfx::Transform());
-
- CreateAndAppendSimpleSharedQuadState(pass.get(), gfx::Transform(), size);
-
- SolidColorDrawQuad* color_quad =
- pass->CreateAndAppendDrawQuad<SolidColorDrawQuad>();
- bool force_anti_aliasing_off = false;
- color_quad->SetNew(pass->shared_quad_state_list.back(), rect, rect,
- color.To<SkColor>(), force_anti_aliasing_off);
-
- scoped_ptr<DelegatedFrameData> delegated_frame_data(new DelegatedFrameData);
- delegated_frame_data->render_pass_list.push_back(pass.Pass());
-
- scoped_ptr<CompositorFrame> frame(new CompositorFrame);
- frame->delegated_frame_data = delegated_frame_data.Pass();
-
- surface_->CreateSurface(kLocalId);
- surface_->SubmitFrame(kLocalId, mojo::Frame::From(*frame), mojo::Closure());
- auto qualified_id = mojo::SurfaceId::New();
- qualified_id->id_namespace = id_namespace_;
- qualified_id->local = kLocalId;
- callback.Run(qualified_id.Pass());
-}
-
-} // namespace examples
-} // namespace mojo
diff --git a/examples/surfaces_app/child_impl.h b/examples/surfaces_app/child_impl.h
deleted file mode 100644
index c5c30f3..0000000
--- a/examples/surfaces_app/child_impl.h
+++ /dev/null
@@ -1,64 +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.
-
-#ifndef EXAMPLES_SURFACES_APP_CHILD_IMPL_H_
-#define EXAMPLES_SURFACES_APP_CHILD_IMPL_H_
-
-#include "base/macros.h"
-#include "base/memory/scoped_ptr.h"
-#include "base/memory/weak_ptr.h"
-#include "cc/surfaces/surface_id.h"
-#include "cc/surfaces/surface_id_allocator.h"
-#include "examples/surfaces_app/child.mojom.h"
-#include "mojo/public/cpp/bindings/string.h"
-#include "mojo/public/cpp/bindings/strong_binding.h"
-#include "mojo/services/surfaces/interfaces/surface_id.mojom.h"
-#include "mojo/services/surfaces/interfaces/surfaces.mojom.h"
-#include "third_party/skia/include/core/SkColor.h"
-#include "ui/gfx/size.h"
-
-namespace cc {
-class CompositorFrame;
-}
-
-namespace mojo {
-
-class ApplicationConnection;
-
-namespace examples {
-
-// Simple example of a child app using surfaces.
-class ChildImpl : public Child {
- public:
- class Context {
- public:
- virtual ApplicationConnection* ShellConnection(
- const mojo::String& application_url) = 0;
- };
- ChildImpl(ApplicationConnection* surfaces_service_connection,
- InterfaceRequest<Child> request);
- ~ChildImpl() override;
-
- private:
- using ProduceCallback = mojo::Callback<void(SurfaceIdPtr id)>;
-
- void SetIdNamespace(uint32_t id_namespace);
-
- // Child implementation.
- void ProduceFrame(ColorPtr color,
- SizePtr size,
- const ProduceCallback& callback) override;
-
- scoped_ptr<cc::SurfaceIdAllocator> allocator_;
- SurfacePtr surface_;
- uint32_t id_namespace_;
- StrongBinding<Child> binding_;
-
- DISALLOW_COPY_AND_ASSIGN(ChildImpl);
-};
-
-} // namespace examples
-} // namespace mojo
-
-#endif // EXAMPLES_SURFACES_APP_CHILD_IMPL_H_
diff --git a/examples/surfaces_app/embedder.cc b/examples/surfaces_app/embedder.cc
deleted file mode 100644
index aaa13bc..0000000
--- a/examples/surfaces_app/embedder.cc
+++ /dev/null
@@ -1,101 +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 "examples/surfaces_app/embedder.h"
-
-#include "cc/output/compositor_frame.h"
-#include "cc/output/delegated_frame_data.h"
-#include "cc/quads/render_pass.h"
-#include "cc/quads/solid_color_draw_quad.h"
-#include "cc/quads/surface_draw_quad.h"
-#include "examples/surfaces_app/surfaces_util.h"
-#include "mojo/converters/surfaces/surfaces_type_converters.h"
-#include "mojo/services/surfaces/interfaces/surface_id.mojom.h"
-#include "ui/gfx/rect.h"
-#include "ui/gfx/size.h"
-#include "ui/gfx/transform.h"
-
-namespace mojo {
-namespace examples {
-
-using cc::RenderPass;
-using cc::RenderPassId;
-using cc::SurfaceDrawQuad;
-using cc::DrawQuad;
-using cc::SolidColorDrawQuad;
-using cc::DelegatedFrameData;
-using cc::CompositorFrame;
-
-Embedder::Embedder(Display* display)
- : display_(display), frame_pending_(false) {
-}
-
-Embedder::~Embedder() {
-}
-
-void Embedder::ProduceFrame(cc::SurfaceId child_one,
- cc::SurfaceId child_two,
- const gfx::Size& child_size,
- const gfx::Size& size,
- int offset) {
- DCHECK(!frame_pending_);
-
- gfx::Rect rect(size);
- RenderPassId pass_id(1, 1);
- scoped_ptr<RenderPass> pass = RenderPass::Create();
- pass->SetNew(pass_id, rect, rect, gfx::Transform());
-
- if (!child_one.is_null()) {
- gfx::Transform one_transform;
- one_transform.Translate(10 + child_size.width() / 2,
- 50 + child_size.height() / 2);
- one_transform.Translate(0, offset);
- one_transform.Translate(-child_size.width() / 2, -child_size.height() / 2);
- CreateAndAppendSimpleSharedQuadState(pass.get(), one_transform, size);
-
- SurfaceDrawQuad* surface_one_quad =
- pass->CreateAndAppendDrawQuad<SurfaceDrawQuad>();
- gfx::Rect one_rect(child_size);
- surface_one_quad->SetNew(
- pass->shared_quad_state_list.back(), one_rect, one_rect, child_one);
- }
-
- if (!child_two.is_null()) {
- gfx::Transform two_transform;
- two_transform.Translate(10 + size.width() / 2 + child_size.width() / 2,
- 50 + child_size.height() / 2);
- two_transform.Translate(0, 200 - offset);
- two_transform.Translate(-child_size.width() / 2, -child_size.height() / 2);
- CreateAndAppendSimpleSharedQuadState(pass.get(), two_transform, size);
-
- SurfaceDrawQuad* surface_two_quad =
- pass->CreateAndAppendDrawQuad<SurfaceDrawQuad>();
- gfx::Rect two_rect(child_size);
- surface_two_quad->SetNew(
- pass->shared_quad_state_list.back(), two_rect, two_rect, child_two);
- }
-
- CreateAndAppendSimpleSharedQuadState(pass.get(), gfx::Transform(), size);
- SolidColorDrawQuad* color_quad =
- pass->CreateAndAppendDrawQuad<SolidColorDrawQuad>();
- bool force_anti_aliasing_off = false;
- color_quad->SetNew(pass->shared_quad_state_list.back(),
- rect,
- rect,
- SK_ColorYELLOW,
- force_anti_aliasing_off);
-
- scoped_ptr<DelegatedFrameData> delegated_frame_data(new DelegatedFrameData);
- delegated_frame_data->render_pass_list.push_back(pass.Pass());
-
- scoped_ptr<CompositorFrame> frame(new CompositorFrame);
- frame->delegated_frame_data = delegated_frame_data.Pass();
-
- frame_pending_ = true;
- display_->SubmitFrame(mojo::Frame::From(*frame),
- [this]() { frame_pending_ = false; });
-}
-
-} // namespace examples
-} // namespace mojo
diff --git a/examples/surfaces_app/embedder.h b/examples/surfaces_app/embedder.h
deleted file mode 100644
index bf5c0ed..0000000
--- a/examples/surfaces_app/embedder.h
+++ /dev/null
@@ -1,40 +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.
-
-#ifndef EXAMPLES_SURFACES_APP_EMBEDDER_H_
-#define EXAMPLES_SURFACES_APP_EMBEDDER_H_
-
-#include "base/memory/scoped_ptr.h"
-#include "cc/surfaces/surface_id.h"
-#include "mojo/services/surfaces/interfaces/display.mojom.h"
-#include "ui/gfx/size.h"
-
-namespace mojo {
-namespace examples {
-
-// Simple example of a surface embedder that embeds two other surfaces.
-class Embedder {
- public:
- explicit Embedder(Display* display);
- ~Embedder();
-
- void ProduceFrame(cc::SurfaceId child_one,
- cc::SurfaceId child_two,
- const gfx::Size& child_size,
- const gfx::Size& size,
- int offset);
-
- bool frame_pending() const { return frame_pending_; }
-
- private:
- Display* display_;
- bool frame_pending_;
-
- DISALLOW_COPY_AND_ASSIGN(Embedder);
-};
-
-} // namespace examples
-} // namespace mojo
-
-#endif // EXAMPLES_SURFACES_APP_EMBEDDER_H_
diff --git a/examples/surfaces_app/surfaces_app.cc b/examples/surfaces_app/surfaces_app.cc
deleted file mode 100644
index 8d413ae..0000000
--- a/examples/surfaces_app/surfaces_app.cc
+++ /dev/null
@@ -1,128 +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/bind.h"
-#include "base/macros.h"
-#include "base/memory/weak_ptr.h"
-#include "base/message_loop/message_loop.h"
-#include "cc/surfaces/surface_id_allocator.h"
-#include "examples/surfaces_app/child.mojom.h"
-#include "examples/surfaces_app/embedder.h"
-#include "mojo/application/application_runner_chromium.h"
-#include "mojo/converters/geometry/geometry_type_converters.h"
-#include "mojo/converters/surfaces/surfaces_type_converters.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/public/cpp/system/core.h"
-#include "mojo/services/gpu/interfaces/command_buffer.mojom.h"
-#include "mojo/services/gpu/interfaces/gpu.mojom.h"
-#include "mojo/services/native_viewport/interfaces/native_viewport.mojom.h"
-#include "mojo/services/surfaces/interfaces/display.mojom.h"
-#include "mojo/services/surfaces/interfaces/surfaces.mojom.h"
-#include "ui/gfx/rect.h"
-
-namespace mojo {
-namespace examples {
-
-class SurfacesApp : public ApplicationDelegate {
- public:
- SurfacesApp() : app_impl_(nullptr), id_namespace_(0u), weak_factory_(this) {}
- ~SurfacesApp() override {}
-
- // ApplicationDelegate implementation
- void Initialize(ApplicationImpl* app) override {
- app_impl_ = app;
- size_ = gfx::Size(800, 600);
-
- // Connect to the native viewport service and create a viewport.
- app_impl_->ConnectToService("mojo:native_viewport_service", &viewport_);
- viewport_->Create(Size::From(size_), SurfaceConfiguration::New(),
- [](ViewportMetricsPtr metrics) {});
- viewport_->Show();
-
- // Grab a ContextProvider associated with the viewport.
- ContextProviderPtr onscreen_context_provider;
- viewport_->GetContextProvider(GetProxy(&onscreen_context_provider));
-
- // Create a surfaces Display bound to the viewport's context provider.
- DisplayFactoryPtr display_factory;
- app_impl_->ConnectToService("mojo:surfaces_service", &display_factory);
- display_factory->Create(onscreen_context_provider.Pass(),
- nullptr, // resource_returner
- GetProxy(&display_));
-
- // Construct a mojo::examples::Embedder object that will draw to our
- // display.
- embedder_.reset(new Embedder(display_.get()));
-
- child_size_ = gfx::Size(size_.width() / 3, size_.height() / 2);
- app_impl_->ConnectToService("mojo:surfaces_child_app", &child_one_);
- app_impl_->ConnectToService("mojo:surfaces_child_gl_app", &child_two_);
- child_one_->ProduceFrame(Color::From(SK_ColorBLUE),
- Size::From(child_size_),
- base::Bind(&SurfacesApp::ChildOneProducedFrame,
- base::Unretained(this)));
- child_two_->ProduceFrame(Color::From(SK_ColorGREEN),
- Size::From(child_size_),
- base::Bind(&SurfacesApp::ChildTwoProducedFrame,
- base::Unretained(this)));
- Draw(10);
- }
-
- bool ConfigureIncomingConnection(ApplicationConnection* connection) override {
- return false;
- }
-
- void ChildOneProducedFrame(SurfaceIdPtr id) {
- child_one_id_ = id.To<cc::SurfaceId>();
- }
-
- void ChildTwoProducedFrame(SurfaceIdPtr id) {
- child_two_id_ = id.To<cc::SurfaceId>();
- }
-
- void Draw(int offset) {
- int bounced_offset = offset;
- if (offset > 200)
- bounced_offset = 400 - offset;
- if (!embedder_->frame_pending()) {
- embedder_->ProduceFrame(child_one_id_, child_two_id_, child_size_, size_,
- bounced_offset);
- }
- base::MessageLoop::current()->PostDelayedTask(
- FROM_HERE,
- base::Bind(
- &SurfacesApp::Draw, base::Unretained(this), (offset + 2) % 400),
- base::TimeDelta::FromMilliseconds(50));
- }
-
- private:
-
- ApplicationImpl* app_impl_;
- DisplayPtr display_;
- uint32_t id_namespace_;
- scoped_ptr<Embedder> embedder_;
- ChildPtr child_one_;
- cc::SurfaceId child_one_id_;
- ChildPtr child_two_;
- cc::SurfaceId child_two_id_;
- gfx::Size size_;
- gfx::Size child_size_;
-
- NativeViewportPtr viewport_;
-
- base::WeakPtrFactory<SurfacesApp> weak_factory_;
-
- DISALLOW_COPY_AND_ASSIGN(SurfacesApp);
-};
-
-} // namespace examples
-} // namespace mojo
-
-MojoResult MojoMain(MojoHandle application_request) {
- mojo::ApplicationRunnerChromium runner(new mojo::examples::SurfacesApp);
- return runner.Run(application_request);
-}
diff --git a/examples/surfaces_app/surfaces_util.cc b/examples/surfaces_app/surfaces_util.cc
deleted file mode 100644
index e19f17e..0000000
--- a/examples/surfaces_app/surfaces_util.cc
+++ /dev/null
@@ -1,39 +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 "examples/surfaces_app/surfaces_util.h"
-
-#include "cc/quads/render_pass.h"
-#include "cc/quads/shared_quad_state.h"
-#include "ui/gfx/rect.h"
-#include "ui/gfx/size.h"
-#include "ui/gfx/transform.h"
-
-namespace mojo {
-namespace examples {
-
-using cc::SharedQuadState;
-
-void CreateAndAppendSimpleSharedQuadState(cc::RenderPass* render_pass,
- const gfx::Transform& transform,
- const gfx::Size& size) {
- const gfx::Size content_bounds = size;
- const gfx::Rect visible_content_rect = gfx::Rect(size);
- const gfx::Rect clip_rect = gfx::Rect(size);
- bool is_clipped = false;
- float opacity = 1.f;
- const SkXfermode::Mode blend_mode = SkXfermode::kSrcOver_Mode;
- SharedQuadState* shared_state = render_pass->CreateAndAppendSharedQuadState();
- shared_state->SetAll(transform,
- content_bounds,
- visible_content_rect,
- clip_rect,
- is_clipped,
- opacity,
- blend_mode,
- 0);
-}
-
-} // namespace mojo
-} // namespace examples
diff --git a/examples/surfaces_app/surfaces_util.h b/examples/surfaces_app/surfaces_util.h
deleted file mode 100644
index 81e985b..0000000
--- a/examples/surfaces_app/surfaces_util.h
+++ /dev/null
@@ -1,27 +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.
-
-#ifndef EXAMPLES_SURFACES_APP_SURFACES_UTIL_H_
-#define EXAMPLES_SURFACES_APP_SURFACES_UTIL_H_
-
-namespace cc {
-class RenderPass;
-}
-
-namespace gfx {
-class Transform;
-class Size;
-}
-
-namespace mojo {
-namespace examples {
-
-void CreateAndAppendSimpleSharedQuadState(cc::RenderPass* render_pass,
- const gfx::Transform& transform,
- const gfx::Size& size);
-
-} // namespace mojo
-} // namespace examples
-
-#endif // EXAMPLES_SURFACES_APP_SURFACES_UTIL_H_
diff --git a/mojo/BUILD.gn b/mojo/BUILD.gn
index 4df674a..f2ce271 100644
--- a/mojo/BUILD.gn
+++ b/mojo/BUILD.gn
@@ -72,10 +72,6 @@
"//mojo/tools:message_generator",
]
- if (is_linux || is_android) {
- deps += [ "//mojo/converters/surfaces/tests:mojo_surfaces_lib_unittests" ]
- }
-
if (mojo_use_prebuilt_network_service) {
deps += [ "//mojo/public/tools:copy_network_service_apptests" ]
}
diff --git a/mojo/converters/surfaces/BUILD.gn b/mojo/converters/surfaces/BUILD.gn
deleted file mode 100644
index b8e2fa7..0000000
--- a/mojo/converters/surfaces/BUILD.gn
+++ /dev/null
@@ -1,28 +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.
-
-component("surfaces") {
- output_name = "mojo_surfaces_lib"
-
- sources = [
- "surfaces_type_converters.cc",
- "surfaces_type_converters.h",
- ]
-
- public_deps = [
- "//mojo/converters/geometry",
- ]
-
- deps = [
- "//base",
- "//cc",
- "//cc/surfaces",
- "//cc/surfaces:surface_id",
- "//gpu",
- "//mojo/environment:chromium",
- "//mojo/public/c/system",
- "//mojo/services/surfaces/interfaces",
- "//mojo/services/surfaces/interfaces:surface_id",
- ]
-}
diff --git a/mojo/converters/surfaces/surfaces_type_converters.cc b/mojo/converters/surfaces/surfaces_type_converters.cc
deleted file mode 100644
index f16dac1..0000000
--- a/mojo/converters/surfaces/surfaces_type_converters.cc
+++ /dev/null
@@ -1,590 +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 "mojo/converters/surfaces/surfaces_type_converters.h"
-
-#include "base/macros.h"
-#include "cc/output/compositor_frame.h"
-#include "cc/output/delegated_frame_data.h"
-#include "cc/quads/draw_quad.h"
-#include "cc/quads/render_pass.h"
-#include "cc/quads/render_pass_draw_quad.h"
-#include "cc/quads/shared_quad_state.h"
-#include "cc/quads/solid_color_draw_quad.h"
-#include "cc/quads/surface_draw_quad.h"
-#include "cc/quads/texture_draw_quad.h"
-#include "cc/quads/tile_draw_quad.h"
-#include "cc/quads/yuv_video_draw_quad.h"
-#include "cc/surfaces/surface_id_allocator.h"
-#include "mojo/converters/geometry/geometry_type_converters.h"
-
-namespace mojo {
-
-#define ASSERT_ENUM_VALUES_EQUAL(value) \
- COMPILE_ASSERT(static_cast<int32_t>(cc::DrawQuad::value) == \
- static_cast<int32_t>(Material::value), \
- value##_enum_value_matches)
-
-ASSERT_ENUM_VALUES_EQUAL(CHECKERBOARD);
-ASSERT_ENUM_VALUES_EQUAL(DEBUG_BORDER);
-ASSERT_ENUM_VALUES_EQUAL(IO_SURFACE_CONTENT);
-ASSERT_ENUM_VALUES_EQUAL(RENDER_PASS);
-ASSERT_ENUM_VALUES_EQUAL(SOLID_COLOR);
-ASSERT_ENUM_VALUES_EQUAL(STREAM_VIDEO_CONTENT);
-ASSERT_ENUM_VALUES_EQUAL(SURFACE_CONTENT);
-ASSERT_ENUM_VALUES_EQUAL(TEXTURE_CONTENT);
-ASSERT_ENUM_VALUES_EQUAL(TILED_CONTENT);
-ASSERT_ENUM_VALUES_EQUAL(YUV_VIDEO_CONTENT);
-
-COMPILE_ASSERT(
- cc::YUVVideoDrawQuad::REC_601 ==
- static_cast<cc::YUVVideoDrawQuad::ColorSpace>(YUVColorSpace::REC_601),
- rec_601_enum_matches);
-COMPILE_ASSERT(cc::YUVVideoDrawQuad::JPEG ==
- static_cast<cc::YUVVideoDrawQuad::ColorSpace>(
- YUVColorSpace::JPEG),
- rec_601_jpeg_enum_matches);
-
-namespace {
-
-cc::SharedQuadState* ConvertSharedQuadState(const SharedQuadStatePtr& input,
- cc::RenderPass* render_pass) {
- cc::SharedQuadState* state = render_pass->CreateAndAppendSharedQuadState();
- state->SetAll(input->content_to_target_transform.To<gfx::Transform>(),
- input->content_bounds.To<gfx::Size>(),
- input->visible_content_rect.To<gfx::Rect>(),
- input->clip_rect.To<gfx::Rect>(),
- input->is_clipped,
- input->opacity,
- static_cast<::SkXfermode::Mode>(input->blend_mode),
- input->sorting_context_id);
- return state;
-}
-
-bool ConvertDrawQuad(const QuadPtr& input,
- cc::SharedQuadState* sqs,
- cc::RenderPass* render_pass) {
- switch (input->material) {
- case Material::RENDER_PASS: {
- cc::RenderPassDrawQuad* render_pass_quad =
- render_pass->CreateAndAppendDrawQuad<cc::RenderPassDrawQuad>();
- RenderPassQuadState* render_pass_quad_state =
- input->render_pass_quad_state.get();
- gfx::PointF mask_uv_scale_as_point =
- render_pass_quad_state->mask_uv_scale.To<gfx::PointF>();
- gfx::PointF filter_scale_as_point =
- render_pass_quad_state->filters_scale.To<gfx::PointF>();
- render_pass_quad->SetAll(
- sqs,
- input->rect.To<gfx::Rect>(),
- input->opaque_rect.To<gfx::Rect>(),
- input->visible_rect.To<gfx::Rect>(),
- input->needs_blending,
- render_pass_quad_state->render_pass_id.To<cc::RenderPassId>(),
- render_pass_quad_state->mask_resource_id,
- mask_uv_scale_as_point.OffsetFromOrigin(),
- render_pass_quad_state->mask_texture_size.To<gfx::Size>(),
- cc::FilterOperations(), // TODO(jamesr): filters
- filter_scale_as_point.OffsetFromOrigin(),
- cc::FilterOperations()); // TODO(jamesr): background_filters
- break;
- }
- case Material::SOLID_COLOR: {
- if (input->solid_color_quad_state.is_null())
- return false;
- cc::SolidColorDrawQuad* color_quad =
- render_pass->CreateAndAppendDrawQuad<cc::SolidColorDrawQuad>();
- color_quad->SetAll(
- sqs,
- input->rect.To<gfx::Rect>(),
- input->opaque_rect.To<gfx::Rect>(),
- input->visible_rect.To<gfx::Rect>(),
- input->needs_blending,
- input->solid_color_quad_state->color.To<SkColor>(),
- input->solid_color_quad_state->force_anti_aliasing_off);
- break;
- }
- case Material::SURFACE_CONTENT: {
- if (input->surface_quad_state.is_null())
- return false;
- cc::SurfaceDrawQuad* surface_quad =
- render_pass->CreateAndAppendDrawQuad<cc::SurfaceDrawQuad>();
- surface_quad->SetAll(
- sqs,
- input->rect.To<gfx::Rect>(),
- input->opaque_rect.To<gfx::Rect>(),
- input->visible_rect.To<gfx::Rect>(),
- input->needs_blending,
- input->surface_quad_state->surface.To<cc::SurfaceId>());
- break;
- }
- case Material::TEXTURE_CONTENT: {
- TextureQuadStatePtr& texture_quad_state =
- input->texture_quad_state;
- if (texture_quad_state.is_null() ||
- texture_quad_state->vertex_opacity.is_null() ||
- texture_quad_state->background_color.is_null())
- return false;
- cc::TextureDrawQuad* texture_quad =
- render_pass->CreateAndAppendDrawQuad<cc::TextureDrawQuad>();
- texture_quad->SetAll(
- sqs,
- input->rect.To<gfx::Rect>(),
- input->opaque_rect.To<gfx::Rect>(),
- input->visible_rect.To<gfx::Rect>(),
- input->needs_blending,
- texture_quad_state->resource_id,
- texture_quad_state->premultiplied_alpha,
- texture_quad_state->uv_top_left.To<gfx::PointF>(),
- texture_quad_state->uv_bottom_right.To<gfx::PointF>(),
- texture_quad_state->background_color.To<SkColor>(),
- &texture_quad_state->vertex_opacity.storage()[0],
- texture_quad_state->flipped,
- texture_quad_state->nearest_neighbor);
- break;
- }
- case Material::TILED_CONTENT: {
- TileQuadStatePtr& tile_state = input->tile_quad_state;
- if (tile_state.is_null())
- return false;
- cc::TileDrawQuad* tile_quad =
- render_pass->CreateAndAppendDrawQuad<cc::TileDrawQuad>();
- tile_quad->SetAll(sqs,
- input->rect.To<gfx::Rect>(),
- input->opaque_rect.To<gfx::Rect>(),
- input->visible_rect.To<gfx::Rect>(),
- input->needs_blending,
- tile_state->resource_id,
- tile_state->tex_coord_rect.To<gfx::RectF>(),
- tile_state->texture_size.To<gfx::Size>(),
- tile_state->swizzle_contents,
- tile_state->nearest_neighbor);
- break;
- }
- case Material::YUV_VIDEO_CONTENT: {
- YUVVideoQuadStatePtr& yuv_state = input->yuv_video_quad_state;
- if (yuv_state.is_null())
- return false;
- cc::YUVVideoDrawQuad* yuv_quad =
- render_pass->CreateAndAppendDrawQuad<cc::YUVVideoDrawQuad>();
- yuv_quad->SetAll(sqs,
- input->rect.To<gfx::Rect>(),
- input->opaque_rect.To<gfx::Rect>(),
- input->visible_rect.To<gfx::Rect>(),
- input->needs_blending,
- yuv_state->tex_coord_rect.To<gfx::RectF>(),
- gfx::Size(), // TODO(jamesr): texture size
- yuv_state->y_plane_resource_id,
- yuv_state->u_plane_resource_id,
- yuv_state->v_plane_resource_id,
- yuv_state->a_plane_resource_id,
- static_cast<cc::YUVVideoDrawQuad::ColorSpace>(
- yuv_state->color_space));
- break;
- }
- default:
- NOTREACHED() << "Unsupported material " << input->material;
- return false;
- }
- return true;
-}
-
-} // namespace
-
-// static
-SurfaceIdPtr TypeConverter<SurfaceIdPtr, cc::SurfaceId>::Convert(
- const cc::SurfaceId& input) {
- SurfaceIdPtr id(SurfaceId::New());
- id->local = static_cast<uint32_t>(input.id);
- id->id_namespace = cc::SurfaceIdAllocator::NamespaceForId(input);
- return id;
-}
-
-// static
-cc::SurfaceId TypeConverter<cc::SurfaceId, SurfaceIdPtr>::Convert(
- const SurfaceIdPtr& input) {
- uint64_t packed_id = input->id_namespace;
- packed_id <<= 32ull;
- packed_id |= input->local;
- return cc::SurfaceId(packed_id);
-}
-
-// static
-ColorPtr TypeConverter<ColorPtr, SkColor>::Convert(const SkColor& input) {
- ColorPtr color(Color::New());
- color->rgba = input;
- return color;
-}
-
-// static
-SkColor TypeConverter<SkColor, ColorPtr>::Convert(const ColorPtr& input) {
- return input->rgba;
-}
-
-// static
-RenderPassIdPtr TypeConverter<RenderPassIdPtr, cc::RenderPassId>::Convert(
- const cc::RenderPassId& input) {
- RenderPassIdPtr pass_id(RenderPassId::New());
- pass_id->layer_id = input.layer_id;
- pass_id->index = input.index;
- return pass_id;
-}
-
-// static
-cc::RenderPassId TypeConverter<cc::RenderPassId, RenderPassIdPtr>::Convert(
- const RenderPassIdPtr& input) {
- return cc::RenderPassId(input->layer_id, input->index);
-}
-
-// static
-QuadPtr TypeConverter<QuadPtr, cc::DrawQuad>::Convert(
- const cc::DrawQuad& input) {
- QuadPtr quad = Quad::New();
- quad->material = static_cast<Material>(input.material);
- quad->rect = Rect::From(input.rect);
- quad->opaque_rect = Rect::From(input.opaque_rect);
- quad->visible_rect = Rect::From(input.visible_rect);
- quad->needs_blending = input.needs_blending;
- // This is intentionally left set to an invalid value here. It's set when
- // converting an entire pass since it's an index into the pass' shared quad
- // state list.
- quad->shared_quad_state_index = UINT32_MAX;
- switch (input.material) {
- case cc::DrawQuad::RENDER_PASS: {
- const cc::RenderPassDrawQuad* render_pass_quad =
- cc::RenderPassDrawQuad::MaterialCast(&input);
- RenderPassQuadStatePtr pass_state = RenderPassQuadState::New();
- pass_state->render_pass_id =
- RenderPassId::From(render_pass_quad->render_pass_id);
- pass_state->mask_resource_id = render_pass_quad->mask_resource_id;
- pass_state->mask_uv_scale = PointF::From(
- gfx::PointAtOffsetFromOrigin(render_pass_quad->mask_uv_scale));
- pass_state->mask_texture_size =
- Size::From(render_pass_quad->mask_texture_size);
- // TODO(jamesr): pass_state->filters
- pass_state->filters_scale = PointF::From(
- gfx::PointAtOffsetFromOrigin(render_pass_quad->filters_scale));
- // TODO(jamesr): pass_state->background_filters
- quad->render_pass_quad_state = pass_state.Pass();
- break;
- }
- case cc::DrawQuad::SOLID_COLOR: {
- const cc::SolidColorDrawQuad* color_quad =
- cc::SolidColorDrawQuad::MaterialCast(&input);
- SolidColorQuadStatePtr color_state = SolidColorQuadState::New();
- color_state->color = Color::From(color_quad->color);
- color_state->force_anti_aliasing_off =
- color_quad->force_anti_aliasing_off;
- quad->solid_color_quad_state = color_state.Pass();
- break;
- }
- case cc::DrawQuad::SURFACE_CONTENT: {
- const cc::SurfaceDrawQuad* surface_quad =
- cc::SurfaceDrawQuad::MaterialCast(&input);
- SurfaceQuadStatePtr surface_state =
- SurfaceQuadState::New();
- surface_state->surface = SurfaceId::From(surface_quad->surface_id);
- quad->surface_quad_state = surface_state.Pass();
- break;
- }
- case cc::DrawQuad::TEXTURE_CONTENT: {
- const cc::TextureDrawQuad* texture_quad =
- cc::TextureDrawQuad::MaterialCast(&input);
- TextureQuadStatePtr texture_state = TextureQuadState::New();
- texture_state->resource_id = texture_quad->resource_id;
- texture_state->premultiplied_alpha = texture_quad->premultiplied_alpha;
- texture_state->uv_top_left = PointF::From(texture_quad->uv_top_left);
- texture_state->uv_bottom_right =
- PointF::From(texture_quad->uv_bottom_right);
- texture_state->background_color =
- Color::From(texture_quad->background_color);
- auto vertex_opacity = Array<float>::New(4);
- for (size_t i = 0; i < 4; ++i) {
- vertex_opacity[i] = texture_quad->vertex_opacity[i];
- }
- texture_state->vertex_opacity = vertex_opacity.Pass();
- texture_state->flipped = texture_quad->flipped;
- quad->texture_quad_state = texture_state.Pass();
- break;
- }
- case cc::DrawQuad::TILED_CONTENT: {
- const cc::TileDrawQuad* tile_quad =
- cc::TileDrawQuad::MaterialCast(&input);
- TileQuadStatePtr tile_state = TileQuadState::New();
- tile_state->tex_coord_rect = RectF::From(tile_quad->tex_coord_rect);
- tile_state->texture_size = Size::From(tile_quad->texture_size);
- tile_state->swizzle_contents = tile_quad->swizzle_contents;
- tile_state->resource_id = tile_quad->resource_id;
- quad->tile_quad_state = tile_state.Pass();
- break;
- }
- case cc::DrawQuad::YUV_VIDEO_CONTENT: {
- const cc::YUVVideoDrawQuad* yuv_quad =
- cc::YUVVideoDrawQuad::MaterialCast(&input);
- YUVVideoQuadStatePtr yuv_state = YUVVideoQuadState::New();
- yuv_state->tex_coord_rect = RectF::From(yuv_quad->tex_coord_rect);
- yuv_state->y_plane_resource_id = yuv_quad->y_plane_resource_id;
- yuv_state->u_plane_resource_id = yuv_quad->u_plane_resource_id;
- yuv_state->v_plane_resource_id = yuv_quad->v_plane_resource_id;
- yuv_state->a_plane_resource_id = yuv_quad->a_plane_resource_id;
- yuv_state->color_space =
- static_cast<YUVColorSpace>(yuv_quad->color_space);
- quad->yuv_video_quad_state = yuv_state.Pass();
- break;
- }
-
- default:
- NOTREACHED() << "Unsupported material " << input.material;
- }
- return quad;
-}
-
-// static
-SharedQuadStatePtr
-TypeConverter<SharedQuadStatePtr, cc::SharedQuadState>::Convert(
- const cc::SharedQuadState& input) {
- SharedQuadStatePtr state = SharedQuadState::New();
- state->content_to_target_transform =
- Transform::From(input.content_to_target_transform);
- state->content_bounds = Size::From(input.content_bounds);
- state->visible_content_rect = Rect::From(input.visible_content_rect);
- state->clip_rect = Rect::From(input.clip_rect);
- state->is_clipped = input.is_clipped;
- state->opacity = input.opacity;
- state->blend_mode = static_cast<SkXfermode>(input.blend_mode);
- state->sorting_context_id = input.sorting_context_id;
- return state;
-}
-
-// static
-PassPtr TypeConverter<PassPtr, cc::RenderPass>::Convert(
- const cc::RenderPass& input) {
- PassPtr pass = Pass::New();
- pass->id = input.id.index;
- pass->output_rect = Rect::From(input.output_rect);
- pass->damage_rect = Rect::From(input.damage_rect);
- pass->transform_to_root_target =
- Transform::From(input.transform_to_root_target);
- pass->has_transparent_background = input.has_transparent_background;
- auto quads = Array<QuadPtr>::New(input.quad_list.size());
- auto shared_quad_state =
- Array<SharedQuadStatePtr>::New(input.shared_quad_state_list.size());
- const cc::SharedQuadState* last_sqs = nullptr;
- cc::SharedQuadStateList::ConstIterator next_sqs_iter =
- input.shared_quad_state_list.begin();
- for (auto iter = input.quad_list.cbegin(); iter != input.quad_list.cend();
- ++iter) {
- const cc::DrawQuad& quad = **iter;
- quads[iter.index()] = Quad::From(quad);
- if (quad.shared_quad_state != last_sqs) {
- shared_quad_state[next_sqs_iter.index()] =
- SharedQuadState::From(**next_sqs_iter);
- last_sqs = *next_sqs_iter;
- ++next_sqs_iter;
- }
- DCHECK_LE(next_sqs_iter.index() - 1, UINT32_MAX);
- quads[iter.index()]->shared_quad_state_index =
- static_cast<uint32_t>(next_sqs_iter.index() - 1);
- }
- // We should copy all shared quad states.
- DCHECK_EQ(next_sqs_iter.index(), shared_quad_state.size());
- pass->quads = quads.Pass();
- pass->shared_quad_states = shared_quad_state.Pass();
- return pass;
-}
-
-// static
-scoped_ptr<cc::RenderPass>
-TypeConverter<scoped_ptr<cc::RenderPass>, PassPtr>::Convert(
- const PassPtr& input) {
- scoped_ptr<cc::RenderPass> pass = cc::RenderPass::Create(
- input->shared_quad_states.size(), input->quads.size());
- pass->SetAll(cc::RenderPassId(1, input->id),
- input->output_rect.To<gfx::Rect>(),
- input->damage_rect.To<gfx::Rect>(),
- input->transform_to_root_target.To<gfx::Transform>(),
- input->has_transparent_background);
- for (size_t i = 0; i < input->shared_quad_states.size(); ++i) {
- ConvertSharedQuadState(input->shared_quad_states[i], pass.get());
- }
- cc::SharedQuadStateList::Iterator sqs_iter =
- pass->shared_quad_state_list.begin();
- for (size_t i = 0; i < input->quads.size(); ++i) {
- QuadPtr quad = input->quads[i].Pass();
- while (quad->shared_quad_state_index > sqs_iter.index()) {
- ++sqs_iter;
- }
- if (!ConvertDrawQuad(quad, *sqs_iter, pass.get()))
- return nullptr;
- }
- return pass;
-}
-
-// static
-MailboxPtr TypeConverter<MailboxPtr, gpu::Mailbox>::Convert(
- const gpu::Mailbox& input) {
- auto name = Array<int8_t>::New(64);
- for (int i = 0; i < 64; ++i) {
- name[i] = input.name[i];
- }
- MailboxPtr mailbox(Mailbox::New());
- mailbox->name = name.Pass();
- return mailbox;
-}
-
-// static
-gpu::Mailbox TypeConverter<gpu::Mailbox, MailboxPtr>::Convert(
- const MailboxPtr& input) {
- gpu::Mailbox mailbox;
- if (!input->name.is_null())
- mailbox.SetName(&input->name.storage()[0]);
- return mailbox;
-}
-
-// static
-MailboxHolderPtr TypeConverter<MailboxHolderPtr, gpu::MailboxHolder>::Convert(
- const gpu::MailboxHolder& input) {
- MailboxHolderPtr holder(MailboxHolder::New());
- holder->mailbox = Mailbox::From<gpu::Mailbox>(input.mailbox);
- holder->texture_target = input.texture_target;
- holder->sync_point = input.sync_point;
- return holder;
-}
-
-// static
-gpu::MailboxHolder TypeConverter<gpu::MailboxHolder, MailboxHolderPtr>::Convert(
- const MailboxHolderPtr& input) {
- gpu::MailboxHolder holder;
- holder.mailbox = input->mailbox.To<gpu::Mailbox>();
- holder.texture_target = input->texture_target;
- holder.sync_point = input->sync_point;
- return holder;
-}
-
-// static
-TransferableResourcePtr
-TypeConverter<TransferableResourcePtr, cc::TransferableResource>::Convert(
- const cc::TransferableResource& input) {
- TransferableResourcePtr transferable = TransferableResource::New();
- transferable->id = input.id;
- transferable->format = static_cast<ResourceFormat>(input.format);
- transferable->filter = input.filter;
- transferable->size = Size::From(input.size);
- transferable->mailbox_holder = MailboxHolder::From(input.mailbox_holder);
- transferable->is_repeated = input.is_repeated;
- transferable->is_software = input.is_software;
- return transferable;
-}
-
-// static
-cc::TransferableResource
-TypeConverter<cc::TransferableResource, TransferableResourcePtr>::Convert(
- const TransferableResourcePtr& input) {
- cc::TransferableResource transferable;
- transferable.id = input->id;
- transferable.format = static_cast<cc::ResourceFormat>(input->format);
- transferable.filter = input->filter;
- transferable.size = input->size.To<gfx::Size>();
- transferable.mailbox_holder = input->mailbox_holder.To<gpu::MailboxHolder>();
- transferable.is_repeated = input->is_repeated;
- transferable.is_software = input->is_software;
- return transferable;
-}
-
-// static
-Array<TransferableResourcePtr> TypeConverter<
- Array<TransferableResourcePtr>,
- cc::TransferableResourceArray>::Convert(const cc::TransferableResourceArray&
- input) {
- auto resources = Array<TransferableResourcePtr>::New(input.size());
- for (size_t i = 0; i < input.size(); ++i) {
- resources[i] = TransferableResource::From(input[i]);
- }
- return resources;
-}
-
-// static
-cc::TransferableResourceArray
-TypeConverter<cc::TransferableResourceArray, Array<TransferableResourcePtr> >::
- Convert(const Array<TransferableResourcePtr>& input) {
- cc::TransferableResourceArray resources(input.size());
- for (size_t i = 0; i < input.size(); ++i) {
- resources[i] = input[i].To<cc::TransferableResource>();
- }
- return resources;
-}
-
-// static
-ReturnedResourcePtr
-TypeConverter<ReturnedResourcePtr, cc::ReturnedResource>::Convert(
- const cc::ReturnedResource& input) {
- ReturnedResourcePtr returned = ReturnedResource::New();
- returned->id = input.id;
- returned->sync_point = input.sync_point;
- returned->count = input.count;
- returned->lost = input.lost;
- return returned;
-}
-
-// static
-cc::ReturnedResource
-TypeConverter<cc::ReturnedResource, ReturnedResourcePtr>::Convert(
- const ReturnedResourcePtr& input) {
- cc::ReturnedResource returned;
- returned.id = input->id;
- returned.sync_point = input->sync_point;
- returned.count = input->count;
- returned.lost = input->lost;
- return returned;
-}
-
-// static
-Array<ReturnedResourcePtr>
-TypeConverter<Array<ReturnedResourcePtr>, cc::ReturnedResourceArray>::Convert(
- const cc::ReturnedResourceArray& input) {
- auto resources = Array<ReturnedResourcePtr>::New(input.size());
- for (size_t i = 0; i < input.size(); ++i) {
- resources[i] = ReturnedResource::From(input[i]);
- }
- return resources;
-}
-
-// static
-FramePtr TypeConverter<FramePtr, cc::CompositorFrame>::Convert(
- const cc::CompositorFrame& input) {
- FramePtr frame = Frame::New();
- DCHECK(input.delegated_frame_data);
- cc::DelegatedFrameData* frame_data = input.delegated_frame_data.get();
- frame->resources =
- Array<TransferableResourcePtr>::From(frame_data->resource_list);
- const cc::RenderPassList& pass_list = frame_data->render_pass_list;
- frame->passes = Array<PassPtr>::New(pass_list.size());
- for (size_t i = 0; i < pass_list.size(); ++i) {
- frame->passes[i] = Pass::From(*pass_list[i]);
- }
- return frame;
-}
-
-// static
-scoped_ptr<cc::CompositorFrame>
-TypeConverter<scoped_ptr<cc::CompositorFrame>, FramePtr>::Convert(
- const FramePtr& input) {
- scoped_ptr<cc::DelegatedFrameData> frame_data(new cc::DelegatedFrameData);
- frame_data->device_scale_factor = 1.f;
- frame_data->resource_list =
- input->resources.To<cc::TransferableResourceArray>();
- frame_data->render_pass_list.reserve(input->passes.size());
- for (size_t i = 0; i < input->passes.size(); ++i) {
- scoped_ptr<cc::RenderPass> pass =
- input->passes[i].To<scoped_ptr<cc::RenderPass> >();
- if (!pass)
- return scoped_ptr<cc::CompositorFrame>();
- frame_data->render_pass_list.push_back(pass.Pass());
- }
- scoped_ptr<cc::CompositorFrame> frame(new cc::CompositorFrame);
- frame->delegated_frame_data = frame_data.Pass();
- return frame;
-}
-
-} // namespace mojo
diff --git a/mojo/converters/surfaces/surfaces_type_converters.h b/mojo/converters/surfaces/surfaces_type_converters.h
deleted file mode 100644
index 1f41613..0000000
--- a/mojo/converters/surfaces/surfaces_type_converters.h
+++ /dev/null
@@ -1,147 +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.
-
-#ifndef MOJO_CONVERTERS_SURFACES_SURFACES_TYPE_CONVERTERS_H_
-#define MOJO_CONVERTERS_SURFACES_SURFACES_TYPE_CONVERTERS_H_
-
-#include "base/memory/scoped_ptr.h"
-#include "cc/resources/returned_resource.h"
-#include "cc/resources/transferable_resource.h"
-#include "cc/surfaces/surface_id.h"
-#include "gpu/command_buffer/common/mailbox.h"
-#include "gpu/command_buffer/common/mailbox_holder.h"
-#include "mojo/services/surfaces/interfaces/quads.mojom.h"
-#include "mojo/services/surfaces/interfaces/surface_id.mojom.h"
-#include "mojo/services/surfaces/interfaces/surfaces.mojom.h"
-#include "third_party/skia/include/core/SkColor.h"
-
-namespace cc {
-class CompositorFrame;
-class DrawQuad;
-class RenderPass;
-class RenderPassId;
-class SharedQuadState;
-} // namespace cc
-
-namespace mojo {
-
-// Types from surface_id.mojom
-template <>
-struct TypeConverter<SurfaceIdPtr, cc::SurfaceId> {
- static SurfaceIdPtr Convert(const cc::SurfaceId& input);
-};
-template <>
-struct TypeConverter<cc::SurfaceId, SurfaceIdPtr> {
- static cc::SurfaceId Convert(const SurfaceIdPtr& input);
-};
-
-// Types from quads.mojom
-template <>
-struct TypeConverter<ColorPtr, SkColor> {
- static ColorPtr Convert(const SkColor& input);
-};
-template <>
-struct TypeConverter<SkColor, ColorPtr> {
- static SkColor Convert(const ColorPtr& input);
-};
-
-template <>
-struct TypeConverter<RenderPassIdPtr, cc::RenderPassId> {
- static RenderPassIdPtr Convert(const cc::RenderPassId& input);
-};
-
-template <>
-struct TypeConverter<cc::RenderPassId, RenderPassIdPtr> {
- static cc::RenderPassId Convert(const RenderPassIdPtr& input);
-};
-
-template <>
-struct TypeConverter<QuadPtr, cc::DrawQuad> {
- static QuadPtr Convert(const cc::DrawQuad& input);
-};
-
-template <>
-struct TypeConverter<SharedQuadStatePtr, cc::SharedQuadState> {
- static SharedQuadStatePtr Convert(const cc::SharedQuadState& input);
-};
-
-template <>
-struct TypeConverter<PassPtr, cc::RenderPass> {
- static PassPtr Convert(const cc::RenderPass& input);
-};
-
-template <>
-struct TypeConverter<scoped_ptr<cc::RenderPass>, PassPtr> {
- static scoped_ptr<cc::RenderPass> Convert(const PassPtr& input);
-};
-
-// Types from surfaces.mojom
-template <>
-struct TypeConverter<MailboxPtr, gpu::Mailbox> {
- static MailboxPtr Convert(const gpu::Mailbox& input);
-};
-template <>
-struct TypeConverter<gpu::Mailbox, MailboxPtr> {
- static gpu::Mailbox Convert(const MailboxPtr& input);
-};
-
-template <>
-struct TypeConverter<MailboxHolderPtr, gpu::MailboxHolder> {
- static MailboxHolderPtr Convert(const gpu::MailboxHolder& input);
-};
-template <>
-struct TypeConverter<gpu::MailboxHolder, MailboxHolderPtr> {
- static gpu::MailboxHolder Convert(const MailboxHolderPtr& input);
-};
-
-template <>
-struct TypeConverter<TransferableResourcePtr, cc::TransferableResource> {
- static TransferableResourcePtr Convert(const cc::TransferableResource& input);
-};
-template <>
-struct TypeConverter<cc::TransferableResource, TransferableResourcePtr> {
- static cc::TransferableResource Convert(const TransferableResourcePtr& input);
-};
-
-template <>
-struct TypeConverter<Array<TransferableResourcePtr>,
- cc::TransferableResourceArray> {
- static Array<TransferableResourcePtr> Convert(
- const cc::TransferableResourceArray& input);
-};
-template <>
-struct TypeConverter<cc::TransferableResourceArray,
- Array<TransferableResourcePtr>> {
- static cc::TransferableResourceArray Convert(
- const Array<TransferableResourcePtr>& input);
-};
-
-template <>
-struct TypeConverter<ReturnedResourcePtr, cc::ReturnedResource> {
- static ReturnedResourcePtr Convert(const cc::ReturnedResource& input);
-};
-template <>
-struct TypeConverter<cc::ReturnedResource, ReturnedResourcePtr> {
- static cc::ReturnedResource Convert(const ReturnedResourcePtr& input);
-};
-
-template <>
-struct TypeConverter<Array<ReturnedResourcePtr>, cc::ReturnedResourceArray> {
- static Array<ReturnedResourcePtr> Convert(
- const cc::ReturnedResourceArray& input);
-};
-
-template <>
-struct TypeConverter<FramePtr, cc::CompositorFrame> {
- static FramePtr Convert(const cc::CompositorFrame& input);
-};
-
-template <>
-struct TypeConverter<scoped_ptr<cc::CompositorFrame>, FramePtr> {
- static scoped_ptr<cc::CompositorFrame> Convert(const FramePtr& input);
-};
-
-} // namespace mojo
-
-#endif // MOJO_CONVERTERS_SURFACES_SURFACES_TYPE_CONVERTERS_H_
diff --git a/mojo/converters/surfaces/tests/BUILD.gn b/mojo/converters/surfaces/tests/BUILD.gn
deleted file mode 100644
index 2a9499d..0000000
--- a/mojo/converters/surfaces/tests/BUILD.gn
+++ /dev/null
@@ -1,30 +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.
-
-import("//testing/test.gni")
-
-test("mojo_surfaces_lib_unittests") {
- deps = [
- "//base",
- "//base/test:test_support",
- "//cc",
- "//cc/surfaces",
- "//gpu",
- "//mojo/converters/geometry",
- "//mojo/converters/surfaces",
- "//mojo/edk/test:run_all_unittests",
- "//mojo/environment:chromium",
- "//mojo/services/geometry/interfaces",
- "//mojo/services/surfaces/interfaces",
- "//skia",
- "//testing/gtest",
- "//ui/gfx",
- "//ui/gfx/geometry",
- "//ui/gfx:test_support",
- ]
-
- sources = [
- "surface_unittest.cc",
- ]
-}
diff --git a/mojo/converters/surfaces/tests/surface_unittest.cc b/mojo/converters/surfaces/tests/surface_unittest.cc
deleted file mode 100644
index 7e0a850..0000000
--- a/mojo/converters/surfaces/tests/surface_unittest.cc
+++ /dev/null
@@ -1,467 +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 "cc/quads/render_pass.h"
-#include "cc/quads/solid_color_draw_quad.h"
-#include "cc/quads/surface_draw_quad.h"
-#include "cc/quads/texture_draw_quad.h"
-#include "gpu/command_buffer/common/mailbox.h"
-#include "gpu/command_buffer/common/mailbox_holder.h"
-#include "mojo/converters/geometry/geometry_type_converters.h"
-#include "mojo/converters/surfaces/surfaces_type_converters.h"
-#include "testing/gtest/include/gtest/gtest.h"
-#include "third_party/skia/include/core/SkColor.h"
-#include "third_party/skia/include/core/SkXfermode.h"
-
-namespace mojo {
-namespace {
-
-TEST(SurfaceLibTest, SurfaceIdConverterNullId) {
- cc::SurfaceId null_id;
- cc::SurfaceId round_trip = SurfaceId::From(null_id).To<cc::SurfaceId>();
- EXPECT_TRUE(round_trip.is_null());
-}
-
-TEST(SurfaceLibTest, SurfaceIdConverterValidId) {
- cc::SurfaceId valid_id(7);
- cc::SurfaceId round_trip = SurfaceId::From(valid_id).To<cc::SurfaceId>();
- EXPECT_FALSE(round_trip.is_null());
- EXPECT_EQ(valid_id, round_trip);
-}
-
-TEST(SurfaceLibTest, Color) {
- SkColor arbitrary_color = SK_ColorMAGENTA;
- SkColor round_trip = Color::From(arbitrary_color).To<SkColor>();
- EXPECT_EQ(arbitrary_color, round_trip);
-}
-
-class SurfaceLibQuadTest : public testing::Test {
- public:
- SurfaceLibQuadTest()
- : rect(5, 7, 13, 19),
- opaque_rect(rect),
- visible_rect(9, 11, 5, 7),
- needs_blending(false) {
- pass = cc::RenderPass::Create();
- sqs = pass->CreateAndAppendSharedQuadState();
- }
-
- protected:
- gfx::Rect rect;
- gfx::Rect opaque_rect;
- gfx::Rect visible_rect;
- bool needs_blending;
- scoped_ptr<cc::RenderPass> pass;
- cc::SharedQuadState* sqs;
-};
-
-TEST_F(SurfaceLibQuadTest, ColorQuad) {
- cc::SolidColorDrawQuad* color_quad =
- pass->CreateAndAppendDrawQuad<cc::SolidColorDrawQuad>();
- SkColor arbitrary_color = SK_ColorGREEN;
- bool force_anti_aliasing_off = true;
- color_quad->SetAll(sqs,
- rect,
- opaque_rect,
- visible_rect,
- needs_blending,
- arbitrary_color,
- force_anti_aliasing_off);
-
- QuadPtr mojo_quad = Quad::From<cc::DrawQuad>(*color_quad);
- ASSERT_FALSE(mojo_quad.is_null());
- EXPECT_EQ(Material::SOLID_COLOR, mojo_quad->material);
- EXPECT_TRUE(Rect::From(rect)->Equals(*mojo_quad->rect));
- EXPECT_TRUE(Rect::From(opaque_rect)->Equals(*mojo_quad->opaque_rect));
- EXPECT_TRUE(Rect::From(visible_rect)->Equals(*mojo_quad->visible_rect));
- EXPECT_EQ(needs_blending, mojo_quad->needs_blending);
- ASSERT_TRUE(mojo_quad->solid_color_quad_state);
- SolidColorQuadStatePtr& mojo_color_state = mojo_quad->solid_color_quad_state;
- EXPECT_TRUE(Color::From(arbitrary_color)->Equals(*mojo_color_state->color));
- EXPECT_EQ(force_anti_aliasing_off, mojo_color_state->force_anti_aliasing_off);
-}
-
-TEST_F(SurfaceLibQuadTest, SurfaceQuad) {
- cc::SurfaceDrawQuad* surface_quad =
- pass->CreateAndAppendDrawQuad<cc::SurfaceDrawQuad>();
- cc::SurfaceId arbitrary_id(5);
- surface_quad->SetAll(
- sqs, rect, opaque_rect, visible_rect, needs_blending, arbitrary_id);
-
- QuadPtr mojo_quad = Quad::From<cc::DrawQuad>(*surface_quad);
- ASSERT_FALSE(mojo_quad.is_null());
- EXPECT_EQ(Material::SURFACE_CONTENT, mojo_quad->material);
- ASSERT_TRUE(mojo_quad->surface_quad_state);
- SurfaceQuadStatePtr& mojo_surface_state = mojo_quad->surface_quad_state;
- EXPECT_TRUE(
- SurfaceId::From(arbitrary_id)->Equals(*mojo_surface_state->surface));
-}
-
-TEST_F(SurfaceLibQuadTest, TextureQuad) {
- cc::TextureDrawQuad* texture_quad =
- pass->CreateAndAppendDrawQuad<cc::TextureDrawQuad>();
- unsigned resource_id = 9;
- bool premultiplied_alpha = true;
- gfx::PointF uv_top_left(1.7f, 2.1f);
- gfx::PointF uv_bottom_right(-7.f, 16.3f);
- SkColor background_color = SK_ColorYELLOW;
- float vertex_opacity[4] = {0.1f, 0.5f, 0.4f, 0.8f};
- bool flipped = false;
- bool nearest_neighbor = false;
- texture_quad->SetAll(sqs,
- rect,
- opaque_rect,
- visible_rect,
- needs_blending,
- resource_id,
- premultiplied_alpha,
- uv_top_left,
- uv_bottom_right,
- background_color,
- vertex_opacity,
- flipped,
- nearest_neighbor);
-
- QuadPtr mojo_quad = Quad::From<cc::DrawQuad>(*texture_quad);
- ASSERT_FALSE(mojo_quad.is_null());
- EXPECT_EQ(Material::TEXTURE_CONTENT, mojo_quad->material);
- ASSERT_TRUE(mojo_quad->texture_quad_state);
- TextureQuadStatePtr& mojo_texture_state = mojo_quad->texture_quad_state;
- EXPECT_EQ(resource_id, mojo_texture_state->resource_id);
- EXPECT_EQ(premultiplied_alpha, mojo_texture_state->premultiplied_alpha);
- EXPECT_TRUE(
- PointF::From(uv_top_left)->Equals(*mojo_texture_state->uv_top_left));
- EXPECT_TRUE(PointF::From(uv_bottom_right)
- ->Equals(*mojo_texture_state->uv_bottom_right));
- EXPECT_TRUE(Color::From(background_color)
- ->Equals(*mojo_texture_state->background_color));
- for (size_t i = 0; i < 4; ++i) {
- EXPECT_EQ(vertex_opacity[i], mojo_texture_state->vertex_opacity[i]) << i;
- }
- EXPECT_EQ(flipped, mojo_texture_state->flipped);
-}
-
-TEST_F(SurfaceLibQuadTest, TextureQuadEmptyVertexOpacity) {
- QuadPtr mojo_texture_quad = Quad::New();
- mojo_texture_quad->material = Material::TEXTURE_CONTENT;
- TextureQuadStatePtr mojo_texture_state = TextureQuadState::New();
- mojo_texture_state->background_color = Color::New();
- mojo_texture_quad->texture_quad_state = mojo_texture_state.Pass();
- PassPtr mojo_pass = Pass::New();
- mojo_pass->quads.push_back(mojo_texture_quad.Pass());
- SharedQuadStatePtr mojo_sqs = SharedQuadState::New();
- mojo_pass->shared_quad_states.push_back(mojo_sqs.Pass());
-
- scoped_ptr<cc::RenderPass> pass = mojo_pass.To<scoped_ptr<cc::RenderPass> >();
-
- EXPECT_FALSE(pass);
-}
-
-TEST_F(SurfaceLibQuadTest, TextureQuadEmptyBackgroundColor) {
- QuadPtr mojo_texture_quad = Quad::New();
- mojo_texture_quad->material = Material::TEXTURE_CONTENT;
- TextureQuadStatePtr mojo_texture_state = TextureQuadState::New();
- mojo_texture_state->vertex_opacity = mojo::Array<float>::New(4);
- mojo_texture_quad->texture_quad_state = mojo_texture_state.Pass();
- PassPtr mojo_pass = Pass::New();
- mojo_pass->quads.push_back(mojo_texture_quad.Pass());
- SharedQuadStatePtr mojo_sqs = SharedQuadState::New();
- mojo_pass->shared_quad_states.push_back(mojo_sqs.Pass());
-
- scoped_ptr<cc::RenderPass> pass = mojo_pass.To<scoped_ptr<cc::RenderPass> >();
- EXPECT_FALSE(pass);
-}
-
-TEST(SurfaceLibTest, SharedQuadState) {
- gfx::Transform content_to_target_transform;
- content_to_target_transform.Scale3d(0.3f, 0.7f, 0.9f);
- gfx::Size content_bounds(57, 39);
- gfx::Rect visible_content_rect(3, 7, 28, 42);
- gfx::Rect clip_rect(9, 12, 21, 31);
- bool is_clipped = true;
- float opacity = 0.65f;
- int sorting_context_id = 13;
- ::SkXfermode::Mode blend_mode = ::SkXfermode::kSrcOver_Mode;
- scoped_ptr<cc::RenderPass> pass = cc::RenderPass::Create();
- cc::SharedQuadState* sqs = pass->CreateAndAppendSharedQuadState();
- sqs->SetAll(content_to_target_transform,
- content_bounds,
- visible_content_rect,
- clip_rect,
- is_clipped,
- opacity,
- blend_mode,
- sorting_context_id);
-
- SharedQuadStatePtr mojo_sqs = SharedQuadState::From(*sqs);
- ASSERT_FALSE(mojo_sqs.is_null());
- EXPECT_TRUE(Transform::From(content_to_target_transform)
- ->Equals(*mojo_sqs->content_to_target_transform));
- EXPECT_TRUE(Size::From(content_bounds)->Equals(*mojo_sqs->content_bounds));
- EXPECT_TRUE(Rect::From(visible_content_rect)
- ->Equals(*mojo_sqs->visible_content_rect));
- EXPECT_TRUE(Rect::From(clip_rect)->Equals(*mojo_sqs->clip_rect));
- EXPECT_EQ(is_clipped, mojo_sqs->is_clipped);
- EXPECT_EQ(opacity, mojo_sqs->opacity);
- EXPECT_EQ(sorting_context_id, mojo_sqs->sorting_context_id);
-}
-
-TEST(SurfaceLibTest, RenderPass) {
- scoped_ptr<cc::RenderPass> pass = cc::RenderPass::Create();
- cc::RenderPassId pass_id(1, 6);
- gfx::Rect output_rect(4, 9, 13, 71);
- gfx::Rect damage_rect(9, 17, 41, 45);
- gfx::Transform transform_to_root_target;
- transform_to_root_target.SkewY(43.0);
- bool has_transparent_background = false;
- pass->SetAll(pass_id,
- output_rect,
- damage_rect,
- transform_to_root_target,
- has_transparent_background);
-
- gfx::Transform content_to_target_transform;
- content_to_target_transform.Scale3d(0.3f, 0.7f, 0.9f);
- gfx::Size content_bounds(57, 39);
- gfx::Rect visible_content_rect(3, 7, 28, 42);
- gfx::Rect clip_rect(9, 12, 21, 31);
- bool is_clipped = true;
- float opacity = 0.65f;
- int sorting_context_id = 13;
- ::SkXfermode::Mode blend_mode = ::SkXfermode::kSrcOver_Mode;
- cc::SharedQuadState* sqs = pass->CreateAndAppendSharedQuadState();
- sqs->SetAll(content_to_target_transform,
- content_bounds,
- visible_content_rect,
- clip_rect,
- is_clipped,
- opacity,
- blend_mode,
- sorting_context_id);
-
- gfx::Rect rect(5, 7, 13, 19);
- gfx::Rect opaque_rect(rect);
- gfx::Rect visible_rect(9, 11, 5, 7);
- bool needs_blending = false;
-
- cc::SolidColorDrawQuad* color_quad =
- pass->CreateAndAppendDrawQuad<cc::SolidColorDrawQuad>();
- SkColor arbitrary_color = SK_ColorGREEN;
- bool force_anti_aliasing_off = true;
- color_quad->SetAll(pass->shared_quad_state_list.back(),
- rect,
- opaque_rect,
- visible_rect,
- needs_blending,
- arbitrary_color,
- force_anti_aliasing_off);
-
- cc::SurfaceDrawQuad* surface_quad =
- pass->CreateAndAppendDrawQuad<cc::SurfaceDrawQuad>();
- cc::SurfaceId arbitrary_id(5);
- surface_quad->SetAll(
- sqs, rect, opaque_rect, visible_rect, needs_blending, arbitrary_id);
-
- cc::TextureDrawQuad* texture_quad =
- pass->CreateAndAppendDrawQuad<cc::TextureDrawQuad>();
- unsigned resource_id = 9;
- bool premultiplied_alpha = true;
- gfx::PointF uv_top_left(1.7f, 2.1f);
- gfx::PointF uv_bottom_right(-7.f, 16.3f);
- SkColor background_color = SK_ColorYELLOW;
- float vertex_opacity[4] = {0.1f, 0.5f, 0.4f, 0.8f};
- bool flipped = false;
- bool nearest_neighbor = false;
- texture_quad->SetAll(sqs,
- rect,
- opaque_rect,
- visible_rect,
- needs_blending,
- resource_id,
- premultiplied_alpha,
- uv_top_left,
- uv_bottom_right,
- background_color,
- vertex_opacity,
- flipped,
- nearest_neighbor);
-
- PassPtr mojo_pass = Pass::From(*pass);
- ASSERT_FALSE(mojo_pass.is_null());
- EXPECT_EQ(6, mojo_pass->id);
- EXPECT_TRUE(Rect::From(output_rect)->Equals(*mojo_pass->output_rect));
- EXPECT_TRUE(Rect::From(damage_rect)->Equals(*mojo_pass->damage_rect));
- EXPECT_TRUE(Transform::From(transform_to_root_target)
- ->Equals(*mojo_pass->transform_to_root_target));
- EXPECT_EQ(has_transparent_background, mojo_pass->has_transparent_background);
- ASSERT_EQ(1u, mojo_pass->shared_quad_states.size());
- ASSERT_EQ(3u, mojo_pass->quads.size());
- EXPECT_EQ(0u, mojo_pass->quads[0]->shared_quad_state_index);
-
- scoped_ptr<cc::RenderPass> round_trip_pass =
- mojo_pass.To<scoped_ptr<cc::RenderPass> >();
- EXPECT_EQ(pass_id, round_trip_pass->id);
- EXPECT_EQ(output_rect, round_trip_pass->output_rect);
- EXPECT_EQ(damage_rect, round_trip_pass->damage_rect);
- EXPECT_EQ(transform_to_root_target,
- round_trip_pass->transform_to_root_target);
- EXPECT_EQ(has_transparent_background,
- round_trip_pass->has_transparent_background);
- ASSERT_EQ(1u, round_trip_pass->shared_quad_state_list.size());
- ASSERT_EQ(3u, round_trip_pass->quad_list.size());
- EXPECT_EQ(round_trip_pass->shared_quad_state_list.front(),
- round_trip_pass->quad_list.front()->shared_quad_state);
-
- cc::SharedQuadState* round_trip_sqs =
- round_trip_pass->shared_quad_state_list.front();
- EXPECT_EQ(content_to_target_transform,
- round_trip_sqs->content_to_target_transform);
- EXPECT_EQ(content_bounds, round_trip_sqs->content_bounds);
- EXPECT_EQ(visible_content_rect, round_trip_sqs->visible_content_rect);
- EXPECT_EQ(clip_rect, round_trip_sqs->clip_rect);
- EXPECT_EQ(is_clipped, round_trip_sqs->is_clipped);
- EXPECT_EQ(opacity, round_trip_sqs->opacity);
- EXPECT_EQ(sorting_context_id, round_trip_sqs->sorting_context_id);
-
- cc::DrawQuad* round_trip_quad = round_trip_pass->quad_list.front();
- // First is solid color quad.
- ASSERT_EQ(cc::DrawQuad::SOLID_COLOR, round_trip_quad->material);
- EXPECT_EQ(rect, round_trip_quad->rect);
- EXPECT_EQ(opaque_rect, round_trip_quad->opaque_rect);
- EXPECT_EQ(visible_rect, round_trip_quad->visible_rect);
- EXPECT_EQ(needs_blending, round_trip_quad->needs_blending);
- const cc::SolidColorDrawQuad* round_trip_color_quad =
- cc::SolidColorDrawQuad::MaterialCast(round_trip_quad);
- EXPECT_EQ(arbitrary_color, round_trip_color_quad->color);
- EXPECT_EQ(force_anti_aliasing_off,
- round_trip_color_quad->force_anti_aliasing_off);
-
- round_trip_quad = round_trip_pass->quad_list.ElementAt(1);
- // Second is surface quad.
- ASSERT_EQ(cc::DrawQuad::SURFACE_CONTENT, round_trip_quad->material);
- const cc::SurfaceDrawQuad* round_trip_surface_quad =
- cc::SurfaceDrawQuad::MaterialCast(round_trip_quad);
- EXPECT_EQ(arbitrary_id, round_trip_surface_quad->surface_id);
-
- round_trip_quad = round_trip_pass->quad_list.ElementAt(2);
- // Third is texture quad.
- ASSERT_EQ(cc::DrawQuad::TEXTURE_CONTENT, round_trip_quad->material);
- const cc::TextureDrawQuad* round_trip_texture_quad =
- cc::TextureDrawQuad::MaterialCast(round_trip_quad);
- EXPECT_EQ(resource_id, round_trip_texture_quad->resource_id);
- EXPECT_EQ(premultiplied_alpha, round_trip_texture_quad->premultiplied_alpha);
- EXPECT_EQ(uv_top_left, round_trip_texture_quad->uv_top_left);
- EXPECT_EQ(uv_bottom_right, round_trip_texture_quad->uv_bottom_right);
- EXPECT_EQ(background_color, round_trip_texture_quad->background_color);
- for (size_t i = 0; i < 4; ++i) {
- EXPECT_EQ(vertex_opacity[i], round_trip_texture_quad->vertex_opacity[i])
- << i;
- }
- EXPECT_EQ(flipped, round_trip_texture_quad->flipped);
-}
-
-TEST(SurfaceLibTest, Mailbox) {
- gpu::Mailbox mailbox;
- mailbox.Generate();
-
- MailboxPtr mojo_mailbox = Mailbox::From(mailbox);
- EXPECT_EQ(0, memcmp(mailbox.name, &mojo_mailbox->name.storage()[0], 64));
-
- gpu::Mailbox round_trip_mailbox = mojo_mailbox.To<gpu::Mailbox>();
- EXPECT_EQ(mailbox, round_trip_mailbox);
-}
-
-TEST(SurfaceLibTest, MailboxEmptyName) {
- MailboxPtr mojo_mailbox = Mailbox::New();
-
- gpu::Mailbox converted_mailbox = mojo_mailbox.To<gpu::Mailbox>();
- EXPECT_TRUE(converted_mailbox.IsZero());
-}
-
-TEST(SurfaceLibTest, MailboxHolder) {
- gpu::Mailbox mailbox;
- mailbox.Generate();
- uint32_t texture_target = GL_TEXTURE_2D;
- uint32_t sync_point = 7u;
- gpu::MailboxHolder holder(mailbox, texture_target, sync_point);
-
- MailboxHolderPtr mojo_holder = MailboxHolder::From(holder);
- EXPECT_EQ(texture_target, mojo_holder->texture_target);
- EXPECT_EQ(sync_point, mojo_holder->sync_point);
-
- gpu::MailboxHolder round_trip_holder = mojo_holder.To<gpu::MailboxHolder>();
- EXPECT_EQ(mailbox, round_trip_holder.mailbox);
- EXPECT_EQ(texture_target, round_trip_holder.texture_target);
- EXPECT_EQ(sync_point, round_trip_holder.sync_point);
-}
-
-TEST(SurfaceLibTest, TransferableResource) {
- uint32_t id = 7u;
- cc::ResourceFormat format = cc::BGRA_8888;
- uint32_t filter = 123u;
- gfx::Size size(17, 18);
- gpu::MailboxHolder mailbox_holder;
- bool is_repeated = false;
- ;
- bool is_software = false;
- cc::TransferableResource resource;
- resource.id = id;
- resource.format = format;
- resource.filter = filter;
- resource.size = size;
- resource.mailbox_holder = mailbox_holder;
- resource.is_repeated = is_repeated;
- resource.is_software = is_software;
-
- TransferableResourcePtr mojo_resource = TransferableResource::From(resource);
- EXPECT_EQ(id, mojo_resource->id);
- EXPECT_EQ(static_cast<ResourceFormat>(format),
- mojo_resource->format);
- EXPECT_EQ(filter, mojo_resource->filter);
- EXPECT_TRUE(Size::From(size)->Equals(*mojo_resource->size));
- EXPECT_EQ(is_repeated, mojo_resource->is_repeated);
- EXPECT_EQ(is_software, mojo_resource->is_software);
-
- cc::TransferableResource round_trip_resource =
- mojo_resource.To<cc::TransferableResource>();
- EXPECT_EQ(id, round_trip_resource.id);
- EXPECT_EQ(format, round_trip_resource.format);
- EXPECT_EQ(filter, round_trip_resource.filter);
- EXPECT_EQ(size, round_trip_resource.size);
- EXPECT_EQ(mailbox_holder.mailbox, round_trip_resource.mailbox_holder.mailbox);
- EXPECT_EQ(mailbox_holder.texture_target,
- round_trip_resource.mailbox_holder.texture_target);
- EXPECT_EQ(mailbox_holder.sync_point,
- round_trip_resource.mailbox_holder.sync_point);
- EXPECT_EQ(is_repeated, round_trip_resource.is_repeated);
- EXPECT_EQ(is_software, round_trip_resource.is_software);
-}
-
-TEST(SurfaceLibTest, ReturnedResource) {
- uint32_t id = 5u;
- uint32_t sync_point = 24u;
- int count = 2;
- bool lost = false;
- cc::ReturnedResource resource;
- resource.id = id;
- resource.sync_point = sync_point;
- resource.count = count;
- resource.lost = lost;
-
- ReturnedResourcePtr mojo_resource = ReturnedResource::From(resource);
- EXPECT_EQ(id, mojo_resource->id);
- EXPECT_EQ(sync_point, mojo_resource->sync_point);
- EXPECT_EQ(count, mojo_resource->count);
- EXPECT_EQ(lost, mojo_resource->lost);
-
- cc::ReturnedResource round_trip_resource =
- mojo_resource.To<cc::ReturnedResource>();
- EXPECT_EQ(id, round_trip_resource.id);
- EXPECT_EQ(sync_point, round_trip_resource.sync_point);
- EXPECT_EQ(count, round_trip_resource.count);
- EXPECT_EQ(lost, round_trip_resource.lost);
-}
-
-} // namespace
-} // namespace mojo
diff --git a/mojo/services/native_viewport/interfaces/BUILD.gn b/mojo/services/native_viewport/interfaces/BUILD.gn
index 49a7d96..f412fe2 100644
--- a/mojo/services/native_viewport/interfaces/BUILD.gn
+++ b/mojo/services/native_viewport/interfaces/BUILD.gn
@@ -16,6 +16,5 @@
"../../geometry/interfaces",
"../../gpu/interfaces",
"../../input_events/interfaces",
- "../../surfaces/interfaces:surface_id",
]
}
diff --git a/services/BUILD.gn b/services/BUILD.gn
index e44f1c2..9492f21 100644
--- a/services/BUILD.gn
+++ b/services/BUILD.gn
@@ -12,7 +12,6 @@
"//services/authentication",
"//services/clipboard",
"//services/dart",
- "//services/fake_surfaces",
"//services/gles2:lib",
"//services/http_server",
"//services/icu_data",
@@ -54,7 +53,6 @@
"//services/files",
"//services/ui",
"//services/native_viewport",
- "//services/surfaces",
"//services/url_response_disk_cache",
]
}
diff --git a/services/fake_surfaces/BUILD.gn b/services/fake_surfaces/BUILD.gn
deleted file mode 100644
index 187952e..0000000
--- a/services/fake_surfaces/BUILD.gn
+++ /dev/null
@@ -1,23 +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.
-
-import("//mojo/public/mojo_application.gni")
-
-mojo_native_application("fake_surfaces") {
- output_name = "fake_surfaces_service"
- sources = [
- "fake_surfaces_service_application.cc",
- "fake_surfaces_service_application.h",
- ]
-
- deps = [
- "//base",
- "//mojo/application",
- "//mojo/common:tracing_impl",
- "//mojo/environment:chromium",
- "//mojo/public/cpp/bindings",
- "//mojo/services/gpu/interfaces",
- "//mojo/services/surfaces/interfaces",
- ]
-}
diff --git a/services/fake_surfaces/fake_surfaces_service_application.cc b/services/fake_surfaces/fake_surfaces_service_application.cc
deleted file mode 100644
index 4eb25c3..0000000
--- a/services/fake_surfaces/fake_surfaces_service_application.cc
+++ /dev/null
@@ -1,151 +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 "services/fake_surfaces/fake_surfaces_service_application.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/bindings/strong_binding.h"
-#include "mojo/services/surfaces/interfaces/surfaces.mojom.h"
-
-using mojo::ApplicationConnection;
-using mojo::Display;
-using mojo::DisplayFactory;
-using mojo::InterfaceRequest;
-using mojo::ResourceReturnerPtr;
-using mojo::StrongBinding;
-using mojo::Surface;
-
-namespace fake_surfaces {
-
-namespace {
-void ReturnAll(const mojo::Array<mojo::TransferableResourcePtr>& resources,
- mojo::ResourceReturner* returner) {
- mojo::Array<mojo::ReturnedResourcePtr> returned;
- returned.resize(resources.size());
- for (size_t i = 0; i < resources.size(); ++i) {
- auto ret = mojo::ReturnedResource::New();
- ret->id = resources[i]->id;
- ret->sync_point = 0u;
- ret->count = 1;
- ret->lost = false;
- returned[i] = ret.Pass();
- }
- returner->ReturnResources(returned.Pass());
-}
-
-} // namespace
-
-class FakeDisplayImpl : public Display {
- public:
- FakeDisplayImpl(ResourceReturnerPtr returner,
- InterfaceRequest<Display> request)
- : returner_(returner.Pass()), binding_(this, request.Pass()) {}
- ~FakeDisplayImpl() override {}
-
- private:
- // Display implementation
- void SubmitFrame(mojo::FramePtr frame,
- const SubmitFrameCallback& callback) override {
- callback.Run();
- if (frame->resources.size() == 0u || !returner_)
- return;
- ReturnAll(frame->resources, returner_.get());
- }
-
- ResourceReturnerPtr returner_;
- StrongBinding<Display> binding_;
-};
-
-class FakeDisplayFactoryImpl : public DisplayFactory {
- public:
- explicit FakeDisplayFactoryImpl(InterfaceRequest<DisplayFactory> request)
- : binding_(this, request.Pass()) {}
- ~FakeDisplayFactoryImpl() override {}
-
- private:
- // DisplayFactory implementation.
- void Create(mojo::ContextProviderPtr context_provider,
- ResourceReturnerPtr returner,
- InterfaceRequest<Display> request) override {
- new FakeDisplayImpl(returner.Pass(), request.Pass());
- }
-
- StrongBinding<DisplayFactory> binding_;
-};
-
-class FakeSurfaceImpl : public Surface {
- public:
- FakeSurfaceImpl(uint32_t id_namespace, InterfaceRequest<Surface> request)
- : id_namespace_(id_namespace), binding_(this, request.Pass()) {}
- ~FakeSurfaceImpl() override {}
-
- // Surface implementation.
- void GetIdNamespace(
- const Surface::GetIdNamespaceCallback& callback) override {
- callback.Run(id_namespace_);
- }
-
- void SetResourceReturner(ResourceReturnerPtr returner) override {
- returner_ = returner.Pass();
- }
-
- void CreateSurface(uint32_t local_id) override {}
-
- void SubmitFrame(uint32_t local_id,
- mojo::FramePtr frame,
- const SubmitFrameCallback& callback) override {
- callback.Run();
- if (frame->resources.size() == 0u || !returner_)
- return;
- ReturnAll(frame->resources, returner_.get());
- }
-
- void DestroySurface(uint32_t local_id) override {}
-
- private:
- const uint32_t id_namespace_;
- ResourceReturnerPtr returner_;
- StrongBinding<Surface> binding_;
-
- DISALLOW_COPY_AND_ASSIGN(FakeSurfaceImpl);
-};
-
-FakeSurfacesServiceApplication::FakeSurfacesServiceApplication()
- : next_id_namespace_(1u) {
-}
-
-FakeSurfacesServiceApplication::~FakeSurfacesServiceApplication() {
-}
-
-void FakeSurfacesServiceApplication::Initialize(mojo::ApplicationImpl* app) {
- tracing_.Initialize(app);
-}
-
-bool FakeSurfacesServiceApplication::ConfigureIncomingConnection(
- ApplicationConnection* connection) {
- connection->AddService<DisplayFactory>(this);
- connection->AddService<Surface>(this);
- return true;
-}
-
-void FakeSurfacesServiceApplication::Create(
- ApplicationConnection* connection,
- InterfaceRequest<DisplayFactory> request) {
- new FakeDisplayFactoryImpl(request.Pass());
-}
-
-void FakeSurfacesServiceApplication::Create(ApplicationConnection* connection,
- InterfaceRequest<Surface> request) {
- new FakeSurfaceImpl(next_id_namespace_++, request.Pass());
-}
-
-} // namespace fake_surfaces
-
-MojoResult MojoMain(MojoHandle application_request) {
- mojo::ApplicationRunnerChromium runner(
- new fake_surfaces::FakeSurfacesServiceApplication);
- return runner.Run(application_request);
-}
diff --git a/services/fake_surfaces/fake_surfaces_service_application.h b/services/fake_surfaces/fake_surfaces_service_application.h
deleted file mode 100644
index 8b02782..0000000
--- a/services/fake_surfaces/fake_surfaces_service_application.h
+++ /dev/null
@@ -1,51 +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.
-
-#ifndef FAKE_SERVICES_SURFACES_SURFACES_SERVICE_APPLICATION_H_
-#define FAKE_SERVICES_SURFACES_SURFACES_SERVICE_APPLICATION_H_
-
-#include "base/macros.h"
-#include "mojo/common/tracing_impl.h"
-#include "mojo/public/cpp/application/application_delegate.h"
-#include "mojo/public/cpp/application/interface_factory.h"
-#include "mojo/services/surfaces/interfaces/display.mojom.h"
-#include "mojo/services/surfaces/interfaces/surfaces.mojom.h"
-
-namespace mojo {
-class ApplicationConnection;
-}
-
-namespace fake_surfaces {
-
-class FakeSurfacesServiceApplication
- : public mojo::ApplicationDelegate,
- public mojo::InterfaceFactory<mojo::DisplayFactory>,
- public mojo::InterfaceFactory<mojo::Surface> {
- public:
- FakeSurfacesServiceApplication();
- ~FakeSurfacesServiceApplication() override;
-
- // ApplicationDelegate implementation.
- void Initialize(mojo::ApplicationImpl* app) override;
- bool ConfigureIncomingConnection(
- mojo::ApplicationConnection* connection) override;
-
- // InterfaceFactory<mojo::DisplayFactory> implementation.
- void Create(mojo::ApplicationConnection* connection,
- mojo::InterfaceRequest<mojo::DisplayFactory> request) override;
-
- // InterfaceFactory<mojo::Surface> implementation.
- void Create(mojo::ApplicationConnection* connection,
- mojo::InterfaceRequest<mojo::Surface> request) override;
-
- private:
- uint32_t next_id_namespace_;
- mojo::TracingImpl tracing_;
-
- DISALLOW_COPY_AND_ASSIGN(FakeSurfacesServiceApplication);
-};
-
-} // namespace fake_surfaces
-
-#endif // FAKE_SERVICES_SURFACES_SURFACES_SERVICE_APPLICATION_H_
diff --git a/services/surfaces/BUILD.gn b/services/surfaces/BUILD.gn
deleted file mode 100644
index 1cdc736..0000000
--- a/services/surfaces/BUILD.gn
+++ /dev/null
@@ -1,48 +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.
-
-import("//mojo/public/mojo_application.gni")
-
-mojo_native_application("surfaces") {
- output_name = "surfaces_service"
- sources = [
- "context_provider_mojo.cc",
- "context_provider_mojo.h",
- "display_factory_impl.cc",
- "display_factory_impl.h",
- "display_impl.cc",
- "display_impl.h",
- "surfaces_impl.cc",
- "surfaces_impl.h",
- "surfaces_output_surface.cc",
- "surfaces_output_surface.h",
- "surfaces_scheduler.cc",
- "surfaces_scheduler.h",
- "surfaces_service_application.cc",
- "surfaces_service_application.h",
- ]
-
- deps = [
- "//base",
- "//cc",
- "//cc/surfaces",
- "//cc/surfaces:surface_id",
- "//gpu/command_buffer/client:gles2_interface",
- "//mojo/application",
- "//mojo/common",
- "//mojo/common:tracing_impl",
- "//mojo/converters/geometry",
- "//mojo/converters/surfaces",
- "//mojo/environment:chromium",
- "//mojo/gpu",
- "//mojo/public/c/gpu",
- "//mojo/public/cpp/bindings",
- "//mojo/public/cpp/environment",
- "//mojo/public/cpp/system",
- "//mojo/services/geometry/interfaces",
- "//mojo/services/gpu/interfaces",
- "//mojo/services/surfaces/interfaces",
- "//ui/gfx/geometry",
- ]
-}
diff --git a/services/surfaces/context_provider_mojo.cc b/services/surfaces/context_provider_mojo.cc
deleted file mode 100644
index 9bc4ee5..0000000
--- a/services/surfaces/context_provider_mojo.cc
+++ /dev/null
@@ -1,79 +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 "services/surfaces/context_provider_mojo.h"
-
-#include "base/logging.h"
-#include "mojo/gpu/mojo_context_support.h"
-#include "mojo/gpu/mojo_gles2_impl_autogen.h"
-#include "mojo/public/cpp/environment/environment.h"
-
-namespace mojo {
-
-ContextProviderMojo::ContextProviderMojo(
- ScopedMessagePipeHandle command_buffer_handle)
- : command_buffer_handle_(command_buffer_handle.Pass()),
- context_(nullptr),
- context_lost_(false) {
-}
-
-bool ContextProviderMojo::BindToCurrentThread() {
- DCHECK(command_buffer_handle_.is_valid());
- context_ = MGLCreateContext(MGL_API_VERSION_GLES2,
- command_buffer_handle_.release().value(),
- MGL_NO_CONTEXT, &ContextLostThunk, this,
- Environment::GetDefaultAsyncWaiter());
- DCHECK(context_);
- context_support_.reset(new MojoContextSupport(context_));
- gles2_impl_.reset(new MojoGLES2Impl(context_));
- return !!context_;
-}
-
-gpu::gles2::GLES2Interface* ContextProviderMojo::ContextGL() {
- return gles2_impl_.get();
-}
-
-gpu::ContextSupport* ContextProviderMojo::ContextSupport() {
- return context_support_.get();
-}
-
-class GrContext* ContextProviderMojo::GrContext() {
- return NULL;
-}
-
-cc::ContextProvider::Capabilities ContextProviderMojo::ContextCapabilities() {
- return capabilities_;
-}
-
-void ContextProviderMojo::SetupLock() {
-}
-
-base::Lock* ContextProviderMojo::GetLock() {
- return &context_lock_;
-}
-
-bool ContextProviderMojo::IsContextLost() {
- return context_lost_;
-}
-bool ContextProviderMojo::DestroyedOnMainThread() {
- return !context_;
-}
-
-void ContextProviderMojo::SetLostContextCallback(
- const LostContextCallback& lost_context_callback) {
- lost_context_callback_ = lost_context_callback;
-}
-
-ContextProviderMojo::~ContextProviderMojo() {
- if (context_)
- MGLDestroyContext(context_);
-}
-
-void ContextProviderMojo::ContextLost() {
- context_lost_ = true;
- if (!lost_context_callback_.is_null())
- lost_context_callback_.Run();
-}
-
-} // namespace mojo
diff --git a/services/surfaces/context_provider_mojo.h b/services/surfaces/context_provider_mojo.h
deleted file mode 100644
index c7d7f58..0000000
--- a/services/surfaces/context_provider_mojo.h
+++ /dev/null
@@ -1,69 +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.
-
-#ifndef SERVICES_SURFACES_CONTEXT_PROVIDER_MOJO_H_
-#define SERVICES_SURFACES_CONTEXT_PROVIDER_MOJO_H_
-
-#include <MGL/mgl.h>
-
-#include "base/macros.h"
-#include "base/synchronization/lock.h"
-#include "cc/output/context_provider.h"
-#include "gpu/command_buffer/client/gles2_interface.h"
-#include "mojo/gpu/mojo_context_support.h"
-#include "mojo/public/cpp/system/core.h"
-
-namespace mojo {
-
-class MojoContextSupport;
-class MojoGLES2Impl;
-
-class ContextProviderMojo : public cc::ContextProvider {
- public:
- explicit ContextProviderMojo(ScopedMessagePipeHandle command_buffer_handle);
-
- // cc::ContextProvider implementation.
- bool BindToCurrentThread() override;
- gpu::gles2::GLES2Interface* ContextGL() override;
- gpu::ContextSupport* ContextSupport() override;
- class GrContext* GrContext() override;
- Capabilities ContextCapabilities() override;
- bool IsContextLost() override;
- void VerifyContexts() override {}
- void DeleteCachedResources() override {}
- bool DestroyedOnMainThread() override;
- void SetLostContextCallback(
- const LostContextCallback& lost_context_callback) override;
- void SetMemoryPolicyChangedCallback(
- const MemoryPolicyChangedCallback& memory_policy_changed_callback)
- override {}
- void SetupLock() override;
- base::Lock* GetLock() override;
-
- protected:
- friend class base::RefCountedThreadSafe<ContextProviderMojo>;
- ~ContextProviderMojo() override;
-
- private:
- static void ContextLostThunk(void* closure) {
- static_cast<ContextProviderMojo*>(closure)->ContextLost();
- }
- void ContextLost();
-
- cc::ContextProvider::Capabilities capabilities_;
- ScopedMessagePipeHandle command_buffer_handle_;
- MGLContext context_;
- scoped_ptr<MojoGLES2Impl> gles2_impl_;
- scoped_ptr<MojoContextSupport> context_support_;
- bool context_lost_;
- LostContextCallback lost_context_callback_;
-
- base::Lock context_lock_;
-
- DISALLOW_COPY_AND_ASSIGN(ContextProviderMojo);
-};
-
-} // namespace mojo
-
-#endif // SERVICES_SURFACES_CONTEXT_PROVIDER_MOJO_H_
diff --git a/services/surfaces/display_factory_impl.cc b/services/surfaces/display_factory_impl.cc
deleted file mode 100644
index cee2ca2..0000000
--- a/services/surfaces/display_factory_impl.cc
+++ /dev/null
@@ -1,36 +0,0 @@
-// Copyright 2015 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 "services/surfaces/display_factory_impl.h"
-
-#include "cc/surfaces/surface_id.h"
-
-namespace surfaces {
-
-DisplayFactoryImpl::DisplayFactoryImpl(
- cc::SurfaceManager* manager,
- uint32_t id_namespace,
- SurfacesScheduler* scheduler,
- mojo::InterfaceRequest<mojo::DisplayFactory> request)
- : id_namespace_(id_namespace),
- next_local_id_(1u),
- scheduler_(scheduler),
- manager_(manager),
- binding_(this, request.Pass()) {
-}
-
-DisplayFactoryImpl::~DisplayFactoryImpl() {
-}
-
-void DisplayFactoryImpl::Create(
- mojo::ContextProviderPtr context_provider,
- mojo::ResourceReturnerPtr returner,
- mojo::InterfaceRequest<mojo::Display> display_request) {
- cc::SurfaceId cc_id(static_cast<uint64_t>(id_namespace_) << 32 |
- next_local_id_++);
- new DisplayImpl(manager_, cc_id, scheduler_, context_provider.Pass(),
- returner.Pass(), display_request.Pass());
-}
-
-} // namespace surfaces
diff --git a/services/surfaces/display_factory_impl.h b/services/surfaces/display_factory_impl.h
deleted file mode 100644
index 745b9f0..0000000
--- a/services/surfaces/display_factory_impl.h
+++ /dev/null
@@ -1,44 +0,0 @@
-// Copyright 2015 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 SERVICES_SURFACES_DISPLAY_FACTORY_IMPL_H_
-#define SERVICES_SURFACES_DISPLAY_FACTORY_IMPL_H_
-
-#include "mojo/public/cpp/bindings/strong_binding.h"
-#include "mojo/services/surfaces/interfaces/display.mojom.h"
-#include "services/surfaces/display_impl.h"
-
-namespace cc {
-class SurfaceManager;
-}
-
-namespace surfaces {
-class SurfacesScheduler;
-
-class DisplayFactoryImpl : public mojo::DisplayFactory {
- public:
- DisplayFactoryImpl(cc::SurfaceManager* manager,
- uint32_t id_namespace,
- SurfacesScheduler* scheduler,
- mojo::InterfaceRequest<mojo::DisplayFactory> request);
- ~DisplayFactoryImpl() override;
-
- private:
- // mojo::DisplayFactory implementation.
- void Create(mojo::ContextProviderPtr context_provider,
- mojo::ResourceReturnerPtr returner,
- mojo::InterfaceRequest<mojo::Display> display_request) override;
-
- // We use one ID namespace for all DisplayImpls since the ID is used only by
- // cc and not exposed through mojom.
- uint32_t id_namespace_;
- uint32_t next_local_id_;
- SurfacesScheduler* scheduler_;
- cc::SurfaceManager* manager_;
- mojo::StrongBinding<mojo::DisplayFactory> binding_;
-};
-
-} // namespace surfaces
-
-#endif // SERVICES_SURFACES_DISPLAY_FACTORY_IMPL_H_
diff --git a/services/surfaces/display_impl.cc b/services/surfaces/display_impl.cc
deleted file mode 100644
index ea45696..0000000
--- a/services/surfaces/display_impl.cc
+++ /dev/null
@@ -1,137 +0,0 @@
-// Copyright 2015 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 "services/surfaces/display_impl.h"
-
-#include "cc/output/compositor_frame.h"
-#include "cc/surfaces/display.h"
-#include "mojo/converters/geometry/geometry_type_converters.h"
-#include "mojo/converters/surfaces/surfaces_type_converters.h"
-#include "services/surfaces/context_provider_mojo.h"
-#include "services/surfaces/surfaces_output_surface.h"
-#include "services/surfaces/surfaces_scheduler.h"
-
-namespace surfaces {
-namespace {
-void CallCallback(const mojo::Closure& callback, cc::SurfaceDrawStatus status) {
- callback.Run();
-}
-}
-
-DisplayImpl::DisplayImpl(cc::SurfaceManager* manager,
- cc::SurfaceId cc_id,
- SurfacesScheduler* scheduler,
- mojo::ContextProviderPtr context_provider,
- mojo::ResourceReturnerPtr returner,
- mojo::InterfaceRequest<mojo::Display> display_request)
- : manager_(manager),
- factory_(manager, this),
- cc_id_(cc_id),
- scheduler_(scheduler),
- context_provider_(context_provider.Pass()),
- returner_(returner.Pass()),
- viewport_param_binding_(this),
- display_binding_(this, display_request.Pass()) {
- mojo::ViewportParameterListenerPtr viewport_parameter_listener;
- viewport_param_binding_.Bind(GetProxy(&viewport_parameter_listener));
- context_provider_->Create(
- viewport_parameter_listener.Pass(),
- base::Bind(&DisplayImpl::OnContextCreated, base::Unretained(this)));
- factory_.Create(cc_id_);
-}
-
-void DisplayImpl::OnContextCreated(mojo::CommandBufferPtr gles2_client) {
- DCHECK(!display_);
-
- cc::RendererSettings settings;
- display_.reset(new cc::Display(this, manager_, nullptr, nullptr, settings));
- scheduler_->AddDisplay(display_.get());
- display_->Initialize(make_scoped_ptr(new mojo::DirectOutputSurface(
- new mojo::ContextProviderMojo(
- gles2_client.PassInterface().PassHandle()))));
- display_->Resize(last_submitted_frame_size_);
-
- display_->SetSurfaceId(cc_id_, 1.f);
- if (pending_frame_)
- Draw();
-}
-
-DisplayImpl::~DisplayImpl() {
- factory_.Destroy(cc_id_);
- if (display_) {
- scheduler_->RemoveDisplay(display_.get());
- }
-}
-
-void DisplayImpl::SubmitFrame(mojo::FramePtr frame,
- const SubmitFrameCallback& callback) {
- DCHECK(pending_callback_.is_null());
- pending_frame_ = frame.Pass();
- pending_callback_ = callback;
- if (display_)
- Draw();
-}
-
-void DisplayImpl::Draw() {
- gfx::Size frame_size =
- pending_frame_->passes[0]->output_rect.To<gfx::Rect>().size();
- last_submitted_frame_size_ = frame_size;
- display_->Resize(frame_size);
- factory_.SubmitFrame(cc_id_,
- pending_frame_.To<scoped_ptr<cc::CompositorFrame>>(),
- base::Bind(&CallCallback, pending_callback_));
- scheduler_->SetNeedsDraw();
- pending_frame_.reset();
- pending_callback_.reset();
-}
-
-void DisplayImpl::DisplayDamaged() {
-}
-
-void DisplayImpl::DidSwapBuffers() {
-}
-
-void DisplayImpl::DidSwapBuffersComplete() {
-}
-
-void DisplayImpl::CommitVSyncParameters(base::TimeTicks timebase,
- base::TimeDelta interval) {
-}
-
-void DisplayImpl::OutputSurfaceLost() {
- // If our OutputSurface is lost we can't draw until we get a new one. For now,
- // destroy the display and create a new one when our ContextProvider provides
- // a new one.
- // TODO: This is more violent than necessary - we could simply remove this
- // display from the scheduler's set and pass a new context in to the
- // OutputSurface. It should be able to reinitialize properly.
- scheduler_->RemoveDisplay(display_.get());
- display_.reset();
- viewport_param_binding_.Close();
- mojo::ViewportParameterListenerPtr viewport_parameter_listener;
- viewport_param_binding_.Bind(GetProxy(&viewport_parameter_listener));
- context_provider_->Create(
- viewport_parameter_listener.Pass(),
- base::Bind(&DisplayImpl::OnContextCreated, base::Unretained(this)));
-}
-
-void DisplayImpl::OnVSyncParametersUpdated(int64_t timebase, int64_t interval) {
- scheduler_->OnVSyncParametersUpdated(
- base::TimeTicks::FromInternalValue(timebase),
- base::TimeDelta::FromInternalValue(interval));
-}
-
-void DisplayImpl::ReturnResources(const cc::ReturnedResourceArray& resources) {
- if (resources.empty())
- return;
- DCHECK(returner_);
-
- auto ret = mojo::Array<mojo::ReturnedResourcePtr>::New(resources.size());
- for (size_t i = 0; i < resources.size(); ++i) {
- ret[i] = mojo::ReturnedResource::From(resources[i]);
- }
- returner_->ReturnResources(ret.Pass());
-}
-
-} // namespace surfaces
diff --git a/services/surfaces/display_impl.h b/services/surfaces/display_impl.h
deleted file mode 100644
index 50bac99..0000000
--- a/services/surfaces/display_impl.h
+++ /dev/null
@@ -1,80 +0,0 @@
-// Copyright 2015 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 SERVICES_SURFACES_DISPLAY_IMPL_H_
-#define SERVICES_SURFACES_DISPLAY_IMPL_H_
-
-#include "base/memory/scoped_ptr.h"
-#include "cc/surfaces/display_client.h"
-#include "cc/surfaces/surface_factory.h"
-#include "cc/surfaces/surface_factory_client.h"
-#include "mojo/public/cpp/bindings/strong_binding.h"
-#include "mojo/services/surfaces/interfaces/display.mojom.h"
-
-namespace cc {
-class Display;
-class SurfaceFactory;
-}
-
-namespace surfaces {
-class SurfacesScheduler;
-
-class DisplayImpl : public mojo::Display,
- public mojo::ViewportParameterListener,
- public cc::DisplayClient,
- public cc::SurfaceFactoryClient {
- public:
- DisplayImpl(cc::SurfaceManager* manager,
- cc::SurfaceId cc_id,
- SurfacesScheduler* scheduler,
- mojo::ContextProviderPtr context_provider,
- mojo::ResourceReturnerPtr returner,
- mojo::InterfaceRequest<mojo::Display> display_request);
- ~DisplayImpl() override;
-
- private:
- void OnContextCreated(mojo::CommandBufferPtr gles2_client);
-
- // mojo::Display implementation:
- void SubmitFrame(mojo::FramePtr frame,
- const SubmitFrameCallback& callback) override;
-
- // DisplayClient implementation.
- void DisplayDamaged() override;
- void DidSwapBuffers() override;
- void DidSwapBuffersComplete() override;
- void CommitVSyncParameters(base::TimeTicks timebase,
- base::TimeDelta interval) override;
- void OutputSurfaceLost() override;
-
- // ViewportParameterListener
- void OnVSyncParametersUpdated(int64_t timebase, int64_t interval) override;
-
- // SurfaceFactoryClient implementation.
- void ReturnResources(const cc::ReturnedResourceArray& resources) override;
-
- void Draw();
-
- cc::SurfaceManager* manager_;
- cc::SurfaceFactory factory_;
- cc::SurfaceId cc_id_;
- SurfacesScheduler* scheduler_;
- mojo::ContextProviderPtr context_provider_;
- mojo::ResourceReturnerPtr returner_;
-
- gfx::Size last_submitted_frame_size_;
- mojo::FramePtr pending_frame_;
- SubmitFrameCallback pending_callback_;
-
- scoped_ptr<cc::Display> display_;
-
- mojo::Binding<mojo::ViewportParameterListener> viewport_param_binding_;
- mojo::StrongBinding<mojo::Display> display_binding_;
-
- DISALLOW_COPY_AND_ASSIGN(DisplayImpl);
-};
-
-} // namespace surfaces
-
-#endif // SERVICES_SURFACES_DISPLAY_IMPL_H_
diff --git a/services/surfaces/surfaces_impl.cc b/services/surfaces/surfaces_impl.cc
deleted file mode 100644
index d096eba..0000000
--- a/services/surfaces/surfaces_impl.cc
+++ /dev/null
@@ -1,81 +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 "services/surfaces/surfaces_impl.h"
-
-#include "base/trace_event/trace_event.h"
-#include "cc/output/compositor_frame.h"
-#include "cc/resources/returned_resource.h"
-#include "cc/surfaces/surface_id_allocator.h"
-#include "mojo/converters/geometry/geometry_type_converters.h"
-#include "mojo/converters/surfaces/surfaces_type_converters.h"
-#include "services/surfaces/surfaces_scheduler.h"
-
-using mojo::SurfaceIdPtr;
-
-namespace surfaces {
-
-namespace {
-void CallCallback(const mojo::Closure& callback, cc::SurfaceDrawStatus status) {
- callback.Run();
-}
-}
-
-SurfacesImpl::SurfacesImpl(cc::SurfaceManager* manager,
- uint32_t id_namespace,
- SurfacesScheduler* scheduler,
- mojo::InterfaceRequest<mojo::Surface> request)
- : manager_(manager),
- factory_(manager, this),
- id_namespace_(id_namespace),
- scheduler_(scheduler),
- binding_(this, request.Pass()) {
-}
-
-SurfacesImpl::~SurfacesImpl() {
- factory_.DestroyAll();
-}
-
-void SurfacesImpl::GetIdNamespace(
- const Surface::GetIdNamespaceCallback& callback) {
- callback.Run(id_namespace_);
-}
-
-void SurfacesImpl::SetResourceReturner(mojo::ResourceReturnerPtr returner) {
- returner_ = returner.Pass();
-}
-
-void SurfacesImpl::CreateSurface(uint32_t local_id) {
- factory_.Create(QualifyIdentifier(local_id));
-}
-
-void SurfacesImpl::SubmitFrame(uint32_t local_id,
- mojo::FramePtr frame,
- const mojo::Closure& callback) {
- TRACE_EVENT0("mojo", "SurfacesImpl::SubmitFrame");
- factory_.SubmitFrame(QualifyIdentifier(local_id),
- frame.To<scoped_ptr<cc::CompositorFrame>>(),
- base::Bind(&CallCallback, callback));
- scheduler_->SetNeedsDraw();
-}
-
-void SurfacesImpl::DestroySurface(uint32_t local_id) {
- factory_.Destroy(QualifyIdentifier(local_id));
-}
-
-void SurfacesImpl::ReturnResources(const cc::ReturnedResourceArray& resources) {
- if (resources.empty() || !returner_)
- return;
- auto ret = mojo::Array<mojo::ReturnedResourcePtr>::New(resources.size());
- for (size_t i = 0; i < resources.size(); ++i) {
- ret[i] = mojo::ReturnedResource::From(resources[i]);
- }
- returner_->ReturnResources(ret.Pass());
-}
-
-cc::SurfaceId SurfacesImpl::QualifyIdentifier(uint32_t local_id) {
- return cc::SurfaceId(static_cast<uint64_t>(id_namespace_) << 32 | local_id);
-}
-
-} // namespace mojo
diff --git a/services/surfaces/surfaces_impl.h b/services/surfaces/surfaces_impl.h
deleted file mode 100644
index 84f11d8..0000000
--- a/services/surfaces/surfaces_impl.h
+++ /dev/null
@@ -1,67 +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.
-
-#ifndef SERVICES_SURFACES_SURFACES_IMPL_H_
-#define SERVICES_SURFACES_SURFACES_IMPL_H_
-
-#include "cc/surfaces/display_client.h"
-#include "cc/surfaces/surface_factory.h"
-#include "cc/surfaces/surface_factory_client.h"
-#include "mojo/public/cpp/application/application_connection.h"
-#include "mojo/public/cpp/bindings/strong_binding.h"
-#include "mojo/services/gpu/interfaces/command_buffer.mojom.h"
-#include "mojo/services/gpu/interfaces/viewport_parameter_listener.mojom.h"
-#include "mojo/services/surfaces/interfaces/surfaces.mojom.h"
-
-namespace cc {
-class Display;
-}
-
-namespace mojo {
-class ApplicationManager;
-}
-
-namespace surfaces {
-class SurfacesScheduler;
-
-class SurfacesImpl : public mojo::Surface, public cc::SurfaceFactoryClient {
- public:
- SurfacesImpl(cc::SurfaceManager* manager,
- uint32_t id_namespace,
- SurfacesScheduler* scheduler,
- mojo::InterfaceRequest<mojo::Surface> request);
-
- ~SurfacesImpl() override;
-
- // Surface implementation.
- void GetIdNamespace(const Surface::GetIdNamespaceCallback& callback) override;
- void SetResourceReturner(mojo::ResourceReturnerPtr returner) override;
- void CreateSurface(uint32_t local_id) override;
- void SubmitFrame(uint32_t local_id,
- mojo::FramePtr frame,
- const mojo::Closure& callback) override;
- void DestroySurface(uint32_t local_id) override;
-
- // SurfaceFactoryClient implementation.
- void ReturnResources(const cc::ReturnedResourceArray& resources) override;
-
- cc::SurfaceFactory* factory() { return &factory_; }
-
- private:
- cc::SurfaceId QualifyIdentifier(uint32_t local_id);
-
- cc::SurfaceManager* manager_;
- cc::SurfaceFactory factory_;
- const uint32_t id_namespace_;
- SurfacesScheduler* scheduler_;
- mojo::ScopedMessagePipeHandle command_buffer_handle_;
- mojo::ResourceReturnerPtr returner_;
- mojo::StrongBinding<Surface> binding_;
-
- DISALLOW_COPY_AND_ASSIGN(SurfacesImpl);
-};
-
-} // namespace surfaces
-
-#endif // SERVICES_SURFACES_SURFACES_IMPL_H_
diff --git a/services/surfaces/surfaces_output_surface.cc b/services/surfaces/surfaces_output_surface.cc
deleted file mode 100644
index 94376eb..0000000
--- a/services/surfaces/surfaces_output_surface.cc
+++ /dev/null
@@ -1,42 +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 "services/surfaces/surfaces_output_surface.h"
-
-#include "base/bind.h"
-#include "cc/output/compositor_frame.h"
-#include "cc/output/context_provider.h"
-#include "cc/output/output_surface_client.h"
-#include "gpu/command_buffer/client/context_support.h"
-#include "gpu/command_buffer/client/gles2_interface.h"
-
-namespace mojo {
-
-DirectOutputSurface::DirectOutputSurface(
- const scoped_refptr<cc::ContextProvider>& context_provider)
- : cc::OutputSurface(context_provider), weak_ptr_factory_(this) {
-}
-
-DirectOutputSurface::~DirectOutputSurface() {
-}
-
-void DirectOutputSurface::SwapBuffers(cc::CompositorFrame* frame) {
- DCHECK(context_provider_.get());
- DCHECK(frame->gl_frame_data);
- if (frame->gl_frame_data->sub_buffer_rect ==
- gfx::Rect(frame->gl_frame_data->size)) {
- context_provider_->ContextSupport()->Swap();
- } else {
- context_provider_->ContextSupport()->PartialSwapBuffers(
- frame->gl_frame_data->sub_buffer_rect);
- }
- uint32_t sync_point =
- context_provider_->ContextGL()->InsertSyncPointCHROMIUM();
- context_provider_->ContextSupport()->SignalSyncPoint(
- sync_point, base::Bind(&OutputSurface::OnSwapBuffersComplete,
- weak_ptr_factory_.GetWeakPtr()));
- client_->DidSwapBuffers();
-}
-
-} // namespace mojo
diff --git a/services/surfaces/surfaces_output_surface.h b/services/surfaces/surfaces_output_surface.h
deleted file mode 100644
index a2e61d0..0000000
--- a/services/surfaces/surfaces_output_surface.h
+++ /dev/null
@@ -1,29 +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.
-
-#ifndef SERVICES_SURFACES_SURFACES_OUTPUT_SURFACE_H_
-#define SERVICES_SURFACES_SURFACES_OUTPUT_SURFACE_H_
-
-#include "cc/output/output_surface.h"
-
-namespace mojo {
-
-// An OutputSurface implementation that directly draws and
-// swaps to an actual GL surface.
-class DirectOutputSurface : public cc::OutputSurface {
- public:
- explicit DirectOutputSurface(
- const scoped_refptr<cc::ContextProvider>& context_provider);
- ~DirectOutputSurface() override;
-
- // cc::OutputSurface implementation
- void SwapBuffers(cc::CompositorFrame* frame) override;
-
- private:
- base::WeakPtrFactory<DirectOutputSurface> weak_ptr_factory_;
-};
-
-} // namespace mojo
-
-#endif // SERVICES_SURFACES_SURFACES_OUTPUT_SURFACE_H_
diff --git a/services/surfaces/surfaces_scheduler.cc b/services/surfaces/surfaces_scheduler.cc
deleted file mode 100644
index 1a23620..0000000
--- a/services/surfaces/surfaces_scheduler.cc
+++ /dev/null
@@ -1,117 +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 "services/surfaces/surfaces_scheduler.h"
-
-#include "cc/surfaces/display.h"
-
-namespace surfaces {
-
-SurfacesScheduler::SurfacesScheduler() {
- cc::SchedulerSettings settings;
- scheduler_ = cc::Scheduler::Create(
- this, settings, 0, base::MessageLoop::current()->task_runner(), nullptr);
- scheduler_->SetCanStart();
- scheduler_->SetVisible(true);
- scheduler_->SetCanDraw(true);
- scheduler_->SetNeedsCommit();
-}
-
-SurfacesScheduler::~SurfacesScheduler() {
-}
-
-void SurfacesScheduler::SetNeedsDraw() {
- // Don't tell the scheduler we need to draw if we have no active displays
- // which can happen if we haven't initialized displays yet or if all active
- // displays have lost their context.
- if (!displays_.empty())
- scheduler_->SetNeedsRedraw();
-}
-
-void SurfacesScheduler::OnVSyncParametersUpdated(base::TimeTicks timebase,
- base::TimeDelta interval) {
- scheduler_->CommitVSyncParameters(timebase, interval);
-}
-
-void SurfacesScheduler::AddDisplay(cc::Display* display) {
- DCHECK(displays_.find(display) == displays_.end());
- displays_.insert(display);
-
- // A draw might be necessary (e.g., this display might be getting added on
- // resumption from backgrounding).
- SetNeedsDraw();
-}
-
-void SurfacesScheduler::RemoveDisplay(cc::Display* display) {
- auto it = displays_.find(display);
- DCHECK(it != displays_.end());
- displays_.erase(it);
-}
-
-void SurfacesScheduler::WillBeginImplFrame(const cc::BeginFrameArgs& args) {
-}
-
-void SurfacesScheduler::ScheduledActionSendBeginMainFrame() {
- scheduler_->NotifyBeginMainFrameStarted();
- scheduler_->NotifyReadyToCommit();
-}
-
-cc::DrawResult SurfacesScheduler::ScheduledActionDrawAndSwapIfPossible() {
- base::TimeTicks start = base::TimeTicks::Now();
- for (const auto& it : displays_) {
- it->Draw();
- }
- base::TimeDelta duration = base::TimeTicks::Now() - start;
-
- draw_estimate_ = (duration + draw_estimate_) / 2;
- return cc::DRAW_SUCCESS;
-}
-
-cc::DrawResult SurfacesScheduler::ScheduledActionDrawAndSwapForced() {
- NOTREACHED() << "ScheduledActionDrawAndSwapIfPossible always succeeds.";
- return cc::DRAW_SUCCESS;
-}
-
-void SurfacesScheduler::ScheduledActionAnimate() {
-}
-
-void SurfacesScheduler::ScheduledActionCommit() {
-}
-
-void SurfacesScheduler::ScheduledActionActivateSyncTree() {
-}
-
-void SurfacesScheduler::ScheduledActionBeginOutputSurfaceCreation() {
- scheduler_->DidCreateAndInitializeOutputSurface();
-}
-
-void SurfacesScheduler::ScheduledActionPrepareTiles() {
-}
-
-void SurfacesScheduler::DidAnticipatedDrawTimeChange(base::TimeTicks time) {
-}
-
-base::TimeDelta SurfacesScheduler::DrawDurationEstimate() {
- return draw_estimate_;
-}
-
-base::TimeDelta SurfacesScheduler::BeginMainFrameToCommitDurationEstimate() {
- return base::TimeDelta();
-}
-
-base::TimeDelta SurfacesScheduler::CommitToActivateDurationEstimate() {
- return base::TimeDelta();
-}
-
-void SurfacesScheduler::DidBeginImplFrameDeadline() {
-}
-
-void SurfacesScheduler::SendBeginFramesToChildren(
- const cc::BeginFrameArgs& args) {
-}
-
-void SurfacesScheduler::SendBeginMainFrameNotExpectedSoon() {
-}
-
-} // namespace mojo
diff --git a/services/surfaces/surfaces_scheduler.h b/services/surfaces/surfaces_scheduler.h
deleted file mode 100644
index 1c98af1..0000000
--- a/services/surfaces/surfaces_scheduler.h
+++ /dev/null
@@ -1,58 +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.
-
-#ifndef MOJO_SERVICES_SURFACES_SURFACES_SCHEDULER_H_
-#define MOJO_SERVICES_SURFACES_SURFACES_SCHEDULER_H_
-
-#include <set>
-
-#include "cc/scheduler/scheduler.h"
-
-namespace cc {
-class Display;
-}
-
-namespace surfaces {
-
-class SurfacesScheduler : public cc::SchedulerClient {
- public:
- SurfacesScheduler();
- ~SurfacesScheduler() override;
-
- void SetNeedsDraw();
-
- void OnVSyncParametersUpdated(base::TimeTicks timebase,
- base::TimeDelta interval);
-
- void AddDisplay(cc::Display* display);
- void RemoveDisplay(cc::Display* display);
-
- private:
- void WillBeginImplFrame(const cc::BeginFrameArgs& args) override;
- void ScheduledActionSendBeginMainFrame() override;
- cc::DrawResult ScheduledActionDrawAndSwapIfPossible() override;
- cc::DrawResult ScheduledActionDrawAndSwapForced() override;
- void ScheduledActionAnimate() override;
- void ScheduledActionCommit() override;
- void ScheduledActionActivateSyncTree() override;
- void ScheduledActionBeginOutputSurfaceCreation() override;
- void ScheduledActionPrepareTiles() override;
- void DidAnticipatedDrawTimeChange(base::TimeTicks time) override;
- base::TimeDelta DrawDurationEstimate() override;
- base::TimeDelta BeginMainFrameToCommitDurationEstimate() override;
- base::TimeDelta CommitToActivateDurationEstimate() override;
- void DidBeginImplFrameDeadline() override;
- void SendBeginFramesToChildren(const cc::BeginFrameArgs& args) override;
- void SendBeginMainFrameNotExpectedSoon() override;
-
- std::set<cc::Display*> displays_;
- scoped_ptr<cc::Scheduler> scheduler_;
- base::TimeDelta draw_estimate_;
-
- DISALLOW_COPY_AND_ASSIGN(SurfacesScheduler);
-};
-
-} // namespace mojo
-
-#endif // MOJO_SERVICES_SURFACES_SURFACES_SCHEDULER_H_
diff --git a/services/surfaces/surfaces_service_application.cc b/services/surfaces/surfaces_service_application.cc
deleted file mode 100644
index f10e534..0000000
--- a/services/surfaces/surfaces_service_application.cc
+++ /dev/null
@@ -1,54 +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 "services/surfaces/surfaces_service_application.h"
-
-#include "mojo/application/application_runner_chromium.h"
-#include "mojo/public/c/system/main.h"
-#include "services/surfaces/display_factory_impl.h"
-#include "services/surfaces/surfaces_impl.h"
-#include "services/surfaces/surfaces_scheduler.h"
-
-namespace surfaces {
-
-SurfacesServiceApplication::SurfacesServiceApplication()
- : next_id_namespace_(1u) {
-}
-
-SurfacesServiceApplication::~SurfacesServiceApplication() {
-}
-
-void SurfacesServiceApplication::Initialize(mojo::ApplicationImpl* app) {
- tracing_.Initialize(app);
- scheduler_.reset(new SurfacesScheduler);
-}
-
-bool SurfacesServiceApplication::ConfigureIncomingConnection(
- mojo::ApplicationConnection* connection) {
- connection->AddService<mojo::DisplayFactory>(this);
- connection->AddService<mojo::Surface>(this);
- return true;
-}
-
-void SurfacesServiceApplication::Create(
- mojo::ApplicationConnection* connection,
- mojo::InterfaceRequest<mojo::DisplayFactory> request) {
- new DisplayFactoryImpl(&manager_, next_id_namespace_++, scheduler_.get(),
- request.Pass());
-}
-
-void SurfacesServiceApplication::Create(
- mojo::ApplicationConnection* connection,
- mojo::InterfaceRequest<mojo::Surface> request) {
- new SurfacesImpl(&manager_, next_id_namespace_++, scheduler_.get(),
- request.Pass());
-}
-
-} // namespace surfaces
-
-MojoResult MojoMain(MojoHandle application_request) {
- mojo::ApplicationRunnerChromium runner(
- new surfaces::SurfacesServiceApplication);
- return runner.Run(application_request);
-}
diff --git a/services/surfaces/surfaces_service_application.h b/services/surfaces/surfaces_service_application.h
deleted file mode 100644
index 8e3c12b..0000000
--- a/services/surfaces/surfaces_service_application.h
+++ /dev/null
@@ -1,55 +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.
-
-#ifndef SERVICES_SURFACES_SURFACES_SERVICE_APPLICATION_H_
-#define SERVICES_SURFACES_SURFACES_SERVICE_APPLICATION_H_
-
-#include "base/macros.h"
-#include "cc/surfaces/surface_manager.h"
-#include "mojo/common/tracing_impl.h"
-#include "mojo/public/cpp/application/application_delegate.h"
-#include "mojo/public/cpp/application/interface_factory.h"
-#include "mojo/services/surfaces/interfaces/display.mojom.h"
-#include "mojo/services/surfaces/interfaces/surfaces.mojom.h"
-
-namespace mojo {
-class ApplicationConnection;
-}
-
-namespace surfaces {
-class SurfacesScheduler;
-
-class SurfacesServiceApplication
- : public mojo::ApplicationDelegate,
- public mojo::InterfaceFactory<mojo::DisplayFactory>,
- public mojo::InterfaceFactory<mojo::Surface> {
- public:
- SurfacesServiceApplication();
- ~SurfacesServiceApplication() override;
-
- // ApplicationDelegate implementation.
- void Initialize(mojo::ApplicationImpl* app) override;
- bool ConfigureIncomingConnection(
- mojo::ApplicationConnection* connection) override;
-
- // InterfaceFactory<DisplayFactory> implementation.
- void Create(mojo::ApplicationConnection* connection,
- mojo::InterfaceRequest<mojo::DisplayFactory> request) override;
-
- // InterfaceFactory<Surface> implementation.
- void Create(mojo::ApplicationConnection* connection,
- mojo::InterfaceRequest<mojo::Surface> request) override;
-
- private:
- cc::SurfaceManager manager_;
- uint32_t next_id_namespace_;
- scoped_ptr<SurfacesScheduler> scheduler_;
- mojo::TracingImpl tracing_;
-
- DISALLOW_COPY_AND_ASSIGN(SurfacesServiceApplication);
-};
-
-} // namespace surfaces
-
-#endif // SERVICES_SURFACES_SURFACES_SERVICE_APPLICATION_H_
diff --git a/shell/BUILD.gn b/shell/BUILD.gn
index 303f907..ef4d7d5 100644
--- a/shell/BUILD.gn
+++ b/shell/BUILD.gn
@@ -428,7 +428,6 @@
"$root_out_dir/device_info.mojo",
"$root_out_dir/icu_data.mojo",
"$root_out_dir/java_handler.mojo",
- "$root_out_dir/surfaces_service.mojo",
"$root_out_dir/tracing.mojo",
]
@@ -438,7 +437,6 @@
"//services/dart:dart_content_handler",
"//services/device_info",
"//services/icu_data",
- "//services/surfaces",
"//services/tracing",
]
}