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

Unified Diff: content/browser/renderer_host/offscreen_canvas_compositor_frame_sink.cc

Issue 2521013003: Compositing Layer update for OffscreenCanvas resize (Closed)
Patch Set: test Created 4 years, 1 month 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
Index: content/browser/renderer_host/offscreen_canvas_compositor_frame_sink.cc
diff --git a/content/browser/renderer_host/offscreen_canvas_compositor_frame_sink.cc b/content/browser/renderer_host/offscreen_canvas_compositor_frame_sink.cc
index 0c4d066e37895a768142f2491c6e6b1d489ce988..fe289cda9a2f39e43e3a8d1b8eb3a1ac905b45c5 100644
--- a/content/browser/renderer_host/offscreen_canvas_compositor_frame_sink.cc
+++ b/content/browser/renderer_host/offscreen_canvas_compositor_frame_sink.cc
@@ -7,6 +7,8 @@
#include "cc/surfaces/surface.h"
#include "cc/surfaces/surface_manager.h"
#include "content/browser/compositor/surface_utils.h"
+#include "content/browser/renderer_host/offscreen_canvas_surface_impl.h"
+#include "content/browser/renderer_host/offscreen_canvas_surface_manager.h"
#include "mojo/public/cpp/bindings/strong_binding.h"
namespace content {
@@ -19,7 +21,6 @@ OffscreenCanvasCompositorFrameSink::OffscreenCanvasCompositorFrameSink(
surface_factory_ = base::MakeUnique<cc::SurfaceFactory>(
surface_id_.frame_sink_id(), manager, this);
manager->RegisterFrameSinkId(surface_id_.frame_sink_id());
- surface_factory_->Create(surface_id_.local_frame_id());
}
OffscreenCanvasCompositorFrameSink::~OffscreenCanvasCompositorFrameSink() {
@@ -46,6 +47,41 @@ void OffscreenCanvasCompositorFrameSink::Create(
void OffscreenCanvasCompositorFrameSink::SubmitCompositorFrame(
cc::CompositorFrame frame) {
+ cc::RenderPass* root_pass = frame.render_pass_list.back().get();
+ gfx::Size surface_size = root_pass->output_rect.size();
+
+ if (!GetSurfaceManager()->GetSurfaceForId(surface_id_)) {
Fady Samuel 2016/11/22 16:04:09 I hate to be overly nitpicky but this flow doesn't
+ // If this is the first commit, surface_id_ is not used to create a new
+ // Surface yet.
+ surface_factory_->Create(surface_id_.local_frame_id());
+ current_surface_size_ = surface_size;
+ } else if (surface_size != current_surface_size_) {
+ // If this is not the first commit, we check whether there is a resize
+ // since the previous commit.
+ OffscreenCanvasSurfaceImpl* surface_impl =
+ OffscreenCanvasSurfaceManager::GetInstance()->GetSurfaceInstance(
+ surface_id_.frame_sink_id());
+ if (!surface_impl) {
+ // We may end up here when the HTMLCanvasElement-
+ // OffscreenCanvasSurfaceImpl connection is torn down and the
+ // OffscreenCanvas-CompositorFrameSink connection is still working. In
+ // this case, we ignore the commit() because it is meaningless to
+ // process a compositor frame when there is no placeholder canvas for
+ // this OffscreenCanvas.
+ LOG(ERROR) << "OffscreenCanvas is submitting frame when its place holder"
+ << " canvas's browser service-end does no longer exist.";
+ return;
+ }
+
+ cc::LocalFrameId new_local_frame_id = surface_impl->GenerateLocalFrameId();
+ surface_factory_->Destroy(surface_id_.local_frame_id());
+ surface_id_ =
+ cc::SurfaceId(surface_id_.frame_sink_id(), new_local_frame_id);
+ surface_factory_->Create(surface_id_.local_frame_id());
+ current_surface_size_ = surface_size;
+ surface_impl->OnSurfaceSizeChanged(surface_id_, current_surface_size_);
+ }
+
++ack_pending_count_;
surface_factory_->SubmitCompositorFrame(
surface_id_.local_frame_id(), std::move(frame),

Powered by Google App Engine
This is Rietveld 408576698