Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(519)

Unified Diff: cc/surfaces/compositor_frame_sink_support.cc

Issue 2848223003: Enforce constant size and device scale factor for surfaces (Closed)
Patch Set: Address comments Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « cc/surfaces/compositor_frame_sink_support.h ('k') | cc/surfaces/compositor_frame_sink_support_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/surfaces/compositor_frame_sink_support.cc
diff --git a/cc/surfaces/compositor_frame_sink_support.cc b/cc/surfaces/compositor_frame_sink_support.cc
index 896536f039cf4966b2c4204acb4034780d7765e6..0a9684dc4f05b09a72c4584f8f61197aa461fdcd 100644
--- a/cc/surfaces/compositor_frame_sink_support.cc
+++ b/cc/surfaces/compositor_frame_sink_support.cc
@@ -97,7 +97,7 @@ void CompositorFrameSinkSupport::DidNotProduceFrame(const BeginFrameAck& ack) {
begin_frame_source_->DidFinishFrame(this, ack);
}
-void CompositorFrameSinkSupport::SubmitCompositorFrame(
+bool CompositorFrameSinkSupport::SubmitCompositorFrame(
const LocalSurfaceId& local_surface_id,
CompositorFrame frame) {
TRACE_EVENT0("cc", "CompositorFrameSinkSupport::SubmitCompositorFrame");
@@ -131,16 +131,36 @@ void CompositorFrameSinkSupport::SubmitCompositorFrame(
if (!create_new_surface) {
surface = std::move(current_surface_);
} else {
- surface = CreateSurface(local_surface_id);
+ SurfaceId surface_id(frame_sink_id_, local_surface_id);
+ gfx::Size frame_size = frame.render_pass_list.back()->output_rect.size();
+ float device_scale_factor = frame.metadata.device_scale_factor;
+ SurfaceInfo surface_info(surface_id, device_scale_factor, frame_size);
+
+ if (!surface_info.is_valid()) {
+ TRACE_EVENT_INSTANT0("cc", "Invalid SurfaceInfo",
+ TRACE_EVENT_SCOPE_THREAD);
+ if (current_surface_)
+ DestroyCurrentSurface();
+ ReturnedResourceArray resources;
+ TransferableResource::ReturnResources(frame.resource_list, &resources);
+ ReturnResources(resources);
+ DidReceiveCompositorFrameAck();
+ return true;
+ }
+
+ surface = CreateSurface(surface_info);
}
- surface->QueueFrame(
+ bool result = surface->QueueFrame(
std::move(frame),
base::Bind(&CompositorFrameSinkSupport::DidReceiveCompositorFrameAck,
weak_factory_.GetWeakPtr()),
base::BindRepeating(&CompositorFrameSinkSupport::WillDrawSurface,
weak_factory_.GetWeakPtr()));
+ if (!result)
+ return false;
+
if (current_surface_) {
surface->SetPreviousFrameSurface(current_surface_.get());
DestroyCurrentSurface();
@@ -154,6 +174,8 @@ void CompositorFrameSinkSupport::SubmitCompositorFrame(
// See https://crbug.com/703079.
if (begin_frame_source_)
begin_frame_source_->DidFinishFrame(this, ack);
+
+ return true;
}
void CompositorFrameSinkSupport::UpdateSurfaceReferences(
@@ -331,11 +353,10 @@ void CompositorFrameSinkSupport::UpdateNeedsBeginFramesInternal() {
}
std::unique_ptr<Surface> CompositorFrameSinkSupport::CreateSurface(
- const LocalSurfaceId& local_surface_id) {
+ const SurfaceInfo& surface_info) {
seen_first_frame_activation_ = false;
- std::unique_ptr<Surface> surface = surface_manager_->CreateSurface(
- weak_factory_.GetWeakPtr(), local_surface_id);
- return surface;
+ return surface_manager_->CreateSurface(weak_factory_.GetWeakPtr(),
+ surface_info);
}
void CompositorFrameSinkSupport::DestroyCurrentSurface() {
« no previous file with comments | « cc/surfaces/compositor_frame_sink_support.h ('k') | cc/surfaces/compositor_frame_sink_support_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698