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

Side by Side Diff: ui/base/cursor/cursors_aura.cc

Issue 2605773002: Fix Aura can't provide accurate cursor hotspot info. (Closed)
Patch Set: Created 3 years, 11 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 (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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/cursors_aura.h" 5 #include "ui/base/cursor/cursors_aura.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include "base/macros.h" 9 #include "base/macros.h"
10 #include "third_party/skia/include/core/SkBitmap.h" 10 #include "third_party/skia/include/core/SkBitmap.h"
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 int id, 168 int id,
169 float scale_factor, 169 float scale_factor,
170 int* resource_id, 170 int* resource_id,
171 gfx::Point* point) { 171 gfx::Point* point) {
172 bool resource_2x_available = 172 bool resource_2x_available =
173 ResourceBundle::GetSharedInstance().GetMaxScaleFactor() == 173 ResourceBundle::GetSharedInstance().GetMaxScaleFactor() ==
174 SCALE_FACTOR_200P; 174 SCALE_FACTOR_200P;
175 for (size_t i = 0; i < table_length; ++i) { 175 for (size_t i = 0; i < table_length; ++i) {
176 if (table[i].id == id) { 176 if (table[i].id == id) {
177 *resource_id = table[i].resource_id; 177 *resource_id = table[i].resource_id;
178 *point = scale_factor == 1.0f || !resource_2x_available ? 178 *point = scale_factor != 2.0f || !resource_2x_available
179 gfx::Point(table[i].hot_1x.x, table[i].hot_1x.y) : 179 ? gfx::Point(table[i].hot_1x.x, table[i].hot_1x.y)
180 gfx::Point(table[i].hot_2x.x, table[i].hot_2x.y); 180 : gfx::Point(table[i].hot_2x.x, table[i].hot_2x.y);
sadrul 2017/01/03 17:18:09 Why change this?
braveyao 2017/01/03 17:30:51 To make the 1x as the default, which I suppose cou
sadrul 2017/01/04 16:16:24 I think we prefer the 2x versions for other image
braveyao 2017/01/04 17:37:36 Done.
181 return true; 181 return true;
182 } 182 }
183 } 183 }
184 184
185 return false; 185 return false;
186 } 186 }
187 187
188 } // namespace 188 } // namespace
189 189
190 bool GetCursorDataFor(CursorSetType cursor_set_id, 190 bool GetCursorDataFor(CursorSetType cursor_set_id,
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
232 bool GetCursorBitmap(const Cursor& cursor, 232 bool GetCursorBitmap(const Cursor& cursor,
233 SkBitmap* bitmap, 233 SkBitmap* bitmap,
234 gfx::Point* point) { 234 gfx::Point* point) {
235 DCHECK(bitmap && point); 235 DCHECK(bitmap && point);
236 #if defined(OS_WIN) 236 #if defined(OS_WIN)
237 Cursor cursor_copy = cursor; 237 Cursor cursor_copy = cursor;
238 ui::CursorLoaderWin cursor_loader; 238 ui::CursorLoaderWin cursor_loader;
239 cursor_loader.SetPlatformCursor(&cursor_copy); 239 cursor_loader.SetPlatformCursor(&cursor_copy);
240 const std::unique_ptr<SkBitmap> cursor_bitmap( 240 const std::unique_ptr<SkBitmap> cursor_bitmap(
241 IconUtil::CreateSkBitmapFromHICON(cursor_copy.platform())); 241 IconUtil::CreateSkBitmapFromHICON(cursor_copy.platform()));
242 *point = IconUtil::GetHotSpotFromHICON(cursor_copy.platform());
242 #else 243 #else
243 int resource_id; 244 int resource_id;
244 if (!GetCursorDataFor(ui::CURSOR_SET_NORMAL, 245 if (!GetCursorDataFor(ui::CURSOR_SET_NORMAL,
245 cursor.native_type(), 246 cursor.native_type(),
246 cursor.device_scale_factor(), 247 cursor.device_scale_factor(),
247 &resource_id, 248 &resource_id,
248 point)) { 249 point)) {
249 return false; 250 return false;
250 } 251 }
251 252
252 const SkBitmap* cursor_bitmap = ResourceBundle::GetSharedInstance(). 253 const SkBitmap* cursor_bitmap = ResourceBundle::GetSharedInstance().
253 GetImageSkiaNamed(resource_id)->bitmap(); 254 GetImageSkiaNamed(resource_id)->bitmap();
254 #endif 255 #endif
255 if (!cursor_bitmap) 256 if (!cursor_bitmap)
256 return false; 257 return false;
257 *bitmap = *cursor_bitmap; 258 *bitmap = *cursor_bitmap;
258 return true; 259 return true;
259 } 260 }
260 261
261 } // namespace ui 262 } // namespace ui
OLDNEW
« no previous file with comments | « ui/base/cursor/cursor_loader_x11.cc ('k') | ui/gfx/icon_util.h » ('j') | ui/gfx/icon_util.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698