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

Side by Side Diff: ui/ozone/platform/dri/hardware_display_controller.cc

Issue 106633002: GBM Ozone implementation (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 6 years, 6 months 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 | Annotate | Revision Log
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/dri/hardware_display_controller.h" 5 #include "ui/ozone/platform/dri/hardware_display_controller.h"
6 6
7 #include <drm.h> 7 #include <drm.h>
8 #include <errno.h> 8 #include <errno.h>
9 #include <string.h> 9 #include <string.h>
10 #include <xf86drm.h> 10 #include <xf86drm.h>
11 11
12 #include "base/basictypes.h" 12 #include "base/basictypes.h"
13 #include "base/debug/trace_event.h" 13 #include "base/debug/trace_event.h"
14 #include "base/logging.h" 14 #include "base/logging.h"
15 #include "base/time/time.h" 15 #include "base/time/time.h"
16 #include "third_party/skia/include/core/SkCanvas.h" 16 #include "third_party/skia/include/core/SkCanvas.h"
17 #include "ui/gfx/geometry/point.h" 17 #include "ui/gfx/geometry/point.h"
18 #include "ui/gfx/geometry/size.h"
18 #include "ui/ozone/platform/dri/dri_buffer.h" 19 #include "ui/ozone/platform/dri/dri_buffer.h"
19 #include "ui/ozone/platform/dri/dri_surface.h"
20 #include "ui/ozone/platform/dri/dri_wrapper.h" 20 #include "ui/ozone/platform/dri/dri_wrapper.h"
21 #include "ui/ozone/platform/dri/scanout_surface.h"
21 22
22 namespace ui { 23 namespace ui {
23 24
24 namespace { 25 namespace {
25 26
26 // DRM callback on page flip events. This callback is triggered after the 27 // DRM callback on page flip events. This callback is triggered after the
27 // page flip has happened and the backbuffer is now the new frontbuffer 28 // page flip has happened and the backbuffer is now the new frontbuffer
28 // The old frontbuffer is no longer used by the hardware and can be used for 29 // The old frontbuffer is no longer used by the hardware and can be used for
29 // future draw operations. 30 // future draw operations.
30 // 31 //
31 // |device| will contain a reference to the |DriSurface| object which 32 // |device| will contain a reference to the |ScanoutSurface| object which
32 // the event belongs to. 33 // the event belongs to.
33 // 34 //
34 // TODO(dnicoara) When we have a FD handler for the DRM calls in the message 35 // TODO(dnicoara) When we have a FD handler for the DRM calls in the message
35 // loop, we can move this function in the handler. 36 // loop, we can move this function in the handler.
36 void HandlePageFlipEvent(int fd, 37 void HandlePageFlipEvent(int fd,
37 unsigned int frame, 38 unsigned int frame,
38 unsigned int seconds, 39 unsigned int seconds,
39 unsigned int useconds, 40 unsigned int useconds,
40 void* controller) { 41 void* controller) {
41 TRACE_EVENT0("dri", "HandlePageFlipEvent"); 42 TRACE_EVENT0("dri", "HandlePageFlipEvent");
(...skipping 14 matching lines...) Expand all
56 time_of_last_flip_(0) {} 57 time_of_last_flip_(0) {}
57 58
58 HardwareDisplayController::~HardwareDisplayController() { 59 HardwareDisplayController::~HardwareDisplayController() {
59 // Reset the cursor. 60 // Reset the cursor.
60 UnsetCursor(); 61 UnsetCursor();
61 UnbindSurfaceFromController(); 62 UnbindSurfaceFromController();
62 } 63 }
63 64
64 bool 65 bool
65 HardwareDisplayController::BindSurfaceToController( 66 HardwareDisplayController::BindSurfaceToController(
66 scoped_ptr<DriSurface> surface, drmModeModeInfo mode) { 67 scoped_ptr<ScanoutSurface> surface, drmModeModeInfo mode) {
67 CHECK(surface); 68 CHECK(surface);
68 69
69 if (!drm_->SetCrtc(crtc_id_, 70 if (!drm_->SetCrtc(crtc_id_,
70 surface->GetFramebufferId(), 71 surface->GetFramebufferId(),
71 &connector_id_, 72 &connector_id_,
72 &mode)) { 73 &mode)) {
73 LOG(ERROR) << "Failed to modeset: error='" << strerror(errno) 74 LOG(ERROR) << "Failed to modeset: error='" << strerror(errno)
74 << "' crtc=" << crtc_id_ << " connector=" << connector_id_ 75 << "' crtc=" << crtc_id_ << " connector=" << connector_id_
75 << " framebuffer_id=" << surface->GetFramebufferId() 76 << " framebuffer_id=" << surface->GetFramebufferId()
76 << " mode=" << mode.hdisplay << "x" << mode.vdisplay << "@" 77 << " mode=" << mode.hdisplay << "x" << mode.vdisplay << "@"
(...skipping 10 matching lines...) Expand all
87 drm_->SetCrtc(crtc_id_, 0, 0, NULL); 88 drm_->SetCrtc(crtc_id_, 0, 0, NULL);
88 surface_.reset(); 89 surface_.reset();
89 } 90 }
90 91
91 void HardwareDisplayController::Disable() { 92 void HardwareDisplayController::Disable() {
92 UnbindSurfaceFromController(); 93 UnbindSurfaceFromController();
93 } 94 }
94 95
95 bool HardwareDisplayController::SchedulePageFlip() { 96 bool HardwareDisplayController::SchedulePageFlip() {
96 CHECK(surface_); 97 CHECK(surface_);
97
98 if (!drm_->PageFlip(crtc_id_, 98 if (!drm_->PageFlip(crtc_id_,
99 surface_->GetFramebufferId(), 99 surface_->GetFramebufferId(),
100 this)) { 100 this)) {
101 LOG(ERROR) << "Cannot page flip: " << strerror(errno); 101 LOG(ERROR) << "Cannot page flip: " << strerror(errno);
102 return false; 102 return false;
103 } 103 }
104 104
105 return true; 105 return true;
106 } 106 }
107 107
(...skipping 12 matching lines...) Expand all
120 void HardwareDisplayController::OnPageFlipEvent(unsigned int frame, 120 void HardwareDisplayController::OnPageFlipEvent(unsigned int frame,
121 unsigned int seconds, 121 unsigned int seconds,
122 unsigned int useconds) { 122 unsigned int useconds) {
123 time_of_last_flip_ = 123 time_of_last_flip_ =
124 static_cast<uint64_t>(seconds) * base::Time::kMicrosecondsPerSecond + 124 static_cast<uint64_t>(seconds) * base::Time::kMicrosecondsPerSecond +
125 useconds; 125 useconds;
126 126
127 surface_->SwapBuffers(); 127 surface_->SwapBuffers();
128 } 128 }
129 129
130 bool HardwareDisplayController::SetCursor(DriSurface* surface) { 130 bool HardwareDisplayController::SetCursor(ScanoutSurface* surface) {
131 bool ret = drm_->SetCursor(crtc_id_, 131 bool ret = drm_->SetCursor(crtc_id_,
132 surface->GetHandle(), 132 surface->GetHandle(),
133 surface->size().width(), 133 surface->Size().width(),
134 surface->size().height()); 134 surface->Size().height());
135 surface->SwapBuffers(); 135 surface->SwapBuffers();
136 return ret; 136 return ret;
137 } 137 }
138 138
139 bool HardwareDisplayController::UnsetCursor() { 139 bool HardwareDisplayController::UnsetCursor() {
140 return drm_->SetCursor(crtc_id_, 0, 0, 0); 140 return drm_->SetCursor(crtc_id_, 0, 0, 0);
141 } 141 }
142 142
143 bool HardwareDisplayController::MoveCursor(const gfx::Point& location) { 143 bool HardwareDisplayController::MoveCursor(const gfx::Point& location) {
144 return drm_->MoveCursor(crtc_id_, location.x(), location.y()); 144 return drm_->MoveCursor(crtc_id_, location.x(), location.y());
145 } 145 }
146 146
147 } // namespace ui 147 } // namespace ui
OLDNEW
« no previous file with comments | « ui/ozone/platform/dri/hardware_display_controller.h ('k') | ui/ozone/platform/dri/hardware_display_controller_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698