From 02ee5f27835143afb8321a569044a25b80f51755 Mon Sep 17 00:00:00 2001 From: "kalyan.kondapally" Date: Wed, 5 Nov 2014 13:59:14 -0800 Subject: [PATCH] Add support to set CursorSize by quering via Capabilities. We currently hard code cursor size to 64* 64. This patch adds support to query the size via drmGetCap. In case drmGetCap fails, we fall back to default cursor size of 64*64. Review URL: https://codereview.chromium.org/701953003 Cr-Commit-Position: refs/heads/master@{#302882} --- ui/ozone/platform/dri/dri_surface_factory.cc | 17 +++++++++++++---- ui/ozone/platform/dri/dri_wrapper.cc | 5 +++++ ui/ozone/platform/dri/dri_wrapper.h | 4 ++++ ui/ozone/platform/dri/test/mock_dri_wrapper.cc | 4 ++++ ui/ozone/platform/dri/test/mock_dri_wrapper.h | 1 + 5 files changed, 27 insertions(+), 4 deletions(-) diff --git a/ui/ozone/platform/dri/dri_surface_factory.cc b/ui/ozone/platform/dri/dri_surface_factory.cc index 0b22680c39a3..ad35476a5e43 100644 --- a/ui/ozone/platform/dri/dri_surface_factory.cc +++ b/ui/ozone/platform/dri/dri_surface_factory.cc @@ -25,8 +25,13 @@ namespace ui { namespace { -// TODO(dnicoara) Read the cursor plane size from the hardware. -const gfx::Size kCursorSize(64, 64); +#ifndef DRM_CAP_CURSOR_WIDTH +#define DRM_CAP_CURSOR_WIDTH 0x8 +#endif + +#ifndef DRM_CAP_CURSOR_HEIGHT +#define DRM_CAP_CURSOR_HEIGHT 0x9 +#endif void UpdateCursorImage(DriBuffer* cursor, const SkBitmap& image) { SkRect damage; @@ -76,8 +81,12 @@ DriSurfaceFactory::HardwareState DriSurfaceFactory::InitializeHardware() { return state_; } - SkImageInfo info = SkImageInfo::MakeN32Premul(kCursorSize.width(), - kCursorSize.height()); + uint64_t cursor_width = 64; + uint64_t cursor_height = 64; + drm_->GetCapability(DRM_CAP_CURSOR_WIDTH, &cursor_width); + drm_->GetCapability(DRM_CAP_CURSOR_HEIGHT, &cursor_height); + + SkImageInfo info = SkImageInfo::MakeN32Premul(cursor_width, cursor_height); for (size_t i = 0; i < arraysize(cursor_buffers_); ++i) { cursor_buffers_[i] = new DriBuffer(drm_); if (!cursor_buffers_[i]->Initialize(info)) { diff --git a/ui/ozone/platform/dri/dri_wrapper.cc b/ui/ozone/platform/dri/dri_wrapper.cc index dcd1a3e76d2e..f7513035e657 100644 --- a/ui/ozone/platform/dri/dri_wrapper.cc +++ b/ui/ozone/platform/dri/dri_wrapper.cc @@ -229,6 +229,11 @@ bool DriWrapper::SetProperty(uint32_t connector_id, return !drmModeConnectorSetProperty(fd_, connector_id, property_id, value); } +bool DriWrapper::GetCapability(uint64_t capability, uint64_t* value) { + DCHECK(fd_ >= 0); + return !drmGetCap(fd_, capability, value); +} + ScopedDrmPropertyBlobPtr DriWrapper::GetPropertyBlob( drmModeConnector* connector, const char* name) { DCHECK(fd_ >= 0); diff --git a/ui/ozone/platform/dri/dri_wrapper.h b/ui/ozone/platform/dri/dri_wrapper.h index a555814e2871..1cf1123b7f46 100644 --- a/ui/ozone/platform/dri/dri_wrapper.h +++ b/ui/ozone/platform/dri/dri_wrapper.h @@ -101,6 +101,10 @@ class DriWrapper { uint32_t property_id, uint64_t value); + // Can be used to query device/driver |capability|. Sets the value of + // |capability to |value|. Returns true in case of a succesful query. + virtual bool GetCapability(uint64_t capability, uint64_t* value); + // Return a binary blob associated with |connector|. The binary blob is // associated with the property with name |name|. Return NULL if the property // could not be found or if the property does not have a binary blob. If valid diff --git a/ui/ozone/platform/dri/test/mock_dri_wrapper.cc b/ui/ozone/platform/dri/test/mock_dri_wrapper.cc index fefddf794031..76c3ee188a52 100644 --- a/ui/ozone/platform/dri/test/mock_dri_wrapper.cc +++ b/ui/ozone/platform/dri/test/mock_dri_wrapper.cc @@ -113,6 +113,10 @@ bool MockDriWrapper::SetProperty(uint32_t connector_id, return true; } +bool MockDriWrapper::GetCapability(uint64_t capability, uint64_t* value) { + return true; +} + ScopedDrmPropertyBlobPtr MockDriWrapper::GetPropertyBlob( drmModeConnector* connector, const char* name) { diff --git a/ui/ozone/platform/dri/test/mock_dri_wrapper.h b/ui/ozone/platform/dri/test/mock_dri_wrapper.h index a9b68b79a8cf..6ba8ec4bd1e4 100644 --- a/ui/ozone/platform/dri/test/mock_dri_wrapper.h +++ b/ui/ozone/platform/dri/test/mock_dri_wrapper.h @@ -85,6 +85,7 @@ class MockDriWrapper : public ui::DriWrapper { virtual bool SetProperty(uint32_t connector_id, uint32_t property_id, uint64_t value) override; + virtual bool GetCapability(uint64_t capability, uint64_t* value) override; virtual ScopedDrmPropertyBlobPtr GetPropertyBlob(drmModeConnector* connector, const char* name) override; virtual bool SetCursor(uint32_t crtc_id, -- 2.11.4.GIT