| 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 25 matching lines...) Expand all Loading... |
| 36 #include "core/platform/graphics/IntSize.h" | 36 #include "core/platform/graphics/IntSize.h" |
| 37 #include "core/platform/graphics/transforms/AffineTransform.h" | 37 #include "core/platform/graphics/transforms/AffineTransform.h" |
| 38 #include "wtf/Forward.h" | 38 #include "wtf/Forward.h" |
| 39 #include "wtf/OwnPtr.h" | 39 #include "wtf/OwnPtr.h" |
| 40 #include "wtf/PassOwnPtr.h" | 40 #include "wtf/PassOwnPtr.h" |
| 41 #include "wtf/PassRefPtr.h" | 41 #include "wtf/PassRefPtr.h" |
| 42 #include "wtf/Uint8ClampedArray.h" | 42 #include "wtf/Uint8ClampedArray.h" |
| 43 #include "wtf/Vector.h" | 43 #include "wtf/Vector.h" |
| 44 | 44 |
| 45 class SkCanvas; | 45 class SkCanvas; |
| 46 class SkImage; |
| 47 class SkSurface; |
| 46 | 48 |
| 47 namespace WebKit { class WebLayer; } | 49 namespace WebKit { class WebLayer; } |
| 48 | 50 |
| 49 namespace WebCore { | 51 namespace WebCore { |
| 50 | 52 |
| 51 class Canvas2DLayerBridge; | 53 class Canvas2DLayerBridge; |
| 52 class Image; | 54 class Image; |
| 53 class ImageData; | 55 class ImageData; |
| 54 class IntPoint; | 56 class IntPoint; |
| 55 class IntRect; | 57 class IntRect; |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 97 static PassOwnPtr<ImageBuffer> createCompatibleBuffer(const IntSize&, float
resolutionScale, const GraphicsContext*, bool hasAlpha); | 99 static PassOwnPtr<ImageBuffer> createCompatibleBuffer(const IntSize&, float
resolutionScale, const GraphicsContext*, bool hasAlpha); |
| 98 | 100 |
| 99 ~ImageBuffer(); | 101 ~ImageBuffer(); |
| 100 | 102 |
| 101 // The actual resolution of the backing store | 103 // The actual resolution of the backing store |
| 102 const IntSize& internalSize() const { return m_size; } | 104 const IntSize& internalSize() const { return m_size; } |
| 103 const IntSize& logicalSize() const { return m_logicalSize; } | 105 const IntSize& logicalSize() const { return m_logicalSize; } |
| 104 | 106 |
| 105 GraphicsContext* context() const; | 107 GraphicsContext* context() const; |
| 106 | 108 |
| 109 SkImage* imageSnapshot() const; |
| 107 PassRefPtr<Image> copyImage(BackingStoreCopy = CopyBackingStore, ScaleBehavi
or = Scaled) const; | 110 PassRefPtr<Image> copyImage(BackingStoreCopy = CopyBackingStore, ScaleBehavi
or = Scaled) const; |
| 108 // Give hints on the faster copyImage Mode, return DontCopyBackingStore if i
t supports the DontCopyBackingStore behavior | 111 // Give hints on the faster copyImage Mode, return DontCopyBackingStore if i
t supports the DontCopyBackingStore behavior |
| 109 // or return CopyBackingStore if it doesn't. | 112 // or return CopyBackingStore if it doesn't. |
| 110 static BackingStoreCopy fastCopyImageMode(); | 113 static BackingStoreCopy fastCopyImageMode(); |
| 111 | 114 |
| 112 enum CoordinateSystem { LogicalCoordinateSystem, BackingStoreCoordinateSyste
m }; | 115 enum CoordinateSystem { LogicalCoordinateSystem, BackingStoreCoordinateSyste
m }; |
| 113 | 116 |
| 114 PassRefPtr<Uint8ClampedArray> getUnmultipliedImageData(const IntRect&, Coord
inateSystem = LogicalCoordinateSystem) const; | 117 PassRefPtr<Uint8ClampedArray> getUnmultipliedImageData(const IntRect&, Coord
inateSystem = LogicalCoordinateSystem) const; |
| 115 PassRefPtr<Uint8ClampedArray> getPremultipliedImageData(const IntRect&, Coor
dinateSystem = LogicalCoordinateSystem) const; | 118 PassRefPtr<Uint8ClampedArray> getPremultipliedImageData(const IntRect&, Coor
dinateSystem = LogicalCoordinateSystem) const; |
| 116 | 119 |
| 117 void putByteArray(Multiply multiplied, Uint8ClampedArray*, const IntSize& so
urceSize, const IntRect& sourceRect, const IntPoint& destPoint, CoordinateSystem
= LogicalCoordinateSystem); | 120 void putByteArray(Multiply multiplied, Uint8ClampedArray*, const IntSize& so
urceSize, const IntRect& sourceRect, const IntPoint& destPoint, CoordinateSystem
= LogicalCoordinateSystem); |
| 118 | 121 |
| 119 void convertToLuminanceMask(); | 122 void convertToLuminanceMask(); |
| 120 | 123 |
| 121 String toDataURL(const String& mimeType, const double* quality = 0, Coordina
teSystem = LogicalCoordinateSystem) const; | 124 String toDataURL(const String& mimeType, const double* quality = 0, Coordina
teSystem = LogicalCoordinateSystem) const; |
| 122 AffineTransform baseTransform() const { return AffineTransform(); } | 125 AffineTransform baseTransform() const { return AffineTransform(); } |
| 123 void transformColorSpace(ColorSpace srcColorSpace, ColorSpace dstColorSpace)
; | 126 void transformColorSpace(ColorSpace srcColorSpace, ColorSpace dstColorSpace)
; |
| 124 static const Vector<uint8_t>& getLinearRgbLUT(); | 127 static const Vector<uint8_t>& getLinearRgbLUT(); |
| 125 static const Vector<uint8_t>& getDeviceRgbLUT(); | 128 static const Vector<uint8_t>& getDeviceRgbLUT(); |
| 126 WebKit::WebLayer* platformLayer() const; | 129 WebKit::WebLayer* platformLayer() const; |
| 127 | 130 |
| 128 // FIXME: current implementations of this method have the restriction that t
hey only work | 131 // FIXME: current implementations of this method have the restriction that t
hey only work |
| 129 // with textures that are RGB or RGBA format, UNSIGNED_BYTE type and level 0
, as specified in | 132 // with textures that are RGB or RGBA format, UNSIGNED_BYTE type and level 0
, as specified in |
| 130 // Extensions3D::canUseCopyTextureCHROMIUM(). | 133 // Extensions3D::canUseCopyTextureCHROMIUM(). |
| 131 bool copyToPlatformTexture(GraphicsContext3D&, Platform3DObject, GC3Denum, G
C3Denum, GC3Dint, bool, bool); | 134 bool copyToPlatformTexture(GraphicsContext3D&, Platform3DObject, GC3Denum, G
C3Denum, GC3Dint, bool, bool); |
| 132 | 135 |
| 133 void reportMemoryUsage(MemoryObjectInfo*) const; | 136 void reportMemoryUsage(MemoryObjectInfo*) const; |
| 134 | 137 |
| 135 private: | 138 private: |
| 139 SkCanvas* createAcceleratedCanvas(const IntSize&, OwnPtr<Canvas2DLayerBridge
>*, OpacityMode); |
| 140 SkCanvas* createNonPlatformCanvas(const IntSize&); |
| 141 |
| 136 void draw(GraphicsContext*, const FloatRect&, const FloatRect& = FloatRect(0
, 0, -1, -1), CompositeOperator = CompositeSourceOver, BlendMode = BlendModeNorm
al, bool useLowQualityScale = false); | 142 void draw(GraphicsContext*, const FloatRect&, const FloatRect& = FloatRect(0
, 0, -1, -1), CompositeOperator = CompositeSourceOver, BlendMode = BlendModeNorm
al, bool useLowQualityScale = false); |
| 137 void drawPattern(GraphicsContext*, const FloatRect&, const FloatSize&, const
FloatPoint&, CompositeOperator, const FloatRect&); | 143 void drawPattern(GraphicsContext*, const FloatRect&, const FloatSize&, const
FloatPoint&, CompositeOperator, const FloatRect&); |
| 138 | 144 |
| 139 friend class GraphicsContext; | 145 friend class GraphicsContext; |
| 140 friend class GeneratedImage; | 146 friend class GeneratedImage; |
| 141 friend class CrossfadeGeneratedImage; | 147 friend class CrossfadeGeneratedImage; |
| 142 friend class GeneratorGeneratedImage; | 148 friend class GeneratorGeneratedImage; |
| 143 | 149 |
| 144 IntSize m_size; | 150 IntSize m_size; |
| 145 IntSize m_logicalSize; | 151 IntSize m_logicalSize; |
| 146 float m_resolutionScale; | 152 float m_resolutionScale; |
| 147 OwnPtr<SkCanvas> m_canvas; | 153 OwnPtr<SkCanvas> m_canvas; |
| 154 RefPtr<SkSurface> m_surface; |
| 148 OwnPtr<GraphicsContext> m_context; | 155 OwnPtr<GraphicsContext> m_context; |
| 149 OwnPtr<Canvas2DLayerBridge> m_layerBridge; | 156 OwnPtr<Canvas2DLayerBridge> m_layerBridge; |
| 150 | 157 |
| 151 // This constructor will place its success into the given out-variable | 158 // This constructor will place its success into the given out-variable |
| 152 // so that create() knows when it should return failure. | 159 // so that create() knows when it should return failure. |
| 153 ImageBuffer(const IntSize&, float resolutionScale, RenderingMode, OpacityMod
e, bool& success); | 160 ImageBuffer(const IntSize&, float resolutionScale, RenderingMode, OpacityMod
e, bool& success); |
| 154 ImageBuffer(const IntSize&, float resolutionScale, const GraphicsContext*, b
ool hasAlpha, bool& success); | 161 ImageBuffer(const IntSize&, float resolutionScale, const GraphicsContext*, b
ool hasAlpha, bool& success); |
| 155 }; | 162 }; |
| 156 | 163 |
| 157 String ImageDataToDataURL(const ImageData&, const String& mimeType, const double
* quality); | 164 String ImageDataToDataURL(const ImageData&, const String& mimeType, const double
* quality); |
| 158 | 165 |
| 159 } // namespace WebCore | 166 } // namespace WebCore |
| 160 | 167 |
| 161 #endif // ImageBuffer_h | 168 #endif // ImageBuffer_h |
| OLD | NEW |