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

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

Issue 2584643002: Revamp OffscreenCanvas commit flow (Closed)
Patch Set: Furnish Created 4 years 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_surface_impl.cc
diff --git a/content/browser/renderer_host/offscreen_canvas_surface_impl.cc b/content/browser/renderer_host/offscreen_canvas_surface_impl.cc
index 29679540fa365f8c20961cffd571b7762c55ddf2..b17cae5e5f98ebda68b36f25d181a2c72468e621 100644
--- a/content/browser/renderer_host/offscreen_canvas_surface_impl.cc
+++ b/content/browser/renderer_host/offscreen_canvas_surface_impl.cc
@@ -16,8 +16,7 @@
namespace content {
-OffscreenCanvasSurfaceImpl::OffscreenCanvasSurfaceImpl()
- : id_allocator_(new cc::SurfaceIdAllocator()) {}
+OffscreenCanvasSurfaceImpl::OffscreenCanvasSurfaceImpl() {}
OffscreenCanvasSurfaceImpl::~OffscreenCanvasSurfaceImpl() {
if (frame_sink_id_.is_valid()) {
@@ -33,29 +32,40 @@ void OffscreenCanvasSurfaceImpl::Create(
std::move(request));
}
-void OffscreenCanvasSurfaceImpl::GetSurfaceId(GetSurfaceIdCallback callback) {
- DCHECK_CURRENTLY_ON(BrowserThread::UI);
+void OffscreenCanvasSurfaceImpl::SetClient(
+ blink::mojom::OffscreenCanvasSurfaceClientPtr client,
+ const cc::FrameSinkId& frame_sink_id) {
if (frame_sink_id_.is_valid()) {
// This IPC should be only called once for each HTMLCanvasElement. In this
// case, frame_sink_id_ is still unset.
// As the browser makes no assumption of correct behavior of renderer, in
- // an unwanted situation when this function is invoked twice, we need to
- // unregister the instance from manager.
- OffscreenCanvasSurfaceManager::GetInstance()
- ->UnregisterOffscreenCanvasSurfaceInstance(frame_sink_id_);
+ // an unwanted situation when this function is invoked twice, we ignore
+ // the second call.
mojo::ReportBadMessage(
- "The same OffscreenCanvasSurfaceImpl is registered to "
- "OffscreenCanvasSurfaceManager twice.");
+ "The same OffscreenCanvasSurfaceImpl sets client "
+ "twice.");
+ return;
}
-
- frame_sink_id_ = AllocateFrameSinkId();
- cc::SurfaceId surface_id =
- cc::SurfaceId(frame_sink_id_, id_allocator_->GenerateId());
+ client_ = std::move(client);
+ frame_sink_id_ = frame_sink_id;
OffscreenCanvasSurfaceManager::GetInstance()
->RegisterOffscreenCanvasSurfaceInstance(frame_sink_id_, this);
+}
- std::move(callback).Run(surface_id);
+void OffscreenCanvasSurfaceImpl::OnSurfaceCreated(
+ const cc::SurfaceId& surface_id,
+ const gfx::Size& frame_size,
+ float device_scale_factor) {
+ DCHECK_EQ(surface_id.frame_sink_id(), frame_sink_id_);
+ if (!current_local_frame_id_.is_valid() ||
+ surface_id.local_frame_id() != current_local_frame_id_) {
+ current_local_frame_id_ = surface_id.local_frame_id();
+ if (client_) {
+ client_->OnSurfaceCreated(surface_id, frame_size.width(),
+ frame_size.height(), device_scale_factor);
+ }
+ }
}
void OffscreenCanvasSurfaceImpl::Require(const cc::SurfaceId& surface_id,

Powered by Google App Engine
This is Rietveld 408576698