Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: cherry-pick 56de3b2004, bbca3704f9 and f2b0985ac3 from chromium #31921

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions patches/chromium/.patches
Expand Up @@ -164,3 +164,6 @@ move_networkstateobserver_from_document_to_window.patch
cherry-pick-0894af410c4e.patch
disable_quictransport_explicitly_in_the_network_service.patch
cherry-pick-91dd4f79ab5b.patch
introduce_crossthreadcopier_skbitmap.patch
allow_null_skbitmap_to_be_transferred_across_threads.patch
use_weakptrs_for_the_threadediconloader_s_background_tasks.patch
@@ -0,0 +1,40 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Yutaka Hirano <yhirano@chromium.org>
Date: Tue, 9 Nov 2021 09:03:17 +0000
Subject: Allow null SkBitmap to be transferred across threads

(cherry picked from commit dad0c0e5162bcc49b8f60354d3bca92224d8381b)

Bug: 1241091
Change-Id: Ie96932c14c8884d6d3eafa76dab5043e7aa31888
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3251815
Reviewed-by: Florin Malita <fmalita@chromium.org>
Commit-Queue: Yutaka Hirano <yhirano@chromium.org>
Cr-Original-Commit-Position: refs/heads/main@{#936861}
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3268018
Auto-Submit: Yutaka Hirano <yhirano@chromium.org>
Reviewed-by: Kentaro Hara <haraken@chromium.org>
Commit-Queue: Kentaro Hara <haraken@chromium.org>
Cr-Commit-Position: refs/branch-heads/4664@{#893}
Cr-Branched-From: 24dc4ee75e01a29d390d43c9c264372a169273a7-refs/heads/main@{#929512}

diff --git a/third_party/blink/renderer/platform/graphics/skia/skia_utils.h b/third_party/blink/renderer/platform/graphics/skia/skia_utils.h
index 3bd49cac3f5dfcad0fcc1140fcf876fe37558930..c037b85210bf2dedeb8478cf918633ad94885048 100644
--- a/third_party/blink/renderer/platform/graphics/skia/skia_utils.h
+++ b/third_party/blink/renderer/platform/graphics/skia/skia_utils.h
@@ -209,11 +209,13 @@ struct CrossThreadCopier<SkBitmap> {

using Type = SkBitmap;
static SkBitmap Copy(const SkBitmap& bitmap) {
- CHECK(bitmap.isImmutable()) << "Only immutable bitmaps can be transferred.";
+ CHECK(bitmap.isImmutable() || bitmap.isNull())
+ << "Only immutable bitmaps can be transferred.";
return bitmap;
}
static SkBitmap Copy(SkBitmap&& bitmap) {
- CHECK(bitmap.isImmutable()) << "Only immutable bitmaps can be transferred.";
+ CHECK(bitmap.isImmutable() || bitmap.isNull())
+ << "Only immutable bitmaps can be transferred.";
return std::move(bitmap);
}
};
62 changes: 62 additions & 0 deletions patches/chromium/introduce_crossthreadcopier_skbitmap.patch
@@ -0,0 +1,62 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Yutaka Hirano <yhirano@chromium.org>
Date: Tue, 9 Nov 2021 05:02:50 +0000
Subject: Introduce CrossThreadCopier<SkBitmap>

Allow immutable SkBitmap to be transferred across threads.

(cherry picked from commit fd794ad56432870e462aab9d62e4f059169c1a5f)

Bug: 1241091
Change-Id: Ia771893245ef2fc1acb05cd4906d64bf2dd406fe
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3244824
Reviewed-by: danakj <danakj@chromium.org>
Reviewed-by: Florin Malita <fmalita@chromium.org>
Commit-Queue: Yutaka Hirano <yhirano@chromium.org>
Cr-Original-Commit-Position: refs/heads/main@{#936435}
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3267808
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Reviewed-by: Kentaro Hara <haraken@chromium.org>
Cr-Commit-Position: refs/branch-heads/4664@{#887}
Cr-Branched-From: 24dc4ee75e01a29d390d43c9c264372a169273a7-refs/heads/main@{#929512}

diff --git a/third_party/blink/renderer/platform/graphics/skia/skia_utils.h b/third_party/blink/renderer/platform/graphics/skia/skia_utils.h
index 997893fef2caee37b65e8ca6dfe9ca7b81302f98..3bd49cac3f5dfcad0fcc1140fcf876fe37558930 100644
--- a/third_party/blink/renderer/platform/graphics/skia/skia_utils.h
+++ b/third_party/blink/renderer/platform/graphics/skia/skia_utils.h
@@ -39,7 +39,9 @@
#include "third_party/blink/renderer/platform/graphics/image.h"
#include "third_party/blink/renderer/platform/platform_export.h"
#include "third_party/blink/renderer/platform/transforms/affine_transform.h"
+#include "third_party/blink/renderer/platform/wtf/cross_thread_copier.h"
#include "third_party/blink/renderer/platform/wtf/math_extras.h"
+#include "third_party/skia/include/core/SkBitmap.h"
#include "third_party/skia/include/core/SkCanvas.h"
#include "third_party/skia/include/core/SkColor.h"
#include "third_party/skia/include/core/SkData.h"
@@ -197,4 +199,25 @@ PLATFORM_EXPORT sk_sp<SkData> TryAllocateSkData(size_t size);

} // namespace blink

+namespace WTF {
+
+// We define CrossThreadCopier<SKBitMap> here because we cannot include skia
+// headers in platform/wtf.
+template <>
+struct CrossThreadCopier<SkBitmap> {
+ STATIC_ONLY(CrossThreadCopier);
+
+ using Type = SkBitmap;
+ static SkBitmap Copy(const SkBitmap& bitmap) {
+ CHECK(bitmap.isImmutable()) << "Only immutable bitmaps can be transferred.";
+ return bitmap;
+ }
+ static SkBitmap Copy(SkBitmap&& bitmap) {
+ CHECK(bitmap.isImmutable()) << "Only immutable bitmaps can be transferred.";
+ return std::move(bitmap);
+ }
+};
+
+} // namespace WTF
+
#endif // THIRD_PARTY_BLINK_RENDERER_PLATFORM_GRAPHICS_SKIA_SKIA_UTILS_H_