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

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

Issue 885443002: Roll Chrome into Mojo. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Rebase to ToT mojo Created 5 years, 10 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
« no previous file with comments | « cc/surfaces/display.h ('k') | cc/surfaces/surface.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/display.h" 5 #include "cc/surfaces/display.h"
6 6
7 #include "base/debug/trace_event.h" 7 #include "base/debug/trace_event.h"
8 #include "base/message_loop/message_loop.h" 8 #include "base/message_loop/message_loop.h"
9 #include "cc/debug/benchmark_instrumentation.h" 9 #include "cc/debug/benchmark_instrumentation.h"
10 #include "cc/output/compositor_frame.h" 10 #include "cc/output/compositor_frame.h"
(...skipping 24 matching lines...) Expand all
35 device_scale_factor_(1.f), 35 device_scale_factor_(1.f),
36 blocking_main_thread_task_runner_( 36 blocking_main_thread_task_runner_(
37 BlockingTaskRunner::Create(base::MessageLoopProxy::current())), 37 BlockingTaskRunner::Create(base::MessageLoopProxy::current())),
38 texture_mailbox_deleter_( 38 texture_mailbox_deleter_(
39 new TextureMailboxDeleter(base::MessageLoopProxy::current())) { 39 new TextureMailboxDeleter(base::MessageLoopProxy::current())) {
40 manager_->AddObserver(this); 40 manager_->AddObserver(this);
41 } 41 }
42 42
43 Display::~Display() { 43 Display::~Display() {
44 manager_->RemoveObserver(this); 44 manager_->RemoveObserver(this);
45 if (aggregator_) {
46 for (const auto& id_entry : aggregator_->previous_contained_surfaces()) {
47 Surface* surface = manager_->GetSurfaceForId(id_entry.first);
48 if (surface)
49 surface->RunDrawCallbacks(SurfaceDrawStatus::DRAW_SKIPPED);
50 }
51 }
45 } 52 }
46 53
47 bool Display::Initialize(scoped_ptr<OutputSurface> output_surface) { 54 bool Display::Initialize(scoped_ptr<OutputSurface> output_surface) {
48 output_surface_ = output_surface.Pass(); 55 output_surface_ = output_surface.Pass();
49 return output_surface_->BindToClient(this); 56 return output_surface_->BindToClient(this);
50 } 57 }
51 58
52 void Display::SetSurfaceId(SurfaceId id, float device_scale_factor) { 59 void Display::SetSurfaceId(SurfaceId id, float device_scale_factor) {
53 current_surface_id_ = id; 60 current_surface_id_ = id;
54 device_scale_factor_ = device_scale_factor; 61 device_scale_factor_ = device_scale_factor;
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 if (!frame) 123 if (!frame)
117 return false; 124 return false;
118 125
119 TRACE_EVENT0("cc", "Display::Draw"); 126 TRACE_EVENT0("cc", "Display::Draw");
120 benchmark_instrumentation::IssueDisplayRenderingStatsEvent(); 127 benchmark_instrumentation::IssueDisplayRenderingStatsEvent();
121 128
122 // Run callbacks early to allow pipelining. 129 // Run callbacks early to allow pipelining.
123 for (const auto& id_entry : aggregator_->previous_contained_surfaces()) { 130 for (const auto& id_entry : aggregator_->previous_contained_surfaces()) {
124 Surface* surface = manager_->GetSurfaceForId(id_entry.first); 131 Surface* surface = manager_->GetSurfaceForId(id_entry.first);
125 if (surface) 132 if (surface)
126 surface->RunDrawCallbacks(); 133 surface->RunDrawCallbacks(SurfaceDrawStatus::DRAWN);
127 } 134 }
128 DelegatedFrameData* frame_data = frame->delegated_frame_data.get(); 135 DelegatedFrameData* frame_data = frame->delegated_frame_data.get();
129 136
130 gfx::Size surface_size = 137 gfx::Size surface_size =
131 frame_data->render_pass_list.back()->output_rect.size(); 138 frame_data->render_pass_list.back()->output_rect.size();
132 139
133 gfx::Rect device_viewport_rect = gfx::Rect(current_surface_size_); 140 gfx::Rect device_viewport_rect = gfx::Rect(current_surface_size_);
134 gfx::Rect device_clip_rect = device_viewport_rect; 141 gfx::Rect device_clip_rect = device_viewport_rect;
135 bool disable_picture_quad_image_filtering = false; 142 bool disable_picture_quad_image_filtering = false;
136 143
(...skipping 24 matching lines...) Expand all
161 168
162 void Display::CommitVSyncParameters(base::TimeTicks timebase, 169 void Display::CommitVSyncParameters(base::TimeTicks timebase,
163 base::TimeDelta interval) { 170 base::TimeDelta interval) {
164 client_->CommitVSyncParameters(timebase, interval); 171 client_->CommitVSyncParameters(timebase, interval);
165 } 172 }
166 173
167 void Display::SetMemoryPolicy(const ManagedMemoryPolicy& policy) { 174 void Display::SetMemoryPolicy(const ManagedMemoryPolicy& policy) {
168 client_->SetMemoryPolicy(policy); 175 client_->SetMemoryPolicy(policy);
169 } 176 }
170 177
171 void Display::OnSurfaceDamaged(SurfaceId surface_id) { 178 void Display::OnSurfaceDamaged(SurfaceId surface_id, bool* changed) {
172 if (aggregator_ && 179 if (aggregator_ &&
173 aggregator_->previous_contained_surfaces().count(surface_id)) { 180 aggregator_->previous_contained_surfaces().count(surface_id)) {
174 Surface* surface = manager_->GetSurfaceForId(surface_id); 181 Surface* surface = manager_->GetSurfaceForId(surface_id);
175 if (surface) { 182 if (surface) {
176 const CompositorFrame* current_frame = surface->GetEligibleFrame(); 183 const CompositorFrame* current_frame = surface->GetEligibleFrame();
177 if (!current_frame || !current_frame->delegated_frame_data || 184 if (!current_frame || !current_frame->delegated_frame_data ||
178 !current_frame->delegated_frame_data->resource_list.size()) 185 !current_frame->delegated_frame_data->resource_list.size())
179 aggregator_->ReleaseResources(surface_id); 186 aggregator_->ReleaseResources(surface_id);
180 } 187 }
181 client_->DisplayDamaged(); 188 client_->DisplayDamaged();
189 *changed = true;
190 } else if (surface_id == current_surface_id_) {
191 client_->DisplayDamaged();
192 *changed = true;
182 } 193 }
183 } 194 }
184 195
185 SurfaceId Display::CurrentSurfaceId() { 196 SurfaceId Display::CurrentSurfaceId() {
186 return current_surface_id_; 197 return current_surface_id_;
187 } 198 }
188 199
189 int Display::GetMaxFramesPending() { 200 int Display::GetMaxFramesPending() {
190 if (!output_surface_) 201 if (!output_surface_)
191 return OutputSurface::DEFAULT_MAX_FRAMES_PENDING; 202 return OutputSurface::DEFAULT_MAX_FRAMES_PENDING;
192 return output_surface_->capabilities().max_frames_pending; 203 return output_surface_->capabilities().max_frames_pending;
193 } 204 }
194 205
195 } // namespace cc 206 } // namespace cc
OLDNEW
« no previous file with comments | « cc/surfaces/display.h ('k') | cc/surfaces/surface.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698