Commit ba21e464 authored by spang's avatar spang Committed by Commit bot

ozone: Plumb animated cursors from BitmapCursorFactoryOzone to DriSurfaceFactory

Update BitmapCursorOzone type to store a vector of bitmaps, a hotspot,
and a frame delay. Plumb the vector through to the GPU process, where
we'll update the cursor on a timer. This is plumbing only; it does not
change the user-visible behavior of showing only the first cursor frame.

R=dnicoara, kenrb
BUG=343245
TEST=viewed css "wait" cursor on cros link_freon

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

Cr-Commit-Position: refs/heads/master@{#294045}
parent e783a653
...@@ -30,6 +30,39 @@ scoped_refptr<BitmapCursorOzone> CreateDefaultBitmapCursor(int type) { ...@@ -30,6 +30,39 @@ scoped_refptr<BitmapCursorOzone> CreateDefaultBitmapCursor(int type) {
} // namespace } // namespace
BitmapCursorOzone::BitmapCursorOzone(const SkBitmap& bitmap,
const gfx::Point& hotspot)
: hotspot_(hotspot), frame_delay_ms_(0) {
bitmaps_.push_back(bitmap);
}
BitmapCursorOzone::BitmapCursorOzone(const std::vector<SkBitmap>& bitmaps,
const gfx::Point& hotspot,
int frame_delay_ms)
: bitmaps_(bitmaps), hotspot_(hotspot), frame_delay_ms_(frame_delay_ms) {
DCHECK_LT(0U, bitmaps.size());
DCHECK_LE(0, frame_delay_ms);
}
BitmapCursorOzone::~BitmapCursorOzone() {
}
const gfx::Point& BitmapCursorOzone::hotspot() {
return hotspot_;
}
const SkBitmap& BitmapCursorOzone::bitmap() {
return bitmaps_[0];
}
const std::vector<SkBitmap>& BitmapCursorOzone::bitmaps() {
return bitmaps_;
}
int BitmapCursorOzone::frame_delay_ms() {
return frame_delay_ms_;
}
BitmapCursorFactoryOzone::BitmapCursorFactoryOzone() {} BitmapCursorFactoryOzone::BitmapCursorFactoryOzone() {}
BitmapCursorFactoryOzone::~BitmapCursorFactoryOzone() {} BitmapCursorFactoryOzone::~BitmapCursorFactoryOzone() {}
...@@ -57,8 +90,10 @@ PlatformCursor BitmapCursorFactoryOzone::CreateAnimatedCursor( ...@@ -57,8 +90,10 @@ PlatformCursor BitmapCursorFactoryOzone::CreateAnimatedCursor(
const gfx::Point& hotspot, const gfx::Point& hotspot,
int frame_delay_ms) { int frame_delay_ms) {
DCHECK_LT(0U, bitmaps.size()); DCHECK_LT(0U, bitmaps.size());
NOTIMPLEMENTED(); BitmapCursorOzone* cursor =
return CreateImageCursor(bitmaps[0], hotspot); new BitmapCursorOzone(bitmaps, hotspot, frame_delay_ms);
cursor->AddRef(); // Balanced by UnrefImageCursor.
return ToPlatformCursor(cursor);
} }
void BitmapCursorFactoryOzone::RefImageCursor(PlatformCursor cursor) { void BitmapCursorFactoryOzone::RefImageCursor(PlatformCursor cursor) {
......
...@@ -20,18 +20,25 @@ namespace ui { ...@@ -20,18 +20,25 @@ namespace ui {
class UI_BASE_EXPORT BitmapCursorOzone class UI_BASE_EXPORT BitmapCursorOzone
: public base::RefCounted<BitmapCursorOzone> { : public base::RefCounted<BitmapCursorOzone> {
public: public:
BitmapCursorOzone(const SkBitmap& bitmap, const gfx::Point& hotspot) BitmapCursorOzone(const SkBitmap& bitmap, const gfx::Point& hotspot);
: bitmap_(bitmap), hotspot_(hotspot) {} BitmapCursorOzone(const std::vector<SkBitmap>& bitmaps,
const gfx::Point& hotspot,
int frame_delay_ms);
const gfx::Point& hotspot() { return hotspot_; } const gfx::Point& hotspot();
const SkBitmap& bitmap() { return bitmap_; } const SkBitmap& bitmap();
// For animated cursors.
const std::vector<SkBitmap>& bitmaps();
int frame_delay_ms();
private: private:
friend class base::RefCounted<BitmapCursorOzone>; friend class base::RefCounted<BitmapCursorOzone>;
~BitmapCursorOzone() {} ~BitmapCursorOzone();
SkBitmap bitmap_; std::vector<SkBitmap> bitmaps_;
gfx::Point hotspot_; gfx::Point hotspot_;
int frame_delay_ms_;
DISALLOW_COPY_AND_ASSIGN(BitmapCursorOzone); DISALLOW_COPY_AND_ASSIGN(BitmapCursorOzone);
}; };
......
...@@ -52,8 +52,11 @@ IPC_STRUCT_TRAITS_END() ...@@ -52,8 +52,11 @@ IPC_STRUCT_TRAITS_END()
// These are messages from the browser to the GPU process. // These are messages from the browser to the GPU process.
// Update the HW cursor bitmap & move to specified location. // Update the HW cursor bitmap & move to specified location.
IPC_MESSAGE_CONTROL3(OzoneGpuMsg_CursorSet, IPC_MESSAGE_CONTROL4(OzoneGpuMsg_CursorSet,
gfx::AcceleratedWidget, SkBitmap, gfx::Point) gfx::AcceleratedWidget,
std::vector<SkBitmap>,
gfx::Point /* location */,
int /* frame_delay_ms */)
// Move the HW cursor to the specified location. // Move the HW cursor to the specified location.
IPC_MESSAGE_CONTROL2(OzoneGpuMsg_CursorMove, IPC_MESSAGE_CONTROL2(OzoneGpuMsg_CursorMove,
......
...@@ -32,16 +32,18 @@ void DriCursor::SetCursor(gfx::AcceleratedWidget widget, ...@@ -32,16 +32,18 @@ void DriCursor::SetCursor(gfx::AcceleratedWidget widget,
cursor_ = cursor; cursor_ = cursor;
if (cursor_.get()) if (cursor_.get())
hardware_->SetHardwareCursor( hardware_->SetHardwareCursor(cursor_window_,
cursor_window_, cursor_->bitmap(), bitmap_location()); cursor_->bitmaps(),
bitmap_location(),
cursor_->frame_delay_ms());
else else
hardware_->SetHardwareCursor(cursor_window_, SkBitmap(), gfx::Point()); UnsetCursor(cursor_window_);
} }
void DriCursor::MoveCursorTo(gfx::AcceleratedWidget widget, void DriCursor::MoveCursorTo(gfx::AcceleratedWidget widget,
const gfx::PointF& location) { const gfx::PointF& location) {
if (widget != cursor_window_) if (widget != cursor_window_)
hardware_->SetHardwareCursor(cursor_window_, SkBitmap(), gfx::Point()); UnsetCursor(cursor_window_);
cursor_window_ = widget; cursor_window_ = widget;
cursor_location_ = location; cursor_location_ = location;
...@@ -75,4 +77,9 @@ gfx::Point DriCursor::bitmap_location() { ...@@ -75,4 +77,9 @@ gfx::Point DriCursor::bitmap_location() {
cursor_->hotspot().OffsetFromOrigin(); cursor_->hotspot().OffsetFromOrigin();
} }
void DriCursor::UnsetCursor(gfx::AcceleratedWidget widget) {
hardware_->SetHardwareCursor(
widget, std::vector<SkBitmap>(), gfx::Point(), 0);
}
} // namespace ui } // namespace ui
...@@ -37,6 +37,8 @@ class DriCursor : public CursorDelegateEvdev { ...@@ -37,6 +37,8 @@ class DriCursor : public CursorDelegateEvdev {
virtual gfx::PointF location() OVERRIDE; virtual gfx::PointF location() OVERRIDE;
private: private:
void UnsetCursor(gfx::AcceleratedWidget widget);
// The location of the bitmap (the cursor location is the hotspot location). // The location of the bitmap (the cursor location is the hotspot location).
gfx::Point bitmap_location(); gfx::Point bitmap_location();
......
...@@ -110,10 +110,15 @@ bool DriSurfaceFactory::LoadEGLGLES2Bindings( ...@@ -110,10 +110,15 @@ bool DriSurfaceFactory::LoadEGLGLES2Bindings(
} }
void DriSurfaceFactory::SetHardwareCursor(gfx::AcceleratedWidget widget, void DriSurfaceFactory::SetHardwareCursor(gfx::AcceleratedWidget widget,
const SkBitmap& image, const std::vector<SkBitmap>& bitmaps,
const gfx::Point& location) { const gfx::Point& location,
cursor_bitmap_ = image; int frame_delay_ms) {
cursor_bitmaps_ = bitmaps;
cursor_location_ = location; cursor_location_ = location;
cursor_frame_delay_ms_ = frame_delay_ms;
if (bitmaps.size() > 1)
NOTIMPLEMENTED(); // No animation of animated cursors.
if (state_ != INITIALIZED) if (state_ != INITIALIZED)
return; return;
...@@ -141,10 +146,10 @@ void DriSurfaceFactory::ResetCursor(gfx::AcceleratedWidget widget) { ...@@ -141,10 +146,10 @@ void DriSurfaceFactory::ResetCursor(gfx::AcceleratedWidget widget) {
HardwareDisplayController* controller = HardwareDisplayController* controller =
window_manager_->GetWindowDelegate(widget)->GetController(); window_manager_->GetWindowDelegate(widget)->GetController();
if (!cursor_bitmap_.empty()) { if (cursor_bitmaps_.size()) {
// Draw new cursor into backbuffer. // Draw new cursor into backbuffer.
UpdateCursorImage(cursor_buffers_[cursor_frontbuffer_ ^ 1].get(), UpdateCursorImage(cursor_buffers_[cursor_frontbuffer_ ^ 1].get(),
cursor_bitmap_); cursor_bitmaps_[0]);
// Reset location & buffer. // Reset location & buffer.
if (controller) { if (controller) {
......
...@@ -54,9 +54,10 @@ class DriSurfaceFactory : public SurfaceFactoryOzone, ...@@ -54,9 +54,10 @@ class DriSurfaceFactory : public SurfaceFactoryOzone,
SetGLGetProcAddressProcCallback set_gl_get_proc_address) OVERRIDE; SetGLGetProcAddressProcCallback set_gl_get_proc_address) OVERRIDE;
// HardwareCursorDelegate: // HardwareCursorDelegate:
virtual void SetHardwareCursor(gfx::AcceleratedWidget window, virtual void SetHardwareCursor(gfx::AcceleratedWidget widget,
const SkBitmap& image, const std::vector<SkBitmap>& bitmaps,
const gfx::Point& location) OVERRIDE; const gfx::Point& location,
int frame_delay_ms) OVERRIDE;
virtual void MoveHardwareCursor(gfx::AcceleratedWidget window, virtual void MoveHardwareCursor(gfx::AcceleratedWidget window,
const gfx::Point& location) OVERRIDE; const gfx::Point& location) OVERRIDE;
...@@ -72,8 +73,9 @@ class DriSurfaceFactory : public SurfaceFactoryOzone, ...@@ -72,8 +73,9 @@ class DriSurfaceFactory : public SurfaceFactoryOzone,
scoped_refptr<DriBuffer> cursor_buffers_[2]; scoped_refptr<DriBuffer> cursor_buffers_[2];
int cursor_frontbuffer_; int cursor_frontbuffer_;
SkBitmap cursor_bitmap_; std::vector<SkBitmap> cursor_bitmaps_;
gfx::Point cursor_location_; gfx::Point cursor_location_;
int cursor_frame_delay_ms_;
DISALLOW_COPY_AND_ASSIGN(DriSurfaceFactory); DISALLOW_COPY_AND_ASSIGN(DriSurfaceFactory);
}; };
......
...@@ -130,8 +130,12 @@ TEST_F(DriSurfaceFactoryTest, SetCursorImage) { ...@@ -130,8 +130,12 @@ TEST_F(DriSurfaceFactoryTest, SetCursorImage) {
image.allocPixels(info); image.allocPixels(info);
image.eraseColor(SK_ColorWHITE); image.eraseColor(SK_ColorWHITE);
factory_->SetHardwareCursor( std::vector<SkBitmap> cursor_bitmaps;
ui::DriSurfaceFactory::kDefaultWidgetHandle, image, gfx::Point(4, 2)); cursor_bitmaps.push_back(image);
factory_->SetHardwareCursor(ui::DriSurfaceFactory::kDefaultWidgetHandle,
cursor_bitmaps,
gfx::Point(4, 2),
0);
SkBitmap cursor; SkBitmap cursor;
// Buffers 0 and 1 are the cursor buffers. // Buffers 0 and 1 are the cursor buffers.
......
...@@ -83,9 +83,10 @@ void GpuPlatformSupportGbm::OnWindowBoundsChanged(gfx::AcceleratedWidget widget, ...@@ -83,9 +83,10 @@ void GpuPlatformSupportGbm::OnWindowBoundsChanged(gfx::AcceleratedWidget widget,
} }
void GpuPlatformSupportGbm::OnCursorSet(gfx::AcceleratedWidget widget, void GpuPlatformSupportGbm::OnCursorSet(gfx::AcceleratedWidget widget,
const SkBitmap& bitmap, const std::vector<SkBitmap>& bitmaps,
const gfx::Point& location) { const gfx::Point& location,
dri_->SetHardwareCursor(widget, bitmap, location); int frame_delay_ms) {
dri_->SetHardwareCursor(widget, bitmaps, location, frame_delay_ms);
} }
void GpuPlatformSupportGbm::OnCursorMove(gfx::AcceleratedWidget widget, void GpuPlatformSupportGbm::OnCursorMove(gfx::AcceleratedWidget widget,
......
...@@ -46,8 +46,9 @@ class GpuPlatformSupportGbm : public GpuPlatformSupport { ...@@ -46,8 +46,9 @@ class GpuPlatformSupportGbm : public GpuPlatformSupport {
void OnWindowBoundsChanged(gfx::AcceleratedWidget widget, void OnWindowBoundsChanged(gfx::AcceleratedWidget widget,
const gfx::Rect& bounds); const gfx::Rect& bounds);
void OnCursorSet(gfx::AcceleratedWidget widget, void OnCursorSet(gfx::AcceleratedWidget widget,
const SkBitmap& bitmap, const std::vector<SkBitmap>& bitmaps,
const gfx::Point& location); const gfx::Point& location,
int frame_delay_ms);
void OnCursorMove(gfx::AcceleratedWidget widget, const gfx::Point& location); void OnCursorMove(gfx::AcceleratedWidget widget, const gfx::Point& location);
IPC::Sender* sender_; IPC::Sender* sender_;
......
...@@ -100,10 +100,12 @@ bool GpuPlatformSupportHostGbm::Send(IPC::Message* message) { ...@@ -100,10 +100,12 @@ bool GpuPlatformSupportHostGbm::Send(IPC::Message* message) {
return true; return true;
} }
void GpuPlatformSupportHostGbm::SetHardwareCursor(gfx::AcceleratedWidget widget, void GpuPlatformSupportHostGbm::SetHardwareCursor(
const SkBitmap& bitmap, gfx::AcceleratedWidget widget,
const gfx::Point& location) { const std::vector<SkBitmap>& bitmaps,
Send(new OzoneGpuMsg_CursorSet(widget, bitmap, location)); const gfx::Point& location,
int frame_delay_ms) {
Send(new OzoneGpuMsg_CursorSet(widget, bitmaps, location, frame_delay_ms));
} }
void GpuPlatformSupportHostGbm::MoveHardwareCursor( void GpuPlatformSupportHostGbm::MoveHardwareCursor(
......
...@@ -50,8 +50,9 @@ class GpuPlatformSupportHostGbm : public GpuPlatformSupportHost, ...@@ -50,8 +50,9 @@ class GpuPlatformSupportHostGbm : public GpuPlatformSupportHost,
// HardwareCursorDelegate: // HardwareCursorDelegate:
virtual void SetHardwareCursor(gfx::AcceleratedWidget widget, virtual void SetHardwareCursor(gfx::AcceleratedWidget widget,
const SkBitmap& bitmap, const std::vector<SkBitmap>& bitmaps,
const gfx::Point& location) OVERRIDE; const gfx::Point& location,
int frame_delay_ms) OVERRIDE;
virtual void MoveHardwareCursor(gfx::AcceleratedWidget widget, virtual void MoveHardwareCursor(gfx::AcceleratedWidget widget,
const gfx::Point& location) OVERRIDE; const gfx::Point& location) OVERRIDE;
......
...@@ -20,8 +20,9 @@ class HardwareCursorDelegate { ...@@ -20,8 +20,9 @@ class HardwareCursorDelegate {
// Update the HW cursor bitmap & move to specified location. If // Update the HW cursor bitmap & move to specified location. If
// the bitmap is empty, the cursor is hidden. // the bitmap is empty, the cursor is hidden.
virtual void SetHardwareCursor(gfx::AcceleratedWidget widget, virtual void SetHardwareCursor(gfx::AcceleratedWidget widget,
const SkBitmap& bitmap, const std::vector<SkBitmap>& bitmaps,
const gfx::Point& location) = 0; const gfx::Point& location,
int frame_delay_ms) = 0;
// Move the HW cursor to the specified location. // Move the HW cursor to the specified location.
virtual void MoveHardwareCursor(gfx::AcceleratedWidget widget, virtual void MoveHardwareCursor(gfx::AcceleratedWidget widget,
......
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