Commit e3319087 authored by ckitagawa's avatar ckitagawa Committed by Commit Bot

[Paint Preview] Enable compositor service behind buildflag

This CL hooks up components/services/paint_preview_compositor to
Chrome. This service is similar in function to the pdf_compositor,
but handles different data and produces a different output.
Specifically, it consumes SkPictures and produces Bitmaps.

Note: this is behind the buildflag enable_paint_preview

Bug: 1011430
Change-Id: I0d169833c65fdb07e02d12dd0753ddc0066bb87a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1879560Reviewed-by: default avatarColin Blundell <blundell@chromium.org>
Reviewed-by: default avatarIan Vollick <vollick@chromium.org>
Reviewed-by: default avatarMehran Mahmoudi <mahmoudi@chromium.org>
Commit-Queue: Calder Kitagawa <ckitagawa@chromium.org>
Cr-Commit-Position: refs/heads/master@{#717270}
parent a2885f73
...@@ -35,8 +35,10 @@ static_library("utility") { ...@@ -35,8 +35,10 @@ static_library("utility") {
"//chrome/common", "//chrome/common",
"//chrome/common:mojo_bindings", "//chrome/common:mojo_bindings",
"//components/mirroring/service:mirroring_service", "//components/mirroring/service:mirroring_service",
"//components/paint_preview/buildflags",
"//components/safe_browsing:buildflags", "//components/safe_browsing:buildflags",
"//components/search_engines", "//components/search_engines",
"//components/services/paint_preview_compositor",
"//components/services/patch:lib", "//components/services/patch:lib",
"//components/services/unzip:lib", "//components/services/unzip:lib",
"//components/strings", "//components/strings",
......
...@@ -22,8 +22,10 @@ include_rules = [ ...@@ -22,8 +22,10 @@ include_rules = [
"+components/crash/core/common/crash_keys.h", "+components/crash/core/common/crash_keys.h",
"+components/mirroring/mojom", "+components/mirroring/mojom",
"+components/mirroring/service", "+components/mirroring/service",
"+components/paint_preview/buildflags",
"+components/payments/content/utility", "+components/payments/content/utility",
"+components/safe_browsing/buildflags.h", "+components/safe_browsing/buildflags.h",
"+components/services/paint_preview_compositor",
"+components/services/patch", "+components/services/patch",
"+components/services/pdf_compositor", "+components/services/pdf_compositor",
"+components/services/quarantine", "+components/services/quarantine",
......
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
#include "base/macros.h" #include "base/macros.h"
#include "base/no_destructor.h" #include "base/no_destructor.h"
#include "build/build_config.h" #include "build/build_config.h"
#include "components/paint_preview/buildflags/buildflags.h"
#include "components/safe_browsing/buildflags.h" #include "components/safe_browsing/buildflags.h"
#include "components/services/patch/file_patcher_impl.h" #include "components/services/patch/file_patcher_impl.h"
#include "components/services/patch/public/mojom/file_patcher.mojom.h" #include "components/services/patch/public/mojom/file_patcher.mojom.h"
...@@ -74,6 +75,9 @@ ...@@ -74,6 +75,9 @@
#include "components/services/pdf_compositor/public/mojom/pdf_compositor.mojom.h" // nogncheck #include "components/services/pdf_compositor/public/mojom/pdf_compositor.mojom.h" // nogncheck
#endif #endif
#include "components/services/paint_preview_compositor/paint_preview_compositor_collection_impl.h"
#include "components/services/paint_preview_compositor/public/mojom/paint_preview_compositor.mojom.h"
#if defined(OS_CHROMEOS) #if defined(OS_CHROMEOS)
#include "chromeos/assistant/buildflags.h" // nogncheck #include "chromeos/assistant/buildflags.h" // nogncheck
#include "chromeos/services/ime/ime_service.h" #include "chromeos/services/ime/ime_service.h"
...@@ -170,6 +174,16 @@ auto RunPrintingService( ...@@ -170,6 +174,16 @@ auto RunPrintingService(
} }
#endif #endif
#if BUILDFLAG(ENABLE_PAINT_PREVIEW)
auto RunPaintPreviewCompositor(
mojo::PendingReceiver<
paint_preview::mojom::PaintPreviewCompositorCollection> receiver) {
return std::make_unique<paint_preview::PaintPreviewCompositorCollectionImpl>(
std::move(receiver), /*initialize_environment=*/true,
content::UtilityThread::Get()->GetIOTaskRunner());
}
#endif // BUILDFLAG(ENABLE_PAINT_PREVIEW)
#if BUILDFLAG(ENABLE_PRINTING) #if BUILDFLAG(ENABLE_PRINTING)
auto RunPdfCompositor( auto RunPdfCompositor(
mojo::PendingReceiver<printing::mojom::PdfCompositor> receiver) { mojo::PendingReceiver<printing::mojom::PdfCompositor> receiver) {
...@@ -257,6 +271,10 @@ mojo::ServiceFactory* GetMainThreadServiceFactory() { ...@@ -257,6 +271,10 @@ mojo::ServiceFactory* GetMainThreadServiceFactory() {
RunPdfCompositor, RunPdfCompositor,
#endif #endif
#if BUILDFLAG(ENABLE_PAINT_PREVIEW)
RunPaintPreviewCompositor,
#endif
#if defined(OS_CHROMEOS) #if defined(OS_CHROMEOS)
RunImeService, RunImeService,
#if BUILDFLAG(ENABLE_CROS_LIBASSISTANT) #if BUILDFLAG(ENABLE_CROS_LIBASSISTANT)
......
...@@ -21,6 +21,7 @@ per-file new_or_sad_tab_strings.grdp=file://chrome/browser/resources/ntp4/OWNERS ...@@ -21,6 +21,7 @@ per-file new_or_sad_tab_strings.grdp=file://chrome/browser/resources/ntp4/OWNERS
per-file ntp_snippets_strings.grdp=file://components/ntp_snippets/OWNERS per-file ntp_snippets_strings.grdp=file://components/ntp_snippets/OWNERS
per-file omnibox_strings.grdp=file://components/omnibox/OWNERS per-file omnibox_strings.grdp=file://components/omnibox/OWNERS
per-file page_info_strings.grdp=file://chrome/browser/ui/page_info/OWNERS per-file page_info_strings.grdp=file://chrome/browser/ui/page_info/OWNERS
per-file paint_preview_strings.grdp=file://components/paint_preview/OWNERS
per-file password_manager_strings.grdp=file://components/password_manager/OWNERS per-file password_manager_strings.grdp=file://components/password_manager/OWNERS
per-file payments_strings.grdp=file://components/payments/OWNERS per-file payments_strings.grdp=file://components/payments/OWNERS
per-file pdf_strings.grdp=file://pdf/OWNERS per-file pdf_strings.grdp=file://pdf/OWNERS
......
...@@ -213,6 +213,7 @@ ...@@ -213,6 +213,7 @@
<part file="ntp_snippets_strings.grdp" /> <part file="ntp_snippets_strings.grdp" />
<part file="omnibox_strings.grdp" /> <part file="omnibox_strings.grdp" />
<part file="page_info_strings.grdp" /> <part file="page_info_strings.grdp" />
<part file="paint_preview_strings.grdp" />
<part file="password_manager_strings.grdp" /> <part file="password_manager_strings.grdp" />
<part file="payments_strings.grdp" /> <part file="payments_strings.grdp" />
<part file="pdf_strings.grdp" /> <part file="pdf_strings.grdp" />
......
...@@ -7,6 +7,8 @@ import("//testing/test.gni") ...@@ -7,6 +7,8 @@ import("//testing/test.gni")
if (!is_ios) { if (!is_ios) {
static_library("browser") { static_library("browser") {
sources = [ sources = [
"compositor_utils.cc",
"compositor_utils.h",
"file_manager.cc", "file_manager.cc",
"file_manager.h", "file_manager.h",
"hit_tester.cc", "hit_tester.cc",
...@@ -18,8 +20,11 @@ if (!is_ios) { ...@@ -18,8 +20,11 @@ if (!is_ios) {
deps = [ deps = [
"//base", "//base",
"//cc/base", "//cc/base",
"//components/discardable_memory/service",
"//components/strings:components_strings",
"//content/public/browser", "//content/public/browser",
"//mojo/public/cpp/base", "//mojo/public/cpp/base",
"//mojo/public/cpp/bindings",
"//third_party/blink/public:blink_headers", "//third_party/blink/public:blink_headers",
"//third_party/blink/public/common", "//third_party/blink/public/common",
"//third_party/zlib/google:zip", "//third_party/zlib/google:zip",
...@@ -31,6 +36,7 @@ if (!is_ios) { ...@@ -31,6 +36,7 @@ if (!is_ios) {
"//components/paint_preview/common", "//components/paint_preview/common",
"//components/paint_preview/common/mojom", "//components/paint_preview/common/mojom",
"//components/paint_preview/common/proto", "//components/paint_preview/common/proto",
"//components/services/paint_preview_compositor/public/mojom",
] ]
} }
......
include_rules = [ include_rules = [
"+cc/base", "+cc/base",
"+components/discardable_memory/service",
"+components/services/paint_preview_compositor/public/mojom",
"+components/strings/grit/components_strings.h",
"+content/public/browser", "+content/public/browser",
"+content/public/test", "+content/public/test",
"+third_party/blink/public/common", "+third_party/blink/public/common",
......
// Copyright 2019 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 "components/paint_preview/browser/compositor_utils.h"
#include <utility>
#include "base/bind.h"
#include "base/task/post_task.h"
#include "components/discardable_memory/service/discardable_shared_memory_manager.h"
#include "components/services/paint_preview_compositor/public/mojom/paint_preview_compositor.mojom.h"
#include "components/strings/grit/components_strings.h"
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/service_process_host.h"
#include "mojo/public/cpp/bindings/remote.h"
namespace paint_preview {
namespace {
void BindDiscardableSharedMemoryManagerOnIOThread(
mojo::PendingReceiver<
discardable_memory::mojom::DiscardableSharedMemoryManager> receiver) {
DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
discardable_memory::DiscardableSharedMemoryManager::Get()->Bind(
std::move(receiver));
}
} // namespace
mojo::Remote<mojom::PaintPreviewCompositorCollection>
CreateCompositorCollection() {
auto collection = content::ServiceProcessHost::Launch<
mojom::PaintPreviewCompositorCollection>(
content::ServiceProcessHost::Options()
.WithDisplayName(IDS_PAINT_PREVIEW_COMPOSITOR_SERVICE_DISPLAY_NAME)
.WithSandboxType(service_manager::SANDBOX_TYPE_PDF_COMPOSITOR)
.Pass());
mojo::PendingRemote<discardable_memory::mojom::DiscardableSharedMemoryManager>
discardable_memory_manager;
// Set up the discardable memory manager.
base::PostTask(
FROM_HERE, {content::BrowserThread::IO},
base::BindOnce(
&BindDiscardableSharedMemoryManagerOnIOThread,
discardable_memory_manager.InitWithNewPipeAndPassReceiver()));
collection->SetDiscardableSharedMemoryManager(
std::move(discardable_memory_manager));
return collection;
}
} // namespace paint_preview
// Copyright 2019 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 COMPONENTS_PAINT_PREVIEW_BROWSER_COMPOSITOR_UTILS_H_
#define COMPONENTS_PAINT_PREVIEW_BROWSER_COMPOSITOR_UTILS_H_
#include "components/services/paint_preview_compositor/public/mojom/paint_preview_compositor.mojom.h"
#include "mojo/public/cpp/bindings/remote.h"
namespace paint_preview {
// Creates a utility process via the service manager that is sandboxed and
// running an instance of the PaintPreviewCompositorCollectionImpl. This can be
// used to create compositor instances that composite Paint Previews into
// bitmaps. The service is killed when the remote goes out of scope.
mojo::Remote<mojom::PaintPreviewCompositorCollection>
CreateCompositorCollection();
} // namespace paint_preview
#endif // COMPONENTS_PAINT_PREVIEW_BROWSER_COMPOSITOR_UTILS_H_
# Copyright 2019 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/buildflag_header.gni")
import("//components/paint_preview/buildflags/buildflags.gni")
# This target is standalone so any targets in the build can refer to the
# buildflag without bringing in any paint preview targets.
buildflag_header("buildflags") {
header = "buildflags.h"
flags = [ "ENABLE_PAINT_PREVIEW=$enable_paint_preview" ]
}
# Copyright 2019 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/config/chromecast_build.gni")
import("//build/config/features.gni")
declare_args() {
# Enable basic paint preview support. Does not work on iOS or Fuchsia. Should
# not be included with Chromecast. Not ready for shipping builds yet so
# include in unofficial builds.
enable_paint_preview =
!is_chromecast && !is_ios && !is_fuchsia && !is_official_build
}
<?xml version="1.0" encoding="utf-8"?>
<grit-part>
<message name="IDS_PAINT_PREVIEW_COMPOSITOR_SERVICE_DISPLAY_NAME" desc="The display name (in the system task manager, etc) of the service process used for compositing Paint Previews.">
Paint Preview Compositor Service
</message>
</grit-part>
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment