OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef WebGLImageConversion_h | 5 #ifndef WebGLImageConversion_h |
6 #define WebGLImageConversion_h | 6 #define WebGLImageConversion_h |
7 | 7 |
8 #include "platform/PlatformExport.h" | 8 #include "platform/PlatformExport.h" |
9 #include "platform/graphics/Image.h" | 9 #include "platform/graphics/Image.h" |
10 #include "third_party/khronos/GLES2/gl2.h" | 10 #include "third_party/khronos/GLES2/gl2.h" |
11 #include "third_party/khronos/GLES2/gl2ext.h" | 11 #include "third_party/khronos/GLES2/gl2ext.h" |
| 12 #include "third_party/skia/include/core/SkBitmap.h" |
12 #include "wtf/RefPtr.h" | 13 #include "wtf/RefPtr.h" |
13 | 14 |
14 namespace blink { | 15 namespace blink { |
15 class Image; | 16 class Image; |
16 class IntSize; | 17 class IntSize; |
17 | 18 |
18 // Helper functions for texture uploading and pixel readback. | 19 // Helper functions for texture uploading and pixel readback. |
19 class PLATFORM_EXPORT WebGLImageConversion { | 20 class PLATFORM_EXPORT WebGLImageConversion { |
20 public: | 21 public: |
21 // Attempt to enumerate all possible native image formats to | 22 // Attempt to enumerate all possible native image formats to |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 unsigned imageHeight() { return m_imageHeight; } | 89 unsigned imageHeight() { return m_imageHeight; } |
89 DataFormat imageSourceFormat() { return m_imageSourceFormat; } | 90 DataFormat imageSourceFormat() { return m_imageSourceFormat; } |
90 AlphaOp imageAlphaOp() { return m_alphaOp; } | 91 AlphaOp imageAlphaOp() { return m_alphaOp; } |
91 unsigned imageSourceUnpackAlignment() { return m_imageSourceUnpackAlignm
ent; } | 92 unsigned imageSourceUnpackAlignment() { return m_imageSourceUnpackAlignm
ent; } |
92 ImageHtmlDomSource imageHtmlDomSource() { return m_imageHtmlDomSource; } | 93 ImageHtmlDomSource imageHtmlDomSource() { return m_imageHtmlDomSource; } |
93 private: | 94 private: |
94 // Extract the image and keeps track of its status, such as width, heigh
t, Source Alignment, format and AlphaOp etc. | 95 // Extract the image and keeps track of its status, such as width, heigh
t, Source Alignment, format and AlphaOp etc. |
95 // This needs to lock the resources or relevant data if needed and retur
n true upon success | 96 // This needs to lock the resources or relevant data if needed and retur
n true upon success |
96 bool extractImage(bool premultiplyAlpha, bool ignoreGammaAndColorProfile
); | 97 bool extractImage(bool premultiplyAlpha, bool ignoreGammaAndColorProfile
); |
97 | 98 |
98 RefPtr<NativeImageSkia> m_nativeImage; | 99 SkBitmap m_bitmap; |
99 RefPtr<NativeImageSkia> m_skiaImage; | 100 SkBitmap m_skiaBitmap; |
100 Image* m_image; | 101 Image* m_image; |
101 ImageHtmlDomSource m_imageHtmlDomSource; | 102 ImageHtmlDomSource m_imageHtmlDomSource; |
102 bool m_extractSucceeded; | 103 bool m_extractSucceeded; |
103 const void* m_imagePixelData; | 104 const void* m_imagePixelData; |
104 unsigned m_imageWidth; | 105 unsigned m_imageWidth; |
105 unsigned m_imageHeight; | 106 unsigned m_imageHeight; |
106 DataFormat m_imageSourceFormat; | 107 DataFormat m_imageSourceFormat; |
107 AlphaOp m_alphaOp; | 108 AlphaOp m_alphaOp; |
108 unsigned m_imageSourceUnpackAlignment; | 109 unsigned m_imageSourceUnpackAlignment; |
109 }; | 110 }; |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
159 // A sourceUnpackAlignment of zero indicates that the source | 160 // A sourceUnpackAlignment of zero indicates that the source |
160 // data is tightly packed. Non-zero values may take a slow path. | 161 // data is tightly packed. Non-zero values may take a slow path. |
161 // Destination data will have no gaps between rows. | 162 // Destination data will have no gaps between rows. |
162 // Implemented in GraphicsContext3DImagePacking.cpp | 163 // Implemented in GraphicsContext3DImagePacking.cpp |
163 static bool packPixels(const uint8_t* sourceData, DataFormat sourceDataForma
t, unsigned width, unsigned height, unsigned sourceUnpackAlignment, unsigned des
tinationFormat, unsigned destinationType, AlphaOp, void* destinationData, bool f
lipY); | 164 static bool packPixels(const uint8_t* sourceData, DataFormat sourceDataForma
t, unsigned width, unsigned height, unsigned sourceUnpackAlignment, unsigned des
tinationFormat, unsigned destinationType, AlphaOp, void* destinationData, bool f
lipY); |
164 }; | 165 }; |
165 | 166 |
166 } // namespace blink | 167 } // namespace blink |
167 | 168 |
168 #endif // WebGLImageConversion_h | 169 #endif // WebGLImageConversion_h |
OLD | NEW |