#include "ui/ozone/platform/dri/dri_buffer.h"
#include "ui/ozone/platform/dri/dri_surface.h"
#include "ui/ozone/platform/dri/dri_util.h"
+#include "ui/ozone/platform/dri/dri_window_delegate_impl.h"
+#include "ui/ozone/platform/dri/dri_window_delegate_manager.h"
#include "ui/ozone/platform/dri/dri_wrapper.h"
#include "ui/ozone/platform/dri/hardware_display_controller.h"
#include "ui/ozone/platform/dri/screen_manager.h"
// static
const gfx::AcceleratedWidget DriSurfaceFactory::kDefaultWidgetHandle = 1;
-DriSurfaceFactory::DriSurfaceFactory(
- DriWrapper* drm,
- ScreenManager* screen_manager)
+DriSurfaceFactory::DriSurfaceFactory(DriWrapper* drm,
+ ScreenManager* screen_manager,
+ DriWindowDelegateManager* window_manager)
: drm_(drm),
screen_manager_(screen_manager),
+ window_manager_(window_manager),
state_(UNINITIALIZED),
- allocated_widgets_(0),
- cursor_frontbuffer_(0) {
+ cursor_frontbuffer_(0),
+ cursor_widget_(0),
+ cursor_frame_(0),
+ cursor_frame_delay_ms_(0) {
}
DriSurfaceFactory::~DriSurfaceFactory() {
}
scoped_ptr<ui::SurfaceOzoneCanvas> DriSurfaceFactory::CreateCanvasForWidget(
- gfx::AcceleratedWidget w) {
+ gfx::AcceleratedWidget widget) {
DCHECK(state_ == INITIALIZED);
- // Initial cursor set.
- ResetCursor(w);
return scoped_ptr<ui::SurfaceOzoneCanvas>(
- new DriSurface(drm_, screen_manager_->GetDisplayController(w)));
+ new DriSurface(window_manager_->GetWindowDelegate(widget), drm_));
}
bool DriSurfaceFactory::LoadEGLGLES2Bindings(
return false;
}
-gfx::AcceleratedWidget DriSurfaceFactory::GetAcceleratedWidget() {
- DCHECK(state_ != FAILED);
-
- // We're not using 0 since other code assumes that a 0 AcceleratedWidget is an
- // invalid widget.
- return ++allocated_widgets_;
-}
-
-gfx::Size DriSurfaceFactory::GetWidgetSize(gfx::AcceleratedWidget w) {
- base::WeakPtr<HardwareDisplayController> controller =
- screen_manager_->GetDisplayController(w);
- if (controller)
- return gfx::Size(controller->get_mode().hdisplay,
- controller->get_mode().vdisplay);
-
- return gfx::Size(0, 0);
-}
-
-void DriSurfaceFactory::SetHardwareCursor(gfx::AcceleratedWidget window,
- const SkBitmap& image,
- const gfx::Point& location) {
- cursor_bitmap_ = image;
+void DriSurfaceFactory::SetHardwareCursor(gfx::AcceleratedWidget widget,
+ const std::vector<SkBitmap>& bitmaps,
+ const gfx::Point& location,
+ int frame_delay_ms) {
+ cursor_widget_ = widget;
+ cursor_bitmaps_ = bitmaps;
cursor_location_ = location;
+ cursor_frame_ = 0;
+ cursor_frame_delay_ms_ = frame_delay_ms;
+ cursor_timer_.Stop();
+
+ if (cursor_frame_delay_ms_)
+ cursor_timer_.Start(
+ FROM_HERE,
+ base::TimeDelta::FromMilliseconds(cursor_frame_delay_ms_),
+ this,
+ &DriSurfaceFactory::OnCursorAnimationTimeout);
if (state_ != INITIALIZED)
return;
- ResetCursor(window);
+ ResetCursor();
}
-void DriSurfaceFactory::MoveHardwareCursor(gfx::AcceleratedWidget window,
+void DriSurfaceFactory::MoveHardwareCursor(gfx::AcceleratedWidget widget,
const gfx::Point& location) {
cursor_location_ = location;
if (state_ != INITIALIZED)
return;
- base::WeakPtr<HardwareDisplayController> controller =
- screen_manager_->GetDisplayController(window);
+ HardwareDisplayController* controller =
+ window_manager_->GetWindowDelegate(widget)->GetController();
if (controller)
controller->MoveCursor(location);
}
////////////////////////////////////////////////////////////////////////////////
// DriSurfaceFactory private
-void DriSurfaceFactory::ResetCursor(gfx::AcceleratedWidget w) {
- base::WeakPtr<HardwareDisplayController> controller =
- screen_manager_->GetDisplayController(w);
+void DriSurfaceFactory::ResetCursor() {
+ if (!cursor_widget_)
+ return;
- if (!cursor_bitmap_.empty()) {
+ HardwareDisplayController* controller =
+ window_manager_->GetWindowDelegate(cursor_widget_)->GetController();
+ if (cursor_bitmaps_.size()) {
// Draw new cursor into backbuffer.
UpdateCursorImage(cursor_buffers_[cursor_frontbuffer_ ^ 1].get(),
- cursor_bitmap_);
+ cursor_bitmaps_[cursor_frame_]);
// Reset location & buffer.
if (controller) {
}
}
+void DriSurfaceFactory::OnCursorAnimationTimeout() {
+ cursor_frame_++;
+ cursor_frame_ %= cursor_bitmaps_.size();
+
+ ResetCursor();
+}
+
} // namespace ui