Commit bfbe1264 authored by Jonah Ryan-Davis's avatar Jonah Ryan-Davis Committed by Commit Bot

Revert "Add SkiaOutputDeviceGL"

This reverts commit 78b558a1.

Reason for revert:
1 tests failed: ['vulkan_content_browsertests on (nvidia-quadro-p400-ubuntu-stable) GPU on Linux']
https://ci.chromium.org/p/chromium/builders/ci/Linux%20FYI%20Release%20%28NVIDIA%29/9112

Original change's description:
> Add SkiaOutputDeviceGL
> 
> This CL moves some platform specific logic out of
> SkiaOutputSurfaceImplOnGpu and into SkiaOutputDeviceGL. I also added the
> hooks to support partial swaps and tested on an i7 gLinux laptop.
> 
> Bug: 920344
> Change-Id: I77b86442fef2340094de9fa93057f1fa2af2f50b
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1539792
> Commit-Queue: Jonathan Backer <backer@chromium.org>
> Reviewed-by: Peng Huang <penghuang@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#645059}

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

Change-Id: I6eff445f1e0c9d4b250267c89b2b937f71270e2e
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: 920344
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1542422Reviewed-by: default avatarGeoff Lang <geofflang@chromium.org>
Commit-Queue: Geoff Lang <geofflang@chromium.org>
Cr-Commit-Position: refs/heads/master@{#645281}
parent a2fe90f0
......@@ -311,8 +311,6 @@ viz_source_set("gpu_service_dependencies") {
sources = [
"display_embedder/skia_output_device.cc",
"display_embedder/skia_output_device.h",
"display_embedder/skia_output_device_gl.cc",
"display_embedder/skia_output_device_gl.h",
"display_embedder/skia_output_device_offscreen.cc",
"display_embedder/skia_output_device_offscreen.h",
"display_embedder/skia_output_surface_impl.cc",
......
......@@ -4,16 +4,9 @@
#include "components/viz/service/display_embedder/skia_output_device.h"
#include <utility>
#include "third_party/skia/include/core/SkSurface.h"
#include "ui/gfx/presentation_feedback.h"
namespace viz {
SkiaOutputDevice::SkiaOutputDevice(
DidSwapBufferCompleteCallback did_swap_buffer_complete_callback)
: did_swap_buffer_complete_callback_(did_swap_buffer_complete_callback) {}
SkiaOutputDevice::SkiaOutputDevice() = default;
SkiaOutputDevice::~SkiaOutputDevice() = default;
......@@ -21,45 +14,9 @@ bool SkiaOutputDevice::SupportPostSubBuffer() {
return false;
}
gfx::SwapResponse SkiaOutputDevice::PostSubBuffer(
const gfx::Rect& rect,
BufferPresentedCallback feedback) {
gfx::SwapResult SkiaOutputDevice::PostSubBuffer(const gfx::Rect& rect) {
NOTREACHED();
StartSwapBuffers(std::move(feedback));
return FinishSwapBuffers(gfx::SwapResult::SWAP_FAILED);
}
void SkiaOutputDevice::StartSwapBuffers(
base::Optional<BufferPresentedCallback> feedback) {
DCHECK(!feedback_);
DCHECK(!params_);
feedback_ = std::move(feedback);
params_.emplace();
params_->swap_response.swap_id = ++swap_id_;
params_->swap_response.swap_start = base::TimeTicks::Now();
}
gfx::SwapResponse SkiaOutputDevice::FinishSwapBuffers(gfx::SwapResult result) {
DCHECK(params_);
params_->swap_response.result = result;
params_->swap_response.swap_end = base::TimeTicks::Now();
if (feedback_) {
std::move(*feedback_)
.Run(gfx::PresentationFeedback(
params_->swap_response.swap_start, base::TimeDelta() /* interval */,
params_->swap_response.result == gfx::SwapResult::SWAP_ACK
? 0
: gfx::PresentationFeedback::Flags::kFailure));
}
did_swap_buffer_complete_callback_.Run(
*params_, gfx::Size(draw_surface_->width(), draw_surface_->height()));
feedback_.reset();
auto response = params_->swap_response;
params_.reset();
return response;
return gfx::SwapResult::SWAP_FAILED;
}
} // namespace viz
......@@ -5,66 +5,35 @@
#ifndef COMPONENTS_VIZ_SERVICE_DISPLAY_EMBEDDER_SKIA_OUTPUT_DEVICE_H_
#define COMPONENTS_VIZ_SERVICE_DISPLAY_EMBEDDER_SKIA_OUTPUT_DEVICE_H_
#include "base/callback.h"
#include "base/macros.h"
#include "base/optional.h"
#include "gpu/command_buffer/common/swap_buffers_complete_params.h"
#include "third_party/skia/include/core/SkRefCnt.h"
#include "ui/gfx/geometry/rect.h"
#include "ui/gfx/geometry/size.h"
#include "ui/gfx/swap_result.h"
class SkSurface;
namespace gfx {
class ColorSpace;
class Rect;
class Size;
struct PresentationFeedback;
} // namespace gfx
namespace viz {
class SkiaOutputDevice {
public:
using BufferPresentedCallback =
base::OnceCallback<void(const gfx::PresentationFeedback& feedback)>;
using DidSwapBufferCompleteCallback =
base::RepeatingCallback<void(gpu::SwapBuffersCompleteParams,
const gfx::Size& pixel_size)>;
explicit SkiaOutputDevice(
DidSwapBufferCompleteCallback did_swap_buffer_complete_callback);
SkiaOutputDevice();
virtual ~SkiaOutputDevice();
// SkSurface that can be drawn to.
sk_sp<SkSurface> DrawSurface() { return draw_surface_; }
virtual sk_sp<SkSurface> DrawSurface() = 0;
// Changes the size of draw surface and invalidates it's contents.
virtual void Reshape(const gfx::Size& size,
float device_scale_factor,
const gfx::ColorSpace& color_space,
bool has_alpha) = 0;
virtual void Reshape(const gfx::Size& size) = 0;
// Presents DrawSurface.
virtual gfx::SwapResponse SwapBuffers(BufferPresentedCallback feedback) = 0;
virtual gfx::SwapResult SwapBuffers() = 0;
virtual bool SupportPostSubBuffer();
virtual gfx::SwapResponse PostSubBuffer(const gfx::Rect& rect,
BufferPresentedCallback feedback);
protected:
void StartSwapBuffers(base::Optional<BufferPresentedCallback> feedback);
gfx::SwapResponse FinishSwapBuffers(gfx::SwapResult result);
sk_sp<SkSurface> draw_surface_;
virtual gfx::SwapResult PostSubBuffer(const gfx::Rect& rect);
private:
uint64_t swap_id_ = 0;
DidSwapBufferCompleteCallback did_swap_buffer_complete_callback_;
// Only valid between StartSwapBuffers and FinishSwapBuffers.
base::Optional<BufferPresentedCallback> feedback_;
base::Optional<gpu::SwapBuffersCompleteParams> params_;
DISALLOW_COPY_AND_ASSIGN(SkiaOutputDevice);
};
......
// Copyright 2019 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "components/viz/service/display_embedder/skia_output_device_gl.h"
#include <utility>
#include "gpu/command_buffer/common/swap_buffers_complete_params.h"
#include "gpu/command_buffer/service/feature_info.h"
#include "gpu/command_buffer/service/gl_utils.h"
#include "gpu/ipc/service/image_transport_surface.h"
#include "third_party/skia/include/core/SkSurface.h"
#include "third_party/skia/include/core/SkSurfaceProps.h"
#include "third_party/skia/include/gpu/GrBackendSurface.h"
#include "third_party/skia/include/gpu/GrContext.h"
#include "third_party/skia/include/gpu/gl/GrGLTypes.h"
#include "ui/gl/gl_bindings.h"
#include "ui/gl/gl_context.h"
#include "ui/gl/gl_surface.h"
#include "ui/gl/gl_version_info.h"
namespace viz {
SkiaOutputDeviceGL::SkiaOutputDeviceGL(
gpu::SurfaceHandle surface_handle,
scoped_refptr<gpu::gles2::FeatureInfo> feature_info,
const DidSwapBufferCompleteCallback& did_swap_buffer_complete_callback)
: SkiaOutputDevice(did_swap_buffer_complete_callback),
surface_handle_(surface_handle),
feature_info_(feature_info) {
DCHECK(surface_handle_);
gl_surface_ = gpu::ImageTransportSurface::CreateNativeSurface(
nullptr, surface_handle_, gl::GLSurfaceFormat());
}
void SkiaOutputDeviceGL::Initialize(GrContext* gr_context,
gl::GLContext* gl_context) {
DCHECK(gr_context);
DCHECK(gl_context);
gr_context_ = gr_context;
gl::CurrentGL* current_gl = gl_context->GetCurrentGL();
DCHECK(current_gl);
// Get alpha and stencil bits from the default frame buffer.
glBindFramebufferEXT(GL_FRAMEBUFFER, 0);
gr_context_->resetContext(kRenderTarget_GrGLBackendState);
const auto* version = current_gl->Version;
GLint stencil_bits = 0;
GLint alpha_bits = 0;
if (version->is_desktop_core_profile) {
glGetFramebufferAttachmentParameterivEXT(
GL_FRAMEBUFFER, GL_STENCIL, GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE,
&stencil_bits);
glGetFramebufferAttachmentParameterivEXT(
GL_FRAMEBUFFER, GL_BACK_LEFT, GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE,
&alpha_bits);
} else {
glGetIntegerv(GL_STENCIL_BITS, &stencil_bits);
glGetIntegerv(GL_ALPHA_BITS, &alpha_bits);
}
CHECK_GL_ERROR();
supports_stencil_ = stencil_bits > 0;
supports_alpha_ = alpha_bits > 0;
supports_post_sub_buffer_ = gl_surface_->SupportsPostSubBuffer();
if (feature_info_->workarounds()
.disable_post_sub_buffers_for_onscreen_surfaces)
supports_post_sub_buffer_ = false;
}
SkiaOutputDeviceGL::~SkiaOutputDeviceGL() {}
scoped_refptr<gl::GLSurface> SkiaOutputDeviceGL::gl_surface() {
return gl_surface_;
}
void SkiaOutputDeviceGL::Reshape(const gfx::Size& size,
float device_scale_factor,
const gfx::ColorSpace& color_space,
bool has_alpha) {
// Conversion to GLSurface's color space follows the same logic as in
// gl::GetGLColorSpace().
gl::GLSurface::ColorSpace surface_color_space =
color_space.IsHDR() ? gl::GLSurface::ColorSpace::SCRGB_LINEAR
: gl::GLSurface::ColorSpace::UNSPECIFIED;
if (!gl_surface_->Resize(size, device_scale_factor, surface_color_space,
has_alpha)) {
LOG(FATAL) << "Failed to resize.";
// TODO(penghuang): Handle the failure.
}
SkSurfaceProps surface_props =
SkSurfaceProps(0, SkSurfaceProps::kLegacyFontHost_InitType);
GrGLFramebufferInfo framebuffer_info;
framebuffer_info.fFBOID = gl_surface_->GetBackingFramebufferObject();
framebuffer_info.fFormat = supports_alpha_ ? GL_RGBA8 : GL_RGB8_OES;
GrBackendRenderTarget render_target(size.width(), size.height(), 0, 8,
framebuffer_info);
auto origin = gl_surface_->FlipsVertically() ? kTopLeft_GrSurfaceOrigin
: kBottomLeft_GrSurfaceOrigin;
auto color_type =
supports_alpha_ ? kRGBA_8888_SkColorType : kRGB_888x_SkColorType;
draw_surface_ = SkSurface::MakeFromBackendRenderTarget(
gr_context_, render_target, origin, color_type,
color_space.ToSkColorSpace(), &surface_props);
DCHECK(draw_surface_);
}
gfx::SwapResponse SkiaOutputDeviceGL::SwapBuffers(
BufferPresentedCallback feedback) {
// TODO(backer): Support SwapBuffersAsync
StartSwapBuffers({});
return FinishSwapBuffers(gl_surface_->SwapBuffers(std::move(feedback)));
}
bool SkiaOutputDeviceGL::SupportPostSubBuffer() {
return supports_post_sub_buffer_;
}
gfx::SwapResponse SkiaOutputDeviceGL::PostSubBuffer(
const gfx::Rect& rect,
BufferPresentedCallback feedback) {
// TODO(backer): Support PostSubBufferAsync
StartSwapBuffers({});
return FinishSwapBuffers(gl_surface_->PostSubBuffer(
rect.x(), rect.y(), rect.width(), rect.height(), std::move(feedback)));
}
} // namespace viz
// Copyright 2019 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef COMPONENTS_VIZ_SERVICE_DISPLAY_EMBEDDER_SKIA_OUTPUT_DEVICE_GL_H_
#define COMPONENTS_VIZ_SERVICE_DISPLAY_EMBEDDER_SKIA_OUTPUT_DEVICE_GL_H_
#include <memory>
#include "base/macros.h"
#include "base/memory/ref_counted.h"
#include "components/viz/service/display_embedder/skia_output_device.h"
#include "gpu/config/gpu_preferences.h"
#include "gpu/ipc/common/surface_handle.h"
class GrContext;
namespace gl {
class GLContext;
class GLSurface;
} // namespace gl
namespace gpu {
namespace gles2 {
class FeatureInfo;
} // namespace gles2
} // namespace gpu
namespace viz {
class SkiaOutputDeviceGL final : public SkiaOutputDevice {
public:
SkiaOutputDeviceGL(
gpu::SurfaceHandle surface_handle,
scoped_refptr<gpu::gles2::FeatureInfo> feature_info,
const DidSwapBufferCompleteCallback& did_swap_buffer_complete_callback);
~SkiaOutputDeviceGL() override;
scoped_refptr<gl::GLSurface> gl_surface();
void Initialize(GrContext* gr_context, gl::GLContext* gl_context);
bool supports_alpha() {
DCHECK(gr_context_);
return supports_alpha_;
}
bool supports_stencil() {
DCHECK(gr_context_);
return supports_stencil_;
}
// SkiaOutputDevice implementation:
void Reshape(const gfx::Size& size,
float device_scale_factor,
const gfx::ColorSpace& color_space,
bool has_alpha) override;
gfx::SwapResponse SwapBuffers(BufferPresentedCallback feedback) override;
bool SupportPostSubBuffer() override;
gfx::SwapResponse PostSubBuffer(const gfx::Rect& rect,
BufferPresentedCallback feedback) override;
private:
const gpu::SurfaceHandle surface_handle_;
scoped_refptr<gpu::gles2::FeatureInfo> feature_info_;
gpu::GpuPreferences gpu_preferences_;
GrContext* gr_context_ = nullptr;
scoped_refptr<gl::GLSurface> gl_surface_;
sk_sp<SkSurface> sk_surface_;
bool supports_alpha_ = false;
bool supports_stencil_ = false;
bool supports_post_sub_buffer_ = false;
DISALLOW_COPY_AND_ASSIGN(SkiaOutputDeviceGL);
};
} // namespace viz
#endif // COMPONENTS_VIZ_SERVICE_DISPLAY_EMBEDDER_SKIA_OUTPUT_DEVICE_GL_H_
......@@ -4,28 +4,22 @@
#include "components/viz/service/display_embedder/skia_output_device_offscreen.h"
#include <utility>
#include "third_party/skia/include/core/SkSurface.h"
namespace viz {
SkiaOutputDeviceOffscreen::SkiaOutputDeviceOffscreen(
GrContext* gr_context,
bool flipped,
bool has_alpha,
DidSwapBufferCompleteCallback did_swap_buffer_complete_callback)
: SkiaOutputDevice(did_swap_buffer_complete_callback),
gr_context_(gr_context),
flipped_(flipped),
has_alpha_(has_alpha) {}
SkiaOutputDeviceOffscreen::SkiaOutputDeviceOffscreen(GrContext* gr_context,
bool flipped,
bool has_alpha)
: gr_context_(gr_context), flipped_(flipped), has_alpha_(has_alpha) {}
SkiaOutputDeviceOffscreen::~SkiaOutputDeviceOffscreen() = default;
void SkiaOutputDeviceOffscreen::Reshape(const gfx::Size& size,
float device_scale_factor,
const gfx::ColorSpace& color_space,
bool has_alpha) {
sk_sp<SkSurface> SkiaOutputDeviceOffscreen::DrawSurface() {
return draw_surface_;
}
void SkiaOutputDeviceOffscreen::Reshape(const gfx::Size& size) {
auto image_info = SkImageInfo::Make(
size.width(), size.height(),
has_alpha_ ? kRGBA_8888_SkColorType : kRGB_888x_SkColorType,
......@@ -36,13 +30,10 @@ void SkiaOutputDeviceOffscreen::Reshape(const gfx::Size& size,
nullptr /* surfaceProps */);
}
gfx::SwapResponse SkiaOutputDeviceOffscreen::SwapBuffers(
BufferPresentedCallback feedback) {
gfx::SwapResult SkiaOutputDeviceOffscreen::SwapBuffers() {
// Reshape should have been called first.
DCHECK(draw_surface_);
StartSwapBuffers(std::move(feedback));
return FinishSwapBuffers(gfx::SwapResult::SWAP_ACK);
return gfx::SwapResult::SWAP_ACK;
}
} // namespace viz
......@@ -14,22 +14,18 @@ namespace viz {
class SkiaOutputDeviceOffscreen : public SkiaOutputDevice {
public:
SkiaOutputDeviceOffscreen(
GrContext* gr_context,
bool flipped,
bool has_alpha,
DidSwapBufferCompleteCallback did_swap_buffer_complete_callback);
SkiaOutputDeviceOffscreen(GrContext* gr_context,
bool flipped,
bool has_alpha);
~SkiaOutputDeviceOffscreen() override;
// SkiaOutputDevice implementation:
void Reshape(const gfx::Size& size,
float device_scale_factor,
const gfx::ColorSpace& color_space,
bool has_alpha) override;
gfx::SwapResponse SwapBuffers(BufferPresentedCallback feedback) override;
sk_sp<SkSurface> DrawSurface() override;
void Reshape(const gfx::Size& size) override;
gfx::SwapResult SwapBuffers() override;
protected:
GrContext* const gr_context_;
sk_sp<SkSurface> draw_surface_;
const bool flipped_;
const bool has_alpha_;
......
......@@ -4,8 +4,6 @@
#include "components/viz/service/display_embedder/skia_output_device_vulkan.h"
#include <utility>
#include "build/build_config.h"
#include "components/viz/common/gpu/vulkan_context_provider.h"
#include "gpu/ipc/common/gpu_surface_lookup.h"
......@@ -19,21 +17,19 @@ namespace viz {
SkiaOutputDeviceVulkan::SkiaOutputDeviceVulkan(
VulkanContextProvider* context_provider,
gpu::SurfaceHandle surface_handle,
DidSwapBufferCompleteCallback did_swap_buffer_complete_callback)
: SkiaOutputDevice(did_swap_buffer_complete_callback),
context_provider_(context_provider),
surface_handle_(surface_handle) {}
gpu::SurfaceHandle surface_handle)
: context_provider_(context_provider), surface_handle_(surface_handle) {}
SkiaOutputDeviceVulkan::~SkiaOutputDeviceVulkan() {
if (vulkan_surface_)
vulkan_surface_->Destroy();
}
void SkiaOutputDeviceVulkan::Reshape(const gfx::Size& size,
float device_scale_factor,
const gfx::ColorSpace& color_space,
bool has_alpha) {
sk_sp<SkSurface> SkiaOutputDeviceVulkan::DrawSurface() {
return draw_surface_;
}
void SkiaOutputDeviceVulkan::Reshape(const gfx::Size& size) {
if (!vulkan_surface_)
CreateVulkanSurface();
......@@ -49,13 +45,11 @@ void SkiaOutputDeviceVulkan::Reshape(const gfx::Size& size,
UpdateDrawSurface();
}
gfx::SwapResponse SkiaOutputDeviceVulkan::SwapBuffers(
BufferPresentedCallback feedback) {
gfx::SwapResult SkiaOutputDeviceVulkan::SwapBuffers() {
// Reshape should have been called first.
DCHECK(vulkan_surface_);
DCHECK(draw_surface_);
StartSwapBuffers(std::move(feedback));
auto backend = draw_surface_->getBackendRenderTarget(
SkSurface::kFlushRead_BackendHandleAccess);
GrVkImageInfo vk_image_info;
......@@ -63,11 +57,11 @@ gfx::SwapResponse SkiaOutputDeviceVulkan::SwapBuffers(
NOTREACHED() << "Failed to get the image info.";
vulkan_surface_->GetSwapChain()->SetCurrentImageLayout(
vk_image_info.fImageLayout);
auto response = FinishSwapBuffers(vulkan_surface_->SwapBuffers());
auto result = vulkan_surface_->SwapBuffers();
UpdateDrawSurface();
return response;
return result;
}
void SkiaOutputDeviceVulkan::CreateVulkanSurface() {
......
......@@ -20,20 +20,15 @@ namespace viz {
class VulkanContextProvider;
class SkiaOutputDeviceVulkan final : public SkiaOutputDevice {
class SkiaOutputDeviceVulkan : public SkiaOutputDevice {
public:
SkiaOutputDeviceVulkan(
VulkanContextProvider* context_provider,
gpu::SurfaceHandle surface_handle,
DidSwapBufferCompleteCallback did_swap_buffer_complete_callback);
SkiaOutputDeviceVulkan(VulkanContextProvider* context_provider,
gpu::SurfaceHandle surface_handle);
~SkiaOutputDeviceVulkan() override;
// SkiaOutputDevice implementation:
void Reshape(const gfx::Size& size,
float device_scale_factor,
const gfx::ColorSpace& color_space,
bool has_alpha) override;
gfx::SwapResponse SwapBuffers(BufferPresentedCallback feedback) override;
sk_sp<SkSurface> DrawSurface() override;
void Reshape(const gfx::Size& size) override;
gfx::SwapResult SwapBuffers() override;
private:
void CreateVulkanSurface();
......@@ -47,6 +42,9 @@ class SkiaOutputDeviceVulkan final : public SkiaOutputDevice {
// SkSurfaces for swap chain images.
std::vector<sk_sp<SkSurface>> sk_surfaces_;
// SkSurface to be drawn to. Updated after Reshape and SwapBuffers.
sk_sp<SkSurface> draw_surface_;
DISALLOW_COPY_AND_ASSIGN(SkiaOutputDeviceVulkan);
};
......
......@@ -4,8 +4,6 @@
#include "components/viz/service/display_embedder/skia_output_device_x11.h"
#include <utility>
#include "third_party/skia/include/core/SkSurface.h"
#include "third_party/skia/include/gpu/GrBackendSurface.h"
#include "third_party/skia/include/gpu/vk/GrVkTypes.h"
......@@ -15,14 +13,11 @@
namespace viz {
SkiaOutputDeviceX11::SkiaOutputDeviceX11(
GrContext* gr_context,
gfx::AcceleratedWidget widget,
DidSwapBufferCompleteCallback did_swap_buffer_complete_callback)
SkiaOutputDeviceX11::SkiaOutputDeviceX11(GrContext* gr_context,
gfx::AcceleratedWidget widget)
: SkiaOutputDeviceOffscreen(gr_context,
false /* flipped */,
true /* has_alpha */,
did_swap_buffer_complete_callback),
true /* has_alpha */),
display_(gfx::GetXDisplay()),
widget_(widget),
gc_(XCreateGC(display_, widget_, 0, nullptr)) {
......@@ -37,33 +32,23 @@ SkiaOutputDeviceX11::~SkiaOutputDeviceX11() {
XFreeGC(display_, gc_);
}
void SkiaOutputDeviceX11::Reshape(const gfx::Size& size,
float device_scale_factor,
const gfx::ColorSpace& color_space,
bool has_alpha) {
SkiaOutputDeviceOffscreen::Reshape(size, device_scale_factor, color_space,
has_alpha);
void SkiaOutputDeviceX11::Reshape(const gfx::Size& size) {
SkiaOutputDeviceOffscreen::Reshape(size);
auto ii =
SkImageInfo::MakeN32(size.width(), size.height(), kOpaque_SkAlphaType);
pixels_.reserve(ii.computeMinByteSize());
}
gfx::SwapResponse SkiaOutputDeviceX11::SwapBuffers(
BufferPresentedCallback feedback) {
gfx::SwapResult SkiaOutputDeviceX11::SwapBuffers() {
return PostSubBuffer(
gfx::Rect(0, 0, draw_surface_->width(), draw_surface_->height()),
std::move(feedback));
gfx::Rect(0, 0, draw_surface_->width(), draw_surface_->height()));
}
bool SkiaOutputDeviceX11::SupportPostSubBuffer() {
return true;
}
gfx::SwapResponse SkiaOutputDeviceX11::PostSubBuffer(
const gfx::Rect& rect,
BufferPresentedCallback feedback) {
StartSwapBuffers(std::move(feedback));
gfx::SwapResult SkiaOutputDeviceX11::PostSubBuffer(const gfx::Rect& rect) {
auto ii =
SkImageInfo::MakeN32(rect.width(), rect.height(), kOpaque_SkAlphaType);
DCHECK_GE(pixels_.capacity(), ii.computeMinByteSize());
......@@ -129,7 +114,7 @@ gfx::SwapResponse SkiaOutputDeviceX11::PostSubBuffer(
NOTIMPLEMENTED();
}
XFlush(display_);
return FinishSwapBuffers(gfx::SwapResult::SWAP_ACK);
return gfx::SwapResult::SWAP_ACK;
}
} // namespace viz
......@@ -17,20 +17,13 @@ namespace viz {
class SkiaOutputDeviceX11 final : public SkiaOutputDeviceOffscreen {
public:
SkiaOutputDeviceX11(
GrContext* gr_context,
gfx::AcceleratedWidget widget,
DidSwapBufferCompleteCallback did_swap_buffer_complete_callback);
SkiaOutputDeviceX11(GrContext* gr_context, gfx::AcceleratedWidget widget);
~SkiaOutputDeviceX11() override;
void Reshape(const gfx::Size& size,
float device_scale_factor,
const gfx::ColorSpace& color_space,
bool has_alpha) override;
gfx::SwapResponse SwapBuffers(BufferPresentedCallback feedback) override;
void Reshape(const gfx::Size& size) override;
gfx::SwapResult SwapBuffers() override;
bool SupportPostSubBuffer() override;
gfx::SwapResponse PostSubBuffer(const gfx::Rect& rect,
BufferPresentedCallback feedback) override;
gfx::SwapResult PostSubBuffer(const gfx::Rect& rect) override;
private:
XDisplay* const display_;
......
......@@ -69,7 +69,7 @@ struct RenderPassGeometry;
// The SkiaOutputSurface implementation running on the GPU thread. This class
// should be created, used and destroyed on the GPU thread.
class SkiaOutputSurfaceImplOnGpu {
class SkiaOutputSurfaceImplOnGpu : public gpu::ImageTransportSurfaceDelegate {
public:
using DidSwapBufferCompleteCallback =
base::RepeatingCallback<void(gpu::SwapBuffersCompleteParams,
......@@ -98,7 +98,7 @@ class SkiaOutputSurfaceImplOnGpu {
const BufferPresentedCallback& buffer_presented_callback,
const ContextLostCallback& context_lost_callback);
~SkiaOutputSurfaceImplOnGpu();
~SkiaOutputSurfaceImplOnGpu() override;
gpu::CommandBufferId command_buffer_id() const {
return sync_point_client_state_->command_buffer_id();
......@@ -160,11 +160,33 @@ class SkiaOutputSurfaceImplOnGpu {
const OutputSurface::Capabilities& capabilities);
private:
// gpu::ImageTransportSurfaceDelegate implementation:
#if defined(OS_WIN)
void DidCreateAcceleratedSurfaceChildWindow(
gpu::SurfaceHandle parent_window,
gpu::SurfaceHandle child_window) override;
#endif
void DidSwapBuffersComplete(gpu::SwapBuffersCompleteParams params) override;
const gpu::gles2::FeatureInfo* GetFeatureInfo() const override;
const gpu::GpuPreferences& GetGpuPreferences() const override;
void BufferPresented(const gfx::PresentationFeedback& feedback) override;
void AddFilter(IPC::MessageFilter* message_filter) override;
int32_t GetRouteID() const override;
void InitializeForGL();
void InitializeForGLWithGpuService(GpuServiceImpl* gpu_service);
void InitializeForGLWithTaskExecutor(
gpu::CommandBufferTaskExecutor* task_executor,
scoped_refptr<gl::GLSurface> gl_surface);
void InitializeForVulkan(GpuServiceImpl* gpu_service);
void BindOrCopyTextureIfNecessary(gpu::TextureBase* texture_base);
// Generage the next swap ID and push it to our pending swap ID queues.
void OnSwapBuffers();
void CreateSkSurfaceForGL();
// Make context current for GL, and return false if the context is lost.
// It will do nothing when Vulkan is used.
bool MakeCurrent(bool need_fbo0);
......@@ -231,6 +253,12 @@ class SkiaOutputSurfaceImplOnGpu {
};
base::flat_map<RenderPassId, OffscreenSurface> offscreen_surfaces_;
// Params are pushed each time we begin a swap, and popped each time we
// present or complete a swap.
base::circular_deque<std::pair<uint64_t, gfx::Size>>
pending_swap_completed_params_;
uint64_t swap_id_ = 0;
ui::LatencyTracker latency_tracker_;
scoped_refptr<base::SingleThreadTaskRunner> context_current_task_runner_;
......
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