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 21 matching lines...) Expand all Loading... |
32 #include "platform/geometry/FloatRect.h" | 32 #include "platform/geometry/FloatRect.h" |
33 #include "platform/geometry/IntSize.h" | 33 #include "platform/geometry/IntSize.h" |
34 #include "platform/graphics/Canvas2DLayerBridge.h" | 34 #include "platform/graphics/Canvas2DLayerBridge.h" |
35 #include "platform/graphics/GraphicsTypes.h" | 35 #include "platform/graphics/GraphicsTypes.h" |
36 #include "platform/graphics/GraphicsTypes3D.h" | 36 #include "platform/graphics/GraphicsTypes3D.h" |
37 #include "platform/graphics/ImageBufferSurface.h" | 37 #include "platform/graphics/ImageBufferSurface.h" |
38 #include "platform/transforms/AffineTransform.h" | 38 #include "platform/transforms/AffineTransform.h" |
39 #include "third_party/skia/include/core/SkPaint.h" | 39 #include "third_party/skia/include/core/SkPaint.h" |
40 #include "third_party/skia/include/core/SkPicture.h" | 40 #include "third_party/skia/include/core/SkPicture.h" |
41 #include "wtf/Forward.h" | 41 #include "wtf/Forward.h" |
42 #include "wtf/OwnPtr.h" | |
43 #include "wtf/PassOwnPtr.h" | |
44 #include "wtf/PassRefPtr.h" | 42 #include "wtf/PassRefPtr.h" |
45 #include "wtf/Vector.h" | 43 #include "wtf/Vector.h" |
46 #include "wtf/text/WTFString.h" | 44 #include "wtf/text/WTFString.h" |
47 #include "wtf/typed_arrays/Uint8ClampedArray.h" | 45 #include "wtf/typed_arrays/Uint8ClampedArray.h" |
| 46 #include <memory> |
48 | 47 |
49 namespace gpu { | 48 namespace gpu { |
50 namespace gles2 { | 49 namespace gles2 { |
51 class GLES2Interface; | 50 class GLES2Interface; |
52 } | 51 } |
53 } | 52 } |
54 | 53 |
55 namespace WTF { | 54 namespace WTF { |
56 | 55 |
57 class ArrayBufferContents; | 56 class ArrayBufferContents; |
(...skipping 11 matching lines...) Expand all Loading... |
69 | 68 |
70 enum Multiply { | 69 enum Multiply { |
71 Premultiplied, | 70 Premultiplied, |
72 Unmultiplied | 71 Unmultiplied |
73 }; | 72 }; |
74 | 73 |
75 class PLATFORM_EXPORT ImageBuffer { | 74 class PLATFORM_EXPORT ImageBuffer { |
76 WTF_MAKE_NONCOPYABLE(ImageBuffer); | 75 WTF_MAKE_NONCOPYABLE(ImageBuffer); |
77 USING_FAST_MALLOC(ImageBuffer); | 76 USING_FAST_MALLOC(ImageBuffer); |
78 public: | 77 public: |
79 static PassOwnPtr<ImageBuffer> create(const IntSize&, OpacityMode = NonOpaqu
e, ImageInitializationMode = InitializeImagePixels); | 78 static std::unique_ptr<ImageBuffer> create(const IntSize&, OpacityMode = Non
Opaque, ImageInitializationMode = InitializeImagePixels); |
80 static PassOwnPtr<ImageBuffer> create(PassOwnPtr<ImageBufferSurface>); | 79 static std::unique_ptr<ImageBuffer> create(std::unique_ptr<ImageBufferSurfac
e>); |
81 | 80 |
82 virtual ~ImageBuffer(); | 81 virtual ~ImageBuffer(); |
83 | 82 |
84 void setClient(ImageBufferClient* client) { m_client = client; } | 83 void setClient(ImageBufferClient* client) { m_client = client; } |
85 | 84 |
86 const IntSize& size() const { return m_surface->size(); } | 85 const IntSize& size() const { return m_surface->size(); } |
87 bool isAccelerated() const { return m_surface->isAccelerated(); } | 86 bool isAccelerated() const { return m_surface->isAccelerated(); } |
88 bool isRecording() const { return m_surface->isRecording(); } | 87 bool isRecording() const { return m_surface->isRecording(); } |
89 void setHasExpensiveOp() { m_surface->setHasExpensiveOp(); } | 88 void setHasExpensiveOp() { m_surface->setHasExpensiveOp(); } |
90 bool isExpensiveToPaint() const { return m_surface->isExpensiveToPaint(); } | 89 bool isExpensiveToPaint() const { return m_surface->isExpensiveToPaint(); } |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
140 PassRefPtr<SkPicture> getPicture() { return m_surface->getPicture(); } | 139 PassRefPtr<SkPicture> getPicture() { return m_surface->getPicture(); } |
141 | 140 |
142 void draw(GraphicsContext&, const FloatRect&, const FloatRect*, SkXfermode::
Mode); | 141 void draw(GraphicsContext&, const FloatRect&, const FloatRect*, SkXfermode::
Mode); |
143 | 142 |
144 void updateGPUMemoryUsage() const; | 143 void updateGPUMemoryUsage() const; |
145 static intptr_t getGlobalGPUMemoryUsage() { return s_globalGPUMemoryUsage; } | 144 static intptr_t getGlobalGPUMemoryUsage() { return s_globalGPUMemoryUsage; } |
146 static unsigned getGlobalAcceleratedImageBufferCount() { return s_globalAcce
leratedImageBufferCount; } | 145 static unsigned getGlobalAcceleratedImageBufferCount() { return s_globalAcce
leratedImageBufferCount; } |
147 intptr_t getGPUMemoryUsage() { return m_gpuMemoryUsage; } | 146 intptr_t getGPUMemoryUsage() { return m_gpuMemoryUsage; } |
148 | 147 |
149 protected: | 148 protected: |
150 ImageBuffer(PassOwnPtr<ImageBufferSurface>); | 149 ImageBuffer(std::unique_ptr<ImageBufferSurface>); |
151 | 150 |
152 private: | 151 private: |
153 enum SnapshotState { | 152 enum SnapshotState { |
154 InitialSnapshotState, | 153 InitialSnapshotState, |
155 DidAcquireSnapshot, | 154 DidAcquireSnapshot, |
156 DrawnToAfterSnapshot, | 155 DrawnToAfterSnapshot, |
157 }; | 156 }; |
158 mutable SnapshotState m_snapshotState; | 157 mutable SnapshotState m_snapshotState; |
159 OwnPtr<ImageBufferSurface> m_surface; | 158 std::unique_ptr<ImageBufferSurface> m_surface; |
160 ImageBufferClient* m_client; | 159 ImageBufferClient* m_client; |
161 | 160 |
162 mutable intptr_t m_gpuMemoryUsage; | 161 mutable intptr_t m_gpuMemoryUsage; |
163 static intptr_t s_globalGPUMemoryUsage; | 162 static intptr_t s_globalGPUMemoryUsage; |
164 static unsigned s_globalAcceleratedImageBufferCount; | 163 static unsigned s_globalAcceleratedImageBufferCount; |
165 }; | 164 }; |
166 | 165 |
167 struct ImageDataBuffer { | 166 struct ImageDataBuffer { |
168 STACK_ALLOCATED(); | 167 STACK_ALLOCATED(); |
169 ImageDataBuffer(const IntSize& size, const unsigned char* data) : m_data(dat
a), m_size(size) { } | 168 ImageDataBuffer(const IntSize& size, const unsigned char* data) : m_data(dat
a), m_size(size) { } |
170 String PLATFORM_EXPORT toDataURL(const String& mimeType, const double& quali
ty) const; | 169 String PLATFORM_EXPORT toDataURL(const String& mimeType, const double& quali
ty) const; |
171 bool PLATFORM_EXPORT encodeImage(const String& mimeType, const double& quali
ty, Vector<unsigned char>* encodedImage) const; | 170 bool PLATFORM_EXPORT encodeImage(const String& mimeType, const double& quali
ty, Vector<unsigned char>* encodedImage) const; |
172 const unsigned char* pixels() const { return m_data; } | 171 const unsigned char* pixels() const { return m_data; } |
173 const IntSize& size() const { return m_size; } | 172 const IntSize& size() const { return m_size; } |
174 int height() const { return m_size.height(); } | 173 int height() const { return m_size.height(); } |
175 int width() const { return m_size.width(); } | 174 int width() const { return m_size.width(); } |
176 | 175 |
177 const unsigned char* m_data; | 176 const unsigned char* m_data; |
178 const IntSize m_size; | 177 const IntSize m_size; |
179 }; | 178 }; |
180 | 179 |
181 } // namespace blink | 180 } // namespace blink |
182 | 181 |
183 #endif // ImageBuffer_h | 182 #endif // ImageBuffer_h |
OLD | NEW |