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

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 return device_scale_factor_ / custom_scale_;
ananta 2015/12/15 23:28:17 do we need a dcheck for custom_scale_ == 0?
Bret 2015/12/16 19:03:59 Done.
117 }
118
119 void WebCursor::CreateScaledBitmapAndHotspotFromCustomData(
120 SkBitmap* bitmap,
121 gfx::Point* hotspot) {
122 *hotspot = hotspot_;
123 bitmap->allocN32Pixels(custom_size_.width(), custom_size_.height());
124 memcpy(bitmap->getAddr32(0, 0), custom_data_.data(), custom_data_.size());
125 ui::ScaleAndRotateCursorBitmapAndHotpoint(
126 GetCursorScaleFactor(), gfx::Display::ROTATE_0, bitmap, hotspot);
127 }
128
129 void WebCursor::SetDisplayInfo(const gfx::Display& display) {
130 if (device_scale_factor_ == display.device_scale_factor())
131 return;
132
133 device_scale_factor_ = display.device_scale_factor();
134 CleanupPlatformData();
135 }
136
114 } // namespace content 137 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698