Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(111)

Side by Side Diff: Source/core/platform/graphics/ImageBuffer.h

Issue 19705006: Use SkImage as a backing store for copying 2d Contexts to ImageBitmaps. Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebase. Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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
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 private: 135 private:
134 bool isValid() const; 136 bool isValid() const;
137 void createAcceleratedCanvas(const IntSize&, OwnPtr<Canvas2DLayerBridge>*, O pacityMode);
138 void createNonPlatformCanvas(const IntSize&);
135 139
136 void draw(GraphicsContext*, const FloatRect&, const FloatRect& = FloatRect(0 , 0, -1, -1), CompositeOperator = CompositeSourceOver, BlendMode = BlendModeNorm al, bool useLowQualityScale = false); 140 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&, BlendMode); 141 void drawPattern(GraphicsContext*, const FloatRect&, const FloatSize&, const FloatPoint&, CompositeOperator, const FloatRect&, BlendMode);
138 142
139 friend class GraphicsContext; 143 friend class GraphicsContext;
140 friend class GeneratedImage; 144 friend class GeneratedImage;
141 friend class CrossfadeGeneratedImage; 145 friend class CrossfadeGeneratedImage;
142 friend class GeneratorGeneratedImage; 146 friend class GeneratorGeneratedImage;
143 147
144 IntSize m_size; 148 IntSize m_size;
145 IntSize m_logicalSize; 149 IntSize m_logicalSize;
146 float m_resolutionScale; 150 float m_resolutionScale;
147 OwnPtr<SkCanvas> m_canvas; 151 OwnPtr<SkCanvas> m_canvas;
152 OwnPtr<SkSurface> m_surface;
148 OwnPtr<GraphicsContext> m_context; 153 OwnPtr<GraphicsContext> m_context;
149 OwnPtr<Canvas2DLayerBridge> m_layerBridge; 154 OwnPtr<Canvas2DLayerBridge> m_layerBridge;
150 155
151 // This constructor will place its success into the given out-variable 156 // This constructor will place its success into the given out-variable
152 // so that create() knows when it should return failure. 157 // so that create() knows when it should return failure.
153 ImageBuffer(const IntSize&, float resolutionScale, RenderingMode, OpacityMod e, bool& success); 158 ImageBuffer(const IntSize&, float resolutionScale, RenderingMode, OpacityMod e, bool& success);
154 ImageBuffer(const IntSize&, float resolutionScale, const GraphicsContext*, b ool hasAlpha, bool& success); 159 ImageBuffer(const IntSize&, float resolutionScale, const GraphicsContext*, b ool hasAlpha, bool& success);
155 }; 160 };
156 161
157 String ImageDataToDataURL(const ImageData&, const String& mimeType, const double * quality); 162 String ImageDataToDataURL(const ImageData&, const String& mimeType, const double * quality);
158 163
159 } // namespace WebCore 164 } // namespace WebCore
160 165
161 #endif // ImageBuffer_h 166 #endif // ImageBuffer_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698