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

Side by Side Diff: ui/ozone/platform/drm/gpu/drm_window.cc

Issue 1426993003: Ozone: Dont hardcode format to YUV when using Overlay Composition. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: cosmetic fixes Created 5 years, 1 month 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 "ui/ozone/platform/drm/gpu/drm_window.h" 5 #include "ui/ozone/platform/drm/gpu/drm_window.h"
6 6
7 #include <drm_fourcc.h>
8
9 #include "base/time/time.h" 7 #include "base/time/time.h"
10 #include "base/trace_event/trace_event.h" 8 #include "base/trace_event/trace_event.h"
11 #include "third_party/skia/include/core/SkBitmap.h" 9 #include "third_party/skia/include/core/SkBitmap.h"
12 #include "third_party/skia/include/core/SkDevice.h" 10 #include "third_party/skia/include/core/SkDevice.h"
13 #include "third_party/skia/include/core/SkSurface.h" 11 #include "third_party/skia/include/core/SkSurface.h"
14 #include "ui/ozone/common/gpu/ozone_gpu_message_params.h"
15 #include "ui/ozone/platform/drm/common/drm_util.h"
16 #include "ui/ozone/platform/drm/gpu/crtc_controller.h" 12 #include "ui/ozone/platform/drm/gpu/crtc_controller.h"
17 #include "ui/ozone/platform/drm/gpu/drm_buffer.h" 13 #include "ui/ozone/platform/drm/gpu/drm_buffer.h"
18 #include "ui/ozone/platform/drm/gpu/drm_device.h" 14 #include "ui/ozone/platform/drm/gpu/drm_device.h"
19 #include "ui/ozone/platform/drm/gpu/drm_device_manager.h" 15 #include "ui/ozone/platform/drm/gpu/drm_device_manager.h"
20 #include "ui/ozone/platform/drm/gpu/scanout_buffer.h" 16 #include "ui/ozone/platform/drm/gpu/drm_overlay_candidate.h"
21 #include "ui/ozone/platform/drm/gpu/screen_manager.h" 17 #include "ui/ozone/platform/drm/gpu/screen_manager.h"
22 18
23 namespace ui { 19 namespace ui {
24 20
25 namespace { 21 namespace {
26 22
27 #ifndef DRM_CAP_CURSOR_WIDTH 23 #ifndef DRM_CAP_CURSOR_WIDTH
28 #define DRM_CAP_CURSOR_WIDTH 0x8 24 #define DRM_CAP_CURSOR_WIDTH 0x8
29 #endif 25 #endif
30 26
(...skipping 26 matching lines...) Expand all
57 screen_manager_(screen_manager) { 53 screen_manager_(screen_manager) {
58 } 54 }
59 55
60 DrmWindow::~DrmWindow() { 56 DrmWindow::~DrmWindow() {
61 } 57 }
62 58
63 void DrmWindow::Initialize() { 59 void DrmWindow::Initialize() {
64 TRACE_EVENT1("drm", "DrmWindow::Initialize", "widget", widget_); 60 TRACE_EVENT1("drm", "DrmWindow::Initialize", "widget", widget_);
65 61
66 device_manager_->UpdateDrmDevice(widget_, nullptr); 62 device_manager_->UpdateDrmDevice(widget_, nullptr);
63 overlay_validator_ = make_scoped_ptr(new DrmOverlayCandidate(this));
67 } 64 }
68 65
69 void DrmWindow::Shutdown() { 66 void DrmWindow::Shutdown() {
70 TRACE_EVENT1("drm", "DrmWindow::Shutdown", "widget", widget_); 67 TRACE_EVENT1("drm", "DrmWindow::Shutdown", "widget", widget_);
71 device_manager_->RemoveDrmDevice(widget_); 68 device_manager_->RemoveDrmDevice(widget_);
72 } 69 }
73 70
74 gfx::AcceleratedWidget DrmWindow::GetAcceleratedWidget() { 71 gfx::AcceleratedWidget DrmWindow::GetAcceleratedWidget() {
75 return widget_; 72 return widget_;
76 } 73 }
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 131
135 if (!controller_) { 132 if (!controller_) {
136 callback.Run(gfx::SwapResult::SWAP_ACK); 133 callback.Run(gfx::SwapResult::SWAP_ACK);
137 return; 134 return;
138 } 135 }
139 136
140 controller_->SchedulePageFlip(last_submitted_planes_, callback); 137 controller_->SchedulePageFlip(last_submitted_planes_, callback);
141 } 138 }
142 139
143 std::vector<OverlayCheck_Params> DrmWindow::TestPageFlip( 140 std::vector<OverlayCheck_Params> DrmWindow::TestPageFlip(
144 const std::vector<OverlayCheck_Params>& overlays, 141 const std::vector<OverlayCheck_Params>& current_combination,
142 const std::vector<OverlayCheck_Params>& new_combination,
145 ScanoutBufferGenerator* buffer_generator) { 143 ScanoutBufferGenerator* buffer_generator) {
146 std::vector<OverlayCheck_Params> params; 144 return overlay_validator_->TestPageFlip(current_combination, new_combination,
147 if (!controller_) { 145 last_submitted_planes_,
148 // Nothing much we can do here. 146 buffer_generator);
149 return params;
150 }
151
152 OverlayPlaneList compatible_test_list;
153 scoped_refptr<DrmDevice> drm = controller_->GetAllocationDrmDevice();
154 for (const auto& overlay : overlays) {
155 OverlayCheck_Params overlay_params(overlay);
156 gfx::Size size =
157 (overlay.plane_z_order == 0) ? bounds().size() : overlay.buffer_size;
158 scoped_refptr<ScanoutBuffer> buffer;
159 // Check if we can re-use existing buffers.
160 for (const auto& plane : last_submitted_planes_) {
161 uint32_t format = GetFourCCFormatFromBufferFormat(overlay.format);
162 // We always use a storage type of XRGB, even if the pixel format
163 // is ARGB.
164 if (format == DRM_FORMAT_ARGB8888)
165 format = DRM_FORMAT_XRGB8888;
166
167 if (plane.buffer->GetFramebufferPixelFormat() == format &&
168 plane.z_order == overlay.plane_z_order &&
169 plane.display_bounds == overlay.display_rect &&
170 plane.buffer->GetSize() == size) {
171 buffer = plane.buffer;
172 break;
173 }
174 }
175
176 if (!buffer)
177 buffer = buffer_generator->Create(drm, overlay.format, size);
178
179 if (!buffer)
180 continue;
181
182 OverlayPlane plane(buffer, overlay.plane_z_order, overlay.transform,
183 overlay.display_rect, overlay.crop_rect);
184
185 // Buffer for Primary plane should always be present for compatibility test.
186 if (!compatible_test_list.size() && overlay.plane_z_order != 0) {
187 compatible_test_list.push_back(
188 *OverlayPlane::GetPrimaryPlane(last_submitted_planes_));
189 }
190
191 compatible_test_list.push_back(plane);
192
193 if (controller_->TestPageFlip(compatible_test_list)) {
194 overlay_params.plane_ids =
195 controller_->GetCompatibleHardwarePlaneIds(plane);
196 params.push_back(overlay_params);
197 }
198
199 if (compatible_test_list.size() > 1)
200 compatible_test_list.pop_back();
201 }
202
203 return params;
204 } 147 }
205 148
206 const OverlayPlane* DrmWindow::GetLastModesetBuffer() { 149 const OverlayPlane* DrmWindow::GetLastModesetBuffer() {
207 return OverlayPlane::GetPrimaryPlane(last_submitted_planes_); 150 return OverlayPlane::GetPrimaryPlane(last_submitted_planes_);
208 } 151 }
209 152
210 void DrmWindow::GetVSyncParameters( 153 void DrmWindow::GetVSyncParameters(
211 const gfx::VSyncProvider::UpdateVSyncCallback& callback) const { 154 const gfx::VSyncProvider::UpdateVSyncCallback& callback) const {
212 if (!controller_) 155 if (!controller_)
213 return; 156 return;
214 157
215 // If we're in mirror mode the 2 CRTCs should have similar modes with the same 158 // If we're in mirror mode the 2 CRTCs should have similar modes with the same
216 // refresh rates. 159 // refresh rates.
217 CrtcController* crtc = controller_->crtc_controllers()[0]; 160 CrtcController* crtc = controller_->crtc_controllers()[0];
218 // The value is invalid, so we can't update the parameters. 161 // The value is invalid, so we can't update the parameters.
219 if (controller_->GetTimeOfLastFlip() == 0 || crtc->mode().vrefresh == 0) 162 if (controller_->GetTimeOfLastFlip() == 0 || crtc->mode().vrefresh == 0)
220 return; 163 return;
221 164
222 // Stores the time of the last refresh. 165 // Stores the time of the last refresh.
223 base::TimeTicks timebase = 166 base::TimeTicks timebase =
224 base::TimeTicks::FromInternalValue(controller_->GetTimeOfLastFlip()); 167 base::TimeTicks::FromInternalValue(controller_->GetTimeOfLastFlip());
225 // Stores the refresh rate. 168 // Stores the refresh rate.
226 base::TimeDelta interval = 169 base::TimeDelta interval =
227 base::TimeDelta::FromSeconds(1) / crtc->mode().vrefresh; 170 base::TimeDelta::FromSeconds(1) / crtc->mode().vrefresh;
228 171
229 callback.Run(timebase, interval); 172 callback.Run(timebase, interval);
230 } 173 }
231 174
175 void DrmWindow::GetOverlayBufferConfigurations(
176 const OverlayParamCallback& callback) const {
177 callback.Run(overlay_validator_->GetOverlayConfigurations());
178 }
179
232 void DrmWindow::ResetCursor(bool bitmap_only) { 180 void DrmWindow::ResetCursor(bool bitmap_only) {
233 if (!controller_) 181 if (!controller_)
234 return; 182 return;
235 183
236 if (cursor_bitmaps_.size()) { 184 if (cursor_bitmaps_.size()) {
237 // Draw new cursor into backbuffer. 185 // Draw new cursor into backbuffer.
238 UpdateCursorImage(cursor_buffers_[cursor_frontbuffer_ ^ 1].get(), 186 UpdateCursorImage(cursor_buffers_[cursor_frontbuffer_ ^ 1].get(),
239 cursor_bitmaps_[cursor_frame_]); 187 cursor_bitmaps_[cursor_frame_]);
240 188
241 // Reset location & buffer. 189 // Reset location & buffer.
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
297 if (!cursor_buffers_[i]->Initialize( 245 if (!cursor_buffers_[i]->Initialize(
298 info, false /* should_register_framebuffer */)) { 246 info, false /* should_register_framebuffer */)) {
299 LOG(FATAL) << "Failed to initialize cursor buffer"; 247 LOG(FATAL) << "Failed to initialize cursor buffer";
300 return; 248 return;
301 } 249 }
302 } 250 }
303 } 251 }
304 } 252 }
305 253
306 } // namespace ui 254 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698