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

Side by Side Diff: content/browser/renderer_host/offscreen_canvas_frame_receiver_impl.cc

Issue 2333133003: Make Surface creation lazy for OffscreenCanvasFrameReceiverImpl (Closed)
Patch Set: Rebase Created 4 years, 3 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 unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/browser/renderer_host/offscreen_canvas_frame_receiver_impl.h" 5 #include "content/browser/renderer_host/offscreen_canvas_frame_receiver_impl.h"
6 6
7 #include "cc/surfaces/surface.h" 7 #include "cc/surfaces/surface.h"
8 #include "cc/surfaces/surface_manager.h" 8 #include "cc/surfaces/surface_manager.h"
9 #include "content/browser/compositor/surface_utils.h" 9 #include "content/browser/compositor/surface_utils.h"
10 #include "mojo/public/cpp/bindings/strong_binding.h" 10 #include "mojo/public/cpp/bindings/strong_binding.h"
11 11
12 namespace content { 12 namespace content {
13 13
14 OffscreenCanvasFrameReceiverImpl::OffscreenCanvasFrameReceiverImpl() {} 14 OffscreenCanvasFrameReceiverImpl::OffscreenCanvasFrameReceiverImpl() {}
15 15
16 OffscreenCanvasFrameReceiverImpl::~OffscreenCanvasFrameReceiverImpl() {} 16 OffscreenCanvasFrameReceiverImpl::~OffscreenCanvasFrameReceiverImpl() {
17 if (surface_factory_) {
18 if (!GetSurfaceManager()) {
19 // Inform SurfaceFactory that SurfaceManager's no longer alive to
20 // avoid its destruction error.
21 surface_factory_->DidDestroySurfaceManager();
22 } else {
23 GetSurfaceManager()->InvalidateSurfaceClientId(surface_id_.client_id());
24 }
25 surface_factory_->Destroy(surface_id_);
26 }
27 }
17 28
18 // static 29 // static
19 void OffscreenCanvasFrameReceiverImpl::Create( 30 void OffscreenCanvasFrameReceiverImpl::Create(
20 blink::mojom::OffscreenCanvasFrameReceiverRequest request) { 31 blink::mojom::OffscreenCanvasFrameReceiverRequest request) {
21 mojo::MakeStrongBinding(base::MakeUnique<OffscreenCanvasFrameReceiverImpl>(), 32 mojo::MakeStrongBinding(base::MakeUnique<OffscreenCanvasFrameReceiverImpl>(),
22 std::move(request)); 33 std::move(request));
23 } 34 }
24 35
25 void OffscreenCanvasFrameReceiverImpl::SubmitCompositorFrame( 36 void OffscreenCanvasFrameReceiverImpl::SubmitCompositorFrame(
26 const cc::SurfaceId& surface_id, 37 const cc::SurfaceId& surface_id,
27 cc::CompositorFrame frame) { 38 cc::CompositorFrame frame) {
28 cc::Surface* surface = GetSurfaceManager()->GetSurfaceForId(surface_id); 39 if (!surface_factory_) {
29 if (surface) { 40 cc::SurfaceManager* manager = GetSurfaceManager();
30 surface->QueueFrame(std::move(frame), base::Closure()); 41 surface_factory_ = base::MakeUnique<cc::SurfaceFactory>(manager, this);
42 surface_factory_->Create(surface_id);
43
44 GetSurfaceManager()->RegisterSurfaceClientId(surface_id.client_id());
45 }
46 if (surface_id_.is_null()) {
47 surface_id_ = surface_id;
31 } 48 }
32 // If surface doet not exist, drop the frame. 49 surface_factory_->SubmitCompositorFrame(surface_id, std::move(frame),
50 base::Closure());
33 } 51 }
34 52
53 // TODO(619136): Implement cc::SurfaceFactoryClient functions for resources
54 // return.
55 void OffscreenCanvasFrameReceiverImpl::ReturnResources(
56 const cc::ReturnedResourceArray& resources) {}
57
58 void OffscreenCanvasFrameReceiverImpl::WillDrawSurface(
59 const cc::SurfaceId& id,
60 const gfx::Rect& damage_rect) {}
61
62 void OffscreenCanvasFrameReceiverImpl::SetBeginFrameSource(
63 cc::BeginFrameSource* begin_frame_source) {}
64
35 } // namespace content 65 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698