Commit 9380a440 authored by Peng Huang's avatar Peng Huang Committed by Commit Bot

Revert "SkiaOutputDevice: use buffer format passed to Reshape"

This reverts commit a37811d1.

Reason for revert: 
https://chromium-swarm.appspot.com/task?id=4e4ecbbb4657b710#ScreenshotSync_GPURasterWithDivs,ScreenshotSync_SWRasterWithDivs

Original change's description:
> SkiaOutputDevice: use buffer format passed to Reshape
> 
> Bug: 1108406
> Change-Id: Iaca79e3b6c1d66e421711c46f75a1cb614b7f961
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2378745
> Reviewed-by: Vasiliy Telezhnikov <vasilyt@chromium.org>
> Commit-Queue: Peng Huang <penghuang@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#802450}

TBR=penghuang@chromium.org,vasilyt@chromium.org

Change-Id: Idd1c5aaca95ede1e052e72fd19e8b590ed21c79a
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: 1108406
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2382056Reviewed-by: default avatarPeng Huang <penghuang@chromium.org>
Commit-Queue: Peng Huang <penghuang@chromium.org>
Cr-Commit-Position: refs/heads/master@{#802699}
parent 60a75b7b
...@@ -117,9 +117,13 @@ class VIZ_SERVICE_EXPORT OutputSurface { ...@@ -117,9 +117,13 @@ class VIZ_SERVICE_EXPORT OutputSurface {
// enforced if zero. // enforced if zero.
int max_render_target_size = 0; int max_render_target_size = 0;
// SkColorType for all supported buffer formats. // The SkColorType and GrBackendFormat for non-HDR and HDR.
SkColorType sk_color_types[static_cast<int>(gfx::BufferFormat::LAST) + 1] = // TODO(penghuang): remove SkColorType and GrBackendFormat when
{}; // OutputSurface uses the |format| passed to Reshape().
SkColorType sk_color_type = kUnknown_SkColorType;
GrBackendFormat gr_backend_format;
SkColorType sk_color_type_for_hdr = kUnknown_SkColorType;
GrBackendFormat gr_backend_format_for_hdr;
}; };
// Constructor for skia-based compositing. // Constructor for skia-based compositing.
......
...@@ -188,10 +188,10 @@ void OutputPresenterFuchsia::InitializeCapabilities( ...@@ -188,10 +188,10 @@ void OutputPresenterFuchsia::InitializeCapabilities(
capabilities->supports_post_sub_buffer = false; capabilities->supports_post_sub_buffer = false;
capabilities->supports_commit_overlay_planes = false; capabilities->supports_commit_overlay_planes = false;
capabilities->sk_color_types[static_cast<int>(gfx::BufferFormat::RGBA_8888)] = capabilities->sk_color_type = kRGBA_8888_SkColorType;
kRGBA_8888_SkColorType; capabilities->gr_backend_format =
capabilities->sk_color_types[static_cast<int>(gfx::BufferFormat::BGRA_8888)] = dependency_->GetSharedContextState()->gr_context()->defaultBackendFormat(
kRGBA_8888_SkColorType; capabilities->sk_color_type, GrRenderable::kYes);
} }
bool OutputPresenterFuchsia::Reshape(const gfx::Size& size, bool OutputPresenterFuchsia::Reshape(const gfx::Size& size,
......
...@@ -214,6 +214,23 @@ OutputPresenterGL::OutputPresenterGL(scoped_refptr<gl::GLSurface> gl_surface, ...@@ -214,6 +214,23 @@ OutputPresenterGL::OutputPresenterGL(scoped_refptr<gl::GLSurface> gl_surface,
// GL is origin is at bottom left normally, all Surfaceless implementations // GL is origin is at bottom left normally, all Surfaceless implementations
// are flipped. // are flipped.
DCHECK_EQ(gl_surface_->GetOrigin(), gfx::SurfaceOrigin::kTopLeft); DCHECK_EQ(gl_surface_->GetOrigin(), gfx::SurfaceOrigin::kTopLeft);
// TODO(https://crbug.com/958166): The initial |image_format_| should not be
// used, and the gfx::BufferFormat specified in Reshape should be used
// instead, because it may be updated to reflect changes in the content being
// displayed (e.g, HDR content appearing on-screen).
#if defined(OS_APPLE)
image_format_ = BGRA_8888;
#else
#if defined(USE_OZONE)
if (features::IsUsingOzonePlatform()) {
image_format_ =
GetResourceFormat(display::DisplaySnapshot::PrimaryFormat());
return;
}
#endif
image_format_ = RGBA_8888;
#endif
} }
OutputPresenterGL::~OutputPresenterGL() = default; OutputPresenterGL::~OutputPresenterGL() = default;
...@@ -230,28 +247,13 @@ void OutputPresenterGL::InitializeCapabilities( ...@@ -230,28 +247,13 @@ void OutputPresenterGL::InitializeCapabilities(
// We expect origin of buffers is at top left. // We expect origin of buffers is at top left.
capabilities->output_surface_origin = gfx::SurfaceOrigin::kTopLeft; capabilities->output_surface_origin = gfx::SurfaceOrigin::kTopLeft;
// TODO(https://crbug.com/1108406): only add supported formats base on // TODO(penghuang): Use defaultBackendFormat() in shared image implementation
// platform, driver, etc. // to make sure backend format is consistent.
capabilities->sk_color_types[static_cast<int>(gfx::BufferFormat::BGR_565)] = capabilities->sk_color_type = ResourceFormatToClosestSkColorType(
kRGB_565_SkColorType; true /* gpu_compositing */, image_format_);
capabilities->sk_color_types[static_cast<int>(gfx::BufferFormat::RGBA_4444)] = capabilities->gr_backend_format =
kARGB_4444_SkColorType; dependency_->GetSharedContextState()->gr_context()->defaultBackendFormat(
capabilities->sk_color_types[static_cast<int>(gfx::BufferFormat::RGBX_8888)] = capabilities->sk_color_type, GrRenderable::kYes);
kRGB_888x_SkColorType;
capabilities->sk_color_types[static_cast<int>(gfx::BufferFormat::RGBA_8888)] =
kRGBA_8888_SkColorType;
capabilities->sk_color_types[static_cast<int>(gfx::BufferFormat::BGRX_8888)] =
kBGRA_8888_SkColorType;
capabilities->sk_color_types[static_cast<int>(gfx::BufferFormat::BGRA_8888)] =
kBGRA_8888_SkColorType;
capabilities
->sk_color_types[static_cast<int>(gfx::BufferFormat::BGRA_1010102)] =
kBGRA_1010102_SkColorType;
capabilities
->sk_color_types[static_cast<int>(gfx::BufferFormat::RGBA_1010102)] =
kRGBA_1010102_SkColorType;
capabilities->sk_color_types[static_cast<int>(gfx::BufferFormat::RGBA_F16)] =
kRGBA_F16_SkColorType;
} }
bool OutputPresenterGL::Reshape(const gfx::Size& size, bool OutputPresenterGL::Reshape(const gfx::Size& size,
...@@ -259,7 +261,6 @@ bool OutputPresenterGL::Reshape(const gfx::Size& size, ...@@ -259,7 +261,6 @@ bool OutputPresenterGL::Reshape(const gfx::Size& size,
const gfx::ColorSpace& color_space, const gfx::ColorSpace& color_space,
gfx::BufferFormat format, gfx::BufferFormat format,
gfx::OverlayTransform transform) { gfx::OverlayTransform transform) {
image_format_ = GetResourceFormat(format);
return gl_surface_->Resize(size, device_scale_factor, color_space, return gl_surface_->Resize(size, device_scale_factor, color_space,
gfx::AlphaBitsForBufferFormat(format)); gfx::AlphaBitsForBufferFormat(format));
} }
......
...@@ -65,7 +65,7 @@ class VIZ_SERVICE_EXPORT OutputPresenterGL : public OutputPresenter { ...@@ -65,7 +65,7 @@ class VIZ_SERVICE_EXPORT OutputPresenterGL : public OutputPresenter {
SkiaOutputSurfaceDependency* dependency_; SkiaOutputSurfaceDependency* dependency_;
const bool supports_async_swap_; const bool supports_async_swap_;
ResourceFormat image_format_ = RGBA_8888; ResourceFormat image_format_;
// Shared Image factories // Shared Image factories
gpu::SharedImageFactory shared_image_factory_; gpu::SharedImageFactory shared_image_factory_;
......
...@@ -120,12 +120,6 @@ void SkiaOutputDevice::ScheduleOverlays( ...@@ -120,12 +120,6 @@ void SkiaOutputDevice::ScheduleOverlays(
void SkiaOutputDevice::EnsureBackbuffer() {} void SkiaOutputDevice::EnsureBackbuffer() {}
void SkiaOutputDevice::DiscardBackbuffer() {} void SkiaOutputDevice::DiscardBackbuffer() {}
void SkiaOutputDevice::SetDrawTimings(base::TimeTicks submitted,
base::TimeTicks started) {
viz_scheduled_draw_ = submitted;
gpu_started_draw_ = started;
}
void SkiaOutputDevice::StartSwapBuffers(BufferPresentedCallback feedback) { void SkiaOutputDevice::StartSwapBuffers(BufferPresentedCallback feedback) {
DCHECK_LT(static_cast<int>(pending_swaps_.size()), DCHECK_LT(static_cast<int>(pending_swaps_.size()),
capabilities_.max_frames_pending); capabilities_.max_frames_pending);
...@@ -164,6 +158,12 @@ void SkiaOutputDevice::FinishSwapBuffers( ...@@ -164,6 +158,12 @@ void SkiaOutputDevice::FinishSwapBuffers(
pending_swaps_.pop(); pending_swaps_.pop();
} }
void SkiaOutputDevice::SetDrawTimings(base::TimeTicks submitted,
base::TimeTicks started) {
viz_scheduled_draw_ = submitted;
gpu_started_draw_ = started;
}
SkiaOutputDevice::SwapInfo::SwapInfo( SkiaOutputDevice::SwapInfo::SwapInfo(
uint64_t swap_id, uint64_t swap_id,
SkiaOutputDevice::BufferPresentedCallback feedback, SkiaOutputDevice::BufferPresentedCallback feedback,
......
...@@ -44,10 +44,11 @@ SkiaOutputDeviceDawn::SkiaOutputDeviceDawn( ...@@ -44,10 +44,11 @@ SkiaOutputDeviceDawn::SkiaOutputDeviceDawn(
capabilities_.uses_default_gl_framebuffer = false; capabilities_.uses_default_gl_framebuffer = false;
capabilities_.supports_post_sub_buffer = false; capabilities_.supports_post_sub_buffer = false;
capabilities_.sk_color_types[static_cast<int>(gfx::BufferFormat::RGBA_8888)] = capabilities_.sk_color_type = kSurfaceColorType;
kSurfaceColorType; capabilities_.gr_backend_format =
capabilities_.sk_color_types[static_cast<int>(gfx::BufferFormat::BGRA_8888)] = context_provider_->GetGrContext()->defaultBackendFormat(
kSurfaceColorType; kSurfaceColorType, GrRenderable::kYes);
vsync_provider_ = std::make_unique<gl::VSyncProviderWin>(widget); vsync_provider_ = std::make_unique<gl::VSyncProviderWin>(widget);
child_window_.Initialize(); child_window_.Initialize();
} }
......
...@@ -105,20 +105,15 @@ SkiaOutputDeviceGL::SkiaOutputDeviceGL( ...@@ -105,20 +105,15 @@ SkiaOutputDeviceGL::SkiaOutputDeviceGL(
glGetIntegerv(GL_ALPHA_BITS, &alpha_bits); glGetIntegerv(GL_ALPHA_BITS, &alpha_bits);
} }
CHECK_GL_ERROR(); CHECK_GL_ERROR();
supports_alpha_ = alpha_bits > 0;
auto color_type =
(alpha_bits > 0) ? kRGBA_8888_SkColorType : kRGB_888x_SkColorType; capabilities_.sk_color_type =
capabilities_.sk_color_types[static_cast<int>(gfx::BufferFormat::RGBA_8888)] = supports_alpha_ ? kRGBA_8888_SkColorType : kRGB_888x_SkColorType;
color_type; capabilities_.gr_backend_format = gr_context->defaultBackendFormat(
capabilities_.sk_color_types[static_cast<int>(gfx::BufferFormat::RGBX_8888)] = capabilities_.sk_color_type, GrRenderable::kYes);
color_type; capabilities_.sk_color_type_for_hdr = kRGBA_F16_SkColorType;
capabilities_.sk_color_types[static_cast<int>(gfx::BufferFormat::BGRA_8888)] = capabilities_.gr_backend_format_for_hdr = gr_context->defaultBackendFormat(
color_type; capabilities_.sk_color_type_for_hdr, GrRenderable::kYes);
capabilities_.sk_color_types[static_cast<int>(gfx::BufferFormat::BGRX_8888)] =
color_type;
capabilities_.sk_color_types[static_cast<int>(gfx::BufferFormat::RGBA_F16)] =
kRGBA_F16_SkColorType;
} }
SkiaOutputDeviceGL::~SkiaOutputDeviceGL() { SkiaOutputDeviceGL::~SkiaOutputDeviceGL() {
...@@ -145,21 +140,22 @@ bool SkiaOutputDeviceGL::Reshape(const gfx::Size& size, ...@@ -145,21 +140,22 @@ bool SkiaOutputDeviceGL::Reshape(const gfx::Size& size,
framebuffer_info.fFBOID = 0; framebuffer_info.fFBOID = 0;
DCHECK_EQ(gl_surface_->GetBackingFramebufferObject(), 0u); DCHECK_EQ(gl_surface_->GetBackingFramebufferObject(), 0u);
const auto format_index = static_cast<int>(buffer_format); SkColorType color_type;
SkColorType color_type = capabilities_.sk_color_types[format_index]; // TODO(https://crbug.com/1049334): The pixel format should be determined by
switch (color_type) { // |buffer_format|, not |color_space|, and not |supports_alpha_|.
case kRGBA_8888_SkColorType: if (color_space.IsHDR()) {
framebuffer_info.fFormat = GL_RGBA8; color_type = capabilities_.sk_color_type_for_hdr;
break; framebuffer_info.fFormat = GL_RGBA16F;
case kRGB_888x_SkColorType: DCHECK_EQ(capabilities_.gr_backend_format_for_hdr.asGLFormat(),
framebuffer_info.fFormat = GL_RGB8; GrGLFormat::kRGBA16F);
break; } else if (supports_alpha_) {
case kRGBA_F16_SkColorType: color_type = capabilities_.sk_color_type;
framebuffer_info.fFormat = GL_RGBA16F; framebuffer_info.fFormat = GL_RGBA8;
break; DCHECK_EQ(capabilities_.gr_backend_format.asGLFormat(), GrGLFormat::kRGBA8);
default: } else {
NOTREACHED() << "color_type: " << color_type color_type = capabilities_.sk_color_type;
<< " buffer_format: " << format_index; framebuffer_info.fFormat = GL_RGB8;
DCHECK_EQ(capabilities_.gr_backend_format.asGLFormat(), GrGLFormat::kRGB8);
} }
// TODO(kylechar): We might need to support RGB10A2 for HDR10. HDR10 was only // TODO(kylechar): We might need to support RGB10A2 for HDR10. HDR10 was only
// used with Windows updated RS3 (2017) as a workaround for a DWM bug so it // used with Windows updated RS3 (2017) as a workaround for a DWM bug so it
......
...@@ -81,6 +81,7 @@ class SkiaOutputDeviceGL final : public SkiaOutputDevice { ...@@ -81,6 +81,7 @@ class SkiaOutputDeviceGL final : public SkiaOutputDevice {
sk_sp<SkSurface> sk_surface_; sk_sp<SkSurface> sk_surface_;
bool supports_alpha_ = false;
uint64_t backbuffer_estimated_size_ = 0; uint64_t backbuffer_estimated_size_ = 0;
base::WeakPtrFactory<SkiaOutputDeviceGL> weak_ptr_factory_{this}; base::WeakPtrFactory<SkiaOutputDeviceGL> weak_ptr_factory_{this};
......
...@@ -34,16 +34,10 @@ SkiaOutputDeviceOffscreen::SkiaOutputDeviceOffscreen( ...@@ -34,16 +34,10 @@ SkiaOutputDeviceOffscreen::SkiaOutputDeviceOffscreen(
capabilities_.output_surface_origin = origin; capabilities_.output_surface_origin = origin;
capabilities_.supports_post_sub_buffer = true; capabilities_.supports_post_sub_buffer = true;
// TODO(https://crbug.com/1108406): use the right color types base on GPU capabilities_.sk_color_type = kSurfaceColorType;
// capabilities. capabilities_.gr_backend_format =
capabilities_.sk_color_types[static_cast<int>(gfx::BufferFormat::RGBA_8888)] = context_state_->gr_context()->defaultBackendFormat(kSurfaceColorType,
kSurfaceColorType; GrRenderable::kYes);
capabilities_.sk_color_types[static_cast<int>(gfx::BufferFormat::RGBX_8888)] =
kSurfaceColorType;
capabilities_.sk_color_types[static_cast<int>(gfx::BufferFormat::BGRA_8888)] =
kSurfaceColorType;
capabilities_.sk_color_types[static_cast<int>(gfx::BufferFormat::BGRX_8888)] =
kSurfaceColorType;
} }
SkiaOutputDeviceOffscreen::~SkiaOutputDeviceOffscreen() { SkiaOutputDeviceOffscreen::~SkiaOutputDeviceOffscreen() {
...@@ -59,7 +53,6 @@ bool SkiaOutputDeviceOffscreen::Reshape(const gfx::Size& size, ...@@ -59,7 +53,6 @@ bool SkiaOutputDeviceOffscreen::Reshape(const gfx::Size& size,
DiscardBackbuffer(); DiscardBackbuffer();
size_ = size; size_ = size;
format_ = format;
sk_color_space_ = color_space.ToSkColorSpace(); sk_color_space_ = color_space.ToSkColorSpace();
EnsureBackbuffer(); EnsureBackbuffer();
return true; return true;
...@@ -89,20 +82,15 @@ void SkiaOutputDeviceOffscreen::EnsureBackbuffer() { ...@@ -89,20 +82,15 @@ void SkiaOutputDeviceOffscreen::EnsureBackbuffer() {
if (size_.IsEmpty()) if (size_.IsEmpty())
return; return;
auto format_index = static_cast<int>(format_);
const auto& sk_color_type = capabilities_.sk_color_types[format_index];
DCHECK(sk_color_type != kUnknown_SkColorType)
<< "SkColorType is invalid for format: " << format_index;
if (has_alpha_) { if (has_alpha_) {
backend_texture_ = context_state_->gr_context()->createBackendTexture( backend_texture_ = context_state_->gr_context()->createBackendTexture(
size_.width(), size_.height(), sk_color_type, GrMipMapped::kNo, size_.width(), size_.height(), kSurfaceColorType, GrMipMapped::kNo,
GrRenderable::kYes); GrRenderable::kYes);
} else { } else {
is_emulated_rgbx_ = true; is_emulated_rgbx_ = true;
// Initialize alpha channel to opaque. // Initialize alpha channel to opaque.
backend_texture_ = context_state_->gr_context()->createBackendTexture( backend_texture_ = context_state_->gr_context()->createBackendTexture(
size_.width(), size_.height(), sk_color_type, SkColors::kBlack, size_.width(), size_.height(), kSurfaceColorType, SkColors::kBlack,
GrMipMapped::kNo, GrRenderable::kYes); GrMipMapped::kNo, GrRenderable::kYes);
} }
DCHECK(backend_texture_.isValid()); DCHECK(backend_texture_.isValid());
......
...@@ -51,7 +51,6 @@ class SkiaOutputDeviceOffscreen : public SkiaOutputDevice { ...@@ -51,7 +51,6 @@ class SkiaOutputDeviceOffscreen : public SkiaOutputDevice {
private: private:
gfx::Size size_; gfx::Size size_;
gfx::BufferFormat format_ = gfx::BufferFormat::RGBA_8888;
uint64_t backbuffer_estimated_size_ = 0; uint64_t backbuffer_estimated_size_ = 0;
sk_sp<SkColorSpace> sk_color_space_; sk_sp<SkColorSpace> sk_color_space_;
......
...@@ -318,14 +318,10 @@ bool SkiaOutputDeviceVulkan::Initialize() { ...@@ -318,14 +318,10 @@ bool SkiaOutputDeviceVulkan::Initialize() {
const auto surface_format = vulkan_surface_->surface_format().format; const auto surface_format = vulkan_surface_->surface_format().format;
DCHECK(surface_format == VK_FORMAT_B8G8R8A8_UNORM || DCHECK(surface_format == VK_FORMAT_B8G8R8A8_UNORM ||
surface_format == VK_FORMAT_R8G8B8A8_UNORM); surface_format == VK_FORMAT_R8G8B8A8_UNORM);
capabilities_.sk_color_type = surface_format == VK_FORMAT_R8G8B8A8_UNORM
auto sk_color_type = surface_format == VK_FORMAT_R8G8B8A8_UNORM ? kRGBA_8888_SkColorType
? kRGBA_8888_SkColorType : kBGRA_8888_SkColorType;
: kBGRA_8888_SkColorType; capabilities_.gr_backend_format = GrBackendFormat::MakeVk(surface_format);
capabilities_.sk_color_types[static_cast<int>(gfx::BufferFormat::RGBA_8888)] =
sk_color_type;
capabilities_.sk_color_types[static_cast<int>(gfx::BufferFormat::BGRA_8888)] =
sk_color_type;
return true; return true;
} }
......
...@@ -16,10 +16,6 @@ ...@@ -16,10 +16,6 @@
namespace viz { namespace viz {
namespace {
constexpr auto kSurfaceColorType = kRGBA_8888_SkColorType;
}
SkiaOutputDeviceWebView::SkiaOutputDeviceWebView( SkiaOutputDeviceWebView::SkiaOutputDeviceWebView(
gpu::SharedContextState* context_state, gpu::SharedContextState* context_state,
scoped_refptr<gl::GLSurface> gl_surface, scoped_refptr<gl::GLSurface> gl_surface,
...@@ -40,10 +36,10 @@ SkiaOutputDeviceWebView::SkiaOutputDeviceWebView( ...@@ -40,10 +36,10 @@ SkiaOutputDeviceWebView::SkiaOutputDeviceWebView(
DCHECK(context_state_->gr_context()); DCHECK(context_state_->gr_context());
DCHECK(context_state_->context()); DCHECK(context_state_->context());
capabilities_.sk_color_types[static_cast<int>(gfx::BufferFormat::RGBA_8888)] = capabilities_.sk_color_type = kRGBA_8888_SkColorType;
kSurfaceColorType; capabilities_.gr_backend_format =
capabilities_.sk_color_types[static_cast<int>(gfx::BufferFormat::BGRA_8888)] = context_state_->gr_context()->defaultBackendFormat(
kSurfaceColorType; capabilities_.sk_color_type, GrRenderable::kYes);
} }
SkiaOutputDeviceWebView::~SkiaOutputDeviceWebView() = default; SkiaOutputDeviceWebView::~SkiaOutputDeviceWebView() = default;
...@@ -104,7 +100,8 @@ void SkiaOutputDeviceWebView::InitSkiaSurface(unsigned int fbo) { ...@@ -104,7 +100,8 @@ void SkiaOutputDeviceWebView::InitSkiaSurface(unsigned int fbo) {
GrGLFramebufferInfo framebuffer_info; GrGLFramebufferInfo framebuffer_info;
framebuffer_info.fFBOID = fbo; framebuffer_info.fFBOID = fbo;
framebuffer_info.fFormat = GL_RGBA8; framebuffer_info.fFormat = GL_RGBA8;
SkColorType color_type = kSurfaceColorType; DCHECK_EQ(capabilities_.gr_backend_format.asGLFormat(), GrGLFormat::kRGBA8);
SkColorType color_type = capabilities_.sk_color_type;
GrBackendRenderTarget render_target(size_.width(), size_.height(), GrBackendRenderTarget render_target(size_.width(), size_.height(),
/*sampleCnt=*/0, /*sampleCnt=*/0,
......
...@@ -236,10 +236,9 @@ void SkiaOutputSurfaceImpl::Reshape(const gfx::Size& size, ...@@ -236,10 +236,9 @@ void SkiaOutputSurfaceImpl::Reshape(const gfx::Size& size,
color_space_ = color_space; color_space_ = color_space;
is_hdr_ = color_space_.IsHDR(); is_hdr_ = color_space_.IsHDR();
size_ = size; size_ = size;
format_ = format;
characterization_ = CreateSkSurfaceCharacterization( characterization_ = CreateSkSurfaceCharacterization(
size, format, false /* mipmap */, color_space_.ToSkColorSpace(), size, GetResourceFormat(format), false /* mipmap */,
true /* is_root_render_pass */); color_space_.ToSkColorSpace(), true /* is_root_render_pass */);
RecreateRootRecorder(); RecreateRootRecorder();
} }
...@@ -290,8 +289,8 @@ SkCanvas* SkiaOutputSurfaceImpl::BeginPaintCurrentFrame() { ...@@ -290,8 +289,8 @@ SkCanvas* SkiaOutputSurfaceImpl::BeginPaintCurrentFrame() {
nway_canvas_->addCanvas(current_paint_->recorder()->getCanvas()); nway_canvas_->addCanvas(current_paint_->recorder()->getCanvas());
SkSurfaceCharacterization characterization = CreateSkSurfaceCharacterization( SkSurfaceCharacterization characterization = CreateSkSurfaceCharacterization(
gfx::Size(characterization_.width(), characterization_.height()), format_, gfx::Size(characterization_.width(), characterization_.height()),
false /* mipmap */, characterization_.refColorSpace(), BGRA_8888, false /* mipmap */, characterization_.refColorSpace(),
false /* is_root_render_pass */); false /* is_root_render_pass */);
if (characterization.isValid()) { if (characterization.isValid()) {
overdraw_surface_recorder_.emplace(characterization); overdraw_surface_recorder_.emplace(characterization);
...@@ -494,7 +493,7 @@ SkCanvas* SkiaOutputSurfaceImpl::BeginPaintRenderPass( ...@@ -494,7 +493,7 @@ SkCanvas* SkiaOutputSurfaceImpl::BeginPaintRenderPass(
DCHECK(resource_sync_tokens_.empty()); DCHECK(resource_sync_tokens_.empty());
SkSurfaceCharacterization characterization = CreateSkSurfaceCharacterization( SkSurfaceCharacterization characterization = CreateSkSurfaceCharacterization(
surface_size, BufferFormat(format), mipmap, std::move(color_space), surface_size, format, mipmap, std::move(color_space),
false /* is_root_render_pass */); false /* is_root_render_pass */);
if (!characterization.isValid()) if (!characterization.isValid())
return nullptr; return nullptr;
...@@ -780,7 +779,7 @@ void SkiaOutputSurfaceImpl::InitializeOnGpuThread( ...@@ -780,7 +779,7 @@ void SkiaOutputSurfaceImpl::InitializeOnGpuThread(
SkSurfaceCharacterization SkSurfaceCharacterization
SkiaOutputSurfaceImpl::CreateSkSurfaceCharacterization( SkiaOutputSurfaceImpl::CreateSkSurfaceCharacterization(
const gfx::Size& surface_size, const gfx::Size& surface_size,
gfx::BufferFormat format, ResourceFormat format,
bool mipmap, bool mipmap,
sk_sp<SkColorSpace> color_space, sk_sp<SkColorSpace> color_space,
bool is_root_render_pass) { bool is_root_render_pass) {
...@@ -792,15 +791,15 @@ SkiaOutputSurfaceImpl::CreateSkSurfaceCharacterization( ...@@ -792,15 +791,15 @@ SkiaOutputSurfaceImpl::CreateSkSurfaceCharacterization(
SkSurfaceProps surface_props(0 /*flags */, SkSurfaceProps surface_props(0 /*flags */,
SkSurfaceProps::kLegacyFontHost_InitType); SkSurfaceProps::kLegacyFontHost_InitType);
if (is_root_render_pass) { if (is_root_render_pass) {
const auto format_index = static_cast<int>(format); auto color_type =
const auto& color_type = capabilities_.sk_color_types[format_index]; is_hdr_ && capabilities_.sk_color_type_for_hdr != kUnknown_SkColorType
const auto backend_format = gr_context_thread_safe_->defaultBackendFormat( ? capabilities_.sk_color_type_for_hdr
color_type, GrRenderable::kYes); : capabilities_.sk_color_type;
DCHECK(color_type != kUnknown_SkColorType)
<< "SkColorType is invalid for buffer format_index: " << format_index; const auto& backend_format =
DCHECK(backend_format.isValid()) is_hdr_ && capabilities_.gr_backend_format_for_hdr.isValid()
<< "GrBackendFormat is invalid for buffer format_index: " ? capabilities_.gr_backend_format_for_hdr
<< format_index; : capabilities_.gr_backend_format;
auto surface_origin = auto surface_origin =
capabilities_.output_surface_origin == gfx::SurfaceOrigin::kBottomLeft capabilities_.output_surface_origin == gfx::SurfaceOrigin::kBottomLeft
? kBottomLeft_GrSurfaceOrigin ? kBottomLeft_GrSurfaceOrigin
...@@ -839,9 +838,8 @@ SkiaOutputSurfaceImpl::CreateSkSurfaceCharacterization( ...@@ -839,9 +838,8 @@ SkiaOutputSurfaceImpl::CreateSkSurfaceCharacterization(
return characterization; return characterization;
} }
auto resource_format = GetResourceFormat(format); auto color_type =
auto color_type = ResourceFormatToClosestSkColorType( ResourceFormatToClosestSkColorType(true /* gpu_compositing */, format);
true /* gpu_compositing */, resource_format);
auto backend_format = gr_context_thread_safe_->defaultBackendFormat( auto backend_format = gr_context_thread_safe_->defaultBackendFormat(
color_type, GrRenderable::kYes); color_type, GrRenderable::kYes);
DCHECK(backend_format.isValid()); DCHECK(backend_format.isValid());
......
...@@ -159,7 +159,7 @@ class VIZ_SERVICE_EXPORT SkiaOutputSurfaceImpl : public SkiaOutputSurface { ...@@ -159,7 +159,7 @@ class VIZ_SERVICE_EXPORT SkiaOutputSurfaceImpl : public SkiaOutputSurface {
bool* result); bool* result);
SkSurfaceCharacterization CreateSkSurfaceCharacterization( SkSurfaceCharacterization CreateSkSurfaceCharacterization(
const gfx::Size& surface_size, const gfx::Size& surface_size,
gfx::BufferFormat format, ResourceFormat format,
bool mipmap, bool mipmap,
sk_sp<SkColorSpace> color_space, sk_sp<SkColorSpace> color_space,
bool is_root_render_pass); bool is_root_render_pass);
...@@ -202,7 +202,6 @@ class VIZ_SERVICE_EXPORT SkiaOutputSurfaceImpl : public SkiaOutputSurface { ...@@ -202,7 +202,6 @@ class VIZ_SERVICE_EXPORT SkiaOutputSurfaceImpl : public SkiaOutputSurface {
gfx::Size size_; gfx::Size size_;
gfx::ColorSpace color_space_; gfx::ColorSpace color_space_;
gfx::BufferFormat format_;
bool is_hdr_ = false; bool is_hdr_ = false;
SkSurfaceCharacterization characterization_; SkSurfaceCharacterization characterization_;
base::Optional<SkDeferredDisplayListRecorder> root_recorder_; base::Optional<SkDeferredDisplayListRecorder> root_recorder_;
......
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