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

Side by Side Diff: webkit/glue/webcursor_aurax11.cc

Issue 15971005: Move the WebCursor sources from webkit/glue to webkit/common/cursors. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 7 years, 6 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 | Annotate | Revision Log
« no previous file with comments | « webkit/glue/webcursor_aurawin.cc ('k') | webkit/glue/webcursor_gtk.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "webkit/glue/webcursor.h"
6
7 #include <X11/Xcursor/Xcursor.h>
8 #include <X11/Xlib.h>
9 #include <X11/cursorfont.h>
10
11 #include "base/logging.h"
12 #include "skia/ext/image_operations.h"
13 #include "third_party/WebKit/Source/WebKit/chromium/public/WebCursorInfo.h"
14 #include "ui/base/cursor/cursor.h"
15 #include "ui/base/x/x11_util.h"
16 #include "ui/gfx/point_conversions.h"
17 #include "ui/gfx/size_conversions.h"
18
19 const ui::PlatformCursor WebCursor::GetPlatformCursor() {
20 if (platform_cursor_)
21 return platform_cursor_;
22
23 if (custom_data_.size() == 0)
24 return 0;
25
26 SkBitmap bitmap;
27 bitmap.setConfig(SkBitmap::kARGB_8888_Config,
28 custom_size_.width(), custom_size_.height());
29 bitmap.allocPixels();
30 memcpy(bitmap.getAddr32(0, 0), custom_data_.data(), custom_data_.size());
31
32 gfx::Point hotspot = hotspot_;
33 if (device_scale_factor_ != custom_scale_) {
34 float scale = device_scale_factor_ / custom_scale_;
35 gfx::Size scaled_size =
36 gfx::ToFlooredSize(gfx::ScaleSize(custom_size_, scale));
37 bitmap = skia::ImageOperations::Resize(bitmap,
38 skia::ImageOperations::RESIZE_BETTER,
39 scaled_size.width(),
40 scaled_size.height());
41 hotspot = gfx::ToFlooredPoint(gfx::ScalePoint(hotspot, scale));
42 }
43
44 XcursorImage* image = ui::SkBitmapToXcursorImage(&bitmap, hotspot);
45 platform_cursor_ = ui::CreateReffedCustomXCursor(image);
46 return platform_cursor_;
47 }
48
49 void WebCursor::SetDeviceScaleFactor(float scale_factor) {
50 if (device_scale_factor_ == scale_factor)
51 return;
52
53 device_scale_factor_ = scale_factor;
54 if (platform_cursor_)
55 ui::UnrefCustomXCursor(platform_cursor_);
56 platform_cursor_ = 0;
57 // It is not necessary to recreate platform_cursor_ yet, since it will be
58 // recreated on demand when GetPlatformCursor is called.
59 }
60
61 void WebCursor::InitPlatformData() {
62 platform_cursor_ = 0;
63 device_scale_factor_ = 1.f;
64 }
65
66 bool WebCursor::SerializePlatformData(Pickle* pickle) const {
67 return true;
68 }
69
70 bool WebCursor::DeserializePlatformData(PickleIterator* iter) {
71 return true;
72 }
73
74 bool WebCursor::IsPlatformDataEqual(const WebCursor& other) const {
75 return true;
76 }
77
78 void WebCursor::CleanupPlatformData() {
79 if (platform_cursor_) {
80 ui::UnrefCustomXCursor(platform_cursor_);
81 platform_cursor_ = 0;
82 }
83 }
84
85 void WebCursor::CopyPlatformData(const WebCursor& other) {
86 if (platform_cursor_)
87 ui::UnrefCustomXCursor(platform_cursor_);
88 platform_cursor_ = other.platform_cursor_;
89 if (platform_cursor_)
90 ui::RefCustomXCursor(platform_cursor_);
91
92 device_scale_factor_ = other.device_scale_factor_;
93 }
OLDNEW
« no previous file with comments | « webkit/glue/webcursor_aurawin.cc ('k') | webkit/glue/webcursor_gtk.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698