Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "ui/base/cursor/cursor_loader_ozone.h" | |
| 6 | |
| 7 #include "ui/base/cursor/cursor.h" | |
| 8 #include "ui/base/resource/resource_bundle.h" | |
| 9 #include "ui/gfx/image/image_skia.h" | |
| 10 | |
| 11 namespace ui { | |
| 12 | |
| 13 namespace { | |
| 14 | |
| 15 // Creates a 1x1 cursor which will be fully transparent. | |
| 16 SkBitmap CreateInvisibleCursor() { | |
| 17 SkBitmap cursor; | |
| 18 cursor.setConfig(SkBitmap::kARGB_8888_Config, 1, 1); | |
| 19 cursor.allocPixels(); | |
| 20 | |
| 21 cursor.lockPixels(); | |
| 22 cursor.eraseARGB(0, 0, 0, 0); | |
| 23 cursor.unlockPixels(); | |
| 24 | |
| 25 return cursor; | |
| 26 } | |
| 27 | |
| 28 } // namespace | |
| 29 | |
| 30 CursorLoaderOzone::CursorLoaderOzone() { | |
| 31 cursors_[kCursorNone] = CreateInvisibleCursor(); | |
| 32 } | |
| 33 | |
| 34 CursorLoaderOzone::~CursorLoaderOzone() {} | |
| 35 | |
| 36 void CursorLoaderOzone::LoadImageCursor(int id, | |
|
rjkroege
2014/02/11 21:57:55
this code as written never removes cursors. how ar
dnicoara
2014/02/12 16:18:19
I've added a call to clear in UnloadAll. It wasn't
| |
| 37 int resource_id, | |
| 38 const gfx::Point& hot) { | |
| 39 const gfx::ImageSkia* image = ResourceBundle::GetSharedInstance() | |
| 40 .GetImageSkiaNamed(resource_id); | |
| 41 const gfx::ImageSkiaRep& image_rep = image->GetRepresentation( | |
| 42 display().device_scale_factor()); | |
| 43 | |
| 44 cursors_[id] = image_rep.sk_bitmap(); | |
| 45 } | |
| 46 | |
| 47 void CursorLoaderOzone::LoadAnimatedCursor(int id, | |
| 48 int resource_id, | |
| 49 const gfx::Point& hot, | |
| 50 int frame_delay_ms) { | |
| 51 NOTIMPLEMENTED(); | |
| 52 } | |
| 53 | |
| 54 void CursorLoaderOzone::UnloadAll() {} | |
| 55 | |
| 56 void CursorLoaderOzone::SetPlatformCursor(gfx::NativeCursor* cursor) { | |
| 57 if (cursors_.find(cursor->native_type()) != cursors_.end()) { | |
| 58 cursor->SetPlatformCursor(&cursors_[cursor->native_type()]); | |
| 59 } else if (*cursor == kCursorCustom) { | |
| 60 cursor->SetPlatformCursor(cursor->platform()); | |
| 61 } else { | |
| 62 cursor->SetPlatformCursor(&cursors_[kCursorPointer]); | |
| 63 } | |
| 64 } | |
| 65 | |
| 66 CursorLoader* CursorLoader::Create() { | |
| 67 return new CursorLoaderOzone(); | |
| 68 } | |
| 69 | |
| 70 } // namespace ui | |
| OLD | NEW |