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/dri/gbm_surface.h" | 5 #include "ui/ozone/platform/dri/gbm_surface.h" |
6 | 6 |
7 #include <gbm.h> | 7 #include <gbm.h> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "ui/ozone/platform/dri/dri_buffer.h" | 10 #include "ui/ozone/platform/dri/dri_buffer.h" |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
93 gbm_surface_destroy(native_surface_); | 93 gbm_surface_destroy(native_surface_); |
94 } | 94 } |
95 | 95 |
96 bool GbmSurface::Initialize() { | 96 bool GbmSurface::Initialize() { |
97 // If we're initializing the surface without a controller (possible on startup | 97 // If we're initializing the surface without a controller (possible on startup |
98 // where the surface creation can happen before the native window delegate | 98 // where the surface creation can happen before the native window delegate |
99 // IPCs arrive), initialize the size to a valid value such that surface | 99 // IPCs arrive), initialize the size to a valid value such that surface |
100 // creation doesn't fail. | 100 // creation doesn't fail. |
101 gfx::Size size(1, 1); | 101 gfx::Size size(1, 1); |
102 if (window_delegate_->GetController()) { | 102 if (window_delegate_->GetController()) { |
103 const drmModeModeInfo& mode = window_delegate_->GetController()->get_mode(); | 103 size = window_delegate_->GetController()->GetModeSize(); |
104 size.SetSize(mode.hdisplay, mode.vdisplay); | |
105 } | 104 } |
106 // TODO(dnicoara) Check underlying system support for pixel format. | 105 // TODO(dnicoara) Check underlying system support for pixel format. |
107 native_surface_ = | 106 native_surface_ = |
108 gbm_surface_create(gbm_device_, | 107 gbm_surface_create(gbm_device_, |
109 size.width(), | 108 size.width(), |
110 size.height(), | 109 size.height(), |
111 GBM_BO_FORMAT_XRGB8888, | 110 GBM_BO_FORMAT_XRGB8888, |
112 GBM_BO_USE_SCANOUT | GBM_BO_USE_RENDERING); | 111 GBM_BO_USE_SCANOUT | GBM_BO_USE_RENDERING); |
113 | 112 |
114 if (!native_surface_) | 113 if (!native_surface_) |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
153 | 152 |
154 // If there was a frontbuffer, it is no longer active. Release it back to GBM. | 153 // If there was a frontbuffer, it is no longer active. Release it back to GBM. |
155 if (current_buffer_) | 154 if (current_buffer_) |
156 gbm_surface_release_buffer(native_surface_, current_buffer_); | 155 gbm_surface_release_buffer(native_surface_, current_buffer_); |
157 | 156 |
158 current_buffer_ = pending_buffer; | 157 current_buffer_ = pending_buffer; |
159 return true; | 158 return true; |
160 } | 159 } |
161 | 160 |
162 } // namespace ui | 161 } // namespace ui |
OLD | NEW |