WebKit Bugzilla
New
Browse
Search+
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
[patch]
revised patch: remove an extra whitespace
cg.patch (text/plain), 12.67 KB, created by
Zhenyao Mo
on 2010-10-21 10:09:59 PDT
(
hide
)
Description:
revised patch: remove an extra whitespace
Filename:
MIME Type:
Creator:
Zhenyao Mo
Created:
2010-10-21 10:09:59 PDT
Size:
12.67 KB
patch
obsolete
>Index: WebCore/ChangeLog >=================================================================== >--- WebCore/ChangeLog (revision 70244) >+++ WebCore/ChangeLog (working copy) >@@ -1,3 +1,17 @@ >+2010-10-21 Zhenyao Mo <zmo@google.com> >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ refactor the nested large switch statements in GraphicsContext3DCG.cpp:getImageData() >+ https://bugs.webkit.org/show_bug.cgi?id=47027 >+ >+ * platform/graphics/GraphicsContext3D.cpp: >+ (WebCore::doPacking): ASSERT false if undefined format is passed in. >+ * platform/graphics/GraphicsContext3D.h: Add kSourceFormatUndefined enum. >+ * platform/graphics/cg/GraphicsContext3DCG.cpp: >+ (WebCore::getSourceDataFormat): Decide source data format from componentsPerPixel, alpha format, bitsPerComponet, etc. >+ (WebCore::GraphicsContext3D::getImageData): Refactor the code to use getSourceDataFormat and remove nested switches. >+ > 2010-10-21 Pavel Feldman <pfeldman@chromium.org> > > Reviewed by Yury Semikhatsky. >Index: WebCore/platform/graphics/GraphicsContext3D.cpp >=================================================================== >--- WebCore/platform/graphics/GraphicsContext3D.cpp (revision 70163) >+++ WebCore/platform/graphics/GraphicsContext3D.cpp (working copy) >@@ -945,6 +945,8 @@ static void doPacking(const void* source > doUnpackingAndPacking<uint16_t, DestType, unpackA16BigToRGBA8, packingFunc>(static_cast<const uint16_t*>(sourceData), width, height, sourceElementsPerPixel, sourceElementsPerRow, destinationData, destinationElementsPerPixel); > break; > } >+ default: >+ ASSERT(false); > } > } > >Index: WebCore/platform/graphics/GraphicsContext3D.h >=================================================================== >--- WebCore/platform/graphics/GraphicsContext3D.h (revision 70163) >+++ WebCore/platform/graphics/GraphicsContext3D.h (working copy) >@@ -566,7 +566,8 @@ public: > kSourceFormatAR16Big, > kSourceFormatA8, > kSourceFormatA16Little, >- kSourceFormatA16Big >+ kSourceFormatA16Big, >+ kSourceFormatUndefined > }; > > //---------------------------------------------------------------------- >Index: WebCore/platform/graphics/cg/GraphicsContext3DCG.cpp >=================================================================== >--- WebCore/platform/graphics/cg/GraphicsContext3DCG.cpp (revision 70163) >+++ WebCore/platform/graphics/cg/GraphicsContext3DCG.cpp (working copy) >@@ -41,6 +41,54 @@ > > namespace WebCore { > >+enum SourceDataFormatBase { >+ kSourceFormatBaseR = 0, >+ kSourceFormatBaseA, >+ kSourceFormatBaseRA, >+ kSourceFormatBaseAR, >+ kSourceFormatBaseRGB, >+ kSourceFormatBaseRGBA, >+ kSourceFormatBaseARGB, >+ kSourceFormatBaseUndefined >+}; >+ >+enum AlphaFormat { >+ kAlphaFormatNone = 0, >+ kAlphaFormatFirst, >+ kAlphaFormatLast, >+}; >+ >+static GraphicsContext3D::SourceDataFormat getSourceDataFormat(unsigned int componentsPerPixel, AlphaFormat alphaFormat, bool bit16, bool bigEndian) >+{ >+ const static SourceDataFormatBase tableFormatBase[4][3] = { // componentsPerPixel x AlphaFormat >+ // kAlphaFormatNone kAlphaFormatFirst kAlphaFormatLast >+ { kSourceFormatBaseR, kSourceFormatBaseA, kSourceFormatBaseA }, // 1 componentsPerPixel >+ { kSourceFormatBaseUndefined, kSourceFormatBaseAR, kSourceFormatBaseRA }, // 2 componentsPerPixel >+ { kSourceFormatBaseRGB, kSourceFormatBaseUndefined, kSourceFormatBaseUndefined }, // 3 componentsPerPixel >+ { kSourceFormatBaseUndefined, kSourceFormatBaseARGB, kSourceFormatBaseRGBA } // 4 componentsPerPixel >+ }; >+ const static GraphicsContext3D::SourceDataFormat tableFormat[7][3] = { // SourceDataFormatBase x bitsPerComponentAndEndian >+ // 8bits 16bits, little endian 16bits, big endian >+ { GraphicsContext3D::kSourceFormatR8, GraphicsContext3D::kSourceFormatR16Little, GraphicsContext3D::kSourceFormatR16Big }, >+ { GraphicsContext3D::kSourceFormatA8, GraphicsContext3D::kSourceFormatA16Little, GraphicsContext3D::kSourceFormatA16Big }, >+ { GraphicsContext3D::kSourceFormatRA8, GraphicsContext3D::kSourceFormatRA16Little, GraphicsContext3D::kSourceFormatRA16Big }, >+ { GraphicsContext3D::kSourceFormatAR8, GraphicsContext3D::kSourceFormatAR16Little, GraphicsContext3D::kSourceFormatAR16Big }, >+ { GraphicsContext3D::kSourceFormatRGB8, GraphicsContext3D::kSourceFormatRGB16Little, GraphicsContext3D::kSourceFormatRGB16Big }, >+ { GraphicsContext3D::kSourceFormatRGBA8, GraphicsContext3D::kSourceFormatRGBA16Little, GraphicsContext3D::kSourceFormatRGBA16Big }, >+ { GraphicsContext3D::kSourceFormatARGB8, GraphicsContext3D::kSourceFormatARGB16Little, GraphicsContext3D::kSourceFormatARGB16Big } >+ }; >+ >+ ASSERT(componentsPerPixel <= 4 && componentsPerPixel > 0); >+ SourceDataFormatBase formatBase = tableFormatBase[componentsPerPixel - 1][alphaFormat]; >+ if (formatBase == kSourceFormatBaseUndefined) >+ return GraphicsContext3D::kSourceFormatUndefined; >+ if (!bit16) >+ return tableFormat[formatBase][0]; >+ if (!bigEndian) >+ return tableFormat[formatBase][1]; >+ return tableFormat[formatBase][2]; >+} >+ > bool GraphicsContext3D::getImageData(Image* image, > unsigned int format, > unsigned int type, >@@ -62,6 +110,7 @@ bool GraphicsContext3D::getImageData(Ima > cgImage = image->nativeImageForCurrentFrame(); > if (!cgImage) > return false; >+ > size_t width = CGImageGetWidth(cgImage); > size_t height = CGImageGetHeight(cgImage); > if (!width || !height) >@@ -73,6 +122,7 @@ bool GraphicsContext3D::getImageData(Ima > if (bitsPerPixel % bitsPerComponent) > return false; > size_t componentsPerPixel = bitsPerPixel / bitsPerComponent; >+ > bool srcByteOrder16Big = false; > if (bitsPerComponent == 16) { > CGBitmapInfo bitInfo = CGImageGetBitmapInfo(cgImage); >@@ -93,8 +143,9 @@ bool GraphicsContext3D::getImageData(Ima > return false; > } > } >- SourceDataFormat srcDataFormat = kSourceFormatRGBA8; >+ > AlphaOp neededAlphaOp = kAlphaDoNothing; >+ AlphaFormat alphaFormat = kAlphaFormatNone; > switch (CGImageGetAlphaInfo(cgImage)) { > case kCGImageAlphaPremultipliedFirst: > // This path is only accessible for MacOS earlier than 10.6.4. >@@ -103,68 +154,17 @@ bool GraphicsContext3D::getImageData(Ima > ASSERT(!image->data()); > if (!premultiplyAlpha) > neededAlphaOp = kAlphaDoUnmultiply; >- switch (componentsPerPixel) { >- case 2: >- if (bitsPerComponent == 8) >- srcDataFormat = kSourceFormatAR8; >- else >- srcDataFormat = srcByteOrder16Big ? kSourceFormatAR16Big : kSourceFormatAR16Little; >- break; >- case 4: >- if (bitsPerComponent == 8) >- srcDataFormat = kSourceFormatARGB8; >- else >- srcDataFormat = srcByteOrder16Big ? kSourceFormatARGB16Big : kSourceFormatARGB16Little; >- break; >- default: >- return false; >- } >+ alphaFormat = kAlphaFormatFirst; > break; > case kCGImageAlphaFirst: > // This path is only accessible for MacOS earlier than 10.6.4. > if (premultiplyAlpha) > neededAlphaOp = kAlphaDoPremultiply; >- switch (componentsPerPixel) { >- case 1: >- if (bitsPerComponent == 8) >- srcDataFormat = kSourceFormatA8; >- else >- srcDataFormat = srcByteOrder16Big ? kSourceFormatA16Big : kSourceFormatA16Little; >- break; >- case 2: >- if (bitsPerComponent == 8) >- srcDataFormat = kSourceFormatAR8; >- else >- srcDataFormat = srcByteOrder16Big ? kSourceFormatAR16Big : kSourceFormatAR16Little; >- break; >- case 4: >- if (bitsPerComponent == 8) >- srcDataFormat = kSourceFormatARGB8; >- else >- srcDataFormat = srcByteOrder16Big ? kSourceFormatARGB16Big : kSourceFormatARGB16Little; >- break; >- default: >- return false; >- } >+ alphaFormat = kAlphaFormatFirst; > break; > case kCGImageAlphaNoneSkipFirst: > // This path is only accessible for MacOS earlier than 10.6.4. >- switch (componentsPerPixel) { >- case 2: >- if (bitsPerComponent == 8) >- srcDataFormat = kSourceFormatAR8; >- else >- srcDataFormat = srcByteOrder16Big ? kSourceFormatAR16Big : kSourceFormatAR16Little; >- break; >- case 4: >- if (bitsPerComponent == 8) >- srcDataFormat = kSourceFormatARGB8; >- else >- srcDataFormat = srcByteOrder16Big ? kSourceFormatARGB16Big : kSourceFormatARGB16Little; >- break; >- default: >- return false; >- } >+ alphaFormat = kAlphaFormatFirst; > break; > case kCGImageAlphaPremultipliedLast: > // This is a special case for texImage2D with HTMLCanvasElement input, >@@ -172,88 +172,26 @@ bool GraphicsContext3D::getImageData(Ima > ASSERT(!image->data()); > if (!premultiplyAlpha) > neededAlphaOp = kAlphaDoUnmultiply; >- switch (componentsPerPixel) { >- case 2: >- if (bitsPerComponent == 8) >- srcDataFormat = kSourceFormatRA8; >- else >- srcDataFormat = srcByteOrder16Big ? kSourceFormatRA16Big : kSourceFormatRA16Little; >- break; >- case 4: >- if (bitsPerComponent == 8) >- srcDataFormat = kSourceFormatRGBA8; >- else >- srcDataFormat = srcByteOrder16Big ? kSourceFormatRGBA16Big : kSourceFormatRGBA16Little; >- break; >- default: >- return false; >- } >+ alphaFormat = kAlphaFormatLast; > break; > case kCGImageAlphaLast: > if (premultiplyAlpha) > neededAlphaOp = kAlphaDoPremultiply; >- switch (componentsPerPixel) { >- case 1: >- if (bitsPerComponent == 8) >- srcDataFormat = kSourceFormatA8; >- else >- srcDataFormat = srcByteOrder16Big ? kSourceFormatA16Big : kSourceFormatA16Little; >- break; >- case 2: >- if (bitsPerComponent == 8) >- srcDataFormat = kSourceFormatRA8; >- else >- srcDataFormat = srcByteOrder16Big ? kSourceFormatRA16Big : kSourceFormatRA16Little; >- break; >- case 4: >- if (bitsPerComponent == 8) >- srcDataFormat = kSourceFormatRGBA8; >- else >- srcDataFormat = srcByteOrder16Big ? kSourceFormatRGBA16Big : kSourceFormatRGBA16Little; >- break; >- default: >- return false; >- } >+ alphaFormat = kAlphaFormatLast; > break; > case kCGImageAlphaNoneSkipLast: >- switch (componentsPerPixel) { >- case 2: >- if (bitsPerComponent == 8) >- srcDataFormat = kSourceFormatRA8; >- else >- srcDataFormat = srcByteOrder16Big ? kSourceFormatRA16Big : kSourceFormatRA16Little; >- break; >- case 4: >- if (bitsPerComponent == 8) >- srcDataFormat = kSourceFormatRGBA8; >- else >- srcDataFormat = srcByteOrder16Big ? kSourceFormatRGBA16Big : kSourceFormatRGBA16Little; >- break; >- default: >- return false; >- } >+ alphaFormat = kAlphaFormatLast; > break; > case kCGImageAlphaNone: >- switch (componentsPerPixel) { >- case 1: >- if (bitsPerComponent == 8) >- srcDataFormat = kSourceFormatR8; >- else >- srcDataFormat = srcByteOrder16Big ? kSourceFormatR16Big : kSourceFormatR16Little; >- break; >- case 3: >- if (bitsPerComponent == 8) >- srcDataFormat = kSourceFormatRGB8; >- else >- srcDataFormat = srcByteOrder16Big ? kSourceFormatRGB16Big : kSourceFormatRGB16Little; >- break; >- default: >- return false; >- } >+ alphaFormat = kAlphaFormatNone; > break; > default: > return false; > } >+ SourceDataFormat srcDataFormat = getSourceDataFormat(componentsPerPixel, alphaFormat, bitsPerComponent == 16, srcByteOrder16Big); >+ if (srcDataFormat == kSourceFormatUndefined) >+ return false; >+ > RetainPtr<CFDataRef> pixelData; > pixelData.adoptCF(CGDataProviderCopyData(CGImageGetDataProvider(cgImage))); > if (!pixelData)
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Flags:
kbr
:
review-
zmo
:
commit-queue-
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 47027
:
71449
|
71451
|
72058