| 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 "platform/graphics/skia/ImagePixelLocker.h" | 10 #include "platform/graphics/skia/ImagePixelLocker.h" |
| 11 #include "platform/heap/Heap.h" | 11 #include "platform/heap/Heap.h" |
| 12 #include "third_party/khronos/GLES2/gl2.h" | 12 #include "third_party/khronos/GLES2/gl2.h" |
| 13 #include "third_party/khronos/GLES2/gl2ext.h" | 13 #include "third_party/khronos/GLES2/gl2ext.h" |
| 14 #include "third_party/khronos/GLES3/gl3.h" | 14 #include "third_party/khronos/GLES3/gl3.h" |
| 15 #include "wtf/Allocator.h" |
| 15 #include "wtf/Optional.h" | 16 #include "wtf/Optional.h" |
| 16 #include "wtf/RefPtr.h" | 17 #include "wtf/RefPtr.h" |
| 17 | 18 |
| 18 namespace blink { | 19 namespace blink { |
| 19 class Image; | 20 class Image; |
| 20 class IntSize; | 21 class IntSize; |
| 21 | 22 |
| 22 // Helper functions for texture uploading and pixel readback. | 23 // Helper functions for texture uploading and pixel readback. |
| 23 class PLATFORM_EXPORT WebGLImageConversion { | 24 class PLATFORM_EXPORT WebGLImageConversion final { |
| 25 STATIC_ONLY(WebGLImageConversion); |
| 24 public: | 26 public: |
| 25 // Attempt to enumerate all possible native image formats to | 27 // Attempt to enumerate all possible native image formats to |
| 26 // reduce the amount of temporary allocations during texture | 28 // reduce the amount of temporary allocations during texture |
| 27 // uploading. This enum must be public because it is accessed | 29 // uploading. This enum must be public because it is accessed |
| 28 // by non-member functions. | 30 // by non-member functions. |
| 29 // "_S" postfix indicates signed type. | 31 // "_S" postfix indicates signed type. |
| 30 enum DataFormat { | 32 enum DataFormat { |
| 31 DataFormatRGBA8 = 0, | 33 DataFormatRGBA8 = 0, |
| 32 DataFormatRGBA8_S, | 34 DataFormatRGBA8_S, |
| 33 DataFormatRGBA16, | 35 DataFormatRGBA16, |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 106 AlphaDoUnmultiply = 2 | 108 AlphaDoUnmultiply = 2 |
| 107 }; | 109 }; |
| 108 | 110 |
| 109 enum ImageHtmlDomSource { | 111 enum ImageHtmlDomSource { |
| 110 HtmlDomImage = 0, | 112 HtmlDomImage = 0, |
| 111 HtmlDomCanvas = 1, | 113 HtmlDomCanvas = 1, |
| 112 HtmlDomVideo = 2, | 114 HtmlDomVideo = 2, |
| 113 HtmlDomNone = 3 | 115 HtmlDomNone = 3 |
| 114 }; | 116 }; |
| 115 | 117 |
| 116 class PLATFORM_EXPORT ImageExtractor { | 118 class PLATFORM_EXPORT ImageExtractor final { |
| 117 STACK_ALLOCATED(); | 119 STACK_ALLOCATED(); |
| 118 public: | 120 public: |
| 119 ImageExtractor(Image*, ImageHtmlDomSource, bool premultiplyAlpha, bool i
gnoreGammaAndColorProfile); | 121 ImageExtractor(Image*, ImageHtmlDomSource, bool premultiplyAlpha, bool i
gnoreGammaAndColorProfile); |
| 120 | 122 |
| 121 const void* imagePixelData() { return m_imagePixelLocker ? m_imagePixelL
ocker->pixels() : nullptr; } | 123 const void* imagePixelData() { return m_imagePixelLocker ? m_imagePixelL
ocker->pixels() : nullptr; } |
| 122 unsigned imageWidth() { return m_imageWidth; } | 124 unsigned imageWidth() { return m_imageWidth; } |
| 123 unsigned imageHeight() { return m_imageHeight; } | 125 unsigned imageHeight() { return m_imageHeight; } |
| 124 DataFormat imageSourceFormat() { return m_imageSourceFormat; } | 126 DataFormat imageSourceFormat() { return m_imageSourceFormat; } |
| 125 AlphaOp imageAlphaOp() { return m_alphaOp; } | 127 AlphaOp imageAlphaOp() { return m_alphaOp; } |
| 126 unsigned imageSourceUnpackAlignment() { return m_imageSourceUnpackAlignm
ent; } | 128 unsigned imageSourceUnpackAlignment() { return m_imageSourceUnpackAlignm
ent; } |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 191 // A sourceUnpackAlignment of zero indicates that the source | 193 // A sourceUnpackAlignment of zero indicates that the source |
| 192 // data is tightly packed. Non-zero values may take a slow path. | 194 // data is tightly packed. Non-zero values may take a slow path. |
| 193 // Destination data will have no gaps between rows. | 195 // Destination data will have no gaps between rows. |
| 194 // Implemented in GraphicsContext3DImagePacking.cpp | 196 // Implemented in GraphicsContext3DImagePacking.cpp |
| 195 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); | 197 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); |
| 196 }; | 198 }; |
| 197 | 199 |
| 198 } // namespace blink | 200 } // namespace blink |
| 199 | 201 |
| 200 #endif // WebGLImageConversion_h | 202 #endif // WebGLImageConversion_h |
| OLD | NEW |