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 18 matching lines...) Expand all Loading... |
29 */ | 29 */ |
30 | 30 |
31 #include "config.h" | 31 #include "config.h" |
32 #include "WebImage.h" | 32 #include "WebImage.h" |
33 | 33 |
34 #include <CoreGraphics/CGImage.h> | 34 #include <CoreGraphics/CGImage.h> |
35 | 35 |
36 #include "WebData.h" | 36 #include "WebData.h" |
37 #include "WebSize.h" | 37 #include "WebSize.h" |
38 | 38 |
| 39 #include "Image.h" |
39 #include "ImageSource.h" | 40 #include "ImageSource.h" |
40 #include "SharedBuffer.h" | 41 #include "SharedBuffer.h" |
41 #include <wtf/PassRefPtr.h> | 42 #include <wtf/PassRefPtr.h> |
42 #include <wtf/RetainPtr.h> | 43 #include <wtf/RetainPtr.h> |
43 | 44 |
44 using namespace WebCore; | 45 using namespace WebCore; |
45 | 46 |
46 namespace WebKit { | 47 namespace WebKit { |
47 | 48 |
48 WebImage WebImage::fromData(const WebData& data, const WebSize& desiredSize) | 49 WebImage WebImage::fromData(const WebData& data, const WebSize& desiredSize) |
(...skipping 27 matching lines...) Expand all Loading... |
76 bool WebImage::isNull() const | 77 bool WebImage::isNull() const |
77 { | 78 { |
78 return m_imageRef != 0; | 79 return m_imageRef != 0; |
79 } | 80 } |
80 | 81 |
81 WebSize WebImage::size() const | 82 WebSize WebImage::size() const |
82 { | 83 { |
83 return WebSize(CGImageGetWidth(m_imageRef), CGImageGetHeight(m_imageRef)); | 84 return WebSize(CGImageGetWidth(m_imageRef), CGImageGetHeight(m_imageRef)); |
84 } | 85 } |
85 | 86 |
| 87 WebImage::WebImage(const PassRefPtr<Image>& image) |
| 88 : m_imageRef(0) |
| 89 { |
| 90 if (image.get()) |
| 91 assign(image->nativeImageForCurrentFrame()); |
| 92 } |
| 93 |
| 94 WebImage& WebImage::operator=(const PassRefPtr<Image>& image) |
| 95 { |
| 96 if (image.get()) |
| 97 assign(image->nativeImageForCurrentFrame()); |
| 98 else |
| 99 reset(); |
| 100 return *this; |
| 101 } |
| 102 |
86 void WebImage::assign(CGImageRef imageRef) | 103 void WebImage::assign(CGImageRef imageRef) |
87 { | 104 { |
88 CGImageRelease(m_imageRef); | 105 CGImageRelease(m_imageRef); |
89 CGImageRetain(m_imageRef = imageRef); | 106 CGImageRetain(m_imageRef = imageRef); |
90 } | 107 } |
91 | 108 |
92 } // namespace WebKit | 109 } // namespace WebKit |
OLD | NEW |