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

Side by Side Diff: cc/test/test_compositor_frame_sink.cc

Issue 2848223003: Enforce constant size and device scale factor for surfaces (Closed)
Patch Set: Address comments 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 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 "cc/test/test_compositor_frame_sink.h" 5 #include "cc/test/test_compositor_frame_sink.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/memory/ptr_util.h" 10 #include "base/memory/ptr_util.h"
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 const LocalSurfaceId& local_surface_id) { 125 const LocalSurfaceId& local_surface_id) {
126 test_client_->DisplayReceivedLocalSurfaceId(local_surface_id); 126 test_client_->DisplayReceivedLocalSurfaceId(local_surface_id);
127 } 127 }
128 128
129 void TestCompositorFrameSink::SubmitCompositorFrame(CompositorFrame frame) { 129 void TestCompositorFrameSink::SubmitCompositorFrame(CompositorFrame frame) {
130 DCHECK(frame.metadata.begin_frame_ack.has_damage); 130 DCHECK(frame.metadata.begin_frame_ack.has_damage);
131 DCHECK_LE(BeginFrameArgs::kStartingFrameNumber, 131 DCHECK_LE(BeginFrameArgs::kStartingFrameNumber,
132 frame.metadata.begin_frame_ack.sequence_number); 132 frame.metadata.begin_frame_ack.sequence_number);
133 test_client_->DisplayReceivedCompositorFrame(frame); 133 test_client_->DisplayReceivedCompositorFrame(frame);
134 134
135 if (!delegated_local_surface_id_.is_valid()) { 135 gfx::Size frame_size = frame.render_pass_list.back()->output_rect.size();
136 delegated_local_surface_id_ = local_surface_id_allocator_->GenerateId(); 136 float device_scale_factor = frame.metadata.device_scale_factor;
137 if (!local_surface_id_.is_valid() || frame_size != display_size_ ||
138 device_scale_factor != device_scale_factor_) {
139 local_surface_id_ = local_surface_id_allocator_->GenerateId();
140 display_->SetLocalSurfaceId(local_surface_id_, device_scale_factor);
141 display_->Resize(frame_size);
142 display_size_ = frame_size;
143 device_scale_factor_ = device_scale_factor;
137 } 144 }
138 display_->SetLocalSurfaceId(delegated_local_surface_id_,
139 frame.metadata.device_scale_factor);
140 145
141 gfx::Size frame_size = frame.render_pass_list.back()->output_rect.size(); 146 bool result =
142 display_->Resize(frame_size); 147 support_->SubmitCompositorFrame(local_surface_id_, std::move(frame));
143 148 DCHECK(result);
144 support_->SubmitCompositorFrame(delegated_local_surface_id_,
145 std::move(frame));
146 149
147 for (std::unique_ptr<CopyOutputRequest>& copy_request : copy_requests_) { 150 for (std::unique_ptr<CopyOutputRequest>& copy_request : copy_requests_) {
148 support_->RequestCopyOfSurface(std::move(copy_request)); 151 support_->RequestCopyOfSurface(std::move(copy_request));
149 } 152 }
150 copy_requests_.clear(); 153 copy_requests_.clear();
151 154
152 if (!display_->has_scheduler()) { 155 if (!display_->has_scheduler()) {
153 display_->DrawAndSwap(); 156 display_->DrawAndSwap();
154 // Post this to get a new stack frame so that we exit this function before 157 // Post this to get a new stack frame so that we exit this function before
155 // calling the client to tell it that it is done. 158 // calling the client to tell it that it is done.
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
205 208
206 void TestCompositorFrameSink::OnNeedsBeginFrames(bool needs_begin_frames) { 209 void TestCompositorFrameSink::OnNeedsBeginFrames(bool needs_begin_frames) {
207 support_->SetNeedsBeginFrame(needs_begin_frames); 210 support_->SetNeedsBeginFrame(needs_begin_frames);
208 } 211 }
209 212
210 void TestCompositorFrameSink::SendCompositorFrameAckToClient() { 213 void TestCompositorFrameSink::SendCompositorFrameAckToClient() {
211 client_->DidReceiveCompositorFrameAck(); 214 client_->DidReceiveCompositorFrameAck();
212 } 215 }
213 216
214 } // namespace cc 217 } // namespace cc
OLDNEW
« no previous file with comments | « cc/test/test_compositor_frame_sink.h ('k') | components/viz/frame_sinks/gpu_compositor_frame_sink.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698