summaryrefslogtreecommitdiffstats
path: root/webkit/api/public/WebImage.h
diff options
context:
space:
mode:
authordarin@google.com <darin@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-03 05:58:45 +0000
committerdarin@google.com <darin@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-03 05:58:45 +0000
commit8973f52efb98f531369f0b9daba397b1bf26d07b (patch)
tree297ec596fbaa2dc38af4c980d1a82b6dc49157ec /webkit/api/public/WebImage.h
parentc505de2b23a6a9b1c38d84cdc301dd6e2a71a9b4 (diff)
downloadchromium_src-8973f52efb98f531369f0b9daba397b1bf26d07b.zip
chromium_src-8973f52efb98f531369f0b9daba397b1bf26d07b.tar.gz
chromium_src-8973f52efb98f531369f0b9daba397b1bf26d07b.tar.bz2
Port WebImage to CG and rework the Skia version so that WebImage just has a
SkBitmap member (avoiding a level of indirection). This CL makes it so that Mac Chrome will now write bitmap data to the clipboard when requested by WebKit. I also simplified the ImageDecoder class that lives in glue. BUG=15648 TEST=none R=dglazkov Review URL: http://codereview.chromium.org/155010 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@19898 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/api/public/WebImage.h')
-rw-r--r--webkit/api/public/WebImage.h87
1 files changed, 34 insertions, 53 deletions
diff --git a/webkit/api/public/WebImage.h b/webkit/api/public/WebImage.h
index 5dd4d52..cef557b 100644
--- a/webkit/api/public/WebImage.h
+++ b/webkit/api/public/WebImage.h
@@ -1,10 +1,10 @@
/*
* Copyright (C) 2009 Google Inc. All rights reserved.
- *
+ *
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
- *
+ *
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
@@ -14,7 +14,7 @@
* * Neither the name of Google Inc. nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
- *
+ *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
@@ -32,24 +32,24 @@
#define WebImage_h
#include "WebCommon.h"
-#include "WebSize.h"
#if WEBKIT_USING_SKIA
-class SkBitmap;
+#include <SkBitmap.h>
+#elif WEBKIT_USING_CG
+typedef struct CGImage* CGImageRef;
#endif
namespace WebKit {
-
- class WebImagePixels;
- class WebImagePrivate;
+ class WebData;
+ struct WebSize;
// A container for an ARGB bitmap.
class WebImage {
public:
~WebImage() { reset(); }
- WebImage() : m_private(0) { }
- WebImage(const WebImage& image) : m_private(0) { assign(image); }
+ WebImage() { init(); }
+ WebImage(const WebImage& image) { init(); assign(image); }
WebImage& operator=(const WebImage& image)
{
@@ -57,70 +57,51 @@ namespace WebKit {
return *this;
}
+ // Decodes the given image data. If the image has multiple frames,
+ // then the frame whose size is desiredSize is returned. Otherwise,
+ // the first frame is returned.
+ WEBKIT_API static WebImage fromData(const WebData&, const WebSize& desiredSize);
+
WEBKIT_API void reset();
- WEBKIT_API WebSize size() const;
+ WEBKIT_API void assign(const WebImage&);
- WebImagePixels pixels() const;
- bool isNull() const { return m_private == 0; }
+ WEBKIT_API bool isNull() const;
+ WEBKIT_API WebSize size() const;
#if WEBKIT_USING_SKIA
- WebImage(const SkBitmap& bitmap) : m_private(0)
- {
- assign(bitmap);
- }
+ WebImage(const SkBitmap& bitmap) : m_bitmap(bitmap) { }
WebImage& operator=(const SkBitmap& bitmap)
{
- assign(bitmap);
+ m_bitmap = bitmap;
return *this;
}
- WEBKIT_API operator SkBitmap() const;
-#endif
+ SkBitmap& getSkBitmap() { return m_bitmap; }
+ const SkBitmap& getSkBitmap() const { return m_bitmap; }
private:
- friend class WebImagePixels;
-
- WEBKIT_API void assign(const WebImage&);
- WEBKIT_API const void* lockPixels();
- WEBKIT_API void unlockPixels();
+ void init() { }
+ SkBitmap m_bitmap;
-#if WEBKIT_USING_SKIA
- WEBKIT_API void assign(const SkBitmap&);
-#endif
+#elif WEBKIT_USING_CG
+ WebImage(CGImageRef imageRef) { init(); assign(imageRef); }
- WebImagePrivate* m_private;
- };
-
- class WebImagePixels {
- public:
- WebImagePixels(WebImage* image) : m_image(image)
- {
- m_data = m_image->lockPixels();
- }
-
- WebImagePixels(const WebImagePixels& other) : m_image(other.m_image)
+ WebImage& operator=(CGImageRef imageRef)
{
- m_data = m_image->lockPixels();
+ assign(imageRef);
+ return *this;
}
- ~WebImagePixels() { m_image->unlockPixels(); }
-
- const void* get() const { return m_data; }
- operator const void*() const { return m_data; }
+ CGImageRef getCGImageRef() const { return m_imageRef; }
private:
- WebImagePixels& operator=(const WebImagePixels&);
-
- WebImage* m_image;
- const void* m_data;
+ void init() { m_imageRef = 0; }
+ void assign(CGImageRef);
+ CGImageRef m_imageRef;
+#endif
};
- inline WebImagePixels WebImage::pixels() const
- {
- return WebImagePixels(const_cast<WebImage*>(this));
- }
-
} // namespace WebKit
#endif