Commit b0284247 authored by Bo Liu's avatar Bo Liu Committed by Commit Bot

aw: Fix SkiaRenderer with GL

--enable-feature=UseSkiaRenderer no longer crashes on webview.

Also make sure SkiaRenderer will end up calling ConsumerTexture
if ProduceSkia fails.

Change-Id: I16416b80a10102330f8de0474236d8040abe2e94
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1787588
Commit-Queue: Bo <boliu@chromium.org>
Reviewed-by: default avatarPeng Huang <penghuang@chromium.org>
Auto-Submit: Bo <boliu@chromium.org>
Cr-Commit-Position: refs/heads/master@{#694597}
parent 8e1511bd
......@@ -124,6 +124,13 @@ SurfacesInstance::SurfacesInstance()
share_group_, gl_surface_, std::move(gl_context),
false /* use_virtualized_gl_contexts */,
base::BindOnce(&OnContextLost), vulkan_context_provider.get());
if (!enable_vulkan) {
auto feature_info = base::MakeRefCounted<gpu::gles2::FeatureInfo>(
workarounds, GpuServiceWebView::GetInstance()->gpu_feature_info());
shared_context_state_->InitializeGL(
GpuServiceWebView::GetInstance()->gpu_preferences(),
std::move(feature_info));
}
shared_context_state_->InitializeGrContext(workarounds,
nullptr /* gr_shader_cache */);
}
......
......@@ -779,10 +779,7 @@ public class AwContentsTest {
Assert.assertEquals(0, consoleHelper.getMessages().size());
}
@Test
@Feature({"AndroidWebView"})
@SmallTest
public void testHardwareRenderingSmokeTest() throws Throwable {
private void doHardwareRenderingSmokeTest() throws Throwable {
AwTestContainerView testView =
mActivityTestRule.createAwTestContainerViewOnMainSync(mContentsClient);
final AwContents awContents = testView.getAwContents();
......@@ -841,6 +838,21 @@ public class AwContentsTest {
Assert.assertEquals(Color.rgb(128, 128, 128), quadrantColors[3]);
}
@Test
@Feature({"AndroidWebView"})
@SmallTest
public void testHardwareRenderingSmokeTest() throws Throwable {
doHardwareRenderingSmokeTest();
}
@Test
@Feature({"AndroidWebView"})
@SmallTest
@CommandLineFlags.Add({"enable-features=UseSkiaRenderer", "disable-oop-rasterization"})
public void testHardwareRenderingSmokeTestSkiaRenderer() throws Throwable {
doHardwareRenderingSmokeTest();
}
@Test
@Feature({"AndroidWebView"})
@SmallTest
......
......@@ -71,60 +71,10 @@ void ImageContextImpl::BeginAccessIfNecessary(
std::vector<GrBackendSemaphore>* begin_semaphores,
std::vector<GrBackendSemaphore>* end_semaphores) {
// Prepare for accessing shared image.
if (mailbox_holder().mailbox.IsSharedImage()) {
// Skip the context if it has been processed.
if (representation_scoped_read_access_) {
DCHECK(!owned_promise_image_texture_);
DCHECK(promise_image_texture_);
return;
}
// promise_image_texture_ is not null here, it means we are using a fallback
// image.
if (promise_image_texture_) {
DCHECK(owned_promise_image_texture_);
return;
}
if (!representation_) {
auto representation = representation_factory->ProduceSkia(
mailbox_holder().mailbox, context_state);
if (!representation) {
DLOG(ERROR) << "Failed to fulfill the promise texture - SharedImage "
"mailbox not found in SharedImageManager.";
CreateFallbackImage(context_state);
return;
}
if (!(representation->usage() & gpu::SHARED_IMAGE_USAGE_DISPLAY)) {
DLOG(ERROR) << "Failed to fulfill the promise texture - SharedImage "
"was not created with display usage.";
CreateFallbackImage(context_state);
return;
}
if (representation->size() != size()) {
DLOG(ERROR) << "Failed to fulfill the promise texture - SharedImage "
"size does not match TransferableResource size.";
CreateFallbackImage(context_state);
return;
}
representation_ = std::move(representation);
}
representation_scoped_read_access_.emplace(
representation_.get(), begin_semaphores, end_semaphores);
if (!representation_scoped_read_access_->success()) {
representation_scoped_read_access_.reset();
representation_ = nullptr;
DLOG(ERROR) << "Failed to fulfill the promise texture - SharedImage "
"begin read access failed..";
CreateFallbackImage(context_state);
return;
}
promise_image_texture_ =
representation_scoped_read_access_->promise_image_texture();
if (mailbox_holder().mailbox.IsSharedImage() &&
BeginAccessIfNecessaryForSharedImage(context_state,
representation_factory,
begin_semaphores, end_semaphores)) {
return;
}
......@@ -171,6 +121,63 @@ void ImageContextImpl::BeginAccessIfNecessary(
set_promise_image_texture(SkPromiseImageTexture::Make(backend_texture));
}
bool ImageContextImpl::BeginAccessIfNecessaryForSharedImage(
gpu::SharedContextState* context_state,
gpu::SharedImageRepresentationFactory* representation_factory,
std::vector<GrBackendSemaphore>* begin_semaphores,
std::vector<GrBackendSemaphore>* end_semaphores) {
// Skip the context if it has been processed.
if (representation_scoped_read_access_) {
DCHECK(!owned_promise_image_texture_);
DCHECK(promise_image_texture_);
return true;
}
// promise_image_texture_ is not null here, it means we are using a fallback
// image.
if (promise_image_texture_) {
DCHECK(owned_promise_image_texture_);
return true;
}
if (!representation_) {
auto representation = representation_factory->ProduceSkia(
mailbox_holder().mailbox, context_state);
if (!representation) {
DLOG(ERROR) << "Failed to fulfill the promise texture - SharedImage "
"mailbox not found in SharedImageManager.";
return false;
}
if (!(representation->usage() & gpu::SHARED_IMAGE_USAGE_DISPLAY)) {
DLOG(ERROR) << "Failed to fulfill the promise texture - SharedImage "
"was not created with display usage.";
return false;
}
if (representation->size() != size()) {
DLOG(ERROR) << "Failed to fulfill the promise texture - SharedImage "
"size does not match TransferableResource size.";
return false;
}
representation_ = std::move(representation);
}
representation_scoped_read_access_.emplace(representation_.get(),
begin_semaphores, end_semaphores);
if (!representation_scoped_read_access_->success()) {
representation_scoped_read_access_.reset();
representation_ = nullptr;
DLOG(ERROR) << "Failed to fulfill the promise texture - SharedImage "
"begin read access failed..";
return false;
}
promise_image_texture_ =
representation_scoped_read_access_->promise_image_texture();
return true;
}
bool ImageContextImpl::BindOrCopyTextureIfNecessary(
gpu::TextureBase* texture_base,
gfx::Size* size) {
......
......@@ -79,6 +79,11 @@ class ImageContextImpl final : public ExternalUseClient::ImageContext {
private:
void CreateFallbackImage(gpu::SharedContextState* context_state);
bool BeginAccessIfNecessaryForSharedImage(
gpu::SharedContextState* context_state,
gpu::SharedImageRepresentationFactory* representation_factory,
std::vector<GrBackendSemaphore>* begin_semaphores,
std::vector<GrBackendSemaphore>* end_semaphores);
// Returns true if |texture_base| is a gles2::Texture and all necessary
// operations completed successfully. In this case, |*size| is the size of
......
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