diff options
author | Ben Murdoch <benm@google.com> | 2010-10-22 13:02:20 +0100 |
---|---|---|
committer | Ben Murdoch <benm@google.com> | 2010-10-26 15:21:41 +0100 |
commit | a94275402997c11dd2e778633dacf4b7e630a35d (patch) | |
tree | e66f56c67e3b01f22c9c23cd932271ee9ac558ed /WebCore/platform/graphics/GraphicsContext3D.cpp | |
parent | 09e26c78506587b3f5d930d7bc72a23287ffbec0 (diff) | |
download | external_webkit-a94275402997c11dd2e778633dacf4b7e630a35d.zip external_webkit-a94275402997c11dd2e778633dacf4b7e630a35d.tar.gz external_webkit-a94275402997c11dd2e778633dacf4b7e630a35d.tar.bz2 |
Merge WebKit at r70209: Initial merge by Git
Change-Id: Id23a68efa36e9d1126bcce0b137872db00892c8e
Diffstat (limited to 'WebCore/platform/graphics/GraphicsContext3D.cpp')
-rw-r--r-- | WebCore/platform/graphics/GraphicsContext3D.cpp | 241 |
1 files changed, 241 insertions, 0 deletions
diff --git a/WebCore/platform/graphics/GraphicsContext3D.cpp b/WebCore/platform/graphics/GraphicsContext3D.cpp index 86e9569..d2e9057 100644 --- a/WebCore/platform/graphics/GraphicsContext3D.cpp +++ b/WebCore/platform/graphics/GraphicsContext3D.cpp @@ -31,11 +31,27 @@ #include "GraphicsContext3D.h" #include "ArrayBufferView.h" +#include "DrawingBuffer.h" #include "Image.h" #include "ImageData.h" namespace WebCore { +static uint8_t convertColor16LittleTo8(uint16_t value) +{ + return value >> 8; +} + +static uint8_t convertColor16BigTo8(uint16_t value) +{ + return static_cast<uint8_t>(value & 0x00FF); +} + +PassRefPtr<DrawingBuffer> GraphicsContext3D::createDrawingBuffer(const IntSize& size) +{ + return DrawingBuffer::create(this, size); +} + bool GraphicsContext3D::computeFormatAndTypeParameters(unsigned int format, unsigned int type, unsigned long* componentsPerPixel, @@ -247,6 +263,22 @@ void unpackRGBA8ToRGBA8(const uint8_t* source, uint8_t* destination) destination[3] = source[3]; } +void unpackRGBA16LittleToRGBA8(const uint16_t* source, uint8_t* destination) +{ + destination[0] = convertColor16LittleTo8(source[0]); + destination[1] = convertColor16LittleTo8(source[1]); + destination[2] = convertColor16LittleTo8(source[2]); + destination[3] = convertColor16LittleTo8(source[3]); +} + +void unpackRGBA16BigToRGBA8(const uint16_t* source, uint8_t* destination) +{ + destination[0] = convertColor16BigTo8(source[0]); + destination[1] = convertColor16BigTo8(source[1]); + destination[2] = convertColor16BigTo8(source[2]); + destination[3] = convertColor16BigTo8(source[3]); +} + void unpackRGB8ToRGBA8(const uint8_t* source, uint8_t* destination) { destination[0] = source[0]; @@ -255,6 +287,22 @@ void unpackRGB8ToRGBA8(const uint8_t* source, uint8_t* destination) destination[3] = 0xFF; } +void unpackRGB16LittleToRGBA8(const uint16_t* source, uint8_t* destination) +{ + destination[0] = convertColor16LittleTo8(source[0]); + destination[1] = convertColor16LittleTo8(source[1]); + destination[2] = convertColor16LittleTo8(source[2]); + destination[3] = 0xFF; +} + +void unpackRGB16BigToRGBA8(const uint16_t* source, uint8_t* destination) +{ + destination[0] = convertColor16BigTo8(source[0]); + destination[1] = convertColor16BigTo8(source[1]); + destination[2] = convertColor16BigTo8(source[2]); + destination[3] = 0xFF; +} + void unpackARGB8ToRGBA8(const uint8_t* source, uint8_t* destination) { destination[0] = source[1]; @@ -263,6 +311,22 @@ void unpackARGB8ToRGBA8(const uint8_t* source, uint8_t* destination) destination[3] = source[0]; } +void unpackARGB16LittleToRGBA8(const uint16_t* source, uint8_t* destination) +{ + destination[0] = convertColor16LittleTo8(source[1]); + destination[1] = convertColor16LittleTo8(source[2]); + destination[2] = convertColor16LittleTo8(source[3]); + destination[3] = convertColor16LittleTo8(source[0]); +} + +void unpackARGB16BigToRGBA8(const uint16_t* source, uint8_t* destination) +{ + destination[0] = convertColor16BigTo8(source[1]); + destination[1] = convertColor16BigTo8(source[2]); + destination[2] = convertColor16BigTo8(source[3]); + destination[3] = convertColor16BigTo8(source[0]); +} + void unpackBGRA8ToRGBA8(const uint8_t* source, uint8_t* destination) { destination[0] = source[2]; @@ -271,6 +335,22 @@ void unpackBGRA8ToRGBA8(const uint8_t* source, uint8_t* destination) destination[3] = source[3]; } +void unpackBGRA16LittleToRGBA8(const uint16_t* source, uint8_t* destination) +{ + destination[0] = convertColor16LittleTo8(source[2]); + destination[1] = convertColor16LittleTo8(source[1]); + destination[2] = convertColor16LittleTo8(source[0]); + destination[3] = convertColor16LittleTo8(source[3]); +} + +void unpackBGRA16BigToRGBA8(const uint16_t* source, uint8_t* destination) +{ + destination[0] = convertColor16BigTo8(source[2]); + destination[1] = convertColor16BigTo8(source[1]); + destination[2] = convertColor16BigTo8(source[0]); + destination[3] = convertColor16BigTo8(source[3]); +} + void unpackRGBA5551ToRGBA8(const uint16_t* source, uint8_t* destination) { uint16_t packedValue = source[0]; @@ -316,6 +396,22 @@ void unpackR8ToRGBA8(const uint8_t* source, uint8_t* destination) destination[3] = 0xFF; } +void unpackR16LittleToRGBA8(const uint16_t* source, uint8_t* destination) +{ + destination[0] = convertColor16LittleTo8(source[0]); + destination[1] = convertColor16LittleTo8(source[0]); + destination[2] = convertColor16LittleTo8(source[0]); + destination[3] = 0xFF; +} + +void unpackR16BigToRGBA8(const uint16_t* source, uint8_t* destination) +{ + destination[0] = convertColor16BigTo8(source[0]); + destination[1] = convertColor16BigTo8(source[0]); + destination[2] = convertColor16BigTo8(source[0]); + destination[3] = 0xFF; +} + void unpackRA8ToRGBA8(const uint8_t* source, uint8_t* destination) { destination[0] = source[0]; @@ -324,6 +420,22 @@ void unpackRA8ToRGBA8(const uint8_t* source, uint8_t* destination) destination[3] = source[1]; } +void unpackRA16LittleToRGBA8(const uint16_t* source, uint8_t* destination) +{ + destination[0] = convertColor16LittleTo8(source[0]); + destination[1] = convertColor16LittleTo8(source[0]); + destination[2] = convertColor16LittleTo8(source[0]); + destination[3] = convertColor16LittleTo8(source[1]); +} + +void unpackRA16BigToRGBA8(const uint16_t* source, uint8_t* destination) +{ + destination[0] = convertColor16BigTo8(source[0]); + destination[1] = convertColor16BigTo8(source[0]); + destination[2] = convertColor16BigTo8(source[0]); + destination[3] = convertColor16BigTo8(source[1]); +} + void unpackAR8ToRGBA8(const uint8_t* source, uint8_t* destination) { destination[0] = source[1]; @@ -332,6 +444,22 @@ void unpackAR8ToRGBA8(const uint8_t* source, uint8_t* destination) destination[3] = source[0]; } +void unpackAR16LittleToRGBA8(const uint16_t* source, uint8_t* destination) +{ + destination[0] = convertColor16LittleTo8(source[1]); + destination[1] = convertColor16LittleTo8(source[1]); + destination[2] = convertColor16LittleTo8(source[1]); + destination[3] = convertColor16LittleTo8(source[0]); +} + +void unpackAR16BigToRGBA8(const uint16_t* source, uint8_t* destination) +{ + destination[0] = convertColor16BigTo8(source[1]); + destination[1] = convertColor16BigTo8(source[1]); + destination[2] = convertColor16BigTo8(source[1]); + destination[3] = convertColor16BigTo8(source[0]); +} + void unpackA8ToRGBA8(const uint8_t* source, uint8_t* destination) { destination[0] = 0x0; @@ -340,6 +468,22 @@ void unpackA8ToRGBA8(const uint8_t* source, uint8_t* destination) destination[3] = source[0]; } +void unpackA16LittleToRGBA8(const uint16_t* source, uint8_t* destination) +{ + destination[0] = 0x0; + destination[1] = 0x0; + destination[2] = 0x0; + destination[3] = convertColor16LittleTo8(source[0]); +} + +void unpackA16BigToRGBA8(const uint16_t* source, uint8_t* destination) +{ + destination[0] = 0x0; + destination[1] = 0x0; + destination[2] = 0x0; + destination[3] = convertColor16BigTo8(source[0]); +} + //---------------------------------------------------------------------- // Pixel packing routines. // @@ -602,6 +746,7 @@ static void computeIncrementParameters(unsigned int width, { unsigned int elementSizeInBytes = sizeof(SourceType); ASSERT(elementSizeInBytes <= bytesPerPixel); + ASSERT(!(bytesPerPixel % elementSizeInBytes)); unsigned int validRowBytes = width * bytesPerPixel; unsigned int totalRowBytes = validRowBytes; if (unpackAlignment) { @@ -644,24 +789,72 @@ static void doPacking(const void* sourceData, } break; } + case GraphicsContext3D::kSourceFormatRGBA16Little: { + unsigned int sourceElementsPerPixel, sourceElementsPerRow; + computeIncrementParameters<uint16_t>(width, 8, sourceUnpackAlignment, &sourceElementsPerPixel, &sourceElementsPerRow); + doUnpackingAndPacking<uint16_t, DestType, unpackRGBA16LittleToRGBA8, packingFunc>(static_cast<const uint16_t*>(sourceData), width, height, sourceElementsPerPixel, sourceElementsPerRow, destinationData, destinationElementsPerPixel); + break; + } + case GraphicsContext3D::kSourceFormatRGBA16Big: { + unsigned int sourceElementsPerPixel, sourceElementsPerRow; + computeIncrementParameters<uint16_t>(width, 8, sourceUnpackAlignment, &sourceElementsPerPixel, &sourceElementsPerRow); + doUnpackingAndPacking<uint16_t, DestType, unpackRGBA16BigToRGBA8, packingFunc>(static_cast<const uint16_t*>(sourceData), width, height, sourceElementsPerPixel, sourceElementsPerRow, destinationData, destinationElementsPerPixel); + break; + } case GraphicsContext3D::kSourceFormatRGB8: { unsigned int sourceElementsPerPixel, sourceElementsPerRow; computeIncrementParameters<uint8_t>(width, 3, sourceUnpackAlignment, &sourceElementsPerPixel, &sourceElementsPerRow); doUnpackingAndPacking<uint8_t, DestType, unpackRGB8ToRGBA8, packingFunc>(static_cast<const uint8_t*>(sourceData), width, height, sourceElementsPerPixel, sourceElementsPerRow, destinationData, destinationElementsPerPixel); break; } + case GraphicsContext3D::kSourceFormatRGB16Little: { + unsigned int sourceElementsPerPixel, sourceElementsPerRow; + computeIncrementParameters<uint16_t>(width, 6, sourceUnpackAlignment, &sourceElementsPerPixel, &sourceElementsPerRow); + doUnpackingAndPacking<uint16_t, DestType, unpackRGB16LittleToRGBA8, packingFunc>(static_cast<const uint16_t*>(sourceData), width, height, sourceElementsPerPixel, sourceElementsPerRow, destinationData, destinationElementsPerPixel); + break; + } + case GraphicsContext3D::kSourceFormatRGB16Big: { + unsigned int sourceElementsPerPixel, sourceElementsPerRow; + computeIncrementParameters<uint16_t>(width, 6, sourceUnpackAlignment, &sourceElementsPerPixel, &sourceElementsPerRow); + doUnpackingAndPacking<uint16_t, DestType, unpackRGB16BigToRGBA8, packingFunc>(static_cast<const uint16_t*>(sourceData), width, height, sourceElementsPerPixel, sourceElementsPerRow, destinationData, destinationElementsPerPixel); + break; + } case GraphicsContext3D::kSourceFormatARGB8: { unsigned int sourceElementsPerPixel, sourceElementsPerRow; computeIncrementParameters<uint8_t>(width, 4, sourceUnpackAlignment, &sourceElementsPerPixel, &sourceElementsPerRow); doUnpackingAndPacking<uint8_t, DestType, unpackARGB8ToRGBA8, packingFunc>(static_cast<const uint8_t*>(sourceData), width, height, sourceElementsPerPixel, sourceElementsPerRow, destinationData, destinationElementsPerPixel); break; } + case GraphicsContext3D::kSourceFormatARGB16Little: { + unsigned int sourceElementsPerPixel, sourceElementsPerRow; + computeIncrementParameters<uint16_t>(width, 8, sourceUnpackAlignment, &sourceElementsPerPixel, &sourceElementsPerRow); + doUnpackingAndPacking<uint16_t, DestType, unpackARGB16LittleToRGBA8, packingFunc>(static_cast<const uint16_t*>(sourceData), width, height, sourceElementsPerPixel, sourceElementsPerRow, destinationData, destinationElementsPerPixel); + break; + } + case GraphicsContext3D::kSourceFormatARGB16Big: { + unsigned int sourceElementsPerPixel, sourceElementsPerRow; + computeIncrementParameters<uint16_t>(width, 8, sourceUnpackAlignment, &sourceElementsPerPixel, &sourceElementsPerRow); + doUnpackingAndPacking<uint16_t, DestType, unpackARGB16BigToRGBA8, packingFunc>(static_cast<const uint16_t*>(sourceData), width, height, sourceElementsPerPixel, sourceElementsPerRow, destinationData, destinationElementsPerPixel); + break; + } case GraphicsContext3D::kSourceFormatBGRA8: { unsigned int sourceElementsPerPixel, sourceElementsPerRow; computeIncrementParameters<uint8_t>(width, 4, sourceUnpackAlignment, &sourceElementsPerPixel, &sourceElementsPerRow); doUnpackingAndPacking<uint8_t, DestType, unpackBGRA8ToRGBA8, packingFunc>(static_cast<const uint8_t*>(sourceData), width, height, sourceElementsPerPixel, sourceElementsPerRow, destinationData, destinationElementsPerPixel); break; } + case GraphicsContext3D::kSourceFormatBGRA16Little: { + unsigned int sourceElementsPerPixel, sourceElementsPerRow; + computeIncrementParameters<uint16_t>(width, 8, sourceUnpackAlignment, &sourceElementsPerPixel, &sourceElementsPerRow); + doUnpackingAndPacking<uint16_t, DestType, unpackBGRA16LittleToRGBA8, packingFunc>(static_cast<const uint16_t*>(sourceData), width, height, sourceElementsPerPixel, sourceElementsPerRow, destinationData, destinationElementsPerPixel); + break; + } + case GraphicsContext3D::kSourceFormatBGRA16Big: { + unsigned int sourceElementsPerPixel, sourceElementsPerRow; + computeIncrementParameters<uint16_t>(width, 8, sourceUnpackAlignment, &sourceElementsPerPixel, &sourceElementsPerRow); + doUnpackingAndPacking<uint16_t, DestType, unpackBGRA16BigToRGBA8, packingFunc>(static_cast<const uint16_t*>(sourceData), width, height, sourceElementsPerPixel, sourceElementsPerRow, destinationData, destinationElementsPerPixel); + break; + } case GraphicsContext3D::kSourceFormatRGBA5551: { unsigned int sourceElementsPerPixel, sourceElementsPerRow; computeIncrementParameters<uint16_t>(width, 2, sourceUnpackAlignment, &sourceElementsPerPixel, &sourceElementsPerRow); @@ -686,24 +879,72 @@ static void doPacking(const void* sourceData, doUnpackingAndPacking<uint8_t, DestType, unpackR8ToRGBA8, packingFunc>(static_cast<const uint8_t*>(sourceData), width, height, sourceElementsPerPixel, sourceElementsPerRow, destinationData, destinationElementsPerPixel); break; } + case GraphicsContext3D::kSourceFormatR16Little: { + unsigned int sourceElementsPerPixel, sourceElementsPerRow; + computeIncrementParameters<uint16_t>(width, 2, sourceUnpackAlignment, &sourceElementsPerPixel, &sourceElementsPerRow); + doUnpackingAndPacking<uint16_t, DestType, unpackR16LittleToRGBA8, packingFunc>(static_cast<const uint16_t*>(sourceData), width, height, sourceElementsPerPixel, sourceElementsPerRow, destinationData, destinationElementsPerPixel); + break; + } + case GraphicsContext3D::kSourceFormatR16Big: { + unsigned int sourceElementsPerPixel, sourceElementsPerRow; + computeIncrementParameters<uint16_t>(width, 2, sourceUnpackAlignment, &sourceElementsPerPixel, &sourceElementsPerRow); + doUnpackingAndPacking<uint16_t, DestType, unpackR16BigToRGBA8, packingFunc>(static_cast<const uint16_t*>(sourceData), width, height, sourceElementsPerPixel, sourceElementsPerRow, destinationData, destinationElementsPerPixel); + break; + } case GraphicsContext3D::kSourceFormatRA8: { unsigned int sourceElementsPerPixel, sourceElementsPerRow; computeIncrementParameters<uint8_t>(width, 2, sourceUnpackAlignment, &sourceElementsPerPixel, &sourceElementsPerRow); doUnpackingAndPacking<uint8_t, DestType, unpackRA8ToRGBA8, packingFunc>(static_cast<const uint8_t*>(sourceData), width, height, sourceElementsPerPixel, sourceElementsPerRow, destinationData, destinationElementsPerPixel); break; } + case GraphicsContext3D::kSourceFormatRA16Little: { + unsigned int sourceElementsPerPixel, sourceElementsPerRow; + computeIncrementParameters<uint16_t>(width, 4, sourceUnpackAlignment, &sourceElementsPerPixel, &sourceElementsPerRow); + doUnpackingAndPacking<uint16_t, DestType, unpackRA16LittleToRGBA8, packingFunc>(static_cast<const uint16_t*>(sourceData), width, height, sourceElementsPerPixel, sourceElementsPerRow, destinationData, destinationElementsPerPixel); + break; + } + case GraphicsContext3D::kSourceFormatRA16Big: { + unsigned int sourceElementsPerPixel, sourceElementsPerRow; + computeIncrementParameters<uint16_t>(width, 4, sourceUnpackAlignment, &sourceElementsPerPixel, &sourceElementsPerRow); + doUnpackingAndPacking<uint16_t, DestType, unpackRA16BigToRGBA8, packingFunc>(static_cast<const uint16_t*>(sourceData), width, height, sourceElementsPerPixel, sourceElementsPerRow, destinationData, destinationElementsPerPixel); + break; + } case GraphicsContext3D::kSourceFormatAR8: { unsigned int sourceElementsPerPixel, sourceElementsPerRow; computeIncrementParameters<uint8_t>(width, 2, sourceUnpackAlignment, &sourceElementsPerPixel, &sourceElementsPerRow); doUnpackingAndPacking<uint8_t, DestType, unpackAR8ToRGBA8, packingFunc>(static_cast<const uint8_t*>(sourceData), width, height, sourceElementsPerPixel, sourceElementsPerRow, destinationData, destinationElementsPerPixel); break; } + case GraphicsContext3D::kSourceFormatAR16Little: { + unsigned int sourceElementsPerPixel, sourceElementsPerRow; + computeIncrementParameters<uint16_t>(width, 4, sourceUnpackAlignment, &sourceElementsPerPixel, &sourceElementsPerRow); + doUnpackingAndPacking<uint16_t, DestType, unpackAR16LittleToRGBA8, packingFunc>(static_cast<const uint16_t*>(sourceData), width, height, sourceElementsPerPixel, sourceElementsPerRow, destinationData, destinationElementsPerPixel); + break; + } + case GraphicsContext3D::kSourceFormatAR16Big: { + unsigned int sourceElementsPerPixel, sourceElementsPerRow; + computeIncrementParameters<uint16_t>(width, 4, sourceUnpackAlignment, &sourceElementsPerPixel, &sourceElementsPerRow); + doUnpackingAndPacking<uint16_t, DestType, unpackAR16BigToRGBA8, packingFunc>(static_cast<const uint16_t*>(sourceData), width, height, sourceElementsPerPixel, sourceElementsPerRow, destinationData, destinationElementsPerPixel); + break; + } case GraphicsContext3D::kSourceFormatA8: { unsigned int sourceElementsPerPixel, sourceElementsPerRow; computeIncrementParameters<uint8_t>(width, 1, sourceUnpackAlignment, &sourceElementsPerPixel, &sourceElementsPerRow); doUnpackingAndPacking<uint8_t, DestType, unpackA8ToRGBA8, packingFunc>(static_cast<const uint8_t*>(sourceData), width, height, sourceElementsPerPixel, sourceElementsPerRow, destinationData, destinationElementsPerPixel); break; } + case GraphicsContext3D::kSourceFormatA16Little: { + unsigned int sourceElementsPerPixel, sourceElementsPerRow; + computeIncrementParameters<uint16_t>(width, 2, sourceUnpackAlignment, &sourceElementsPerPixel, &sourceElementsPerRow); + doUnpackingAndPacking<uint16_t, DestType, unpackA16LittleToRGBA8, packingFunc>(static_cast<const uint16_t*>(sourceData), width, height, sourceElementsPerPixel, sourceElementsPerRow, destinationData, destinationElementsPerPixel); + break; + } + case GraphicsContext3D::kSourceFormatA16Big: { + unsigned int sourceElementsPerPixel, sourceElementsPerRow; + computeIncrementParameters<uint16_t>(width, 2, sourceUnpackAlignment, &sourceElementsPerPixel, &sourceElementsPerRow); + doUnpackingAndPacking<uint16_t, DestType, unpackA16BigToRGBA8, packingFunc>(static_cast<const uint16_t*>(sourceData), width, height, sourceElementsPerPixel, sourceElementsPerRow, destinationData, destinationElementsPerPixel); + break; + } } } |