Chromium Code Reviews| 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 "components/mus/ws/platform_display.h" | 5 #include "components/mus/ws/platform_display.h" |
| 6 | 6 |
| 7 #include "base/numerics/safe_conversions.h" | 7 #include "base/numerics/safe_conversions.h" |
| 8 #include "build/build_config.h" | 8 #include "build/build_config.h" |
| 9 #include "cc/ipc/quads.mojom.h" | 9 #include "cc/ipc/quads.mojom.h" |
| 10 #include "cc/output/compositor_frame.h" | |
| 11 #include "cc/output/copy_output_request.h" | 10 #include "cc/output/copy_output_request.h" |
| 12 #include "cc/output/delegated_frame_data.h" | 11 #include "cc/output/delegated_frame_data.h" |
| 13 #include "cc/quads/render_pass.h" | |
| 14 #include "cc/quads/shared_quad_state.h" | |
| 15 #include "cc/quads/surface_draw_quad.h" | |
| 16 #include "components/mus/gles2/gpu_state.h" | 12 #include "components/mus/gles2/gpu_state.h" |
| 17 #include "components/mus/public/interfaces/gpu.mojom.h" | 13 #include "components/mus/public/interfaces/gpu.mojom.h" |
| 18 #include "components/mus/surfaces/display_compositor.h" | |
| 19 #include "components/mus/surfaces/surfaces_state.h" | 14 #include "components/mus/surfaces/surfaces_state.h" |
| 20 #include "components/mus/ws/platform_display_factory.h" | 15 #include "components/mus/ws/platform_display_factory.h" |
| 16 #include "components/mus/ws/platform_display_init_params.h" | |
| 21 #include "components/mus/ws/server_window.h" | 17 #include "components/mus/ws/server_window.h" |
| 22 #include "components/mus/ws/server_window_surface.h" | |
| 23 #include "components/mus/ws/server_window_surface_manager.h" | |
| 24 #include "components/mus/ws/window_coordinate_conversions.h" | 18 #include "components/mus/ws/window_coordinate_conversions.h" |
| 25 #include "services/shell/public/cpp/connection.h" | 19 #include "services/shell/public/cpp/connection.h" |
| 26 #include "services/shell/public/cpp/connector.h" | 20 #include "services/shell/public/cpp/connector.h" |
| 27 #include "third_party/skia/include/core/SkXfermode.h" | 21 #include "third_party/skia/include/core/SkXfermode.h" |
| 28 #include "ui/base/cursor/cursor_loader.h" | 22 #include "ui/base/cursor/cursor_loader.h" |
| 29 #include "ui/display/display.h" | 23 #include "ui/display/display.h" |
| 30 #include "ui/events/event.h" | 24 #include "ui/events/event.h" |
| 31 #include "ui/events/event_utils.h" | 25 #include "ui/events/event_utils.h" |
| 32 #include "ui/platform_window/platform_ime_controller.h" | 26 #include "ui/platform_window/platform_ime_controller.h" |
| 33 #include "ui/platform_window/platform_window.h" | 27 #include "ui/platform_window/platform_window.h" |
| 34 | 28 |
| 35 #if defined(OS_WIN) | 29 #if defined(OS_WIN) |
| 36 #include "ui/platform_window/win/win_window.h" | 30 #include "ui/platform_window/win/win_window.h" |
| 37 #elif defined(USE_X11) | 31 #elif defined(USE_X11) |
| 38 #include "ui/platform_window/x11/x11_window.h" | 32 #include "ui/platform_window/x11/x11_window.h" |
| 39 #elif defined(OS_ANDROID) | 33 #elif defined(OS_ANDROID) |
| 40 #include "ui/platform_window/android/platform_window_android.h" | 34 #include "ui/platform_window/android/platform_window_android.h" |
| 41 #elif defined(USE_OZONE) | 35 #elif defined(USE_OZONE) |
| 42 #include "ui/ozone/public/ozone_platform.h" | 36 #include "ui/ozone/public/ozone_platform.h" |
| 43 #endif | 37 #endif |
| 44 | 38 |
| 45 namespace mus { | 39 namespace mus { |
| 46 | 40 |
| 47 namespace ws { | 41 namespace ws { |
| 48 namespace { | |
| 49 | |
| 50 // DrawWindowTree recursively visits ServerWindows, creating a SurfaceDrawQuad | |
| 51 // for each that lacks one. | |
| 52 void DrawWindowTree(cc::RenderPass* pass, | |
| 53 ServerWindow* window, | |
| 54 const gfx::Vector2d& parent_to_root_origin_offset, | |
| 55 float opacity) { | |
| 56 if (!window->visible()) | |
| 57 return; | |
| 58 | |
| 59 ServerWindowSurface* default_surface = | |
| 60 window->surface_manager() ? window->surface_manager()->GetDefaultSurface() | |
| 61 : nullptr; | |
| 62 | |
| 63 const gfx::Rect absolute_bounds = | |
| 64 window->bounds() + parent_to_root_origin_offset; | |
| 65 std::vector<ServerWindow*> children(window->GetChildren()); | |
| 66 // TODO(rjkroege, fsamuel): Make sure we're handling alpha correctly. | |
| 67 const float combined_opacity = opacity * window->opacity(); | |
| 68 for (auto it = children.rbegin(); it != children.rend(); ++it) { | |
| 69 DrawWindowTree(pass, *it, absolute_bounds.OffsetFromOrigin(), | |
| 70 combined_opacity); | |
| 71 } | |
| 72 | |
| 73 if (!window->surface_manager() || !window->surface_manager()->ShouldDraw()) | |
| 74 return; | |
| 75 | |
| 76 ServerWindowSurface* underlay_surface = | |
| 77 window->surface_manager()->GetUnderlaySurface(); | |
| 78 if (!default_surface && !underlay_surface) | |
| 79 return; | |
| 80 | |
| 81 if (default_surface) { | |
| 82 gfx::Transform quad_to_target_transform; | |
| 83 quad_to_target_transform.Translate(absolute_bounds.x(), | |
| 84 absolute_bounds.y()); | |
| 85 | |
| 86 cc::SharedQuadState* sqs = pass->CreateAndAppendSharedQuadState(); | |
| 87 | |
| 88 const gfx::Rect bounds_at_origin(window->bounds().size()); | |
| 89 // TODO(fsamuel): These clipping and visible rects are incorrect. They need | |
| 90 // to be populated from CompositorFrame structs. | |
| 91 sqs->SetAll(quad_to_target_transform, | |
| 92 bounds_at_origin.size() /* layer_bounds */, | |
| 93 bounds_at_origin /* visible_layer_bounds */, | |
| 94 bounds_at_origin /* clip_rect */, false /* is_clipped */, | |
| 95 window->opacity(), SkXfermode::kSrcOver_Mode, | |
| 96 0 /* sorting-context_id */); | |
| 97 auto quad = pass->CreateAndAppendDrawQuad<cc::SurfaceDrawQuad>(); | |
| 98 quad->SetAll(sqs, bounds_at_origin /* rect */, | |
| 99 gfx::Rect() /* opaque_rect */, | |
| 100 bounds_at_origin /* visible_rect */, true /* needs_blending*/, | |
| 101 default_surface->id()); | |
| 102 } | |
| 103 if (underlay_surface) { | |
| 104 const gfx::Rect underlay_absolute_bounds = | |
| 105 absolute_bounds - window->underlay_offset(); | |
| 106 gfx::Transform quad_to_target_transform; | |
| 107 quad_to_target_transform.Translate(underlay_absolute_bounds.x(), | |
| 108 underlay_absolute_bounds.y()); | |
| 109 cc::SharedQuadState* sqs = pass->CreateAndAppendSharedQuadState(); | |
| 110 const gfx::Rect bounds_at_origin( | |
| 111 underlay_surface->last_submitted_frame_size()); | |
| 112 sqs->SetAll(quad_to_target_transform, | |
| 113 bounds_at_origin.size() /* layer_bounds */, | |
| 114 bounds_at_origin /* visible_layer_bounds */, | |
| 115 bounds_at_origin /* clip_rect */, false /* is_clipped */, | |
| 116 window->opacity(), SkXfermode::kSrcOver_Mode, | |
| 117 0 /* sorting-context_id */); | |
| 118 | |
| 119 auto quad = pass->CreateAndAppendDrawQuad<cc::SurfaceDrawQuad>(); | |
| 120 quad->SetAll(sqs, bounds_at_origin /* rect */, | |
| 121 gfx::Rect() /* opaque_rect */, | |
| 122 bounds_at_origin /* visible_rect */, true /* needs_blending*/, | |
| 123 underlay_surface->id()); | |
| 124 } | |
| 125 } | |
| 126 | |
| 127 } // namespace | |
| 128 | 42 |
| 129 // static | 43 // static |
| 130 PlatformDisplayFactory* PlatformDisplay::factory_ = nullptr; | 44 PlatformDisplayFactory* PlatformDisplay::factory_ = nullptr; |
| 131 | 45 |
| 132 // static | 46 // static |
| 133 PlatformDisplay* PlatformDisplay::Create( | 47 PlatformDisplay* PlatformDisplay::Create( |
| 134 const PlatformDisplayInitParams& init_params) { | 48 const PlatformDisplayInitParams& init_params) { |
| 135 if (factory_) | 49 if (factory_) |
| 136 return factory_->CreatePlatformDisplay(); | 50 return factory_->CreatePlatformDisplay(); |
| 137 | 51 |
| 138 return new DefaultPlatformDisplay(init_params); | 52 return new DefaultPlatformDisplay(init_params); |
| 139 } | 53 } |
| 140 | 54 |
| 141 DefaultPlatformDisplay::DefaultPlatformDisplay( | 55 DefaultPlatformDisplay::DefaultPlatformDisplay( |
| 142 const PlatformDisplayInitParams& init_params) | 56 const PlatformDisplayInitParams& init_params) |
| 143 : display_id_(init_params.display_id), | 57 : display_id_(init_params.display_id), |
| 144 gpu_state_(init_params.gpu_state), | |
| 145 surfaces_state_(init_params.surfaces_state), | |
| 146 delegate_(nullptr), | |
| 147 draw_timer_(false, false), | |
| 148 frame_pending_(false), | |
| 149 #if !defined(OS_ANDROID) | 58 #if !defined(OS_ANDROID) |
| 150 cursor_loader_(ui::CursorLoader::Create()), | 59 cursor_loader_(ui::CursorLoader::Create()), |
| 151 #endif | 60 #endif |
| 152 weak_factory_(this) { | 61 frame_generator_(new FrameGenerator(this, |
| 62 init_params.gpu_state, | |
| 63 init_params.surfaces_state)) { | |
| 153 metrics_.size_in_pixels = init_params.display_bounds.size(); | 64 metrics_.size_in_pixels = init_params.display_bounds.size(); |
| 154 // TODO(rjkroege): Preserve the display_id when Ozone platform can use it. | 65 // TODO(rjkroege): Preserve the display_id when Ozone platform can use it. |
| 155 } | 66 } |
| 156 | 67 |
| 157 void DefaultPlatformDisplay::Init(PlatformDisplayDelegate* delegate) { | 68 void DefaultPlatformDisplay::Init(PlatformDisplayDelegate* delegate) { |
| 158 delegate_ = delegate; | 69 delegate_ = delegate; |
| 159 | 70 |
| 160 gfx::Rect bounds(metrics_.size_in_pixels); | 71 gfx::Rect bounds(metrics_.size_in_pixels); |
| 161 #if defined(OS_WIN) | 72 #if defined(OS_WIN) |
| 162 platform_window_.reset(new ui::WinWindow(this, bounds)); | 73 platform_window_.reset(new ui::WinWindow(this, bounds)); |
| 163 #elif defined(USE_X11) | 74 #elif defined(USE_X11) |
| 164 platform_window_.reset(new ui::X11Window(this)); | 75 platform_window_.reset(new ui::X11Window(this)); |
| 165 #elif defined(OS_ANDROID) | 76 #elif defined(OS_ANDROID) |
| 166 platform_window_.reset(new ui::PlatformWindowAndroid(this)); | 77 platform_window_.reset(new ui::PlatformWindowAndroid(this)); |
| 167 #elif defined(USE_OZONE) | 78 #elif defined(USE_OZONE) |
| 168 platform_window_ = | 79 platform_window_ = |
| 169 ui::OzonePlatform::GetInstance()->CreatePlatformWindow(this, bounds); | 80 ui::OzonePlatform::GetInstance()->CreatePlatformWindow(this, bounds); |
| 170 #else | 81 #else |
| 171 NOTREACHED() << "Unsupported platform"; | 82 NOTREACHED() << "Unsupported platform"; |
| 172 #endif | 83 #endif |
| 173 platform_window_->SetBounds(bounds); | 84 platform_window_->SetBounds(bounds); |
| 174 platform_window_->Show(); | 85 platform_window_->Show(); |
| 175 } | 86 } |
| 176 | 87 |
| 177 DefaultPlatformDisplay::~DefaultPlatformDisplay() { | 88 DefaultPlatformDisplay::~DefaultPlatformDisplay() { |
| 178 // Don't notify the delegate from the destructor. | 89 // Don't notify the delegate from the destructor. |
| 179 delegate_ = nullptr; | 90 delegate_ = nullptr; |
| 180 | 91 |
| 181 // Invalidate WeakPtrs now to avoid callbacks back into the | 92 frame_generator_.reset(); |
| 182 // DefaultPlatformDisplay during destruction of |display_compositor_|. | |
| 183 weak_factory_.InvalidateWeakPtrs(); | |
| 184 display_compositor_.reset(); | |
| 185 // Destroy the PlatformWindow early on as it may call us back during | 93 // Destroy the PlatformWindow early on as it may call us back during |
| 186 // destruction and we want to be in a known state. But destroy the surface | 94 // destruction and we want to be in a known state. But destroy the surface |
| 187 // first because it can still be using the platform window. | 95 // first because it can still be using the platform window. |
| 188 platform_window_.reset(); | 96 platform_window_.reset(); |
| 189 } | 97 } |
| 190 | 98 |
| 191 void DefaultPlatformDisplay::SchedulePaint(const ServerWindow* window, | 99 void DefaultPlatformDisplay::SchedulePaint(const ServerWindow* window, |
| 192 const gfx::Rect& bounds) { | 100 const gfx::Rect& bounds) { |
| 193 DCHECK(window); | 101 DCHECK(window); |
| 194 if (!window->IsDrawn()) | 102 if (!window->IsDrawn()) |
| 195 return; | 103 return; |
| 196 const gfx::Rect root_relative_rect = | 104 const gfx::Rect root_relative_rect = |
| 197 ConvertRectBetweenWindows(window, delegate_->GetRootWindow(), bounds); | 105 ConvertRectBetweenWindows(window, delegate_->GetRootWindow(), bounds); |
| 198 if (root_relative_rect.IsEmpty()) | 106 if (root_relative_rect.IsEmpty()) |
| 199 return; | 107 return; |
| 200 dirty_rect_.Union(root_relative_rect); | 108 frame_generator_->RequestRedraw(root_relative_rect); |
| 201 WantToDraw(); | |
| 202 } | 109 } |
| 203 | 110 |
| 204 void DefaultPlatformDisplay::SetViewportSize(const gfx::Size& size) { | 111 void DefaultPlatformDisplay::SetViewportSize(const gfx::Size& size) { |
| 205 platform_window_->SetBounds(gfx::Rect(size)); | 112 platform_window_->SetBounds(gfx::Rect(size)); |
| 206 } | 113 } |
| 207 | 114 |
| 208 void DefaultPlatformDisplay::SetTitle(const base::string16& title) { | 115 void DefaultPlatformDisplay::SetTitle(const base::string16& title) { |
| 209 platform_window_->SetTitle(title); | 116 platform_window_->SetTitle(title); |
| 210 } | 117 } |
| 211 | 118 |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 245 if (ime) | 152 if (ime) |
| 246 ime->UpdateTextInputState(state); | 153 ime->UpdateTextInputState(state); |
| 247 } | 154 } |
| 248 | 155 |
| 249 void DefaultPlatformDisplay::SetImeVisibility(bool visible) { | 156 void DefaultPlatformDisplay::SetImeVisibility(bool visible) { |
| 250 ui::PlatformImeController* ime = platform_window_->GetPlatformImeController(); | 157 ui::PlatformImeController* ime = platform_window_->GetPlatformImeController(); |
| 251 if (ime) | 158 if (ime) |
| 252 ime->SetImeVisibility(visible); | 159 ime->SetImeVisibility(visible); |
| 253 } | 160 } |
| 254 | 161 |
| 255 void DefaultPlatformDisplay::Draw() { | |
| 256 if (!delegate_->GetRootWindow()->visible()) | |
| 257 return; | |
| 258 | |
| 259 // TODO(fsamuel): We should add a trace for generating a top level frame. | |
| 260 std::unique_ptr<cc::CompositorFrame> frame(GenerateCompositorFrame()); | |
| 261 frame_pending_ = true; | |
| 262 if (display_compositor_) { | |
| 263 display_compositor_->SubmitCompositorFrame( | |
| 264 std::move(frame), base::Bind(&DefaultPlatformDisplay::DidDraw, | |
| 265 weak_factory_.GetWeakPtr())); | |
| 266 } | |
| 267 dirty_rect_ = gfx::Rect(); | |
| 268 } | |
| 269 | |
| 270 void DefaultPlatformDisplay::DidDraw(cc::SurfaceDrawStatus status) { | |
| 271 frame_pending_ = false; | |
| 272 delegate_->OnCompositorFrameDrawn(); | |
| 273 if (!dirty_rect_.IsEmpty()) | |
| 274 WantToDraw(); | |
| 275 } | |
| 276 | |
| 277 bool DefaultPlatformDisplay::IsFramePending() const { | 162 bool DefaultPlatformDisplay::IsFramePending() const { |
| 278 return frame_pending_; | 163 return frame_generator_->is_frame_pending(); |
| 279 } | 164 } |
| 280 | 165 |
| 281 int64_t DefaultPlatformDisplay::GetDisplayId() const { | 166 int64_t DefaultPlatformDisplay::GetDisplayId() const { |
| 282 return display_id_; | 167 return display_id_; |
| 283 } | 168 } |
| 284 | 169 |
| 285 void DefaultPlatformDisplay::WantToDraw() { | |
| 286 if (draw_timer_.IsRunning() || frame_pending_) | |
| 287 return; | |
| 288 | |
| 289 // TODO(rjkroege): Use vblank to kick off Draw. | |
| 290 draw_timer_.Start( | |
| 291 FROM_HERE, base::TimeDelta(), | |
| 292 base::Bind(&DefaultPlatformDisplay::Draw, weak_factory_.GetWeakPtr())); | |
| 293 } | |
| 294 | |
| 295 void DefaultPlatformDisplay::UpdateMetrics(const gfx::Size& size, | 170 void DefaultPlatformDisplay::UpdateMetrics(const gfx::Size& size, |
| 296 float device_scale_factor) { | 171 float device_scale_factor) { |
| 297 if (display::Display::HasForceDeviceScaleFactor()) | 172 if (display::Display::HasForceDeviceScaleFactor()) |
| 298 device_scale_factor = display::Display::GetForcedDeviceScaleFactor(); | 173 device_scale_factor = display::Display::GetForcedDeviceScaleFactor(); |
| 299 if (metrics_.size_in_pixels == size && | 174 if (metrics_.size_in_pixels == size && |
| 300 metrics_.device_scale_factor == device_scale_factor) | 175 metrics_.device_scale_factor == device_scale_factor) |
| 301 return; | 176 return; |
| 302 | 177 |
| 303 ViewportMetrics old_metrics = metrics_; | 178 ViewportMetrics old_metrics = metrics_; |
| 304 metrics_.size_in_pixels = size; | 179 metrics_.size_in_pixels = size; |
| 305 metrics_.device_scale_factor = device_scale_factor; | 180 metrics_.device_scale_factor = device_scale_factor; |
| 306 delegate_->OnViewportMetricsChanged(old_metrics, metrics_); | 181 delegate_->OnViewportMetricsChanged(old_metrics, metrics_); |
| 307 } | 182 } |
| 308 | 183 |
| 309 std::unique_ptr<cc::CompositorFrame> | |
| 310 DefaultPlatformDisplay::GenerateCompositorFrame() { | |
| 311 std::unique_ptr<cc::RenderPass> render_pass = cc::RenderPass::Create(); | |
| 312 render_pass->damage_rect = dirty_rect_; | |
| 313 render_pass->output_rect = gfx::Rect(metrics_.size_in_pixels); | |
| 314 | |
| 315 DrawWindowTree(render_pass.get(), delegate_->GetRootWindow(), gfx::Vector2d(), | |
| 316 1.0f); | |
| 317 | |
| 318 std::unique_ptr<cc::DelegatedFrameData> frame_data( | |
| 319 new cc::DelegatedFrameData); | |
| 320 frame_data->device_scale_factor = metrics_.device_scale_factor; | |
| 321 frame_data->render_pass_list.push_back(std::move(render_pass)); | |
| 322 | |
| 323 std::unique_ptr<cc::CompositorFrame> frame(new cc::CompositorFrame); | |
| 324 frame->delegated_frame_data = std::move(frame_data); | |
| 325 return frame; | |
| 326 } | |
| 327 | |
| 328 void DefaultPlatformDisplay::OnBoundsChanged(const gfx::Rect& new_bounds) { | 184 void DefaultPlatformDisplay::OnBoundsChanged(const gfx::Rect& new_bounds) { |
| 329 UpdateMetrics(new_bounds.size(), metrics_.device_scale_factor); | 185 UpdateMetrics(new_bounds.size(), metrics_.device_scale_factor); |
| 330 } | 186 } |
| 331 | 187 |
| 332 void DefaultPlatformDisplay::OnDamageRect(const gfx::Rect& damaged_region) { | 188 void DefaultPlatformDisplay::OnDamageRect(const gfx::Rect& damaged_region) { |
| 333 dirty_rect_.Union(damaged_region); | 189 frame_generator_->RequestRedraw(damaged_region); |
| 334 WantToDraw(); | |
| 335 } | 190 } |
| 336 | 191 |
| 337 void DefaultPlatformDisplay::DispatchEvent(ui::Event* event) { | 192 void DefaultPlatformDisplay::DispatchEvent(ui::Event* event) { |
| 338 if (event->IsScrollEvent()) { | 193 if (event->IsScrollEvent()) { |
| 339 // TODO(moshayedi): crbug.com/602859. Dispatch scroll events as | 194 // TODO(moshayedi): crbug.com/602859. Dispatch scroll events as |
| 340 // they are once we have proper support for scroll events. | 195 // they are once we have proper support for scroll events. |
| 341 delegate_->OnEvent(ui::MouseWheelEvent(*event->AsScrollEvent())); | 196 delegate_->OnEvent(ui::MouseWheelEvent(*event->AsScrollEvent())); |
| 342 } else if (event->IsMouseEvent() && !event->IsMouseWheelEvent()) { | 197 } else if (event->IsMouseEvent() && !event->IsMouseWheelEvent()) { |
| 343 delegate_->OnEvent(ui::PointerEvent(*event->AsMouseEvent())); | 198 delegate_->OnEvent(ui::PointerEvent(*event->AsMouseEvent())); |
| 344 } else if (event->IsTouchEvent()) { | 199 } else if (event->IsTouchEvent()) { |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 384 void DefaultPlatformDisplay::OnWindowStateChanged( | 239 void DefaultPlatformDisplay::OnWindowStateChanged( |
| 385 ui::PlatformWindowState new_state) {} | 240 ui::PlatformWindowState new_state) {} |
| 386 | 241 |
| 387 void DefaultPlatformDisplay::OnLostCapture() { | 242 void DefaultPlatformDisplay::OnLostCapture() { |
| 388 delegate_->OnNativeCaptureLost(); | 243 delegate_->OnNativeCaptureLost(); |
| 389 } | 244 } |
| 390 | 245 |
| 391 void DefaultPlatformDisplay::OnAcceleratedWidgetAvailable( | 246 void DefaultPlatformDisplay::OnAcceleratedWidgetAvailable( |
| 392 gfx::AcceleratedWidget widget, | 247 gfx::AcceleratedWidget widget, |
| 393 float device_scale_factor) { | 248 float device_scale_factor) { |
| 394 if (widget != gfx::kNullAcceleratedWidget) { | 249 frame_generator_->OnAcceleratedWidgetAvailable(widget); |
|
sky
2016/06/30 23:40:20
Could we delay creation of frame_generator until w
mfomitchev
2016/07/06 15:53:09
That would mean that we'd need to add gpu_state an
| |
| 395 display_compositor_.reset( | |
| 396 new DisplayCompositor(base::ThreadTaskRunnerHandle::Get(), widget, | |
| 397 gpu_state_, surfaces_state_)); | |
| 398 } | |
| 399 UpdateMetrics(metrics_.size_in_pixels, device_scale_factor); | 250 UpdateMetrics(metrics_.size_in_pixels, device_scale_factor); |
| 400 } | 251 } |
| 401 | 252 |
| 402 void DefaultPlatformDisplay::OnAcceleratedWidgetDestroyed() { | 253 void DefaultPlatformDisplay::OnAcceleratedWidgetDestroyed() { |
| 403 NOTREACHED(); | 254 NOTREACHED(); |
| 404 } | 255 } |
| 405 | 256 |
| 406 void DefaultPlatformDisplay::OnActivationChanged(bool active) {} | 257 void DefaultPlatformDisplay::OnActivationChanged(bool active) {} |
| 407 | 258 |
| 408 void DefaultPlatformDisplay::RequestCopyOfOutput( | 259 void DefaultPlatformDisplay::RequestCopyOfOutput( |
| 409 std::unique_ptr<cc::CopyOutputRequest> output_request) { | 260 std::unique_ptr<cc::CopyOutputRequest> output_request) { |
| 410 if (display_compositor_) | 261 frame_generator_->RequestCopyOfOutput(std::move(output_request)); |
| 411 display_compositor_->RequestCopyOfOutput(std::move(output_request)); | 262 } |
| 263 | |
| 264 ServerWindow* DefaultPlatformDisplay::GetRootWindow() { | |
| 265 return delegate_->GetRootWindow(); | |
| 266 } | |
| 267 | |
| 268 void DefaultPlatformDisplay::OnCompositorFrameDrawn() { | |
| 269 if (delegate_) | |
| 270 delegate_->OnCompositorFrameDrawn(); | |
| 271 } | |
| 272 | |
| 273 const ViewportMetrics& DefaultPlatformDisplay::GetViewportMetrics() { | |
| 274 return metrics_; | |
| 412 } | 275 } |
| 413 | 276 |
| 414 } // namespace ws | 277 } // namespace ws |
| 415 | 278 |
| 416 } // namespace mus | 279 } // namespace mus |
| OLD | NEW |