| 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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 48 class SkCanvas; | 48 class SkCanvas; |
| 49 | 49 |
| 50 namespace blink { | 50 namespace blink { |
| 51 class WebGraphicsContext3D; | 51 class WebGraphicsContext3D; |
| 52 } | 52 } |
| 53 | 53 |
| 54 namespace WebCore { | 54 namespace WebCore { |
| 55 | 55 |
| 56 class DrawingBuffer; | 56 class DrawingBuffer; |
| 57 class Image; | 57 class Image; |
| 58 class ImageBufferClient; |
| 58 class IntPoint; | 59 class IntPoint; |
| 59 class IntRect; | 60 class IntRect; |
| 60 | 61 |
| 61 enum Multiply { | 62 enum Multiply { |
| 62 Premultiplied, | 63 Premultiplied, |
| 63 Unmultiplied | 64 Unmultiplied |
| 64 }; | 65 }; |
| 65 | 66 |
| 66 enum BackingStoreCopy { | 67 enum BackingStoreCopy { |
| 67 CopyBackingStore, // Guarantee subsequent draws don't affect the copy. | 68 CopyBackingStore, // Guarantee subsequent draws don't affect the copy. |
| 68 DontCopyBackingStore // Subsequent draws may affect the copy. | 69 DontCopyBackingStore // Subsequent draws may affect the copy. |
| 69 }; | 70 }; |
| 70 | 71 |
| 71 enum ScaleBehavior { | 72 enum ScaleBehavior { |
| 72 Scaled, | 73 Scaled, |
| 73 Unscaled | 74 Unscaled |
| 74 }; | 75 }; |
| 75 | 76 |
| 76 class PLATFORM_EXPORT ImageBuffer { | 77 class PLATFORM_EXPORT ImageBuffer { |
| 77 WTF_MAKE_NONCOPYABLE(ImageBuffer); WTF_MAKE_FAST_ALLOCATED; | 78 WTF_MAKE_NONCOPYABLE(ImageBuffer); WTF_MAKE_FAST_ALLOCATED; |
| 78 public: | 79 public: |
| 79 static PassOwnPtr<ImageBuffer> create(const IntSize&, OpacityMode = NonOpaqu
e); | 80 static PassOwnPtr<ImageBuffer> create(const IntSize&, OpacityMode = NonOpaqu
e); |
| 80 static PassOwnPtr<ImageBuffer> create(PassOwnPtr<ImageBufferSurface>); | 81 static PassOwnPtr<ImageBuffer> create(PassOwnPtr<ImageBufferSurface>); |
| 81 | 82 |
| 82 ~ImageBuffer(); | 83 ~ImageBuffer(); |
| 83 | 84 |
| 85 void setClient(ImageBufferClient* client) { m_client = client; } |
| 86 |
| 84 const IntSize& size() const { return m_surface->size(); } | 87 const IntSize& size() const { return m_surface->size(); } |
| 85 bool isAccelerated() const { return m_surface->isAccelerated(); } | 88 bool isAccelerated() const { return m_surface->isAccelerated(); } |
| 89 bool isSurfaceValid() const; |
| 90 bool restoreSurface() const; |
| 86 | 91 |
| 87 void setIsHidden(bool hidden) { m_surface->setIsHidden(hidden); } | 92 void setIsHidden(bool hidden) { m_surface->setIsHidden(hidden); } |
| 88 | 93 |
| 89 GraphicsContext* context() const; | 94 GraphicsContext* context() const; |
| 90 | 95 |
| 91 const SkBitmap& bitmap() const; | 96 const SkBitmap& bitmap() const; |
| 92 | 97 |
| 93 PassRefPtr<Image> copyImage(BackingStoreCopy = CopyBackingStore, ScaleBehavi
or = Scaled) const; | 98 PassRefPtr<Image> copyImage(BackingStoreCopy = CopyBackingStore, ScaleBehavi
or = Scaled) const; |
| 94 // Give hints on the faster copyImage Mode, return DontCopyBackingStore if i
t supports the DontCopyBackingStore behavior | 99 // Give hints on the faster copyImage Mode, return DontCopyBackingStore if i
t supports the DontCopyBackingStore behavior |
| 95 // or return CopyBackingStore if it doesn't. | 100 // or return CopyBackingStore if it doesn't. |
| (...skipping 14 matching lines...) Expand all Loading... |
| 110 // Extensions3D::canUseCopyTextureCHROMIUM(). | 115 // Extensions3D::canUseCopyTextureCHROMIUM(). |
| 111 // Destroys the TEXTURE_2D binding for the active texture unit of the passed
context | 116 // Destroys the TEXTURE_2D binding for the active texture unit of the passed
context |
| 112 bool copyToPlatformTexture(blink::WebGraphicsContext3D*, Platform3DObject, G
Lenum, GLenum, GLint, bool, bool); | 117 bool copyToPlatformTexture(blink::WebGraphicsContext3D*, Platform3DObject, G
Lenum, GLenum, GLint, bool, bool); |
| 113 | 118 |
| 114 Platform3DObject getBackingTexture(); | 119 Platform3DObject getBackingTexture(); |
| 115 | 120 |
| 116 bool copyRenderingResultsFromDrawingBuffer(DrawingBuffer*); | 121 bool copyRenderingResultsFromDrawingBuffer(DrawingBuffer*); |
| 117 | 122 |
| 118 void flush(); | 123 void flush(); |
| 119 | 124 |
| 125 void notifySurfaceInvalid(); |
| 126 |
| 120 private: | 127 private: |
| 121 ImageBuffer(PassOwnPtr<ImageBufferSurface>); | 128 ImageBuffer(PassOwnPtr<ImageBufferSurface>); |
| 122 bool isValid() const; | |
| 123 | 129 |
| 124 void draw(GraphicsContext*, const FloatRect&, const FloatRect& = FloatRect(0
, 0, -1, -1), CompositeOperator = CompositeSourceOver, blink::WebBlendMode = bli
nk::WebBlendModeNormal); | 130 void draw(GraphicsContext*, const FloatRect&, const FloatRect& = FloatRect(0
, 0, -1, -1), CompositeOperator = CompositeSourceOver, blink::WebBlendMode = bli
nk::WebBlendModeNormal); |
| 125 void drawPattern(GraphicsContext*, const FloatRect&, const FloatSize&, const
FloatPoint&, CompositeOperator, const FloatRect&, blink::WebBlendMode, const In
tSize& repeatSpacing = IntSize()); | 131 void drawPattern(GraphicsContext*, const FloatRect&, const FloatSize&, const
FloatPoint&, CompositeOperator, const FloatRect&, blink::WebBlendMode, const In
tSize& repeatSpacing = IntSize()); |
| 126 static PassRefPtr<SkColorFilter> createColorSpaceFilter(ColorSpace srcColorS
pace, ColorSpace dstColorSpace); | 132 static PassRefPtr<SkColorFilter> createColorSpaceFilter(ColorSpace srcColorS
pace, ColorSpace dstColorSpace); |
| 127 | 133 |
| 128 friend class GraphicsContext; | 134 friend class GraphicsContext; |
| 129 friend class GeneratedImage; | 135 friend class GeneratedImage; |
| 130 friend class CrossfadeGeneratedImage; | 136 friend class CrossfadeGeneratedImage; |
| 131 friend class GradientGeneratedImage; | 137 friend class GradientGeneratedImage; |
| 132 friend class SkiaImageFilterBuilder; | 138 friend class SkiaImageFilterBuilder; |
| 133 | 139 |
| 134 OwnPtr<ImageBufferSurface> m_surface; | 140 OwnPtr<ImageBufferSurface> m_surface; |
| 135 OwnPtr<GraphicsContext> m_context; | 141 OwnPtr<GraphicsContext> m_context; |
| 142 ImageBufferClient* m_client; |
| 136 }; | 143 }; |
| 137 | 144 |
| 138 struct ImageDataBuffer { | 145 struct ImageDataBuffer { |
| 139 ImageDataBuffer(const IntSize& size, PassRefPtr<Uint8ClampedArray> data) : m
_size(size), m_data(data) { } | 146 ImageDataBuffer(const IntSize& size, PassRefPtr<Uint8ClampedArray> data) : m
_size(size), m_data(data) { } |
| 140 IntSize size() const { return m_size; } | 147 IntSize size() const { return m_size; } |
| 141 unsigned char* data() const { return m_data->data(); } | 148 unsigned char* data() const { return m_data->data(); } |
| 142 | 149 |
| 143 IntSize m_size; | 150 IntSize m_size; |
| 144 RefPtr<Uint8ClampedArray> m_data; | 151 RefPtr<Uint8ClampedArray> m_data; |
| 145 }; | 152 }; |
| 146 | 153 |
| 147 String PLATFORM_EXPORT ImageDataToDataURL(const ImageDataBuffer&, const String&
mimeType, const double* quality); | 154 String PLATFORM_EXPORT ImageDataToDataURL(const ImageDataBuffer&, const String&
mimeType, const double* quality); |
| 148 | 155 |
| 149 } // namespace WebCore | 156 } // namespace WebCore |
| 150 | 157 |
| 151 #endif // ImageBuffer_h | 158 #endif // ImageBuffer_h |
| OLD | NEW |