Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(55)

Side by Side Diff: ui/base/cursor/ozone/bitmap_cursor_factory_ozone.cc

Issue 543823002: ozone: Plumb animated cursors from CursorLoaderOzone to CursorFactoryOzone (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: s/0/0U/ Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/ozone/bitmap_cursor_factory_ozone.h" 5 #include "ui/base/cursor/ozone/bitmap_cursor_factory_ozone.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "third_party/skia/include/core/SkBitmap.h" 8 #include "third_party/skia/include/core/SkBitmap.h"
9 #include "ui/base/cursor/cursors_aura.h" 9 #include "ui/base/cursor/cursors_aura.h"
10 10
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 } 45 }
46 46
47 PlatformCursor BitmapCursorFactoryOzone::CreateImageCursor( 47 PlatformCursor BitmapCursorFactoryOzone::CreateImageCursor(
48 const SkBitmap& bitmap, 48 const SkBitmap& bitmap,
49 const gfx::Point& hotspot) { 49 const gfx::Point& hotspot) {
50 BitmapCursorOzone* cursor = new BitmapCursorOzone(bitmap, hotspot); 50 BitmapCursorOzone* cursor = new BitmapCursorOzone(bitmap, hotspot);
51 cursor->AddRef(); // Balanced by UnrefImageCursor. 51 cursor->AddRef(); // Balanced by UnrefImageCursor.
52 return ToPlatformCursor(cursor); 52 return ToPlatformCursor(cursor);
53 } 53 }
54 54
55 PlatformCursor BitmapCursorFactoryOzone::CreateAnimatedCursor(
56 const std::vector<SkBitmap>& bitmaps,
57 const gfx::Point& hotspot,
58 int frame_delay_ms) {
59 DCHECK_LT(0U, bitmaps.size());
60 NOTIMPLEMENTED();
61 return CreateImageCursor(bitmaps[0], hotspot);
62 }
63
55 void BitmapCursorFactoryOzone::RefImageCursor(PlatformCursor cursor) { 64 void BitmapCursorFactoryOzone::RefImageCursor(PlatformCursor cursor) {
56 ToBitmapCursorOzone(cursor)->AddRef(); 65 ToBitmapCursorOzone(cursor)->AddRef();
57 } 66 }
58 67
59 void BitmapCursorFactoryOzone::UnrefImageCursor(PlatformCursor cursor) { 68 void BitmapCursorFactoryOzone::UnrefImageCursor(PlatformCursor cursor) {
60 ToBitmapCursorOzone(cursor)->Release(); 69 ToBitmapCursorOzone(cursor)->Release();
61 } 70 }
62 71
63 scoped_refptr<BitmapCursorOzone> 72 scoped_refptr<BitmapCursorOzone>
64 BitmapCursorFactoryOzone::GetDefaultCursorInternal(int type) { 73 BitmapCursorFactoryOzone::GetDefaultCursorInternal(int type) {
65 if (type == kCursorNone) 74 if (type == kCursorNone)
66 return NULL; // NULL is used for hidden cursor. 75 return NULL; // NULL is used for hidden cursor.
67 76
68 if (!default_cursors_.count(type)) { 77 if (!default_cursors_.count(type)) {
69 // Create new image cursor from default aura bitmap for this type. We hold a 78 // Create new image cursor from default aura bitmap for this type. We hold a
70 // ref forever because clients do not do refcounting for default cursors. 79 // ref forever because clients do not do refcounting for default cursors.
71 scoped_refptr<BitmapCursorOzone> cursor = CreateDefaultBitmapCursor(type); 80 scoped_refptr<BitmapCursorOzone> cursor = CreateDefaultBitmapCursor(type);
72 if (!cursor.get() && type != kCursorPointer) 81 if (!cursor.get() && type != kCursorPointer)
73 cursor = GetDefaultCursorInternal(kCursorPointer); 82 cursor = GetDefaultCursorInternal(kCursorPointer);
74 DCHECK(cursor.get()) << "Failed to load default cursor bitmap"; 83 DCHECK(cursor.get()) << "Failed to load default cursor bitmap";
75 default_cursors_[type] = cursor; 84 default_cursors_[type] = cursor;
76 } 85 }
77 86
78 // Returned owned default cursor for this type. 87 // Returned owned default cursor for this type.
79 return default_cursors_[type]; 88 return default_cursors_[type];
80 } 89 }
81 90
82 } // namespace ui 91 } // namespace ui
OLDNEW
« no previous file with comments | « ui/base/cursor/ozone/bitmap_cursor_factory_ozone.h ('k') | ui/ozone/public/cursor_factory_ozone.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698