diff options
author | sky <sky@chromium.org> | 2015-04-20 16:44:51 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-04-20 23:45:39 +0000 |
commit | 8327ac08ec2c80f26c73a83b75a66eae7b27e3cc (patch) | |
tree | a68b6bbfba04c1fa98f081533a7100847d834d0d /mojo | |
parent | 638ab71c6b28552e6adb7fd195ce50195b24725a (diff) | |
download | chromium_src-8327ac08ec2c80f26c73a83b75a66eae7b27e3cc.zip chromium_src-8327ac08ec2c80f26c73a83b75a66eae7b27e3cc.tar.gz chromium_src-8327ac08ec2c80f26c73a83b75a66eae7b27e3cc.tar.bz2 |
Moves mojo/services/* to components/* part 1
I'm splitting this up in chunks so I can actually use the cq.
R=ben@chromium.org
Review URL: https://codereview.chromium.org/1097183002
Cr-Commit-Position: refs/heads/master@{#325942}
Diffstat (limited to 'mojo')
40 files changed, 20 insertions, 1681 deletions
diff --git a/mojo/gles2/BUILD.gn b/mojo/gles2/BUILD.gn index 3c27743..c6e501a 100644 --- a/mojo/gles2/BUILD.gn +++ b/mojo/gles2/BUILD.gn @@ -16,9 +16,9 @@ source_set("gles2") { sources = [ "command_buffer_client_impl.cc", "command_buffer_client_impl.h", - "gles2_impl.cc", "gles2_context.cc", "gles2_context.h", + "gles2_impl.cc", ] defines = [ @@ -36,6 +36,7 @@ source_set("gles2") { deps = [ "//base", "//base/third_party/dynamic_annotations", + "//components/gles2:lib", "//gpu/command_buffer/client", "//gpu/command_buffer/client:gles2_cmd_helper", "//gpu/command_buffer/client:gles2_implementation", @@ -47,7 +48,6 @@ source_set("gles2") { "//third_party/mojo/src/mojo/public/cpp/bindings", "//third_party/mojo/src/mojo/public/cpp/system", "//third_party/mojo_services/src/gpu/public/interfaces", - "//mojo/services/gles2:lib", ] include_dirs = [ ".." ] diff --git a/mojo/gles2/DEPS b/mojo/gles2/DEPS index aa72943..9aea877 100644 --- a/mojo/gles2/DEPS +++ b/mojo/gles2/DEPS @@ -1,4 +1,5 @@ include_rules = [ + "+components/gles2", "+gpu", "+third_party/mojo_services/src/gpu", -]
\ No newline at end of file +] diff --git a/mojo/gles2/command_buffer_client_impl.cc b/mojo/gles2/command_buffer_client_impl.cc index 37dc30c..abe95f6 100644 --- a/mojo/gles2/command_buffer_client_impl.cc +++ b/mojo/gles2/command_buffer_client_impl.cc @@ -8,8 +8,8 @@ #include "base/logging.h" #include "base/process/process_handle.h" -#include "mojo/services/gles2/command_buffer_type_conversions.h" -#include "mojo/services/gles2/mojo_buffer_backing.h" +#include "components/gles2/command_buffer_type_conversions.h" +#include "components/gles2/mojo_buffer_backing.h" namespace gles2 { diff --git a/mojo/services/BUILD.gn b/mojo/services/BUILD.gn index 494785f..59775e4 100644 --- a/mojo/services/BUILD.gn +++ b/mojo/services/BUILD.gn @@ -19,7 +19,7 @@ group("services") { if (!is_component_build) { deps += [ - "//mojo/services/clipboard", + "//components/clipboard", "//mojo/services/html_viewer", "//mojo/services/kiosk_wm:window_manager", "//mojo/services/native_viewport", @@ -73,7 +73,7 @@ group("apptests") { ] if (!is_component_build) { deps += [ - "//mojo/services/clipboard:apptests", + "//components/clipboard:apptests", "//mojo/services/html_viewer:apptests", "//mojo/services/network:apptests", "//mojo/services/view_manager:apptests", diff --git a/mojo/services/clipboard/BUILD.gn b/mojo/services/clipboard/BUILD.gn deleted file mode 100644 index cfdcb25..0000000 --- a/mojo/services/clipboard/BUILD.gn +++ /dev/null @@ -1,44 +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("//third_party/mojo/src/mojo/public/mojo_application.gni") - -mojo_native_application("clipboard") { - sources = [ - "clipboard_standalone_impl.cc", - "clipboard_standalone_impl.h", - "main.cc", - ] - - deps = [ - "//base", - "//mojo/application", - "//mojo/common", - "//mojo/environment:chromium", - "//third_party/mojo/src/mojo/public/cpp/bindings", - "//third_party/mojo/src/mojo/public/cpp/bindings:callback", - "//third_party/mojo_services/src/clipboard/public/interfaces", - ] -} - -mojo_native_application("apptests") { - output_name = "clipboard_apptests" - - testonly = true - - sources = [ - "clipboard_apptest.cc", - ] - - deps = [ - "//base", - "//mojo/application", - "//mojo/application:test_support", - "//mojo/common", - "//third_party/mojo/src/mojo/public/cpp/bindings", - "//third_party/mojo_services/src/clipboard/public/interfaces", - ] - - data_deps = [ ":clipboard($default_toolchain)" ] -} diff --git a/mojo/services/clipboard/DEPS b/mojo/services/clipboard/DEPS deleted file mode 100644 index e6505c5..0000000 --- a/mojo/services/clipboard/DEPS +++ /dev/null @@ -1,4 +0,0 @@ -include_rules = [ - "+mojo/application", - "+third_party/mojo_services/src/clipboard", -] diff --git a/mojo/services/clipboard/clipboard_apptest.cc b/mojo/services/clipboard/clipboard_apptest.cc deleted file mode 100644 index cb8f1e6..0000000 --- a/mojo/services/clipboard/clipboard_apptest.cc +++ /dev/null @@ -1,156 +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/run_loop.h" -#include "mojo/application/application_test_base_chromium.h" -#include "mojo/common/common_type_converters.h" -#include "mojo/public/cpp/application/application_impl.h" -#include "third_party/mojo_services/src/clipboard/public/interfaces/clipboard.mojom.h" - -using mojo::Array; -using mojo::Clipboard; -using mojo::Map; -using mojo::String; - -namespace { - -void CopyUint64AndEndRunloop(uint64_t* output, - base::RunLoop* run_loop, - uint64_t input) { - *output = input; - run_loop->Quit(); -} - -void CopyStringAndEndRunloop(std::string* output, - bool* string_is_null, - base::RunLoop* run_loop, - const Array<uint8_t>& input) { - *string_is_null = input.is_null(); - *output = input.is_null() ? "" : input.To<std::string>(); - run_loop->Quit(); -} - -void CopyVectorStringAndEndRunloop(std::vector<std::string>* output, - base::RunLoop* run_loop, - const Array<String>& input) { - *output = input.To<std::vector<std::string> >(); - run_loop->Quit(); -} - -const char* kUninitialized = "Uninitialized data"; -const char* kPlainTextData = "Some plain data"; -const char* kHtmlData = "<html>data</html>"; - -} // namespace - -namespace clipboard { - -class ClipboardAppTest : public mojo::test::ApplicationTestBase { - public: - ClipboardAppTest() : ApplicationTestBase() {} - ~ClipboardAppTest() override {} - - void SetUp() override { - mojo::test::ApplicationTestBase::SetUp(); - application_impl()->ConnectToService("mojo:clipboard", &clipboard_); - } - - uint64_t GetSequenceNumber() { - base::RunLoop run_loop; - uint64_t sequence_num = 999999; - clipboard_->GetSequenceNumber( - Clipboard::TYPE_COPY_PASTE, - base::Bind(&CopyUint64AndEndRunloop, &sequence_num, &run_loop)); - run_loop.Run(); - return sequence_num; - } - - std::vector<std::string> GetAvailableFormatMimeTypes() { - base::RunLoop run_loop; - std::vector<std::string> types; - types.push_back(kUninitialized); - clipboard_->GetAvailableMimeTypes( - Clipboard::TYPE_COPY_PASTE, - base::Bind(&CopyVectorStringAndEndRunloop, &types, &run_loop)); - run_loop.Run(); - return types; - } - - bool GetDataOfType(const std::string& mime_type, std::string* data) { - base::RunLoop run_loop; - bool is_null = false; - clipboard_->ReadMimeType( - Clipboard::TYPE_COPY_PASTE, mime_type, - base::Bind(&CopyStringAndEndRunloop, data, &is_null, &run_loop)); - run_loop.Run(); - return !is_null; - } - - void SetStringText(const std::string& data) { - Map<String, Array<uint8_t>> mime_data; - mime_data[Clipboard::MIME_TYPE_TEXT] = Array<uint8_t>::From(data); - clipboard_->WriteClipboardData(Clipboard::TYPE_COPY_PASTE, - mime_data.Pass()); - } - - protected: - mojo::ClipboardPtr clipboard_; - - DISALLOW_COPY_AND_ASSIGN(ClipboardAppTest); -}; - -TEST_F(ClipboardAppTest, EmptyClipboardOK) { - EXPECT_EQ(0ul, GetSequenceNumber()); - EXPECT_TRUE(GetAvailableFormatMimeTypes().empty()); - std::string data; - EXPECT_FALSE(GetDataOfType(Clipboard::MIME_TYPE_TEXT, &data)); -} - -TEST_F(ClipboardAppTest, CanReadBackText) { - std::string data; - EXPECT_FALSE(GetDataOfType(Clipboard::MIME_TYPE_TEXT, &data)); - EXPECT_EQ(0ul, GetSequenceNumber()); - - SetStringText(kPlainTextData); - EXPECT_EQ(1ul, GetSequenceNumber()); - - EXPECT_TRUE(GetDataOfType(Clipboard::MIME_TYPE_TEXT, &data)); - EXPECT_EQ(kPlainTextData, data); -} - -TEST_F(ClipboardAppTest, CanSetMultipleDataTypesAtOnce) { - Map<String, Array<uint8_t>> mime_data; - mime_data[Clipboard::MIME_TYPE_TEXT] = - Array<uint8_t>::From(std::string(kPlainTextData)); - mime_data[Clipboard::MIME_TYPE_HTML] = - Array<uint8_t>::From(std::string(kHtmlData)); - - clipboard_->WriteClipboardData(Clipboard::TYPE_COPY_PASTE, mime_data.Pass()); - - EXPECT_EQ(1ul, GetSequenceNumber()); - - std::string data; - EXPECT_TRUE(GetDataOfType(Clipboard::MIME_TYPE_TEXT, &data)); - EXPECT_EQ(kPlainTextData, data); - EXPECT_TRUE(GetDataOfType(Clipboard::MIME_TYPE_HTML, &data)); - EXPECT_EQ(kHtmlData, data); -} - -TEST_F(ClipboardAppTest, CanClearClipboardWithZeroArray) { - std::string data; - SetStringText(kPlainTextData); - EXPECT_EQ(1ul, GetSequenceNumber()); - - EXPECT_TRUE(GetDataOfType(Clipboard::MIME_TYPE_TEXT, &data)); - EXPECT_EQ(kPlainTextData, data); - - Map<String, Array<uint8_t>> mime_data; - clipboard_->WriteClipboardData(Clipboard::TYPE_COPY_PASTE, mime_data.Pass()); - - EXPECT_EQ(2ul, GetSequenceNumber()); - EXPECT_FALSE(GetDataOfType(Clipboard::MIME_TYPE_TEXT, &data)); -} - -} // namespace clipboard diff --git a/mojo/services/clipboard/clipboard_standalone_impl.cc b/mojo/services/clipboard/clipboard_standalone_impl.cc deleted file mode 100644 index e783af7..0000000 --- a/mojo/services/clipboard/clipboard_standalone_impl.cc +++ /dev/null @@ -1,89 +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/services/clipboard/clipboard_standalone_impl.h" - -#include <string.h> - -#include "mojo/public/cpp/bindings/array.h" -#include "mojo/public/cpp/bindings/callback.h" -#include "mojo/public/cpp/bindings/string.h" - -using mojo::Array; -using mojo::Map; -using mojo::String; - -namespace clipboard { - -// ClipboardData contains data copied to the Clipboard for a variety of formats. -// It mostly just provides APIs to cleanly access and manipulate this data. -class ClipboardStandaloneImpl::ClipboardData { - public: - ClipboardData() {} - ~ClipboardData() {} - - Array<String> GetMimeTypes() const { - Array<String> types(data_types_.size()); - int i = 0; - for (auto it = data_types_.begin(); it != data_types_.end(); ++it, ++i) - types[i] = it.GetKey(); - - return types.Pass(); - } - - void SetData(Map<String, Array<uint8_t>> data) { data_types_ = data.Pass(); } - - void GetData(const String& mime_type, Array<uint8_t>* data) const { - auto it = data_types_.find(mime_type); - if (it != data_types_.end()) - *data = it.GetValue().Clone(); - } - - private: - Map<String, Array<uint8_t>> data_types_; - - DISALLOW_COPY_AND_ASSIGN(ClipboardData); -}; - -ClipboardStandaloneImpl::ClipboardStandaloneImpl( - mojo::InterfaceRequest<mojo::Clipboard> request) - : binding_(this, request.Pass()) { - for (int i = 0; i < kNumClipboards; ++i) { - sequence_number_[i] = 0; - clipboard_state_[i].reset(new ClipboardData); - } -} - -ClipboardStandaloneImpl::~ClipboardStandaloneImpl() { -} - -void ClipboardStandaloneImpl::GetSequenceNumber( - Clipboard::Type clipboard_type, - const mojo::Callback<void(uint64_t)>& callback) { - callback.Run(sequence_number_[clipboard_type]); -} - -void ClipboardStandaloneImpl::GetAvailableMimeTypes( - Clipboard::Type clipboard_type, - const mojo::Callback<void(Array<String>)>& callback) { - callback.Run(clipboard_state_[clipboard_type]->GetMimeTypes().Pass()); -} - -void ClipboardStandaloneImpl::ReadMimeType( - Clipboard::Type clipboard_type, - const String& mime_type, - const mojo::Callback<void(Array<uint8_t>)>& callback) { - Array<uint8_t> mime_data; - clipboard_state_[clipboard_type]->GetData(mime_type, &mime_data); - callback.Run(mime_data.Pass()); -} - -void ClipboardStandaloneImpl::WriteClipboardData( - Clipboard::Type clipboard_type, - Map<String, Array<uint8_t>> data) { - sequence_number_[clipboard_type]++; - clipboard_state_[clipboard_type]->SetData(data.Pass()); -} - -} // namespace clipboard diff --git a/mojo/services/clipboard/clipboard_standalone_impl.h b/mojo/services/clipboard/clipboard_standalone_impl.h deleted file mode 100644 index 6c5d828..0000000 --- a/mojo/services/clipboard/clipboard_standalone_impl.h +++ /dev/null @@ -1,62 +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_CLIPBOARD_CLIPBOARD_STANDALONE_IMPL_H_ -#define SERVICES_CLIPBOARD_CLIPBOARD_STANDALONE_IMPL_H_ - -#include <base/memory/scoped_ptr.h> -#include <string> - -#include "mojo/public/cpp/bindings/strong_binding.h" -#include "third_party/mojo_services/src/clipboard/public/interfaces/clipboard.mojom.h" - -namespace clipboard { - -// Stub clipboard implementation. -// -// Eventually, we'll actually want to interact with the system clipboard, but -// that's hard today because the system clipboard is asynchronous (on X11), the -// ui::Clipboard interface is synchronous (which is what we'd use), mojo is -// asynchronous across processes, and the WebClipboard interface is synchronous -// (which is at least tractable). -class ClipboardStandaloneImpl : public mojo::Clipboard { - public: - // mojo::Clipboard exposes three possible clipboards. - static const int kNumClipboards = 3; - - explicit ClipboardStandaloneImpl( - mojo::InterfaceRequest<mojo::Clipboard> request); - ~ClipboardStandaloneImpl() override; - - // mojo::Clipboard implementation. - void GetSequenceNumber( - mojo::Clipboard::Type clipboard_type, - const mojo::Callback<void(uint64_t)>& callback) override; - void GetAvailableMimeTypes( - mojo::Clipboard::Type clipboard_types, - const mojo::Callback<void(mojo::Array<mojo::String>)>& callback) override; - void ReadMimeType( - mojo::Clipboard::Type clipboard_type, - const mojo::String& mime_type, - const mojo::Callback<void(mojo::Array<uint8_t>)>& callback) override; - void WriteClipboardData( - mojo::Clipboard::Type clipboard_type, - mojo::Map<mojo::String, mojo::Array<uint8_t>> data) override; - - private: - uint64_t sequence_number_[kNumClipboards]; - - // Internal struct which stores the current state of the clipboard. - class ClipboardData; - - // The current clipboard state. This is what is read from. - scoped_ptr<ClipboardData> clipboard_state_[kNumClipboards]; - mojo::StrongBinding<mojo::Clipboard> binding_; - - DISALLOW_COPY_AND_ASSIGN(ClipboardStandaloneImpl); -}; - -} // namespace clipboard - -#endif // SERVICES_CLIPBOARD_CLIPBOARD_STANDALONE_IMPL_H_ diff --git a/mojo/services/clipboard/main.cc b/mojo/services/clipboard/main.cc deleted file mode 100644 index 0c5e17a..0000000 --- a/mojo/services/clipboard/main.cc +++ /dev/null @@ -1,37 +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/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/interface_factory.h" -#include "mojo/services/clipboard/clipboard_standalone_impl.h" - -class Delegate : public mojo::ApplicationDelegate, - public mojo::InterfaceFactory<mojo::Clipboard> { - public: - Delegate() {} - ~Delegate() override {} - - // mojo::ApplicationDelegate implementation. - bool ConfigureIncomingConnection( - mojo::ApplicationConnection* connection) override { - connection->AddService(this); - return true; - } - - // mojo::InterfaceFactory<mojo::Clipboard> implementation. - void Create(mojo::ApplicationConnection* connection, - mojo::InterfaceRequest<mojo::Clipboard> request) override { - // TODO(erg): Write native implementations of the clipboard. For now, we - // just build a clipboard which doesn't interact with the system. - new clipboard::ClipboardStandaloneImpl(request.Pass()); - } -}; - -MojoResult MojoMain(MojoHandle shell_handle) { - mojo::ApplicationRunnerChromium runner(new Delegate); - return runner.Run(shell_handle); -} diff --git a/mojo/services/gles2/BUILD.gn b/mojo/services/gles2/BUILD.gn deleted file mode 100644 index a34b9b3..0000000 --- a/mojo/services/gles2/BUILD.gn +++ /dev/null @@ -1,59 +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("//third_party/mojo/src/mojo/public/tools/bindings/mojom.gni") - -source_set("gles2") { - visibility = [ - "//mojo/shell:lib", # For android - "//mojo/services/native_viewport:*", - ] - - sources = [ - "command_buffer_driver.cc", - "command_buffer_driver.h", - "command_buffer_impl.cc", - "command_buffer_impl.h", - "gpu_state.cc", - "gpu_state.h", - "gpu_impl.cc", - "gpu_impl.h", - ] - - public_deps = [ - ":lib", - ] - deps = [ - "//base", - "//gpu/command_buffer/service", - "//mojo/converters/geometry", - "//third_party/mojo/src/mojo/public/cpp/bindings", - "//third_party/mojo_services/src/geometry/public/interfaces", - "//third_party/mojo_services/src/gpu/public/interfaces", - "//ui/gfx", - "//ui/gfx/geometry", - "//ui/gl", - ] - - include_dirs = [ "../.." ] -} - -source_set("lib") { - sources = [ - "command_buffer_type_conversions.cc", - "command_buffer_type_conversions.h", - "mojo_buffer_backing.cc", - "mojo_buffer_backing.h", - ] - - deps = [ - "//base", - "//gpu/command_buffer/common", - "//third_party/mojo/src/mojo/public/cpp/bindings", - "//third_party/mojo/src/mojo/public/cpp/system", - "//third_party/mojo_services/src/gpu/public/interfaces", - ] - - include_dirs = [ "../.." ] -} diff --git a/mojo/services/gles2/DEPS b/mojo/services/gles2/DEPS deleted file mode 100644 index f34d3eb..0000000 --- a/mojo/services/gles2/DEPS +++ /dev/null @@ -1,7 +0,0 @@ -include_rules = [ - "+gpu", - "+mojo/converters", - "+third_party/mojo_services/src/geometry", - "+third_party/mojo_services/src/gpu", - "+ui", -] diff --git a/mojo/services/gles2/command_buffer_driver.cc b/mojo/services/gles2/command_buffer_driver.cc deleted file mode 100644 index 3ae617b..0000000 --- a/mojo/services/gles2/command_buffer_driver.cc +++ /dev/null @@ -1,250 +0,0 @@ -// Copyright 2013 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/services/gles2/command_buffer_driver.h" - -#include "base/bind.h" -#include "base/macros.h" -#include "base/memory/shared_memory.h" -#include "gpu/command_buffer/common/constants.h" -#include "gpu/command_buffer/common/value_state.h" -#include "gpu/command_buffer/service/command_buffer_service.h" -#include "gpu/command_buffer/service/context_group.h" -#include "gpu/command_buffer/service/gles2_cmd_decoder.h" -#include "gpu/command_buffer/service/gpu_scheduler.h" -#include "gpu/command_buffer/service/image_manager.h" -#include "gpu/command_buffer/service/mailbox_manager.h" -#include "gpu/command_buffer/service/memory_tracking.h" -#include "gpu/command_buffer/service/sync_point_manager.h" -#include "gpu/command_buffer/service/valuebuffer_manager.h" -#include "mojo/services/gles2/command_buffer_type_conversions.h" -#include "mojo/services/gles2/mojo_buffer_backing.h" -#include "ui/gfx/vsync_provider.h" -#include "ui/gl/gl_context.h" -#include "ui/gl/gl_surface.h" - -namespace gles2 { - -namespace { - -class MemoryTrackerStub : public gpu::gles2::MemoryTracker { - public: - MemoryTrackerStub() {} - - void TrackMemoryAllocatedChange( - size_t old_size, - size_t new_size, - gpu::gles2::MemoryTracker::Pool pool) override {} - - bool EnsureGPUMemoryAvailable(size_t size_needed) override { return true; }; - - private: - ~MemoryTrackerStub() override {} - - DISALLOW_COPY_AND_ASSIGN(MemoryTrackerStub); -}; - -} // anonymous namespace - -CommandBufferDriver::Client::~Client() { -} - -CommandBufferDriver::CommandBufferDriver( - gfx::GLShareGroup* share_group, - gpu::gles2::MailboxManager* mailbox_manager, - gpu::SyncPointManager* sync_point_manager) - : CommandBufferDriver(gfx::kNullAcceleratedWidget, - share_group, - mailbox_manager, - sync_point_manager) { -} - -CommandBufferDriver::CommandBufferDriver( - gfx::AcceleratedWidget widget, - gfx::GLShareGroup* share_group, - gpu::gles2::MailboxManager* mailbox_manager, - gpu::SyncPointManager* sync_point_manager) - : client_(nullptr), - widget_(widget), - share_group_(share_group), - mailbox_manager_(mailbox_manager), - sync_point_manager_(sync_point_manager), - weak_factory_(this) { -} - -CommandBufferDriver::~CommandBufferDriver() { - if (decoder_) { - bool have_context = decoder_->MakeCurrent(); - decoder_->Destroy(have_context); - } -} - -void CommandBufferDriver::Initialize( - mojo::CommandBufferSyncClientPtr sync_client, - mojo::CommandBufferLostContextObserverPtr loss_observer, - mojo::ScopedSharedBufferHandle shared_state) { - sync_client_ = sync_client.Pass(); - loss_observer_ = loss_observer.Pass(); - bool success = DoInitialize(shared_state.Pass()); - mojo::GpuCapabilitiesPtr capabilities = - success ? mojo::GpuCapabilities::From(decoder_->GetCapabilities()) - : mojo::GpuCapabilities::New(); - sync_client_->DidInitialize(success, capabilities.Pass()); -} - -bool CommandBufferDriver::DoInitialize( - mojo::ScopedSharedBufferHandle shared_state) { - if (widget_ == gfx::kNullAcceleratedWidget) - surface_ = gfx::GLSurface::CreateOffscreenGLSurface(gfx::Size(1, 1)); - else { - surface_ = gfx::GLSurface::CreateViewGLSurface(widget_); - if (auto vsync_provider = surface_->GetVSyncProvider()) { - vsync_provider->GetVSyncParameters( - base::Bind(&CommandBufferDriver::OnUpdateVSyncParameters, - weak_factory_.GetWeakPtr())); - } - } - - if (!surface_.get()) - return false; - - // TODO(piman): virtual contexts, gpu preference. - context_ = gfx::GLContext::CreateGLContext(share_group_.get(), surface_.get(), - gfx::PreferIntegratedGpu); - if (!context_.get()) - return false; - - if (!context_->MakeCurrent(surface_.get())) - return false; - - // TODO(piman): ShaderTranslatorCache is currently per-ContextGroup but - // only needs to be per-thread. - bool bind_generates_resource = false; - scoped_refptr<gpu::gles2::ContextGroup> context_group = - new gpu::gles2::ContextGroup( - mailbox_manager_.get(), new MemoryTrackerStub, - new gpu::gles2::ShaderTranslatorCache, nullptr, nullptr, nullptr, - bind_generates_resource); - - command_buffer_.reset( - new gpu::CommandBufferService(context_group->transfer_buffer_manager())); - bool result = command_buffer_->Initialize(); - DCHECK(result); - - decoder_.reset(::gpu::gles2::GLES2Decoder::Create(context_group.get())); - scheduler_.reset(new gpu::GpuScheduler(command_buffer_.get(), decoder_.get(), - decoder_.get())); - decoder_->set_engine(scheduler_.get()); - decoder_->SetResizeCallback( - base::Bind(&CommandBufferDriver::OnResize, base::Unretained(this))); - decoder_->SetWaitSyncPointCallback(base::Bind( - &CommandBufferDriver::OnWaitSyncPoint, base::Unretained(this))); - - gpu::gles2::DisallowedFeatures disallowed_features; - - // TODO(piman): attributes. - std::vector<int32> attrib_vector; - if (!decoder_->Initialize(surface_, context_, false /* offscreen */, - gfx::Size(1, 1), disallowed_features, - attrib_vector)) - return false; - - command_buffer_->SetPutOffsetChangeCallback(base::Bind( - &gpu::GpuScheduler::PutChanged, base::Unretained(scheduler_.get()))); - command_buffer_->SetGetBufferChangeCallback(base::Bind( - &gpu::GpuScheduler::SetGetBuffer, base::Unretained(scheduler_.get()))); - command_buffer_->SetParseErrorCallback( - base::Bind(&CommandBufferDriver::OnParseError, base::Unretained(this))); - - // TODO(piman): other callbacks - - const size_t kSize = sizeof(gpu::CommandBufferSharedState); - scoped_ptr<gpu::BufferBacking> backing( - gles2::MojoBufferBacking::Create(shared_state.Pass(), kSize)); - if (!backing) - return false; - - command_buffer_->SetSharedStateBuffer(backing.Pass()); - return true; -} - -void CommandBufferDriver::SetGetBuffer(int32_t buffer) { - command_buffer_->SetGetBuffer(buffer); -} - -void CommandBufferDriver::Flush(int32_t put_offset) { - if (!context_->MakeCurrent(surface_.get())) { - DLOG(WARNING) << "Context lost"; - OnContextLost(gpu::error::kUnknown); - return; - } - command_buffer_->Flush(put_offset); -} - -void CommandBufferDriver::MakeProgress(int32_t last_get_offset) { - // TODO(piman): handle out-of-order. - sync_client_->DidMakeProgress( - mojo::CommandBufferState::From(command_buffer_->GetLastState())); -} - -void CommandBufferDriver::RegisterTransferBuffer( - int32_t id, - mojo::ScopedSharedBufferHandle transfer_buffer, - uint32_t size) { - // Take ownership of the memory and map it into this process. - // This validates the size. - scoped_ptr<gpu::BufferBacking> backing( - gles2::MojoBufferBacking::Create(transfer_buffer.Pass(), size)); - if (!backing) { - DVLOG(0) << "Failed to map shared memory."; - return; - } - command_buffer_->RegisterTransferBuffer(id, backing.Pass()); -} - -void CommandBufferDriver::DestroyTransferBuffer(int32_t id) { - command_buffer_->DestroyTransferBuffer(id); -} - -void CommandBufferDriver::Echo(const mojo::Callback<void()>& callback) { - callback.Run(); -} - -void CommandBufferDriver::OnParseError() { - gpu::CommandBuffer::State state = command_buffer_->GetLastState(); - OnContextLost(state.context_lost_reason); -} - -void CommandBufferDriver::OnResize(gfx::Size size, float scale_factor) { - surface_->Resize(size); -} - -bool CommandBufferDriver::OnWaitSyncPoint(uint32_t sync_point) { - if (!sync_point) - return true; - if (sync_point_manager_->IsSyncPointRetired(sync_point)) - return true; - scheduler_->SetScheduled(false); - sync_point_manager_->AddSyncPointCallback( - sync_point, base::Bind(&CommandBufferDriver::OnSyncPointRetired, - weak_factory_.GetWeakPtr())); - return scheduler_->IsScheduled(); -} - -void CommandBufferDriver::OnSyncPointRetired() { - scheduler_->SetScheduled(true); -} - -void CommandBufferDriver::OnContextLost(uint32_t reason) { - loss_observer_->DidLoseContext(reason); - client_->DidLoseContext(); -} - -void CommandBufferDriver::OnUpdateVSyncParameters( - const base::TimeTicks timebase, - const base::TimeDelta interval) { - client_->UpdateVSyncParameters(timebase, interval); -} - -} // namespace gles2 diff --git a/mojo/services/gles2/command_buffer_driver.h b/mojo/services/gles2/command_buffer_driver.h deleted file mode 100644 index 5006567..0000000 --- a/mojo/services/gles2/command_buffer_driver.h +++ /dev/null @@ -1,103 +0,0 @@ -// Copyright 2013 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_GLES2_COMMAND_BUFFER_DRIVER_H_ -#define SERVICES_GLES2_COMMAND_BUFFER_DRIVER_H_ - -#include "base/callback.h" -#include "base/macros.h" -#include "base/memory/scoped_ptr.h" -#include "base/single_thread_task_runner.h" -#include "base/timer/timer.h" -#include "third_party/mojo_services/src/gpu/public/interfaces/command_buffer.mojom.h" -#include "ui/gfx/geometry/size.h" -#include "ui/gfx/native_widget_types.h" - -namespace gpu { -class CommandBufferService; -class GpuScheduler; -class GpuControlService; -class SyncPointManager; -namespace gles2 { -class GLES2Decoder; -class MailboxManager; -} -} - -namespace gfx { -class GLContext; -class GLShareGroup; -class GLSurface; -} - -namespace gles2 { - -class CommandBufferDriver { - public: - class Client { - public: - virtual ~Client(); - virtual void UpdateVSyncParameters(base::TimeTicks timebase, - base::TimeDelta interval) = 0; - virtual void DidLoseContext() = 0; - }; - // Offscreen. - CommandBufferDriver(gfx::GLShareGroup* share_group, - gpu::gles2::MailboxManager* mailbox_manager, - gpu::SyncPointManager* sync_point_manager); - // Onscreen. - CommandBufferDriver(gfx::AcceleratedWidget widget, - gfx::GLShareGroup* share_group, - gpu::gles2::MailboxManager* mailbox_manager, - gpu::SyncPointManager* sync_point_manager); - ~CommandBufferDriver(); - - void set_client(scoped_ptr<Client> client) { client_ = client.Pass(); } - - void Initialize(mojo::CommandBufferSyncClientPtr sync_client, - mojo::CommandBufferLostContextObserverPtr loss_observer, - mojo::ScopedSharedBufferHandle shared_state); - void SetGetBuffer(int32_t buffer); - void Flush(int32_t put_offset); - void MakeProgress(int32_t last_get_offset); - void RegisterTransferBuffer(int32_t id, - mojo::ScopedSharedBufferHandle transfer_buffer, - uint32_t size); - void DestroyTransferBuffer(int32_t id); - void Echo(const mojo::Callback<void()>& callback); - - private: - bool DoInitialize(mojo::ScopedSharedBufferHandle shared_state); - void OnResize(gfx::Size size, float scale_factor); - bool OnWaitSyncPoint(uint32_t sync_point); - void OnSyncPointRetired(); - void OnParseError(); - void OnContextLost(uint32_t reason); - void OnUpdateVSyncParameters(const base::TimeTicks timebase, - const base::TimeDelta interval); - - scoped_ptr<Client> client_; - mojo::CommandBufferSyncClientPtr sync_client_; - mojo::CommandBufferLostContextObserverPtr loss_observer_; - gfx::AcceleratedWidget widget_; - scoped_ptr<gpu::CommandBufferService> command_buffer_; - scoped_ptr<gpu::gles2::GLES2Decoder> decoder_; - scoped_ptr<gpu::GpuScheduler> scheduler_; - scoped_refptr<gfx::GLContext> context_; - scoped_refptr<gfx::GLSurface> surface_; - scoped_refptr<gfx::GLShareGroup> share_group_; - scoped_refptr<gpu::gles2::MailboxManager> mailbox_manager_; - scoped_refptr<gpu::SyncPointManager> sync_point_manager_; - - scoped_refptr<base::SingleThreadTaskRunner> context_lost_task_runner_; - base::Callback<void(int32_t)> context_lost_callback_; - - base::WeakPtrFactory<CommandBufferDriver> weak_factory_; - - DISALLOW_COPY_AND_ASSIGN(CommandBufferDriver); -}; - -} // namespace gles2 - -#endif // SERVICES_GLES2_COMMAND_BUFFER_DRIVER_H_ diff --git a/mojo/services/gles2/command_buffer_impl.cc b/mojo/services/gles2/command_buffer_impl.cc deleted file mode 100644 index b89279f..0000000 --- a/mojo/services/gles2/command_buffer_impl.cc +++ /dev/null @@ -1,160 +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/services/gles2/command_buffer_impl.h" - -#include "base/bind.h" -#include "base/message_loop/message_loop.h" -#include "gpu/command_buffer/service/sync_point_manager.h" -#include "mojo/services/gles2/command_buffer_driver.h" - -namespace gles2 { -namespace { -void DestroyDriver(scoped_ptr<CommandBufferDriver> driver) { - // Just let ~scoped_ptr run. -} - -void RunCallback(const mojo::Callback<void()>& callback) { - callback.Run(); -} - -class CommandBufferDriverClientImpl : public CommandBufferDriver::Client { - public: - CommandBufferDriverClientImpl( - base::WeakPtr<CommandBufferImpl> command_buffer, - scoped_refptr<base::SingleThreadTaskRunner> control_task_runner) - : command_buffer_(command_buffer), - control_task_runner_(control_task_runner) {} - - private: - void UpdateVSyncParameters(base::TimeTicks timebase, - base::TimeDelta interval) override { - control_task_runner_->PostTask( - FROM_HERE, base::Bind(&CommandBufferImpl::UpdateVSyncParameters, - command_buffer_, timebase, interval)); - } - - void DidLoseContext() override { - control_task_runner_->PostTask( - FROM_HERE, base::Bind(&CommandBufferImpl::DidLoseContext, - command_buffer_)); - } - - base::WeakPtr<CommandBufferImpl> command_buffer_; - scoped_refptr<base::SingleThreadTaskRunner> control_task_runner_; -}; -} - -CommandBufferImpl::CommandBufferImpl( - mojo::InterfaceRequest<mojo::CommandBuffer> request, - mojo::ViewportParameterListenerPtr listener, - scoped_refptr<base::SingleThreadTaskRunner> control_task_runner, - gpu::SyncPointManager* sync_point_manager, - scoped_ptr<CommandBufferDriver> driver) - : sync_point_manager_(sync_point_manager), - driver_task_runner_(base::MessageLoop::current()->task_runner()), - driver_(driver.Pass()), - viewport_parameter_listener_(listener.Pass()), - binding_(this), - weak_factory_(this) { - driver_->set_client(make_scoped_ptr(new CommandBufferDriverClientImpl( - weak_factory_.GetWeakPtr(), control_task_runner))); - - control_task_runner->PostTask( - FROM_HERE, base::Bind(&CommandBufferImpl::BindToRequest, - base::Unretained(this), base::Passed(&request))); -} - -CommandBufferImpl::~CommandBufferImpl() { - driver_task_runner_->PostTask( - FROM_HERE, base::Bind(&DestroyDriver, base::Passed(&driver_))); -} - -void CommandBufferImpl::Initialize( - mojo::CommandBufferSyncClientPtr sync_client, - mojo::CommandBufferSyncPointClientPtr sync_point_client, - mojo::CommandBufferLostContextObserverPtr loss_observer, - mojo::ScopedSharedBufferHandle shared_state) { - sync_point_client_ = sync_point_client.Pass(); - driver_task_runner_->PostTask( - FROM_HERE, - base::Bind(&CommandBufferDriver::Initialize, - base::Unretained(driver_.get()), base::Passed(&sync_client), - base::Passed(&loss_observer), - base::Passed(&shared_state))); -} - -void CommandBufferImpl::SetGetBuffer(int32_t buffer) { - driver_task_runner_->PostTask( - FROM_HERE, base::Bind(&CommandBufferDriver::SetGetBuffer, - base::Unretained(driver_.get()), buffer)); -} - -void CommandBufferImpl::Flush(int32_t put_offset) { - driver_task_runner_->PostTask( - FROM_HERE, base::Bind(&CommandBufferDriver::Flush, - base::Unretained(driver_.get()), put_offset)); -} - -void CommandBufferImpl::MakeProgress(int32_t last_get_offset) { - driver_task_runner_->PostTask( - FROM_HERE, base::Bind(&CommandBufferDriver::MakeProgress, - base::Unretained(driver_.get()), last_get_offset)); -} - -void CommandBufferImpl::RegisterTransferBuffer( - int32_t id, - mojo::ScopedSharedBufferHandle transfer_buffer, - uint32_t size) { - driver_task_runner_->PostTask( - FROM_HERE, base::Bind(&CommandBufferDriver::RegisterTransferBuffer, - base::Unretained(driver_.get()), id, - base::Passed(&transfer_buffer), size)); -} - -void CommandBufferImpl::DestroyTransferBuffer(int32_t id) { - driver_task_runner_->PostTask( - FROM_HERE, base::Bind(&CommandBufferDriver::DestroyTransferBuffer, - base::Unretained(driver_.get()), id)); -} - -void CommandBufferImpl::InsertSyncPoint(bool retire) { - uint32_t sync_point = sync_point_manager_->GenerateSyncPoint(); - sync_point_client_->DidInsertSyncPoint(sync_point); - if (retire) { - driver_task_runner_->PostTask( - FROM_HERE, base::Bind(&gpu::SyncPointManager::RetireSyncPoint, - sync_point_manager_, sync_point)); - } -} - -void CommandBufferImpl::RetireSyncPoint(uint32_t sync_point) { - driver_task_runner_->PostTask( - FROM_HERE, base::Bind(&gpu::SyncPointManager::RetireSyncPoint, - sync_point_manager_, sync_point)); -} - -void CommandBufferImpl::Echo(const mojo::Callback<void()>& callback) { - driver_task_runner_->PostTaskAndReply(FROM_HERE, base::Bind(&base::DoNothing), - base::Bind(&RunCallback, callback)); -} - -void CommandBufferImpl::BindToRequest( - mojo::InterfaceRequest<mojo::CommandBuffer> request) { - binding_.Bind(request.Pass()); -} - -void CommandBufferImpl::DidLoseContext() { - binding_.OnConnectionError(); -} - -void CommandBufferImpl::UpdateVSyncParameters(base::TimeTicks timebase, - base::TimeDelta interval) { - if (!viewport_parameter_listener_) - return; - viewport_parameter_listener_->OnVSyncParametersUpdated( - timebase.ToInternalValue(), interval.ToInternalValue()); -} - -} // namespace gles2 diff --git a/mojo/services/gles2/command_buffer_impl.h b/mojo/services/gles2/command_buffer_impl.h deleted file mode 100644 index 61b33a2..0000000 --- a/mojo/services/gles2/command_buffer_impl.h +++ /dev/null @@ -1,71 +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_GLES2_COMMAND_BUFFER_IMPL_H_ -#define SERVICES_GLES2_COMMAND_BUFFER_IMPL_H_ - -#include "base/memory/scoped_ptr.h" -#include "base/memory/weak_ptr.h" -#include "base/single_thread_task_runner.h" -#include "third_party/mojo/src/mojo/public/cpp/bindings/strong_binding.h" -#include "third_party/mojo_services/src/gpu/public/interfaces/command_buffer.mojom.h" -#include "third_party/mojo_services/src/gpu/public/interfaces/viewport_parameter_listener.mojom.h" - -namespace gpu { -class SyncPointManager; -} - -namespace gles2 { -class CommandBufferDriver; - -// This class listens to the CommandBuffer message pipe on a low-latency thread -// so that we can insert sync points without blocking on the GL driver. It -// forwards most method calls to the CommandBufferDriver, which runs on the -// same thread as the native viewport. -class CommandBufferImpl : public mojo::CommandBuffer { - public: - CommandBufferImpl( - mojo::InterfaceRequest<CommandBuffer> request, - mojo::ViewportParameterListenerPtr listener, - scoped_refptr<base::SingleThreadTaskRunner> control_task_runner, - gpu::SyncPointManager* sync_point_manager, - scoped_ptr<CommandBufferDriver> driver); - ~CommandBufferImpl() override; - - void Initialize(mojo::CommandBufferSyncClientPtr sync_client, - mojo::CommandBufferSyncPointClientPtr sync_point_client, - mojo::CommandBufferLostContextObserverPtr loss_observer, - mojo::ScopedSharedBufferHandle shared_state) override; - void SetGetBuffer(int32_t buffer) override; - void Flush(int32_t put_offset) override; - void MakeProgress(int32_t last_get_offset) override; - void RegisterTransferBuffer(int32_t id, - mojo::ScopedSharedBufferHandle transfer_buffer, - uint32_t size) override; - void DestroyTransferBuffer(int32_t id) override; - void InsertSyncPoint(bool retire) override; - void RetireSyncPoint(uint32_t sync_point) override; - void Echo(const mojo::Callback<void()>& callback) override; - - void DidLoseContext(); - void UpdateVSyncParameters(base::TimeTicks timebase, - base::TimeDelta interval); - - private: - void BindToRequest(mojo::InterfaceRequest<CommandBuffer> request); - - scoped_refptr<gpu::SyncPointManager> sync_point_manager_; - scoped_refptr<base::SingleThreadTaskRunner> driver_task_runner_; - scoped_ptr<CommandBufferDriver> driver_; - mojo::CommandBufferSyncPointClientPtr sync_point_client_; - mojo::ViewportParameterListenerPtr viewport_parameter_listener_; - mojo::StrongBinding<CommandBuffer> binding_; - - base::WeakPtrFactory<CommandBufferImpl> weak_factory_; - DISALLOW_COPY_AND_ASSIGN(CommandBufferImpl); -}; - -} // namespace gles2 - -#endif // SERVICES_GLES2_COMMAND_BUFFER_IMPL_H_ diff --git a/mojo/services/gles2/command_buffer_type_conversions.cc b/mojo/services/gles2/command_buffer_type_conversions.cc deleted file mode 100644 index 9c068be..0000000 --- a/mojo/services/gles2/command_buffer_type_conversions.cc +++ /dev/null @@ -1,170 +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/services/gles2/command_buffer_type_conversions.h" - -#include "third_party/mojo_services/src/gpu/public/interfaces/command_buffer.mojom.h" - -namespace mojo { - -CommandBufferStatePtr -TypeConverter<CommandBufferStatePtr, gpu::CommandBuffer::State>::Convert( - const gpu::CommandBuffer::State& input) { - CommandBufferStatePtr result(CommandBufferState::New()); - result->get_offset = input.get_offset; - result->token = input.token; - result->error = input.error; - result->context_lost_reason = input.context_lost_reason; - result->generation = input.generation; - return result.Pass(); -} - -gpu::CommandBuffer::State -TypeConverter<gpu::CommandBuffer::State, CommandBufferStatePtr>::Convert( - const CommandBufferStatePtr& input) { - gpu::CommandBuffer::State state; - state.get_offset = input->get_offset; - state.token = input->token; - state.error = static_cast<gpu::error::Error>(input->error); - state.context_lost_reason = - static_cast<gpu::error::ContextLostReason>(input->context_lost_reason); - state.generation = input->generation; - return state; -} - -GpuShaderPrecisionPtr -TypeConverter<GpuShaderPrecisionPtr, gpu::Capabilities::ShaderPrecision>:: - Convert(const gpu::Capabilities::ShaderPrecision& input) { - GpuShaderPrecisionPtr result(GpuShaderPrecision::New()); - result->min_range = input.min_range; - result->max_range = input.max_range; - result->precision = input.precision; - return result.Pass(); -} - -gpu::Capabilities::ShaderPrecision TypeConverter< - gpu::Capabilities::ShaderPrecision, - GpuShaderPrecisionPtr>::Convert(const GpuShaderPrecisionPtr& input) { - gpu::Capabilities::ShaderPrecision result; - result.min_range = input->min_range; - result.max_range = input->max_range; - result.precision = input->precision; - return result; -} - -GpuPerStagePrecisionsPtr -TypeConverter<GpuPerStagePrecisionsPtr, gpu::Capabilities::PerStagePrecisions>:: - Convert(const gpu::Capabilities::PerStagePrecisions& input) { - GpuPerStagePrecisionsPtr result(GpuPerStagePrecisions::New()); - result->low_int = GpuShaderPrecision::From(input.low_int); - result->medium_int = GpuShaderPrecision::From(input.medium_int); - result->high_int = GpuShaderPrecision::From(input.high_int); - result->low_float = GpuShaderPrecision::From(input.low_float); - result->medium_float = GpuShaderPrecision::From(input.medium_float); - result->high_float = GpuShaderPrecision::From(input.high_float); - return result.Pass(); -} - -gpu::Capabilities::PerStagePrecisions TypeConverter< - gpu::Capabilities::PerStagePrecisions, - GpuPerStagePrecisionsPtr>::Convert(const GpuPerStagePrecisionsPtr& input) { - gpu::Capabilities::PerStagePrecisions result; - result.low_int = input->low_int.To<gpu::Capabilities::ShaderPrecision>(); - result.medium_int = - input->medium_int.To<gpu::Capabilities::ShaderPrecision>(); - result.high_int = input->high_int.To<gpu::Capabilities::ShaderPrecision>(); - result.low_float = input->low_float.To<gpu::Capabilities::ShaderPrecision>(); - result.medium_float = - input->medium_float.To<gpu::Capabilities::ShaderPrecision>(); - result.high_float = - input->high_float.To<gpu::Capabilities::ShaderPrecision>(); - return result; -} - -GpuCapabilitiesPtr -TypeConverter<GpuCapabilitiesPtr, gpu::Capabilities>::Convert( - const gpu::Capabilities& input) { - GpuCapabilitiesPtr result(GpuCapabilities::New()); - result->vertex_shader_precisions = - GpuPerStagePrecisions::From(input.vertex_shader_precisions); - result->fragment_shader_precisions = - GpuPerStagePrecisions::From(input.fragment_shader_precisions); - result->max_combined_texture_image_units = - input.max_combined_texture_image_units; - result->max_cube_map_texture_size = input.max_cube_map_texture_size; - result->max_fragment_uniform_vectors = input.max_fragment_uniform_vectors; - result->max_renderbuffer_size = input.max_renderbuffer_size; - result->max_texture_image_units = input.max_texture_image_units; - result->max_texture_size = input.max_texture_size; - result->max_varying_vectors = input.max_varying_vectors; - result->max_vertex_attribs = input.max_vertex_attribs; - result->max_vertex_texture_image_units = input.max_vertex_texture_image_units; - result->max_vertex_uniform_vectors = input.max_vertex_uniform_vectors; - result->num_compressed_texture_formats = input.num_compressed_texture_formats; - result->num_shader_binary_formats = input.num_shader_binary_formats; - result->bind_generates_resource_chromium = - input.bind_generates_resource_chromium; - result->post_sub_buffer = input.post_sub_buffer; - result->egl_image_external = input.egl_image_external; - result->texture_format_bgra8888 = input.texture_format_bgra8888; - result->texture_format_etc1 = input.texture_format_etc1; - result->texture_format_etc1_npot = input.texture_format_etc1_npot; - result->texture_rectangle = input.texture_rectangle; - result->iosurface = input.iosurface; - result->texture_usage = input.texture_usage; - result->texture_storage = input.texture_storage; - result->discard_framebuffer = input.discard_framebuffer; - result->sync_query = input.sync_query; - result->image = input.image; - result->future_sync_points = input.future_sync_points; - result->blend_equation_advanced = input.blend_equation_advanced; - result->blend_equation_advanced_coherent = - input.blend_equation_advanced_coherent; - return result.Pass(); -} - -gpu::Capabilities TypeConverter<gpu::Capabilities, GpuCapabilitiesPtr>::Convert( - const GpuCapabilitiesPtr& input) { - gpu::Capabilities result; - result.vertex_shader_precisions = - input->vertex_shader_precisions - .To<gpu::Capabilities::PerStagePrecisions>(); - result.fragment_shader_precisions = - input->fragment_shader_precisions - .To<gpu::Capabilities::PerStagePrecisions>(); - result.max_combined_texture_image_units = - input->max_combined_texture_image_units; - result.max_cube_map_texture_size = input->max_cube_map_texture_size; - result.max_fragment_uniform_vectors = input->max_fragment_uniform_vectors; - result.max_renderbuffer_size = input->max_renderbuffer_size; - result.max_texture_image_units = input->max_texture_image_units; - result.max_texture_size = input->max_texture_size; - result.max_varying_vectors = input->max_varying_vectors; - result.max_vertex_attribs = input->max_vertex_attribs; - result.max_vertex_texture_image_units = input->max_vertex_texture_image_units; - result.max_vertex_uniform_vectors = input->max_vertex_uniform_vectors; - result.num_compressed_texture_formats = input->num_compressed_texture_formats; - result.num_shader_binary_formats = input->num_shader_binary_formats; - result.bind_generates_resource_chromium = - input->bind_generates_resource_chromium; - result.post_sub_buffer = input->post_sub_buffer; - result.egl_image_external = input->egl_image_external; - result.texture_format_bgra8888 = input->texture_format_bgra8888; - result.texture_format_etc1 = input->texture_format_etc1; - result.texture_format_etc1_npot = input->texture_format_etc1_npot; - result.texture_rectangle = input->texture_rectangle; - result.iosurface = input->iosurface; - result.texture_usage = input->texture_usage; - result.texture_storage = input->texture_storage; - result.discard_framebuffer = input->discard_framebuffer; - result.sync_query = input->sync_query; - result.image = input->image; - result.future_sync_points = input->future_sync_points; - result.blend_equation_advanced = input->blend_equation_advanced; - result.blend_equation_advanced_coherent = - input->blend_equation_advanced_coherent; - return result; -} - -} // namespace gles2 diff --git a/mojo/services/gles2/command_buffer_type_conversions.h b/mojo/services/gles2/command_buffer_type_conversions.h deleted file mode 100644 index 9243a56..0000000 --- a/mojo/services/gles2/command_buffer_type_conversions.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_GLES2_COMMAND_BUFFER_TYPE_CONVERSIONS_H_ -#define SERVICES_GLES2_COMMAND_BUFFER_TYPE_CONVERSIONS_H_ - -#include "gpu/command_buffer/common/capabilities.h" -#include "gpu/command_buffer/common/command_buffer.h" -#include "third_party/mojo/src/mojo/public/cpp/bindings/type_converter.h" -#include "third_party/mojo_services/src/gpu/public/interfaces/command_buffer.mojom.h" - -namespace mojo { - -class CommandBufferState; - -template <> -struct TypeConverter<CommandBufferStatePtr, gpu::CommandBuffer::State> { - static CommandBufferStatePtr Convert(const gpu::CommandBuffer::State& input); -}; - -template <> -struct TypeConverter<gpu::CommandBuffer::State, CommandBufferStatePtr> { - static gpu::CommandBuffer::State Convert(const CommandBufferStatePtr& input); -}; - -template <> -struct TypeConverter<GpuShaderPrecisionPtr, - gpu::Capabilities::ShaderPrecision> { - static GpuShaderPrecisionPtr Convert( - const gpu::Capabilities::ShaderPrecision& input); -}; - -template <> -struct TypeConverter<gpu::Capabilities::ShaderPrecision, - GpuShaderPrecisionPtr> { - static gpu::Capabilities::ShaderPrecision Convert( - const GpuShaderPrecisionPtr& input); -}; - -template <> -struct TypeConverter<GpuPerStagePrecisionsPtr, - gpu::Capabilities::PerStagePrecisions> { - static GpuPerStagePrecisionsPtr Convert( - const gpu::Capabilities::PerStagePrecisions& input); -}; - -template <> -struct TypeConverter<gpu::Capabilities::PerStagePrecisions, - GpuPerStagePrecisionsPtr> { - static gpu::Capabilities::PerStagePrecisions Convert( - const GpuPerStagePrecisionsPtr& input); -}; - -template <> -struct TypeConverter<GpuCapabilitiesPtr, gpu::Capabilities> { - static GpuCapabilitiesPtr Convert(const gpu::Capabilities& input); -}; - -template <> -struct TypeConverter<gpu::Capabilities, GpuCapabilitiesPtr> { - static gpu::Capabilities Convert(const GpuCapabilitiesPtr& input); -}; - -} // namespace gles2 - -#endif // SERVICES_GLES2_COMMAND_BUFFER_TYPE_CONVERSIONS_H_ diff --git a/mojo/services/gles2/gpu_impl.cc b/mojo/services/gles2/gpu_impl.cc deleted file mode 100644 index 304da8d..0000000 --- a/mojo/services/gles2/gpu_impl.cc +++ /dev/null @@ -1,36 +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/services/gles2/gpu_impl.h" - -#include "gpu/command_buffer/service/mailbox_manager.h" -#include "gpu/command_buffer/service/mailbox_manager_impl.h" -#include "gpu/command_buffer/service/sync_point_manager.h" -#include "mojo/converters/geometry/geometry_type_converters.h" -#include "mojo/services/gles2/command_buffer_driver.h" -#include "mojo/services/gles2/command_buffer_impl.h" -#include "ui/gl/gl_share_group.h" -#include "ui/gl/gl_surface.h" - -namespace gles2 { - -GpuImpl::GpuImpl(mojo::InterfaceRequest<Gpu> request, - const scoped_refptr<GpuState>& state) - : binding_(this, request.Pass()), state_(state) { -} - -GpuImpl::~GpuImpl() { -} - -void GpuImpl::CreateOffscreenGLES2Context( - mojo::InterfaceRequest<mojo::CommandBuffer> request) { - new CommandBufferImpl(request.Pass(), mojo::ViewportParameterListenerPtr(), - state_->control_task_runner(), - state_->sync_point_manager(), - make_scoped_ptr(new CommandBufferDriver( - state_->share_group(), state_->mailbox_manager(), - state_->sync_point_manager()))); -} - -} // namespace gles2 diff --git a/mojo/services/gles2/gpu_impl.h b/mojo/services/gles2/gpu_impl.h deleted file mode 100644 index 3e50a9a..0000000 --- a/mojo/services/gles2/gpu_impl.h +++ /dev/null @@ -1,49 +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_GLES2_GPU_IMPL_H_ -#define SERVICES_GLES2_GPU_IMPL_H_ - -#include "base/macros.h" -#include "base/memory/ref_counted.h" -#include "base/threading/thread.h" -#include "mojo/services/gles2/gpu_state.h" -#include "third_party/mojo/src/mojo/public/cpp/bindings/interface_request.h" -#include "third_party/mojo/src/mojo/public/cpp/bindings/strong_binding.h" -#include "third_party/mojo_services/src/geometry/public/interfaces/geometry.mojom.h" -#include "third_party/mojo_services/src/gpu/public/interfaces/command_buffer.mojom.h" -#include "third_party/mojo_services/src/gpu/public/interfaces/gpu.mojom.h" - -namespace gfx { -class GLShareGroup; -} - -namespace gpu { -class SyncPointManager; -namespace gles2 { -class MailboxManager; -} -} - -namespace gles2 { - -class GpuImpl : public mojo::Gpu { - public: - GpuImpl(mojo::InterfaceRequest<mojo::Gpu> request, - const scoped_refptr<GpuState>& state); - ~GpuImpl() override; - - private: - void CreateOffscreenGLES2Context(mojo::InterfaceRequest<mojo::CommandBuffer> - command_buffer_request) override; - - mojo::StrongBinding<Gpu> binding_; - scoped_refptr<GpuState> state_; - - DISALLOW_COPY_AND_ASSIGN(GpuImpl); -}; - -} // namespace gles2 - -#endif // SERVICES_GLES2_GPU_IMPL_H_ diff --git a/mojo/services/gles2/gpu_state.cc b/mojo/services/gles2/gpu_state.cc deleted file mode 100644 index 63d6e29..0000000 --- a/mojo/services/gles2/gpu_state.cc +++ /dev/null @@ -1,21 +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 "mojo/services/gles2/gpu_state.h" - -namespace gles2 { - -GpuState::GpuState() - : control_thread_("gpu_command_buffer_control"), - sync_point_manager_(gpu::SyncPointManager::Create(true)), - share_group_(new gfx::GLShareGroup), - mailbox_manager_(new gpu::gles2::MailboxManagerImpl) { - control_thread_.Start(); -} - -GpuState::~GpuState() { -} - -} // namespace gles2 diff --git a/mojo/services/gles2/gpu_state.h b/mojo/services/gles2/gpu_state.h deleted file mode 100644 index 1d75318..0000000 --- a/mojo/services/gles2/gpu_state.h +++ /dev/null @@ -1,52 +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_GLES2_GPU_STATE_H_ -#define SERVICES_GLES2_GPU_STATE_H_ - -#include "base/memory/ref_counted.h" -#include "base/single_thread_task_runner.h" -#include "base/threading/thread.h" -#include "gpu/command_buffer/service/mailbox_manager_impl.h" -#include "gpu/command_buffer/service/sync_point_manager.h" -#include "ui/gl/gl_share_group.h" - -namespace gles2 { - -// We need to share these across all CommandBuffer instances so that contexts -// they create can share resources with each other via mailboxes. -class GpuState : public base::RefCounted<GpuState> { - public: - GpuState(); - - // We run the CommandBufferImpl on the control_task_runner, which forwards - // most method class to the CommandBufferDriver, which runs on the "driver", - // thread (i.e., the thread on which GpuImpl instances are created). - scoped_refptr<base::SingleThreadTaskRunner> control_task_runner() { - return control_thread_.task_runner(); - } - - // These objects are intended to be used on the "driver" thread (i.e., the - // thread on which GpuImpl instances are created). - gfx::GLShareGroup* share_group() const { return share_group_.get(); } - gpu::gles2::MailboxManager* mailbox_manager() const { - return mailbox_manager_.get(); - } - gpu::SyncPointManager* sync_point_manager() const { - return sync_point_manager_.get(); - } - - private: - friend class base::RefCounted<GpuState>; - ~GpuState(); - - base::Thread control_thread_; - scoped_refptr<gpu::SyncPointManager> sync_point_manager_; - scoped_refptr<gfx::GLShareGroup> share_group_; - scoped_refptr<gpu::gles2::MailboxManager> mailbox_manager_; -}; - -} // namespace gles2 - -#endif // SERVICES_GLES2_GPU_STATE_H_ diff --git a/mojo/services/gles2/mojo_buffer_backing.cc b/mojo/services/gles2/mojo_buffer_backing.cc deleted file mode 100644 index 3e6c38e..0000000 --- a/mojo/services/gles2/mojo_buffer_backing.cc +++ /dev/null @@ -1,34 +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/services/gles2/mojo_buffer_backing.h" - -#include "base/logging.h" - -namespace gles2 { - -MojoBufferBacking::MojoBufferBacking(mojo::ScopedSharedBufferHandle handle, - void* memory, - size_t size) - : handle_(handle.Pass()), memory_(memory), size_(size) {} - -MojoBufferBacking::~MojoBufferBacking() { mojo::UnmapBuffer(memory_); } - -// static -scoped_ptr<gpu::BufferBacking> MojoBufferBacking::Create( - mojo::ScopedSharedBufferHandle handle, - size_t size) { - void* memory = NULL; - MojoResult result = mojo::MapBuffer( - handle.get(), 0, size, &memory, MOJO_MAP_BUFFER_FLAG_NONE); - if (result != MOJO_RESULT_OK) - return scoped_ptr<BufferBacking>(); - DCHECK(memory); - return scoped_ptr<BufferBacking>( - new MojoBufferBacking(handle.Pass(), memory, size)); -} -void* MojoBufferBacking::GetMemory() const { return memory_; } -size_t MojoBufferBacking::GetSize() const { return size_; } - -} // namespace gles2 diff --git a/mojo/services/gles2/mojo_buffer_backing.h b/mojo/services/gles2/mojo_buffer_backing.h deleted file mode 100644 index 6dfd509..0000000 --- a/mojo/services/gles2/mojo_buffer_backing.h +++ /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. - -#ifndef SERVICES_GLES2_MOJO_BUFFER_BACKING_H_ -#define SERVICES_GLES2_MOJO_BUFFER_BACKING_H_ - -#include "base/macros.h" -#include "base/memory/scoped_ptr.h" -#include "gpu/command_buffer/common/buffer.h" -#include "third_party/mojo/src/mojo/public/cpp/system/core.h" - -namespace gles2 { - -class MojoBufferBacking : public gpu::BufferBacking { - public: - MojoBufferBacking(mojo::ScopedSharedBufferHandle handle, - void* memory, - size_t size); - ~MojoBufferBacking() override; - - static scoped_ptr<gpu::BufferBacking> Create( - mojo::ScopedSharedBufferHandle handle, - size_t size); - - void* GetMemory() const override; - size_t GetSize() const override; - - private: - mojo::ScopedSharedBufferHandle handle_; - void* memory_; - size_t size_; - - DISALLOW_COPY_AND_ASSIGN(MojoBufferBacking); -}; - -} // namespace gles2 - -#endif // SERVICES_GLES2_MOJO_BUFFER_BACKING_H_ diff --git a/mojo/services/keyboard/public/interfaces/BUILD.gn b/mojo/services/keyboard/public/interfaces/BUILD.gn deleted file mode 100644 index 6aa9389..0000000 --- a/mojo/services/keyboard/public/interfaces/BUILD.gn +++ /dev/null @@ -1,12 +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("//build/module_args/mojo.gni") -import("$mojo_sdk_root/mojo/public/tools/bindings/mojom.gni") - -mojom("interfaces") { - sources = [ - "keyboard.mojom", - ] -} diff --git a/mojo/services/keyboard/public/interfaces/keyboard.mojom b/mojo/services/keyboard/public/interfaces/keyboard.mojom deleted file mode 100644 index d11253e..0000000 --- a/mojo/services/keyboard/public/interfaces/keyboard.mojom +++ /dev/null @@ -1,10 +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. - -module mojo; - -interface Keyboard { - Show(); - Hide(); -}; diff --git a/mojo/services/native_viewport/BUILD.gn b/mojo/services/native_viewport/BUILD.gn index 3e77370..39dee00 100644 --- a/mojo/services/native_viewport/BUILD.gn +++ b/mojo/services/native_viewport/BUILD.gn @@ -42,12 +42,12 @@ if (is_android) { deps = [ ":lib", "//base", + "//components/gles2", "//mojo/application", "//mojo/common:tracing_impl", "//third_party/mojo/src/mojo/public/cpp/bindings:bindings", "//third_party/mojo_services/src/native_viewport/public/interfaces", "//third_party/mojo_services/src/native_viewport/public/cpp:args", - "//mojo/services/gles2", "//ui/events", "//ui/events/platform", "//ui/gl", @@ -77,13 +77,13 @@ source_set("lib") { deps = [ "//base", + "//components/gles2", "//gpu/command_buffer/service", "//mojo/application", "//mojo/common", "//mojo/converters/geometry", "//mojo/converters/input_events", "//mojo/environment:chromium", - "//mojo/services/gles2", "//third_party/mojo_services/src/geometry/public/interfaces", "//third_party/mojo_services/src/native_viewport/public/interfaces", "//ui/events", diff --git a/mojo/services/native_viewport/DEPS b/mojo/services/native_viewport/DEPS index 9c70113..cfb361f 100644 --- a/mojo/services/native_viewport/DEPS +++ b/mojo/services/native_viewport/DEPS @@ -1,7 +1,7 @@ include_rules = [ + "+components/gles2", "+mojo/application", "+mojo/converters", - "+mojo/services/gles2", "+third_party/mojo_services", "+ui", ] diff --git a/mojo/services/native_viewport/main.cc b/mojo/services/native_viewport/main.cc index 504e555..35f6bd2 100644 --- a/mojo/services/native_viewport/main.cc +++ b/mojo/services/native_viewport/main.cc @@ -7,6 +7,7 @@ #include "base/command_line.h" #include "base/macros.h" #include "base/message_loop/message_loop.h" +#include "components/gles2/gpu_impl.h" #include "mojo/application/application_runner_chromium.h" #include "mojo/common/tracing_impl.h" #include "mojo/public/c/system/main.h" @@ -14,7 +15,6 @@ #include "mojo/public/cpp/application/application_delegate.h" #include "mojo/public/cpp/application/application_impl.h" #include "mojo/public/cpp/application/interface_factory_impl.h" -#include "mojo/services/gles2/gpu_impl.h" #include "mojo/services/native_viewport/native_viewport_impl.h" #include "third_party/mojo_services/src/native_viewport/public/cpp/args.h" #include "ui/events/event_switches.h" diff --git a/mojo/services/native_viewport/native_viewport_impl.cc b/mojo/services/native_viewport/native_viewport_impl.cc index f5bcc27..6450d78 100644 --- a/mojo/services/native_viewport/native_viewport_impl.cc +++ b/mojo/services/native_viewport/native_viewport_impl.cc @@ -9,9 +9,9 @@ #include "base/macros.h" #include "base/message_loop/message_loop.h" #include "base/time/time.h" +#include "components/gles2/gpu_state.h" #include "mojo/converters/geometry/geometry_type_converters.h" #include "mojo/public/cpp/application/interface_factory.h" -#include "mojo/services/gles2/gpu_state.h" #include "mojo/services/native_viewport/platform_viewport_headless.h" #include "ui/events/event.h" diff --git a/mojo/services/native_viewport/onscreen_context_provider.cc b/mojo/services/native_viewport/onscreen_context_provider.cc index af72736..da72837 100644 --- a/mojo/services/native_viewport/onscreen_context_provider.cc +++ b/mojo/services/native_viewport/onscreen_context_provider.cc @@ -4,9 +4,9 @@ #include "mojo/services/native_viewport/onscreen_context_provider.h" -#include "mojo/services/gles2/command_buffer_driver.h" -#include "mojo/services/gles2/command_buffer_impl.h" -#include "mojo/services/gles2/gpu_state.h" +#include "components/gles2/command_buffer_driver.h" +#include "components/gles2/command_buffer_impl.h" +#include "components/gles2/gpu_state.h" namespace native_viewport { diff --git a/mojo/shell/BUILD.gn b/mojo/shell/BUILD.gn index 10c5b2c..3620709 100644 --- a/mojo/shell/BUILD.gn +++ b/mojo/shell/BUILD.gn @@ -156,8 +156,6 @@ source_set("lib") { "android/android_handler_loader.h", "android/background_application_loader.cc", "android/background_application_loader.h", - "android/keyboard_impl.cc", - "android/keyboard_impl.h", "android/native_viewport_application_loader.cc", "android/native_viewport_application_loader.h", "android/ui_application_loader_android.cc", @@ -167,9 +165,8 @@ source_set("lib") { deps += [ ":jni_headers", ":run_android_application_function", + "//components/gles2", "//mojo/application:content_handler", - "//mojo/services/keyboard/public/interfaces", - "//mojo/services/gles2", "//mojo/services/native_viewport:lib", ] } @@ -223,7 +220,6 @@ if (is_android) { sources = [ "android/apk/src/org/chromium/mojo/shell/AndroidHandler.java", "android/apk/src/org/chromium/mojo/shell/Bootstrap.java", - "android/apk/src/org/chromium/mojo/shell/Keyboard.java", "android/apk/src/org/chromium/mojo/shell/ShellMain.java", "android/tests/src/org/chromium/mojo/shell/ShellTestBase.java", ] @@ -267,7 +263,6 @@ if (is_android) { java_files = [ "android/apk/src/org/chromium/mojo/shell/AndroidHandler.java", "android/apk/src/org/chromium/mojo/shell/FileHelper.java", - "android/apk/src/org/chromium/mojo/shell/Keyboard.java", "android/apk/src/org/chromium/mojo/shell/MojoShellActivity.java", "android/apk/src/org/chromium/mojo/shell/MojoShellApplication.java", "android/apk/src/org/chromium/mojo/shell/ShellMain.java", diff --git a/mojo/shell/DEPS b/mojo/shell/DEPS index 04fbd79..6c6ed51 100644 --- a/mojo/shell/DEPS +++ b/mojo/shell/DEPS @@ -1,4 +1,5 @@ include_rules = [ + "+components/gles2", "+crypto", "+jni", "+third_party/mojo_services", diff --git a/mojo/shell/android/apk/src/org/chromium/mojo/shell/Keyboard.java b/mojo/shell/android/apk/src/org/chromium/mojo/shell/Keyboard.java deleted file mode 100644 index e13ddea..0000000 --- a/mojo/shell/android/apk/src/org/chromium/mojo/shell/Keyboard.java +++ /dev/null @@ -1,35 +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. - -package org.chromium.mojo.shell; - -import android.app.Activity; -import android.content.Context; -import android.view.View; -import android.view.inputmethod.InputMethodManager; - -import org.chromium.base.CalledByNative; -import org.chromium.base.JNINamespace; - -/** - * Interaction with the keyboard. - */ -@JNINamespace("mojo::shell") -public class Keyboard { - @CalledByNative - private static void showSoftKeyboard(Activity activity) { - View v = activity.getCurrentFocus(); - InputMethodManager imm = - (InputMethodManager) activity.getSystemService(Context.INPUT_METHOD_SERVICE); - imm.showSoftInput(v, InputMethodManager.SHOW_IMPLICIT); - } - - @CalledByNative - private static void hideSoftKeyboard(Activity activity) { - View v = activity.getCurrentFocus(); - InputMethodManager imm = - (InputMethodManager) activity.getSystemService(Context.INPUT_METHOD_SERVICE); - imm.hideSoftInputFromWindow(v.getApplicationWindowToken(), 0); - } -} diff --git a/mojo/shell/android/keyboard_impl.cc b/mojo/shell/android/keyboard_impl.cc deleted file mode 100644 index 60336bb..0000000 --- a/mojo/shell/android/keyboard_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 "mojo/shell/android/keyboard_impl.h" - -#include "base/android/jni_android.h" -#include "base/logging.h" -#include "jni/Keyboard_jni.h" - -namespace mojo { -namespace shell { - -KeyboardImpl::KeyboardImpl(InterfaceRequest<Keyboard> request) - : binding_(this, request.Pass()) { -} - -KeyboardImpl::~KeyboardImpl() { -} - -void KeyboardImpl::Show() { - Java_Keyboard_showSoftKeyboard(base::android::AttachCurrentThread(), - base::android::GetApplicationContext()); -} - -void KeyboardImpl::Hide() { - Java_Keyboard_hideSoftKeyboard(base::android::AttachCurrentThread(), - base::android::GetApplicationContext()); -} - -bool RegisterKeyboardJni(JNIEnv* env) { - return RegisterNativesImpl(env); -} - -} // namespace shell -} // namespace mojo diff --git a/mojo/shell/android/keyboard_impl.h b/mojo/shell/android/keyboard_impl.h deleted file mode 100644 index e40b7dd..0000000 --- a/mojo/shell/android/keyboard_impl.h +++ /dev/null @@ -1,35 +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 SHELL_ANDROID_KEYBOARD_IMPL_H_ -#define SHELL_ANDROID_KEYBOARD_IMPL_H_ - -#include <jni.h> - -#include "mojo/public/cpp/bindings/interface_request.h" -#include "mojo/public/cpp/bindings/strong_binding.h" -#include "mojo/services/keyboard/public/interfaces/keyboard.mojom.h" - -namespace mojo { -namespace shell { - -class KeyboardImpl : public Keyboard { - public: - KeyboardImpl(InterfaceRequest<Keyboard> request); - ~KeyboardImpl(); - - // Keyboard implementation - void Show() override; - void Hide() override; - - private: - StrongBinding<Keyboard> binding_; -}; - -bool RegisterKeyboardJni(JNIEnv* env); - -} // namespace shell -} // namespace mojo - -#endif // SHELL_ANDROID_KEYBOARD_IMPL_H_ diff --git a/mojo/shell/android/library_loader.cc b/mojo/shell/android/library_loader.cc index cd3f7d2..3a1faa4 100644 --- a/mojo/shell/android/library_loader.cc +++ b/mojo/shell/android/library_loader.cc @@ -9,14 +9,12 @@ #include "base/bind.h" #include "mojo/services/native_viewport/platform_viewport_android.h" #include "mojo/shell/android/android_handler.h" -#include "mojo/shell/android/keyboard_impl.h" #include "mojo/shell/android/main.h" namespace { base::android::RegistrationMethod kMojoRegisteredMethods[] = { {"AndroidHandler", mojo::shell::RegisterAndroidHandlerJni}, - {"Keyboard", mojo::shell::RegisterKeyboardJni}, {"PlatformViewportAndroid", native_viewport::PlatformViewportAndroid::Register}, {"ShellMain", mojo::shell::RegisterShellMain}, diff --git a/mojo/shell/android/main.cc b/mojo/shell/android/main.cc index 9caf840..0e6c917 100644 --- a/mojo/shell/android/main.cc +++ b/mojo/shell/android/main.cc @@ -83,10 +83,6 @@ void ConfigureAndroidServices(Context* context) { make_scoped_ptr(new AndroidHandlerLoader()), "android_handler", base::MessageLoop::TYPE_DEFAULT)), GURL("mojo:android_handler")); - - // By default, the keyboard is handled by the native_viewport_service. - context->url_resolver()->AddURLMapping(GURL("mojo:keyboard"), - GURL("mojo:native_viewport_service")); } void QuitShellThread() { diff --git a/mojo/shell/android/native_viewport_application_loader.cc b/mojo/shell/android/native_viewport_application_loader.cc index e3e3767..bc52947 100644 --- a/mojo/shell/android/native_viewport_application_loader.cc +++ b/mojo/shell/android/native_viewport_application_loader.cc @@ -4,10 +4,9 @@ #include "mojo/shell/android/native_viewport_application_loader.h" +#include "components/gles2/gpu_state.h" #include "mojo/public/cpp/application/application_impl.h" -#include "mojo/services/gles2/gpu_state.h" #include "mojo/services/native_viewport/native_viewport_impl.h" -#include "mojo/shell/android/keyboard_impl.h" namespace mojo { namespace shell { @@ -29,7 +28,6 @@ bool NativeViewportApplicationLoader::ConfigureIncomingConnection( ApplicationConnection* connection) { connection->AddService<NativeViewport>(this); connection->AddService<Gpu>(this); - connection->AddService<Keyboard>(this); return true; } @@ -41,12 +39,6 @@ void NativeViewportApplicationLoader::Create( new native_viewport::NativeViewportImpl(false, gpu_state_, request.Pass()); } -void NativeViewportApplicationLoader::Create( - ApplicationConnection* connection, - InterfaceRequest<Keyboard> request) { - new KeyboardImpl(request.Pass()); -} - void NativeViewportApplicationLoader::Create(ApplicationConnection* connection, InterfaceRequest<Gpu> request) { if (!gpu_state_) diff --git a/mojo/shell/android/native_viewport_application_loader.h b/mojo/shell/android/native_viewport_application_loader.h index ece77e1..1efa7f4 100644 --- a/mojo/shell/android/native_viewport_application_loader.h +++ b/mojo/shell/android/native_viewport_application_loader.h @@ -5,10 +5,9 @@ #ifndef MOJO_SHELL_ANDROID_NATIVE_VIEWPORT_APPLICATION_LOADER_H_ #define MOJO_SHELL_ANDROID_NATIVE_VIEWPORT_APPLICATION_LOADER_H_ +#include "components/gles2/gpu_impl.h" #include "mojo/public/cpp/application/application_delegate.h" #include "mojo/public/cpp/application/interface_factory.h" -#include "mojo/services/gles2/gpu_impl.h" -#include "mojo/services/keyboard/public/interfaces/keyboard.mojom.h" #include "mojo/shell/application_manager/application_loader.h" #include "third_party/mojo_services/src/gpu/public/interfaces/gpu.mojom.h" #include "third_party/mojo_services/src/native_viewport/public/interfaces/native_viewport.mojom.h" @@ -25,7 +24,6 @@ namespace shell { class NativeViewportApplicationLoader : public ApplicationLoader, public ApplicationDelegate, - public InterfaceFactory<Keyboard>, public InterfaceFactory<NativeViewport>, public InterfaceFactory<Gpu> { public: @@ -48,10 +46,6 @@ class NativeViewportApplicationLoader : public ApplicationLoader, void Create(ApplicationConnection* connection, InterfaceRequest<Gpu> request) override; - // InterfaceFactory<Keyboard> implementation. - void Create(ApplicationConnection* connection, - InterfaceRequest<Keyboard> request) override; - scoped_refptr<gles2::GpuState> gpu_state_; scoped_ptr<ApplicationImpl> app_; |