| OLD | NEW |
| 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/dri_window_delegate_impl.h" | 5 #include "ui/ozone/platform/dri/dri_window_delegate_impl.h" |
| 6 | 6 |
| 7 #include "base/trace_event/trace_event.h" | 7 #include "base/trace_event/trace_event.h" |
| 8 #include "third_party/skia/include/core/SkBitmap.h" | 8 #include "third_party/skia/include/core/SkBitmap.h" |
| 9 #include "third_party/skia/include/core/SkDevice.h" | 9 #include "third_party/skia/include/core/SkDevice.h" |
| 10 #include "third_party/skia/include/core/SkSurface.h" | 10 #include "third_party/skia/include/core/SkSurface.h" |
| 11 #include "ui/ozone/platform/dri/dri_buffer.h" | 11 #include "ui/ozone/platform/dri/dri_buffer.h" |
| 12 #include "ui/ozone/platform/dri/dri_wrapper.h" | 12 #include "ui/ozone/platform/dri/drm_device.h" |
| 13 #include "ui/ozone/platform/dri/drm_device_manager.h" | 13 #include "ui/ozone/platform/dri/drm_device_manager.h" |
| 14 #include "ui/ozone/platform/dri/screen_manager.h" | 14 #include "ui/ozone/platform/dri/screen_manager.h" |
| 15 | 15 |
| 16 namespace ui { | 16 namespace ui { |
| 17 | 17 |
| 18 namespace { | 18 namespace { |
| 19 | 19 |
| 20 #ifndef DRM_CAP_CURSOR_WIDTH | 20 #ifndef DRM_CAP_CURSOR_WIDTH |
| 21 #define DRM_CAP_CURSOR_WIDTH 0x8 | 21 #define DRM_CAP_CURSOR_WIDTH 0x8 |
| 22 #endif | 22 #endif |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 174 } | 174 } |
| 175 | 175 |
| 176 void DriWindowDelegateImpl::OnCursorAnimationTimeout() { | 176 void DriWindowDelegateImpl::OnCursorAnimationTimeout() { |
| 177 cursor_frame_++; | 177 cursor_frame_++; |
| 178 cursor_frame_ %= cursor_bitmaps_.size(); | 178 cursor_frame_ %= cursor_bitmaps_.size(); |
| 179 | 179 |
| 180 ResetCursor(true); | 180 ResetCursor(true); |
| 181 } | 181 } |
| 182 | 182 |
| 183 void DriWindowDelegateImpl::UpdateWidgetToDrmDeviceMapping() { | 183 void DriWindowDelegateImpl::UpdateWidgetToDrmDeviceMapping() { |
| 184 scoped_refptr<DriWrapper> drm = nullptr; | 184 scoped_refptr<DrmDevice> drm = nullptr; |
| 185 if (controller_) | 185 if (controller_) |
| 186 drm = controller_->GetAllocationDriWrapper(); | 186 drm = controller_->GetAllocationDrmDevice(); |
| 187 | 187 |
| 188 device_manager_->UpdateDrmDevice(widget_, drm); | 188 device_manager_->UpdateDrmDevice(widget_, drm); |
| 189 } | 189 } |
| 190 | 190 |
| 191 void DriWindowDelegateImpl::UpdateCursorBuffers() { | 191 void DriWindowDelegateImpl::UpdateCursorBuffers() { |
| 192 if (!controller_) { | 192 if (!controller_) { |
| 193 for (size_t i = 0; i < arraysize(cursor_buffers_); ++i) { | 193 for (size_t i = 0; i < arraysize(cursor_buffers_); ++i) { |
| 194 cursor_buffers_[i] = nullptr; | 194 cursor_buffers_[i] = nullptr; |
| 195 } | 195 } |
| 196 } else { | 196 } else { |
| 197 scoped_refptr<DriWrapper> drm = controller_->GetAllocationDriWrapper(); | 197 scoped_refptr<DrmDevice> drm = controller_->GetAllocationDrmDevice(); |
| 198 | 198 |
| 199 uint64_t cursor_width = 64; | 199 uint64_t cursor_width = 64; |
| 200 uint64_t cursor_height = 64; | 200 uint64_t cursor_height = 64; |
| 201 drm->GetCapability(DRM_CAP_CURSOR_WIDTH, &cursor_width); | 201 drm->GetCapability(DRM_CAP_CURSOR_WIDTH, &cursor_width); |
| 202 drm->GetCapability(DRM_CAP_CURSOR_HEIGHT, &cursor_height); | 202 drm->GetCapability(DRM_CAP_CURSOR_HEIGHT, &cursor_height); |
| 203 | 203 |
| 204 SkImageInfo info = SkImageInfo::MakeN32Premul(cursor_width, cursor_height); | 204 SkImageInfo info = SkImageInfo::MakeN32Premul(cursor_width, cursor_height); |
| 205 for (size_t i = 0; i < arraysize(cursor_buffers_); ++i) { | 205 for (size_t i = 0; i < arraysize(cursor_buffers_); ++i) { |
| 206 cursor_buffers_[i] = new DriBuffer(drm); | 206 cursor_buffers_[i] = new DriBuffer(drm); |
| 207 // Don't register a framebuffer for cursors since they are special (they | 207 // Don't register a framebuffer for cursors since they are special (they |
| 208 // aren't modesetting buffers and drivers may fail to register them due to | 208 // aren't modesetting buffers and drivers may fail to register them due to |
| 209 // their small sizes). | 209 // their small sizes). |
| 210 if (!cursor_buffers_[i]->Initialize( | 210 if (!cursor_buffers_[i]->Initialize( |
| 211 info, false /* should_register_framebuffer */)) { | 211 info, false /* should_register_framebuffer */)) { |
| 212 LOG(FATAL) << "Failed to initialize cursor buffer"; | 212 LOG(FATAL) << "Failed to initialize cursor buffer"; |
| 213 return; | 213 return; |
| 214 } | 214 } |
| 215 } | 215 } |
| 216 } | 216 } |
| 217 } | 217 } |
| 218 | 218 |
| 219 } // namespace ui | 219 } // namespace ui |
| OLD | NEW |