Commit 0d62cddf authored by Vikas Soni's avatar Vikas Soni Committed by Commit Bot

Reland "Vulkan backed skia representation of SharedImageBackingAHB."

This is a reland of 8dc8014f
with a BUILD file fix.

Original change's description:
> Vulkan backed skia representation of SharedImageBackingAHB.
>
> 1. Implemented Vulkan backed skia representation of
> SharedImageBackingAHB.
> 2. Added synchronisation between gl backed and Vk backed
> representations.
>
> Bug: 891060
> Change-Id: I46ba32dea62569cd67d6f3b24559f4ef28307168
> Reviewed-on: https://chromium-review.googlesource.com/c/1370471
> Reviewed-by: Eric Karl <ericrk@chromium.org>
> Commit-Queue: vikas soni <vikassoni@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#618320}

Bug: 891060
Change-Id: Ic8dc4572a27b8c40a6fcf7a021c3e2225e155691
Reviewed-on: https://chromium-review.googlesource.com/c/1388559
Commit-Queue: vikas soni <vikassoni@chromium.org>
Reviewed-by: default avatarEric Karl <ericrk@chromium.org>
Cr-Commit-Position: refs/heads/master@{#618771}
parent 143100ae
......@@ -414,7 +414,7 @@ void SkiaOutputSurfaceImplOnGpu::FulfillPromiseTexture(
shared_image_representation_factory_->ProduceSkia(
metadata.mailbox_holder.mailbox);
DCHECK(shared_image);
if (!shared_image->BeginReadAccess(backend_texture)) {
if (!shared_image->BeginReadAccess(sk_surface_.get(), backend_texture)) {
DLOG(ERROR)
<< "Failed to begin read access for SharedImageRepresentationSkia";
return;
......
......@@ -4,8 +4,8 @@
import("//build/config/jumbo.gni")
import("//build/config/ui.gni")
import("//third_party/protobuf/proto_library.gni")
import("//gpu/vulkan/features.gni")
import("//third_party/protobuf/proto_library.gni")
group("service") {
if (is_component_build) {
......@@ -258,15 +258,6 @@ target(link_target_type, "gles2_sources") {
"wrapped_sk_image.h",
]
if (is_android) {
sources += [
"ahardwarebuffer_utils.cc",
"ahardwarebuffer_utils.h",
"shared_image_backing_factory_ahardwarebuffer.cc",
"shared_image_backing_factory_ahardwarebuffer.h",
]
}
configs += [
"//build/config:precompiled_headers",
"//gpu:gpu_gles2_implementation",
......@@ -322,11 +313,32 @@ target(link_target_type, "gles2_sources") {
]
}
if (is_android && !is_debug) {
if (is_android) {
if (!is_debug) {
# On Android optimize more since this component can be a bottleneck.
configs -= [ "//build/config/compiler:default_optimization" ]
configs += [ "//build/config/compiler:optimize_max" ]
}
sources += [
"ahardwarebuffer_utils.cc",
"ahardwarebuffer_utils.h",
"shared_image_backing_factory_ahardwarebuffer.cc",
"shared_image_backing_factory_ahardwarebuffer.h",
]
# TODO(cblume): http://crbug.com/911313
# Abstract out the platform specific defines. Right now we need the android
# platform specific define here to be able to include android specific
# functions.
defines = [ "VK_USE_PLATFORM_ANDROID_KHR" ]
deps += [ "//third_party/libsync" ]
if (enable_vulkan) {
deps += [
"//gpu/ipc/common:android_image_reader_utils",
"//gpu/vulkan:vulkan",
]
}
}
}
proto_library("disk_cache_proto") {
......
......@@ -22,13 +22,19 @@ class GpuDriverBugWorkarounds;
struct GpuFeatureInfo;
struct Mailbox;
namespace raster {
struct RasterDecoderContextState;
} // namespace raster
// Implementation of SharedImageBackingFactory that produces AHardwareBuffer
// backed SharedImages. This is meant to be used on Android only.
class GPU_GLES2_EXPORT SharedImageBackingFactoryAHB
: public SharedImageBackingFactory {
public:
SharedImageBackingFactoryAHB(const GpuDriverBugWorkarounds& workarounds,
const GpuFeatureInfo& gpu_feature_info);
SharedImageBackingFactoryAHB(
const GpuDriverBugWorkarounds& workarounds,
const GpuFeatureInfo& gpu_feature_info,
raster::RasterDecoderContextState* context_state);
~SharedImageBackingFactoryAHB() override;
// SharedImageBackingFactory implementation.
......@@ -77,6 +83,7 @@ class GPU_GLES2_EXPORT SharedImageBackingFactoryAHB
// Used to limit the max size of AHardwareBuffer.
int32_t max_gl_texture_size_ = 0;
raster::RasterDecoderContextState* context_state_ = nullptr;
DISALLOW_COPY_AND_ASSIGN(SharedImageBackingFactoryAHB);
};
......
......@@ -49,8 +49,6 @@ class SharedImageBackingFactoryAHBTest : public testing::Test {
GpuDriverBugWorkarounds workarounds;
workarounds.max_texture_size = INT_MAX - 1;
backing_factory_ = std::make_unique<SharedImageBackingFactoryAHB>(
workarounds, GpuFeatureInfo());
scoped_refptr<gl::GLShareGroup> share_group = new gl::GLShareGroup();
context_state_ = new raster::RasterDecoderContextState(
......@@ -61,6 +59,9 @@ class SharedImageBackingFactoryAHBTest : public testing::Test {
base::MakeRefCounted<gles2::FeatureInfo>(workarounds, GpuFeatureInfo());
context_state_->InitializeGL(std::move(feature_info));
backing_factory_ = std::make_unique<SharedImageBackingFactoryAHB>(
workarounds, GpuFeatureInfo(), context_state_.get());
memory_type_tracker_ = std::make_unique<MemoryTypeTracker>(nullptr);
shared_image_representation_factory_ =
std::make_unique<SharedImageRepresentationFactory>(
......@@ -149,7 +150,7 @@ TEST_F(SharedImageBackingFactoryAHBTest, Basic) {
EXPECT_EQ(size.height(), surface->height());
skia_representation->EndWriteAccess(std::move(surface));
GrBackendTexture backend_texture;
EXPECT_TRUE(skia_representation->BeginReadAccess(&backend_texture));
EXPECT_TRUE(skia_representation->BeginReadAccess(nullptr, &backend_texture));
EXPECT_EQ(size.width(), backend_texture.width());
EXPECT_EQ(size.width(), backend_texture.width());
skia_representation->EndReadAccess();
......@@ -209,7 +210,7 @@ TEST_F(SharedImageBackingFactoryAHBTest, GLSkiaGL) {
shared_image_representation_factory_->ProduceSkia(mailbox);
EXPECT_TRUE(skia_representation);
GrBackendTexture backend_texture;
EXPECT_TRUE(skia_representation->BeginReadAccess(&backend_texture));
EXPECT_TRUE(skia_representation->BeginReadAccess(nullptr, &backend_texture));
EXPECT_EQ(size.width(), backend_texture.width());
EXPECT_EQ(size.width(), backend_texture.width());
......
......@@ -269,7 +269,8 @@ class SharedImageRepresentationSkiaImpl : public SharedImageRepresentationSkia {
write_surface_ = nullptr;
}
bool BeginReadAccess(GrBackendTexture* backend_texture) override {
bool BeginReadAccess(SkSurface* sk_surface,
GrBackendTexture* backend_texture) override {
if (!GetGrBackendTexture(gl::GLContext::GetCurrent()->GetVersionInfo(),
target_, size(), service_id_, format(),
backend_texture)) {
......
......@@ -186,7 +186,7 @@ TEST_P(SharedImageBackingFactoryGLTextureTest, Basic) {
EXPECT_EQ(size.height(), surface->height());
skia_representation->EndWriteAccess(std::move(surface));
GrBackendTexture backend_texture;
EXPECT_TRUE(skia_representation->BeginReadAccess(&backend_texture));
EXPECT_TRUE(skia_representation->BeginReadAccess(nullptr, &backend_texture));
EXPECT_EQ(size.width(), backend_texture.width());
EXPECT_EQ(size.width(), backend_texture.width());
skia_representation->EndReadAccess();
......@@ -270,7 +270,7 @@ TEST_P(SharedImageBackingFactoryGLTextureTest, Image) {
EXPECT_EQ(size.height(), surface->height());
skia_representation->EndWriteAccess(std::move(surface));
GrBackendTexture backend_texture;
EXPECT_TRUE(skia_representation->BeginReadAccess(&backend_texture));
EXPECT_TRUE(skia_representation->BeginReadAccess(nullptr, &backend_texture));
EXPECT_EQ(size.width(), backend_texture.width());
EXPECT_EQ(size.width(), backend_texture.width());
skia_representation->EndReadAccess();
......
......@@ -112,7 +112,8 @@ class SharedImageRepresentationSkia : public SharedImageRepresentation {
int final_msaa_count,
const SkSurfaceProps& surface_props) = 0;
virtual void EndWriteAccess(sk_sp<SkSurface> surface) = 0;
virtual bool BeginReadAccess(GrBackendTexture* backend_texture_out) = 0;
virtual bool BeginReadAccess(SkSurface* sk_surface,
GrBackendTexture* backend_texture_out) = 0;
virtual void EndReadAccess() = 0;
};
......
......@@ -205,7 +205,8 @@ class WrappedSkImageRepresentation : public SharedImageRepresentationSkia {
write_surface_ = nullptr;
}
bool BeginReadAccess(GrBackendTexture* backend_texture) override {
bool BeginReadAccess(SkSurface* sk_surface,
GrBackendTexture* backend_texture) override {
if (!wrapped_sk_image()->GetGrBackendTexture(backend_texture))
return false;
return true;
......
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