OLD | NEW |
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 Loading... |
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 // Need to ensure all pending swaps have executed before the window is |
| 62 // resized, or D3D11 will scale the swap output. |
| 63 if (renderer_ && settings_.finish_rendering_on_resize) |
| 64 renderer_->Finish(); |
56 current_surface_size_ = size; | 65 current_surface_size_ = size; |
57 device_scale_factor_ = device_scale_factor; | |
58 client_->DisplayDamaged(); | 66 client_->DisplayDamaged(); |
59 } | 67 } |
60 | 68 |
61 void Display::InitializeRenderer() { | 69 void Display::InitializeRenderer() { |
62 if (resource_provider_) | 70 if (resource_provider_) |
63 return; | 71 return; |
64 | 72 |
65 scoped_ptr<ResourceProvider> resource_provider = ResourceProvider::Create( | 73 scoped_ptr<ResourceProvider> resource_provider = ResourceProvider::Create( |
66 output_surface_.get(), bitmap_manager_, gpu_memory_buffer_manager_, | 74 output_surface_.get(), bitmap_manager_, gpu_memory_buffer_manager_, |
67 blocking_main_thread_task_runner_.get(), settings_.highp_threshold_min, | 75 blocking_main_thread_task_runner_.get(), settings_.highp_threshold_min, |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 // while Aggregate is called to immediately run release callbacks afterward. | 113 // while Aggregate is called to immediately run release callbacks afterward. |
106 scoped_ptr<CompositorFrame> frame = | 114 scoped_ptr<CompositorFrame> frame = |
107 aggregator_->Aggregate(current_surface_id_); | 115 aggregator_->Aggregate(current_surface_id_); |
108 if (!frame) | 116 if (!frame) |
109 return false; | 117 return false; |
110 | 118 |
111 TRACE_EVENT0("cc", "Display::Draw"); | 119 TRACE_EVENT0("cc", "Display::Draw"); |
112 benchmark_instrumentation::IssueDisplayRenderingStatsEvent(); | 120 benchmark_instrumentation::IssueDisplayRenderingStatsEvent(); |
113 DelegatedFrameData* frame_data = frame->delegated_frame_data.get(); | 121 DelegatedFrameData* frame_data = frame->delegated_frame_data.get(); |
114 | 122 |
| 123 gfx::Size surface_size = |
| 124 frame_data->render_pass_list.back()->output_rect.size(); |
| 125 |
115 gfx::Rect device_viewport_rect = gfx::Rect(current_surface_size_); | 126 gfx::Rect device_viewport_rect = gfx::Rect(current_surface_size_); |
116 gfx::Rect device_clip_rect = device_viewport_rect; | 127 gfx::Rect device_clip_rect = device_viewport_rect; |
117 bool disable_picture_quad_image_filtering = false; | 128 bool disable_picture_quad_image_filtering = false; |
118 | 129 |
119 renderer_->DecideRenderPassAllocationsForFrame(frame_data->render_pass_list); | 130 renderer_->DecideRenderPassAllocationsForFrame(frame_data->render_pass_list); |
120 renderer_->DrawFrame(&frame_data->render_pass_list, | 131 renderer_->DrawFrame(&frame_data->render_pass_list, |
121 device_scale_factor_, | 132 device_scale_factor_, |
122 device_viewport_rect, | 133 device_viewport_rect, |
123 device_clip_rect, | 134 device_clip_rect, |
124 disable_picture_quad_image_filtering); | 135 disable_picture_quad_image_filtering); |
125 renderer_->SwapBuffers(frame->metadata); | 136 |
| 137 bool disable_swap = surface_size != current_surface_size_; |
| 138 if (disable_swap) { |
| 139 DidSwapBuffers(); |
| 140 } else { |
| 141 renderer_->SwapBuffers(frame->metadata); |
| 142 } |
| 143 |
126 for (SurfaceAggregator::SurfaceIndexMap::iterator it = | 144 for (SurfaceAggregator::SurfaceIndexMap::iterator it = |
127 aggregator_->previous_contained_surfaces().begin(); | 145 aggregator_->previous_contained_surfaces().begin(); |
128 it != aggregator_->previous_contained_surfaces().end(); | 146 it != aggregator_->previous_contained_surfaces().end(); |
129 ++it) { | 147 ++it) { |
130 Surface* surface = manager_->GetSurfaceForId(it->first); | 148 Surface* surface = manager_->GetSurfaceForId(it->first); |
131 if (surface) | 149 if (surface) |
132 surface->RunDrawCallbacks(); | 150 surface->RunDrawCallbacks(); |
133 } | 151 } |
| 152 if (disable_swap) |
| 153 DidSwapBuffersComplete(); |
134 return true; | 154 return true; |
135 } | 155 } |
136 | 156 |
137 void Display::DidSwapBuffers() { | 157 void Display::DidSwapBuffers() { |
138 client_->DidSwapBuffers(); | 158 client_->DidSwapBuffers(); |
139 } | 159 } |
140 | 160 |
141 void Display::DidSwapBuffersComplete() { | 161 void Display::DidSwapBuffersComplete() { |
142 client_->DidSwapBuffersComplete(); | 162 client_->DidSwapBuffersComplete(); |
143 } | 163 } |
(...skipping 16 matching lines...) Expand all Loading... |
160 return current_surface_id_; | 180 return current_surface_id_; |
161 } | 181 } |
162 | 182 |
163 int Display::GetMaxFramesPending() { | 183 int Display::GetMaxFramesPending() { |
164 if (!output_surface_) | 184 if (!output_surface_) |
165 return OutputSurface::DEFAULT_MAX_FRAMES_PENDING; | 185 return OutputSurface::DEFAULT_MAX_FRAMES_PENDING; |
166 return output_surface_->capabilities().max_frames_pending; | 186 return output_surface_->capabilities().max_frames_pending; |
167 } | 187 } |
168 | 188 |
169 } // namespace cc | 189 } // namespace cc |
OLD | NEW |