[SyncFS] Build indexes from FileTracker entries on disk.
[chromium-blink-merge.git] / ui / base / cursor / cursor_loader_ozone.cc
blob8309c2e4b2afc8e8e38cac4e5cd3eb249a8f37ff
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.
5 #include "ui/base/cursor/cursor_loader_ozone.h"
7 #include "ui/base/cursor/cursor.h"
8 #include "ui/base/resource/resource_bundle.h"
9 #include "ui/gfx/image/image_skia.h"
10 #include "ui/ozone/public/cursor_factory_ozone.h"
12 namespace ui {
14 CursorLoaderOzone::CursorLoaderOzone() {}
16 CursorLoaderOzone::~CursorLoaderOzone() {}
18 void CursorLoaderOzone::LoadImageCursor(int id,
19 int resource_id,
20 const gfx::Point& hot) {
21 const gfx::ImageSkia* image =
22 ResourceBundle::GetSharedInstance().GetImageSkiaNamed(resource_id);
23 const gfx::ImageSkiaRep& image_rep =
24 image->GetRepresentation(scale());
25 SkBitmap bitmap = image_rep.sk_bitmap();
26 cursors_[id] =
27 CursorFactoryOzone::GetInstance()->CreateImageCursor(bitmap, hot);
30 void CursorLoaderOzone::LoadAnimatedCursor(int id,
31 int resource_id,
32 const gfx::Point& hot,
33 int frame_delay_ms) {
34 // TODO(dnicoara) Add support: crbug.com/343245
35 NOTIMPLEMENTED();
38 void CursorLoaderOzone::UnloadAll() {
39 for (ImageCursorMap::const_iterator it = cursors_.begin();
40 it != cursors_.end();
41 ++it)
42 CursorFactoryOzone::GetInstance()->UnrefImageCursor(it->second);
43 cursors_.clear();
46 void CursorLoaderOzone::SetPlatformCursor(gfx::NativeCursor* cursor) {
47 int native_type = cursor->native_type();
48 PlatformCursor platform;
50 if (cursors_.count(native_type)) {
51 // An image cursor is loaded for this type.
52 platform = cursors_[native_type];
53 } else if (native_type == kCursorCustom) {
54 // The platform cursor was already set via WebCursor::GetPlatformCursor.
55 platform = cursor->platform();
56 } else {
57 // Use default cursor of this type.
58 platform = CursorFactoryOzone::GetInstance()->GetDefaultCursor(native_type);
61 cursor->SetPlatformCursor(platform);
64 CursorLoader* CursorLoader::Create() {
65 return new CursorLoaderOzone();
68 } // namespace ui