summaryrefslogtreecommitdiffstats
path: root/webkit/glue/webcursor.cc
diff options
context:
space:
mode:
authormark@chromium.org <mark@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2008-10-23 21:57:51 +0000
committermark@chromium.org <mark@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2008-10-23 21:57:51 +0000
commit67b2505a94d723c7f6fb7814aefc677540d4fc7e (patch)
treeefb20ec239ad1f7686e06866931bb5436b5faf81 /webkit/glue/webcursor.cc
parent0c3abea91971ae0e2289da9c43ad359b716dd3aa (diff)
downloadchromium_src-67b2505a94d723c7f6fb7814aefc677540d4fc7e.zip
chromium_src-67b2505a94d723c7f6fb7814aefc677540d4fc7e.tar.gz
chromium_src-67b2505a94d723c7f6fb7814aefc677540d4fc7e.tar.bz2
Let cursors be based on CGImage instead of SkBitmap on the Mac
Review URL: http://codereview.chromium.org/8111 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@3869 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/glue/webcursor.cc')
-rw-r--r--webkit/glue/webcursor.cc34
1 files changed, 25 insertions, 9 deletions
diff --git a/webkit/glue/webcursor.cc b/webkit/glue/webcursor.cc
index 52496a4..80a5e8b 100644
--- a/webkit/glue/webcursor.cc
+++ b/webkit/glue/webcursor.cc
@@ -12,18 +12,20 @@
WebCursor::WebCursor()
: type_(ARROW),
hotspot_x_(0),
- hotspot_y_(0) {
- memset(&bitmap_, 0, sizeof(bitmap_));
+ hotspot_y_(0),
+ bitmap_() {
}
WebCursor::WebCursor(Type cursor_type)
: type_(cursor_type),
hotspot_x_(0),
- hotspot_y_(0) {
- memset(&bitmap_, 0, sizeof(bitmap_));
+ hotspot_y_(0),
+ bitmap_() {
}
-WebCursor::WebCursor(const SkBitmap* bitmap, int hotspot_x, int hotspot_y)
+WebCursor::WebCursor(const WebCursorBitmapPtr bitmap,
+ int hotspot_x,
+ int hotspot_y)
: type_(ARROW),
hotspot_x_(0),
hotspot_y_(0) {
@@ -31,20 +33,31 @@ WebCursor::WebCursor(const SkBitmap* bitmap, int hotspot_x, int hotspot_y)
type_ = CUSTOM;
hotspot_x_ = hotspot_x;
hotspot_y_ = hotspot_y;
+#if defined(OS_MACOSX)
+ CGImageRetain(bitmap_ = bitmap);
+#else
bitmap_ = *bitmap;
+#endif
} else {
+#if defined(OS_MACOSX)
+ bitmap_ = NULL;
+#else
memset(&bitmap_, 0, sizeof(bitmap_));
+#endif
}
}
WebCursor::~WebCursor() {
+#if defined(OS_MACOSX)
+ CGImageRelease(bitmap_);
+#endif
}
WebCursor::WebCursor(const WebCursor& other) {
type_ = other.type_;
hotspot_x_ = other.hotspot_x_;
hotspot_y_ = other.hotspot_y_;
- bitmap_ = other.bitmap_;
+ set_bitmap(other.bitmap_);
}
WebCursor& WebCursor::operator=(const WebCursor& other) {
@@ -52,10 +65,11 @@ WebCursor& WebCursor::operator=(const WebCursor& other) {
type_ = other.type_;
hotspot_x_ = other.hotspot_x_;
hotspot_y_ = other.hotspot_y_;
- bitmap_ = other.bitmap_;
+ set_bitmap(other.bitmap_);
}
return *this;
}
+
#if defined(OS_WIN)
HCURSOR WebCursor::GetCursor(HINSTANCE module_handle) const {
if (type_ == CUSTOM)
@@ -136,7 +150,9 @@ HCURSOR WebCursor::GetCustomCursor() const {
return cursor_handle;
}
#endif
-bool WebCursor::IsSameBitmap(const SkBitmap& bitmap) const {
+
+#if !defined(OS_MACOSX)
+bool WebCursor::IsSameBitmap(const WebCursorBitmap& bitmap) const {
SkAutoLockPixels new_bitmap_lock(bitmap);
SkAutoLockPixels bitmap_lock(bitmap_);
return (memcmp(bitmap_.getPixels(), bitmap.getPixels(),
@@ -151,4 +167,4 @@ bool WebCursor::IsEqual(const WebCursor& other) const {
return IsSameBitmap(other.bitmap_);
return true;
}
-
+#endif