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

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: Fixed dchecks 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 } 72 local_surface_id_ = id_allocator_.GenerateId();
73 } 73 }
74 support_->SubmitCompositorFrame(local_surface_id_, std::move(frame)); 74 bool result =
75 support_->SubmitCompositorFrame(local_surface_id_, std::move(frame));
76 DCHECK(result);
75 77
76 if (local_surface_id_ != old_local_surface_id) { 78 if (local_surface_id_ != old_local_surface_id) {
77 surface_changed_callback_.Run( 79 surface_changed_callback_.Run(
78 cc::SurfaceId(frame_sink_id_, local_surface_id_), 80 cc::SurfaceId(frame_sink_id_, local_surface_id_), surface_size_);
79 last_submitted_frame_size_);
80 } 81 }
81 } 82 }
82 83
83 void CompositorFrameSinkLocal::DidReceiveCompositorFrameAck( 84 void CompositorFrameSinkLocal::DidReceiveCompositorFrameAck(
84 const cc::ReturnedResourceArray& resources) { 85 const cc::ReturnedResourceArray& resources) {
85 DCHECK(thread_checker_); 86 DCHECK(thread_checker_);
86 DCHECK(thread_checker_->CalledOnValidThread()); 87 DCHECK(thread_checker_->CalledOnValidThread());
87 if (!client_) 88 if (!client_)
88 return; 89 return;
89 if (!resources.empty()) 90 if (!resources.empty())
(...skipping 24 matching lines...) Expand all
114 115
115 void CompositorFrameSinkLocal::OnDidFinishFrame(const cc::BeginFrameAck& ack) { 116 void CompositorFrameSinkLocal::OnDidFinishFrame(const cc::BeginFrameAck& ack) {
116 DCHECK(thread_checker_); 117 DCHECK(thread_checker_);
117 DCHECK(thread_checker_->CalledOnValidThread()); 118 DCHECK(thread_checker_->CalledOnValidThread());
118 // If there was damage, the submitted CompositorFrame includes the ack. 119 // If there was damage, the submitted CompositorFrame includes the ack.
119 if (!ack.has_damage) 120 if (!ack.has_damage)
120 support_->BeginFrameDidNotSwap(ack); 121 support_->BeginFrameDidNotSwap(ack);
121 } 122 }
122 123
123 } // namespace aura 124 } // namespace aura
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698