Skip to content

Commit

Permalink
Move cc::VideoResourceUpdater to media.
Browse files Browse the repository at this point in the history
This class is used by the media (and blink) code directly to produce
video resources for submission to the viz display compositor.
cc::VideoLayerImpl also uses it for this, but is deprecated and
eventually cc won't use this class at all. So we move it out of cc/ to
the media/ component.

Also satisfies a TODO and moves the SharedBitmapReporter from
viz/common/ to viz/client/ as it is a part of the client library,
and expand on the class comment to explain how to use it more.

[email protected]
TBR=kbr

Bug: 722935
Cq-Include-Trybots: luci.chromium.try:android_optional_gpu_tests_rel;luci.chromium.try:linux_optional_gpu_tests_rel;luci.chromium.try:mac_optional_gpu_tests_rel;luci.chromium.try:win_optional_gpu_tests_rel;master.tryserver.blink:linux_trusty_blink_rel;master.tryserver.chromium.linux:linux_layout_tests_slimming_paint_v2
Change-Id: I5505b56c5fde79df0fe199dc14323fab07c3d292
Reviewed-on: https://chromium-review.googlesource.com/1073788
Commit-Queue: danakj <[email protected]>
Reviewed-by: Ken Rockot <[email protected]>
Reviewed-by: Jeremy Roman <[email protected]>
Reviewed-by: Dale Curtis <[email protected]>
Reviewed-by: Avi Drissman <[email protected]>
Cr-Commit-Position: refs/heads/master@{#562514}
  • Loading branch information
danakj authored and Commit Bot committed May 29, 2018
1 parent 9f14d81 commit dda293b
Show file tree
Hide file tree
Showing 24 changed files with 234 additions and 185 deletions.
6 changes: 1 addition & 5 deletions cc/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -195,8 +195,6 @@ cc_component("cc") {
"resources/ui_resource_manager.h",
"resources/ui_resource_request.cc",
"resources/ui_resource_request.h",
"resources/video_resource_updater.cc",
"resources/video_resource_updater.h",
"scheduler/begin_frame_tracker.cc",
"scheduler/begin_frame_tracker.h",
"scheduler/commit_earlyout_reason.h",
Expand Down Expand Up @@ -372,10 +370,9 @@ cc_component("cc") {
"//gpu/ipc:gl_in_process_context",
"//gpu/skia_bindings:skia_bindings",
"//gpu/vulkan:buildflags",
"//media",
"//media", # For VideoLayerImpl.
"//mojo/public/cpp/bindings:struct_traits",
"//services/metrics/public/cpp:ukm_builders",
"//third_party/libyuv",
"//ui/events:events_base",
"//ui/gfx",
"//ui/gfx/geometry",
Expand Down Expand Up @@ -639,7 +636,6 @@ cc_test("cc_unittests") {
"raster/task_graph_work_queue_unittest.cc",
"raster/texture_compressor_etc1_unittest.cc",
"resources/resource_pool_unittest.cc",
"resources/video_resource_updater_unittest.cc",
"scheduler/compositor_timing_history_unittest.cc",
"scheduler/scheduler_state_machine_unittest.cc",
"scheduler/scheduler_unittest.cc",
Expand Down
3 changes: 2 additions & 1 deletion cc/layers/video_layer_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include "components/viz/common/quads/yuv_video_draw_quad.h"
#include "components/viz/common/resources/single_release_callback.h"
#include "media/base/video_frame.h"
#include "media/renderers/video_resource_updater.h"
#include "ui/gfx/color_space.h"

namespace cc {
Expand Down Expand Up @@ -103,7 +104,7 @@ bool VideoLayerImpl::WillDraw(DrawMode draw_mode,

if (!updater_) {
const LayerTreeSettings& settings = layer_tree_impl()->settings();
updater_ = std::make_unique<VideoResourceUpdater>(
updater_ = std::make_unique<media::VideoResourceUpdater>(
layer_tree_impl()->context_provider(),
layer_tree_impl()->layer_tree_frame_sink(),
layer_tree_impl()->resource_provider(),
Expand Down
4 changes: 2 additions & 2 deletions cc/layers/video_layer_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@
#include "base/macros.h"
#include "cc/cc_export.h"
#include "cc/layers/layer_impl.h"
#include "cc/resources/video_resource_updater.h"
#include "components/viz/common/resources/release_callback.h"
#include "media/base/video_rotation.h"

namespace media {
class VideoFrame;
class VideoResourceUpdater;
}

namespace cc {
Expand Down Expand Up @@ -62,7 +62,7 @@ class CC_EXPORT VideoLayerImpl : public LayerImpl {

media::VideoRotation video_rotation_;

std::unique_ptr<VideoResourceUpdater> updater_;
std::unique_ptr<media::VideoResourceUpdater> updater_;

DISALLOW_COPY_AND_ASSIGN(VideoLayerImpl);
};
Expand Down
2 changes: 1 addition & 1 deletion cc/trees/layer_tree_frame_sink.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@
#include "base/single_thread_task_runner.h"
#include "base/threading/thread_checker.h"
#include "cc/cc_export.h"
#include "components/viz/client/shared_bitmap_reporter.h"
#include "components/viz/common/gpu/context_lost_observer.h"
#include "components/viz/common/gpu/context_provider.h"
#include "components/viz/common/gpu/raster_context_provider.h"
#include "components/viz/common/resources/returned_resource.h"
#include "components/viz/common/resources/shared_bitmap_reporter.h"
#include "gpu/command_buffer/common/texture_in_use_response.h"
#include "ui/gfx/color_space.h"

Expand Down
3 changes: 3 additions & 0 deletions components/viz/client/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,16 @@ viz_component("client") {
"hit_test_data_provider_draw_quad.h",
"local_surface_id_provider.cc",
"local_surface_id_provider.h",
"shared_bitmap_reporter.cc",
"shared_bitmap_reporter.h",
]

defines = [ "VIZ_CLIENT_IMPLEMENTATION" ]

public_deps = [
"//base",
"//components/viz/common",
"//mojo/public/cpp/system",
"//skia",
]
deps = [
Expand Down
1 change: 1 addition & 0 deletions components/viz/client/DEPS
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ include_rules = [
"+gpu/GLES2/gl2extchromium.h",
"+gpu/command_buffer/client",
"+gpu/command_buffer/common",
"+mojo/public/cpp/system/buffer.h",
"+third_party/skia",
"+third_party/khronos/GLES2",

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

#include "components/viz/common/resources/shared_bitmap_reporter.h"
#include "components/viz/client/shared_bitmap_reporter.h"

namespace viz {

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

#ifndef COMPONENTS_VIZ_COMMON_RESOURCES_SHARED_BITMAP_REPORTER_H_
#define COMPONENTS_VIZ_COMMON_RESOURCES_SHARED_BITMAP_REPORTER_H_
#ifndef COMPONENTS_VIZ_CLIENT_SHARED_BITMAP_REPORTER_H_
#define COMPONENTS_VIZ_CLIENT_SHARED_BITMAP_REPORTER_H_

#include "components/viz/client/viz_client_export.h"
#include "components/viz/common/quads/shared_bitmap.h"
#include "components/viz/common/viz_common_export.h"
#include "mojo/public/cpp/system/buffer.h"

namespace viz {

// Used by clients to notify the display compositor about SharedMemory allocated
// for shared bitmaps.
// TODO(kylechar): This should be //components/viz/client but because of deps
// issues that isn't possible. Fix and move there.
class VIZ_COMMON_EXPORT SharedBitmapReporter {
// An interface that can be used for code without a direct connection to the viz
// display compositor, as an intermediary in order to notify the display
// compositor about SharedMemory allocated for shared bitmaps. The
// implementation of this interface would be responsible to passing the
// notifications on to the display compositor via the CompositorFrameSink.
class VIZ_CLIENT_EXPORT SharedBitmapReporter {
public:
// Associates a SharedBitmapId with a shared buffer handle.
virtual void DidAllocateSharedBitmap(mojo::ScopedSharedBufferHandle buffer,
Expand All @@ -31,4 +32,4 @@ class VIZ_COMMON_EXPORT SharedBitmapReporter {

} // namespace viz

#endif // COMPONENTS_VIZ_COMMON_RESOURCES_SHARED_BITMAP_REPORTER_H_
#endif // COMPONENTS_VIZ_CLIENT_SHARED_BITMAP_REPORTER_H_
5 changes: 1 addition & 4 deletions components/viz/common/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,6 @@ viz_component("common") {
"resources/return_callback.h",
"resources/returned_resource.h",
"resources/shared_bitmap_manager.h",
"resources/shared_bitmap_reporter.cc",
"resources/shared_bitmap_reporter.h",
"resources/single_release_callback.cc",
"resources/single_release_callback.h",
"resources/transferable_resource.cc",
Expand Down Expand Up @@ -159,13 +157,12 @@ viz_component("common") {
# cc::MathUtil. Remove it once cc/base/math_util* are moved to viz.
"//cc/base",
"//cc/paint",
"//gpu",
"//gpu/command_buffer/client:gles2_implementation",
"//gpu/command_buffer/client:gles2_interface",
"//gpu/command_buffer/client:raster",
"//gpu/command_buffer/client:raster_interface",
"//gpu/vulkan:buildflags",
"//mojo/public/cpp/bindings",
"//mojo/public/cpp/system",
"//third_party/libyuv",
"//ui/gfx",
"//ui/gfx:color_space",
Expand Down
9 changes: 8 additions & 1 deletion components/viz/common/DEPS
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# Please consult components/viz/README.md about allowable dependencies.

include_rules = [
# Do not use mojo bindings in viz/client/. This library should be agnostic
# about how to communicate with viz.
"-mojo/public/cpp/bindings",
# Exception is struct_traits.h which is used for defining friends only.
"+mojo/public/cpp/bindings/struct_traits.h",
]

specific_include_rules = {
"skia_helper.(cc|h)": [
"+cc/base",
Expand All @@ -12,7 +20,6 @@ specific_include_rules = {
"+gpu/command_buffer/common",
"+gpu/command_buffer/service",
"+gpu/ipc/common",
"+mojo/public/cpp/bindings",
"+third_party/skia",
],
".*_unittest\.cc": [
Expand Down
1 change: 1 addition & 0 deletions components/viz/service/display/DEPS
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ specific_include_rules = {
"+components/viz/service/frame_sinks",
"+components/viz/test",
"+gpu/GLES2",
"+media",
"+third_party/libyuv",
],
}
36 changes: 18 additions & 18 deletions components/viz/service/display/renderer_pixeltest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
#include "cc/base/math_util.h"
#include "cc/paint/paint_flags.h"
#include "cc/paint/skia_paint_canvas.h"
#include "cc/resources/video_resource_updater.h"
#include "cc/test/fake_raster_source.h"
#include "cc/test/fake_recording_source.h"
#include "cc/test/pixel_test.h"
Expand All @@ -29,6 +28,7 @@
#include "components/viz/test/test_shared_bitmap_manager.h"
#include "gpu/command_buffer/client/gles2_interface.h"
#include "media/base/video_frame.h"
#include "media/renderers/video_resource_updater.h"
#include "third_party/skia/include/core/SkColorPriv.h"
#include "third_party/skia/include/core/SkColorSpaceXform.h"
#include "third_party/skia/include/core/SkMatrix.h"
Expand Down Expand Up @@ -346,7 +346,7 @@ void CreateTestYUVVideoDrawQuad_FromVideoFrame(
uint8_t alpha_value,
const gfx::RectF& tex_coord_rect,
RenderPass* render_pass,
cc::VideoResourceUpdater* video_resource_updater,
media::VideoResourceUpdater* video_resource_updater,
const gfx::Rect& rect,
const gfx::Rect& visible_rect,
DisplayResourceProvider* resource_provider,
Expand All @@ -365,11 +365,11 @@ void CreateTestYUVVideoDrawQuad_FromVideoFrame(
video_frame->rows(media::VideoFrame::kAPlane));
}

cc::VideoFrameExternalResources resources =
media::VideoFrameExternalResources resources =
video_resource_updater->CreateExternalResourcesFromVideoFrame(
video_frame);

EXPECT_EQ(cc::VideoFrameResourceType::YUV, resources.type);
EXPECT_EQ(media::VideoFrameResourceType::YUV, resources.type);
EXPECT_EQ(media::VideoFrame::NumPlanes(video_frame->format()),
resources.resources.size());
EXPECT_EQ(media::VideoFrame::NumPlanes(video_frame->format()),
Expand Down Expand Up @@ -465,17 +465,17 @@ void CreateTestY16TextureDrawQuad_FromVideoFrame(
scoped_refptr<media::VideoFrame> video_frame,
const gfx::RectF& tex_coord_rect,
RenderPass* render_pass,
cc::VideoResourceUpdater* video_resource_updater,
media::VideoResourceUpdater* video_resource_updater,
const gfx::Rect& rect,
const gfx::Rect& visible_rect,
DisplayResourceProvider* resource_provider,
ClientResourceProvider* child_resource_provider,
ContextProvider* child_context_provider) {
cc::VideoFrameExternalResources resources =
media::VideoFrameExternalResources resources =
video_resource_updater->CreateExternalResourcesFromVideoFrame(
video_frame);

EXPECT_EQ(cc::VideoFrameResourceType::RGBA, resources.type);
EXPECT_EQ(media::VideoFrameResourceType::RGBA, resources.type);
EXPECT_EQ(1u, resources.resources.size());
EXPECT_EQ(1u, resources.release_callbacks.size());

Expand Down Expand Up @@ -550,7 +550,7 @@ void CreateTestYUVVideoDrawQuad_Striped(
bool highbit,
const gfx::RectF& tex_coord_rect,
RenderPass* render_pass,
cc::VideoResourceUpdater* video_resource_updater,
media::VideoResourceUpdater* video_resource_updater,
const gfx::Rect& rect,
const gfx::Rect& visible_rect,
DisplayResourceProvider* resource_provider,
Expand Down Expand Up @@ -616,7 +616,7 @@ void CreateTestYUVVideoDrawQuad_TwoColor(
uint8_t u_foreground,
uint8_t v_foreground,
RenderPass* render_pass,
cc::VideoResourceUpdater* video_resource_updater,
media::VideoResourceUpdater* video_resource_updater,
DisplayResourceProvider* resource_provider,
ClientResourceProvider* child_resource_provider,
ContextProvider* child_context_provider) {
Expand Down Expand Up @@ -676,7 +676,7 @@ void CreateTestYUVVideoDrawQuad_Solid(
uint8_t u,
uint8_t v,
RenderPass* render_pass,
cc::VideoResourceUpdater* video_resource_updater,
media::VideoResourceUpdater* video_resource_updater,
const gfx::Rect& rect,
const gfx::Rect& visible_rect,
DisplayResourceProvider* resource_provider,
Expand Down Expand Up @@ -715,7 +715,7 @@ void CreateTestYUVVideoDrawQuad_NV12(
uint8_t u,
uint8_t v,
RenderPass* render_pass,
cc::VideoResourceUpdater* video_resource_updater,
media::VideoResourceUpdater* video_resource_updater,
const gfx::Rect& rect,
const gfx::Rect& visible_rect,
DisplayResourceProvider* resource_provider,
Expand Down Expand Up @@ -779,7 +779,7 @@ void CreateTestY16TextureDrawQuad_TwoColor(
uint8_t g_foreground,
uint8_t g_background,
RenderPass* render_pass,
cc::VideoResourceUpdater* video_resource_updater,
media::VideoResourceUpdater* video_resource_updater,
const gfx::Rect& rect,
const gfx::Rect& visible_rect,
const gfx::Rect& foreground_rect,
Expand Down Expand Up @@ -1228,19 +1228,19 @@ class IntersectingQuadGLPixelTest
constexpr bool kUseR16Texture = false;
constexpr int kMaxResourceSize = 10000;

video_resource_updater_ = std::make_unique<cc::VideoResourceUpdater>(
video_resource_updater_ = std::make_unique<media::VideoResourceUpdater>(
this->child_context_provider_.get(), nullptr,
this->child_resource_provider_.get(), kUseStreamVideoDrawQuad,
kUseGpuMemoryBufferResources, kUseR16Texture, kMaxResourceSize);
video_resource_updater2_ = std::make_unique<cc::VideoResourceUpdater>(
video_resource_updater2_ = std::make_unique<media::VideoResourceUpdater>(
this->child_context_provider_.get(), nullptr,
this->child_resource_provider_.get(), kUseStreamVideoDrawQuad,
kUseGpuMemoryBufferResources, kUseR16Texture, kMaxResourceSize);
}

protected:
std::unique_ptr<cc::VideoResourceUpdater> video_resource_updater_;
std::unique_ptr<cc::VideoResourceUpdater> video_resource_updater2_;
std::unique_ptr<media::VideoResourceUpdater> video_resource_updater_;
std::unique_ptr<media::VideoResourceUpdater> video_resource_updater2_;
};

template <typename TypeParam>
Expand Down Expand Up @@ -1583,13 +1583,13 @@ class VideoGLRendererPixelTest : public cc::GLRendererPixelTest {
constexpr bool kUseGpuMemoryBufferResources = false;
constexpr bool kUseR16Texture = false;
constexpr int kMaxResourceSize = 10000;
video_resource_updater_ = std::make_unique<cc::VideoResourceUpdater>(
video_resource_updater_ = std::make_unique<media::VideoResourceUpdater>(
child_context_provider_.get(), nullptr, child_resource_provider_.get(),
kUseStreamVideoDrawQuad, kUseGpuMemoryBufferResources, kUseR16Texture,
kMaxResourceSize);
}

std::unique_ptr<cc::VideoResourceUpdater> video_resource_updater_;
std::unique_ptr<media::VideoResourceUpdater> video_resource_updater_;
};

class VideoGLRendererPixelHiLoTest : public VideoGLRendererPixelTest,
Expand Down
1 change: 1 addition & 0 deletions components/viz/test/DEPS
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ include_rules = [
"+gpu/config/gpu_feature_info.h",
"+gpu/GLES2",
"+gpu/skia_bindings/grcontext_for_gles2_interface.h",
"+media",
"+mojo/public/cpp/bindings",
"+mojo/public/cpp/system",
"+services/viz/privileged/interfaces",
Expand Down
8 changes: 8 additions & 0 deletions media/renderers/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,15 @@ source_set("renderers") {
"video_overlay_factory.h",
"video_renderer_impl.cc",
"video_renderer_impl.h",
"video_resource_updater.cc",
"video_resource_updater.h",
]

deps = [
"//base",
"//cc/base", # For MathUtil.
"//cc/paint",
"//components/viz/client",
"//gpu/command_buffer/client:gles2_interface",
"//gpu/command_buffer/common",
"//media/base",
Expand All @@ -44,6 +48,7 @@ source_set("renderers") {
"//ui/gfx:geometry_skia",
"//ui/gfx:memory_buffer",
"//ui/gfx/geometry",
"//ui/gl",
]

configs += [
Expand All @@ -61,12 +66,15 @@ source_set("unit_tests") {
"paint_canvas_video_renderer_unittest.cc",
"renderer_impl_unittest.cc",
"video_renderer_impl_unittest.cc",
"video_resource_updater_unittest.cc",
]
configs += [ "//media:media_config" ]
deps = [
"//base",
"//base/test:test_support",
"//cc/paint",
"//components/viz/client",
"//components/viz/test:test_support",
"//gpu:test_support",
"//gpu/command_buffer/client:gles2_interface",
"//gpu/command_buffer/common",
Expand Down
Loading

0 comments on commit dda293b

Please sign in to comment.