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

Side by Side Diff: ui/gfx/ozone/dri/dri_surface_factory.cc

Issue 205433005: ozone: Add OzoneWindowFactory & OzoneWindow (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 9 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 2013 The Chromium Authors. All rights reserved. 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 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/gfx/ozone/dri/dri_surface_factory.h" 5 #include "ui/gfx/ozone/dri/dri_surface_factory.h"
6 6
7 #include <drm.h> 7 #include <drm.h>
8 #include <errno.h> 8 #include <errno.h>
9 #include <xf86drm.h> 9 #include <xf86drm.h>
10 10
11 #include "base/message_loop/message_loop.h" 11 #include "base/message_loop/message_loop.h"
12 #include "third_party/skia/include/core/SkBitmap.h" 12 #include "third_party/skia/include/core/SkBitmap.h"
13 #include "third_party/skia/include/core/SkDevice.h" 13 #include "third_party/skia/include/core/SkDevice.h"
14 #include "ui/gfx/native_widget_types.h" 14 #include "ui/gfx/native_widget_types.h"
15 #include "ui/gfx/ozone/dri/dri_skbitmap.h" 15 #include "ui/gfx/ozone/dri/dri_skbitmap.h"
16 #include "ui/gfx/ozone/dri/dri_surface.h" 16 #include "ui/gfx/ozone/dri/dri_surface.h"
17 #include "ui/gfx/ozone/dri/dri_vsync_provider.h" 17 #include "ui/gfx/ozone/dri/dri_vsync_provider.h"
18 #include "ui/gfx/ozone/dri/dri_wrapper.h" 18 #include "ui/gfx/ozone/dri/dri_wrapper.h"
19 #include "ui/gfx/ozone/dri/hardware_display_controller.h" 19 #include "ui/gfx/ozone/dri/hardware_display_controller.h"
20 #include "ui/gfx/ozone/surface_ozone.h" 20 #include "ui/gfx/ozone/surface_ozone.h"
21 21
22 namespace gfx { 22 namespace gfx {
23 23
24 namespace { 24 namespace {
25 25
26 const char kDefaultGraphicsCardPath[] = "/dev/dri/card0"; 26 const char kDefaultGraphicsCardPath[] = "/dev/dri/card0";
27 const char kDPMSProperty[] = "DPMS"; 27 const char kDPMSProperty[] = "DPMS";
28 28
29 const gfx::AcceleratedWidget kDefaultWidgetHandle = 1; 29 const gfx::AcceleratedWidget kDefaultWidgetHandle =
30 kDefaultAcceleratedWidgetForSingleWindow;
30 31
31 // TODO(dnicoara) Read the cursor plane size from the hardware. 32 // TODO(dnicoara) Read the cursor plane size from the hardware.
32 const gfx::Size kCursorSize(64, 64); 33 const gfx::Size kCursorSize(64, 64);
33 34
34 // DRM callback on page flip events. This callback is triggered after the 35 // DRM callback on page flip events. This callback is triggered after the
35 // page flip has happened and the backbuffer is now the new frontbuffer 36 // page flip has happened and the backbuffer is now the new frontbuffer
36 // The old frontbuffer is no longer used by the hardware and can be used for 37 // The old frontbuffer is no longer used by the hardware and can be used for
37 // future draw operations. 38 // future draw operations.
38 // 39 //
39 // |device| will contain a reference to the |DriSurface| object which 40 // |device| will contain a reference to the |DriSurface| object which
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 return state_; 172 return state_;
172 } 173 }
173 174
174 cursor_surface_.reset(CreateSurface(kCursorSize)); 175 cursor_surface_.reset(CreateSurface(kCursorSize));
175 if (!cursor_surface_->Initialize()) { 176 if (!cursor_surface_->Initialize()) {
176 LOG(ERROR) << "Failed to initialize cursor surface"; 177 LOG(ERROR) << "Failed to initialize cursor surface";
177 state_ = FAILED; 178 state_ = FAILED;
178 return state_; 179 return state_;
179 } 180 }
180 181
182 // TODO(dnicoara) When there's more information on which display we want,
183 // then we can return the widget associated with the display.
184 // For now just assume we have 1 display device and return it.
185 if (!controller_.get())
186 controller_.reset(new HardwareDisplayController());
187
181 state_ = INITIALIZED; 188 state_ = INITIALIZED;
182 return state_; 189 return state_;
183 } 190 }
184 191
185 void DriSurfaceFactory::ShutdownHardware() { 192 void DriSurfaceFactory::ShutdownHardware() {
186 CHECK(state_ == INITIALIZED); 193 CHECK(state_ == INITIALIZED);
187 194
188 controller_.reset(); 195 controller_.reset();
189 drm_.reset(); 196 drm_.reset();
190 197
191 state_ = UNINITIALIZED; 198 state_ = UNINITIALIZED;
192 } 199 }
193 200
194 gfx::AcceleratedWidget DriSurfaceFactory::GetAcceleratedWidget() { 201 gfx::AcceleratedWidget DriSurfaceFactory::GetAcceleratedWidget() {
195 CHECK(state_ != FAILED); 202 CHECK(state_ != FAILED);
196 203
197 // TODO(dnicoara) When there's more information on which display we want,
198 // then we can return the widget associated with the display.
199 // For now just assume we have 1 display device and return it.
200 if (!controller_.get())
201 controller_.reset(new HardwareDisplayController());
202
203 // TODO(dnicoara) We only have 1 display for now, so only 1 AcceleratedWidget. 204 // TODO(dnicoara) We only have 1 display for now, so only 1 AcceleratedWidget.
204 // When we'll support multiple displays this needs to be changed to return a 205 // When we'll support multiple displays this needs to be changed to return a
205 // different handle for every display. 206 // different handle for every display.
206 return kDefaultWidgetHandle; 207 return kDefaultWidgetHandle;
207 } 208 }
208 209
209 scoped_ptr<SurfaceOzone> DriSurfaceFactory::CreateSurfaceForWidget( 210 scoped_ptr<SurfaceOzone> DriSurfaceFactory::CreateSurfaceForWidget(
210 gfx::AcceleratedWidget w) { 211 gfx::AcceleratedWidget w) {
211 CHECK(state_ == INITIALIZED); 212 CHECK(state_ == INITIALIZED);
212 // TODO(dnicoara) Once we can handle multiple displays this needs to be 213 // TODO(dnicoara) Once we can handle multiple displays this needs to be
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
386 drmEventContext drm_event; 387 drmEventContext drm_event;
387 drm_event.version = DRM_EVENT_CONTEXT_VERSION; 388 drm_event.version = DRM_EVENT_CONTEXT_VERSION;
388 drm_event.page_flip_handler = HandlePageFlipEvent; 389 drm_event.page_flip_handler = HandlePageFlipEvent;
389 drm_event.vblank_handler = NULL; 390 drm_event.vblank_handler = NULL;
390 391
391 // Wait for the page-flip to complete. 392 // Wait for the page-flip to complete.
392 drmHandleEvent(fd, &drm_event); 393 drmHandleEvent(fd, &drm_event);
393 } 394 }
394 395
395 } // namespace gfx 396 } // namespace gfx
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698