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

Side by Side Diff: ui/aura/local/compositor_frame_sink_local.cc

Issue 2848223003: Enforce constant size and device scale factor for surfaces (Closed)
Patch Set: Notify CFSSClient when a frame is rejected 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 unified diff | Download patch
OLDNEW
1 // Copyright 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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 "ui/aura/local/compositor_frame_sink_local.h" 5 #include "ui/aura/local/compositor_frame_sink_local.h"
6 6
7 #include "cc/output/compositor_frame_sink_client.h" 7 #include "cc/output/compositor_frame_sink_client.h"
8 #include "cc/surfaces/compositor_frame_sink_support.h" 8 #include "cc/surfaces/compositor_frame_sink_support.h"
9 #include "ui/aura/client/cursor_client.h" 9 #include "ui/aura/client/cursor_client.h"
10 #include "ui/aura/env.h" 10 #include "ui/aura/env.h"
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 thread_checker_.reset(); 56 thread_checker_.reset();
57 cc::CompositorFrameSink::DetachFromClient(); 57 cc::CompositorFrameSink::DetachFromClient();
58 } 58 }
59 59
60 void CompositorFrameSinkLocal::SubmitCompositorFrame( 60 void CompositorFrameSinkLocal::SubmitCompositorFrame(
61 cc::CompositorFrame frame) { 61 cc::CompositorFrame frame) {
62 DCHECK(thread_checker_); 62 DCHECK(thread_checker_);
63 DCHECK(thread_checker_->CalledOnValidThread()); 63 DCHECK(thread_checker_->CalledOnValidThread());
64 64
65 cc::LocalSurfaceId old_local_surface_id = local_surface_id_; 65 cc::LocalSurfaceId old_local_surface_id = local_surface_id_;
66 if (!frame.render_pass_list.empty()) { 66 const auto& frame_size = frame.render_pass_list.back()->output_rect.size();
67 const auto& frame_size = frame.render_pass_list.back()->output_rect.size(); 67 if (frame_size != surface_size_ ||
68 if (frame_size != last_submitted_frame_size_ || 68 frame.metadata.device_scale_factor != device_scale_factor_ ||
69 !local_surface_id_.is_valid()) { 69 !local_surface_id_.is_valid()) {
70 last_submitted_frame_size_ = frame_size; 70 surface_size_ = frame_size;
71 local_surface_id_ = id_allocator_.GenerateId(); 71 device_scale_factor_ = frame.metadata.device_scale_factor;
72 local_surface_id_ = id_allocator_.GenerateId();
72 } 73 }
73 }
74 support_->SubmitCompositorFrame(local_surface_id_, std::move(frame)); 74 support_->SubmitCompositorFrame(local_surface_id_, std::move(frame));
75 75
76 if (local_surface_id_ != old_local_surface_id) { 76 if (local_surface_id_ != old_local_surface_id) {
77 surface_changed_callback_.Run( 77 surface_changed_callback_.Run(
78 cc::SurfaceId(frame_sink_id_, local_surface_id_), 78 cc::SurfaceId(frame_sink_id_, local_surface_id_), surface_size_);
79 last_submitted_frame_size_);
80 } 79 }
81 } 80 }
82 81
83 void CompositorFrameSinkLocal::DidReceiveCompositorFrameAck( 82 void CompositorFrameSinkLocal::DidReceiveCompositorFrameAck(
84 const cc::ReturnedResourceArray& resources) { 83 const cc::ReturnedResourceArray& resources) {
85 DCHECK(thread_checker_); 84 DCHECK(thread_checker_);
86 DCHECK(thread_checker_->CalledOnValidThread()); 85 DCHECK(thread_checker_->CalledOnValidThread());
87 if (!client_) 86 if (!client_)
88 return; 87 return;
89 if (!resources.empty()) 88 if (!resources.empty())
90 client_->ReclaimResources(resources); 89 client_->ReclaimResources(resources);
91 client_->DidReceiveCompositorFrameAck(); 90 client_->DidReceiveCompositorFrameAck();
92 } 91 }
93 92
94 void CompositorFrameSinkLocal::OnBeginFrame(const cc::BeginFrameArgs& args) { 93 void CompositorFrameSinkLocal::OnBeginFrame(const cc::BeginFrameArgs& args) {
95 DCHECK(thread_checker_); 94 DCHECK(thread_checker_);
96 DCHECK(thread_checker_->CalledOnValidThread()); 95 DCHECK(thread_checker_->CalledOnValidThread());
97 begin_frame_source_->OnBeginFrame(args); 96 begin_frame_source_->OnBeginFrame(args);
98 } 97 }
99 98
100 void CompositorFrameSinkLocal::ReclaimResources( 99 void CompositorFrameSinkLocal::ReclaimResources(
101 const cc::ReturnedResourceArray& resources) { 100 const cc::ReturnedResourceArray& resources) {
102 DCHECK(thread_checker_); 101 DCHECK(thread_checker_);
103 DCHECK(thread_checker_->CalledOnValidThread()); 102 DCHECK(thread_checker_->CalledOnValidThread());
104 if (!client_) 103 if (!client_)
105 return; 104 return;
106 client_->ReclaimResources(resources); 105 client_->ReclaimResources(resources);
107 } 106 }
108 107
108 void CompositorFrameSinkLocal::DidRejectCompositorFrame() {
109 NOTREACHED();
110 }
111
109 void CompositorFrameSinkLocal::OnNeedsBeginFrames(bool needs_begin_frames) { 112 void CompositorFrameSinkLocal::OnNeedsBeginFrames(bool needs_begin_frames) {
110 DCHECK(thread_checker_); 113 DCHECK(thread_checker_);
111 DCHECK(thread_checker_->CalledOnValidThread()); 114 DCHECK(thread_checker_->CalledOnValidThread());
112 support_->SetNeedsBeginFrame(needs_begin_frames); 115 support_->SetNeedsBeginFrame(needs_begin_frames);
113 } 116 }
114 117
115 void CompositorFrameSinkLocal::OnDidFinishFrame(const cc::BeginFrameAck& ack) { 118 void CompositorFrameSinkLocal::OnDidFinishFrame(const cc::BeginFrameAck& ack) {
116 DCHECK(thread_checker_); 119 DCHECK(thread_checker_);
117 DCHECK(thread_checker_->CalledOnValidThread()); 120 DCHECK(thread_checker_->CalledOnValidThread());
118 // If there was damage, the submitted CompositorFrame includes the ack. 121 // If there was damage, the submitted CompositorFrame includes the ack.
119 if (!ack.has_damage) 122 if (!ack.has_damage)
120 support_->BeginFrameDidNotSwap(ack); 123 support_->BeginFrameDidNotSwap(ack);
121 } 124 }
122 125
123 } // namespace aura 126 } // namespace aura
OLDNEW
« cc/surfaces/compositor_frame_sink_support.cc ('K') | « ui/aura/local/compositor_frame_sink_local.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698