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

Side by Side Diff: content/common/cursors/webcursor.h

Issue 1525263004: hidpi support for custom cursors in windows (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fixed style issues and added more test cases 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 #ifndef CONTENT_COMMON_CURSORS_WEBCURSOR_H_ 5 #ifndef CONTENT_COMMON_CURSORS_WEBCURSOR_H_
6 #define CONTENT_COMMON_CURSORS_WEBCURSOR_H_ 6 #define CONTENT_COMMON_CURSORS_WEBCURSOR_H_
7 7
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 blink::WebCursorInfo::Type type; 64 blink::WebCursorInfo::Type type;
65 gfx::Point hotspot; 65 gfx::Point hotspot;
66 float image_scale_factor; 66 float image_scale_factor;
67 SkBitmap custom_image; 67 SkBitmap custom_image;
68 #if defined(OS_WIN) 68 #if defined(OS_WIN)
69 HCURSOR external_handle; 69 HCURSOR external_handle;
70 #endif 70 #endif
71 }; 71 };
72 72
73 WebCursor(); 73 WebCursor();
74 explicit WebCursor(const CursorInfo& cursor_info);
75 ~WebCursor(); 74 ~WebCursor();
76 75
77 // Copy constructor/assignment operator combine. 76 // Copy constructor/assignment operator combine.
78 WebCursor(const WebCursor& other); 77 WebCursor(const WebCursor& other);
79 const WebCursor& operator=(const WebCursor& other); 78 const WebCursor& operator=(const WebCursor& other);
80 79
81 // Conversion from/to CursorInfo. 80 // Conversion from/to CursorInfo.
82 void InitFromCursorInfo(const CursorInfo& cursor_info); 81 void InitFromCursorInfo(const CursorInfo& cursor_info);
83 void GetCursorInfo(CursorInfo* cursor_info) const; 82 void GetCursorInfo(CursorInfo* cursor_info) const;
84 83
(...skipping 19 matching lines...) Expand all
104 // APIs on it. 103 // APIs on it.
105 void InitFromExternalCursor(HCURSOR handle); 104 void InitFromExternalCursor(HCURSOR handle);
106 #endif 105 #endif
107 106
108 #if defined(USE_AURA) 107 #if defined(USE_AURA)
109 ui::PlatformCursor GetPlatformCursor(); 108 ui::PlatformCursor GetPlatformCursor();
110 109
111 // Updates |device_scale_factor_| and |rotation_| based on |display|. 110 // Updates |device_scale_factor_| and |rotation_| based on |display|.
112 void SetDisplayInfo(const gfx::Display& display); 111 void SetDisplayInfo(const gfx::Display& display);
113 112
113 float GetCursorScaleFactor();
114
115 void CreateScaledBitmapAndHotspotFromCustomData(
116 SkBitmap* bitmap,
117 gfx::Point* hotspot);
118
114 #elif defined(OS_WIN) 119 #elif defined(OS_WIN)
115 // Returns a HCURSOR representing the current WebCursor instance. 120 // Returns a HCURSOR representing the current WebCursor instance.
116 // The ownership of the HCURSOR (does not apply to external cursors) remains 121 // The ownership of the HCURSOR (does not apply to external cursors) remains
117 // with the WebCursor instance. 122 // with the WebCursor instance.
118 HCURSOR GetCursor(HINSTANCE module_handle); 123 HCURSOR GetCursor(HINSTANCE module_handle);
119 124
120 #elif defined(OS_MACOSX) 125 #elif defined(OS_MACOSX)
121 // Initialize this from the given Cocoa NSCursor. 126 // Initialize this from the given Cocoa NSCursor.
122 void InitFromNSCursor(NSCursor* cursor); 127 void InitFromNSCursor(NSCursor* cursor);
123 #endif 128 #endif
(...skipping 16 matching lines...) Expand all
140 // matches that of the cursor passed in. 145 // matches that of the cursor passed in.
141 bool IsPlatformDataEqual(const WebCursor& other) const ; 146 bool IsPlatformDataEqual(const WebCursor& other) const ;
142 147
143 // Copies platform specific data from the WebCursor instance passed in. 148 // Copies platform specific data from the WebCursor instance passed in.
144 void CopyPlatformData(const WebCursor& other); 149 void CopyPlatformData(const WebCursor& other);
145 150
146 // Platform specific cleanup. 151 // Platform specific cleanup.
147 void CleanupPlatformData(); 152 void CleanupPlatformData();
148 153
149 void SetCustomData(const SkBitmap& image); 154 void SetCustomData(const SkBitmap& image);
155
156 // Fills the custom_data vector and custom_size object with the image data
157 // taken from the bitmap.
158 void CreateCustomData(const SkBitmap& bitmap,
159 std::vector<char>* custom_data,
160 gfx::Size* custom_size);
161
150 void ImageFromCustomData(SkBitmap* image) const; 162 void ImageFromCustomData(SkBitmap* image) const;
151 163
152 // Clamp the hotspot to the custom image's bounds, if this is a custom cursor. 164 // Clamp the hotspot to the custom image's bounds, if this is a custom cursor.
153 void ClampHotspot(); 165 void ClampHotspot();
154 166
155 // WebCore::PlatformCursor type. 167 // WebCore::PlatformCursor type.
156 int type_; 168 int type_;
157 169
158 // Hotspot in cursor image in pixels. 170 // Hotspot in cursor image in pixels.
159 gfx::Point hotspot_; 171 gfx::Point hotspot_;
160 172
161 // Custom cursor data, as 32-bit RGBA. 173 // Custom cursor data, as 32-bit RGBA.
162 // Platform-inspecific because it can be serialized. 174 // Platform-inspecific because it can be serialized.
163 gfx::Size custom_size_; // In pixels. 175 gfx::Size custom_size_; // In pixels.
164 float custom_scale_; 176 float custom_scale_;
165 std::vector<char> custom_data_; 177 std::vector<char> custom_data_;
166 178
167 #if defined(OS_WIN) 179 #if defined(OS_WIN)
168 // An externally generated HCURSOR. We assume that it remains valid, i.e we 180 // An externally generated HCURSOR. We assume that it remains valid, i.e we
169 // don't attempt to copy the HCURSOR. 181 // don't attempt to copy the HCURSOR.
170 HCURSOR external_cursor_; 182 HCURSOR external_cursor_;
171 #endif 183 #endif
172 184
173 #if defined(USE_AURA) && (defined(USE_X11) || defined(USE_OZONE)) 185 #if defined(USE_AURA) && (defined(USE_X11) || defined(USE_OZONE))
174 // Only used for custom cursors. 186 // Only used for custom cursors.
175 ui::PlatformCursor platform_cursor_; 187 ui::PlatformCursor platform_cursor_;
176 float device_scale_factor_;
177 #elif defined(OS_WIN) 188 #elif defined(OS_WIN)
178 // A custom cursor created from custom bitmap data by Webkit. 189 // A custom cursor created from custom bitmap data by Webkit.
179 HCURSOR custom_cursor_; 190 HCURSOR custom_cursor_;
180 #endif 191 #endif
192 #if defined(USE_AURA)
193 float device_scale_factor_;
ananta 2015/12/16 20:47:54 Please initialize this in the ctor
Bret 2015/12/16 22:27:51 Done.
194 #endif
181 195
182 #if defined(USE_OZONE) 196 #if defined(USE_OZONE)
183 gfx::Display::Rotation rotation_; 197 gfx::Display::Rotation rotation_;
184 #endif 198 #endif
185 }; 199 };
186 200
187 } // namespace content 201 } // namespace content
188 202
189 #endif // CONTENT_COMMON_CURSORS_WEBCURSOR_H_ 203 #endif // CONTENT_COMMON_CURSORS_WEBCURSOR_H_
OLDNEW
« no previous file with comments | « no previous file | content/common/cursors/webcursor.cc » ('j') | content/common/cursors/webcursor_unittest.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698