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

Side by Side Diff: ui/gfx/ozone/impl/hardware_display_controller.cc

Issue 62953003: Support removal of DRI platform (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix use_ozone=0 Created 7 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 | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "ui/gfx/ozone/impl/hardware_display_controller.h"
6
7 #include <errno.h>
8 #include <string.h>
9
10 #include "base/basictypes.h"
11 #include "base/logging.h"
12 #include "ui/gfx/ozone/impl/dri_skbitmap.h"
13 #include "ui/gfx/ozone/impl/dri_surface.h"
14 #include "ui/gfx/ozone/impl/dri_wrapper.h"
15
16 namespace gfx {
17
18 HardwareDisplayController::HardwareDisplayController()
19 : drm_(NULL),
20 connector_id_(0),
21 crtc_id_(0),
22 mode_(),
23 saved_crtc_(NULL),
24 state_(UNASSOCIATED),
25 surface_() {
26 }
27
28 void HardwareDisplayController::SetControllerInfo(
29 DriWrapper* drm,
30 uint32_t connector_id,
31 uint32_t crtc_id,
32 uint32_t dpms_property_id,
33 drmModeModeInfo mode) {
34 drm_ = drm;
35 connector_id_ = connector_id;
36 crtc_id_ = crtc_id;
37 dpms_property_id_ = dpms_property_id;
38 mode_ = mode;
39 saved_crtc_ = drm_->GetCrtc(crtc_id_);
40 state_ = UNINITIALIZED;
41 }
42
43 HardwareDisplayController::~HardwareDisplayController() {
44 if (saved_crtc_) {
45 if (!drm_->SetCrtc(saved_crtc_, &connector_id_))
46 DLOG(ERROR) << "Failed to restore CRTC state: " << strerror(errno);
47 drm_->FreeCrtc(saved_crtc_);
48 }
49
50 if (surface_.get()) {
51 // Unregister the buffers.
52 for (int i = 0; i < 2; ++i) {
53 if (!drm_->RemoveFramebuffer(surface_->bitmaps_[i]->get_framebuffer()))
54 DLOG(ERROR) << "Failed to remove FB: " << strerror(errno);
55 }
56 }
57 }
58
59 bool
60 HardwareDisplayController::BindSurfaceToController(
61 scoped_ptr<DriSurface> surface) {
62 CHECK(state_ == UNINITIALIZED);
63
64 // Register the buffers.
65 for (int i = 0; i < 2; ++i) {
66 uint32_t fb_id;
67 if (!drm_->AddFramebuffer(mode_,
68 surface->bitmaps_[i]->GetColorDepth(),
69 surface->bitmaps_[i]->bytesPerPixel() << 3,
70 surface->bitmaps_[i]->rowBytes(),
71 surface->bitmaps_[i]->get_handle(),
72 &fb_id)) {
73 DLOG(ERROR) << "Failed to register framebuffer: " << strerror(errno);
74 state_ = FAILED;
75 return false;
76 }
77 surface->bitmaps_[i]->set_framebuffer(fb_id);
78 }
79
80 surface_.reset(surface.release());
81 state_ = SURFACE_INITIALIZED;
82 return true;
83 }
84
85 bool HardwareDisplayController::SchedulePageFlip() {
86 CHECK(state_ == SURFACE_INITIALIZED || state_ == INITIALIZED);
87
88 if (state_ == SURFACE_INITIALIZED) {
89 // Perform the initial modeset.
90 if (!drm_->SetCrtc(crtc_id_,
91 surface_->GetFramebufferId(),
92 &connector_id_,
93 &mode_)) {
94 DLOG(ERROR) << "Cannot set CRTC: " << strerror(errno);
95 state_ = FAILED;
96 return false;
97 } else {
98 state_ = INITIALIZED;
99 }
100
101 if (dpms_property_id_)
102 drm_->ConnectorSetProperty(connector_id_,
103 dpms_property_id_,
104 DRM_MODE_DPMS_ON);
105 }
106
107 if (!drm_->PageFlip(crtc_id_,
108 surface_->GetFramebufferId(),
109 this)) {
110 state_ = FAILED;
111 LOG(ERROR) << "Cannot page flip: " << strerror(errno);
112 return false;
113 }
114
115 return true;
116 }
117
118 } // namespace gfx
OLDNEW
« no previous file with comments | « ui/gfx/ozone/impl/hardware_display_controller.h ('k') | ui/gfx/ozone/impl/hardware_display_controller_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698