| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "content/common/cursors/webcursor.h" | 5 #include "content/common/cursors/webcursor.h" |
| 6 | 6 |
| 7 #include "third_party/WebKit/public/platform/WebCursorInfo.h" | 7 #include "third_party/WebKit/public/platform/WebCursorInfo.h" |
| 8 #include "ui/base/cursor/cursor.h" | 8 #include "ui/base/cursor/cursor.h" |
| 9 #include "ui/base/cursor/cursor_util.h" | 9 #include "ui/base/cursor/cursor_util.h" |
| 10 #include "ui/ozone/public/cursor_factory_ozone.h" | 10 #include "ui/ozone/public/cursor_factory_ozone.h" |
| (...skipping 22 matching lines...) Expand all Loading... |
| 33 bitmap.height()); | 33 bitmap.height()); |
| 34 | 34 |
| 35 ui::ScaleAndRotateCursorBitmapAndHotpoint(scale, rotation_, &bitmap, | 35 ui::ScaleAndRotateCursorBitmapAndHotpoint(scale, rotation_, &bitmap, |
| 36 &hotspot); | 36 &hotspot); |
| 37 | 37 |
| 38 platform_cursor_ = | 38 platform_cursor_ = |
| 39 ui::CursorFactoryOzone::GetInstance()->CreateImageCursor(bitmap, hotspot); | 39 ui::CursorFactoryOzone::GetInstance()->CreateImageCursor(bitmap, hotspot); |
| 40 return platform_cursor_; | 40 return platform_cursor_; |
| 41 } | 41 } |
| 42 | 42 |
| 43 void WebCursor::SetDisplayInfo(const gfx::Display& display) { | 43 void WebCursor::SetDisplayInfo(const display::Display& display) { |
| 44 if (rotation_ == display.rotation() && | 44 if (rotation_ == display.rotation() && |
| 45 device_scale_factor_ == display.device_scale_factor() && | 45 device_scale_factor_ == display.device_scale_factor() && |
| 46 maximum_cursor_size_ == display.maximum_cursor_size()) | 46 maximum_cursor_size_ == display.maximum_cursor_size()) |
| 47 return; | 47 return; |
| 48 device_scale_factor_ = display.device_scale_factor(); | 48 device_scale_factor_ = display.device_scale_factor(); |
| 49 rotation_ = display.rotation(); | 49 rotation_ = display.rotation(); |
| 50 maximum_cursor_size_ = display.maximum_cursor_size(); | 50 maximum_cursor_size_ = display.maximum_cursor_size(); |
| 51 // TODO(oshima): Identify if it's possible to remove this check here and move | 51 // TODO(oshima): Identify if it's possible to remove this check here and move |
| 52 // the kDefaultMaxCursor{Width,Height} constants to a single place. | 52 // the kDefaultMaxCursor{Width,Height} constants to a single place. |
| 53 // crbug.com/603512 | 53 // crbug.com/603512 |
| 54 if (maximum_cursor_size_.width() == 0 || maximum_cursor_size_.height() == 0) | 54 if (maximum_cursor_size_.width() == 0 || maximum_cursor_size_.height() == 0) |
| 55 maximum_cursor_size_ = | 55 maximum_cursor_size_ = |
| 56 gfx::Size(kDefaultMaxCursorWidth, kDefaultMaxCursorHeight); | 56 gfx::Size(kDefaultMaxCursorWidth, kDefaultMaxCursorHeight); |
| 57 if (platform_cursor_) | 57 if (platform_cursor_) |
| 58 ui::CursorFactoryOzone::GetInstance()->UnrefImageCursor(platform_cursor_); | 58 ui::CursorFactoryOzone::GetInstance()->UnrefImageCursor(platform_cursor_); |
| 59 platform_cursor_ = NULL; | 59 platform_cursor_ = NULL; |
| 60 // It is not necessary to recreate platform_cursor_ yet, since it will be | 60 // It is not necessary to recreate platform_cursor_ yet, since it will be |
| 61 // recreated on demand when GetPlatformCursor is called. | 61 // recreated on demand when GetPlatformCursor is called. |
| 62 } | 62 } |
| 63 | 63 |
| 64 void WebCursor::InitPlatformData() { | 64 void WebCursor::InitPlatformData() { |
| 65 platform_cursor_ = NULL; | 65 platform_cursor_ = NULL; |
| 66 device_scale_factor_ = 1.f; | 66 device_scale_factor_ = 1.f; |
| 67 rotation_ = gfx::Display::ROTATE_0; | 67 rotation_ = display::Display::ROTATE_0; |
| 68 maximum_cursor_size_ = | 68 maximum_cursor_size_ = |
| 69 gfx::Size(kDefaultMaxCursorWidth, kDefaultMaxCursorHeight); | 69 gfx::Size(kDefaultMaxCursorWidth, kDefaultMaxCursorHeight); |
| 70 } | 70 } |
| 71 | 71 |
| 72 bool WebCursor::SerializePlatformData(base::Pickle* pickle) const { | 72 bool WebCursor::SerializePlatformData(base::Pickle* pickle) const { |
| 73 return true; | 73 return true; |
| 74 } | 74 } |
| 75 | 75 |
| 76 bool WebCursor::DeserializePlatformData(base::PickleIterator* iter) { | 76 bool WebCursor::DeserializePlatformData(base::PickleIterator* iter) { |
| 77 return true; | 77 return true; |
| (...skipping 15 matching lines...) Expand all Loading... |
| 93 ui::CursorFactoryOzone::GetInstance()->UnrefImageCursor(platform_cursor_); | 93 ui::CursorFactoryOzone::GetInstance()->UnrefImageCursor(platform_cursor_); |
| 94 platform_cursor_ = other.platform_cursor_; | 94 platform_cursor_ = other.platform_cursor_; |
| 95 if (platform_cursor_) | 95 if (platform_cursor_) |
| 96 ui::CursorFactoryOzone::GetInstance()->RefImageCursor(platform_cursor_); | 96 ui::CursorFactoryOzone::GetInstance()->RefImageCursor(platform_cursor_); |
| 97 | 97 |
| 98 device_scale_factor_ = other.device_scale_factor_; | 98 device_scale_factor_ = other.device_scale_factor_; |
| 99 maximum_cursor_size_ = other.maximum_cursor_size_; | 99 maximum_cursor_size_ = other.maximum_cursor_size_; |
| 100 } | 100 } |
| 101 | 101 |
| 102 } // namespace content | 102 } // namespace content |
| OLD | NEW |