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

Side by Side Diff: cc/surfaces/surface_display_output_surface.cc

Issue 1821863002: Hook up ui::Compositor to Display's BeginFrameSource (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix Display member destruction order Created 4 years, 8 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "cc/surfaces/surface_display_output_surface.h" 5 #include "cc/surfaces/surface_display_output_surface.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "cc/output/compositor_frame.h" 8 #include "cc/output/compositor_frame.h"
9 #include "cc/output/compositor_frame_ack.h" 9 #include "cc/output/compositor_frame_ack.h"
10 #include "cc/surfaces/display.h" 10 #include "cc/surfaces/display.h"
11 #include "cc/surfaces/onscreen_display_client.h" 11 #include "cc/surfaces/onscreen_display_client.h"
12 #include "cc/surfaces/surface.h" 12 #include "cc/surfaces/surface.h"
13 #include "cc/surfaces/surface_manager.h" 13 #include "cc/surfaces/surface_manager.h"
14 14
15 namespace cc { 15 namespace cc {
16 16
17 SurfaceDisplayOutputSurface::SurfaceDisplayOutputSurface( 17 SurfaceDisplayOutputSurface::SurfaceDisplayOutputSurface(
18 SurfaceManager* surface_manager, 18 SurfaceManager* surface_manager,
19 SurfaceIdAllocator* allocator, 19 SurfaceIdAllocator* allocator,
20 scoped_refptr<ContextProvider> context_provider, 20 scoped_refptr<ContextProvider> context_provider,
21 scoped_refptr<ContextProvider> worker_context_provider) 21 scoped_refptr<ContextProvider> worker_context_provider)
22 : OutputSurface(std::move(context_provider), 22 : OutputSurface(std::move(context_provider),
23 std::move(worker_context_provider)), 23 std::move(worker_context_provider)),
24 display_client_(NULL), 24 display_client_(nullptr),
25 factory_(surface_manager, this), 25 factory_(surface_manager, this),
26 allocator_(allocator) { 26 allocator_(allocator) {
27 factory_.set_needs_sync_points(false); 27 factory_.set_needs_sync_points(false);
28 capabilities_.delegated_rendering = true; 28 capabilities_.delegated_rendering = true;
29 capabilities_.adjust_deadline_for_parent = true; 29 capabilities_.adjust_deadline_for_parent = true;
30 capabilities_.can_force_reclaim_resources = true; 30 capabilities_.can_force_reclaim_resources = true;
31 // Display and SurfaceDisplayOutputSurface share a GL context, so sync 31 // Display and SurfaceDisplayOutputSurface share a GL context, so sync
32 // points aren't needed when passing resources between them. 32 // points aren't needed when passing resources between them.
33 capabilities_.delegated_sync_points_required = false; 33 capabilities_.delegated_sync_points_required = false;
34 } 34 }
35 35
36 SurfaceDisplayOutputSurface::~SurfaceDisplayOutputSurface() { 36 SurfaceDisplayOutputSurface::~SurfaceDisplayOutputSurface() {
37 if (HasClient()) 37 if (HasClient())
38 DetachFromClient(); 38 DetachFromClient();
39 if (!surface_id_.is_null()) { 39 if (!surface_id_.is_null()) {
40 factory_.Destroy(surface_id_); 40 factory_.Destroy(surface_id_);
41 } 41 }
42 } 42 }
43 43
44 void SurfaceDisplayOutputSurface::ReceivedVSyncParameters(
45 base::TimeTicks timebase,
46 base::TimeDelta interval) {
47 CommitVSyncParameters(timebase, interval);
48 }
49
50 void SurfaceDisplayOutputSurface::SwapBuffers(CompositorFrame* frame) { 44 void SurfaceDisplayOutputSurface::SwapBuffers(CompositorFrame* frame) {
51 gfx::Size frame_size = 45 gfx::Size frame_size =
52 frame->delegated_frame_data->render_pass_list.back()->output_rect.size(); 46 frame->delegated_frame_data->render_pass_list.back()->output_rect.size();
53 if (frame_size.IsEmpty() || frame_size != display_size_) { 47 if (frame_size.IsEmpty() || frame_size != display_size_) {
54 if (!surface_id_.is_null()) { 48 if (!surface_id_.is_null()) {
55 factory_.Destroy(surface_id_); 49 factory_.Destroy(surface_id_);
56 } 50 }
57 surface_id_ = allocator_->GenerateId(); 51 surface_id_ = allocator_->GenerateId();
58 factory_.Create(surface_id_); 52 factory_.Create(surface_id_);
59 display_size_ = frame_size; 53 display_size_ = frame_size;
60 } 54 }
61 display_client_->display()->SetSurfaceId(surface_id_, 55 display_client_->display()->SetSurfaceId(surface_id_,
62 frame->metadata.device_scale_factor); 56 frame->metadata.device_scale_factor);
63 57
64 client_->DidSwapBuffers(); 58 client_->DidSwapBuffers();
65 59
66 std::unique_ptr<CompositorFrame> frame_copy(new CompositorFrame()); 60 std::unique_ptr<CompositorFrame> frame_copy(new CompositorFrame());
67 frame->AssignTo(frame_copy.get()); 61 frame->AssignTo(frame_copy.get());
68 factory_.SubmitCompositorFrame( 62 factory_.SubmitCompositorFrame(
69 surface_id_, std::move(frame_copy), 63 surface_id_, std::move(frame_copy),
70 base::Bind(&SurfaceDisplayOutputSurface::SwapBuffersComplete, 64 base::Bind(&SurfaceDisplayOutputSurface::SwapBuffersComplete,
71 base::Unretained(this))); 65 base::Unretained(this)));
72 } 66 }
73 67
74 bool SurfaceDisplayOutputSurface::BindToClient(OutputSurfaceClient* client) { 68 bool SurfaceDisplayOutputSurface::BindToClient(OutputSurfaceClient* client) {
75 DCHECK(client); 69 DCHECK(client);
76 DCHECK(display_client_); 70 DCHECK(display_client_);
71 client_ = client;
77 factory_.manager()->RegisterSurfaceFactoryClient(allocator_->id_namespace(), 72 factory_.manager()->RegisterSurfaceFactoryClient(allocator_->id_namespace(),
78 this); 73 this);
79 74
80 client_ = client;
81 // Avoid initializing GL context here, as this should be sharing the 75 // Avoid initializing GL context here, as this should be sharing the
82 // Display's context. 76 // Display's context.
83 return display_client_->Initialize(); 77 return display_client_->Initialize();
84 } 78 }
85 79
86 void SurfaceDisplayOutputSurface::ForceReclaimResources() { 80 void SurfaceDisplayOutputSurface::ForceReclaimResources() {
87 if (!surface_id_.is_null()) 81 if (!surface_id_.is_null())
88 factory_.SubmitCompositorFrame(surface_id_, nullptr, 82 factory_.SubmitCompositorFrame(surface_id_, nullptr,
89 SurfaceFactory::DrawCallback()); 83 SurfaceFactory::DrawCallback());
90 } 84 }
(...skipping 11 matching lines...) Expand all
102 void SurfaceDisplayOutputSurface::ReturnResources( 96 void SurfaceDisplayOutputSurface::ReturnResources(
103 const ReturnedResourceArray& resources) { 97 const ReturnedResourceArray& resources) {
104 CompositorFrameAck ack; 98 CompositorFrameAck ack;
105 ack.resources = resources; 99 ack.resources = resources;
106 if (client_) 100 if (client_)
107 client_->ReclaimResources(&ack); 101 client_->ReclaimResources(&ack);
108 } 102 }
109 103
110 void SurfaceDisplayOutputSurface::SetBeginFrameSource( 104 void SurfaceDisplayOutputSurface::SetBeginFrameSource(
111 BeginFrameSource* begin_frame_source) { 105 BeginFrameSource* begin_frame_source) {
112 // TODO(tansell): Hook this up. 106 DCHECK(client_);
107 client_->SetBeginFrameSource(begin_frame_source);
113 } 108 }
114 109
115 void SurfaceDisplayOutputSurface::SwapBuffersComplete(SurfaceDrawStatus drawn) { 110 void SurfaceDisplayOutputSurface::SwapBuffersComplete(SurfaceDrawStatus drawn) {
116 if (client_ && !display_client_->output_surface_lost()) 111 if (client_ && !display_client_->output_surface_lost())
117 client_->DidSwapBuffersComplete(); 112 client_->DidSwapBuffersComplete();
118 } 113 }
119 114
120 } // namespace cc 115 } // namespace cc
OLDNEW
« no previous file with comments | « cc/surfaces/surface_display_output_surface.h ('k') | cc/surfaces/surface_display_output_surface_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698