Commit 27db632f authored by spang@chromium.org's avatar spang@chromium.org

ozone: dri: Do initial cursor set

The cursor is invisible unless set explicitly, so set a bitmap from
CursorFactoryEvdevDri upon construction.

Configuration of the cursor plane must be delayed until we've configured
the hardware, so store the bitmap on DriSurfaceFactory and set it in
RealizeAcceleratedWidget.

TEST=content_shell --ozone-platform=dri
BUG=252315

Review URL: https://codereview.chromium.org/208553004

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@260189 0039d316-1c4b-4281-b951-d872f2087c98
parent 3da8c168
......@@ -211,6 +211,9 @@ gfx::AcceleratedWidget DriSurfaceFactory::RealizeAcceleratedWidget(
return gfx::kNullAcceleratedWidget;
}
// Initial cursor set.
ResetCursor();
return reinterpret_cast<gfx::AcceleratedWidget>(controller_->get_surface());
}
......@@ -273,17 +276,19 @@ scoped_ptr<gfx::VSyncProvider> DriSurfaceFactory::CreateVSyncProvider(
void DriSurfaceFactory::SetHardwareCursor(gfx::AcceleratedWidget window,
const SkBitmap& image,
const gfx::Point& location) {
cursor_bitmap_ = image;
cursor_location_ = location;
if (state_ != INITIALIZED)
return;
UpdateCursorImage(cursor_surface_.get(), image);
controller_->MoveCursor(location);
controller_->SetCursor(*cursor_surface_.get());
cursor_surface_->SwapBuffers();
ResetCursor();
}
void DriSurfaceFactory::MoveHardwareCursor(gfx::AcceleratedWidget window,
const gfx::Point& location) {
cursor_location_ = location;
if (state_ != INITIALIZED)
return;
......@@ -291,10 +296,12 @@ void DriSurfaceFactory::MoveHardwareCursor(gfx::AcceleratedWidget window,
}
void DriSurfaceFactory::UnsetHardwareCursor(gfx::AcceleratedWidget window) {
cursor_bitmap_.reset();
if (state_ != INITIALIZED)
return;
controller_->UnsetCursor();
ResetCursor();
}
////////////////////////////////////////////////////////////////////////////////
......@@ -367,4 +374,19 @@ void DriSurfaceFactory::WaitForPageFlipEvent(int fd) {
drmHandleEvent(fd, &drm_event);
}
void DriSurfaceFactory::ResetCursor() {
if (!cursor_bitmap_.empty()) {
// Draw new cursor into backbuffer.
UpdateCursorImage(cursor_surface_.get(), cursor_bitmap_);
// Reset location & buffer.
controller_->MoveCursor(cursor_location_);
controller_->SetCursor(cursor_surface_.get());
} else {
// No cursor set.
controller_->UnsetCursor();
}
}
} // namespace gfx
......@@ -6,6 +6,7 @@
#define UI_GFX_OZONE_DRI_DRI_SURFACE_FACTORY_H_
#include "base/memory/scoped_ptr.h"
#include "third_party/skia/include/core/SkBitmap.h"
#include "ui/gfx/ozone/surface_factory_ozone.h"
namespace gfx {
......@@ -67,6 +68,9 @@ class GFX_EXPORT DriSurfaceFactory : public SurfaceFactoryOzone {
// pending frame.
virtual void WaitForPageFlipEvent(int fd);
// Draw the last set cursor & update the cursor plane.
void ResetCursor();
scoped_ptr<DriWrapper> drm_;
HardwareState state_;
......@@ -76,6 +80,9 @@ class GFX_EXPORT DriSurfaceFactory : public SurfaceFactoryOzone {
scoped_ptr<DriSurface> cursor_surface_;
SkBitmap cursor_bitmap_;
gfx::Point cursor_location_;
DISALLOW_COPY_AND_ASSIGN(DriSurfaceFactory);
};
......
......@@ -133,12 +133,14 @@ void HardwareDisplayController::OnPageFlipEvent(unsigned int frame,
surface_->SwapBuffers();
}
bool HardwareDisplayController::SetCursor(const DriSurface& surface) {
bool HardwareDisplayController::SetCursor(DriSurface* surface) {
CHECK(state_ != UNASSOCIATED);
return drm_->SetCursor(crtc_id_,
surface.GetHandle(),
surface.size().width(),
surface.size().height());
bool ret = drm_->SetCursor(crtc_id_,
surface->GetHandle(),
surface->size().width(),
surface->size().height());
surface->SwapBuffers();
return ret;
}
bool HardwareDisplayController::UnsetCursor() {
......
......@@ -147,7 +147,7 @@ class GFX_EXPORT HardwareDisplayController {
unsigned int useconds);
// Set the hardware cursor to show the contents of |surface|.
bool SetCursor(const DriSurface& surface);
bool SetCursor(DriSurface* surface);
bool UnsetCursor();
......
......@@ -15,6 +15,11 @@ CursorFactoryEvdevDri::CursorFactoryEvdevDri(gfx::DriSurfaceFactory* dri)
cursor_bounds_ = gfx::RectF(0, 0, 2560, 1700); // TODO(spang): Argh!
cursor_location_ =
gfx::PointF(cursor_bounds_.width() / 2, cursor_bounds_.height() / 2);
// The DRI cursor is invisible unless explicitly set. Therefore, set the
// pointer cursor on initialization.
// TODO(spang): Move this to DRI window initialization.
SetCursor(dri->GetAcceleratedWidget(), GetDefaultCursor(kCursorPointer));
}
CursorFactoryEvdevDri::~CursorFactoryEvdevDri() {}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment