| 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" |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 141 }; | 141 }; |
| 142 | 142 |
| 143 // Computes the components per pixel and bytes per component | 143 // Computes the components per pixel and bytes per component |
| 144 // for the given format and type combination. Returns false if | 144 // for the given format and type combination. Returns false if |
| 145 // either was an invalid enum. | 145 // either was an invalid enum. |
| 146 static bool computeFormatAndTypeParameters(GLenum format, GLenum type, unsig
ned* componentsPerPixel, unsigned* bytesPerComponent); | 146 static bool computeFormatAndTypeParameters(GLenum format, GLenum type, unsig
ned* componentsPerPixel, unsigned* bytesPerComponent); |
| 147 | 147 |
| 148 // Computes the image size in bytes. If paddingInBytes is not null, padding | 148 // Computes the image size in bytes. If paddingInBytes is not null, padding |
| 149 // is also calculated in return. Returns NO_ERROR if succeed, otherwise | 149 // is also calculated in return. Returns NO_ERROR if succeed, otherwise |
| 150 // return the suggested GL error indicating the cause of the failure: | 150 // return the suggested GL error indicating the cause of the failure: |
| 151 // INVALID_VALUE if width/height is negative or overflow happens. | 151 // INVALID_VALUE if width/height/depth is negative or overflow happens. |
| 152 // INVALID_ENUM if format/type is illegal. | 152 // INVALID_ENUM if format/type is illegal. |
| 153 static GLenum computeImageSizeInBytes(GLenum format, GLenum type, GLsizei wi
dth, GLsizei height, GLint alignment, unsigned* imageSizeInBytes, unsigned* padd
ingInBytes); | 153 static GLenum computeImageSizeInBytes(GLenum format, GLenum type, GLsizei wi
dth, GLsizei height, GLsizei depth, GLint alignment, unsigned* imageSizeInBytes,
unsigned* paddingInBytes); |
| 154 | 154 |
| 155 // Check if the format is one of the formats from the ImageData or DOM eleme
nts. | 155 // Check if the format is one of the formats from the ImageData or DOM eleme
nts. |
| 156 // The formats from ImageData is always RGBA8. | 156 // The formats from ImageData is always RGBA8. |
| 157 // The formats from DOM elements vary with Graphics ports. It can only be RG
BA8 or BGRA8. | 157 // The formats from DOM elements vary with Graphics ports. It can only be RG
BA8 or BGRA8. |
| 158 static ALWAYS_INLINE bool srcFormatComeFromDOMElementOrImageData(DataFormat
SrcFormat) | 158 static ALWAYS_INLINE bool srcFormatComeFromDOMElementOrImageData(DataFormat
SrcFormat) |
| 159 { | 159 { |
| 160 return SrcFormat == DataFormatBGRA8 || SrcFormat == DataFormatRGBA8; | 160 return SrcFormat == DataFormatBGRA8 || SrcFormat == DataFormatRGBA8; |
| 161 } | 161 } |
| 162 | 162 |
| 163 // The input can be either format or internalformat. | 163 // The input can be either format or internalformat. |
| (...skipping 27 matching lines...) Expand all Loading... |
| 191 // A sourceUnpackAlignment of zero indicates that the source | 191 // A sourceUnpackAlignment of zero indicates that the source |
| 192 // data is tightly packed. Non-zero values may take a slow path. | 192 // data is tightly packed. Non-zero values may take a slow path. |
| 193 // Destination data will have no gaps between rows. | 193 // Destination data will have no gaps between rows. |
| 194 // Implemented in GraphicsContext3DImagePacking.cpp | 194 // 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); | 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); |
| 196 }; | 196 }; |
| 197 | 197 |
| 198 } // namespace blink | 198 } // namespace blink |
| 199 | 199 |
| 200 #endif // WebGLImageConversion_h | 200 #endif // WebGLImageConversion_h |
| OLD | NEW |