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

Side by Side Diff: content/common/cursors/webcursor_aura.cc

Issue 1525263004: hidpi support for custom cursors in windows (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 5 years 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "content/common/cursors/webcursor.h" 5 #include "content/common/cursors/webcursor.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "third_party/WebKit/public/platform/WebCursorInfo.h" 8 #include "third_party/WebKit/public/platform/WebCursorInfo.h"
9 #include "ui/base/cursor/cursor.h" 9 #include "ui/base/cursor/cursor.h"
10 #include "ui/base/cursor/cursor_util.h"
10 11
11 using blink::WebCursorInfo; 12 using blink::WebCursorInfo;
12 13
13 namespace content { 14 namespace content {
14 15
15 gfx::NativeCursor WebCursor::GetNativeCursor() { 16 gfx::NativeCursor WebCursor::GetNativeCursor() {
16 switch (type_) { 17 switch (type_) {
17 case WebCursorInfo::TypePointer: 18 case WebCursorInfo::TypePointer:
18 return ui::kCursorPointer; 19 return ui::kCursorPointer;
19 case WebCursorInfo::TypeCross: 20 case WebCursorInfo::TypeCross:
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 ui::Cursor cursor(ui::kCursorCustom); 105 ui::Cursor cursor(ui::kCursorCustom);
105 cursor.SetPlatformCursor(GetPlatformCursor()); 106 cursor.SetPlatformCursor(GetPlatformCursor());
106 return cursor; 107 return cursor;
107 } 108 }
108 default: 109 default:
109 NOTREACHED(); 110 NOTREACHED();
110 return gfx::kNullCursor; 111 return gfx::kNullCursor;
111 } 112 }
112 } 113 }
113 114
115 float WebCursor::GetCursorScaleFactor() {
116 DCHECK(custom_scale_ != 0);
117 return device_scale_factor_ / custom_scale_;
118 }
119
120 void WebCursor::CreateScaledBitmapAndHotspotFromCustomData(
121 SkBitmap* bitmap,
122 gfx::Point* hotspot) {
123 DCHECK(custom_data_.size() > 0);
124 *hotspot = hotspot_;
125 bitmap->allocN32Pixels(custom_size_.width(), custom_size_.height());
126 memcpy(bitmap->getAddr32(0, 0), custom_data_.data(), custom_data_.size());
127 ui::ScaleAndRotateCursorBitmapAndHotpoint(
128 GetCursorScaleFactor(), gfx::Display::ROTATE_0, bitmap, hotspot);
129 }
130
131 // ozone has its own SetDisplayInfo that takes rotation into account
132 #if !defined(USE_OZONE)
133 void WebCursor::SetDisplayInfo(const gfx::Display& display) {
134 if (device_scale_factor_ == display.device_scale_factor())
135 return;
136
137 device_scale_factor_ = display.device_scale_factor();
138 CleanupPlatformData();
139 }
140 #endif
141
114 } // namespace content 142 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698