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 case WebCursorInfo::kTypeEastResize: |
| 22 resource_id = IDR_ANDROID_CURSOR_EAST_RESIZE; |
| 23 break; |
| 24 case WebCursorInfo::kTypeNorthResize: |
| 25 resource_id = IDR_ANDROID_CURSOR_NORTH_RESIZE; |
| 26 break; |
| 27 case WebCursorInfo::kTypeNorthEastResize: |
| 28 resource_id = IDR_ANDROID_CURSOR_NORTH_EAST_RESIZE; |
| 29 break; |
| 30 case WebCursorInfo::kTypeNorthWestResize: |
| 31 resource_id = IDR_ANDROID_CURSOR_NORTH_WEST_RESIZE; |
| 32 break; |
| 33 case WebCursorInfo::kTypeSouthResize: |
| 34 resource_id = IDR_ANDROID_CURSOR_SOUTH_RESIZE; |
| 35 break; |
| 36 case WebCursorInfo::kTypeSouthEastResize: |
| 37 resource_id = IDR_ANDROID_CURSOR_SOUTH_EAST_RESIZE; |
| 38 break; |
| 39 case WebCursorInfo::kTypeSouthWestResize: |
| 40 resource_id = IDR_ANDROID_CURSOR_SOUTH_WEST_RESIZE; |
| 41 break; |
| 42 case WebCursorInfo::kTypeWestResize: |
| 43 resource_id = IDR_ANDROID_CURSOR_WEST_RESIZE; |
| 44 break; |
| 45 case WebCursorInfo::kTypeMove: |
| 46 resource_id = IDR_ANDROID_CURSOR_MOVE; |
| 47 break; |
| 48 case WebCursorInfo::kTypeMiddlePanning: |
| 49 resource_id = IDR_ANDROID_CURSOR_MIDDLE_PANNING; |
| 50 break; |
| 51 case WebCursorInfo::kTypeProgress: |
| 52 resource_id = IDR_ANDROID_CURSOR_PROGRESS; |
| 53 break; |
| 54 case WebCursorInfo::kTypeNotAllowed: |
| 55 resource_id = IDR_ANDROID_CURSOR_NOT_ALLOWED; |
| 56 break; |
| 57 default: |
| 58 return false; |
| 59 } |
| 60 |
| 61 const SkBitmap* cursor_bitmap = ResourceBundle::GetSharedInstance() |
| 62 .GetImageSkiaNamed(resource_id) |
| 63 ->bitmap(); |
| 64 if (!cursor_bitmap) |
| 65 return false; |
| 66 *bitmap = *cursor_bitmap; |
| 67 return true; |
| 68 } |
| 69 |
| 70 } // namespace ui |
OLD | NEW |