1 // Copyright 2014 Intel Corporation. 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.
5 #include "ozone/wayland/ozone_hardware_display.h"
7 #include "ozone/wayland/display.h"
9 namespace ozonewayland {
11 OzoneHardwareDisplay::OzoneHardwareDisplay() : native_display_(NULL) {
12 gfx::OzoneDisplay::SetInstance(this);
15 OzoneHardwareDisplay::~OzoneHardwareDisplay() {
17 gfx::OzoneDisplay::SetInstance(NULL);
20 gfx::SurfaceFactoryOzone::HardwareState
21 OzoneHardwareDisplay::InitializeHardware() {
22 if (!native_display_) {
23 native_display_ = new WaylandDisplay(WaylandDisplay::RegisterAsNeeded);
24 if (!native_display_->display()) {
25 delete native_display_;
26 native_display_ = NULL;
27 LOG(ERROR) << "SurfaceFactoryWayland failed to initialize hardware";
28 return gfx::SurfaceFactoryOzone::FAILED;
32 return gfx::SurfaceFactoryOzone::INITIALIZED;
35 void OzoneHardwareDisplay::ShutdownHardware() {
39 intptr_t OzoneHardwareDisplay::GetNativeDisplay() {
40 return (intptr_t)native_display_->display();
43 void OzoneHardwareDisplay::FlushDisplay() {
44 DCHECK(native_display_);
45 native_display_->FlushDisplay();
48 gfx::AcceleratedWidget OzoneHardwareDisplay::GetAcceleratedWidget() {
49 static int opaque_handle = 0;
51 ui::WindowStateChangeHandler::GetInstance()->SetWidgetState(opaque_handle,
56 return (gfx::AcceleratedWidget)opaque_handle;
59 gfx::AcceleratedWidget OzoneHardwareDisplay::RealizeAcceleratedWidget(
60 gfx::AcceleratedWidget w) {
61 DCHECK(native_display_);
62 return (gfx::AcceleratedWidget)native_display_->RealizeAcceleratedWidget(w);
65 bool OzoneHardwareDisplay::AttemptToResizeAcceleratedWidget(
66 gfx::AcceleratedWidget w, const gfx::Rect& bounds) {
67 ui::WindowStateChangeHandler::GetInstance()->SetWidgetState(
68 w, ui::RESIZE, bounds.width(), bounds.height());
73 void OzoneHardwareDisplay::DestroyWidget(gfx::AcceleratedWidget w) {
74 ui::WindowStateChangeHandler::GetInstance()->SetWidgetState(w,
78 void OzoneHardwareDisplay::LookAheadOutputGeometry() {
79 WaylandDisplay::LookAheadOutputGeometry();
82 void OzoneHardwareDisplay::Terminate() {
83 delete native_display_;
86 } // namespace ozonewayland