ae12d53884
Fixes #14327. Backports https://chromium-review.googlesource.com/802574.
1298 lines
62 KiB
Diff
1298 lines
62 KiB
Diff
diff --git a/components/viz/DEPS b/components/viz/DEPS
|
|
index eba179ee3b2f..ce3033f070c1 100644
|
|
--- a/components/viz/DEPS
|
|
+++ b/components/viz/DEPS
|
|
@@ -6,3 +6,9 @@ include_rules = [
|
|
"+ui/base",
|
|
"+ui/gfx",
|
|
]
|
|
+
|
|
+specific_include_rules = {
|
|
+ ".*_(unittest|perftest|fuzzer)\.cc": [
|
|
+ "+components/viz",
|
|
+ ],
|
|
+}
|
|
diff --git a/components/viz/client/DEPS b/components/viz/client/DEPS
|
|
index db90fed94b97..626d4d8b5f11 100644
|
|
--- a/components/viz/client/DEPS
|
|
+++ b/components/viz/client/DEPS
|
|
@@ -14,6 +14,5 @@ include_rules = [
|
|
specific_include_rules = {
|
|
".*unittest\.cc": [
|
|
"+cc/test",
|
|
- "+components/viz/test",
|
|
],
|
|
}
|
|
diff --git a/components/viz/common/DEPS b/components/viz/common/DEPS
|
|
index 7ccd5e03c1eb..8c356af9c666 100644
|
|
--- a/components/viz/common/DEPS
|
|
+++ b/components/viz/common/DEPS
|
|
@@ -24,7 +24,6 @@ specific_include_rules = {
|
|
],
|
|
".*_unittest\.cc": [
|
|
"+cc/test",
|
|
- "+components/viz/test",
|
|
"+gpu/ipc/gl_in_process_context.h",
|
|
"+media/base",
|
|
"+ui/gl",
|
|
diff --git a/components/viz/host/DEPS b/components/viz/host/DEPS
|
|
index 83389e05a389..b9d508f19a49 100644
|
|
--- a/components/viz/host/DEPS
|
|
+++ b/components/viz/host/DEPS
|
|
@@ -24,7 +24,4 @@ specific_include_rules = {
|
|
"+components/viz/service/frame_sinks/frame_sink_manager_impl.h",
|
|
"+components/viz/service/surfaces/surface_manager.h",
|
|
],
|
|
- ".*_unittest\.cc": [
|
|
- "+components/viz/test",
|
|
- ]
|
|
}
|
|
diff --git a/components/viz/host/host_frame_sink_manager_unittest.cc b/components/viz/host/host_frame_sink_manager_unittest.cc
|
|
index f957e388a5c9..0f91e10691be 100644
|
|
--- a/components/viz/host/host_frame_sink_manager_unittest.cc
|
|
+++ b/components/viz/host/host_frame_sink_manager_unittest.cc
|
|
@@ -13,6 +13,7 @@
|
|
#include "components/viz/common/surfaces/frame_sink_id.h"
|
|
#include "components/viz/common/surfaces/surface_id.h"
|
|
#include "components/viz/common/surfaces/surface_info.h"
|
|
+#include "components/viz/service/display_embedder/server_shared_bitmap_manager.h"
|
|
#include "components/viz/service/frame_sinks/compositor_frame_sink_support.h"
|
|
#include "components/viz/service/frame_sinks/frame_sink_manager_impl.h"
|
|
#include "components/viz/service/surfaces/surface_manager.h"
|
|
@@ -69,7 +70,8 @@ struct RootCompositorFrameSinkData {
|
|
// A mock implementation of mojom::FrameSinkManager.
|
|
class MockFrameSinkManagerImpl : public FrameSinkManagerImpl {
|
|
public:
|
|
- MockFrameSinkManagerImpl() = default;
|
|
+ explicit MockFrameSinkManagerImpl(SharedBitmapManager* shared_bitmap_manager)
|
|
+ : FrameSinkManagerImpl(shared_bitmap_manager) {}
|
|
~MockFrameSinkManagerImpl() override = default;
|
|
|
|
// mojom::FrameSinkManager:
|
|
@@ -148,6 +150,7 @@ class HostFrameSinkManagerTestBase : public testing::Test {
|
|
}
|
|
|
|
protected:
|
|
+ ServerSharedBitmapManager shared_bitmap_manager_;
|
|
std::unique_ptr<HostFrameSinkManager> host_manager_;
|
|
std::unique_ptr<testing::NiceMock<MockFrameSinkManagerImpl>> manager_impl_;
|
|
|
|
@@ -171,7 +174,8 @@ class HostFrameSinkManagerLocalTest : public HostFrameSinkManagerTestBase {
|
|
// testing::Test:
|
|
void SetUp() override {
|
|
manager_impl_ =
|
|
- std::make_unique<testing::NiceMock<MockFrameSinkManagerImpl>>();
|
|
+ std::make_unique<testing::NiceMock<MockFrameSinkManagerImpl>>(
|
|
+ &shared_bitmap_manager_);
|
|
host_manager_ = std::make_unique<HostFrameSinkManager>();
|
|
|
|
manager_impl_->SetLocalClient(host_manager_.get());
|
|
@@ -195,7 +199,8 @@ class HostFrameSinkManagerRemoteTest : public HostFrameSinkManagerTestBase {
|
|
DCHECK(!manager_impl_);
|
|
|
|
manager_impl_ =
|
|
- std::make_unique<testing::NiceMock<MockFrameSinkManagerImpl>>();
|
|
+ std::make_unique<testing::NiceMock<MockFrameSinkManagerImpl>>(
|
|
+ &shared_bitmap_manager_);
|
|
|
|
mojom::FrameSinkManagerPtr frame_sink_manager;
|
|
mojom::FrameSinkManagerRequest frame_sink_manager_request =
|
|
diff --git a/components/viz/service/DEPS b/components/viz/service/DEPS
|
|
index 4ec6497057fc..0f76030dfcb0 100644
|
|
--- a/components/viz/service/DEPS
|
|
+++ b/components/viz/service/DEPS
|
|
@@ -12,9 +12,3 @@ include_rules = [
|
|
"+ui/latency",
|
|
"+ui/ozone/public",
|
|
]
|
|
-
|
|
-specific_include_rules = {
|
|
- ".*_unittest\.cc": [
|
|
- "+components/viz/test",
|
|
- ]
|
|
-}
|
|
diff --git a/components/viz/service/display/display_unittest.cc b/components/viz/service/display/display_unittest.cc
|
|
index e0790451dc8a..d71831e15c53 100644
|
|
--- a/components/viz/service/display/display_unittest.cc
|
|
+++ b/components/viz/service/display/display_unittest.cc
|
|
@@ -18,11 +18,11 @@
|
|
#include "components/viz/common/quads/render_pass_draw_quad.h"
|
|
#include "components/viz/common/quads/solid_color_draw_quad.h"
|
|
#include "components/viz/common/quads/surface_draw_quad.h"
|
|
-#include "components/viz/common/resources/shared_bitmap_manager.h"
|
|
#include "components/viz/common/surfaces/frame_sink_id.h"
|
|
#include "components/viz/common/surfaces/parent_local_surface_id_allocator.h"
|
|
#include "components/viz/service/display/display_client.h"
|
|
#include "components/viz/service/display/display_scheduler.h"
|
|
+#include "components/viz/service/display_embedder/server_shared_bitmap_manager.h"
|
|
#include "components/viz/service/frame_sinks/compositor_frame_sink_support.h"
|
|
#include "components/viz/service/frame_sinks/frame_sink_manager_impl.h"
|
|
#include "components/viz/service/surfaces/surface.h"
|
|
@@ -31,7 +31,6 @@
|
|
#include "components/viz/test/fake_output_surface.h"
|
|
#include "components/viz/test/mock_compositor_frame_sink_client.h"
|
|
#include "components/viz/test/test_gles2_interface.h"
|
|
-#include "components/viz/test/test_shared_bitmap_manager.h"
|
|
#include "gpu/GLES2/gl2extchromium.h"
|
|
#include "testing/gmock/include/gmock/gmock.h"
|
|
#include "testing/gtest/include/gtest/gtest.h"
|
|
@@ -97,7 +96,8 @@ class TestDisplayScheduler : public DisplayScheduler {
|
|
class DisplayTest : public testing::Test {
|
|
public:
|
|
DisplayTest()
|
|
- : support_(std::make_unique<CompositorFrameSinkSupport>(
|
|
+ : manager_(&shared_bitmap_manager_),
|
|
+ support_(std::make_unique<CompositorFrameSinkSupport>(
|
|
nullptr,
|
|
&manager_,
|
|
kArbitraryFrameSinkId,
|
|
@@ -186,11 +186,11 @@ class DisplayTest : public testing::Test {
|
|
|
|
void LatencyInfoCapTest(bool over_capacity);
|
|
|
|
+ ServerSharedBitmapManager shared_bitmap_manager_;
|
|
FrameSinkManagerImpl manager_;
|
|
std::unique_ptr<CompositorFrameSinkSupport> support_;
|
|
ParentLocalSurfaceIdAllocator id_allocator_;
|
|
scoped_refptr<base::NullTaskRunner> task_runner_;
|
|
- TestSharedBitmapManager shared_bitmap_manager_;
|
|
std::unique_ptr<BeginFrameSource> begin_frame_source_;
|
|
std::unique_ptr<Display> display_;
|
|
TestSoftwareOutputDevice* software_output_device_ = nullptr;
|
|
diff --git a/components/viz/service/display/surface_aggregator_pixeltest.cc b/components/viz/service/display/surface_aggregator_pixeltest.cc
|
|
index 549191558eaf..493ba4987a0a 100644
|
|
--- a/components/viz/service/display/surface_aggregator_pixeltest.cc
|
|
+++ b/components/viz/service/display/surface_aggregator_pixeltest.cc
|
|
@@ -13,6 +13,7 @@
|
|
#include "components/viz/common/quads/surface_draw_quad.h"
|
|
#include "components/viz/common/surfaces/parent_local_surface_id_allocator.h"
|
|
#include "components/viz/service/display/surface_aggregator.h"
|
|
+#include "components/viz/service/display_embedder/server_shared_bitmap_manager.h"
|
|
#include "components/viz/service/frame_sinks/compositor_frame_sink_support.h"
|
|
#include "components/viz/service/frame_sinks/frame_sink_manager_impl.h"
|
|
#include "components/viz/service/surfaces/surface.h"
|
|
@@ -36,7 +37,8 @@ constexpr bool kNeedsSyncPoints = true;
|
|
class SurfaceAggregatorPixelTest : public cc::RendererPixelTest<GLRenderer> {
|
|
public:
|
|
SurfaceAggregatorPixelTest()
|
|
- : support_(std::make_unique<CompositorFrameSinkSupport>(
|
|
+ : manager_(&shared_bitmap_manager_),
|
|
+ support_(std::make_unique<CompositorFrameSinkSupport>(
|
|
nullptr,
|
|
&manager_,
|
|
kArbitraryRootFrameSinkId,
|
|
@@ -51,6 +53,7 @@ class SurfaceAggregatorPixelTest : public cc::RendererPixelTest<GLRenderer> {
|
|
}
|
|
|
|
protected:
|
|
+ ServerSharedBitmapManager shared_bitmap_manager_;
|
|
FrameSinkManagerImpl manager_;
|
|
ParentLocalSurfaceIdAllocator allocator_;
|
|
std::unique_ptr<CompositorFrameSinkSupport> support_;
|
|
diff --git a/components/viz/service/display_embedder/gpu_display_provider.cc b/components/viz/service/display_embedder/gpu_display_provider.cc
|
|
index 6f8d1ae7d609..27b68891ead9 100644
|
|
--- a/components/viz/service/display_embedder/gpu_display_provider.cc
|
|
+++ b/components/viz/service/display_embedder/gpu_display_provider.cc
|
|
@@ -69,6 +69,7 @@ GpuDisplayProvider::GpuDisplayProvider(
|
|
GpuServiceImpl* gpu_service_impl,
|
|
scoped_refptr<gpu::InProcessCommandBuffer::Service> gpu_service,
|
|
gpu::GpuChannelManager* gpu_channel_manager,
|
|
+ ServerSharedBitmapManager* server_shared_bitmap_manager,
|
|
bool headless,
|
|
bool wait_for_all_pipeline_stages_before_draw)
|
|
: restart_id_(restart_id),
|
|
@@ -79,6 +80,7 @@ GpuDisplayProvider::GpuDisplayProvider(
|
|
std::make_unique<InProcessGpuMemoryBufferManager>(
|
|
gpu_channel_manager)),
|
|
image_factory_(GetImageFactory(gpu_channel_manager)),
|
|
+ server_shared_bitmap_manager_(server_shared_bitmap_manager),
|
|
task_runner_(base::ThreadTaskRunnerHandle::Get()),
|
|
headless_(headless),
|
|
wait_for_all_pipeline_stages_before_draw_(
|
|
@@ -195,7 +197,7 @@ std::unique_ptr<Display> GpuDisplayProvider::CreateDisplay(
|
|
*out_begin_frame_source = std::move(synthetic_begin_frame_source);
|
|
|
|
return std::make_unique<Display>(
|
|
- ServerSharedBitmapManager::current(), renderer_settings, frame_sink_id,
|
|
+ server_shared_bitmap_manager_, renderer_settings, frame_sink_id,
|
|
std::move(output_surface), std::move(scheduler), task_runner_,
|
|
skia_output_surface);
|
|
}
|
|
diff --git a/components/viz/service/display_embedder/gpu_display_provider.h b/components/viz/service/display_embedder/gpu_display_provider.h
|
|
index f714ee18a648..69b46536d378 100644
|
|
--- a/components/viz/service/display_embedder/gpu_display_provider.h
|
|
+++ b/components/viz/service/display_embedder/gpu_display_provider.h
|
|
@@ -32,6 +32,7 @@ namespace viz {
|
|
class Display;
|
|
class ExternalBeginFrameControllerImpl;
|
|
class GpuServiceImpl;
|
|
+class ServerSharedBitmapManager;
|
|
class SoftwareOutputDevice;
|
|
|
|
// In-process implementation of DisplayProvider.
|
|
@@ -42,6 +43,7 @@ class VIZ_SERVICE_EXPORT GpuDisplayProvider : public DisplayProvider {
|
|
GpuServiceImpl* gpu_service_impl,
|
|
scoped_refptr<gpu::InProcessCommandBuffer::Service> gpu_service,
|
|
gpu::GpuChannelManager* gpu_channel_manager,
|
|
+ ServerSharedBitmapManager* server_shared_bitmap_manager,
|
|
bool headless,
|
|
bool wait_for_all_pipeline_stages_before_draw);
|
|
~GpuDisplayProvider() override;
|
|
@@ -68,6 +70,7 @@ class VIZ_SERVICE_EXPORT GpuDisplayProvider : public DisplayProvider {
|
|
gpu::GpuChannelManagerDelegate* const gpu_channel_manager_delegate_;
|
|
std::unique_ptr<gpu::GpuMemoryBufferManager> gpu_memory_buffer_manager_;
|
|
gpu::ImageFactory* const image_factory_;
|
|
+ ServerSharedBitmapManager* const server_shared_bitmap_manager_;
|
|
|
|
#if defined(OS_WIN)
|
|
// Used for software compositing output on Windows.
|
|
diff --git a/components/viz/service/display_embedder/server_shared_bitmap_manager.cc b/components/viz/service/display_embedder/server_shared_bitmap_manager.cc
|
|
index 5e252917bc0f..142131ce2057 100644
|
|
--- a/components/viz/service/display_embedder/server_shared_bitmap_manager.cc
|
|
+++ b/components/viz/service/display_embedder/server_shared_bitmap_manager.cc
|
|
@@ -57,9 +57,6 @@ class ServerSharedBitmap : public SharedBitmap {
|
|
|
|
} // namespace
|
|
|
|
-base::LazyInstance<ServerSharedBitmapManager>::DestructorAtExit
|
|
- g_shared_memory_manager = LAZY_INSTANCE_INITIALIZER;
|
|
-
|
|
ServerSharedBitmapManager::ServerSharedBitmapManager() = default;
|
|
|
|
ServerSharedBitmapManager::~ServerSharedBitmapManager() {
|
|
@@ -68,10 +65,6 @@ ServerSharedBitmapManager::~ServerSharedBitmapManager() {
|
|
DCHECK(handle_map_.empty());
|
|
}
|
|
|
|
-ServerSharedBitmapManager* ServerSharedBitmapManager::current() {
|
|
- return g_shared_memory_manager.Pointer();
|
|
-}
|
|
-
|
|
std::unique_ptr<SharedBitmap> ServerSharedBitmapManager::GetSharedBitmapFromId(
|
|
const gfx::Size& size,
|
|
ResourceFormat format,
|
|
diff --git a/components/viz/service/display_embedder/server_shared_bitmap_manager.h b/components/viz/service/display_embedder/server_shared_bitmap_manager.h
|
|
index 578107358506..6055c3875d80 100644
|
|
--- a/components/viz/service/display_embedder/server_shared_bitmap_manager.h
|
|
+++ b/components/viz/service/display_embedder/server_shared_bitmap_manager.h
|
|
@@ -33,8 +33,6 @@ class VIZ_SERVICE_EXPORT ServerSharedBitmapManager
|
|
ServerSharedBitmapManager();
|
|
~ServerSharedBitmapManager() override;
|
|
|
|
- static ServerSharedBitmapManager* current();
|
|
-
|
|
// SharedBitmapManager implementation.
|
|
std::unique_ptr<SharedBitmap> GetSharedBitmapFromId(
|
|
const gfx::Size& size,
|
|
diff --git a/components/viz/service/frame_sinks/compositor_frame_sink_support.cc b/components/viz/service/frame_sinks/compositor_frame_sink_support.cc
|
|
index a40382267238..fae027adc21a 100644
|
|
--- a/components/viz/service/frame_sinks/compositor_frame_sink_support.cc
|
|
+++ b/components/viz/service/frame_sinks/compositor_frame_sink_support.cc
|
|
@@ -9,9 +9,9 @@
|
|
|
|
#include "components/viz/common/frame_sinks/begin_frame_source.h"
|
|
#include "components/viz/common/quads/compositor_frame.h"
|
|
+#include "components/viz/common/resources/shared_bitmap_manager.h"
|
|
#include "components/viz/common/surfaces/surface_info.h"
|
|
#include "components/viz/service/display/display.h"
|
|
-#include "components/viz/service/display_embedder/server_shared_bitmap_manager.h"
|
|
#include "components/viz/service/frame_sinks/frame_sink_manager_impl.h"
|
|
#include "components/viz/service/surfaces/surface.h"
|
|
#include "components/viz/service/surfaces/surface_reference.h"
|
|
@@ -65,7 +65,7 @@ CompositorFrameSinkSupport::~CompositorFrameSinkSupport() {
|
|
// SharedBitmapId that has been reported from the client. Since the client is
|
|
// gone that memory can be freed. If we don't then it would leak.
|
|
for (const auto& id : owned_bitmaps_)
|
|
- ServerSharedBitmapManager::current()->ChildDeletedSharedBitmap(id);
|
|
+ frame_sink_manager_->shared_bitmap_manager()->ChildDeletedSharedBitmap(id);
|
|
|
|
// No video capture clients should remain after calling
|
|
// UnregisterCompositorFrameSinkSupport().
|
|
@@ -254,7 +254,7 @@ void CompositorFrameSinkSupport::SubmitCompositorFrame(
|
|
bool CompositorFrameSinkSupport::DidAllocateSharedBitmap(
|
|
mojo::ScopedSharedBufferHandle buffer,
|
|
const SharedBitmapId& id) {
|
|
- if (!ServerSharedBitmapManager::current()->ChildAllocatedSharedBitmap(
|
|
+ if (!frame_sink_manager_->shared_bitmap_manager()->ChildAllocatedSharedBitmap(
|
|
std::move(buffer), id))
|
|
return false;
|
|
|
|
@@ -264,7 +264,7 @@ bool CompositorFrameSinkSupport::DidAllocateSharedBitmap(
|
|
|
|
void CompositorFrameSinkSupport::DidDeleteSharedBitmap(
|
|
const SharedBitmapId& id) {
|
|
- ServerSharedBitmapManager::current()->ChildDeletedSharedBitmap(id);
|
|
+ frame_sink_manager_->shared_bitmap_manager()->ChildDeletedSharedBitmap(id);
|
|
owned_bitmaps_.erase(id);
|
|
}
|
|
|
|
diff --git a/components/viz/service/frame_sinks/compositor_frame_sink_support_unittest.cc b/components/viz/service/frame_sinks/compositor_frame_sink_support_unittest.cc
|
|
index 9852c9b2f180..c1a68ede915e 100644
|
|
--- a/components/viz/service/frame_sinks/compositor_frame_sink_support_unittest.cc
|
|
+++ b/components/viz/service/frame_sinks/compositor_frame_sink_support_unittest.cc
|
|
@@ -11,6 +11,7 @@
|
|
#include "components/viz/common/surfaces/frame_sink_id.h"
|
|
#include "components/viz/common/surfaces/surface_id.h"
|
|
#include "components/viz/common/surfaces/surface_info.h"
|
|
+#include "components/viz/service/display_embedder/server_shared_bitmap_manager.h"
|
|
#include "components/viz/service/frame_sinks/frame_sink_manager_impl.h"
|
|
#include "components/viz/test/begin_frame_args_test.h"
|
|
#include "components/viz/test/compositor_frame_helpers.h"
|
|
@@ -81,7 +82,8 @@ class MockFrameSinkManagerClient : public mojom::FrameSinkManagerClient {
|
|
class CompositorFrameSinkSupportTest : public testing::Test {
|
|
public:
|
|
CompositorFrameSinkSupportTest()
|
|
- : begin_frame_source_(0.f, false),
|
|
+ : manager_(&shared_bitmap_manager_),
|
|
+ begin_frame_source_(0.f, false),
|
|
local_surface_id_(3, kArbitraryToken),
|
|
frame_sync_token_(GenTestSyncToken(4)),
|
|
consumer_sync_token_(GenTestSyncToken(5)) {
|
|
@@ -181,6 +183,7 @@ class CompositorFrameSinkSupportTest : public testing::Test {
|
|
}
|
|
|
|
protected:
|
|
+ ServerSharedBitmapManager shared_bitmap_manager_;
|
|
FrameSinkManagerImpl manager_;
|
|
MockFrameSinkManagerClient frame_sink_manager_client_;
|
|
FakeCompositorFrameSinkClient fake_support_client_;
|
|
diff --git a/components/viz/service/frame_sinks/direct_layer_tree_frame_sink_unittest.cc b/components/viz/service/frame_sinks/direct_layer_tree_frame_sink_unittest.cc
|
|
index 26f1c30b4842..4b742b4a1f93 100644
|
|
--- a/components/viz/service/frame_sinks/direct_layer_tree_frame_sink_unittest.cc
|
|
+++ b/components/viz/service/frame_sinks/direct_layer_tree_frame_sink_unittest.cc
|
|
@@ -68,6 +68,7 @@ class DirectLayerTreeFrameSinkTest : public testing::Test {
|
|
task_runner_(new cc::OrderedSimpleTaskRunner(now_src_.get(), true)),
|
|
display_size_(1920, 1080),
|
|
display_rect_(display_size_),
|
|
+ frame_sink_manager_(&bitmap_manager_),
|
|
support_manager_(&frame_sink_manager_),
|
|
context_provider_(TestContextProvider::Create()) {
|
|
auto display_output_surface = FakeOutputSurface::Create3d();
|
|
@@ -130,9 +131,9 @@ class DirectLayerTreeFrameSinkTest : public testing::Test {
|
|
|
|
const gfx::Size display_size_;
|
|
const gfx::Rect display_rect_;
|
|
+ TestSharedBitmapManager bitmap_manager_;
|
|
FrameSinkManagerImpl frame_sink_manager_;
|
|
TestCompositorFrameSinkSupportManager support_manager_;
|
|
- TestSharedBitmapManager bitmap_manager_;
|
|
TestGpuMemoryBufferManager gpu_memory_buffer_manager_;
|
|
|
|
scoped_refptr<TestContextProvider> context_provider_;
|
|
diff --git a/components/viz/service/frame_sinks/frame_sink_manager_impl.cc b/components/viz/service/frame_sinks/frame_sink_manager_impl.cc
|
|
index d01557f46949..bad389a1e18a 100644
|
|
--- a/components/viz/service/frame_sinks/frame_sink_manager_impl.cc
|
|
+++ b/components/viz/service/frame_sinks/frame_sink_manager_impl.cc
|
|
@@ -9,6 +9,7 @@
|
|
|
|
#include "base/logging.h"
|
|
#include "base/metrics/histogram_functions.h"
|
|
+#include "components/viz/common/resources/shared_bitmap_manager.h"
|
|
#include "components/viz/service/display/display.h"
|
|
#include "components/viz/service/display_embedder/display_provider.h"
|
|
#include "components/viz/service/display_embedder/external_begin_frame_controller_impl.h"
|
|
@@ -39,9 +40,11 @@ FrameSinkManagerImpl::FrameSinkSourceMapping::operator=(
|
|
FrameSinkSourceMapping&& other) = default;
|
|
|
|
FrameSinkManagerImpl::FrameSinkManagerImpl(
|
|
+ SharedBitmapManager* shared_bitmap_manager,
|
|
base::Optional<uint32_t> activation_deadline_in_frames,
|
|
DisplayProvider* display_provider)
|
|
- : display_provider_(display_provider),
|
|
+ : shared_bitmap_manager_(shared_bitmap_manager),
|
|
+ display_provider_(display_provider),
|
|
surface_manager_(activation_deadline_in_frames),
|
|
hit_test_manager_(surface_manager()),
|
|
binding_(this) {
|
|
diff --git a/components/viz/service/frame_sinks/frame_sink_manager_impl.h b/components/viz/service/frame_sinks/frame_sink_manager_impl.h
|
|
index 7f2352e93677..edf6b35827d8 100644
|
|
--- a/components/viz/service/frame_sinks/frame_sink_manager_impl.h
|
|
+++ b/components/viz/service/frame_sinks/frame_sink_manager_impl.h
|
|
@@ -37,10 +37,10 @@
|
|
#include "services/viz/public/interfaces/compositing/video_detector_observer.mojom.h"
|
|
|
|
namespace viz {
|
|
-
|
|
class CapturableFrameSink;
|
|
class CompositorFrameSinkSupport;
|
|
class DisplayProvider;
|
|
+class SharedBitmapManager;
|
|
|
|
// FrameSinkManagerImpl manages BeginFrame hierarchy. This is the implementation
|
|
// detail for FrameSinkManagerImpl.
|
|
@@ -50,9 +50,11 @@ class VIZ_SERVICE_EXPORT FrameSinkManagerImpl
|
|
public mojom::FrameSinkManager,
|
|
public HitTestAggregatorDelegate {
|
|
public:
|
|
- FrameSinkManagerImpl(base::Optional<uint32_t> activation_deadline_in_frames =
|
|
- kDefaultActivationDeadlineInFrames,
|
|
- DisplayProvider* display_provider = nullptr);
|
|
+ explicit FrameSinkManagerImpl(
|
|
+ SharedBitmapManager* shared_bitmap_manager,
|
|
+ base::Optional<uint32_t> activation_deadline_in_frames =
|
|
+ kDefaultActivationDeadlineInFrames,
|
|
+ DisplayProvider* display_provider = nullptr);
|
|
~FrameSinkManagerImpl() override;
|
|
|
|
// Binds |this| as a FrameSinkManagerImpl for |request| on |task_runner|. On
|
|
@@ -142,8 +144,10 @@ class VIZ_SERVICE_EXPORT FrameSinkManagerImpl
|
|
BeginFrameSource* GetPrimaryBeginFrameSource();
|
|
|
|
SurfaceManager* surface_manager() { return &surface_manager_; }
|
|
-
|
|
const HitTestManager* hit_test_manager() { return &hit_test_manager_; }
|
|
+ SharedBitmapManager* shared_bitmap_manager() {
|
|
+ return shared_bitmap_manager_;
|
|
+ }
|
|
|
|
void SubmitHitTestRegionList(
|
|
const SurfaceId& surface_id,
|
|
@@ -210,6 +214,9 @@ class VIZ_SERVICE_EXPORT FrameSinkManagerImpl
|
|
bool ChildContains(const FrameSinkId& child_frame_sink_id,
|
|
const FrameSinkId& search_frame_sink_id) const;
|
|
|
|
+ // SharedBitmapManager for the viz display service for receiving software
|
|
+ // resources in CompositorFrameSinks.
|
|
+ SharedBitmapManager* const shared_bitmap_manager_;
|
|
// Provides a Display for CreateRootCompositorFrameSink().
|
|
DisplayProvider* const display_provider_;
|
|
|
|
diff --git a/components/viz/service/frame_sinks/frame_sink_manager_unittest.cc b/components/viz/service/frame_sinks/frame_sink_manager_unittest.cc
|
|
index 3f17acac088a..1fdbc3fb35e6 100644
|
|
--- a/components/viz/service/frame_sinks/frame_sink_manager_unittest.cc
|
|
+++ b/components/viz/service/frame_sinks/frame_sink_manager_unittest.cc
|
|
@@ -12,6 +12,7 @@
|
|
#include "components/viz/common/constants.h"
|
|
#include "components/viz/common/frame_sinks/begin_frame_source.h"
|
|
#include "components/viz/common/surfaces/parent_local_surface_id_allocator.h"
|
|
+#include "components/viz/service/display_embedder/server_shared_bitmap_manager.h"
|
|
#include "components/viz/service/frame_sinks/compositor_frame_sink_support.h"
|
|
#include "components/viz/test/begin_frame_source_test.h"
|
|
#include "components/viz/test/compositor_frame_helpers.h"
|
|
@@ -55,7 +56,9 @@ struct RootCompositorFrameSinkData {
|
|
class FrameSinkManagerTest : public testing::Test {
|
|
public:
|
|
FrameSinkManagerTest()
|
|
- : manager_(kDefaultActivationDeadlineInFrames, &display_provider_) {}
|
|
+ : manager_(&shared_bitmap_manager_,
|
|
+ kDefaultActivationDeadlineInFrames,
|
|
+ &display_provider_) {}
|
|
~FrameSinkManagerTest() override = default;
|
|
|
|
std::unique_ptr<CompositorFrameSinkSupport> CreateCompositorFrameSinkSupport(
|
|
@@ -84,6 +87,7 @@ class FrameSinkManagerTest : public testing::Test {
|
|
}
|
|
|
|
protected:
|
|
+ ServerSharedBitmapManager shared_bitmap_manager_;
|
|
TestDisplayProvider display_provider_;
|
|
FrameSinkManagerImpl manager_;
|
|
};
|
|
diff --git a/components/viz/service/frame_sinks/surface_references_unittest.cc b/components/viz/service/frame_sinks/surface_references_unittest.cc
|
|
index eb69755a3177..e5df8b486541 100644
|
|
--- a/components/viz/service/frame_sinks/surface_references_unittest.cc
|
|
+++ b/components/viz/service/frame_sinks/surface_references_unittest.cc
|
|
@@ -10,6 +10,7 @@
|
|
#include "base/containers/flat_set.h"
|
|
#include "base/test/test_mock_time_task_runner.h"
|
|
#include "components/viz/common/surfaces/surface_id.h"
|
|
+#include "components/viz/service/display_embedder/server_shared_bitmap_manager.h"
|
|
#include "components/viz/service/frame_sinks/compositor_frame_sink_support.h"
|
|
#include "components/viz/service/frame_sinks/frame_sink_manager_impl.h"
|
|
#include "components/viz/service/surfaces/surface.h"
|
|
@@ -126,7 +127,7 @@ class SurfaceReferencesTest : public testing::Test {
|
|
// testing::Test:
|
|
void SetUp() override {
|
|
// Start each test with a fresh SurfaceManager instance.
|
|
- manager_ = std::make_unique<FrameSinkManagerImpl>();
|
|
+ manager_ = std::make_unique<FrameSinkManagerImpl>(&shared_bitmap_manager_);
|
|
frame_sink_manager_client_ =
|
|
std::make_unique<TestFrameSinkManagerClient>(manager_.get());
|
|
manager_->SetLocalClient(frame_sink_manager_client_.get());
|
|
@@ -140,12 +141,13 @@ class SurfaceReferencesTest : public testing::Test {
|
|
scoped_refptr<base::TestMockTimeTaskRunner> task_runner_;
|
|
base::TestMockTimeTaskRunner::ScopedContext scoped_context_;
|
|
|
|
+ ServerSharedBitmapManager shared_bitmap_manager_;
|
|
+ std::unique_ptr<FrameSinkManagerImpl> manager_;
|
|
+ std::unique_ptr<TestFrameSinkManagerClient> frame_sink_manager_client_;
|
|
std::unordered_map<FrameSinkId,
|
|
std::unique_ptr<CompositorFrameSinkSupport>,
|
|
FrameSinkIdHash>
|
|
supports_;
|
|
- std::unique_ptr<FrameSinkManagerImpl> manager_;
|
|
- std::unique_ptr<TestFrameSinkManagerClient> frame_sink_manager_client_;
|
|
};
|
|
|
|
TEST_F(SurfaceReferencesTest, AddReference) {
|
|
diff --git a/components/viz/service/frame_sinks/surface_synchronization_unittest.cc b/components/viz/service/frame_sinks/surface_synchronization_unittest.cc
|
|
index 8b83cea05dd3..36eb4787a071 100644
|
|
--- a/components/viz/service/frame_sinks/surface_synchronization_unittest.cc
|
|
+++ b/components/viz/service/frame_sinks/surface_synchronization_unittest.cc
|
|
@@ -5,6 +5,7 @@
|
|
#include "base/containers/flat_set.h"
|
|
#include "base/test/simple_test_tick_clock.h"
|
|
#include "components/viz/common/surfaces/surface_id.h"
|
|
+#include "components/viz/service/display_embedder/server_shared_bitmap_manager.h"
|
|
#include "components/viz/service/frame_sinks/compositor_frame_sink_support.h"
|
|
#include "components/viz/service/frame_sinks/frame_sink_manager_impl.h"
|
|
#include "components/viz/test/begin_frame_args_test.h"
|
|
@@ -87,7 +88,8 @@ class FakeExternalBeginFrameSourceClient
|
|
class SurfaceSynchronizationTest : public testing::Test {
|
|
public:
|
|
SurfaceSynchronizationTest()
|
|
- : frame_sink_manager_client_(&frame_sink_manager_),
|
|
+ : frame_sink_manager_(&shared_bitmap_manager_),
|
|
+ frame_sink_manager_client_(&frame_sink_manager_),
|
|
surface_observer_(false) {}
|
|
~SurfaceSynchronizationTest() override {}
|
|
|
|
@@ -258,6 +260,7 @@ class SurfaceSynchronizationTest : public testing::Test {
|
|
|
|
private:
|
|
std::unique_ptr<base::SimpleTestTickClock> now_src_;
|
|
+ ServerSharedBitmapManager shared_bitmap_manager_;
|
|
FrameSinkManagerImpl frame_sink_manager_;
|
|
TestFrameSinkManagerClient frame_sink_manager_client_;
|
|
FakeSurfaceObserver surface_observer_;
|
|
diff --git a/components/viz/service/frame_sinks/video_detector_unittest.cc b/components/viz/service/frame_sinks/video_detector_unittest.cc
|
|
index c56d8d49f82a..d7f76b72c88a 100644
|
|
--- a/components/viz/service/frame_sinks/video_detector_unittest.cc
|
|
+++ b/components/viz/service/frame_sinks/video_detector_unittest.cc
|
|
@@ -13,6 +13,7 @@
|
|
#include "components/viz/common/quads/surface_draw_quad.h"
|
|
#include "components/viz/common/surfaces/parent_local_surface_id_allocator.h"
|
|
#include "components/viz/service/display/surface_aggregator.h"
|
|
+#include "components/viz/service/display_embedder/server_shared_bitmap_manager.h"
|
|
#include "components/viz/service/frame_sinks/compositor_frame_sink_support.h"
|
|
#include "components/viz/service/frame_sinks/frame_sink_manager_impl.h"
|
|
#include "components/viz/service/frame_sinks/video_detector.h"
|
|
@@ -74,7 +75,8 @@ class TestObserver : public mojom::VideoDetectorObserver {
|
|
class VideoDetectorTest : public testing::Test {
|
|
public:
|
|
VideoDetectorTest()
|
|
- : surface_aggregator_(frame_sink_manager_.surface_manager(),
|
|
+ : frame_sink_manager_(&shared_bitmap_manager_),
|
|
+ surface_aggregator_(frame_sink_manager_.surface_manager(),
|
|
nullptr,
|
|
false) {}
|
|
|
|
@@ -192,6 +194,7 @@ class VideoDetectorTest : public testing::Test {
|
|
.Build();
|
|
}
|
|
|
|
+ ServerSharedBitmapManager shared_bitmap_manager_;
|
|
FrameSinkManagerImpl frame_sink_manager_;
|
|
FakeCompositorFrameSinkClient frame_sink_client_;
|
|
ParentLocalSurfaceIdAllocator parent_local_surface_id_allocator_;
|
|
diff --git a/components/viz/service/hit_test/hit_test_aggregator_unittest.cc b/components/viz/service/hit_test/hit_test_aggregator_unittest.cc
|
|
index d59985209db2..7e8a966240bd 100644
|
|
--- a/components/viz/service/hit_test/hit_test_aggregator_unittest.cc
|
|
+++ b/components/viz/service/hit_test/hit_test_aggregator_unittest.cc
|
|
@@ -11,6 +11,7 @@
|
|
#include "components/viz/common/surfaces/frame_sink_id.h"
|
|
#include "components/viz/common/surfaces/surface_id.h"
|
|
#include "components/viz/host/host_frame_sink_manager.h"
|
|
+#include "components/viz/service/display_embedder/server_shared_bitmap_manager.h"
|
|
#include "components/viz/service/frame_sinks/compositor_frame_sink_support.h"
|
|
#include "components/viz/service/frame_sinks/frame_sink_manager_impl.h"
|
|
#include "components/viz/service/hit_test/hit_test_aggregator_delegate.h"
|
|
@@ -59,7 +60,8 @@ class TestHostFrameSinkManager : public HostFrameSinkManager {
|
|
|
|
class TestFrameSinkManagerImpl : public FrameSinkManagerImpl {
|
|
public:
|
|
- TestFrameSinkManagerImpl() = default;
|
|
+ explicit TestFrameSinkManagerImpl(SharedBitmapManager* shared_bitmap_manager)
|
|
+ : FrameSinkManagerImpl(shared_bitmap_manager) {}
|
|
~TestFrameSinkManagerImpl() override = default;
|
|
|
|
void SetLocalClient(TestHostFrameSinkManager* client) {
|
|
@@ -112,7 +114,8 @@ class HitTestAggregatorTest : public testing::Test {
|
|
|
|
// testing::Test:
|
|
void SetUp() override {
|
|
- frame_sink_manager_ = std::make_unique<TestFrameSinkManagerImpl>();
|
|
+ frame_sink_manager_ =
|
|
+ std::make_unique<TestFrameSinkManagerImpl>(&shared_bitmap_manager_);
|
|
host_frame_sink_manager_ = std::make_unique<TestHostFrameSinkManager>();
|
|
local_surface_id_lookup_delegate_ =
|
|
std::make_unique<TestLatestLocalSurfaceIdLookupDelegate>();
|
|
@@ -208,6 +211,7 @@ class HitTestAggregatorTest : public testing::Test {
|
|
}
|
|
|
|
private:
|
|
+ ServerSharedBitmapManager shared_bitmap_manager_;
|
|
std::unique_ptr<TestHitTestAggregator> hit_test_aggregator_;
|
|
std::unique_ptr<TestFrameSinkManagerImpl> frame_sink_manager_;
|
|
std::unique_ptr<TestHostFrameSinkManager> host_frame_sink_manager_;
|
|
diff --git a/components/viz/service/hit_test/hit_test_manager_fuzzer.cc b/components/viz/service/hit_test/hit_test_manager_fuzzer.cc
|
|
index 734d626750d8..9b6001433292 100644
|
|
--- a/components/viz/service/hit_test/hit_test_manager_fuzzer.cc
|
|
+++ b/components/viz/service/hit_test/hit_test_manager_fuzzer.cc
|
|
@@ -8,6 +8,7 @@
|
|
|
|
#include "base/command_line.h"
|
|
#include "base/test/fuzzed_data_provider.h"
|
|
+#include "components/viz/service/display_embedder/server_shared_bitmap_manager.h"
|
|
#include "components/viz/service/frame_sinks/compositor_frame_sink_support.h"
|
|
#include "components/viz/service/frame_sinks/frame_sink_manager_impl.h"
|
|
#include "components/viz/service/hit_test/hit_test_aggregator.h"
|
|
@@ -134,7 +135,8 @@ void SubmitHitTestRegionList(
|
|
|
|
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t num_bytes) {
|
|
base::FuzzedDataProvider fuzz(data, num_bytes);
|
|
- viz::FrameSinkManagerImpl frame_sink_manager;
|
|
+ viz::ServerSharedBitmapManager shared_bitmap_manager;
|
|
+ viz::FrameSinkManagerImpl frame_sink_manager(&shared_bitmap_manager);
|
|
viz::TestLatestLocalSurfaceIdLookupDelegate delegate;
|
|
viz::TestLatestLocalSurfaceIdLookupDelegate* lsi_delegate =
|
|
fuzz.ConsumeBool() ? &delegate : nullptr;
|
|
diff --git a/components/viz/service/main/viz_main_impl.cc b/components/viz/service/main/viz_main_impl.cc
|
|
index 72b26afce32d..662034906499 100644
|
|
--- a/components/viz/service/main/viz_main_impl.cc
|
|
+++ b/components/viz/service/main/viz_main_impl.cc
|
|
@@ -12,9 +12,11 @@
|
|
#include "base/power_monitor/power_monitor_device_source.h"
|
|
#include "base/single_thread_task_runner.h"
|
|
#include "base/threading/sequenced_task_runner_handle.h"
|
|
+#include "base/trace_event/memory_dump_manager.h"
|
|
#include "build/build_config.h"
|
|
#include "components/viz/common/switches.h"
|
|
#include "components/viz/service/display_embedder/gpu_display_provider.h"
|
|
+#include "components/viz/service/display_embedder/server_shared_bitmap_manager.h"
|
|
#include "components/viz/service/frame_sinks/frame_sink_manager_impl.h"
|
|
#include "components/viz/service/gl/gpu_service_impl.h"
|
|
#include "gpu/command_buffer/common/activity_flags.h"
|
|
@@ -279,9 +281,14 @@ void VizMainImpl::CreateFrameSinkManagerOnCompositorThread(
|
|
|
|
base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
|
|
|
|
+ server_shared_bitmap_manager_ = std::make_unique<ServerSharedBitmapManager>();
|
|
+ base::trace_event::MemoryDumpManager::GetInstance()->RegisterDumpProvider(
|
|
+ server_shared_bitmap_manager_.get(), "viz::ServerSharedBitmapManager",
|
|
+ base::ThreadTaskRunnerHandle::Get());
|
|
+
|
|
display_provider_ = std::make_unique<GpuDisplayProvider>(
|
|
params->restart_id, gpu_service_.get(), gpu_command_service_,
|
|
- gpu_service_->gpu_channel_manager(),
|
|
+ gpu_service_->gpu_channel_manager(), server_shared_bitmap_manager_.get(),
|
|
command_line->HasSwitch(switches::kHeadless),
|
|
command_line->HasSwitch(switches::kRunAllCompositorStagesBeforeDraw));
|
|
|
|
@@ -291,14 +298,20 @@ void VizMainImpl::CreateFrameSinkManagerOnCompositorThread(
|
|
if (params->use_activation_deadline)
|
|
activation_deadline_in_frames = params->activation_deadline_in_frames;
|
|
frame_sink_manager_ = std::make_unique<FrameSinkManagerImpl>(
|
|
- activation_deadline_in_frames, display_provider_.get());
|
|
+ server_shared_bitmap_manager_.get(), activation_deadline_in_frames,
|
|
+ display_provider_.get());
|
|
frame_sink_manager_->BindAndSetClient(std::move(params->frame_sink_manager),
|
|
nullptr, std::move(client));
|
|
}
|
|
|
|
void VizMainImpl::TearDownOnCompositorThread() {
|
|
+ base::trace_event::MemoryDumpManager::GetInstance()->UnregisterDumpProvider(
|
|
+ server_shared_bitmap_manager_.get());
|
|
+
|
|
frame_sink_manager_.reset();
|
|
display_provider_.reset();
|
|
+
|
|
+ server_shared_bitmap_manager_.reset();
|
|
}
|
|
|
|
void VizMainImpl::PreSandboxStartup() {
|
|
diff --git a/components/viz/service/main/viz_main_impl.h b/components/viz/service/main/viz_main_impl.h
|
|
index 8bb8e2be1643..48e12c66da18 100644
|
|
--- a/components/viz/service/main/viz_main_impl.h
|
|
+++ b/components/viz/service/main/viz_main_impl.h
|
|
@@ -33,6 +33,7 @@ namespace viz {
|
|
class DisplayProvider;
|
|
class FrameSinkManagerImpl;
|
|
class GpuServiceImpl;
|
|
+class ServerSharedBitmapManager;
|
|
|
|
class VizMainImpl : public gpu::GpuSandboxHelper, public mojom::VizMain {
|
|
public:
|
|
@@ -149,8 +150,9 @@ class VizMainImpl : public gpu::GpuSandboxHelper, public mojom::VizMain {
|
|
|
|
// Provides mojo interfaces for creating and managing FrameSinks. These live
|
|
// on the compositor thread.
|
|
- std::unique_ptr<FrameSinkManagerImpl> frame_sink_manager_;
|
|
+ std::unique_ptr<ServerSharedBitmapManager> server_shared_bitmap_manager_;
|
|
std::unique_ptr<DisplayProvider> display_provider_;
|
|
+ std::unique_ptr<FrameSinkManagerImpl> frame_sink_manager_;
|
|
|
|
const scoped_refptr<base::SingleThreadTaskRunner> gpu_thread_task_runner_;
|
|
|
|
diff --git a/components/viz/service/surfaces/surface_hittest_unittest.cc b/components/viz/service/surfaces/surface_hittest_unittest.cc
|
|
index ea2e4788e7d8..d9cd05c3d9e4 100644
|
|
--- a/components/viz/service/surfaces/surface_hittest_unittest.cc
|
|
+++ b/components/viz/service/surfaces/surface_hittest_unittest.cc
|
|
@@ -6,6 +6,7 @@
|
|
|
|
#include "components/viz/common/quads/compositor_frame.h"
|
|
#include "components/viz/common/surfaces/parent_local_surface_id_allocator.h"
|
|
+#include "components/viz/service/display_embedder/server_shared_bitmap_manager.h"
|
|
#include "components/viz/service/frame_sinks/compositor_frame_sink_support.h"
|
|
#include "components/viz/service/frame_sinks/frame_sink_manager_impl.h"
|
|
#include "components/viz/service/surfaces/surface.h"
|
|
@@ -70,7 +71,7 @@ using namespace test;
|
|
|
|
class SurfaceHittestTest : public testing::Test {
|
|
public:
|
|
- SurfaceHittestTest() = default;
|
|
+ SurfaceHittestTest() : frame_sink_manager_(&shared_bitmap_manager_) {}
|
|
~SurfaceHittestTest() override = default;
|
|
|
|
CompositorFrameSinkSupport& root_support() { return *supports_[0]; }
|
|
@@ -96,6 +97,7 @@ class SurfaceHittestTest : public testing::Test {
|
|
void TearDown() override { supports_.clear(); }
|
|
|
|
private:
|
|
+ ServerSharedBitmapManager shared_bitmap_manager_;
|
|
FrameSinkManagerImpl frame_sink_manager_;
|
|
std::vector<std::unique_ptr<CompositorFrameSinkSupport>> supports_;
|
|
FakeCompositorFrameSinkClient client_;
|
|
diff --git a/components/viz/service/surfaces/surface_unittest.cc b/components/viz/service/surfaces/surface_unittest.cc
|
|
index fb4bb3cd7777..c1d55fdfa622 100644
|
|
--- a/components/viz/service/surfaces/surface_unittest.cc
|
|
+++ b/components/viz/service/surfaces/surface_unittest.cc
|
|
@@ -6,6 +6,7 @@
|
|
#include "cc/test/scheduler_test_common.h"
|
|
#include "components/viz/common/frame_sinks/copy_output_result.h"
|
|
#include "components/viz/common/surfaces/parent_local_surface_id_allocator.h"
|
|
+#include "components/viz/service/display_embedder/server_shared_bitmap_manager.h"
|
|
#include "components/viz/service/frame_sinks/compositor_frame_sink_support.h"
|
|
#include "components/viz/service/frame_sinks/frame_sink_manager_impl.h"
|
|
#include "components/viz/service/surfaces/surface_dependency_tracker.h"
|
|
@@ -28,7 +29,8 @@ TEST(SurfaceTest, PresentationCallback) {
|
|
constexpr gfx::Rect kDamageRect(0, 0);
|
|
const LocalSurfaceId local_surface_id(6, base::UnguessableToken::Create());
|
|
|
|
- FrameSinkManagerImpl frame_sink_manager;
|
|
+ ServerSharedBitmapManager shared_bitmap_manager;
|
|
+ FrameSinkManagerImpl frame_sink_manager(&shared_bitmap_manager);
|
|
MockCompositorFrameSinkClient client;
|
|
auto support = std::make_unique<CompositorFrameSinkSupport>(
|
|
&client, &frame_sink_manager, kArbitraryFrameSinkId, kIsRoot,
|
|
@@ -78,7 +80,8 @@ void TestCopyResultCallback(bool* called,
|
|
// Test that CopyOutputRequests can outlive the current frame and be
|
|
// aggregated on the next frame.
|
|
TEST(SurfaceTest, CopyRequestLifetime) {
|
|
- FrameSinkManagerImpl frame_sink_manager;
|
|
+ ServerSharedBitmapManager shared_bitmap_manager;
|
|
+ FrameSinkManagerImpl frame_sink_manager(&shared_bitmap_manager);
|
|
SurfaceManager* surface_manager = frame_sink_manager.surface_manager();
|
|
auto support = std::make_unique<CompositorFrameSinkSupport>(
|
|
nullptr, &frame_sink_manager, kArbitraryFrameSinkId, kIsRoot,
|
|
diff --git a/components/viz/test/test_layer_tree_frame_sink.cc b/components/viz/test/test_layer_tree_frame_sink.cc
|
|
index 14e1c74a9e88..932cfb499826 100644
|
|
--- a/components/viz/test/test_layer_tree_frame_sink.cc
|
|
+++ b/components/viz/test/test_layer_tree_frame_sink.cc
|
|
@@ -73,7 +73,8 @@ bool TestLayerTreeFrameSink::BindToClient(
|
|
if (!LayerTreeFrameSink::BindToClient(client))
|
|
return false;
|
|
|
|
- frame_sink_manager_ = std::make_unique<FrameSinkManagerImpl>();
|
|
+ frame_sink_manager_ =
|
|
+ std::make_unique<FrameSinkManagerImpl>(&shared_bitmap_manager_);
|
|
|
|
std::unique_ptr<OutputSurface> display_output_surface =
|
|
test_client_->CreateDisplayOutputSurface(context_provider());
|
|
diff --git a/content/browser/browser_main_loop.cc b/content/browser/browser_main_loop.cc
|
|
index c17b467f2140..6ac229f6ba79 100644
|
|
--- a/content/browser/browser_main_loop.cc
|
|
+++ b/content/browser/browser_main_loop.cc
|
|
@@ -750,9 +750,13 @@ void BrowserMainLoop::PostMainMessageLoopStart() {
|
|
|
|
// Enable memory-infra dump providers.
|
|
InitSkiaEventTracer();
|
|
- base::trace_event::MemoryDumpManager::GetInstance()->RegisterDumpProvider(
|
|
- viz::ServerSharedBitmapManager::current(),
|
|
- "viz::ServerSharedBitmapManager", nullptr);
|
|
+#if !defined(OS_ANDROID)
|
|
+ if (server_shared_bitmap_manager_) {
|
|
+ base::trace_event::MemoryDumpManager::GetInstance()->RegisterDumpProvider(
|
|
+ server_shared_bitmap_manager_.get(), "viz::ServerSharedBitmapManager",
|
|
+ nullptr);
|
|
+ }
|
|
+#endif
|
|
base::trace_event::MemoryDumpManager::GetInstance()->RegisterDumpProvider(
|
|
skia::SkiaMemoryDumpProvider::GetInstance(), "Skia", nullptr);
|
|
base::trace_event::MemoryDumpManager::GetInstance()->RegisterDumpProvider(
|
|
@@ -1055,6 +1059,7 @@ void BrowserMainLoop::ShutdownThreadsAndCleanUp() {
|
|
host_frame_sink_manager_.reset();
|
|
frame_sink_manager_impl_.reset();
|
|
compositing_mode_reporter_impl_.reset();
|
|
+ server_shared_bitmap_manager_.reset();
|
|
#endif
|
|
|
|
// The device monitors are using |system_monitor_| as dependency, so delete
|
|
@@ -1150,6 +1155,11 @@ base::SequencedTaskRunner* BrowserMainLoop::audio_service_runner() {
|
|
viz::FrameSinkManagerImpl* BrowserMainLoop::GetFrameSinkManager() const {
|
|
return frame_sink_manager_impl_.get();
|
|
}
|
|
+
|
|
+viz::ServerSharedBitmapManager* BrowserMainLoop::GetServerSharedBitmapManager()
|
|
+ const {
|
|
+ return server_shared_bitmap_manager_.get();
|
|
+}
|
|
#endif
|
|
|
|
void BrowserMainLoop::GetCompositingModeReporter(
|
|
@@ -1267,17 +1277,20 @@ int BrowserMainLoop::BrowserThreadsStarted() {
|
|
transport_factory->ConnectHostFrameSinkManager();
|
|
ImageTransportFactory::SetFactory(std::move(transport_factory));
|
|
} else {
|
|
+ server_shared_bitmap_manager_ =
|
|
+ std::make_unique<viz::ServerSharedBitmapManager>();
|
|
frame_sink_manager_impl_ = std::make_unique<viz::FrameSinkManagerImpl>(
|
|
+ server_shared_bitmap_manager_.get(),
|
|
switches::GetDeadlineToSynchronizeSurfaces());
|
|
|
|
surface_utils::ConnectWithLocalFrameSinkManager(
|
|
host_frame_sink_manager_.get(), frame_sink_manager_impl_.get());
|
|
|
|
-
|
|
ImageTransportFactory::SetFactory(
|
|
std::make_unique<GpuProcessTransportFactory>(
|
|
BrowserGpuChannelHostFactory::instance(),
|
|
- compositing_mode_reporter_impl_.get(), GetResizeTaskRunner()));
|
|
+ compositing_mode_reporter_impl_.get(),
|
|
+ server_shared_bitmap_manager_.get(), GetResizeTaskRunner()));
|
|
}
|
|
}
|
|
|
|
diff --git a/content/browser/browser_main_loop.h b/content/browser/browser_main_loop.h
|
|
index f117bf39fa7b..572bfdcda6ab 100644
|
|
--- a/content/browser/browser_main_loop.h
|
|
+++ b/content/browser/browser_main_loop.h
|
|
@@ -91,6 +91,7 @@ namespace viz {
|
|
class CompositingModeReporterImpl;
|
|
class FrameSinkManagerImpl;
|
|
class HostFrameSinkManager;
|
|
+class ServerSharedBitmapManager;
|
|
}
|
|
|
|
namespace content {
|
|
@@ -217,6 +218,9 @@ class CONTENT_EXPORT BrowserMainLoop {
|
|
// TODO(crbug.com/657959): This will be removed once there are no users, as
|
|
// SurfaceManager is being moved out of process.
|
|
viz::FrameSinkManagerImpl* GetFrameSinkManager() const;
|
|
+
|
|
+ // This returns null when the display compositor is out of process.
|
|
+ viz::ServerSharedBitmapManager* GetServerSharedBitmapManager() const;
|
|
#endif
|
|
|
|
// Fulfills a mojo pointer to the singleton CompositingModeReporter.
|
|
@@ -384,6 +388,11 @@ class CONTENT_EXPORT BrowserMainLoop {
|
|
scoped_refptr<SaveFileManager> save_file_manager_;
|
|
std::unique_ptr<content::TracingControllerImpl> tracing_controller_;
|
|
#if !defined(OS_ANDROID)
|
|
+ // A SharedBitmapManager used to sharing and mapping IDs to shared memory
|
|
+ // between processes for software compositing. When the display compositor is
|
|
+ // in the browser process, then |server_shared_bitmap_manager_| is set, and
|
|
+ // when it is in the viz process, then it is null.
|
|
+ std::unique_ptr<viz::ServerSharedBitmapManager> server_shared_bitmap_manager_;
|
|
std::unique_ptr<viz::HostFrameSinkManager> host_frame_sink_manager_;
|
|
// This is owned here so that SurfaceManager will be accessible in process
|
|
// when display is in the same process. Other than using SurfaceManager,
|
|
diff --git a/content/browser/compositor/gpu_process_transport_factory.cc b/content/browser/compositor/gpu_process_transport_factory.cc
|
|
index d90a276fc0e1..f0db9d11ce10 100644
|
|
--- a/content/browser/compositor/gpu_process_transport_factory.cc
|
|
+++ b/content/browser/compositor/gpu_process_transport_factory.cc
|
|
@@ -178,6 +178,7 @@ struct GpuProcessTransportFactory::PerCompositorData {
|
|
GpuProcessTransportFactory::GpuProcessTransportFactory(
|
|
gpu::GpuChannelEstablishFactory* gpu_channel_factory,
|
|
viz::CompositingModeReporterImpl* compositing_mode_reporter,
|
|
+ viz::ServerSharedBitmapManager* server_shared_bitmap_manager,
|
|
scoped_refptr<base::SingleThreadTaskRunner> resize_task_runner)
|
|
: frame_sink_id_allocator_(kDefaultClientId),
|
|
renderer_settings_(viz::CreateRendererSettings()),
|
|
@@ -185,6 +186,7 @@ GpuProcessTransportFactory::GpuProcessTransportFactory(
|
|
task_graph_runner_(new cc::SingleThreadTaskGraphRunner),
|
|
gpu_channel_factory_(gpu_channel_factory),
|
|
compositing_mode_reporter_(compositing_mode_reporter),
|
|
+ server_shared_bitmap_manager_(server_shared_bitmap_manager),
|
|
callback_factory_(this) {
|
|
DCHECK(gpu_channel_factory_);
|
|
cc::SetClientNameForMetrics("Browser");
|
|
@@ -641,7 +643,7 @@ void GpuProcessTransportFactory::EstablishedGpuChannel(
|
|
|
|
// The Display owns and uses the |display_output_surface| created above.
|
|
data->display = std::make_unique<viz::Display>(
|
|
- viz::ServerSharedBitmapManager::current(), renderer_settings_,
|
|
+ server_shared_bitmap_manager_, renderer_settings_,
|
|
compositor->frame_sink_id(), std::move(display_output_surface),
|
|
std::move(scheduler), compositor->task_runner());
|
|
data->display_client =
|
|
diff --git a/content/browser/compositor/gpu_process_transport_factory.h b/content/browser/compositor/gpu_process_transport_factory.h
|
|
index 02c1ec0d59bd..2ea8c9f4162e 100644
|
|
--- a/content/browser/compositor/gpu_process_transport_factory.h
|
|
+++ b/content/browser/compositor/gpu_process_transport_factory.h
|
|
@@ -47,6 +47,7 @@ class ContextProviderCommandBuffer;
|
|
namespace viz {
|
|
class CompositingModeReporterImpl;
|
|
class OutputDeviceBacking;
|
|
+class ServerSharedBitmapManager;
|
|
class SoftwareOutputDevice;
|
|
class VulkanInProcessContextProvider;
|
|
class RasterContextProvider;
|
|
@@ -62,6 +63,7 @@ class GpuProcessTransportFactory : public ui::ContextFactory,
|
|
GpuProcessTransportFactory(
|
|
gpu::GpuChannelEstablishFactory* gpu_channel_factory,
|
|
viz::CompositingModeReporterImpl* compositing_mode_reporter,
|
|
+ viz::ServerSharedBitmapManager* server_shared_bitmap_manager,
|
|
scoped_refptr<base::SingleThreadTaskRunner> resize_task_runner);
|
|
|
|
~GpuProcessTransportFactory() override;
|
|
@@ -180,6 +182,8 @@ class GpuProcessTransportFactory : public ui::ContextFactory,
|
|
// Service-side impl that controls the compositing mode based on what mode the
|
|
// display compositors are using.
|
|
viz::CompositingModeReporterImpl* const compositing_mode_reporter_;
|
|
+ // Manages a mapping of SharedBitmapId to shared memory objects.
|
|
+ viz::ServerSharedBitmapManager* const server_shared_bitmap_manager_;
|
|
|
|
base::WeakPtrFactory<GpuProcessTransportFactory> callback_factory_;
|
|
|
|
diff --git a/content/browser/compositor/test/test_image_transport_factory.cc b/content/browser/compositor/test/test_image_transport_factory.cc
|
|
index 037a51961140..cb6f07bdc3e0 100644
|
|
--- a/content/browser/compositor/test/test_image_transport_factory.cc
|
|
+++ b/content/browser/compositor/test/test_image_transport_factory.cc
|
|
@@ -9,6 +9,7 @@
|
|
|
|
#include "components/viz/common/features.h"
|
|
#include "components/viz/common/gl_helper.h"
|
|
+#include "components/viz/service/display_embedder/server_shared_bitmap_manager.h"
|
|
#include "components/viz/service/frame_sinks/frame_sink_manager_impl.h"
|
|
#include "components/viz/test/test_frame_sink_manager.h"
|
|
#include "content/browser/compositor/surface_utils.h"
|
|
@@ -61,7 +62,9 @@ TestImageTransportFactory::TestImageTransportFactory()
|
|
std::move(frame_sink_manager_request),
|
|
std::move(frame_sink_manager_client));
|
|
} else {
|
|
- frame_sink_manager_impl_ = std::make_unique<viz::FrameSinkManagerImpl>();
|
|
+ shared_bitmap_manager_ = std::make_unique<viz::ServerSharedBitmapManager>();
|
|
+ frame_sink_manager_impl_ = std::make_unique<viz::FrameSinkManagerImpl>(
|
|
+ shared_bitmap_manager_.get());
|
|
surface_utils::ConnectWithLocalFrameSinkManager(
|
|
&host_frame_sink_manager_, frame_sink_manager_impl_.get());
|
|
}
|
|
diff --git a/content/browser/compositor/test/test_image_transport_factory.h b/content/browser/compositor/test/test_image_transport_factory.h
|
|
index 76196cee2e27..1cd245d0a01a 100644
|
|
--- a/content/browser/compositor/test/test_image_transport_factory.h
|
|
+++ b/content/browser/compositor/test/test_image_transport_factory.h
|
|
@@ -23,6 +23,7 @@
|
|
namespace viz {
|
|
class GLHelper;
|
|
class FrameSinkManagerImpl;
|
|
+class ServerSharedBitmapManager;
|
|
class TestFrameSinkManagerImpl;
|
|
} // namespace viz
|
|
|
|
@@ -98,6 +99,7 @@ class TestImageTransportFactory : public ui::ContextFactory,
|
|
viz::HostFrameSinkManager host_frame_sink_manager_;
|
|
|
|
// Objects that exist if |enable_viz_| is false.
|
|
+ std::unique_ptr<viz::ServerSharedBitmapManager> shared_bitmap_manager_;
|
|
std::unique_ptr<viz::FrameSinkManagerImpl> frame_sink_manager_impl_;
|
|
std::unique_ptr<viz::GLHelper> gl_helper_;
|
|
|
|
diff --git a/content/browser/renderer_host/compositor_impl_android.cc b/content/browser/renderer_host/compositor_impl_android.cc
|
|
index d2f18a562af3..85e4d4b5c1df 100644
|
|
--- a/content/browser/renderer_host/compositor_impl_android.cc
|
|
+++ b/content/browser/renderer_host/compositor_impl_android.cc
|
|
@@ -174,7 +174,10 @@ class CompositorDependencies {
|
|
bool enable_viz =
|
|
base::FeatureList::IsEnabled(features::kVizDisplayCompositor);
|
|
if (!enable_viz) {
|
|
- frame_sink_manager_impl = std::make_unique<viz::FrameSinkManagerImpl>();
|
|
+ // The SharedBitmapManager can be null as software compositing is not
|
|
+ // supported or used on Android.
|
|
+ frame_sink_manager_impl = std::make_unique<viz::FrameSinkManagerImpl>(
|
|
+ /*shared_bitmap_manager=*/nullptr);
|
|
surface_utils::ConnectWithLocalFrameSinkManager(
|
|
&host_frame_sink_manager, frame_sink_manager_impl.get());
|
|
}
|
|
@@ -1008,9 +1011,8 @@ void CompositorImpl::InitializeDisplay(
|
|
const bool should_register_begin_frame_source = !display_;
|
|
|
|
display_ = std::make_unique<viz::Display>(
|
|
- viz::ServerSharedBitmapManager::current(), renderer_settings,
|
|
- frame_sink_id_, std::move(display_output_surface), std::move(scheduler),
|
|
- task_runner);
|
|
+ nullptr, renderer_settings, frame_sink_id_,
|
|
+ std::move(display_output_surface), std::move(scheduler), task_runner);
|
|
|
|
auto layer_tree_frame_sink = std::make_unique<viz::DirectLayerTreeFrameSink>(
|
|
frame_sink_id_, GetHostFrameSinkManager(), manager, display_.get(),
|
|
diff --git a/content/browser/renderer_host/embedded_frame_sink_provider_impl_unittest.cc b/content/browser/renderer_host/embedded_frame_sink_provider_impl_unittest.cc
|
|
index 02999045b0b3..71073a5ff02d 100644
|
|
--- a/content/browser/renderer_host/embedded_frame_sink_provider_impl_unittest.cc
|
|
+++ b/content/browser/renderer_host/embedded_frame_sink_provider_impl_unittest.cc
|
|
@@ -13,6 +13,7 @@
|
|
#include "build/build_config.h"
|
|
#include "components/viz/common/quads/compositor_frame.h"
|
|
#include "components/viz/host/host_frame_sink_manager.h"
|
|
+#include "components/viz/service/display_embedder/server_shared_bitmap_manager.h"
|
|
#include "components/viz/service/frame_sinks/frame_sink_manager_impl.h"
|
|
#include "components/viz/test/compositor_frame_helpers.h"
|
|
#include "components/viz/test/fake_host_frame_sink_client.h"
|
|
@@ -119,7 +120,8 @@ class EmbeddedFrameSinkProviderImplTest : public testing::Test {
|
|
host_frame_sink_manager_ = std::make_unique<viz::HostFrameSinkManager>();
|
|
|
|
// The FrameSinkManagerImpl implementation is in-process here for tests.
|
|
- frame_sink_manager_ = std::make_unique<viz::FrameSinkManagerImpl>();
|
|
+ frame_sink_manager_ =
|
|
+ std::make_unique<viz::FrameSinkManagerImpl>(&shared_bitmap_manager_);
|
|
surface_utils::ConnectWithLocalFrameSinkManager(
|
|
host_frame_sink_manager_.get(), frame_sink_manager_.get());
|
|
|
|
@@ -140,6 +142,7 @@ class EmbeddedFrameSinkProviderImplTest : public testing::Test {
|
|
// A MessageLoop is required for mojo bindings which are used to
|
|
// connect to graphics services.
|
|
base::MessageLoop message_loop_;
|
|
+ viz::ServerSharedBitmapManager shared_bitmap_manager_;
|
|
viz::FakeHostFrameSinkClient host_frame_sink_client_;
|
|
std::unique_ptr<viz::HostFrameSinkManager> host_frame_sink_manager_;
|
|
std::unique_ptr<viz::FrameSinkManagerImpl> frame_sink_manager_;
|
|
diff --git a/content/browser/renderer_host/render_widget_host_impl.cc b/content/browser/renderer_host/render_widget_host_impl.cc
|
|
index 2efe7a5c7de9..856dc18181f1 100644
|
|
--- a/content/browser/renderer_host/render_widget_host_impl.cc
|
|
+++ b/content/browser/renderer_host/render_widget_host_impl.cc
|
|
@@ -421,6 +421,17 @@ RenderWidgetHostImpl::RenderWidgetHostImpl(RenderWidgetHostDelegate* delegate,
|
|
enable_surface_synchronization_ = features::IsSurfaceSynchronizationEnabled();
|
|
enable_viz_ = base::FeatureList::IsEnabled(features::kVizDisplayCompositor);
|
|
|
|
+ if (!enable_viz_) {
|
|
+#if !defined(OS_ANDROID)
|
|
+ // Software compositing is not supported or used on Android.
|
|
+ //
|
|
+ // The BrowserMainLoop is null in unit tests, but they do not use
|
|
+ // compositing and report SharedBitmapIds.
|
|
+ if (BrowserMainLoop* main_loop = BrowserMainLoop::GetInstance())
|
|
+ shared_bitmap_manager_ = main_loop->GetServerSharedBitmapManager();
|
|
+#endif
|
|
+ }
|
|
+
|
|
delegate_->RenderWidgetCreated(this);
|
|
render_frame_metadata_provider_.AddObserver(this);
|
|
}
|
|
@@ -1991,8 +2002,15 @@ void RenderWidgetHostImpl::Destroy(bool also_delete) {
|
|
// The display compositor has ownership of shared memory for each
|
|
// SharedBitmapId that has been reported from the client. Since the client is
|
|
// gone that memory can be freed. If we don't then it would leak.
|
|
- for (const auto& id : owned_bitmaps_)
|
|
- viz::ServerSharedBitmapManager::current()->ChildDeletedSharedBitmap(id);
|
|
+ if (shared_bitmap_manager_) {
|
|
+ for (const auto& id : owned_bitmaps_)
|
|
+ shared_bitmap_manager_->ChildDeletedSharedBitmap(id);
|
|
+ } else {
|
|
+ // If the display compositor is not in the browser process, then the
|
|
+ // |bitmap_manager| is not present in the process either, and no bitmaps
|
|
+ // should have been registered with this class.
|
|
+ DCHECK(owned_bitmaps_.empty());
|
|
+ }
|
|
|
|
process_->RemoveWidget(this);
|
|
process_->RemoveRoute(routing_id_);
|
|
@@ -2150,8 +2168,8 @@ void RenderWidgetHostImpl::DidNotProduceFrame(const viz::BeginFrameAck& ack) {
|
|
void RenderWidgetHostImpl::DidAllocateSharedBitmap(
|
|
mojo::ScopedSharedBufferHandle buffer,
|
|
const viz::SharedBitmapId& id) {
|
|
- if (!viz::ServerSharedBitmapManager::current()->ChildAllocatedSharedBitmap(
|
|
- std::move(buffer), id)) {
|
|
+ if (!shared_bitmap_manager_->ChildAllocatedSharedBitmap(std::move(buffer),
|
|
+ id)) {
|
|
bad_message::ReceivedBadMessage(GetProcess(),
|
|
bad_message::RWH_SHARED_BITMAP);
|
|
}
|
|
@@ -2160,7 +2178,7 @@ void RenderWidgetHostImpl::DidAllocateSharedBitmap(
|
|
|
|
void RenderWidgetHostImpl::DidDeleteSharedBitmap(
|
|
const viz::SharedBitmapId& id) {
|
|
- viz::ServerSharedBitmapManager::current()->ChildDeletedSharedBitmap(id);
|
|
+ shared_bitmap_manager_->ChildDeletedSharedBitmap(id);
|
|
owned_bitmaps_.erase(id);
|
|
}
|
|
|
|
diff --git a/content/browser/renderer_host/render_widget_host_impl.h b/content/browser/renderer_host/render_widget_host_impl.h
|
|
index 7328c615c87d..05f539cddbd3 100644
|
|
--- a/content/browser/renderer_host/render_widget_host_impl.h
|
|
+++ b/content/browser/renderer_host/render_widget_host_impl.h
|
|
@@ -96,6 +96,10 @@ namespace ui {
|
|
enum class DomCode;
|
|
}
|
|
|
|
+namespace viz {
|
|
+class ServerSharedBitmapManager;
|
|
+}
|
|
+
|
|
namespace content {
|
|
|
|
class BrowserAccessibilityManager;
|
|
@@ -1170,9 +1174,15 @@ class CONTENT_EXPORT RenderWidgetHostImpl
|
|
base::Optional<uint16_t> screen_orientation_angle_for_testing_;
|
|
base::Optional<ScreenOrientationValues> screen_orientation_type_for_testing_;
|
|
|
|
+ // When the viz display compositor is in the browser process, this is used to
|
|
+ // register and unregister the bitmaps (stored in |owned_bitmaps_| reported to
|
|
+ // this class from the renderer.
|
|
+ viz::ServerSharedBitmapManager* shared_bitmap_manager_ = nullptr;
|
|
// The set of SharedBitmapIds that have been reported as allocated to this
|
|
// interface. On closing this interface, the display compositor should drop
|
|
- // ownership of the bitmaps with these ids to avoid leaking them.
|
|
+ // ownership of the bitmaps with these ids to avoid leaking them. This is only
|
|
+ // used when SharedBitmaps are reported to this class because the display
|
|
+ // compositor is in the browser process.
|
|
std::set<viz::SharedBitmapId> owned_bitmaps_;
|
|
|
|
bool force_enable_zoom_ = false;
|
|
diff --git a/third_party/blink/renderer/platform/graphics/offscreen_canvas_resource_provider.cc b/third_party/blink/renderer/platform/graphics/offscreen_canvas_resource_provider.cc
|
|
index 8c140158bfd4..6d2fe1f74f78 100644
|
|
--- a/third_party/blink/renderer/platform/graphics/offscreen_canvas_resource_provider.cc
|
|
+++ b/third_party/blink/renderer/platform/graphics/offscreen_canvas_resource_provider.cc
|
|
@@ -181,8 +181,10 @@ void OffscreenCanvasResourceProvider::ReclaimResourceInternal(
|
|
}
|
|
|
|
OffscreenCanvasResourceProvider::FrameResource::~FrameResource() {
|
|
- provider->frame_dispatcher_->DidDeleteSharedBitmap(
|
|
- SharedBitmapIdToGpuMailboxPtr(shared_bitmap_id));
|
|
+ if (!shared_bitmap_id.IsZero()) {
|
|
+ provider->frame_dispatcher_->DidDeleteSharedBitmap(
|
|
+ SharedBitmapIdToGpuMailboxPtr(shared_bitmap_id));
|
|
+ }
|
|
}
|
|
|
|
} // namespace blink
|
|
diff --git a/ui/aura/BUILD.gn b/ui/aura/BUILD.gn
|
|
index c5eb719ef5d8..6f6a0534e8c9 100644
|
|
--- a/ui/aura/BUILD.gn
|
|
+++ b/ui/aura/BUILD.gn
|
|
@@ -344,6 +344,7 @@ executable("demo") {
|
|
"//build/config:exe_and_shlib_deps",
|
|
"//build/win:default_exe_manifest",
|
|
"//components/viz/host",
|
|
+ "//components/viz/service",
|
|
"//skia",
|
|
"//third_party/icu",
|
|
"//ui/base",
|
|
diff --git a/ui/aura/demo/DEPS b/ui/aura/demo/DEPS
|
|
index 4026dbd84623..608c21f85e51 100644
|
|
--- a/ui/aura/demo/DEPS
|
|
+++ b/ui/aura/demo/DEPS
|
|
@@ -1,5 +1,6 @@
|
|
include_rules = [
|
|
"+components/viz/host",
|
|
+ "+components/viz/service", # In-process viz service.
|
|
"+ui/display", # Windows DPI Initialization.
|
|
"+ui/gl/init/gl_factory.h", # To initialize GL bindings.
|
|
]
|
|
diff --git a/ui/aura/demo/demo_main.cc b/ui/aura/demo/demo_main.cc
|
|
index 7c7c6da576b2..c44a9f8bf1fb 100644
|
|
--- a/ui/aura/demo/demo_main.cc
|
|
+++ b/ui/aura/demo/demo_main.cc
|
|
@@ -16,6 +16,8 @@
|
|
#include "base/task_scheduler/task_scheduler.h"
|
|
#include "build/build_config.h"
|
|
#include "components/viz/host/host_frame_sink_manager.h"
|
|
+#include "components/viz/service/display_embedder/server_shared_bitmap_manager.h"
|
|
+#include "components/viz/service/frame_sinks/frame_sink_manager_impl.h"
|
|
#include "third_party/skia/include/core/SkBlendMode.h"
|
|
#include "ui/aura/client/default_capture_client.h"
|
|
#include "ui/aura/client/window_parenting_client.h"
|
|
@@ -147,7 +149,8 @@ int DemoMain() {
|
|
|
|
// The ContextFactory must exist before any Compositors are created.
|
|
viz::HostFrameSinkManager host_frame_sink_manager;
|
|
- viz::FrameSinkManagerImpl frame_sink_manager;
|
|
+ viz::ServerSharedBitmapManager server_shared_bitmap_manager;
|
|
+ viz::FrameSinkManagerImpl frame_sink_manager(&server_shared_bitmap_manager);
|
|
host_frame_sink_manager.SetLocalManager(&frame_sink_manager);
|
|
frame_sink_manager.SetLocalClient(&host_frame_sink_manager);
|
|
auto context_factory = std::make_unique<ui::InProcessContextFactory>(
|
|
diff --git a/ui/compositor/test/context_factories_for_test.cc b/ui/compositor/test/context_factories_for_test.cc
|
|
index ece65c0bddc0..aa1eb1807135 100644
|
|
--- a/ui/compositor/test/context_factories_for_test.cc
|
|
+++ b/ui/compositor/test/context_factories_for_test.cc
|
|
@@ -7,6 +7,7 @@
|
|
#include "base/command_line.h"
|
|
#include "base/sys_info.h"
|
|
#include "components/viz/host/host_frame_sink_manager.h"
|
|
+#include "components/viz/service/display_embedder/server_shared_bitmap_manager.h"
|
|
#include "components/viz/service/frame_sinks/frame_sink_manager_impl.h"
|
|
#include "ui/compositor/compositor.h"
|
|
#include "ui/compositor/compositor_switches.h"
|
|
@@ -16,6 +17,7 @@
|
|
namespace {
|
|
|
|
static viz::HostFrameSinkManager* g_host_frame_sink_manager = nullptr;
|
|
+static viz::ServerSharedBitmapManager* g_shared_bitmap_manager = nullptr;
|
|
static viz::FrameSinkManagerImpl* g_frame_sink_manager = nullptr;
|
|
static ui::InProcessContextFactory* g_implicit_factory = nullptr;
|
|
static gl::DisableNullDrawGLBindings* g_disable_null_draw = nullptr;
|
|
@@ -44,7 +46,8 @@ void InitializeContextFactoryForTests(
|
|
if (enable_pixel_output)
|
|
g_disable_null_draw = new gl::DisableNullDrawGLBindings;
|
|
g_host_frame_sink_manager = new viz::HostFrameSinkManager;
|
|
- g_frame_sink_manager = new viz::FrameSinkManagerImpl;
|
|
+ g_shared_bitmap_manager = new viz::ServerSharedBitmapManager;
|
|
+ g_frame_sink_manager = new viz::FrameSinkManagerImpl(g_shared_bitmap_manager);
|
|
g_implicit_factory = new InProcessContextFactory(g_host_frame_sink_manager,
|
|
g_frame_sink_manager);
|
|
g_implicit_factory->SetUseFastRefreshRateForTests();
|
|
@@ -64,6 +67,8 @@ void TerminateContextFactoryForTests() {
|
|
g_host_frame_sink_manager = nullptr;
|
|
delete g_frame_sink_manager;
|
|
g_frame_sink_manager = nullptr;
|
|
+ delete g_shared_bitmap_manager;
|
|
+ g_shared_bitmap_manager = nullptr;
|
|
delete g_disable_null_draw;
|
|
g_disable_null_draw = nullptr;
|
|
}
|
|
diff --git a/ui/views/examples/BUILD.gn b/ui/views/examples/BUILD.gn
|
|
index 661329c2482e..aec5cf1466b3 100644
|
|
--- a/ui/views/examples/BUILD.gn
|
|
+++ b/ui/views/examples/BUILD.gn
|
|
@@ -114,6 +114,7 @@ executable("views_examples_exe") {
|
|
"//build/config:exe_and_shlib_deps",
|
|
"//build/win:default_exe_manifest",
|
|
"//components/viz/host",
|
|
+ "//components/viz/service",
|
|
"//ui/base",
|
|
"//ui/compositor",
|
|
"//ui/compositor:test_support",
|
|
diff --git a/ui/views/examples/DEPS b/ui/views/examples/DEPS
|
|
index c55d1e8778f1..38ff08c5007e 100644
|
|
--- a/ui/views/examples/DEPS
|
|
+++ b/ui/views/examples/DEPS
|
|
@@ -1,5 +1,6 @@
|
|
include_rules = [
|
|
"+components/viz/host",
|
|
+ "+components/viz/service", # In-process viz service.
|
|
"+content/public",
|
|
"+content/shell",
|
|
"+sandbox",
|
|
diff --git a/ui/views/examples/examples_main.cc b/ui/views/examples/examples_main.cc
|
|
index 9ddb537f8c52..4dd22a71197b 100644
|
|
--- a/ui/views/examples/examples_main.cc
|
|
+++ b/ui/views/examples/examples_main.cc
|
|
@@ -17,6 +17,8 @@
|
|
#include "base/test/test_discardable_memory_allocator.h"
|
|
#include "build/build_config.h"
|
|
#include "components/viz/host/host_frame_sink_manager.h"
|
|
+#include "components/viz/service/display_embedder/server_shared_bitmap_manager.h"
|
|
+#include "components/viz/service/frame_sinks/frame_sink_manager_impl.h"
|
|
#include "ui/base/ime/input_method_initializer.h"
|
|
#include "ui/base/material_design/material_design_controller.h"
|
|
#include "ui/base/resource/resource_bundle.h"
|
|
@@ -68,7 +70,8 @@ int main(int argc, char** argv) {
|
|
|
|
// The ContextFactory must exist before any Compositors are created.
|
|
viz::HostFrameSinkManager host_frame_sink_manager;
|
|
- viz::FrameSinkManagerImpl frame_sink_manager;
|
|
+ viz::ServerSharedBitmapManager shared_bitmap_manager;
|
|
+ viz::FrameSinkManagerImpl frame_sink_manager(&shared_bitmap_manager);
|
|
host_frame_sink_manager.SetLocalManager(&frame_sink_manager);
|
|
frame_sink_manager.SetLocalClient(&host_frame_sink_manager);
|
|
auto context_factory = std::make_unique<ui::InProcessContextFactory>(
|