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

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

Issue 767443002: Ensure Surface size always matches window size on swap (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years 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/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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 42
43 Display::~Display() { 43 Display::~Display() {
44 manager_->RemoveObserver(this); 44 manager_->RemoveObserver(this);
45 } 45 }
46 46
47 bool Display::Initialize(scoped_ptr<OutputSurface> output_surface) { 47 bool Display::Initialize(scoped_ptr<OutputSurface> output_surface) {
48 output_surface_ = output_surface.Pass(); 48 output_surface_ = output_surface.Pass();
49 return output_surface_->BindToClient(this); 49 return output_surface_->BindToClient(this);
50 } 50 }
51 51
52 void Display::Resize(SurfaceId id, 52 void Display::SetSurfaceId(SurfaceId id, float device_scale_factor) {
53 const gfx::Size& size,
54 float device_scale_factor) {
55 current_surface_id_ = id; 53 current_surface_id_ = id;
54 device_scale_factor_ = device_scale_factor;
55 client_->DisplayDamaged();
56 }
57
58 void Display::Resize(const gfx::Size& size) {
59 if (size == current_surface_size_)
60 return;
61 if (renderer_)
62 renderer_->Finish();
jamesr 2014/12/02 00:04:17 add a comment here indicating why we need to finis
56 current_surface_size_ = size; 63 current_surface_size_ = size;
57 device_scale_factor_ = device_scale_factor;
58 client_->DisplayDamaged(); 64 client_->DisplayDamaged();
59 } 65 }
60 66
61 void Display::InitializeRenderer() { 67 void Display::InitializeRenderer() {
62 if (resource_provider_) 68 if (resource_provider_)
63 return; 69 return;
64 70
65 scoped_ptr<ResourceProvider> resource_provider = ResourceProvider::Create( 71 scoped_ptr<ResourceProvider> resource_provider = ResourceProvider::Create(
66 output_surface_.get(), bitmap_manager_, gpu_memory_buffer_manager_, 72 output_surface_.get(), bitmap_manager_, gpu_memory_buffer_manager_,
67 blocking_main_thread_task_runner_.get(), settings_.highp_threshold_min, 73 blocking_main_thread_task_runner_.get(), settings_.highp_threshold_min,
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 // while Aggregate is called to immediately run release callbacks afterward. 111 // while Aggregate is called to immediately run release callbacks afterward.
106 scoped_ptr<CompositorFrame> frame = 112 scoped_ptr<CompositorFrame> frame =
107 aggregator_->Aggregate(current_surface_id_); 113 aggregator_->Aggregate(current_surface_id_);
108 if (!frame) 114 if (!frame)
109 return false; 115 return false;
110 116
111 TRACE_EVENT0("cc", "Display::Draw"); 117 TRACE_EVENT0("cc", "Display::Draw");
112 benchmark_instrumentation::IssueDisplayRenderingStatsEvent(); 118 benchmark_instrumentation::IssueDisplayRenderingStatsEvent();
113 DelegatedFrameData* frame_data = frame->delegated_frame_data.get(); 119 DelegatedFrameData* frame_data = frame->delegated_frame_data.get();
114 120
121 gfx::Size surface_size;
122 if (!frame_data->render_pass_list.empty())
jamesr 2014/12/02 00:04:17 hmm, maybe Aggregate() should return a null frame
123 surface_size = frame_data->render_pass_list.back()->output_rect.size();
124
115 gfx::Rect device_viewport_rect = gfx::Rect(current_surface_size_); 125 gfx::Rect device_viewport_rect = gfx::Rect(current_surface_size_);
116 gfx::Rect device_clip_rect = device_viewport_rect; 126 gfx::Rect device_clip_rect = device_viewport_rect;
117 bool disable_picture_quad_image_filtering = false; 127 bool disable_picture_quad_image_filtering = false;
118 128
119 renderer_->DecideRenderPassAllocationsForFrame(frame_data->render_pass_list); 129 renderer_->DecideRenderPassAllocationsForFrame(frame_data->render_pass_list);
120 renderer_->DrawFrame(&frame_data->render_pass_list, 130 renderer_->DrawFrame(&frame_data->render_pass_list,
121 device_scale_factor_, 131 device_scale_factor_,
122 device_viewport_rect, 132 device_viewport_rect,
123 device_clip_rect, 133 device_clip_rect,
124 disable_picture_quad_image_filtering); 134 disable_picture_quad_image_filtering);
125 renderer_->SwapBuffers(frame->metadata); 135
136 if (surface_size == current_surface_size_) {
137 renderer_->SwapBuffers(frame->metadata);
138 } else {
139 DidSwapBuffers();
140 DidSwapBuffersComplete();
piman 2014/12/01 23:42:09 Do we need to respect order wrt surface callbacks
141 }
142
126 for (SurfaceAggregator::SurfaceIndexMap::iterator it = 143 for (SurfaceAggregator::SurfaceIndexMap::iterator it =
127 aggregator_->previous_contained_surfaces().begin(); 144 aggregator_->previous_contained_surfaces().begin();
128 it != aggregator_->previous_contained_surfaces().end(); 145 it != aggregator_->previous_contained_surfaces().end();
129 ++it) { 146 ++it) {
130 Surface* surface = manager_->GetSurfaceForId(it->first); 147 Surface* surface = manager_->GetSurfaceForId(it->first);
131 if (surface) 148 if (surface)
132 surface->RunDrawCallbacks(); 149 surface->RunDrawCallbacks();
jamesr 2014/12/02 00:04:17 we probably don't want to run these if we didn't a
133 } 150 }
134 return true; 151 return true;
135 } 152 }
136 153
137 void Display::DidSwapBuffers() { 154 void Display::DidSwapBuffers() {
138 client_->DidSwapBuffers(); 155 client_->DidSwapBuffers();
139 } 156 }
140 157
141 void Display::DidSwapBuffersComplete() { 158 void Display::DidSwapBuffersComplete() {
142 client_->DidSwapBuffersComplete(); 159 client_->DidSwapBuffersComplete();
(...skipping 17 matching lines...) Expand all
160 return current_surface_id_; 177 return current_surface_id_;
161 } 178 }
162 179
163 int Display::GetMaxFramesPending() { 180 int Display::GetMaxFramesPending() {
164 if (!output_surface_) 181 if (!output_surface_)
165 return OutputSurface::DEFAULT_MAX_FRAMES_PENDING; 182 return OutputSurface::DEFAULT_MAX_FRAMES_PENDING;
166 return output_surface_->capabilities().max_frames_pending; 183 return output_surface_->capabilities().max_frames_pending;
167 } 184 }
168 185
169 } // namespace cc 186 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698