OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #include "ui/base/cursor/cursors_android.h" | |
6 | |
7 #include "third_party/WebKit/public/platform/WebCursorInfo.h" | |
8 #include "third_party/skia/include/core/SkBitmap.h" | |
9 #include "ui/base/resource/resource_bundle.h" | |
10 #include "ui/gfx/image/image_skia.h" | |
11 #include "ui/resources/grit/ui_resources.h" | |
12 | |
13 using blink::WebCursorInfo; | |
14 | |
15 namespace ui { | |
16 | |
17 bool GetCursorBitmap(int type, SkBitmap* bitmap) { | |
18 DCHECK(bitmap); | |
19 int resource_id; | |
20 switch (type) { | |
21 // TODO(jaebaek): set types correctly | |
22 // after fixing http://crbug.com/584424. | |
23 case WebCursorInfo::kTypeMove: | |
24 resource_id = IDR_ANDROID_CURSOR_MOVE; | |
25 break; | |
26 case WebCursorInfo::kTypeMiddlePanning: | |
27 resource_id = IDR_ANDROID_CURSOR_MIDDLE_PANNING; | |
28 break; | |
29 case WebCursorInfo::kTypeEastWestResize: | |
30 case WebCursorInfo::kTypeNorthSouthResize: | |
31 case WebCursorInfo::kTypeEastResize: | |
32 case WebCursorInfo::kTypeNorthResize: | |
33 case WebCursorInfo::kTypeNorthEastResize: | |
34 case WebCursorInfo::kTypeNorthWestResize: | |
35 case WebCursorInfo::kTypeSouthResize: | |
36 case WebCursorInfo::kTypeSouthEastResize: | |
37 case WebCursorInfo::kTypeSouthWestResize: | |
38 case WebCursorInfo::kTypeWestResize: | |
39 case WebCursorInfo::kTypeProgress: | |
40 case WebCursorInfo::kTypeNotAllowed: | |
41 default: | |
boliu
2017/05/24 18:24:07
avoid default
jaebaek
2017/05/29 12:40:03
I also drop this file.
| |
42 return false; | |
43 } | |
44 | |
45 const SkBitmap* cursor_bitmap = ResourceBundle::GetSharedInstance() | |
46 .GetImageSkiaNamed(resource_id) | |
47 ->bitmap(); | |
48 if (!cursor_bitmap) | |
49 return false; | |
50 *bitmap = *cursor_bitmap; | |
51 return true; | |
52 } | |
53 | |
54 } // namespace ui | |
OLD | NEW |