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 "ui/ozone/platform/drm/gpu/gbm_surfaceless.h" | 5 #include "ui/ozone/platform/drm/gpu/gbm_surfaceless.h" |
6 | 6 |
7 #include "ui/ozone/common/gpu/ozone_gpu_message_params.h" | |
7 #include "ui/ozone/platform/drm/gpu/drm_device.h" | 8 #include "ui/ozone/platform/drm/gpu/drm_device.h" |
8 #include "ui/ozone/platform/drm/gpu/drm_vsync_provider.h" | 9 #include "ui/ozone/platform/drm/gpu/drm_vsync_provider.h" |
9 #include "ui/ozone/platform/drm/gpu/drm_window_proxy.h" | 10 #include "ui/ozone/platform/drm/gpu/drm_window_proxy.h" |
10 #include "ui/ozone/platform/drm/gpu/gbm_surface_factory.h" | 11 #include "ui/ozone/platform/drm/gpu/gbm_surface_factory.h" |
11 #include "ui/ozone/platform/drm/gpu/scanout_buffer.h" | 12 #include "ui/ozone/platform/drm/gpu/scanout_buffer.h" |
12 | 13 |
13 namespace ui { | 14 namespace ui { |
14 | 15 |
15 GbmSurfaceless::GbmSurfaceless(scoped_ptr<DrmWindowProxy> window, | 16 GbmSurfaceless::GbmSurfaceless(scoped_ptr<DrmWindowProxy> window, |
16 GbmSurfaceFactory* surface_manager) | 17 GbmSurfaceFactory* surface_manager) |
17 : window_(window.Pass()), surface_manager_(surface_manager) { | 18 : window_(window.Pass()), |
19 surface_manager_(surface_manager), | |
20 weak_ptr_factory_(this) { | |
18 surface_manager_->RegisterSurface(window_->widget(), this); | 21 surface_manager_->RegisterSurface(window_->widget(), this); |
19 } | 22 } |
20 | 23 |
21 GbmSurfaceless::~GbmSurfaceless() { | 24 GbmSurfaceless::~GbmSurfaceless() { |
22 surface_manager_->UnregisterSurface(window_->widget()); | 25 surface_manager_->UnregisterSurface(window_->widget()); |
23 } | 26 } |
24 | 27 |
25 void GbmSurfaceless::QueueOverlayPlane(const OverlayPlane& plane) { | 28 void GbmSurfaceless::QueueOverlayPlane(const OverlayPlane& plane) { |
26 planes_.push_back(plane); | 29 planes_.push_back(plane); |
27 } | 30 } |
28 | 31 |
32 void GbmSurfaceless::EvaluateBufferConfiguration( | |
33 const gfx::Rect& display_rect, | |
34 const gfx::RectF& crop_rect, | |
35 const gfx::Size& buffer_size, | |
36 gfx::BufferFormat buffer_format, | |
37 gfx::OverlayTransform transform, | |
38 uint32_t z_order, | |
39 gfx::Size* target_size, | |
40 gfx::BufferFormat* target_format) { | |
41 OverlayCheck_Params lookup; | |
42 lookup.display_rect = display_rect; | |
43 lookup.crop_rect = crop_rect; | |
44 lookup.buffer_size = buffer_size; | |
45 lookup.format = buffer_format; | |
46 lookup.plane_z_order = z_order; | |
47 lookup.transform = transform; | |
48 | |
49 std::vector<OverlayCheck_Params>::iterator it; | |
50 it = std::find(overlay_params_.begin(), overlay_params_.end(), lookup); | |
51 if (it != overlay_params_.end()) { | |
52 *target_size = it->required_buffer_size; | |
53 *target_format = it->optimal_format; | |
54 } else { | |
55 *target_size = buffer_size; | |
56 *target_format = buffer_format; | |
57 } | |
58 } | |
59 | |
60 void GbmSurfaceless::GetOverlayBufferConfigurations( | |
61 const std::vector<OverlayCheck_Params>& params) { | |
62 overlay_params_ = params; | |
63 } | |
64 | |
29 intptr_t GbmSurfaceless::GetNativeWindow() { | 65 intptr_t GbmSurfaceless::GetNativeWindow() { |
30 NOTREACHED(); | 66 NOTREACHED(); |
31 return 0; | 67 return 0; |
32 } | 68 } |
33 | 69 |
34 bool GbmSurfaceless::ResizeNativeWindow(const gfx::Size& viewport_size) { | 70 bool GbmSurfaceless::ResizeNativeWindow(const gfx::Size& viewport_size) { |
35 return true; | 71 return true; |
36 } | 72 } |
37 | 73 |
38 bool GbmSurfaceless::OnSwapBuffers() { | 74 bool GbmSurfaceless::OnSwapBuffers() { |
39 NOTREACHED(); | 75 NOTREACHED(); |
40 return false; | 76 return false; |
41 } | 77 } |
42 | 78 |
43 void GbmSurfaceless::OnSwapBuffersAsync( | 79 void GbmSurfaceless::OnSwapBuffersAsync( |
44 const SwapCompletionCallback& callback) { | 80 const SwapCompletionCallback& callback) { |
81 window_->GetOverlayBufferConfigurations( | |
kalyank
2015/11/19 16:10:41
I am still looking if we can pass target size and
| |
82 base::Bind(&GbmSurfaceless::GetOverlayBufferConfigurations, | |
83 weak_ptr_factory_.GetWeakPtr())); | |
84 | |
45 window_->SchedulePageFlip(planes_, callback); | 85 window_->SchedulePageFlip(planes_, callback); |
46 planes_.clear(); | 86 planes_.clear(); |
47 } | 87 } |
48 | 88 |
49 scoped_ptr<gfx::VSyncProvider> GbmSurfaceless::CreateVSyncProvider() { | 89 scoped_ptr<gfx::VSyncProvider> GbmSurfaceless::CreateVSyncProvider() { |
50 return make_scoped_ptr(new DrmVSyncProvider(window_.get())); | 90 return make_scoped_ptr(new DrmVSyncProvider(window_.get())); |
51 } | 91 } |
52 | 92 |
53 bool GbmSurfaceless::IsUniversalDisplayLinkDevice() { | 93 bool GbmSurfaceless::IsUniversalDisplayLinkDevice() { |
54 return planes_.empty() ? false : planes_[0].buffer->RequiresGlFinish(); | 94 return planes_.empty() ? false : planes_[0].buffer->RequiresGlFinish(); |
55 } | 95 } |
56 | 96 |
57 } // namespace ui | 97 } // namespace ui |
OLD | NEW |