Skip to content

Commit

Permalink
Move OutputSurfaceFrame to the viz service.
Browse files Browse the repository at this point in the history
This class is an output of the viz display compositor, so move it
there.

R=enne@chromium.org
TBR=boliu

Bug: 722935
Cq-Include-Trybots: master.tryserver.blink:linux_trusty_blink_rel
Change-Id: Ib7047bbed87cb5d669e1155d269b47927a76905c
Reviewed-on: https://chromium-review.googlesource.com/676175
Commit-Queue: danakj <danakj@chromium.org>
Reviewed-by: enne <enne@chromium.org>
Reviewed-by: Bo <boliu@chromium.org>
Reviewed-by: danakj <danakj@chromium.org>
Cr-Commit-Position: refs/heads/master@{#503482}
  • Loading branch information
danakj authored and Commit Bot committed Sep 21, 2017
1 parent 0169933 commit d248b33
Show file tree
Hide file tree
Showing 39 changed files with 75 additions and 79 deletions.
4 changes: 2 additions & 2 deletions android_webview/browser/parent_output_surface.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@

#include "android_webview/browser/aw_render_thread_context_provider.h"
#include "android_webview/browser/scoped_app_gl_state_restore.h"
#include "cc/output/output_surface_frame.h"
#include "components/viz/service/display/output_surface_client.h"
#include "components/viz/service/display/output_surface_frame.h"
#include "gpu/command_buffer/client/gles2_interface.h"

namespace android_webview {
Expand Down Expand Up @@ -39,7 +39,7 @@ void ParentOutputSurface::Reshape(const gfx::Size& size,
bool has_alpha,
bool use_stencil) {}

void ParentOutputSurface::SwapBuffers(cc::OutputSurfaceFrame frame) {
void ParentOutputSurface::SwapBuffers(viz::OutputSurfaceFrame frame) {
context_provider_->ContextGL()->ShallowFlushCHROMIUM();
}

Expand Down
2 changes: 1 addition & 1 deletion android_webview/browser/parent_output_surface.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class ParentOutputSurface : public viz::OutputSurface {
const gfx::ColorSpace& color_space,
bool has_alpha,
bool use_stencil) override;
void SwapBuffers(cc::OutputSurfaceFrame frame) override;
void SwapBuffers(viz::OutputSurfaceFrame frame) override;
bool HasExternalStencilTest() const override;
void ApplyExternalStencil() override;
uint32_t GetFramebufferCopyTextureFormat() override;
Expand Down
2 changes: 0 additions & 2 deletions cc/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,6 @@ cc_component("cc") {
"output/compositor_frame.h",
"output/compositor_frame_metadata.cc",
"output/compositor_frame_metadata.h",
"output/output_surface_frame.cc",
"output/output_surface_frame.h",
"output/overlay_candidate.cc",
"output/overlay_candidate.h",
"output/software_output_device.cc",
Expand Down
5 changes: 3 additions & 2 deletions cc/test/fake_output_surface.cc
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,9 @@ void FakeOutputSurface::Reshape(const gfx::Size& size,
last_reshape_color_space_ = color_space;
}

void FakeOutputSurface::SwapBuffers(OutputSurfaceFrame frame) {
last_sent_frame_.reset(new OutputSurfaceFrame(std::move(frame)));
void FakeOutputSurface::SwapBuffers(viz::OutputSurfaceFrame frame) {
last_sent_frame_ =
std::make_unique<viz::OutputSurfaceFrame>(std::move(frame));
++num_sent_frames_;

base::ThreadTaskRunnerHandle::Get()->PostTask(
Expand Down
8 changes: 4 additions & 4 deletions cc/test/fake_output_surface.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@
#include "base/logging.h"
#include "base/memory/ptr_util.h"
#include "base/time/time.h"
#include "cc/output/output_surface_frame.h"
#include "cc/output/software_output_device.h"
#include "cc/test/test_context_provider.h"
#include "cc/test/test_gles2_interface.h"
#include "cc/test/test_web_graphics_context_3d.h"
#include "components/viz/common/frame_sinks/begin_frame_args.h"
#include "components/viz/service/display/output_surface.h"
#include "components/viz/service/display/output_surface_frame.h"

namespace cc {

Expand Down Expand Up @@ -53,7 +53,7 @@ class FakeOutputSurface : public viz::OutputSurface {
capabilities_.max_frames_pending = max;
}

OutputSurfaceFrame* last_sent_frame() { return last_sent_frame_.get(); }
viz::OutputSurfaceFrame* last_sent_frame() { return last_sent_frame_.get(); }
size_t num_sent_frames() { return num_sent_frames_; }

viz::OutputSurfaceClient* client() { return client_; }
Expand All @@ -68,7 +68,7 @@ class FakeOutputSurface : public viz::OutputSurface {
const gfx::ColorSpace& color_space,
bool has_alpha,
bool use_stencil) override;
void SwapBuffers(OutputSurfaceFrame frame) override;
void SwapBuffers(viz::OutputSurfaceFrame frame) override;
uint32_t GetFramebufferCopyTextureFormat() override;
bool HasExternalStencilTest() const override;
void ApplyExternalStencil() override {}
Expand Down Expand Up @@ -110,7 +110,7 @@ class FakeOutputSurface : public viz::OutputSurface {
std::unique_ptr<SoftwareOutputDevice> software_device);

viz::OutputSurfaceClient* client_ = nullptr;
std::unique_ptr<OutputSurfaceFrame> last_sent_frame_;
std::unique_ptr<viz::OutputSurfaceFrame> last_sent_frame_;
size_t num_sent_frames_ = 0;
bool has_external_stencil_test_ = false;
bool suspended_for_recycle_ = false;
Expand Down
4 changes: 2 additions & 2 deletions cc/test/pixel_test_output_surface.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@

#include "base/bind.h"
#include "base/threading/thread_task_runner_handle.h"
#include "cc/output/output_surface_frame.h"
#include "components/viz/service/display/output_surface_client.h"
#include "components/viz/service/display/output_surface_frame.h"
#include "gpu/command_buffer/client/gles2_interface.h"
#include "third_party/khronos/GLES2/gl2.h"
#include "ui/gfx/transform.h"
Expand Down Expand Up @@ -69,7 +69,7 @@ bool PixelTestOutputSurface::HasExternalStencilTest() const {

void PixelTestOutputSurface::ApplyExternalStencil() {}

void PixelTestOutputSurface::SwapBuffers(OutputSurfaceFrame frame) {
void PixelTestOutputSurface::SwapBuffers(viz::OutputSurfaceFrame frame) {
base::ThreadTaskRunnerHandle::Get()->PostTask(
FROM_HERE, base::BindOnce(&PixelTestOutputSurface::SwapBuffersCallback,
weak_ptr_factory_.GetWeakPtr()));
Expand Down
2 changes: 1 addition & 1 deletion cc/test/pixel_test_output_surface.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class PixelTestOutputSurface : public viz::OutputSurface {
bool use_stencil) override;
bool HasExternalStencilTest() const override;
void ApplyExternalStencil() override;
void SwapBuffers(OutputSurfaceFrame frame) override;
void SwapBuffers(viz::OutputSurfaceFrame frame) override;
viz::OverlayCandidateValidator* GetOverlayCandidateValidator() const override;
bool IsDisplayedAsOverlayPlane() const override;
unsigned GetOverlayTextureId() const override;
Expand Down
2 changes: 2 additions & 0 deletions components/viz/service/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ viz_component("service") {
"display/output_surface.cc",
"display/output_surface.h",
"display/output_surface_client.h",
"display/output_surface_frame.cc",
"display/output_surface_frame.h",
"display/overlay_candidate_validator.h",
"display/overlay_processor.cc",
"display/overlay_processor.h",
Expand Down
4 changes: 2 additions & 2 deletions components/viz/service/display/gl_renderer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
#include "cc/debug/debug_colors.h"
#include "cc/output/compositor_frame.h"
#include "cc/output/compositor_frame_metadata.h"
#include "cc/output/output_surface_frame.h"
#include "cc/raster/scoped_gpu_raster.h"
#include "cc/resources/resource_pool.h"
#include "cc/resources/scoped_resource.h"
Expand All @@ -46,6 +45,7 @@
#include "components/viz/service/display/dynamic_geometry_binding.h"
#include "components/viz/service/display/layer_quad.h"
#include "components/viz/service/display/output_surface.h"
#include "components/viz/service/display/output_surface_frame.h"
#include "components/viz/service/display/static_geometry_binding.h"
#include "components/viz/service/display/texture_mailbox_deleter.h"
#include "gpu/GLES2/gl2extchromium.h"
Expand Down Expand Up @@ -2732,7 +2732,7 @@ void GLRenderer::SwapBuffers(std::vector<ui::LatencyInfo> latency_info) {

gfx::Size surface_size = surface_size_for_swap_buffers();

cc::OutputSurfaceFrame output_frame;
OutputSurfaceFrame output_frame;
output_frame.latency_info = std::move(latency_info);
output_frame.size = surface_size;
if (use_swap_with_bounds_) {
Expand Down
6 changes: 2 additions & 4 deletions components/viz/service/display/gl_renderer_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1786,10 +1786,8 @@ class MockOutputSurface : public OutputSurface {
MOCK_METHOD0(BindFramebuffer, void());
MOCK_METHOD1(SetDrawRectangle, void(const gfx::Rect&));
MOCK_METHOD0(GetFramebufferCopyTextureFormat, GLenum());
MOCK_METHOD1(SwapBuffers_, void(cc::OutputSurfaceFrame& frame)); // NOLINT
void SwapBuffers(cc::OutputSurfaceFrame frame) override {
SwapBuffers_(frame);
}
MOCK_METHOD1(SwapBuffers_, void(OutputSurfaceFrame& frame)); // NOLINT
void SwapBuffers(OutputSurfaceFrame frame) override { SwapBuffers_(frame); }
MOCK_CONST_METHOD0(GetOverlayCandidateValidator,
OverlayCandidateValidator*());
MOCK_CONST_METHOD0(IsDisplayedAsOverlayPlane, bool());
Expand Down
2 changes: 1 addition & 1 deletion components/viz/service/display/output_surface.cc
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
#include "base/macros.h"
#include "base/threading/thread_task_runner_handle.h"
#include "base/trace_event/trace_event.h"
#include "cc/output/output_surface_frame.h"
#include "components/viz/service/display/output_surface_client.h"
#include "components/viz/service/display/output_surface_frame.h"
#include "gpu/GLES2/gl2extchromium.h"
#include "gpu/command_buffer/client/context_support.h"
#include "gpu/command_buffer/client/gles2_interface.h"
Expand Down
7 changes: 2 additions & 5 deletions components/viz/service/display/output_surface.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,14 @@
#include "gpu/command_buffer/common/texture_in_use_response.h"
#include "ui/gfx/color_space.h"

namespace cc {
class OutputSurfaceFrame;
}

namespace gfx {
class ColorSpace;
class Size;
} // namespace gfx

namespace viz {
class OutputSurfaceClient;
class OutputSurfaceFrame;

// This class represents a platform-independent API for presenting
// buffers to display via GPU or software compositing. Implementations
Expand Down Expand Up @@ -122,7 +119,7 @@ class VIZ_SERVICE_EXPORT OutputSurface {
// Swaps the current backbuffer to the screen. For successful swaps, the
// implementation must call OutputSurfaceClient::DidReceiveSwapBuffersAck()
// after returning from this method in order to unblock the next frame.
virtual void SwapBuffers(cc::OutputSurfaceFrame frame) = 0;
virtual void SwapBuffers(OutputSurfaceFrame frame) = 0;

protected:
struct OutputSurface::Capabilities capabilities_;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "cc/output/output_surface_frame.h"
#include "components/viz/service/display/output_surface_frame.h"

namespace cc {
namespace viz {

OutputSurfaceFrame::OutputSurfaceFrame() = default;

Expand All @@ -15,4 +15,4 @@ OutputSurfaceFrame::~OutputSurfaceFrame() = default;
OutputSurfaceFrame& OutputSurfaceFrame::operator=(OutputSurfaceFrame&& other) =
default;

} // namespace cc
} // namespace viz
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,23 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef CC_OUTPUT_OUTPUT_SURFACE_FRAME_H_
#define CC_OUTPUT_OUTPUT_SURFACE_FRAME_H_
#ifndef COMPONENTS_VIZ_SERVICE_DISPLAY_OUTPUT_SURFACE_FRAME_H_
#define COMPONENTS_VIZ_SERVICE_DISPLAY_OUTPUT_SURFACE_FRAME_H_

#include <vector>

#include "base/macros.h"
#include "base/optional.h"
#include "cc/cc_export.h"
#include "components/viz/service/viz_service_export.h"
#include "ui/gfx/geometry/rect.h"
#include "ui/gfx/geometry/size.h"
#include "ui/latency/latency_info.h"

namespace cc {
namespace viz {

// Metadata given to the OutputSurface for it to swap what was drawn and make
// current frame visible.
class CC_EXPORT OutputSurfaceFrame {
class VIZ_SERVICE_EXPORT OutputSurfaceFrame {
public:
OutputSurfaceFrame();
OutputSurfaceFrame(OutputSurfaceFrame&& other);
Expand All @@ -39,6 +39,6 @@ class CC_EXPORT OutputSurfaceFrame {
DISALLOW_COPY_AND_ASSIGN(OutputSurfaceFrame);
};

} // namespace cc
} // namespace viz

#endif // CC_OUTPUT_OUTPUT_SURFACE_FRAME_H_
#endif // COMPONENTS_VIZ_SERVICE_DISPLAY_OUTPUT_SURFACE_FRAME_H_
4 changes: 2 additions & 2 deletions components/viz/service/display/overlay_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
#include "base/containers/flat_map.h"
#include "base/memory/ptr_util.h"
#include "base/test/scoped_feature_list.h"
#include "cc/output/output_surface_frame.h"
#include "cc/resources/display_resource_provider.h"
#include "cc/resources/layer_tree_resource_provider.h"
#include "cc/test/fake_output_surface_client.h"
Expand All @@ -29,6 +28,7 @@
#include "components/viz/service/display/gl_renderer.h"
#include "components/viz/service/display/output_surface.h"
#include "components/viz/service/display/output_surface_client.h"
#include "components/viz/service/display/output_surface_frame.h"
#include "components/viz/service/display/overlay_candidate_validator.h"
#include "components/viz/service/display/overlay_processor.h"
#include "components/viz/service/display/overlay_strategy_fullscreen.h"
Expand Down Expand Up @@ -198,7 +198,7 @@ class OverlayOutputSurface : public OutputSurface {
const gfx::ColorSpace& color_space,
bool has_alpha,
bool use_stencil) override {}
void SwapBuffers(cc::OutputSurfaceFrame frame) override {}
void SwapBuffers(OutputSurfaceFrame frame) override {}
uint32_t GetFramebufferCopyTextureFormat() override {
// TestContextProvider has no real framebuffer, just use RGB.
return GL_RGB;
Expand Down
4 changes: 2 additions & 2 deletions components/viz/service/display/skia_renderer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
#include "base/trace_event/trace_event.h"
#include "cc/base/math_util.h"
#include "cc/base/render_surface_filters.h"
#include "cc/output/output_surface_frame.h"
#include "cc/resources/scoped_resource.h"
#include "components/viz/common/display/renderer_settings.h"
#include "components/viz/common/quads/copy_output_request.h"
Expand All @@ -19,6 +18,7 @@
#include "components/viz/common/quads/texture_draw_quad.h"
#include "components/viz/common/quads/tile_draw_quad.h"
#include "components/viz/service/display/output_surface.h"
#include "components/viz/service/display/output_surface_frame.h"
#include "gpu/command_buffer/client/gles2_interface.h"
#include "skia/ext/opacity_filter_canvas.h"
#include "third_party/skia/include/core/SkCanvas.h"
Expand Down Expand Up @@ -137,7 +137,7 @@ void SkiaRenderer::FinishDrawingFrame() {
void SkiaRenderer::SwapBuffers(std::vector<ui::LatencyInfo> latency_info) {
DCHECK(visible_);
TRACE_EVENT0("cc,benchmark", "SkiaRenderer::SwapBuffers");
cc::OutputSurfaceFrame output_frame;
OutputSurfaceFrame output_frame;
output_frame.latency_info = std::move(latency_info);
output_frame.size = surface_size_for_swap_buffers();
if (use_swap_with_bounds_) {
Expand Down
4 changes: 2 additions & 2 deletions components/viz/service/display/software_renderer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
#include "base/trace_event/trace_event.h"
#include "cc/base/math_util.h"
#include "cc/base/render_surface_filters.h"
#include "cc/output/output_surface_frame.h"
#include "cc/output/software_output_device.h"
#include "cc/resources/scoped_resource.h"
#include "components/viz/common/display/renderer_settings.h"
Expand All @@ -20,6 +19,7 @@
#include "components/viz/common/quads/texture_draw_quad.h"
#include "components/viz/common/quads/tile_draw_quad.h"
#include "components/viz/service/display/output_surface.h"
#include "components/viz/service/display/output_surface_frame.h"
#include "skia/ext/opacity_filter_canvas.h"
#include "third_party/skia/include/core/SkCanvas.h"
#include "third_party/skia/include/core/SkColor.h"
Expand Down Expand Up @@ -89,7 +89,7 @@ void SoftwareRenderer::FinishDrawingFrame() {
void SoftwareRenderer::SwapBuffers(std::vector<ui::LatencyInfo> latency_info) {
DCHECK(visible_);
TRACE_EVENT0("cc", "SoftwareRenderer::SwapBuffers");
cc::OutputSurfaceFrame output_frame;
OutputSurfaceFrame output_frame;
output_frame.latency_info = std::move(latency_info);
output_surface_->SwapBuffers(std::move(output_frame));
}
Expand Down
4 changes: 2 additions & 2 deletions components/viz/service/display/vulkan_renderer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@

#include "components/viz/service/display/vulkan_renderer.h"

#include "cc/output/output_surface_frame.h"
#include "components/viz/service/display/output_surface.h"
#include "components/viz/service/display/output_surface_frame.h"

namespace viz {

VulkanRenderer::~VulkanRenderer() {}

void VulkanRenderer::SwapBuffers(std::vector<ui::LatencyInfo> latency_info) {
cc::OutputSurfaceFrame output_frame;
OutputSurfaceFrame output_frame;
output_frame.latency_info = std::move(latency_info);
output_surface_->SwapBuffers(std::move(output_frame));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
#include "base/bind.h"
#include "base/memory/ptr_util.h"
#include "base/threading/thread_task_runner_handle.h"
#include "cc/output/output_surface_frame.h"
#include "components/viz/common/frame_sinks/begin_frame_source.h"
#include "components/viz/common/gpu/context_provider.h"
#include "components/viz/service/display/output_surface_client.h"
#include "components/viz/service/display/output_surface_frame.h"
#include "gpu/command_buffer/client/context_support.h"
#include "gpu/command_buffer/client/gles2_interface.h"
#include "ui/gl/gl_utils.h"
Expand Down Expand Up @@ -79,7 +79,7 @@ void DisplayOutputSurface::Reshape(const gfx::Size& size,
gl::GetGLColorSpace(color_space), has_alpha);
}

void DisplayOutputSurface::SwapBuffers(cc::OutputSurfaceFrame frame) {
void DisplayOutputSurface::SwapBuffers(OutputSurfaceFrame frame) {
DCHECK(context_provider_);

if (frame.latency_info.size() > 0)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class DisplayOutputSurface : public OutputSurface {
const gfx::ColorSpace& color_space,
bool has_alpha,
bool use_stencil) override;
void SwapBuffers(cc::OutputSurfaceFrame frame) override;
void SwapBuffers(OutputSurfaceFrame frame) override;
uint32_t GetFramebufferCopyTextureFormat() override;
OverlayCandidateValidator* GetOverlayCandidateValidator() const override;
bool IsDisplayedAsOverlayPlane() const override;
Expand Down
Loading

0 comments on commit d248b33

Please sign in to comment.