| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2006 Nikolas Zimmermann <zimmermann@kde.org> | 2 * Copyright (C) 2006 Nikolas Zimmermann <zimmermann@kde.org> |
| 3 * Copyright (C) 2007, 2008, 2009 Apple Inc. All rights reserved. | 3 * Copyright (C) 2007, 2008, 2009 Apple Inc. All rights reserved. |
| 4 * Copyright (C) 2010 Torch Mobile (Beijing) Co. Ltd. All rights reserved. | 4 * Copyright (C) 2010 Torch Mobile (Beijing) Co. Ltd. All rights reserved. |
| 5 * | 5 * |
| 6 * Redistribution and use in source and binary forms, with or without | 6 * Redistribution and use in source and binary forms, with or without |
| 7 * modification, are permitted provided that the following conditions | 7 * modification, are permitted provided that the following conditions |
| 8 * are met: | 8 * are met: |
| 9 * 1. Redistributions of source code must retain the above copyright | 9 * 1. Redistributions of source code must retain the above copyright |
| 10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 66 enum BackingStoreCopy { | 66 enum BackingStoreCopy { |
| 67 CopyBackingStore, // Guarantee subsequent draws don't affect the copy. | 67 CopyBackingStore, // Guarantee subsequent draws don't affect the copy. |
| 68 DontCopyBackingStore // Subsequent draws may affect the copy. | 68 DontCopyBackingStore // Subsequent draws may affect the copy. |
| 69 }; | 69 }; |
| 70 | 70 |
| 71 enum ScaleBehavior { | 71 enum ScaleBehavior { |
| 72 Scaled, | 72 Scaled, |
| 73 Unscaled | 73 Unscaled |
| 74 }; | 74 }; |
| 75 | 75 |
| 76 enum OpacityMode { |
| 77 NonOpaque, |
| 78 Opaque, |
| 79 }; |
| 80 |
| 76 class ImageBuffer { | 81 class ImageBuffer { |
| 77 WTF_MAKE_NONCOPYABLE(ImageBuffer); WTF_MAKE_FAST_ALLOCATED; | 82 WTF_MAKE_NONCOPYABLE(ImageBuffer); WTF_MAKE_FAST_ALLOCATED; |
| 78 public: | 83 public: |
| 79 // Will return a null pointer on allocation failure. | 84 // Will return a null pointer on allocation failure. |
| 80 static PassOwnPtr<ImageBuffer> create(const IntSize& size, float resolut
ionScale = 1, ColorSpace colorSpace = ColorSpaceDeviceRGB, RenderingMode renderi
ngMode = Unaccelerated) | 85 static PassOwnPtr<ImageBuffer> create(const IntSize& size, float resolut
ionScale = 1, ColorSpace colorSpace = ColorSpaceDeviceRGB, RenderingMode renderi
ngMode = Unaccelerated, OpacityMode opacityMode = NonOpaque) |
| 81 { | 86 { |
| 82 bool success = false; | 87 bool success = false; |
| 83 OwnPtr<ImageBuffer> buf = adoptPtr(new ImageBuffer(size, resolutionS
cale, colorSpace, renderingMode, success)); | 88 OwnPtr<ImageBuffer> buf = adoptPtr(new ImageBuffer(size, resolutionS
cale, colorSpace, renderingMode, opacityMode, success)); |
| 84 if (!success) | 89 if (!success) |
| 85 return nullptr; | 90 return nullptr; |
| 86 return buf.release(); | 91 return buf.release(); |
| 87 } | 92 } |
| 88 | 93 |
| 89 static PassOwnPtr<ImageBuffer> createCompatibleBuffer(const IntSize&, fl
oat resolutionScale, ColorSpace, const GraphicsContext*, bool hasAlpha); | 94 static PassOwnPtr<ImageBuffer> createCompatibleBuffer(const IntSize&, fl
oat resolutionScale, ColorSpace, const GraphicsContext*, bool hasAlpha); |
| 90 | 95 |
| 91 ~ImageBuffer(); | 96 ~ImageBuffer(); |
| 92 | 97 |
| 93 // The actual resolution of the backing store | 98 // The actual resolution of the backing store |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 137 | 142 |
| 138 private: | 143 private: |
| 139 ImageBufferData m_data; | 144 ImageBufferData m_data; |
| 140 IntSize m_size; | 145 IntSize m_size; |
| 141 IntSize m_logicalSize; | 146 IntSize m_logicalSize; |
| 142 float m_resolutionScale; | 147 float m_resolutionScale; |
| 143 OwnPtr<GraphicsContext> m_context; | 148 OwnPtr<GraphicsContext> m_context; |
| 144 | 149 |
| 145 // This constructor will place its success into the given out-variable | 150 // This constructor will place its success into the given out-variable |
| 146 // so that create() knows when it should return failure. | 151 // so that create() knows when it should return failure. |
| 147 ImageBuffer(const IntSize&, float resolutionScale, ColorSpace, Rendering
Mode, bool& success); | 152 ImageBuffer(const IntSize&, float resolutionScale, ColorSpace, Rendering
Mode, OpacityMode, bool& success); |
| 148 ImageBuffer(const IntSize&, float resolutionScale, ColorSpace, const Gra
phicsContext*, bool hasAlpha, bool& success); | 153 ImageBuffer(const IntSize&, float resolutionScale, ColorSpace, const Gra
phicsContext*, bool hasAlpha, bool& success); |
| 149 }; | 154 }; |
| 150 | 155 |
| 151 String ImageDataToDataURL(const ImageData&, const String& mimeType, const do
uble* quality); | 156 String ImageDataToDataURL(const ImageData&, const String& mimeType, const do
uble* quality); |
| 152 | 157 |
| 153 } // namespace WebCore | 158 } // namespace WebCore |
| 154 | 159 |
| 155 #endif // ImageBuffer_h | 160 #endif // ImageBuffer_h |
| OLD | NEW |