aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTreehugger Robot <android-test-infra-autosubmit@system.gserviceaccount.com>2023-12-12 17:14:00 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2023-12-12 17:14:00 +0000
commitae84ac601811ef056d10c77df9caab6d247c3310 (patch)
tree009c337c6d500a12b10e20547bc709abf0e5daa7
parent83a2dba507bf05de3cf512275ac5573809cd75c4 (diff)
parenta91bd4a4a48cb83547d60667c51c3a01a4c26c0b (diff)
downloadskia-ae84ac601811ef056d10c77df9caab6d247c3310.tar.gz
Merge "Roll Skia from 053490edfa70 to 7685acfb6221 (1 revision)" into main
-rw-r--r--Android.bp3
-rw-r--r--BUILD.gn4
-rw-r--r--METADATA2
-rw-r--r--bazel/exporter_tool/main.go4
-rw-r--r--gn/gpu.gni4
-rw-r--r--include/android/AHardwareBufferUtils.h23
-rw-r--r--include/android/BUILD.bazel1
-rw-r--r--include/android/GrAHardwareBufferUtils.h2
-rw-r--r--src/gpu/BUILD.bazel1
-rw-r--r--src/gpu/android/AHardwareBufferUtils.cpp45
-rw-r--r--src/gpu/android/BUILD.bazel11
-rw-r--r--src/gpu/ganesh/GrAHardwareBufferImageGenerator.cpp3
-rw-r--r--src/gpu/ganesh/GrAHardwareBufferUtils.cpp29
-rw-r--r--src/gpu/ganesh/surface/SkSurface_AndroidFactories.cpp82
-rw-r--r--src/image/SkImage_AndroidFactories.cpp3
-rw-r--r--tests/MultiPictureDocumentTest.cpp3
16 files changed, 151 insertions, 69 deletions
diff --git a/Android.bp b/Android.bp
index 65bfaa1bc9..1fd1f2cdab 100644
--- a/Android.bp
+++ b/Android.bp
@@ -453,6 +453,7 @@ cc_library_static {
"src/gpu/SkBackingFit.cpp",
"src/gpu/Swizzle.cpp",
"src/gpu/TiledTextureUtils.cpp",
+ "src/gpu/android/AHardwareBufferUtils.cpp",
"src/gpu/ganesh/ClipStack.cpp",
"src/gpu/ganesh/Device.cpp",
"src/gpu/ganesh/Device_drawTexture.cpp",
@@ -1563,6 +1564,7 @@ cc_library_static {
"src/gpu/SkBackingFit.cpp",
"src/gpu/Swizzle.cpp",
"src/gpu/TiledTextureUtils.cpp",
+ "src/gpu/android/AHardwareBufferUtils.cpp",
"src/gpu/ganesh/ClipStack.cpp",
"src/gpu/ganesh/Device.cpp",
"src/gpu/ganesh/Device_drawTexture.cpp",
@@ -4173,6 +4175,7 @@ cc_library_shared {
"src/gpu/SkBackingFit.cpp",
"src/gpu/Swizzle.cpp",
"src/gpu/TiledTextureUtils.cpp",
+ "src/gpu/android/AHardwareBufferUtils.cpp",
"src/gpu/ganesh/ClipStack.cpp",
"src/gpu/ganesh/Device.cpp",
"src/gpu/ganesh/Device_drawTexture.cpp",
diff --git a/BUILD.gn b/BUILD.gn
index e93503ee48..8ce9ad8da7 100644
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -962,6 +962,10 @@ optional("gpu_shared") {
public_defines += [ "SK_METAL" ]
sources += skia_shared_mtl_sources
}
+
+ if (is_android) {
+ sources += skia_shared_android_sources
+ }
}
optional("gpu") {
diff --git a/METADATA b/METADATA
index 3b863ffbcf..ee0a58aba9 100644
--- a/METADATA
+++ b/METADATA
@@ -9,7 +9,7 @@ third_party {
type: GIT
value: "https://skia.googlesource.com/skia"
}
- version: "053490edfa703f3433d97a299ee80f2acc93de71"
+ version: "7685acfb622190506f54533b5083737cb36f86ca"
license_type: RECIPROCAL
last_upgrade_date {
year: 2023
diff --git a/bazel/exporter_tool/main.go b/bazel/exporter_tool/main.go
index 76c58fa087..a587eea164 100644
--- a/bazel/exporter_tool/main.go
+++ b/bazel/exporter_tool/main.go
@@ -420,6 +420,10 @@ var gniExportDescs = []exporter.GNIExportDesc{
"//src/gpu/mtl:mtl_hdrs",
"//src/gpu/mtl:mtl_srcs",
}},
+ {Var: "skia_shared_android_sources",
+ Rules: []string{
+ "//src/gpu/android:shared_android_srcs",
+ }},
}},
{GNI: "modules/svg/svg.gni", Vars: []exporter.GNIFileListExportDesc{
{Var: "skia_svg_public",
diff --git a/gn/gpu.gni b/gn/gpu.gni
index c7cfaa913a..61afc6d8e9 100644
--- a/gn/gpu.gni
+++ b/gn/gpu.gni
@@ -18,6 +18,7 @@
# //include/private/gpu/ganesh/BUILD.bazel
# //include/private/gpu/vk/BUILD.bazel
# //src/gpu/BUILD.bazel
+# //src/gpu/android/BUILD.bazel
# //src/gpu/ganesh/BUILD.bazel
# //src/gpu/ganesh/d3d/BUILD.bazel
# //src/gpu/ganesh/effects/BUILD.bazel
@@ -1120,3 +1121,6 @@ skia_shared_mtl_sources = [
"$_src/gpu/mtl/MtlUtils.mm",
"$_src/gpu/mtl/MtlUtilsPriv.h",
]
+
+# Generated by Bazel rule //src/gpu/android:shared_android_srcs
+skia_shared_android_sources = [ "$_src/gpu/android/AHardwareBufferUtils.cpp" ]
diff --git a/include/android/AHardwareBufferUtils.h b/include/android/AHardwareBufferUtils.h
new file mode 100644
index 0000000000..a1f4f7e99a
--- /dev/null
+++ b/include/android/AHardwareBufferUtils.h
@@ -0,0 +1,23 @@
+/*
+ * Copyright 2023 Google LLC
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+#ifndef AHardwareBufferUtils_DEFINED
+#define AHardwareBufferUtils_DEFINED
+
+#include "include/core/SkColorType.h"
+#include "include/core/SkTypes.h"
+
+#if __ANDROID_API__ >= 26
+
+namespace AHardwareBufferUtils {
+
+SkColorType GetSkColorTypeFromBufferFormat(uint32_t bufferFormat);
+
+} // namespace AHardwareBufferUtils
+
+#endif
+
+#endif // AHardwareBufferUtils_DEFINED
diff --git a/include/android/BUILD.bazel b/include/android/BUILD.bazel
index 45d87a6885..7e0e61c277 100644
--- a/include/android/BUILD.bazel
+++ b/include/android/BUILD.bazel
@@ -16,6 +16,7 @@ skia_filegroup(
skia_filegroup(
name = "private_hdrs",
srcs = [
+ "AHardwareBufferUtils.h",
"GrAHardwareBufferUtils.h",
"SkCanvasAndroid.h",
"SkImageAndroid.h",
diff --git a/include/android/GrAHardwareBufferUtils.h b/include/android/GrAHardwareBufferUtils.h
index 474e9f4a66..92d6dd4d78 100644
--- a/include/android/GrAHardwareBufferUtils.h
+++ b/include/android/GrAHardwareBufferUtils.h
@@ -22,6 +22,8 @@ extern "C" {
namespace GrAHardwareBufferUtils {
+// TODO: remove this function once Android has been updated to call the AHardwareBufferUtils
+// version
SkColorType GetSkColorTypeFromBufferFormat(uint32_t bufferFormat);
#if !defined(SK_DISABLE_LEGACY_ANDROID_HW_UTILS)
diff --git a/src/gpu/BUILD.bazel b/src/gpu/BUILD.bazel
index a06915cee2..6c1bc7244b 100644
--- a/src/gpu/BUILD.bazel
+++ b/src/gpu/BUILD.bazel
@@ -151,6 +151,7 @@ skia_filegroup(
] + select(
{
":has_vulkan": ["//src/gpu/vk:srcs"],
+ "@platforms//os:android": ["//src/gpu/android:shared_android_srcs"],
"//conditions:default": [],
},
),
diff --git a/src/gpu/android/AHardwareBufferUtils.cpp b/src/gpu/android/AHardwareBufferUtils.cpp
new file mode 100644
index 0000000000..dfe236aacf
--- /dev/null
+++ b/src/gpu/android/AHardwareBufferUtils.cpp
@@ -0,0 +1,45 @@
+/*
+ * Copyright 2023 Google LLC
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "include/android/AHardwareBufferUtils.h"
+
+#if __ANDROID_API__ >= 26
+
+#include <android/hardware_buffer.h>
+
+namespace AHardwareBufferUtils {
+
+SkColorType GetSkColorTypeFromBufferFormat(uint32_t bufferFormat) {
+ switch (bufferFormat) {
+ case AHARDWAREBUFFER_FORMAT_R8G8B8A8_UNORM:
+ return kRGBA_8888_SkColorType;
+ case AHARDWAREBUFFER_FORMAT_R8G8B8X8_UNORM:
+ return kRGB_888x_SkColorType;
+ case AHARDWAREBUFFER_FORMAT_R16G16B16A16_FLOAT:
+ return kRGBA_F16_SkColorType;
+ case AHARDWAREBUFFER_FORMAT_R5G6B5_UNORM:
+ return kRGB_565_SkColorType;
+ case AHARDWAREBUFFER_FORMAT_R8G8B8_UNORM:
+ return kRGB_888x_SkColorType;
+ case AHARDWAREBUFFER_FORMAT_R10G10B10A2_UNORM:
+ return kRGBA_1010102_SkColorType;
+#if __ANDROID_API__ >= 33
+ case AHARDWAREBUFFER_FORMAT_R8_UNORM:
+ return kAlpha_8_SkColorType;
+#endif
+ default:
+ // Given that we only use this texture as a source, colorType will not impact how Skia
+ // uses the texture. The only potential affect this is anticipated to have is that for
+ // some format types if we are not bound as an OES texture we may get invalid results
+ // for SKP capture if we read back the texture.
+ return kRGBA_8888_SkColorType;
+ }
+}
+
+} // namespace AHardwareBufferUtils
+
+#endif
diff --git a/src/gpu/android/BUILD.bazel b/src/gpu/android/BUILD.bazel
new file mode 100644
index 0000000000..d1b7ec8b2f
--- /dev/null
+++ b/src/gpu/android/BUILD.bazel
@@ -0,0 +1,11 @@
+load("//bazel:skia_rules.bzl", "exports_files_legacy", "skia_filegroup")
+
+licenses(["notice"])
+
+exports_files_legacy()
+
+skia_filegroup(
+ name = "shared_android_srcs",
+ srcs = ["AHardwareBufferUtils.cpp"],
+ visibility = ["//src/gpu:__pkg__"],
+)
diff --git a/src/gpu/ganesh/GrAHardwareBufferImageGenerator.cpp b/src/gpu/ganesh/GrAHardwareBufferImageGenerator.cpp
index 2de02ee604..98f5c4ef30 100644
--- a/src/gpu/ganesh/GrAHardwareBufferImageGenerator.cpp
+++ b/src/gpu/ganesh/GrAHardwareBufferImageGenerator.cpp
@@ -11,6 +11,7 @@
#include "src/gpu/ganesh/GrAHardwareBufferImageGenerator.h"
+#include "include/android/AHardwareBufferUtils.h"
#include "include/android/GrAHardwareBufferUtils.h"
#include "include/core/SkColorSpace.h"
#include "include/gpu/GrBackendSurface.h"
@@ -38,7 +39,7 @@ std::unique_ptr<SkImageGenerator> GrAHardwareBufferImageGenerator::Make(
AHardwareBuffer_describe(graphicBuffer, &bufferDesc);
SkColorType colorType =
- GrAHardwareBufferUtils::GetSkColorTypeFromBufferFormat(bufferDesc.format);
+ AHardwareBufferUtils::GetSkColorTypeFromBufferFormat(bufferDesc.format);
SkImageInfo info = SkImageInfo::Make(bufferDesc.width, bufferDesc.height, colorType,
alphaType, std::move(colorSpace));
diff --git a/src/gpu/ganesh/GrAHardwareBufferUtils.cpp b/src/gpu/ganesh/GrAHardwareBufferUtils.cpp
index c7dffb750a..dc41e4688b 100644
--- a/src/gpu/ganesh/GrAHardwareBufferUtils.cpp
+++ b/src/gpu/ganesh/GrAHardwareBufferUtils.cpp
@@ -17,33 +17,14 @@
#include "include/gpu/GrDirectContext.h"
#endif
+// TODO: remove this once Android is using the AHardwareBufferUtils version of
+// GetSkColorTypeFromBufferFormat
+#include "include/android/AHardwareBufferUtils.h"
+
namespace GrAHardwareBufferUtils {
SkColorType GetSkColorTypeFromBufferFormat(uint32_t bufferFormat) {
- switch (bufferFormat) {
- case AHARDWAREBUFFER_FORMAT_R8G8B8A8_UNORM:
- return kRGBA_8888_SkColorType;
- case AHARDWAREBUFFER_FORMAT_R8G8B8X8_UNORM:
- return kRGB_888x_SkColorType;
- case AHARDWAREBUFFER_FORMAT_R16G16B16A16_FLOAT:
- return kRGBA_F16_SkColorType;
- case AHARDWAREBUFFER_FORMAT_R5G6B5_UNORM:
- return kRGB_565_SkColorType;
- case AHARDWAREBUFFER_FORMAT_R8G8B8_UNORM:
- return kRGB_888x_SkColorType;
- case AHARDWAREBUFFER_FORMAT_R10G10B10A2_UNORM:
- return kRGBA_1010102_SkColorType;
-#if __ANDROID_API__ >= 33
- case AHARDWAREBUFFER_FORMAT_R8_UNORM:
- return kAlpha_8_SkColorType;
-#endif
- default:
- // Given that we only use this texture as a source, colorType will not impact how Skia
- // uses the texture. The only potential affect this is anticipated to have is that for
- // some format types if we are not bound as an OES texture we may get invalid results
- // for SKP capture if we read back the texture.
- return kRGBA_8888_SkColorType;
- }
+ return AHardwareBufferUtils::GetSkColorTypeFromBufferFormat(bufferFormat);
}
#if !defined(SK_DISABLE_LEGACY_ANDROID_HW_UTILS)
diff --git a/src/gpu/ganesh/surface/SkSurface_AndroidFactories.cpp b/src/gpu/ganesh/surface/SkSurface_AndroidFactories.cpp
index b2a401e8eb..5a434afea6 100644
--- a/src/gpu/ganesh/surface/SkSurface_AndroidFactories.cpp
+++ b/src/gpu/ganesh/surface/SkSurface_AndroidFactories.cpp
@@ -9,6 +9,8 @@
#if defined(SK_BUILD_FOR_ANDROID) && __ANDROID_API__ >= 26
+#include "include/android/AHardwareBufferUtils.h"
+#include "include/android/GrAHardwareBufferUtils.h"
#include "include/android/SkSurfaceAndroid.h"
#include "include/core/SkCanvas.h"
#include "include/core/SkColorSpace.h"
@@ -35,7 +37,6 @@
#include "src/gpu/SkBackingFit.h"
#include "src/gpu/SkRenderEngineAbortf.h"
#include "src/gpu/ganesh/Device.h"
-#include "include/android/GrAHardwareBufferUtils.h"
#include "src/gpu/ganesh/GrCaps.h"
#include "src/gpu/ganesh/GrContextThreadSafeProxyPriv.h"
#include "src/gpu/ganesh/GrDirectContextPriv.h"
@@ -75,6 +76,9 @@ sk_sp<SkSurface> WrapAndroidHardwareBuffer(GrDirectContext* dContext,
}
bool isTextureable = SkToBool(bufferDesc.usage & AHARDWAREBUFFER_USAGE_GPU_SAMPLED_IMAGE);
+ if (!isTextureable) {
+ return nullptr;
+ }
GrBackendFormat backendFormat = GrAHardwareBufferUtils::GetBackendFormat(
dContext, hardwareBuffer, bufferDesc.format, true);
@@ -82,53 +86,49 @@ sk_sp<SkSurface> WrapAndroidHardwareBuffer(GrDirectContext* dContext,
return nullptr;
}
- if (isTextureable) {
- GrAHardwareBufferUtils::DeleteImageProc deleteImageProc = nullptr;
- GrAHardwareBufferUtils::UpdateImageProc updateImageProc = nullptr;
- GrAHardwareBufferUtils::TexImageCtx deleteImageCtx = nullptr;
+ GrAHardwareBufferUtils::DeleteImageProc deleteImageProc = nullptr;
+ GrAHardwareBufferUtils::UpdateImageProc updateImageProc = nullptr;
+ GrAHardwareBufferUtils::TexImageCtx deleteImageCtx = nullptr;
- bool isProtectedContent =
- SkToBool(bufferDesc.usage & AHARDWAREBUFFER_USAGE_PROTECTED_CONTENT);
+ bool isProtectedContent =
+ SkToBool(bufferDesc.usage & AHARDWAREBUFFER_USAGE_PROTECTED_CONTENT);
- bool fromWindowLocal = false;
+ bool fromWindowLocal = false;
#ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK
- fromWindowLocal = fromWindow;
+ fromWindowLocal = fromWindow;
#endif
- GrBackendTexture backendTexture =
- GrAHardwareBufferUtils::MakeBackendTexture(dContext,
- hardwareBuffer,
- bufferDesc.width,
- bufferDesc.height,
- &deleteImageProc,
- &updateImageProc,
- &deleteImageCtx,
- isProtectedContent,
- backendFormat,
- true,
- fromWindowLocal);
- if (!backendTexture.isValid()) {
- return nullptr;
- }
-
- SkColorType colorType =
- GrAHardwareBufferUtils::GetSkColorTypeFromBufferFormat(bufferDesc.format);
-
- // Will call deleteImageProc if SkSurface creation fails.
- sk_sp<SkSurface> surface = SkSurfaces::WrapBackendTexture(dContext,
- backendTexture,
- origin,
- 0,
- colorType,
- std::move(colorSpace),
- surfaceProps,
- deleteImageProc,
- deleteImageCtx);
-
- return surface;
- } else {
+ GrBackendTexture backendTexture =
+ GrAHardwareBufferUtils::MakeBackendTexture(dContext,
+ hardwareBuffer,
+ bufferDesc.width,
+ bufferDesc.height,
+ &deleteImageProc,
+ &updateImageProc,
+ &deleteImageCtx,
+ isProtectedContent,
+ backendFormat,
+ true,
+ fromWindowLocal);
+ if (!backendTexture.isValid()) {
return nullptr;
}
+
+ SkColorType colorType =
+ AHardwareBufferUtils::GetSkColorTypeFromBufferFormat(bufferDesc.format);
+
+ // Will call deleteImageProc if SkSurface creation fails.
+ sk_sp<SkSurface> surface = SkSurfaces::WrapBackendTexture(dContext,
+ backendTexture,
+ origin,
+ 0,
+ colorType,
+ std::move(colorSpace),
+ surfaceProps,
+ deleteImageProc,
+ deleteImageCtx);
+
+ return surface;
}
} // namespace SkSurfaces
diff --git a/src/image/SkImage_AndroidFactories.cpp b/src/image/SkImage_AndroidFactories.cpp
index a595c96dbe..4c8df1526f 100644
--- a/src/image/SkImage_AndroidFactories.cpp
+++ b/src/image/SkImage_AndroidFactories.cpp
@@ -11,6 +11,7 @@
#include "include/android/SkImageAndroid.h"
+#include "include/android/AHardwareBufferUtils.h"
#include "include/android/GrAHardwareBufferUtils.h"
#include "include/core/SkAlphaType.h"
#include "include/core/SkBitmap.h"
@@ -127,7 +128,7 @@ sk_sp<SkImage> TextureFromAHardwareBufferWithData(GrDirectContext* dContext,
auto releaseHelper = skgpu::RefCntedCallback::Make(deleteImageProc, deleteImageCtx);
SkColorType colorType =
- GrAHardwareBufferUtils::GetSkColorTypeFromBufferFormat(bufferDesc.format);
+ AHardwareBufferUtils::GetSkColorTypeFromBufferFormat(bufferDesc.format);
GrColorType grColorType = SkColorTypeToGrColorType(colorType);
diff --git a/tests/MultiPictureDocumentTest.cpp b/tests/MultiPictureDocumentTest.cpp
index 6cbead0290..e4bce003fa 100644
--- a/tests/MultiPictureDocumentTest.cpp
+++ b/tests/MultiPictureDocumentTest.cpp
@@ -183,6 +183,7 @@ DEF_TEST(SkMultiPictureDocument_Serialize_and_deserialize, reporter) {
#if defined(SK_GANESH) && defined(SK_BUILD_FOR_ANDROID) && __ANDROID_API__ >= 26
+#include "include/android/AHardwareBufferUtils.h"
#include "include/android/GrAHardwareBufferUtils.h"
#include "include/core/SkBitmap.h"
#include "include/core/SkColorSpace.h"
@@ -310,7 +311,7 @@ static sk_sp<SkImage> makeAHardwareBufferTestImage(
backendFormat,
false // isRenderable
);
- SkColorType colorType = GrAHardwareBufferUtils::GetSkColorTypeFromBufferFormat(hwbDesc.format);
+ SkColorType colorType = AHardwareBufferUtils::GetSkColorTypeFromBufferFormat(hwbDesc.format);
sk_sp<SkImage> image = SkImages::BorrowTextureFrom(context,
texture,
kTopLeft_GrSurfaceOrigin,