Commit 3ba78f0f authored by Peng Huang's avatar Peng Huang Committed by Commit Bot

SkiaRenderer: fix low end device mode related crash

In low end device mode, the GLContext is created to be compatible to
GLSurfaces with RGB565 format. Right now,
SkiaOutputSurfaceDependencyImpl::CreateGLSurface() creates GLSurface
with default format which is RGBA8888. It isn't compatible to the
GLContext. It causes MakeCurrent fail.

Bug: 1033170
Change-Id: Id372e0dee73a01b8e7511bbef6740481b890d742
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2016338Reviewed-by: default avatarkylechar <kylechar@chromium.org>
Reviewed-by: default avatarBo <boliu@chromium.org>
Commit-Queue: Bo <boliu@chromium.org>
Auto-Submit: Peng Huang <penghuang@chromium.org>
Cr-Commit-Position: refs/heads/master@{#735410}
parent d3a81113
......@@ -113,7 +113,8 @@ gpu::SurfaceHandle SkiaOutputSurfaceDependencyWebView::GetSurfaceHandle() {
scoped_refptr<gl::GLSurface>
SkiaOutputSurfaceDependencyWebView::CreateGLSurface(
base::WeakPtr<gpu::ImageTransportSurfaceDelegate> stub) {
base::WeakPtr<gpu::ImageTransportSurfaceDelegate> stub,
gl::GLSurfaceFormat format) {
return gl_surface_;
}
......
......@@ -44,7 +44,8 @@ class SkiaOutputSurfaceDependencyWebView
bool IsOffscreen() override;
gpu::SurfaceHandle GetSurfaceHandle() override;
scoped_refptr<gl::GLSurface> CreateGLSurface(
base::WeakPtr<gpu::ImageTransportSurfaceDelegate> stub) override;
base::WeakPtr<gpu::ImageTransportSurfaceDelegate> stub,
gl::GLSurfaceFormat format) override;
base::ScopedClosureRunner CacheGLSurface(gl::GLSurface* surface) override;
void RegisterDisplayContext(gpu::DisplayContext* display_context) override;
void UnregisterDisplayContext(gpu::DisplayContext* display_context) override;
......
......@@ -82,6 +82,7 @@ void ImageContextImpl::CreateFallbackImage(
GrMipMapped::kNo, GrRenderable::kYes);
if (!fallback_texture_.isValid()) {
fallback_context_state_ = nullptr;
DLOG(ERROR) << "Could not create backend texture.";
return;
}
......
......@@ -16,6 +16,7 @@
#include "gpu/command_buffer/common/constants.h"
#include "gpu/command_buffer/service/sequence_id.h"
#include "gpu/ipc/common/surface_handle.h"
#include "ui/gl/gl_surface_format.h"
class GURL;
......@@ -86,7 +87,8 @@ class VIZ_SERVICE_EXPORT SkiaOutputSurfaceDependency {
virtual bool IsOffscreen() = 0;
virtual gpu::SurfaceHandle GetSurfaceHandle() = 0;
virtual scoped_refptr<gl::GLSurface> CreateGLSurface(
base::WeakPtr<gpu::ImageTransportSurfaceDelegate> stub) = 0;
base::WeakPtr<gpu::ImageTransportSurfaceDelegate> stub,
gl::GLSurfaceFormat format) = 0;
// Hold a ref of the given surface until the returned closure is fired.
virtual base::ScopedClosureRunner CacheGLSurface(gl::GLSurface* surface) = 0;
virtual void PostTaskToClientThread(base::OnceClosure closure) = 0;
......
......@@ -97,12 +97,13 @@ gpu::SurfaceHandle SkiaOutputSurfaceDependencyImpl::GetSurfaceHandle() {
}
scoped_refptr<gl::GLSurface> SkiaOutputSurfaceDependencyImpl::CreateGLSurface(
base::WeakPtr<gpu::ImageTransportSurfaceDelegate> stub) {
base::WeakPtr<gpu::ImageTransportSurfaceDelegate> stub,
gl::GLSurfaceFormat format) {
if (IsOffscreen()) {
return gl::init::CreateOffscreenGLSurface(gfx::Size());
return gl::init::CreateOffscreenGLSurfaceWithFormat(gfx::Size(), format);
} else {
return gpu::ImageTransportSurface::CreateNativeSurface(
stub, surface_handle_, gl::GLSurfaceFormat());
stub, surface_handle_, format);
}
}
......
......@@ -41,7 +41,8 @@ class VIZ_SERVICE_EXPORT SkiaOutputSurfaceDependencyImpl
bool IsOffscreen() override;
gpu::SurfaceHandle GetSurfaceHandle() override;
scoped_refptr<gl::GLSurface> CreateGLSurface(
base::WeakPtr<gpu::ImageTransportSurfaceDelegate> stub) override;
base::WeakPtr<gpu::ImageTransportSurfaceDelegate> stub,
gl::GLSurfaceFormat format) override;
base::ScopedClosureRunner CacheGLSurface(gl::GLSurface* surface) override;
void PostTaskToClientThread(base::OnceClosure closure) override;
void ScheduleGrContextCleanup() override;
......
......@@ -20,6 +20,7 @@
#include "components/viz/common/frame_sinks/copy_output_util.h"
#include "components/viz/common/resources/resource_format_utils.h"
#include "components/viz/common/skia_helper.h"
#include "components/viz/common/viz_utils.h"
#include "components/viz/service/display/dc_layer_overlay.h"
#include "components/viz/service/display/gl_renderer_copier.h"
#include "components/viz/service/display/output_surface_frame.h"
......@@ -1450,8 +1451,14 @@ bool SkiaOutputSurfaceImplOnGpu::InitializeForGL() {
api_ = current_gl->Api;
gl_version_info_ = context->GetVersionInfo();
gl::GLSurfaceFormat format;
if (PreferRGB565ResourcesForDisplay() &&
!renderer_settings_.requires_alpha_channel) {
format.SetRGB565();
}
if (dependency_->IsOffscreen()) {
gl_surface_ = dependency_->CreateGLSurface(nullptr);
gl_surface_ = dependency_->CreateGLSurface(nullptr, format);
if (!gl_surface_)
return false;
......@@ -1461,7 +1468,8 @@ bool SkiaOutputSurfaceImplOnGpu::InitializeForGL() {
did_swap_buffer_complete_callback_);
supports_alpha_ = renderer_settings_.requires_alpha_channel;
} else {
gl_surface_ = dependency_->CreateGLSurface(weak_ptr_factory_.GetWeakPtr());
gl_surface_ =
dependency_->CreateGLSurface(weak_ptr_factory_.GetWeakPtr(), format);
if (!gl_surface_)
return false;
......
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