summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormazda@chromium.org <mazda@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-10-22 23:45:05 +0000
committermazda@chromium.org <mazda@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-10-22 23:45:05 +0000
commit2216f232f22777cabab33e2a889af82b5b92468d (patch)
treefe56924229bc1d7fc490649180dfd311cae2ae34
parentb75e0ad9d0e78f14a9c477f155688b02b78e26ad (diff)
downloadchromium_src-2216f232f22777cabab33e2a889af82b5b92468d.zip
chromium_src-2216f232f22777cabab33e2a889af82b5b92468d.tar.gz
chromium_src-2216f232f22777cabab33e2a889af82b5b92468d.tar.bz2
Ensure ImageCursor to load image cursors.
After http://crrev.com/163108, ImageCursor does not load image cursors until a device scale factor other than 1.0f is set. This CL fixes that. BUG=157059 Review URL: https://chromiumcodereview.appspot.com/11235030 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@163443 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--ash/wm/cursor_manager.cc6
-rw-r--r--ash/wm/image_cursors.cc18
-rw-r--r--ash/wm/image_cursors.h8
3 files changed, 20 insertions, 12 deletions
diff --git a/ash/wm/cursor_manager.cc b/ash/wm/cursor_manager.cc
index d1bfa83..b251051 100644
--- a/ash/wm/cursor_manager.cc
+++ b/ash/wm/cursor_manager.cc
@@ -69,10 +69,8 @@ bool CursorManager::IsCursorVisible() const {
}
void CursorManager::SetDeviceScaleFactor(float device_scale_factor) {
- if (image_cursors_->GetDeviceScaleFactor() == device_scale_factor)
- return;
- image_cursors_->SetDeviceScaleFactor(device_scale_factor);
- SetCursorInternal(current_cursor_);
+ if (image_cursors_->SetDeviceScaleFactor(device_scale_factor))
+ SetCursorInternal(current_cursor_);
}
void CursorManager::LockCursor() {
diff --git a/ash/wm/image_cursors.cc b/ash/wm/image_cursors.cc
index c893fdc..5d22016 100644
--- a/ash/wm/image_cursors.cc
+++ b/ash/wm/image_cursors.cc
@@ -82,20 +82,27 @@ const CursorData kAnimatedCursors[] = {
namespace ash {
-ImageCursors::ImageCursors()
- : cursor_loader_(ui::CursorLoader::Create()) {
+ImageCursors::ImageCursors() {
}
ImageCursors::~ImageCursors() {
}
float ImageCursors::GetDeviceScaleFactor() const {
+ if (!cursor_loader_.get()) {
+ NOTREACHED();
+ // Returning 1.0f on release build as it's not serious enough to crash
+ // even if this ever happens.
+ return 1.0f;
+ }
return cursor_loader_->device_scale_factor();
}
-void ImageCursors::SetDeviceScaleFactor(float device_scale_factor) {
- if (GetDeviceScaleFactor() == device_scale_factor)
- return;
+bool ImageCursors::SetDeviceScaleFactor(float device_scale_factor) {
+ if (!cursor_loader_.get())
+ cursor_loader_.reset(ui::CursorLoader::Create());
+ else if (GetDeviceScaleFactor() == device_scale_factor)
+ return false;
cursor_loader_->UnloadAll();
cursor_loader_->set_device_scale_factor(device_scale_factor);
@@ -115,6 +122,7 @@ void ImageCursors::SetDeviceScaleFactor(float device_scale_factor) {
gfx::Point(hot.x, hot.y),
kAnimatedCursorFrameDelayMs);
}
+ return true;
}
void ImageCursors::SetPlatformCursor(gfx::NativeCursor* cursor) {
diff --git a/ash/wm/image_cursors.h b/ash/wm/image_cursors.h
index a1a7c41..61169a9 100644
--- a/ash/wm/image_cursors.h
+++ b/ash/wm/image_cursors.h
@@ -22,12 +22,14 @@ class ASH_EXPORT ImageCursors {
ImageCursors();
~ImageCursors();
- // Returns the device scale factor of cursors.
+ // Returns the device scale factor of cursors. The device scale factor must
+ // be set by SetDeviceScaleFactor at least once before using this.
float GetDeviceScaleFactor() const;
// Sets the device scale factor of the cursors with |device_scale_factor| and
- // reloads the cursor images if necessary.
- void SetDeviceScaleFactor(float device_scale_factor);
+ // reloads the cursor images if necessary. Returns true if the cursor image
+ // is reloaded.
+ bool SetDeviceScaleFactor(float device_scale_factor);
// Sets the platform cursor based on the native type of |cursor|.
void SetPlatformCursor(gfx::NativeCursor* cursor);