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