| 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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 55 enum Multiply { | 55 enum Multiply { |
| 56 Premultiplied, | 56 Premultiplied, |
| 57 Unmultiplied | 57 Unmultiplied |
| 58 }; | 58 }; |
| 59 | 59 |
| 60 enum RenderingMode { | 60 enum RenderingMode { |
| 61 Unaccelerated, | 61 Unaccelerated, |
| 62 UnacceleratedNonPlatformBuffer, // Use plain memory allocation rather th
an platform API to allocate backing store. | 62 UnacceleratedNonPlatformBuffer, // Use plain memory allocation rather th
an platform API to allocate backing store. |
| 63 Accelerated | 63 Accelerated |
| 64 }; | 64 }; |
| 65 | 65 |
| 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 { | 76 enum OpacityMode { |
| 77 NonOpaque, | 77 NonOpaque, |
| 78 Opaque, | 78 Opaque, |
| 79 }; | 79 }; |
| 80 | 80 |
| 81 class ImageBuffer { | 81 class ImageBuffer { |
| 82 WTF_MAKE_NONCOPYABLE(ImageBuffer); WTF_MAKE_FAST_ALLOCATED; | 82 WTF_MAKE_NONCOPYABLE(ImageBuffer); WTF_MAKE_FAST_ALLOCATED; |
| 83 public: | 83 public: |
| 84 // Will return a null pointer on allocation failure. | 84 // Will return a null pointer on allocation failure. |
| 85 static PassOwnPtr<ImageBuffer> create(const IntSize& size, float resolut
ionScale = 1, ColorSpace colorSpace = ColorSpaceDeviceRGB, RenderingMode renderi
ngMode = Unaccelerated, OpacityMode opacityMode = NonOpaque) | 85 static PassOwnPtr<ImageBuffer> create(const IntSize& size, float resolut
ionScale = 1, RenderingMode renderingMode = Unaccelerated, OpacityMode opacityMo
de = NonOpaque) |
| 86 { | 86 { |
| 87 bool success = false; | 87 bool success = false; |
| 88 OwnPtr<ImageBuffer> buf = adoptPtr(new ImageBuffer(size, resolutionS
cale, colorSpace, renderingMode, opacityMode, success)); | 88 OwnPtr<ImageBuffer> buf = adoptPtr(new ImageBuffer(size, resolutionS
cale, renderingMode, opacityMode, success)); |
| 89 if (!success) | 89 if (!success) |
| 90 return nullptr; | 90 return nullptr; |
| 91 return buf.release(); | 91 return buf.release(); |
| 92 } | 92 } |
| 93 | 93 |
| 94 static PassOwnPtr<ImageBuffer> createCompatibleBuffer(const IntSize&, fl
oat resolutionScale, ColorSpace, const GraphicsContext*, bool hasAlpha); | 94 static PassOwnPtr<ImageBuffer> createCompatibleBuffer(const IntSize&, fl
oat resolutionScale, const GraphicsContext*, bool hasAlpha); |
| 95 | 95 |
| 96 ~ImageBuffer(); | 96 ~ImageBuffer(); |
| 97 | 97 |
| 98 // The actual resolution of the backing store | 98 // The actual resolution of the backing store |
| 99 const IntSize& internalSize() const { return m_size; } | 99 const IntSize& internalSize() const { return m_size; } |
| 100 const IntSize& logicalSize() const { return m_logicalSize; } | 100 const IntSize& logicalSize() const { return m_logicalSize; } |
| 101 | 101 |
| 102 GraphicsContext* context() const; | 102 GraphicsContext* context() const; |
| 103 | 103 |
| 104 PassRefPtr<Image> copyImage(BackingStoreCopy = CopyBackingStore, ScaleBe
havior = Scaled) const; | 104 PassRefPtr<Image> copyImage(BackingStoreCopy = CopyBackingStore, ScaleBe
havior = Scaled) const; |
| (...skipping 19 matching lines...) Expand all Loading... |
| 124 // FIXME: current implementations of this method have the restriction th
at they only work | 124 // FIXME: current implementations of this method have the restriction th
at they only work |
| 125 // with textures that are RGB or RGBA format, UNSIGNED_BYTE type and lev
el 0, as specified in | 125 // with textures that are RGB or RGBA format, UNSIGNED_BYTE type and lev
el 0, as specified in |
| 126 // Extensions3D::canUseCopyTextureCHROMIUM(). | 126 // Extensions3D::canUseCopyTextureCHROMIUM(). |
| 127 bool copyToPlatformTexture(GraphicsContext3D&, Platform3DObject, GC3Denu
m, GC3Denum, GC3Dint, bool, bool); | 127 bool copyToPlatformTexture(GraphicsContext3D&, Platform3DObject, GC3Denu
m, GC3Denum, GC3Dint, bool, bool); |
| 128 | 128 |
| 129 void reportMemoryUsage(MemoryObjectInfo*) const; | 129 void reportMemoryUsage(MemoryObjectInfo*) const; |
| 130 | 130 |
| 131 private: | 131 private: |
| 132 void clip(GraphicsContext*, const FloatRect&) const; | 132 void clip(GraphicsContext*, const FloatRect&) const; |
| 133 | 133 |
| 134 void draw(GraphicsContext*, ColorSpace, const FloatRect& destRect, const
FloatRect& srcRect = FloatRect(0, 0, -1, -1), CompositeOperator = CompositeSour
ceOver, BlendMode = BlendModeNormal, bool useLowQualityScale = false); | 134 void draw(GraphicsContext*, const FloatRect& destRect, const FloatRect&
srcRect = FloatRect(0, 0, -1, -1), CompositeOperator = CompositeSourceOver, Blen
dMode = BlendModeNormal, bool useLowQualityScale = false); |
| 135 void drawPattern(GraphicsContext*, const FloatRect& srcRect, const Affin
eTransform& patternTransform, const FloatPoint& phase, ColorSpace styleColorSpac
e, CompositeOperator, const FloatRect& destRect); | 135 void drawPattern(GraphicsContext*, const FloatRect& srcRect, const Affin
eTransform& patternTransform, const FloatPoint& phase, CompositeOperator, const
FloatRect& destRect); |
| 136 | 136 |
| 137 inline void genericConvertToLuminanceMask(); | 137 inline void genericConvertToLuminanceMask(); |
| 138 | 138 |
| 139 friend class GraphicsContext; | 139 friend class GraphicsContext; |
| 140 friend class GeneratedImage; | 140 friend class GeneratedImage; |
| 141 friend class CrossfadeGeneratedImage; | 141 friend class CrossfadeGeneratedImage; |
| 142 friend class GeneratorGeneratedImage; | 142 friend class GeneratorGeneratedImage; |
| 143 | 143 |
| 144 private: | 144 private: |
| 145 ImageBufferData m_data; | 145 ImageBufferData m_data; |
| 146 IntSize m_size; | 146 IntSize m_size; |
| 147 IntSize m_logicalSize; | 147 IntSize m_logicalSize; |
| 148 float m_resolutionScale; | 148 float m_resolutionScale; |
| 149 OwnPtr<GraphicsContext> m_context; | 149 OwnPtr<GraphicsContext> m_context; |
| 150 | 150 |
| 151 // This constructor will place its success into the given out-variable | 151 // This constructor will place its success into the given out-variable |
| 152 // so that create() knows when it should return failure. | 152 // so that create() knows when it should return failure. |
| 153 ImageBuffer(const IntSize&, float resolutionScale, ColorSpace, Rendering
Mode, OpacityMode, bool& success); | 153 ImageBuffer(const IntSize&, float resolutionScale, RenderingMode, Opacit
yMode, bool& success); |
| 154 ImageBuffer(const IntSize&, float resolutionScale, ColorSpace, const Gra
phicsContext*, bool hasAlpha, bool& success); | 154 ImageBuffer(const IntSize&, float resolutionScale, const GraphicsContext
*, bool hasAlpha, bool& success); |
| 155 }; | 155 }; |
| 156 | 156 |
| 157 String ImageDataToDataURL(const ImageData&, const String& mimeType, const do
uble* quality); | 157 String ImageDataToDataURL(const ImageData&, const String& mimeType, const do
uble* quality); |
| 158 | 158 |
| 159 } // namespace WebCore | 159 } // namespace WebCore |
| 160 | 160 |
| 161 #endif // ImageBuffer_h | 161 #endif // ImageBuffer_h |
| OLD | NEW |