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 "ui/base/cursor/cursor_loader_ozone.h" | 5 #include "ui/base/cursor/cursor_loader_ozone.h" |
6 | 6 |
| 7 #include <vector> |
| 8 |
7 #include "ui/base/cursor/cursor.h" | 9 #include "ui/base/cursor/cursor.h" |
8 #include "ui/base/resource/resource_bundle.h" | 10 #include "ui/base/cursor/cursor_util.h" |
9 #include "ui/gfx/image/image_skia.h" | |
10 #include "ui/ozone/public/cursor_factory_ozone.h" | 11 #include "ui/ozone/public/cursor_factory_ozone.h" |
11 | 12 |
12 namespace ui { | 13 namespace ui { |
13 | 14 |
14 CursorLoaderOzone::CursorLoaderOzone() {} | 15 CursorLoaderOzone::CursorLoaderOzone() {} |
15 | 16 |
16 CursorLoaderOzone::~CursorLoaderOzone() {} | 17 CursorLoaderOzone::~CursorLoaderOzone() {} |
17 | 18 |
18 void CursorLoaderOzone::LoadImageCursor(int id, | 19 void CursorLoaderOzone::LoadImageCursor(int id, |
19 int resource_id, | 20 int resource_id, |
20 const gfx::Point& hot) { | 21 const gfx::Point& hot) { |
21 const gfx::ImageSkia* image = | 22 SkBitmap bitmap; |
22 ResourceBundle::GetSharedInstance().GetImageSkiaNamed(resource_id); | 23 gfx::Point hotspot = hot; |
23 const gfx::ImageSkiaRep& image_rep = | 24 |
24 image->GetRepresentation(scale()); | 25 GetImageCursorBitmap(resource_id, scale(), rotation(), &hotspot, &bitmap); |
25 SkBitmap bitmap = image_rep.sk_bitmap(); | 26 |
26 cursors_[id] = | 27 cursors_[id] = |
27 CursorFactoryOzone::GetInstance()->CreateImageCursor(bitmap, hot); | 28 CursorFactoryOzone::GetInstance()->CreateImageCursor(bitmap, hotspot); |
28 } | 29 } |
29 | 30 |
30 void CursorLoaderOzone::LoadAnimatedCursor(int id, | 31 void CursorLoaderOzone::LoadAnimatedCursor(int id, |
31 int resource_id, | 32 int resource_id, |
32 const gfx::Point& hot, | 33 const gfx::Point& hot, |
33 int frame_delay_ms) { | 34 int frame_delay_ms) { |
34 // TODO(dnicoara) Add support: crbug.com/343245 | 35 std::vector<SkBitmap> bitmaps; |
35 NOTIMPLEMENTED(); | 36 gfx::Point hotspot = hot; |
| 37 |
| 38 GetAnimatedCursorBitmaps( |
| 39 resource_id, scale(), rotation(), &hotspot, &bitmaps); |
| 40 |
| 41 cursors_[id] = CursorFactoryOzone::GetInstance()->CreateAnimatedCursor( |
| 42 bitmaps, hotspot, frame_delay_ms); |
36 } | 43 } |
37 | 44 |
38 void CursorLoaderOzone::UnloadAll() { | 45 void CursorLoaderOzone::UnloadAll() { |
39 for (ImageCursorMap::const_iterator it = cursors_.begin(); | 46 for (ImageCursorMap::const_iterator it = cursors_.begin(); |
40 it != cursors_.end(); | 47 it != cursors_.end(); |
41 ++it) | 48 ++it) |
42 CursorFactoryOzone::GetInstance()->UnrefImageCursor(it->second); | 49 CursorFactoryOzone::GetInstance()->UnrefImageCursor(it->second); |
43 cursors_.clear(); | 50 cursors_.clear(); |
44 } | 51 } |
45 | 52 |
(...skipping 13 matching lines...) Expand all Loading... |
59 } | 66 } |
60 | 67 |
61 cursor->SetPlatformCursor(platform); | 68 cursor->SetPlatformCursor(platform); |
62 } | 69 } |
63 | 70 |
64 CursorLoader* CursorLoader::Create() { | 71 CursorLoader* CursorLoader::Create() { |
65 return new CursorLoaderOzone(); | 72 return new CursorLoaderOzone(); |
66 } | 73 } |
67 | 74 |
68 } // namespace ui | 75 } // namespace ui |
OLD | NEW |