| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2009 Google Inc. All rights reserved. | 2 * Copyright (C) 2009 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 #define WebImage_h | 32 #define WebImage_h |
| 33 | 33 |
| 34 #include "WebCommon.h" | 34 #include "WebCommon.h" |
| 35 | 35 |
| 36 #if WEBKIT_USING_SKIA | 36 #if WEBKIT_USING_SKIA |
| 37 #include <SkBitmap.h> | 37 #include <SkBitmap.h> |
| 38 #elif WEBKIT_USING_CG | 38 #elif WEBKIT_USING_CG |
| 39 typedef struct CGImage* CGImageRef; | 39 typedef struct CGImage* CGImageRef; |
| 40 #endif | 40 #endif |
| 41 | 41 |
| 42 #if WEBKIT_IMPLEMENTATION |
| 43 namespace WebCore { class Image; } |
| 44 namespace WTF { template <typename T> class PassRefPtr; } |
| 45 #endif |
| 46 |
| 42 namespace WebKit { | 47 namespace WebKit { |
| 43 class WebData; | 48 class WebData; |
| 44 struct WebSize; | 49 struct WebSize; |
| 45 | 50 |
| 46 // A container for an ARGB bitmap. | 51 // A container for an ARGB bitmap. |
| 47 class WebImage { | 52 class WebImage { |
| 48 public: | 53 public: |
| 49 ~WebImage() { reset(); } | 54 ~WebImage() { reset(); } |
| 50 | 55 |
| 51 WebImage() { init(); } | 56 WebImage() { init(); } |
| 52 WebImage(const WebImage& image) { init(); assign(image); } | 57 WebImage(const WebImage& image) { init(); assign(image); } |
| 53 | 58 |
| 54 WebImage& operator=(const WebImage& image) | 59 WebImage& operator=(const WebImage& image) |
| 55 { | 60 { |
| 56 assign(image); | 61 assign(image); |
| 57 return *this; | 62 return *this; |
| 58 } | 63 } |
| 59 | 64 |
| 60 // Decodes the given image data. If the image has multiple frames, | 65 // Decodes the given image data. If the image has multiple frames, |
| 61 // then the frame whose size is desiredSize is returned. Otherwise, | 66 // then the frame whose size is desiredSize is returned. Otherwise, |
| 62 // the first frame is returned. | 67 // the first frame is returned. |
| 63 WEBKIT_API static WebImage fromData(const WebData&, const WebSize& desiredSize); | 68 WEBKIT_API static WebImage fromData(const WebData&, const WebSize& desiredSize); |
| 64 | 69 |
| 65 WEBKIT_API void reset(); | 70 WEBKIT_API void reset(); |
| 66 WEBKIT_API void assign(const WebImage&); | 71 WEBKIT_API void assign(const WebImage&); |
| 67 | 72 |
| 68 WEBKIT_API bool isNull() const; | 73 WEBKIT_API bool isNull() const; |
| 69 WEBKIT_API WebSize size() const; | 74 WEBKIT_API WebSize size() const; |
| 70 | 75 |
| 76 #if WEBKIT_IMPLEMENTATION |
| 77 WebImage(const WTF::PassRefPtr<WebCore::Image>&); |
| 78 WebImage& operator=(const WTF::PassRefPtr<WebCore::Image>&); |
| 79 #endif |
| 80 |
| 71 #if WEBKIT_USING_SKIA | 81 #if WEBKIT_USING_SKIA |
| 72 WebImage(const SkBitmap& bitmap) : m_bitmap(bitmap) { } | 82 WebImage(const SkBitmap& bitmap) : m_bitmap(bitmap) { } |
| 73 | 83 |
| 74 WebImage& operator=(const SkBitmap& bitmap) | 84 WebImage& operator=(const SkBitmap& bitmap) |
| 75 { | 85 { |
| 76 m_bitmap = bitmap; | 86 m_bitmap = bitmap; |
| 77 return *this; | 87 return *this; |
| 78 } | 88 } |
| 79 | 89 |
| 80 SkBitmap& getSkBitmap() { return m_bitmap; } | 90 SkBitmap& getSkBitmap() { return m_bitmap; } |
| (...skipping 17 matching lines...) Expand all Loading... |
| 98 private: | 108 private: |
| 99 void init() { m_imageRef = 0; } | 109 void init() { m_imageRef = 0; } |
| 100 void assign(CGImageRef); | 110 void assign(CGImageRef); |
| 101 CGImageRef m_imageRef; | 111 CGImageRef m_imageRef; |
| 102 #endif | 112 #endif |
| 103 }; | 113 }; |
| 104 | 114 |
| 105 } // namespace WebKit | 115 } // namespace WebKit |
| 106 | 116 |
| 107 #endif | 117 #endif |
| OLD | NEW |