Added license headers to all files. Sync to latest perforce revision.
authorcroachrose <croachrose@2bbb7eff-a529-9590-31e7-b0007b416f81>
Wed, 8 Nov 2006 19:24:48 +0000 (19:24 +0000)
committercroachrose <croachrose@2bbb7eff-a529-9590-31e7-b0007b416f81>
Wed, 8 Nov 2006 19:24:48 +0000 (19:24 +0000)
git-svn-id: http://skia.googlecode.com/svn/trunk@3 2bbb7eff-a529-9590-31e7-b0007b416f81

477 files changed:
include/corecg/Sk64.h
include/corecg/SkBuffer.h
include/corecg/SkChunkAlloc.h
include/corecg/SkEndian.h
include/corecg/SkFDot6.h
include/corecg/SkFixed.h
include/corecg/SkFloatingPoint.h
include/corecg/SkInterpolator.h [new file with mode: 0644]
include/corecg/SkMath.h
include/corecg/SkMatrix.h
include/corecg/SkPerspIter.h [new file with mode: 0644]
include/corecg/SkPoint.h
include/corecg/SkPostConfig.h
include/corecg/SkPreConfig.h
include/corecg/SkRandom.h
include/corecg/SkRect.h
include/corecg/SkRegion.h
include/corecg/SkScalar.h
include/corecg/SkTSearch.h [new file with mode: 0644]
include/corecg/SkTemplates.h
include/corecg/SkThread.h
include/corecg/SkThread_platform.h
include/corecg/SkTypes.h
include/corecg/SkUserConfig.h
include/graphics/Sk1DPathEffect.h
include/graphics/Sk2DPathEffect.h
include/graphics/SkAnimator.h
include/graphics/SkAnimatorView.h
include/graphics/SkApplication.h
include/graphics/SkAvoidXfermode.h
include/graphics/SkBGViewArtist.h
include/graphics/SkBML_WXMLParser.h
include/graphics/SkBML_XMLParser.h
include/graphics/SkBitmap.h
include/graphics/SkBitmapRef.h
include/graphics/SkBlurMaskFilter.h
include/graphics/SkBorderView.h
include/graphics/SkBounder.h
include/graphics/SkCamera.h
include/graphics/SkCanvas.h
include/graphics/SkColor.h
include/graphics/SkColorFilter.h
include/graphics/SkColorPriv.h
include/graphics/SkCornerPathEffect.h
include/graphics/SkCullPoints.h
include/graphics/SkDOM.h
include/graphics/SkDashPathEffect.h
include/graphics/SkDeque.h
include/graphics/SkDescriptor.h
include/graphics/SkDiscretePathEffect.h
include/graphics/SkEmbossMaskFilter.h
include/graphics/SkEvent.h
include/graphics/SkEventSink.h
include/graphics/SkFlattenable.h
include/graphics/SkFontCodec.h
include/graphics/SkFontHost.h
include/graphics/SkGlobals.h
include/graphics/SkGradientShader.h
include/graphics/SkGraphics.h
include/graphics/SkImageDecoder.h
include/graphics/SkImageView.h
include/graphics/SkInterpolator.h [deleted file]
include/graphics/SkJS.h
include/graphics/SkKey.h
include/graphics/SkLayerRasterizer.h
include/graphics/SkMask.h
include/graphics/SkMaskFilter.h
include/graphics/SkMetaData.h
include/graphics/SkNinePatch.h
include/graphics/SkOSFile.h
include/graphics/SkOSMenu.h
include/graphics/SkOSSound.h
include/graphics/SkOSWindow_Mac.h
include/graphics/SkOSWindow_Unix.h
include/graphics/SkOSWindow_Win.h
include/graphics/SkOSWindow_wxwidgets.h
include/graphics/SkPaint.h
include/graphics/SkParse.h
include/graphics/SkParsePaint.h
include/graphics/SkPath.h
include/graphics/SkPathEffect.h
include/graphics/SkPathMeasure.h
include/graphics/SkPorterDuff.h
include/graphics/SkPrefix_Debug_Fixed.h
include/graphics/SkPrefix_Release_Fixed.h
include/graphics/SkProgressBarView.h
include/graphics/SkRasterizer.h
include/graphics/SkRefCnt.h
include/graphics/SkSVGAttribute.h
include/graphics/SkSVGBase.h
include/graphics/SkSVGPaintState.h
include/graphics/SkSVGParser.h
include/graphics/SkSVGTypes.h
include/graphics/SkScalerContext.h
include/graphics/SkScrollBarView.h
include/graphics/SkShader.h
include/graphics/SkShaderExtras.h
include/graphics/SkStackViewLayout.h
include/graphics/SkStdLib_Redirect.h
include/graphics/SkStream.h
include/graphics/SkStream_Win.h
include/graphics/SkString.h
include/graphics/SkStroke.h
include/graphics/SkSystemEventTypes.h
include/graphics/SkTDArray.h
include/graphics/SkTDStack.h
include/graphics/SkTDict.h
include/graphics/SkTSearch.h [deleted file]
include/graphics/SkTextBox.h
include/graphics/SkTextLayout.h [deleted file]
include/graphics/SkTime.h
include/graphics/SkTransparentShader.h
include/graphics/SkTypeface.h
include/graphics/SkUnitMapper.h
include/graphics/SkUtils.h
include/graphics/SkView.h
include/graphics/SkViewInflate.h
include/graphics/SkWidget.h
include/graphics/SkWidgetViews.h
include/graphics/SkWindow.h
include/graphics/SkXMLParser.h
include/graphics/SkXMLWriter.h
include/graphics/SkXfermode.h
libs/corecg/Makefile
libs/corecg/Sk64.cpp
libs/corecg/SkBuffer.cpp
libs/corecg/SkChunkAlloc.cpp
libs/corecg/SkCordic.cpp
libs/corecg/SkCordic.h
libs/corecg/SkDebug.cpp
libs/corecg/SkDebug_stdio.cpp
libs/corecg/SkFP.h
libs/corecg/SkFloat.cpp
libs/corecg/SkFloat.h
libs/corecg/SkInterpolator.cpp [new file with mode: 0644]
libs/corecg/SkMath.cpp
libs/corecg/SkMatrix.cpp
libs/corecg/SkMemory_stdlib.cpp
libs/corecg/SkPoint.cpp
libs/corecg/SkRect.cpp
libs/corecg/SkRegion.cpp
libs/corecg/SkRegionPriv.h
libs/corecg/SkSinTable.h
libs/corecg/SkTSort.h
libs/graphics/Makefile
libs/graphics/animator/SkAnimate.h
libs/graphics/animator/SkAnimateActive.cpp
libs/graphics/animator/SkAnimateActive.h
libs/graphics/animator/SkAnimateBase.cpp
libs/graphics/animator/SkAnimateBase.h
libs/graphics/animator/SkAnimateField.cpp
libs/graphics/animator/SkAnimateMaker.cpp
libs/graphics/animator/SkAnimateMaker.h
libs/graphics/animator/SkAnimateProperties.h
libs/graphics/animator/SkAnimateSet.cpp
libs/graphics/animator/SkAnimateSet.h
libs/graphics/animator/SkAnimator.cpp
libs/graphics/animator/SkAnimatorScript.cpp
libs/graphics/animator/SkAnimatorScript.h
libs/graphics/animator/SkBase64.cpp
libs/graphics/animator/SkBase64.h
libs/graphics/animator/SkBoundable.cpp
libs/graphics/animator/SkBoundable.h
libs/graphics/animator/SkBuildCondensedInfo.cpp
libs/graphics/animator/SkCondensedDebug.cpp
libs/graphics/animator/SkCondensedRelease.cpp
libs/graphics/animator/SkDisplayAdd.cpp
libs/graphics/animator/SkDisplayAdd.h
libs/graphics/animator/SkDisplayApply.cpp
libs/graphics/animator/SkDisplayApply.h
libs/graphics/animator/SkDisplayBounds.cpp
libs/graphics/animator/SkDisplayBounds.h
libs/graphics/animator/SkDisplayEvent.cpp
libs/graphics/animator/SkDisplayEvent.h
libs/graphics/animator/SkDisplayEvents.cpp
libs/graphics/animator/SkDisplayEvents.h
libs/graphics/animator/SkDisplayInclude.cpp
libs/graphics/animator/SkDisplayInclude.h
libs/graphics/animator/SkDisplayInput.cpp
libs/graphics/animator/SkDisplayInput.h
libs/graphics/animator/SkDisplayList.cpp
libs/graphics/animator/SkDisplayList.h
libs/graphics/animator/SkDisplayMath.cpp
libs/graphics/animator/SkDisplayMath.h
libs/graphics/animator/SkDisplayMovie.cpp
libs/graphics/animator/SkDisplayMovie.h
libs/graphics/animator/SkDisplayNumber.cpp
libs/graphics/animator/SkDisplayNumber.h
libs/graphics/animator/SkDisplayPost.cpp
libs/graphics/animator/SkDisplayPost.h
libs/graphics/animator/SkDisplayRandom.cpp
libs/graphics/animator/SkDisplayRandom.h
libs/graphics/animator/SkDisplayScreenplay.cpp
libs/graphics/animator/SkDisplayScreenplay.h
libs/graphics/animator/SkDisplayType.cpp
libs/graphics/animator/SkDisplayType.h
libs/graphics/animator/SkDisplayTypes.cpp
libs/graphics/animator/SkDisplayTypes.h
libs/graphics/animator/SkDisplayXMLParser.cpp
libs/graphics/animator/SkDisplayXMLParser.h
libs/graphics/animator/SkDisplayable.cpp
libs/graphics/animator/SkDisplayable.h
libs/graphics/animator/SkDraw3D.cpp
libs/graphics/animator/SkDraw3D.h
libs/graphics/animator/SkDrawBitmap.cpp
libs/graphics/animator/SkDrawBitmap.h
libs/graphics/animator/SkDrawBlur.cpp
libs/graphics/animator/SkDrawBlur.h
libs/graphics/animator/SkDrawClip.cpp
libs/graphics/animator/SkDrawClip.h
libs/graphics/animator/SkDrawColor.cpp
libs/graphics/animator/SkDrawColor.h
libs/graphics/animator/SkDrawDash.cpp
libs/graphics/animator/SkDrawDash.h
libs/graphics/animator/SkDrawDiscrete.cpp
libs/graphics/animator/SkDrawDiscrete.h
libs/graphics/animator/SkDrawEmboss.cpp
libs/graphics/animator/SkDrawEmboss.h
libs/graphics/animator/SkDrawExtraPathEffect.cpp
libs/graphics/animator/SkDrawFull.cpp
libs/graphics/animator/SkDrawFull.h
libs/graphics/animator/SkDrawGradient.cpp
libs/graphics/animator/SkDrawGradient.h
libs/graphics/animator/SkDrawGroup.cpp
libs/graphics/animator/SkDrawGroup.h
libs/graphics/animator/SkDrawLine.cpp
libs/graphics/animator/SkDrawLine.h
libs/graphics/animator/SkDrawMatrix.cpp
libs/graphics/animator/SkDrawMatrix.h
libs/graphics/animator/SkDrawOval.cpp
libs/graphics/animator/SkDrawOval.h
libs/graphics/animator/SkDrawPaint.cpp
libs/graphics/animator/SkDrawPaint.h
libs/graphics/animator/SkDrawPath.cpp
libs/graphics/animator/SkDrawPath.h
libs/graphics/animator/SkDrawPoint.cpp
libs/graphics/animator/SkDrawPoint.h
libs/graphics/animator/SkDrawRectangle.cpp
libs/graphics/animator/SkDrawRectangle.h
libs/graphics/animator/SkDrawSaveLayer.cpp
libs/graphics/animator/SkDrawSaveLayer.h
libs/graphics/animator/SkDrawShader.cpp
libs/graphics/animator/SkDrawShader.h
libs/graphics/animator/SkDrawText.cpp
libs/graphics/animator/SkDrawText.h
libs/graphics/animator/SkDrawTextBox.cpp
libs/graphics/animator/SkDrawTextBox.h
libs/graphics/animator/SkDrawTo.cpp
libs/graphics/animator/SkDrawTo.h
libs/graphics/animator/SkDrawTransparentShader.cpp
libs/graphics/animator/SkDrawTransparentShader.h
libs/graphics/animator/SkDrawable.cpp
libs/graphics/animator/SkDrawable.h
libs/graphics/animator/SkDump.cpp
libs/graphics/animator/SkDump.h
libs/graphics/animator/SkExtras.h
libs/graphics/animator/SkGetCondensedInfo.cpp
libs/graphics/animator/SkHitClear.cpp
libs/graphics/animator/SkHitClear.h
libs/graphics/animator/SkHitTest.cpp
libs/graphics/animator/SkHitTest.h
libs/graphics/animator/SkIntArray.h
libs/graphics/animator/SkInterpolator.cpp [deleted file]
libs/graphics/animator/SkMatrixParts.cpp
libs/graphics/animator/SkMatrixParts.h
libs/graphics/animator/SkMemberInfo.cpp
libs/graphics/animator/SkMemberInfo.h
libs/graphics/animator/SkOperand.h
libs/graphics/animator/SkOperandInterpolator.h
libs/graphics/animator/SkOperandIterpolator.cpp
libs/graphics/animator/SkPaintParts.cpp
libs/graphics/animator/SkPaintParts.h
libs/graphics/animator/SkPathParts.cpp
libs/graphics/animator/SkPathParts.h
libs/graphics/animator/SkPostParts.cpp
libs/graphics/animator/SkPostParts.h
libs/graphics/animator/SkSVGPath.cpp
libs/graphics/animator/SkScript.cpp
libs/graphics/animator/SkScript.h
libs/graphics/animator/SkScriptDecompile.cpp
libs/graphics/animator/SkSnapshot.cpp
libs/graphics/animator/SkSnapshot.h
libs/graphics/animator/SkTDArray_Experimental.h
libs/graphics/animator/SkTextOnPath.cpp
libs/graphics/animator/SkTextOnPath.h
libs/graphics/animator/SkTextToPath.cpp
libs/graphics/animator/SkTextToPath.h
libs/graphics/animator/SkTime.cpp
libs/graphics/animator/SkTypedArray.cpp
libs/graphics/animator/SkTypedArray.h
libs/graphics/animator/SkXMLAnimatorWriter.cpp
libs/graphics/animator/SkXMLAnimatorWriter.h
libs/graphics/effects/Sk1DPathEffect.cpp
libs/graphics/effects/Sk2DPathEffect.cpp
libs/graphics/effects/SkAvoidXfermode.cpp
libs/graphics/effects/SkBlurMask.cpp
libs/graphics/effects/SkBlurMask.h
libs/graphics/effects/SkBlurMaskFilter.cpp
libs/graphics/effects/SkCamera.cpp
libs/graphics/effects/SkColorFilters.cpp
libs/graphics/effects/SkCornerPathEffect.cpp
libs/graphics/effects/SkCullPoints.cpp
libs/graphics/effects/SkDashPathEffect.cpp
libs/graphics/effects/SkDiscretePathEffect.cpp
libs/graphics/effects/SkEmbossMask.cpp
libs/graphics/effects/SkEmbossMask.h
libs/graphics/effects/SkEmbossMaskFilter.cpp
libs/graphics/effects/SkEmbossMask_Table.h
libs/graphics/effects/SkGradientShader.cpp
libs/graphics/effects/SkLayerRasterizer.cpp
libs/graphics/effects/SkNinePatch.cpp
libs/graphics/effects/SkRadialGradient_Table.h
libs/graphics/effects/SkShaderExtras.cpp
libs/graphics/effects/SkTransparentShader.cpp
libs/graphics/images/SkBitmapRef.cpp
libs/graphics/images/SkBitmapRefPriv.h
libs/graphics/images/SkImageDecoder.cpp
libs/graphics/images/SkImageDecoder_libgif.cpp
libs/graphics/images/SkImageDecoder_libico.cpp [new file with mode: 0644]
libs/graphics/images/SkImageDecoder_libjpeg.cpp
libs/graphics/images/SkImageDecoder_libpng.cpp
libs/graphics/images/SkImageDecoder_zbm.cpp [new file with mode: 0644]
libs/graphics/images/SkStream.cpp
libs/graphics/ports/SkFontHost_FONTPATH.cpp
libs/graphics/ports/SkFontHost_FreeType.cpp
libs/graphics/ports/SkFontHost_android.cpp [moved from libs/graphics/ports/SkFontHost.cpp with 78% similarity]
libs/graphics/ports/SkFontHost_none.cpp
libs/graphics/ports/SkGlobals_global.cpp
libs/graphics/ports/SkImageDecoder_Factory.cpp
libs/graphics/ports/SkOSEvent_android.cpp
libs/graphics/ports/SkOSEvent_dummy.cpp
libs/graphics/ports/SkOSFile_stdio.cpp
libs/graphics/ports/SkThread_none.cpp
libs/graphics/ports/SkTime_Unix.cpp
libs/graphics/ports/SkXMLParser_empty.cpp
libs/graphics/ports/SkXMLParser_expat.cpp
libs/graphics/ports/SkXMLParser_tinyxml.cpp
libs/graphics/sgl/ARGB32_Clamp_Bilinear_BitmapShader.cpp [new file with mode: 0644]
libs/graphics/sgl/SkAlphaRuns.cpp
libs/graphics/sgl/SkAntiRun.h
libs/graphics/sgl/SkBitmap.cpp
libs/graphics/sgl/SkBitmapSampler.cpp
libs/graphics/sgl/SkBitmapSampler.h
libs/graphics/sgl/SkBitmapSamplerTemplate.h
libs/graphics/sgl/SkBitmapShader.cpp
libs/graphics/sgl/SkBitmapShader.h
libs/graphics/sgl/SkBitmapShader16BilerpTemplate.h
libs/graphics/sgl/SkBitmapShaderTemplate.h
libs/graphics/sgl/SkBlitBWMaskTemplate.h
libs/graphics/sgl/SkBlitter.cpp
libs/graphics/sgl/SkBlitter.h
libs/graphics/sgl/SkBlitter_A1.cpp
libs/graphics/sgl/SkBlitter_A8.cpp
libs/graphics/sgl/SkBlitter_ARGB32.cpp
libs/graphics/sgl/SkBlitter_RGB16.cpp
libs/graphics/sgl/SkBlitter_Sprite.cpp
libs/graphics/sgl/SkCanvas.cpp
libs/graphics/sgl/SkColor.cpp
libs/graphics/sgl/SkColorFilter.cpp
libs/graphics/sgl/SkColorTable.cpp
libs/graphics/sgl/SkCoreBlitters.h
libs/graphics/sgl/SkDeque.cpp
libs/graphics/sgl/SkDraw.cpp
libs/graphics/sgl/SkDraw.h
libs/graphics/sgl/SkEdge.cpp
libs/graphics/sgl/SkEdge.h
libs/graphics/sgl/SkFP.h
libs/graphics/sgl/SkFilterProc.cpp
libs/graphics/sgl/SkFilterProc.h
libs/graphics/sgl/SkGeometry.cpp
libs/graphics/sgl/SkGeometry.h
libs/graphics/sgl/SkGlobals.cpp
libs/graphics/sgl/SkGlyphCache.cpp
libs/graphics/sgl/SkGlyphCache.h
libs/graphics/sgl/SkGraphics.cpp
libs/graphics/sgl/SkMaskFilter.cpp
libs/graphics/sgl/SkPaint.cpp
libs/graphics/sgl/SkPath.cpp
libs/graphics/sgl/SkPathEffect.cpp
libs/graphics/sgl/SkPathMeasure.cpp
libs/graphics/sgl/SkProcSpriteBlitter.cpp
libs/graphics/sgl/SkRasterizer.cpp
libs/graphics/sgl/SkRefCnt.cpp
libs/graphics/sgl/SkRegion_path.cpp
libs/graphics/sgl/SkScalerContext.cpp
libs/graphics/sgl/SkScan.cpp
libs/graphics/sgl/SkScan.h
libs/graphics/sgl/SkScanPriv.h
libs/graphics/sgl/SkScan_AntiPath.cpp
libs/graphics/sgl/SkScan_Antihair.cpp
libs/graphics/sgl/SkScan_Hairline.cpp
libs/graphics/sgl/SkScan_Path.cpp
libs/graphics/sgl/SkShader.cpp
libs/graphics/sgl/SkSinTable.h
libs/graphics/sgl/SkSpriteBlitter.h
libs/graphics/sgl/SkSpriteBlitterTemplate.h
libs/graphics/sgl/SkSpriteBlitter_ARGB32.cpp
libs/graphics/sgl/SkSpriteBlitter_RGB16.cpp
libs/graphics/sgl/SkString.cpp
libs/graphics/sgl/SkStroke.cpp
libs/graphics/sgl/SkStrokerPriv.cpp
libs/graphics/sgl/SkStrokerPriv.h
libs/graphics/sgl/SkTSearch.cpp
libs/graphics/sgl/SkTSort.h
libs/graphics/sgl/SkTemplatesPriv.h
libs/graphics/sgl/SkTextLayout.cpp [deleted file]
libs/graphics/sgl/SkUtils.cpp
libs/graphics/sgl/SkXfermode.cpp
libs/graphics/svg/SkSVG.cpp
libs/graphics/svg/SkSVGCircle.cpp
libs/graphics/svg/SkSVGCircle.h
libs/graphics/svg/SkSVGClipPath.cpp
libs/graphics/svg/SkSVGClipPath.h
libs/graphics/svg/SkSVGDefs.cpp
libs/graphics/svg/SkSVGDefs.h
libs/graphics/svg/SkSVGElements.cpp
libs/graphics/svg/SkSVGElements.h
libs/graphics/svg/SkSVGEllipse.cpp
libs/graphics/svg/SkSVGEllipse.h
libs/graphics/svg/SkSVGFeColorMatrix.cpp
libs/graphics/svg/SkSVGFeColorMatrix.h
libs/graphics/svg/SkSVGFilter.cpp
libs/graphics/svg/SkSVGFilter.h
libs/graphics/svg/SkSVGG.cpp
libs/graphics/svg/SkSVGG.h
libs/graphics/svg/SkSVGGradient.cpp
libs/graphics/svg/SkSVGGradient.h
libs/graphics/svg/SkSVGGroup.cpp
libs/graphics/svg/SkSVGGroup.h
libs/graphics/svg/SkSVGImage.cpp
libs/graphics/svg/SkSVGImage.h
libs/graphics/svg/SkSVGLine.cpp
libs/graphics/svg/SkSVGLine.h
libs/graphics/svg/SkSVGLinearGradient.cpp
libs/graphics/svg/SkSVGLinearGradient.h
libs/graphics/svg/SkSVGMask.cpp
libs/graphics/svg/SkSVGMask.h
libs/graphics/svg/SkSVGMetadata.cpp
libs/graphics/svg/SkSVGMetadata.h
libs/graphics/svg/SkSVGPaintState.cpp
libs/graphics/svg/SkSVGParser.cpp
libs/graphics/svg/SkSVGPath.cpp
libs/graphics/svg/SkSVGPath.h
libs/graphics/svg/SkSVGPolygon.cpp
libs/graphics/svg/SkSVGPolygon.h
libs/graphics/svg/SkSVGPolyline.cpp
libs/graphics/svg/SkSVGPolyline.h
libs/graphics/svg/SkSVGRadialGradient.cpp
libs/graphics/svg/SkSVGRadialGradient.h
libs/graphics/svg/SkSVGRect.cpp
libs/graphics/svg/SkSVGRect.h
libs/graphics/svg/SkSVGSVG.cpp
libs/graphics/svg/SkSVGSVG.h
libs/graphics/svg/SkSVGStop.cpp
libs/graphics/svg/SkSVGStop.h
libs/graphics/svg/SkSVGSymbol.cpp
libs/graphics/svg/SkSVGSymbol.h
libs/graphics/svg/SkSVGText.cpp
libs/graphics/svg/SkSVGText.h
libs/graphics/svg/SkSVGUse.cpp
libs/graphics/svg/SkSVGUse.h
libs/graphics/text/ATextEntry.h
libs/graphics/views/SkEvent.cpp
libs/graphics/views/SkEventSink.cpp
libs/graphics/views/SkMetaData.cpp
libs/graphics/views/SkTagList.cpp
libs/graphics/views/SkTagList.h
libs/graphics/views/SkTextBox.cpp
libs/graphics/xml/SkBML_Verbs.h
libs/graphics/xml/SkBML_XMLParser.cpp
libs/graphics/xml/SkDOM.cpp
libs/graphics/xml/SkJS.cpp
libs/graphics/xml/SkJSDisplayable.cpp
libs/graphics/xml/SkParse.cpp
libs/graphics/xml/SkParseColor.cpp
libs/graphics/xml/SkXMLParser.cpp
libs/graphics/xml/SkXMLWriter.cpp

index ed67b1f..031b0cc 100644 (file)
+/* include/corecg/Sk64.h
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #ifndef Sk64_DEFINED
 #define Sk64_DEFINED
 
 #include "SkMath.h"
 
-/**    \class Sk64
+/** \class Sk64
 
-       Sk64 is a 64-bit math package that does not require long long support from the compiler.
+    Sk64 is a 64-bit math package that does not require long long support from the compiler.
 */
 struct Sk64 {
-       int32_t  fHi;   //!< the high 32 bits of the number (including sign)
-       uint32_t fLo;   //!< the low 32 bits of the number
-
-       /**     Returns non-zero if the Sk64 can be represented as a signed 32 bit integer
-       */
-       SkBool  is32() const { return fHi == ((int32_t)fLo >> 31); }
-       /**     Returns non-zero if the Sk64 cannot be represented as a signed 32 bit integer
-       */
-       SkBool  is64() const { return fHi != ((int32_t)fLo >> 31); }
-       /**     Returns non-zero if the Sk64 can be represented as a signed 48 bit integer. Used to know
-               if we can shift the value down by 16 to treat it as a SkFixed.
-       */
-       SkBool  isFixed() const;
-
-       /**     Return the signed 32 bit integer equivalent. Asserts that is32() returns non-zero.
-       */
-       int32_t get32() const { SkASSERT(this->is32()); return (int32_t)fLo; }
-       /**     Return the number >> 16. Asserts that this does not loose any significant high bits.
-       */
-       SkFixed getFixed() const
-       {
-               SkASSERT(this->isFixed());
-
-               uint32_t sum = fLo + (1 << 15);
-               int32_t  hi = fHi;
-               if (sum < fLo)
-                       hi += 1;
-
-               return (hi << 16) | (sum >> 16);
-       }
-       /**     Return the number >> 30. Asserts that this does not loose any significant high bits.
-       */
-       SkFract getFract() const;
-
-       /**     Returns the square-root of the number as a signed 32 bit value.
-       */
-       int32_t getSqrt() const;
-
-       /**     Returns the number of leading zeros of the absolute value of this.
-               Will return in the range [0..64]
-       */
-       int     getClzAbs() const;
-
-       /**     Returns non-zero if the number is zero
-       */
-       SkBool  isZero() const { return (fHi | fLo) == 0; }
-       /**     Returns non-zero if the number is non-zero
-       */
-       SkBool  nonZero() const { return fHi | fLo; }
-       /**     Returns non-zero if the number is negative (number < 0)
-       */
-       SkBool  isNeg() const { return (uint32_t)fHi >> 31; }
-       /**     Returns non-zero if the number is positive (number > 0)
-       */
-       SkBool  isPos() const { return ~(fHi >> 31) & (fHi | fLo); }
-       /**     Returns -1,0,+1 based on the sign of the number
-       */
-       int             sign() const { return (fHi >> 31) | Sk32ToBool(fHi | fLo); }
-       /**     Negate the number
-       */
-       void    negate();
-
-       /**     If the number < 0, negate the number
-       */
-       void    abs();
-
-       /**     Returns the number of bits needed to shift the Sk64 to the right
-               in order to make it fit in a signed 32 bit integer.
-       */
-       int             shiftToMake32() const;
-
-       /**     Set the number to zero
-       */
-       void    setZero() { fHi = fLo = 0; }
-       /**     Set the high and low 32 bit values of the number
-       */
-       void    set(int32_t hi, uint32_t lo) { fHi = hi; fLo = lo; }
-       /**     Set the number to the specified 32 bit integer
-       */
-       void    set(int32_t a) { fHi = a >> 31; fLo = a; }
-       /**     Set the number to the product of the two 32 bit integers
-       */
-       void    setMul(int32_t a, int32_t b);
-
-       /** extract 32bits after shifting right by bitCount.
-               Note: itCount must be [0..63].
-               Asserts that no significant high bits were lost.
-       */
-       int32_t getShiftRight(unsigned bitCount) const;
-       /**     Shift the number left by the specified number of bits.
-               @param bits     How far to shift left, must be [0..63]
-       */
-       void    shiftLeft(unsigned bits);
-       /**     Shift the number right by the specified number of bits.
-               @param bits     How far to shift right, must be [0..63]. This
-               performs an arithmetic right-shift (sign extending).
-       */
-       void    shiftRight(unsigned bits);
-       /**     Shift the number right by the specified number of bits, but
-               round the result.
-               @param bits     How far to shift right, must be [0..63]. This
-               performs an arithmetic right-shift (sign extending).
-       */
-       void    roundRight(unsigned bits);
-
-       /**     Add the specified 32 bit integer to the number
-       */
-       void    add(int32_t lo)
-       {
-               int32_t  hi = lo >> 31; // 0 or -1
-               uint32_t sum = fLo + (uint32_t)lo;
-
-               fHi = fHi + hi + (sum < fLo);
-               fLo = sum;
-       }
-       /**     Add the specified Sk64 to the number
-       */
-       void    add(int32_t hi, uint32_t lo)
-       {
-               uint32_t sum = fLo + lo;
-
-               fHi = fHi + hi + (sum < fLo);
-               fLo = sum;
-       }
-       /**     Add the specified Sk64 to the number
-       */
-       void    add(const Sk64& other) { this->add(other.fHi, other.fLo); }
-       /**     Subtract the specified Sk64 from the number. (*this) = (*this) - num
-       */
-       void    sub(const Sk64& num);
-       /**     Subtract the number from the specified Sk64. (*this) = num - (*this)
-       */
-       void    rsub(const Sk64& num);
-       /**     Multiply the number by the specified 32 bit integer
-       */
-       void    mul(int32_t);
-
-       enum DivOptions {
-               kTrunc_DivOption,       //!< truncate the result when calling div()
-               kRound_DivOption        //!< round the result when calling div()
-       };
-       /**     Divide the number by the specified 32 bit integer, using the specified
-               divide option (either truncate or round).
-       */
-       void    div(int32_t, DivOptions);
-
-       SkFixed addGetFixed(const Sk64& other) const
-       {
-               return this->addGetFixed(other.fHi, other.fLo);
-       }
-       SkFixed addGetFixed(int32_t hi, uint32_t lo) const
-       {
+    int32_t  fHi;   //!< the high 32 bits of the number (including sign)
+    uint32_t fLo;   //!< the low 32 bits of the number
+
+    /** Returns non-zero if the Sk64 can be represented as a signed 32 bit integer
+    */
+    SkBool  is32() const { return fHi == ((int32_t)fLo >> 31); }
+    /** Returns non-zero if the Sk64 cannot be represented as a signed 32 bit integer
+    */
+    SkBool  is64() const { return fHi != ((int32_t)fLo >> 31); }
+    /** Returns non-zero if the Sk64 can be represented as a signed 48 bit integer. Used to know
+        if we can shift the value down by 16 to treat it as a SkFixed.
+    */
+    SkBool  isFixed() const;
+
+    /** Return the signed 32 bit integer equivalent. Asserts that is32() returns non-zero.
+    */
+    int32_t get32() const { SkASSERT(this->is32()); return (int32_t)fLo; }
+    /** Return the number >> 16. Asserts that this does not loose any significant high bits.
+    */
+    SkFixed getFixed() const
+    {
+        SkASSERT(this->isFixed());
+
+        uint32_t sum = fLo + (1 << 15);
+        int32_t  hi = fHi;
+        if (sum < fLo)
+            hi += 1;
+
+        return (hi << 16) | (sum >> 16);
+    }
+    /** Return the number >> 30. Asserts that this does not loose any significant high bits.
+    */
+    SkFract getFract() const;
+
+    /** Returns the square-root of the number as a signed 32 bit value.
+    */
+    int32_t getSqrt() const;
+
+    /** Returns the number of leading zeros of the absolute value of this.
+        Will return in the range [0..64]
+    */
+    int getClzAbs() const;
+
+    /** Returns non-zero if the number is zero
+    */
+    SkBool  isZero() const { return (fHi | fLo) == 0; }
+    /** Returns non-zero if the number is non-zero
+    */
+    SkBool  nonZero() const { return fHi | fLo; }
+    /** Returns non-zero if the number is negative (number < 0)
+    */
+    SkBool  isNeg() const { return (uint32_t)fHi >> 31; }
+    /** Returns non-zero if the number is positive (number > 0)
+    */
+    SkBool  isPos() const { return ~(fHi >> 31) & (fHi | fLo); }
+    /** Returns -1,0,+1 based on the sign of the number
+    */
+    int     sign() const { return (fHi >> 31) | Sk32ToBool(fHi | fLo); }
+    /** Negate the number
+    */
+    void    negate();
+
+    /** If the number < 0, negate the number
+    */
+    void    abs();
+
+    /** Returns the number of bits needed to shift the Sk64 to the right
+        in order to make it fit in a signed 32 bit integer.
+    */
+    int     shiftToMake32() const;
+
+    /** Set the number to zero
+    */
+    void    setZero() { fHi = fLo = 0; }
+    /** Set the high and low 32 bit values of the number
+    */
+    void    set(int32_t hi, uint32_t lo) { fHi = hi; fLo = lo; }
+    /** Set the number to the specified 32 bit integer
+    */
+    void    set(int32_t a) { fHi = a >> 31; fLo = a; }
+    /** Set the number to the product of the two 32 bit integers
+    */
+    void    setMul(int32_t a, int32_t b);
+
+    /** extract 32bits after shifting right by bitCount.
+        Note: itCount must be [0..63].
+        Asserts that no significant high bits were lost.
+    */
+    int32_t getShiftRight(unsigned bitCount) const;
+    /** Shift the number left by the specified number of bits.
+        @param bits How far to shift left, must be [0..63]
+    */
+    void    shiftLeft(unsigned bits);
+    /** Shift the number right by the specified number of bits.
+        @param bits How far to shift right, must be [0..63]. This
+        performs an arithmetic right-shift (sign extending).
+    */
+    void    shiftRight(unsigned bits);
+    /** Shift the number right by the specified number of bits, but
+        round the result.
+        @param bits How far to shift right, must be [0..63]. This
+        performs an arithmetic right-shift (sign extending).
+    */
+    void    roundRight(unsigned bits);
+
+    /** Add the specified 32 bit integer to the number
+    */
+    void    add(int32_t lo)
+    {
+        int32_t  hi = lo >> 31; // 0 or -1
+        uint32_t sum = fLo + (uint32_t)lo;
+
+        fHi = fHi + hi + (sum < fLo);
+        fLo = sum;
+    }
+    /** Add the specified Sk64 to the number
+    */
+    void    add(int32_t hi, uint32_t lo)
+    {
+        uint32_t sum = fLo + lo;
+
+        fHi = fHi + hi + (sum < fLo);
+        fLo = sum;
+    }
+    /** Add the specified Sk64 to the number
+    */
+    void    add(const Sk64& other) { this->add(other.fHi, other.fLo); }
+    /** Subtract the specified Sk64 from the number. (*this) = (*this) - num
+    */
+    void    sub(const Sk64& num);
+    /** Subtract the number from the specified Sk64. (*this) = num - (*this)
+    */
+    void    rsub(const Sk64& num);
+    /** Multiply the number by the specified 32 bit integer
+    */
+    void    mul(int32_t);
+
+    enum DivOptions {
+        kTrunc_DivOption,   //!< truncate the result when calling div()
+        kRound_DivOption    //!< round the result when calling div()
+    };
+    /** Divide the number by the specified 32 bit integer, using the specified
+        divide option (either truncate or round).
+    */
+    void    div(int32_t, DivOptions);
+
+    SkFixed addGetFixed(const Sk64& other) const
+    {
+        return this->addGetFixed(other.fHi, other.fLo);
+    }
+    SkFixed addGetFixed(int32_t hi, uint32_t lo) const
+    {
 #ifdef SK_DEBUG
-               Sk64    tmp(*this);
-               tmp.add(hi, lo);
+        Sk64    tmp(*this);
+        tmp.add(hi, lo);
 #endif
-               uint32_t sum = fLo + lo + (1 << 15);
-
-               hi = fHi + hi + (sum < fLo);
-               hi = (hi << 16) | (sum >> 16);
-
-               SkASSERT(hi == tmp.getFixed());
-               return hi;
-       }
-
-       /**     Return the result of dividing the number by denom, treating the answer
-               as a SkFixed. (*this) << 16 / denom. It is an error for denom to be 0.
-       */
-       SkFixed getFixedDiv(const Sk64& denom) const;
-
-       friend bool operator==(const Sk64& a, const Sk64& b)
-       {
-               return a.fHi == b.fHi && a.fLo == b.fLo;
-       }
-       friend bool operator!=(const Sk64& a, const Sk64& b)
-       {
-               return a.fHi != b.fHi || a.fLo != b.fLo;
-       }
-       friend bool operator<(const Sk64& a, const Sk64& b)
-       {
-               return a.fHi < b.fHi || a.fHi == b.fHi && a.fLo < b.fLo;
-       }
-       friend bool operator<=(const Sk64& a, const Sk64& b)
-       {
-               return a.fHi < b.fHi || a.fHi == b.fHi && a.fLo <= b.fLo;
-       }
-       friend bool operator>(const Sk64& a, const Sk64& b)
-       {
-               return a.fHi > b.fHi || a.fHi == b.fHi && a.fLo > b.fLo;
-       }
-       friend bool operator>=(const Sk64& a, const Sk64& b)
-       {
-               return a.fHi > b.fHi || a.fHi == b.fHi && a.fLo >= b.fLo;
-       }
+        uint32_t sum = fLo + lo + (1 << 15);
+
+        hi = fHi + hi + (sum < fLo);
+        hi = (hi << 16) | (sum >> 16);
+
+        SkASSERT(hi == tmp.getFixed());
+        return hi;
+    }
+
+    /** Return the result of dividing the number by denom, treating the answer
+        as a SkFixed. (*this) << 16 / denom. It is an error for denom to be 0.
+    */
+    SkFixed getFixedDiv(const Sk64& denom) const;
+
+    friend bool operator==(const Sk64& a, const Sk64& b)
+    {
+        return a.fHi == b.fHi && a.fLo == b.fLo;
+    }
+    friend bool operator!=(const Sk64& a, const Sk64& b)
+    {
+        return a.fHi != b.fHi || a.fLo != b.fLo;
+    }
+    friend bool operator<(const Sk64& a, const Sk64& b)
+    {
+        return a.fHi < b.fHi || a.fHi == b.fHi && a.fLo < b.fLo;
+    }
+    friend bool operator<=(const Sk64& a, const Sk64& b)
+    {
+        return a.fHi < b.fHi || a.fHi == b.fHi && a.fLo <= b.fLo;
+    }
+    friend bool operator>(const Sk64& a, const Sk64& b)
+    {
+        return a.fHi > b.fHi || a.fHi == b.fHi && a.fLo > b.fLo;
+    }
+    friend bool operator>=(const Sk64& a, const Sk64& b)
+    {
+        return a.fHi > b.fHi || a.fHi == b.fHi && a.fLo >= b.fLo;
+    }
 
 #ifdef SK_CAN_USE_LONGLONG
-       SkLONGLONG getLongLong() const;
+    SkLONGLONG getLongLong() const;
 #endif
 
 #ifdef SK_DEBUG
   /** @cond UNIT_TEST */
-       static void UnitTest();
+    static void UnitTest();
   /** @endcond */
 #endif
 };
index cd670fc..cbbf747 100644 (file)
@@ -1,3 +1,20 @@
+/* include/corecg/SkBuffer.h
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #ifndef SkBuffer_DEFINED
 #define SkBuffer_DEFINED
 
index 3070af8..78777d3 100644 (file)
@@ -1,3 +1,20 @@
+/* include/corecg/SkChunkAlloc.h
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #ifndef SkChunkAlloc_DEFINED
 #define SkChunkAlloc_DEFINED
 
 
 class SkChunkAlloc {
 public:
-       SkChunkAlloc(size_t minSize) : fBlock(nil), fMinSize(SkAlign4(minSize)) {}
-       ~SkChunkAlloc();
+    SkChunkAlloc(size_t minSize) : fBlock(nil), fMinSize(SkAlign4(minSize)) {}
+    ~SkChunkAlloc();
 
-       void    reset();
+    void    reset();
 
-       enum AllocFailType {
-               kReturnNil_AllocFailType,
-               kThrow_AllocFailType
-       };
-       void*   alloc(size_t bytes, AllocFailType);
-       
+    enum AllocFailType {
+        kReturnNil_AllocFailType,
+        kThrow_AllocFailType
+    };
+    void*   alloc(size_t bytes, AllocFailType);
+    
 private:
-       struct Block {
-               Block*  fNext;
-               size_t  fFreeSize;
-               char*   fFreePtr;
-               // data[] follows
-       };
-       Block*  fBlock;
-       size_t  fMinSize;
+    struct Block {
+        Block*  fNext;
+        size_t  fFreeSize;
+        char*   fFreePtr;
+        // data[] follows
+    };
+    Block*  fBlock;
+    size_t  fMinSize;
 };
 
 #endif
index 845037c..4cdd756 100644 (file)
@@ -1,80 +1,97 @@
+/* include/corecg/SkEndian.h
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #ifndef SkEndian_DEFINED
 #define SkEndian_DEFINED
 
 #include "SkTypes.h"
 
-/**    \file SkEndian.h
+/** \file SkEndian.h
 
-       Macros and helper functions for handling 16 and 32 bit values in
-       big and little endian formats.
+    Macros and helper functions for handling 16 and 32 bit values in
+    big and little endian formats.
 */
 
 #if defined(SK_CPU_LENDIAN) && defined(SK_CPU_BENDIAN)
-       #error "can't have both LENDIAN and BENDIAN defined"
+    #error "can't have both LENDIAN and BENDIAN defined"
 #endif
 
 #if !defined(SK_CPU_LENDIAN) && !defined(SK_CPU_BENDIAN)
-       #error "need either LENDIAN or BENDIAN defined"
+    #error "need either LENDIAN or BENDIAN defined"
 #endif
 
-/**    Swap the two bytes in the low 16bits of the parameters.
-       e.g. 0x1234 -> 0x3412
+/** Swap the two bytes in the low 16bits of the parameters.
+    e.g. 0x1234 -> 0x3412
 */
 inline uint16_t SkEndianSwap16(U16CPU value)
 {
-       SkASSERT(value == (uint16_t)value);
-       return (uint16_t)((value >> 8) | (value << 8));
+    SkASSERT(value == (uint16_t)value);
+    return (uint16_t)((value >> 8) | (value << 8));
 }
 
-/**    Vector version of SkEndianSwap16(), which swaps the
-       low two bytes of each value in the array.
+/** Vector version of SkEndianSwap16(), which swaps the
+    low two bytes of each value in the array.
 */
 inline void SkEndianSwap16s(uint16_t array[], int count)
 {
-       SkASSERT(count == 0 || array != nil);
+    SkASSERT(count == 0 || array != nil);
 
-       while (--count >= 0)
-       {
-               *array = SkEndianSwap16(*array);
-               array += 1;
-       }
+    while (--count >= 0)
+    {
+        *array = SkEndianSwap16(*array);
+        array += 1;
+    }
 }
 
-/**    Reverse all 4 bytes in a 32bit value.
-       e.g. 0x12345678 -> 0x78563412
+/** Reverse all 4 bytes in a 32bit value.
+    e.g. 0x12345678 -> 0x78563412
 */
 inline uint32_t SkEndianSwap32(uint32_t value)
 {
-       return  ((value & 0xFF) << 24) |
-                       ((value & 0xFF00) << 8) |
-                       ((value & 0xFF0000) >> 8) |
-                       (value >> 24);
+    return  ((value & 0xFF) << 24) |
+            ((value & 0xFF00) << 8) |
+            ((value & 0xFF0000) >> 8) |
+            (value >> 24);
 }
 
-/**    Vector version of SkEndianSwap16(), which swaps the
-       bytes of each value in the array.
+/** Vector version of SkEndianSwap16(), which swaps the
+    bytes of each value in the array.
 */
 inline void SkEndianSwap32s(uint32_t array[], int count)
 {
-       SkASSERT(count == 0 || array != nil);
+    SkASSERT(count == 0 || array != nil);
 
-       while (--count >= 0)
-       {
-               *array = SkEndianSwap32(*array);
-               array += 1;
-       }
+    while (--count >= 0)
+    {
+        *array = SkEndianSwap32(*array);
+        array += 1;
+    }
 }
 
 #ifdef SK_CPU_LENDIAN
-       #define SkEndian_SwapBE16(n)    SkEndianSwap16(n)
-       #define SkEndian_SwapBE32(n)    SkEndianSwap32(n)
-       #define SkEndian_SwapLE16(n)    (n)
-       #define SkEndian_SwapLE32(n)    (n)
-#else  // SK_CPU_BENDIAN
-       #define SkEndian_SwapBE16(n)    (n)
-       #define SkEndian_SwapBE32(n)    (n)
-       #define SkEndian_SwapLE16(n)    SkEndianSwap16(n)
-       #define SkEndian_SwapLE32(n)    SkEndianSwap32(n)
+    #define SkEndian_SwapBE16(n)    SkEndianSwap16(n)
+    #define SkEndian_SwapBE32(n)    SkEndianSwap32(n)
+    #define SkEndian_SwapLE16(n)    (n)
+    #define SkEndian_SwapLE32(n)    (n)
+#else   // SK_CPU_BENDIAN
+    #define SkEndian_SwapBE16(n)    (n)
+    #define SkEndian_SwapBE32(n)    (n)
+    #define SkEndian_SwapLE16(n)    SkEndianSwap16(n)
+    #define SkEndian_SwapLE32(n)    SkEndianSwap32(n)
 #endif
 
 
index 838c3ba..57d4516 100644 (file)
@@ -1,50 +1,67 @@
+/* include/corecg/SkFDot6.h
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #ifndef SkFDot6_DEFINED
 #define SkFDot6_DEFINED
 
 #include "SkMath.h"
 
-typedef int32_t        SkFDot6;
+typedef int32_t SkFDot6;
 
-#define SK_FDot61                      (64)
-#define SK_FDot6Half           (32)
+#define SK_FDot61           (64)
+#define SK_FDot6Half        (32)
 
 #ifdef SK_DEBUG
-       inline SkFDot6 SkIntToFDot6(S16CPU x)
-       {
-               SkASSERT(SkToS16(x) == x);
-               return x << 6;
-       }
+    inline SkFDot6 SkIntToFDot6(S16CPU x)
+    {
+        SkASSERT(SkToS16(x) == x);
+        return x << 6;
+    }
 #else
-       #define SkIntToFDot6(x) ((x) << 6)
+    #define SkIntToFDot6(x) ((x) << 6)
 #endif
 
-#define SkFDot6Floor(x)                ((x) >> 6)
-#define SkFDot6Ceil(x)         (((x) + 63) >> 6)
-#define SkFDot6Round(x)                (((x) + 32) >> 6)
+#define SkFDot6Floor(x)     ((x) >> 6)
+#define SkFDot6Ceil(x)      (((x) + 63) >> 6)
+#define SkFDot6Round(x)     (((x) + 32) >> 6)
 
-#define SkFixedToFDot6(x)      ((x) >> 10)
+#define SkFixedToFDot6(x)   ((x) >> 10)
 
 inline SkFixed SkFDot6ToFixed(SkFDot6 x)
 {
-       SkASSERT((x << 10 >> 10) == x);
+    SkASSERT((x << 10 >> 10) == x);
 
-       return x << 10;
+    return x << 10;
 }
 
 #ifdef SK_SCALAR_IS_FLOAT
-       #define SkScalarToFDot6(x)      (SkFDot6)((x) * 64)
+    #define SkScalarToFDot6(x)  (SkFDot6)((x) * 64)
 #else
-       #define SkScalarToFDot6(x)      ((x) >> 10)
+    #define SkScalarToFDot6(x)  ((x) >> 10)
 #endif
 
 inline SkFixed SkFDot6Div(SkFDot6 a, SkFDot6 b)
 {
-       SkASSERT(b != 0);
+    SkASSERT(b != 0);
 
-       if (a == (int16_t)a)
-               return (a << 16) / b;
-       else
-               return SkFixedDiv(a, b);
+    if (a == (int16_t)a)
+        return (a << 16) / b;
+    else
+        return SkFixedDiv(a, b);
 }
 
 #endif
index ddb4a6f..edfa560 100644 (file)
+/* include/corecg/SkFixed.h
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #ifndef SkFixed_DEFINED
 #define SkFixed_DEFINED
 
-/**    \file SkFixed.h
+/** \file SkFixed.h
 
-       Types and macros for 16.16 fixed point
+    Types and macros for 16.16 fixed point
 */
 
-/**    32 bit signed integer used to represent fractions values with 16 bits to the right of the decimal point
+/** 32 bit signed integer used to represent fractions values with 16 bits to the right of the decimal point
 */
-typedef int32_t                                SkFixed;
-#define SK_Fixed1                      (1 << 16)
-#define SK_FixedHalf           (1 << 15)
-#define SK_FixedMax                    (0x7FFFFFFF)
-#define SK_FixedMin                    (0x1)
-#define SK_FixedNaN                    ((int) 0x80000000)
-#define SK_FixedPI                     (0x3243F)
-#define SK_FixedSqrt2          (92682)
-#define SK_FixedTanPIOver8     (0x6A0A)
-#define SK_FixedRoot2Over2     (0xB505)
+typedef int32_t             SkFixed;
+#define SK_Fixed1           (1 << 16)
+#define SK_FixedHalf        (1 << 15)
+#define SK_FixedMax         (0x7FFFFFFF)
+#define SK_FixedMin         (0x1)
+#define SK_FixedNaN         ((int) 0x80000000)
+#define SK_FixedPI          (0x3243F)
+#define SK_FixedSqrt2       (92682)
+#define SK_FixedTanPIOver8  (0x6A0A)
+#define SK_FixedRoot2Over2  (0xB505)
 
 #ifdef SK_CAN_USE_FLOAT
-       #define SkFixedToFloat(x)       ((x) * 1.5258789e-5f)
-       #define SkFloatToFixed(x)       ((SkFixed)((x) * SK_Fixed1))
+    #define SkFixedToFloat(x)   ((x) * 1.5258789e-5f)
+    #define SkFloatToFixed(x)   ((SkFixed)((x) * SK_Fixed1))
 #endif
 
-/**    32 bit signed integer used to represent fractions values with 30 bits to the right of the decimal point
+/** 32 bit signed integer used to represent fractions values with 30 bits to the right of the decimal point
 */
 typedef int32_t             SkFract;
-#define SK_Fract1                      (1 << 30)
-#define Sk_FracHalf                    (1 << 29)
-#define SK_FractPIOver180      (0x11DF46A)
+#define SK_Fract1           (1 << 30)
+#define Sk_FracHalf         (1 << 29)
+#define SK_FractPIOver180   (0x11DF46A)
 
 #ifdef SK_CAN_USE_FLOAT
-       #define SkFractToFloat(x)       ((float)(x) * 0.00000000093132257f)
-       #define SkFloatToFract(x)       ((SkFract)((x) * SK_Fract1))
+    #define SkFractToFloat(x)   ((float)(x) * 0.00000000093132257f)
+    #define SkFloatToFract(x)   ((SkFract)((x) * SK_Fract1))
 #endif
 
-/**    Converts an integer to a SkFixed, asserting that the result does not overflow
-       a 32 bit signed integer
+/** Converts an integer to a SkFixed, asserting that the result does not overflow
+    a 32 bit signed integer
 */
 #ifdef SK_DEBUG
-       inline SkFixed SkIntToFixed(int n)
-       {
-               SkASSERT(n >= -32768 && n <= 32767);
-               return n << 16;
-       }
+    inline SkFixed SkIntToFixed(int n)
+    {
+        SkASSERT(n >= -32768 && n <= 32767);
+        return n << 16;
+    }
 #else
-       //      force the cast to SkFixed to ensure that the answer is signed (like the debug version)
-       #define SkIntToFixed(n)         (SkFixed)((n) << 16)
+    //  force the cast to SkFixed to ensure that the answer is signed (like the debug version)
+    #define SkIntToFixed(n)     (SkFixed)((n) << 16)
 #endif
 
-/**    Converts a SkFixed to a SkFract, asserting that the result does not overflow
-       a 32 bit signed integer
+/** Converts a SkFixed to a SkFract, asserting that the result does not overflow
+    a 32 bit signed integer
 */
 #ifdef SK_DEBUG
-       inline SkFract SkFixedToFract(SkFixed x)
-       {
-               SkASSERT(x >= (-2 << 16) && x <= (2 << 16) - 1);
-               return x << 14;
-       }
+    inline SkFract SkFixedToFract(SkFixed x)
+    {
+        SkASSERT(x >= (-2 << 16) && x <= (2 << 16) - 1);
+        return x << 14;
+    }
 #else
-       #define SkFixedToFract(x)       ((x) << 14)
+    #define SkFixedToFract(x)   ((x) << 14)
 #endif
 
-/**    Returns the signed fraction of a SkFixed
+/** Returns the signed fraction of a SkFixed
 */
 inline SkFixed SkFixedFraction(SkFixed x)
 {
-       SkFixed mask = x >> 31 << 16;
-       return x & 0xFFFF | mask;
+    SkFixed mask = x >> 31 << 16;
+    return x & 0xFFFF | mask;
 }
 
-/**    Converts a SkFract to a SkFixed
+/** Converts a SkFract to a SkFixed
 */
-#define SkFractToFixed(x)      ((x) >> 14)
-/**    Round a SkFixed to an integer
+#define SkFractToFixed(x)   ((x) >> 14)
+/** Round a SkFixed to an integer
 */
-#define SkFixedRound(x)                (((x) + SK_FixedHalf) >> 16)
-#define SkFixedCeil(x)         (((x) + SK_Fixed1 - 1) >> 16)
-#define SkFixedFloor(x)                ((x) >> 16)
-#define SkFixedAbs(x)          SkAbs32(x)
-#define SkFixedAve(a, b)       (((a) + (b)) >> 1)
-
-#if defined(SK_BUILD_FOR_BREW) && !defined(AEE_SIMULATOR)
-       inline SkFixed SkFixedSquare(SkFixed a)
-       {
-               SkFixed answer;
-               asm volatile ( "SMULL r6, r7, %0, %0" : : "r"(a) : "r6", "r7" );
-               asm volatile ( "MOV      r6, r6, LSR #16" );
-               asm volatile ( "ORR      r6, r6, r7, LSL #16" );
-               asm volatile ( "STR      r6, %0" : "=m"(answer) );
-               return answer;
-       }
-       inline SkFixed SkFixedMul(SkFixed a, SkFixed b)
-       {
-               SkFixed answer;
-               asm volatile ( "SMULL r6, r7, %0, %1" : : "r"(a), "r"(b) : "r6", "r7" );
-               asm volatile ( "MOV      r6, r6, LSR #16" );
-               asm volatile ( "ORR      r6, r6, r7, LSL #16" );
-               asm volatile ( "STR      r6, %0" : "=m"(answer) );
-               return answer;
-       }
-       inline SkFract SkFractMul(SkFract a, SkFract b)
-       {
-               SkFract answer;
-               asm volatile ( "SMULL r6, r7, %0, %1" : : "r"(a), "r"(b) : "r6", "r7" );
-               asm volatile ( "MOV      r6, r6, LSR #30" );
-               asm volatile ( "ORR      r6, r6, r7, LSL #2" );
-               asm volatile ( "STR      r6, %0" : "=m"(answer) );
-               return answer;
-       }
-#else
-       inline SkFixed SkFixedSquare(SkFixed value)
-       {
-               uint32_t a = SkAbs32(value);
-               uint32_t ah = a >> 16;
-               uint32_t al = a & 0xFFFF;
-               return ah * a + al * ah + (al * al >> 16);
-       }
-       SkFixed SkFixedMul(SkFixed, SkFixed);
-       SkFract SkFractMul(SkFract, SkFract);
-#endif
-#define SkFixedDiv(numer, denom)       SkDivBits(numer, denom, 16)
+#define SkFixedRound(x)     (((x) + SK_FixedHalf) >> 16)
+#define SkFixedCeil(x)      (((x) + SK_Fixed1 - 1) >> 16)
+#define SkFixedFloor(x)     ((x) >> 16)
+#define SkFixedAbs(x)       SkAbs32(x)
+#define SkFixedAve(a, b)    (((a) + (b)) >> 1)
+
+SkFixed SkFixedMul_portable(SkFixed, SkFixed);
+SkFract SkFractMul_portable(SkFract, SkFract);
+inline SkFixed SkFixedSquare_portable(SkFixed value)
+{
+    uint32_t a = SkAbs32(value);
+    uint32_t ah = a >> 16;
+    uint32_t al = a & 0xFFFF;
+    return ah * a + al * ah + (al * al >> 16);
+}
+
+#define SkFixedDiv(numer, denom)    SkDivBits(numer, denom, 16)
 SkFixed SkFixedDivInt(int32_t numer, int32_t denom);
 SkFixed SkFixedMod(SkFixed numer, SkFixed denom);
-#define SkFixedInvert(n)                       SkDivBits(SK_Fixed1, n, 16)
-#define SkFixedSqrt(n)                         SkSqrtBits(n, 23)
+#define SkFixedInvert(n)            SkDivBits(SK_Fixed1, n, 16)
+SkFixed SkFixedFastInvert(SkFixed n);
+#define SkFixedSqrt(n)              SkSqrtBits(n, 23)
 SkFixed SkFixedMean(SkFixed a, SkFixed b);  //*< returns sqrt(x*y)
-int SkFixedMulCommon(SkFixed, int , int bias); // internal used by SkFixedMulFloor, SkFixedMulCeil, SkFixedMulRound
+int SkFixedMulCommon(SkFixed, int , int bias);  // internal used by SkFixedMulFloor, SkFixedMulCeil, SkFixedMulRound
 
-#define SkFractDiv(numer, denom)       SkDivBits(numer, denom, 30)
-#define SkFractSqrt(n)                         SkSqrtBits(n, 30)
+#define SkFractDiv(numer, denom)    SkDivBits(numer, denom, 30)
+#define SkFractSqrt(n)              SkSqrtBits(n, 30)
 
 SkFixed SkFixedSinCos(SkFixed radians, SkFixed* cosValueOrNil);
-#define SkFixedSin(radians)                    SkFixedSinCos(radians, nil)
+#define SkFixedSin(radians)         SkFixedSinCos(radians, nil)
 inline SkFixed SkFixedCos(SkFixed radians)
 {
-       SkFixed cosValue;
-       (void)SkFixedSinCos(radians, &cosValue);
-       return cosValue;
+    SkFixed cosValue;
+    (void)SkFixedSinCos(radians, &cosValue);
+    return cosValue;
 }
 SkFixed SkFixedTan(SkFixed radians);
 SkFixed SkFixedASin(SkFixed);
@@ -147,13 +136,89 @@ SkFixed SkFixedATan2(SkFixed y, SkFixed x);
 SkFixed SkFixedExp(SkFixed);
 SkFixed SkFixedLog(SkFixed);
 
-#define SK_FixedNearlyZero                     (SK_Fixed1 >> 12)
+#define SK_FixedNearlyZero          (SK_Fixed1 >> 12)
 
 inline bool SkFixedNearlyZero(SkFixed x, SkFixed tolerance = SK_FixedNearlyZero)
 {
-       SkASSERT(tolerance > 0);
-       return SkAbs32(x) < tolerance;
+    SkASSERT(tolerance > 0);
+    return SkAbs32(x) < tolerance;
 }
 
+//////////////////////////////////////////////////////////////////////////////////////////////////////
+// Now look for ASM overrides for our portable versions (should consider putting this in its own file)
+
+#if defined(__arm__) && !defined(__thumb)
+    inline SkFixed SkFixedMul_arm(SkFixed x, SkFixed y)
+    {
+        register int32_t t;
+        asm("smull  %0, %2, %1, %3          \n"
+            "mov    %0, %0, lsr #16         \n"
+            "orr    %0, %0, %2, lsl #16     \n"
+            : "=r"(x), "=&r"(y), "=r"(t)
+            : "r"(x), "1"(y)
+            :
+            );
+        return x;
+    }
+    inline SkFixed SkFractMul_arm(SkFixed x, SkFixed y)
+    {
+        register int32_t t;
+        asm("smull  %0, %2, %1, %3          \n"
+            "mov    %0, %0, lsr #30         \n"
+            "orr    %0, %0, %2, lsl #2      \n"
+            : "=r"(x), "=&r"(y), "=r"(t)
+            : "r"(x), "1"(y)
+            :
+            );
+        return x;
+    }
+    #define SkFixedMul(x, y)    SkFixedMul_arm(x, y)
+    #define SkFractMul(x, y)    SkFractMul_arm(x, y)
+
+#elif defined(SK_BUILD_FOR_BREW) && !defined(AEE_SIMULATOR)
+    inline SkFixed SkFixedSquare_brew(SkFixed a)
+    {
+        SkFixed answer;
+        asm volatile ( "SMULL r6, r7, %0, %0" : : "r"(a) : "r6", "r7" );
+        asm volatile ( "MOV  r6, r6, LSR #16" );
+        asm volatile ( "ORR  r6, r6, r7, LSL #16" );
+        asm volatile ( "STR  r6, %0" : "=m"(answer) );
+        return answer;
+    }
+    inline SkFixed SkFixedMul_brew(SkFixed a, SkFixed b)
+    {
+        SkFixed answer;
+        asm volatile ( "SMULL r6, r7, %0, %1" : : "r"(a), "r"(b) : "r6", "r7" );
+        asm volatile ( "MOV  r6, r6, LSR #16" );
+        asm volatile ( "ORR  r6, r6, r7, LSL #16" );
+        asm volatile ( "STR  r6, %0" : "=m"(answer) );
+        return answer;
+    }
+    inline SkFract SkFractMul_brew(SkFract a, SkFract b)
+    {
+        SkFract answer;
+        asm volatile ( "SMULL r6, r7, %0, %1" : : "r"(a), "r"(b) : "r6", "r7" );
+        asm volatile ( "MOV  r6, r6, LSR #30" );
+        asm volatile ( "ORR  r6, r6, r7, LSL #2" );
+        asm volatile ( "STR  r6, %0" : "=m"(answer) );
+        return answer;
+    }
+    #define SkFixedSquare(x)    SkFixedSquare_brew(x)
+    #define SkFixedMul(x, y)    SkFixedMul_brew(x, y)
+    #define SkFractMul(x, y)    SkFractMul_brew(x, y)
+#endif
+
+/////////////////////// Now define our macros to the portable versions if they weren't overridden
+
+#ifndef SkFixedSquare
+    #define SkFixedSquare(x)    SkFixedSquare_portable(x)
+#endif
+#ifndef SkFixedMul
+    #define SkFixedMul(x, y)    SkFixedMul_portable(x, y)
+#endif
+#ifndef SkFractMul
+    #define SkFractMul(x, y)    SkFractMul_portable(x, y)
+#endif
+
 #endif
 
index 9841086..1e95f31 100644 (file)
@@ -1,3 +1,20 @@
+/* include/corecg/SkFloatingPoint.h
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #ifndef SkFloatingPoint_DEFINED
 #define SkFloatingPoint_DEFINED
 
 #include <float.h>
 
 #ifdef SK_BUILD_FOR_WINCE
-       #define sk_float_sqrt(x)                (float)::sqrt(x)
-       #define sk_float_sin(x)                 (float)::sin(x)
-       #define sk_float_cos(x)                 (float)::cos(x)
-       #define sk_float_tan(x)                 (float)::tan(x)
-       #define sk_float_acos(x)                (float)::acos(x)
-       #define sk_float_asin(x)                (float)::asin(x)
-       #define sk_float_atan2(y,x)             (float)::atan2(y,x)
-       #define sk_float_abs(x)                 (float)::fabs(x)
-       #define sk_float_mod(x,y)               (float)::fmod(x,y)
-       #define sk_float_exp(x)         (float)::exp(x)
-       #define sk_float_log(x)         (float)::log(x)
+    #define sk_float_sqrt(x)        (float)::sqrt(x)
+    #define sk_float_sin(x)         (float)::sin(x)
+    #define sk_float_cos(x)         (float)::cos(x)
+    #define sk_float_tan(x)         (float)::tan(x)
+    #define sk_float_acos(x)        (float)::acos(x)
+    #define sk_float_asin(x)        (float)::asin(x)
+    #define sk_float_atan2(y,x)     (float)::atan2(y,x)
+    #define sk_float_abs(x)         (float)::fabs(x)
+    #define sk_float_mod(x,y)       (float)::fmod(x,y)
+    #define sk_float_exp(x)     (float)::exp(x)
+    #define sk_float_log(x)     (float)::log(x)
 #else
-       #define sk_float_sqrt(x)                sqrtf(x)
-       #define sk_float_sin(x)                 sinf(x)
-       #define sk_float_cos(x)                 cosf(x)
-       #define sk_float_tan(x)                 tanf(x)
+    #define sk_float_sqrt(x)        sqrtf(x)
+    #define sk_float_sin(x)         sinf(x)
+    #define sk_float_cos(x)         cosf(x)
+    #define sk_float_tan(x)         tanf(x)
 #ifdef SK_BUILD_FOR_MAC
-       #define sk_float_acos(x)                acos(x)
-       #define sk_float_asin(x)                asin(x)
+    #define sk_float_acos(x)        acos(x)
+    #define sk_float_asin(x)        asin(x)
 #else
-       #define sk_float_acos(x)                acosf(x)
-       #define sk_float_asin(x)                asinf(x)
+    #define sk_float_acos(x)        acosf(x)
+    #define sk_float_asin(x)        asinf(x)
 #endif
-       #define sk_float_atan2(y,x)     atan2f(y,x)
-       #define sk_float_abs(x)                 fabsf(x)
-       #define sk_float_mod(x,y)               fmodf(x,y)
-       #define sk_float_exp(x)                 expf(x)
-       #define sk_float_log(x)                 logf(x)
-       #define sk_float_isNaN(x)               _isnan(x)
+    #define sk_float_atan2(y,x) atan2f(y,x)
+    #define sk_float_abs(x)         fabsf(x)
+    #define sk_float_mod(x,y)       fmodf(x,y)
+    #define sk_float_exp(x)         expf(x)
+    #define sk_float_log(x)         logf(x)
+    #define sk_float_isNaN(x)       _isnan(x)
 #endif
 
 #endif
diff --git a/include/corecg/SkInterpolator.h b/include/corecg/SkInterpolator.h
new file mode 100644 (file)
index 0000000..9a37d9b
--- /dev/null
@@ -0,0 +1,119 @@
+/* include/corecg/SkInterpolator.h
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
+#ifndef SkInterpolator_DEFINED
+#define SkInterpolator_DEFINED
+
+#include "SkMath.h"
+
+class SkInterpolatorBase {
+public:
+    enum Result {
+        kNormal_Result,
+        kFreezeStart_Result,
+        kFreezeEnd_Result
+    };
+protected:
+    SkInterpolatorBase();
+    ~SkInterpolatorBase();
+public:
+    void    reset(int elemCount, int frameCount);
+
+    /** Return the start and end time for this interpolator.
+        If there are no key frames, return false.
+        @param  startTime   If no nil, returns the time (in milliseconds) of the
+                            first keyframe. If there are no keyframes, this parameter
+                            is ignored (left unchanged).
+        @param  endTime     If no nil, returns the time (in milliseconds) of the
+                            last keyframe. If there are no keyframes, this parameter
+                            is ignored (left unchanged).
+        @return True if there are key frames, or false if there are none.
+    */
+    bool    getDuration(SkMSec* startTime, SkMSec* endTime) const;
+
+
+    /** Set the whether the repeat is mirrored.
+        @param If true, the odd repeats interpolate from the last key frame and the first.
+    */
+    void    setMirror(bool mirror) { fFlags = SkToU8(fFlags & ~kMirror | (int) mirror); }
+
+    /** Set the repeat count. The repeat count may be fractional.
+        @param repeatCount Multiplies the total time by this scalar.
+    */
+    void    setRepeatCount(SkScalar repeatCount) { fRepeat = repeatCount; }
+
+    /** Set the whether the repeat is mirrored.
+        @param If true, the odd repeats interpolate from the last key frame and the first.
+    */
+    void    setReset(bool reset) { fFlags = SkToU8(fFlags & ~kReset | (int) reset); }
+
+    Result  timeToT(SkMSec time, SkScalar* T, int* index, SkBool* exact) const;
+protected:
+    enum Flags {
+        kMirror = 1,
+        kReset = 2,
+        kHasBlend = 4
+    };
+    static SkScalar ComputeRelativeT(SkMSec time, SkMSec prevTime, SkMSec nextTime, const SkScalar blend[4] = NULL);
+    int16_t fFrameCount;
+    uint8_t fElemCount;
+    uint8_t fFlags;
+    SkScalar fRepeat;
+    struct SkTimeCode {
+        SkMSec  fTime;
+        SkScalar fBlend[4];
+    };
+    SkTimeCode* fTimes;     // pointer into fStorage
+    void* fStorage;
+#ifdef SK_DEBUG
+    SkTimeCode(* fTimesArray)[10];
+#endif
+};
+
+class SkInterpolator : public SkInterpolatorBase {
+public:
+    SkInterpolator();
+    SkInterpolator(int elemCount, int frameCount);
+    void    reset(int elemCount, int frameCount);
+
+    /** Add or replace a key frame, copying the values[] data into the interpolator.
+        @param index    The index of this frame (frames must be ordered by time)
+        @param time The millisecond time for this frame
+        @param values   The array of values [elemCount] for this frame. The data is copied
+                        into the interpolator.
+        @param blend    A positive scalar specifying how to blend between this and the next key frame.
+                        [0...1) is a cubic lag/log/lag blend (slow to change at the beginning and end)
+                        1 is a linear blend (default)
+    */
+    bool    setKeyFrame(int index, SkMSec time, const SkScalar values[], const SkScalar blend[4] = NULL);
+    Result timeToValues(SkMSec time, SkScalar values[]) const;
+    SkDEBUGCODE(static void UnitTest();)
+private:
+    SkScalar* fValues;  // pointer into fStorage
+#ifdef SK_DEBUG
+    SkScalar(* fScalarsArray)[10];
+#endif
+    typedef SkInterpolatorBase INHERITED;
+};
+
+/** Given all the parameters are [0...1], apply the cubic specified by (0,0) (bx,by) (cx,cy) (1,1)
+    to value, returning the answer, also [0...1].
+*/
+SkScalar SkUnitCubicInterp(SkScalar value, SkScalar bx, SkScalar by, SkScalar cx, SkScalar cy);
+
+#endif
+
index 9657f71..9a4ffd7 100644 (file)
@@ -1,3 +1,20 @@
+/* include/corecg/SkMath.h
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #ifndef SkMath_DEFINED
 #define SkMath_DEFINED
 
 
 /** \file SkMath.h
 
-       This file defines various math types and functions. It also introduces
-       SkScalar, the type used to describe fractional values and coordinates.
-       SkScalar is defined at compile time to be either an IEEE float, or a
-       16.16 fixed point integer. Various macros and functions in SkMath.h
-       allow arithmetic operations to be performed on SkScalars without known
-       which representation is being used. e.g. SkScalarMul(a, b) multiplies
-       two SkScalar values, and returns a SkScalar, and this works with either
-       float or fixed implementations.
+    This file defines various math types and functions. It also introduces
+    SkScalar, the type used to describe fractional values and coordinates.
+    SkScalar is defined at compile time to be either an IEEE float, or a
+    16.16 fixed point integer. Various macros and functions in SkMath.h
+    allow arithmetic operations to be performed on SkScalars without known
+    which representation is being used. e.g. SkScalarMul(a, b) multiplies
+    two SkScalar values, and returns a SkScalar, and this works with either
+    float or fixed implementations.
 */
 
-//#if defined(SK_BUILD_FOR_BREW) && !defined(AEE_SIMULATOR)
-#if 0
-       inline int SkCLZ(uint32_t value)
-       {
-               int     answer;
-               asm volatile ( "CLZ r6, %0" : : "r"(value) : "r6" );
-               asm volatile ( "STR r6, %0" : "=m"(answer) );
-               return answer;
-       }
-#else
-       int     SkCLZ(uint32_t);        //<! Returns the number of leading zero bits (0...32)
-#endif
+int SkCLZ_portable(uint32_t);   //<! Returns the number of leading zero bits (0...32)
 
-/**    Computes the 64bit product of a * b, and then shifts the answer down by
-       shift bits, returning the low 32bits. shift must be [0..63]
-       e.g. to perform a fixedmul, call SkMulShift(a, b, 16)
+/** Computes the 64bit product of a * b, and then shifts the answer down by
+    shift bits, returning the low 32bits. shift must be [0..63]
+    e.g. to perform a fixedmul, call SkMulShift(a, b, 16)
 */
 int32_t SkMulShift(int32_t a, int32_t b, unsigned shift);
-/**    Computes numer1 * numer2 / denom in full 64 intermediate precision.
-       It is an error for denom to be 0. There is no special handling if
-       the result overflows 32bits.
+/** Computes numer1 * numer2 / denom in full 64 intermediate precision.
+    It is an error for denom to be 0. There is no special handling if
+    the result overflows 32bits.
 */
 int32_t SkMulDiv(int32_t numer1, int32_t numer2, int32_t denom);
-/**    Computes (numer1 << shift) / denom in full 64 intermediate precision.
-       It is an error for denom to be 0. There is no special handling if
-       the result overflows 32bits.
+/** Computes (numer1 << shift) / denom in full 64 intermediate precision.
+    It is an error for denom to be 0. There is no special handling if
+    the result overflows 32bits.
 */
 int32_t SkDivBits(int32_t numer, int32_t denom, int shift);
 int32_t SkSqrtBits(int32_t value, int bits);
-#define SkSqrt32(n)                    SkSqrtBits(n, 15)
+#define SkSqrt32(n)         SkSqrtBits(n, 15)
 int32_t SkCubeRootBits(int32_t value, int bits);
 
-/**    Returns -1 if n < 0, else returns 0
+/** Returns -1 if n < 0, else returns 0
 */
-#define SkExtractSign(n)       ((int32_t)(n) >> 31)
+#define SkExtractSign(n)    ((int32_t)(n) >> 31)
 
-/**    If sign == -1, returns -n, else sign must be 0, and returns n.
-       Typically used in conjunction with SkExtractSign().
+/** If sign == -1, returns -n, else sign must be 0, and returns n.
+    Typically used in conjunction with SkExtractSign().
 */
 inline int32_t SkApplySign(int32_t n, int32_t sign)
 {
-       SkASSERT(sign == 0 || sign == -1);
-       return (n ^ sign) - sign;
+    SkASSERT(sign == 0 || sign == -1);
+    return (n ^ sign) - sign;
 }
 
-/**    Returns max(value, 0)
+/** Returns max(value, 0)
 */
 inline int SkClampPos(int value)
 {
-       return value & ~(value >> 31);
+    return value & ~(value >> 31);
 }
 
-/**    Given an integer and a positive (max) integer, return the value
-       pinned against 0 and max, inclusive.
-       Note: only works as long as max - value doesn't wrap around
-       @param value    The value we want returned pinned between [0...max]
-       @param max              The positive max value
-       @return 0 if value < 0, max if value > max, else value
+/** Given an integer and a positive (max) integer, return the value
+    pinned against 0 and max, inclusive.
+    Note: only works as long as max - value doesn't wrap around
+    @param value    The value we want returned pinned between [0...max]
+    @param max      The positive max value
+    @return 0 if value < 0, max if value > max, else value
 */
 inline int SkClampMax(int value, int max)
 {
-       // ensure that max is positive
-       SkASSERT(max >= 0);
-       // ensure that if value is negative, max - value doesn't wrap around
-       SkASSERT(value >= 0 || max - value > 0);
+    // ensure that max is positive
+    SkASSERT(max >= 0);
+    // ensure that if value is negative, max - value doesn't wrap around
+    SkASSERT(value >= 0 || max - value > 0);
 
 #ifdef SK_CPU_HAS_CONDITIONAL_INSTR
-       if (value < 0)
-               value = 0;
-       if (value > max)
-               value = max;
-       return value;
+    if (value < 0)
+        value = 0;
+    if (value > max)
+        value = max;
+    return value;
 #else
 
-       int     diff = max - value;
-       // clear diff if diff is positive
-       diff &= diff >> 31;
+    int diff = max - value;
+    // clear diff if diff is positive
+    diff &= diff >> 31;
 
-       // clear the result if value < 0
-       return (value + diff) & ~(value >> 31);
+    // clear the result if value < 0
+    return (value + diff) & ~(value >> 31);
 #endif
 }
 
-/**    Given a positive value and a positive max, return the value
-       pinned against max.
-       Note: only works as long as max - value doesn't wrap around
-       @return max if value >= max, else value
+/** Given a positive value and a positive max, return the value
+    pinned against max.
+    Note: only works as long as max - value doesn't wrap around
+    @return max if value >= max, else value
 */
 inline unsigned SkClampUMax(unsigned value, unsigned max)
 {
 #ifdef SK_CPU_HAS_CONDITIONAL_INSTR
-       if (value > max)
-               value = max;
-       return value;
+    if (value > max)
+        value = max;
+    return value;
 #else
-       int     diff = max - value;
-       // clear diff if diff is positive
-       diff &= diff >> 31;
+    int diff = max - value;
+    // clear diff if diff is positive
+    diff &= diff >> 31;
 
-       return value + diff;
+    return value + diff;
 #endif
 }
 
+//////////////////////////////////////////////////////////////////////////////////
+
+#if defined(__arm__)
+    #define SkCLZ(x)    __builtin_clz(x)
+#endif
+
+#ifndef SkCLZ
+    #define SkCLZ(x)    SkCLZ_portable(x)
+#endif
+
+//////////////////////////////////////////////////////////////////////////////////
+
 #include "SkFixed.h"
 #include "SkScalar.h"
 
 #ifdef SK_DEBUG
-       class SkMath {
-       public:
-               static void UnitTest();
-       };
+    class SkMath {
+    public:
+        static void UnitTest();
+    };
 #endif
 
 #endif
index 26fdb29..a32714b 100644 (file)
+/* include/corecg/SkMatrix.h
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #ifndef SkMatrix_DEFINED
 #define SkMatrix_DEFINED
 
 #include "SkRect.h"
 
-/**    \class SkMatrix
+/** \class SkMatrix
 
-       The SkMatrix class holds a 3x3 matrix for transforming coordinates.
-       SkMatrix does not have a constructor, so it must be explicitly initialized
-       using either reset() - to construct an identity matrix, or one of the set...()
-       functions (e.g. setTranslate, setRotate, etc.).
+    The SkMatrix class holds a 3x3 matrix for transforming coordinates.
+    SkMatrix does not have a constructor, so it must be explicitly initialized
+    using either reset() - to construct an identity matrix, or one of the set...()
+    functions (e.g. setTranslate, setRotate, etc.).
 */
 class SkMatrix {
 public:
-       /**     Bit fields used to identify the characteristics of the matrix.
-               See TypeMask for the corresponding mask values.
-       */
-       enum TypeShift {
-               kTranslate_Shift,
-               kScale_Shift,
-               kAffine_Shift,
-               kPerspective_Shift,
+    /** Enum of bit fields for the mask return by getType().
+        Use this to identify the complexity of the matrix.
+        This enum is not exported to java.
+    */
+    enum TypeMask {
+        kTranslate_Mask     = 0x1,  //!< set if the matrix has non-zero translation
+        kScale_Mask         = 0x2,  //!< set if the matrix has X or Y scale different from 1.0
+        kAffine_Mask        = 0x4,  //!< set if the matrix skews or rotates
+        kPerspective_Mask   = 0x8   //!< set if the matrix is in perspective
+    };
 
-               kShiftCount
-       };
+    /** Returns true if the mask represents a matrix that will only scale
+        or translate (i.e., will map a rectangle into another rectangle).
+        This method is not exported to java.
+    */
+    static bool RectStaysRect(TypeMask mask)
+    {
+        return (mask & (kAffine_Mask | kPerspective_Mask)) == 0;
+    }
 
-       /**     Enum of bit fields for the mask return by getType().
-               Use this to identify the complexity of the matrix.
-       */
-       enum TypeMask {
-               kIdentity_Mask          = 0,                                            //!< type is 0 iff the matrix is the identiy
-               kTranslate_Mask         = 1 << kTranslate_Shift,        //!< set if the matrix has non-zero translation
-               kScale_Mask                     = 1 << kScale_Shift,            //!< set if the matrix has X or Y scale different from 1.0
-               kAffine_Mask            = 1 << kAffine_Shift,           //!< set if the matrix skews or rotates
-               kPerspective_Mask       = 1 << kPerspective_Shift       //!< set if the matrix is in perspective
-       };
+    /** Returns a mask bitfield describing the types of transformations
+        that the matrix will perform. This information is used by routines
+        like mapPoints, to optimize its inner loops to only perform as much
+        arithmetic as is necessary.
+        This method is not exported to java.
+    */
+    TypeMask getType() const;
 
-       /**     Returns true if the mask represents a matrix that will only scale
-               or translate (i.e., will map a rectangle into another rectangle).
-       */
-       static bool RectStaysRect(TypeMask mask)
-       {
-               return (mask & (kAffine_Mask | kPerspective_Mask)) == 0;
-       }
+    /** Returns true if the matrix is identity.
+        This maybe faster than testing if (getType() == 0)
+    */
+    bool isIdentity() const;
 
-       /**     Returns a mask bitfield describing the types of transformations
-               that the matrix will perform. This information is used by routines
-               like mapPoints, to optimize its inner loops to only perform as much
-               arithmetic as is necessary.
-       */
-       TypeMask getType() const;
+    /** Returns true if the matrix that will only scale
+        or translate (i.e., will map a rectangle into another rectangle).
+    */
+    bool rectStaysRect() const { return RectStaysRect(this->getType()); }
 
-       /**     Returns true if the matrix is identity.
-               This is faster than testing if (getType() == kIdentity_Mask)
-       */
-       bool isIdentity() const;
-
-       /**     Returns true if the matrix that will only scale
-               or translate (i.e., will map a rectangle into another rectangle).
-       */
-       bool rectStaysRect() const { return RectStaysRect(this->getType()); }
+    enum {
+        kMScaleX,
+        kMSkewX,
+        kMTransX,
+        kMSkewY,
+        kMScaleY,
+        kMTransY,
+        kMPersp0,
+        kMPersp1,
+        kMPersp2
+    };
+    
+    SkScalar    operator[](int index) const { SkASSERT((unsigned)index < 9); return fMat[index]; }
+    SkScalar&   operator[](int index) { SkASSERT((unsigned)index < 9); return fMat[index]; }
 
-       SkScalar        getScaleX() const { return fMat[0]; }
-       SkScalar        getScaleY() const { return fMat[4]; }
-       SkScalar        getSkewY() const { return fMat[3]; }
-       SkScalar        getSkewX() const { return fMat[1]; }
-       SkScalar        getTranslateX() const { return fMat[2]; }
-       SkScalar        getTranslateY() const { return fMat[5]; }
-       SkScalar        getPerspX() const { return fMat[6]; }
-       SkScalar        getPerspY() const { return fMat[7]; }
+    // deprecated, use [] instead
+    SkScalar    getScaleX() const { return fMat[0]; }
+    // deprecated, use [] instead
+    SkScalar    getScaleY() const { return fMat[4]; }
+    // deprecated, use [] instead
+    SkScalar    getSkewY() const { return fMat[3]; }
+    // deprecated, use [] instead
+    SkScalar    getSkewX() const { return fMat[1]; }
+    // deprecated, use [] instead
+    SkScalar    getTranslateX() const { return fMat[2]; }
+    // deprecated, use [] instead
+    SkScalar    getTranslateY() const { return fMat[5]; }
+    // deprecated, use [] instead
+    SkScalar    getPerspX() const { return fMat[6]; }
+    // deprecated, use [] instead
+    SkScalar    getPerspY() const { return fMat[7]; }
 
-       void    setScaleX(SkScalar v) { fMat[0] = v; }
-       void    setScaleY(SkScalar v) { fMat[4] = v; }
-       void    setSkewY(SkScalar v) { fMat[3] = v; }
-       void    setSkewX(SkScalar v) { fMat[1] = v; }
-       void    setTranslateX(SkScalar v) { fMat[2] = v; }
-       void    setTranslateY(SkScalar v) { fMat[5] = v; }
+    // deprecated, use [] instead
+    void    setScaleX(SkScalar v) { fMat[0] = v; }
+    // deprecated, use [] instead
+    void    setScaleY(SkScalar v) { fMat[4] = v; }
+    // deprecated, use [] instead
+    void    setSkewY(SkScalar v) { fMat[3] = v; }
+    // deprecated, use [] instead
+    void    setSkewX(SkScalar v) { fMat[1] = v; }
+    // deprecated, use [] instead
+    void    setTranslateX(SkScalar v) { fMat[2] = v; }
+    // deprecated, use [] instead
+    void    setTranslateY(SkScalar v) { fMat[5] = v; }
 #ifdef SK_SCALAR_IS_FIXED
-       void    setPerspX(SkFract v) { fMat[6] = v; }
-       void    setPerspY(SkFract v) { fMat[7] = v; }
+    // deprecated, use [] instead
+    void    setPerspX(SkFract v) { fMat[6] = v; }
+    // deprecated, use [] instead
+    void    setPerspY(SkFract v) { fMat[7] = v; }
 #else
-       void    setPerspX(SkScalar v) { fMat[6] = v; }
-       void    setPerspY(SkScalar v) { fMat[7] = v; }
+    // deprecated, use [] instead
+    void    setPerspX(SkScalar v) { fMat[6] = v; }
+    // deprecated, use [] instead
+    void    setPerspY(SkScalar v) { fMat[7] = v; }
 #endif
-       /**     Set the matrix to identity
-       */
-       void    reset();
+
+    /** Set the matrix to identity
+    */
+    void    reset();
     
     void    set(const SkMatrix& other) { *this = other; }
     
-       /**     Set the matrix to translate by (dx, dy).
-       */
-       void    setTranslate(SkScalar dx, SkScalar dy);
-       /**     Set the matrix to scale by sx and sy, with a pivot point at (px, py).
-               The pivot point is the coordinate that should remain unchanged by the
-               specified transformation.
-       */
-       void    setScale(SkScalar sx, SkScalar sy, SkScalar px, SkScalar py);
-       /**     Set the matrix to rotate by the specified number of degrees, with a pivot point at (px, py).
-               The pivot point is the coordinate that should remain unchanged by the
-               specified transformation.
-       */
-       void    setRotate(SkScalar degrees, SkScalar px, SkScalar py);
-       /**     Set the matrix to rotate by the specified sine and cosine values, with a pivot point at (px, py).
-               The pivot point is the coordinate that should remain unchanged by the
-               specified transformation.
-       */
-       void    setSinCos(SkScalar sinValue, SkScalar cosValue, SkScalar px, SkScalar py);
-       /**     Set the matrix to skew by sx and sy, with a pivot point at (px, py).
-               The pivot point is the coordinate that should remain unchanged by the
-               specified transformation.
-       */
-       void    setSkew(SkScalar kx, SkScalar ky, SkScalar px, SkScalar py);
-       /**     Set the matrix to the concatenation of the two specified matrices, returning
-               true if the the result can be represented. Either of the two matrices may
-               also be the target matrix. *this = a * b;
-       */
-       bool    setConcat(const SkMatrix& a, const SkMatrix& b);
+    /** Set the matrix to translate by (dx, dy).
+    */
+    void    setTranslate(SkScalar dx, SkScalar dy);
+    /** Set the matrix to scale by sx and sy, with a pivot point at (px, py).
+        The pivot point is the coordinate that should remain unchanged by the
+        specified transformation.
+    */
+    void    setScale(SkScalar sx, SkScalar sy, SkScalar px, SkScalar py);
+    /** Set the matrix to scale by sx and sy.
+    */
+    void    setScale(SkScalar sx, SkScalar sy);
+    /** Set the matrix to rotate by the specified number of degrees, with a pivot point at (px, py).
+        The pivot point is the coordinate that should remain unchanged by the
+        specified transformation.
+    */
+    void    setRotate(SkScalar degrees, SkScalar px, SkScalar py);
+    /** Set the matrix to rotate about (0,0) by the specified number of degrees.
+    */
+    void    setRotate(SkScalar degrees);
+    /** Set the matrix to rotate by the specified sine and cosine values, with a pivot point at (px, py).
+        The pivot point is the coordinate that should remain unchanged by the
+        specified transformation.
+    */
+    void    setSinCos(SkScalar sinValue, SkScalar cosValue, SkScalar px, SkScalar py);
+    /** Set the matrix to rotate by the specified sine and cosine values.
+    */
+    void    setSinCos(SkScalar sinValue, SkScalar cosValue);
+    /** Set the matrix to skew by sx and sy, with a pivot point at (px, py).
+        The pivot point is the coordinate that should remain unchanged by the
+        specified transformation.
+    */
+    void    setSkew(SkScalar kx, SkScalar ky, SkScalar px, SkScalar py);
+    /** Set the matrix to skew by sx and sy.
+    */
+    void    setSkew(SkScalar kx, SkScalar ky);
+    /** Set the matrix to the concatenation of the two specified matrices, returning
+        true if the the result can be represented. Either of the two matrices may
+        also be the target matrix. *this = a * b;
+    */
+    bool    setConcat(const SkMatrix& a, const SkMatrix& b);
+
+    /** Preconcats the matrix with the specified translation.
+        M' = M * T(dx, dy)
+    */
+    bool    preTranslate(SkScalar dx, SkScalar dy);
+    /** Preconcats the matrix with the specified scale.
+        M' = M * S(sx, sy, px, py)
+    */
+    bool    preScale(SkScalar sx, SkScalar sy, SkScalar px, SkScalar py);
+    /** Preconcats the matrix with the specified scale.
+        M' = M * S(sx, sy)
+    */
+    bool    preScale(SkScalar sx, SkScalar sy);
+    /** Preconcats the matrix with the specified rotation.
+        M' = M * R(degrees, px, py)
+    */
+    bool    preRotate(SkScalar degrees, SkScalar px, SkScalar py);
+    /** Preconcats the matrix with the specified rotation.
+        M' = M * R(degrees)
+    */
+    bool    preRotate(SkScalar degrees);
+    /** Preconcats the matrix with the specified skew.
+        M' = M * K(kx, ky, px, py)
+    */
+    bool    preSkew(SkScalar kx, SkScalar ky, SkScalar px, SkScalar py);
+    /** Preconcats the matrix with the specified skew.
+        M' = M * K(kx, ky)
+    */
+    bool    preSkew(SkScalar kx, SkScalar ky);
+    /** Preconcats the matrix with the specified matrix.
+        M' = M * other
+    */
+    bool    preConcat(const SkMatrix& other);
 
-       /**     Preconcats the matrix with the specified translation.
-               M' = M * T(dx, dy)
-       */
-       bool    preTranslate(SkScalar dx, SkScalar dy);
-       /**     Preconcats the matrix with the specified scale.
-               M' = M * S(sx, sy, px, py)
-       */
-       bool    preScale(SkScalar sx, SkScalar sy, SkScalar px, SkScalar py);
-       /**     Preconcats the matrix with the specified rotation.
-               M' = M * R(degrees, px, py)
-       */
-       bool    preRotate(SkScalar degrees, SkScalar px, SkScalar py);
-       /**     Preconcats the matrix with the specified skew.
-               M' = M * K(kx, ky, px, py)
-       */
-       bool    preSkew(SkScalar kx, SkScalar ky, SkScalar px, SkScalar py);
-       /**     Preconcats the matrix with the specified matrix.
-               M' = M * other
-       */
-       bool    preConcat(const SkMatrix& other);
+    /** Postconcats the matrix with the specified translation.
+        M' = T(dx, dy) * M
+    */
+    bool    postTranslate(SkScalar dx, SkScalar dy);
+    /** Postconcats the matrix with the specified scale.
+        M' = S(sx, sy, px, py) * M
+    */
+    bool    postScale(SkScalar sx, SkScalar sy, SkScalar px, SkScalar py);
+    /** Postconcats the matrix with the specified scale.
+        M' = S(sx, sy) * M
+    */
+    bool    postScale(SkScalar sx, SkScalar sy);
+    /** Postconcats the matrix by dividing it by the specified integers.
+        M' = S(1/divx, 1/divy, 0, 0) * M
+    */
+    bool    postIDiv(int divx, int divy);
+    /** Postconcats the matrix with the specified rotation.
+        M' = R(degrees, px, py) * M
+    */
+    bool    postRotate(SkScalar degrees, SkScalar px, SkScalar py);
+    /** Postconcats the matrix with the specified rotation.
+        M' = R(degrees) * M
+    */
+    bool    postRotate(SkScalar degrees);
+    /** Postconcats the matrix with the specified skew.
+        M' = K(kx, ky, px, py) * M
+    */
+    bool    postSkew(SkScalar kx, SkScalar ky, SkScalar px, SkScalar py);
+    /** Postconcats the matrix with the specified skew.
+        M' = K(kx, ky) * M
+    */
+    bool    postSkew(SkScalar kx, SkScalar ky);
+    /** Postconcats the matrix with the specified matrix.
+        M' = other * M
+    */
+    bool    postConcat(const SkMatrix& other);
 
-       /**     Postconcats the matrix with the specified translation.
-               M' = T(dx, dy) * M
-       */
-       bool    postTranslate(SkScalar dx, SkScalar dy);
-       /**     Postconcats the matrix with the specified scale.
-               M' = S(sx, sy, px, py) * M
-       */
-       bool    postScale(SkScalar sx, SkScalar sy, SkScalar px, SkScalar py);
-       /**     Postconcats the matrix with the specified rotation.
-               M' = R(degrees, px, py) * M
-       */
-       bool    postRotate(SkScalar degrees, SkScalar px, SkScalar py);
-       /**     Postconcats the matrix with the specified skew.
-               M' = K(kx, ky, px, py) * M
-       */
-       bool    postSkew(SkScalar kx, SkScalar ky, SkScalar px, SkScalar py);
-       /**     Postconcats the matrix with the specified matrix.
-               M' = other * M
-       */
-       bool    postConcat(const SkMatrix& other);
+    enum ScaleToFit {
+        kFill_ScaleToFit,       //!< scale in X and Y independently
+        kStart_ScaleToFit,      //!< uniform scale in X/Y, align along left/top
+        kCenter_ScaleToFit,     //!< uniform scale in X/Y, align along center
+        kEnd_ScaleToFit         //!< uniform scale in X/Y, align along right/bottom
+    };
+    /** Set the matrix to the scale and translate values that map the source rectangle
+        to the destination rectangle, returning true if the the result can be represented.
+        @param src the source rectangle to map from.
+        @param dst the destination rectangle to map to.
+        @param stf the ScaleToFit option
+        @return true if the matrix can be represented by the rectangle mapping.
+    */
+    bool    setRectToRect(const SkRect& src, const SkRect& dst, ScaleToFit stf = kFill_ScaleToFit);
+    /** Set the matrix such that the specified src points would map to the
+        specified dst points. count must be within [0..4].
+    */
+    bool    setPolyToPoly(const SkPoint dst[], const SkPoint src[], int count);
 
-       enum ScaleToFit {
-               kFill_ScaleToFit,               //!< scale in X and Y independently
-               kStart_ScaleToFit,              //!< uniform scale in X/Y, align along left/top
-               kCenter_ScaleToFit,             //!< uniform scale in X/Y, align along center
-               kEnd_ScaleToFit                 //!< uniform scale in X/Y, align along right/bottom
-       };
-       /**     Set the matrix to the scale and translate values that map the source rectangle
-               to the destination rectangle, returning true if the the result can be represented.
-               @param src the source rectangle to map from.
-               @param dst the destination rectangle to map to.
-               @param stf the ScaleToFit option
-               @return true if the matrix can be represented by the rectangle mapping.
-       */
-       bool    setRectToRect(const SkRect& src, const SkRect& dst, ScaleToFit stf = kFill_ScaleToFit);
-       /**     Set the matrix such that the specified src points would map to the
-               specified dst points. count must be withing [0..4].
-       */
-       bool    setPolyToPoly(const SkPoint dst[], const SkPoint src[], int count);
 
+    /** If this matrix can be inverted, return true and if inverse is not nil, set inverse
+        to be the inverse of this matrix. If this matrix cannot be inverted, ignore inverse
+        and return false
+    */
+    bool    invert(SkMatrix* inverse) const;
 
-       /**     If this matrix can be inverted, return true and if inverse is not nil, set inverse
-               to be the inverse of this matrix. If this matrix cannot be inverted, ignore inverse
-               and return false
-       */
-       bool    invert(SkMatrix* inverse) const;
+    /** Apply this matrix to the array of points specified by src, and write the transformed
+        points into the array of points specified by dst.
+        dst[] = M * src[]
+        This method is not exported to java.
+        @param dst  Where the transformed coordinates are written. It must contain at least count entries
+        @param src  The original coordinates that are to be transformed. It must contain at least count entries
+        @param count The number of points in src to read, and then transform into dst.
+        @param typeMask The mask bits returned by getType() for this matrix.
+    */
+    bool    mapPoints(SkPoint dst[], const SkPoint src[], int count, TypeMask typeMask) const;
+    /** Apply this matrix to the array of points specified by src, and write the transformed
+        points into the array of points specified by dst.
+        dst[] = M * src[]
+        @param dst  Where the transformed coordinates are written. It must contain at least count entries
+        @param src  The original coordinates that are to be transformed. It must contain at least count entries
+        @param count The number of points in src to read, and then transform into dst.
+    */
+    bool mapPoints(SkPoint dst[], const SkPoint src[], int count) const
+    {
+        return this->mapPoints(dst, src, count, this->getType());
+    }
+    /** Apply this matrix to the array of points, overwriting it with the transformed values.
+        dst[] = M * pts[]
+        @param pts  The points to be transformed. It must contain at least count entries
+        @param count The number of points in pts.
+    */
+    bool mapPoints(SkPoint pts[], int count) const
+    {
+        return this->mapPoints(pts, pts, count, this->getType());
+    }
 
-       /**     Apply this matrix to the array of points specified by src, and write the transformed
-               points into the array of points specified by dst.
-               dst[] = M * src[]
-               @param dst      Where the transformed coordinates are written. It must contain at least count entries
-               @param src      The original coordinates that are to be transformed. It must contain at least count entries
-               @param count The number of points in src to read, and then transform into dst.
-               @param typeMask The mask bits returned by getType() for this matrix.
-       */
-       bool    mapPoints(SkPoint dst[], const SkPoint src[], int count, TypeMask typeMask) const;
-       /**     Apply this matrix to the array of vectors specified by src, and write the transformed
-               vectors into the array of points specified by dst. This is similar to mapPoints, but
-               ignores any translation in the matrix.
-               @param dst      Where the transformed coordinates are written. It must contain at least count entries
-               @param src      The original coordinates that are to be transformed. It must contain at least count entries
-               @param count The number of vectors in src to read, and then transform into dst.
-               @param typeMask The mask bits returned by getType() for this matrix.
-       */
-       bool    mapVectors(SkVector dst[], const SkVector src[], int count, TypeMask typeMask) const;
-       /**     Apply this matrix to the src rectangle, and write the transformed rectangle into
-               dst. This is accomplished by transforming the 4 corners of src, and then setting
-               dst to the bounds of those points.
-               @param dst      Where the transformed rectangle is written.
-               @param src      The original rectangle to be transformed.
-               @param typeMask The mask bits returned by getType() for this matrix.
-       */
-       bool    mapRect(SkRect* dst, const SkRect& src, TypeMask typeMask) const;
+    /** Apply this matrix to the array of vectors specified by src, and write the transformed
+        vectors into the array of vectors specified by dst. This is similar to mapPoints, but
+        ignores any translation in the matrix.
+        This method is not exported to java.
+        @param dst  Where the transformed coordinates are written. It must contain at least count entries
+        @param src  The original coordinates that are to be transformed. It must contain at least count entries
+        @param count The number of vectors in src to read, and then transform into dst.
+        @param typeMask The mask bits returned by getType() for this matrix.
+    */
+    bool    mapVectors(SkVector dst[], const SkVector src[], int count, TypeMask typeMask) const;
+    /** Apply this matrix to the array of vectors specified by src, and write the transformed
+        vectors into the array of vectors specified by dst. This is similar to mapPoints, but
+        ignores any translation in the matrix.
+        @param dst  Where the transformed coordinates are written. It must contain at least count entries
+        @param src  The original coordinates that are to be transformed. It must contain at least count entries
+        @param count The number of vectors in src to read, and then transform into dst.
+    */
+    bool mapVectors(SkVector dst[], const SkVector src[], int count) const
+    {
+        return this->mapVectors(dst, src, count, this->getType());
+    }
+    /** Apply this matrix to the array of vectors specified by src, and write the transformed
+        vectors into the array of vectors specified by dst. This is similar to mapPoints, but
+        ignores any translation in the matrix.
+        @param vecs The vectors to be transformed. It must contain at least count entries
+        @param count The number of vectors in vecs.
+    */
+    bool mapVectors(SkVector vecs[], int count) const
+    {
+        return this->mapVectors(vecs, vecs, count, this->getType());
+    }
 
-       /**     Helper method for mapPoints() where the TypeMask needs to be computed.
-       */
-       bool mapPoints(SkPoint dst[], const SkPoint src[], int count) const
-       {
-               return this->mapPoints(dst, src, count, this->getType());
-       }
-       /**     Helper method for mapPoints() where the src and dst arrays are the
-               same, and the TypeMask needs to be computed.
-       */
-       bool mapPoints(SkPoint pts[], int count) const
-       {
-               return this->mapPoints(pts, pts, count, this->getType());
-       }
-       /**     Helper method for mapVectors() where the TypeMask needs to be computed.
-       */
-       bool mapVectors(SkVector dst[], const SkVector src[], int count) const
-       {
-               return this->mapVectors(dst, src, count, this->getType());
-       }
-       /**     Helper method for mapVectors() where the src and dst arrays are the
-               same, and the TypeMask needs to be computed.
-       */
-       bool mapVectors(SkVector vecs[], int count) const
-       {
-               return this->mapVectors(vecs, vecs, count, this->getType());
-       }
-       /**     Helper method for mapRect() where the TypeMask needs to be computed.
-       */
-       bool mapRect(SkRect* dst, const SkRect& src) const
-       {
-               return this->mapRect(dst, src, this->getType());
-       }
-       /**     Helper method for mapRect() where the TypeMask needs to be computed
-               and the src and dst rects are the same (i.e. map in place)
-       */
-       bool mapRect(SkRect* rect) const
-       {
-               return this->mapRect(rect, *rect, this->getType());
-       }
+    /** Apply this matrix to the src rectangle, and write the transformed rectangle into
+        dst. This is accomplished by transforming the 4 corners of src, and then setting
+        dst to the bounds of those points.
+        This method is not exported to java.
+        @param dst  Where the transformed rectangle is written.
+        @param src  The original rectangle to be transformed.
+        @param typeMask The mask bits returned by getType() for this matrix.
+    */
+    bool    mapRect(SkRect* dst, const SkRect& src, TypeMask typeMask) const;
+    /** Apply this matrix to the src rectangle, and write the transformed rectangle into
+        dst. This is accomplished by transforming the 4 corners of src, and then setting
+        dst to the bounds of those points.
+        @param dst  Where the transformed rectangle is written.
+        @param src  The original rectangle to be transformed.
+    */
+    bool mapRect(SkRect* dst, const SkRect& src) const
+    {
+        return this->mapRect(dst, src, this->getType());
+    }
+    /** Apply this matrix to the rectangle, and write the transformed rectangle back into it.
+        This is accomplished by transforming the 4 corners of rect, and then setting
+        it to the bounds of those points
+        @param rect The rectangle to transform.
+    */
+    bool mapRect(SkRect* rect) const
+    {
+        return this->mapRect(rect, *rect, this->getType());
+    }
 
-       /**     Return the mean radius of a circle after it has been mapped by
-               this matrix. NOTE: in perspective this value assumes the circle
-               has its center at the origin.
-       */
-       SkScalar mapRadius(SkScalar radius) const;
+    /** Return the mean radius of a circle after it has been mapped by
+        this matrix. NOTE: in perspective this value assumes the circle
+        has its center at the origin.
+    */
+    SkScalar mapRadius(SkScalar radius) const;
 
-       typedef void (*MapPtProc)(const SkMatrix& mat, SkScalar x, SkScalar y, SkPoint* result);
-       MapPtProc       getMapPtProc() const;
+    typedef void (*MapPtProc)(const SkMatrix& mat, SkScalar x, SkScalar y, SkPoint* result);
+    MapPtProc   getMapPtProc() const;
 
-       /**     If the matrix can be stepped in X (not complex perspective)
-               then return true and if step[XY] is not nil, return the step[XY] value.
-               If it cannot, return false and ignore step.
-       */
-       bool fixedStepInX(SkScalar y, SkFixed* stepX, SkFixed* stepY) const;
+    /** If the matrix can be stepped in X (not complex perspective)
+        then return true and if step[XY] is not nil, return the step[XY] value.
+        If it cannot, return false and ignore step.
+        This method is not exported to java.
+    */
+    bool fixedStepInX(SkScalar y, SkFixed* stepX, SkFixed* stepY) const;
 
-       friend bool operator==(const SkMatrix& a, const SkMatrix& b)
-       {
-               return memcmp(a.fMat, b.fMat, sizeof(a)) == 0;
-       }
+    friend bool operator==(const SkMatrix& a, const SkMatrix& b)
+    {
+        return memcmp(a.fMat, b.fMat, sizeof(a)) == 0;
+    }
 
 #ifdef SK_DEBUG
   /** @cond UNIT_TEST */
   void dump() const;
 
-       static void UnitTest();
+    static void UnitTest();
   /** @endcond */
 #endif
 
 private:
-       SkScalar fMat[9];
+    SkScalar fMat[9];
 
-       static void Map2Pt(const SkPoint srcPt[], SkMatrix* dst, SkScalar scale);
-       static void Map3Pt(const SkPoint srcPt[], SkMatrix* dst, SkScalar scaleX, SkScalar scaleY);
-       static void Map4Pt(const SkPoint srcPt[], SkMatrix* dst, SkScalar scaleX, SkScalar scaleY);
+    static void Map2Pt(const SkPoint srcPt[], SkMatrix* dst, SkScalar scale);
+    static void Map3Pt(const SkPoint srcPt[], SkMatrix* dst, SkScalar scaleX, SkScalar scaleY);
+    static void Map4Pt(const SkPoint srcPt[], SkMatrix* dst, SkScalar scaleX, SkScalar scaleY);
 
-       static void Perspective_ptProc(const SkMatrix&, SkScalar, SkScalar, SkPoint*);
-       static void Affine_ptProc(const SkMatrix&, SkScalar, SkScalar, SkPoint*);
-       static void Scale_ptProc(const SkMatrix&, SkScalar, SkScalar, SkPoint*);
-       static void Translate_ptProc(const SkMatrix&, SkScalar, SkScalar, SkPoint*);
-       static void Identity_ptProc(const SkMatrix&, SkScalar, SkScalar, SkPoint*);
+    static void Perspective_ptProc(const SkMatrix&, SkScalar, SkScalar, SkPoint*);
+    static void Affine_ptProc(const SkMatrix&, SkScalar, SkScalar, SkPoint*);
+    static void Scale_ptProc(const SkMatrix&, SkScalar, SkScalar, SkPoint*);
+    static void Translate_ptProc(const SkMatrix&, SkScalar, SkScalar, SkPoint*);
+    static void Identity_ptProc(const SkMatrix&, SkScalar, SkScalar, SkPoint*);
+    
+    friend class SkPerspIter;
 };
 
 #endif
diff --git a/include/corecg/SkPerspIter.h b/include/corecg/SkPerspIter.h
new file mode 100644 (file)
index 0000000..1a5d82f
--- /dev/null
@@ -0,0 +1,56 @@
+/* include/corecg/SkPerspIter.h
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
+#ifndef SkPerspIter_DEFINED
+#define SkPerspIter_DEFINED
+
+#include "SkMatrix.h"
+
+class SkPerspIter {
+public:
+    /** Iterate a line through the matrix [x,y] ... [x+count-1, y].
+        @param m    The matrix we will be iterating a line through
+        @param x    The initial X coordinate to be mapped through the matrix
+        @param y    The initial Y coordinate to be mapped through the matrix
+        @param count The number of points (x,y) (x+1,y) (x+2,y) ... we will eventually map
+    */
+    SkPerspIter(const SkMatrix& m, SkScalar x, SkScalar y, int count);
+    
+    /** Return the buffer of [x,y] fixed point values we will be filling.
+        This always returns the same value, so it can be saved across calls to
+        next().
+    */
+    const SkFixed* getXY() const { return fStorage; }
+
+    /** Return the number of [x,y] pairs that have been filled in the getXY() buffer.
+        When this returns 0, the iterator is finished.
+    */
+    int next();
+    
+private:
+    enum {
+        kShift  = 4,
+        kCount  = (1 << kShift)
+    };
+    const SkMatrix& fMatrix;
+    SkFixed         fStorage[kCount * 2];
+    SkFixed         fX, fY;
+    SkScalar        fSX, fSY;
+    int             fCount;
+};
+
+#endif
index 5c9e165..b4c3b40 100644 (file)
+/* include/corecg/SkPoint.h
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #ifndef SkPoint_DEFINED
 #define SkPoint_DEFINED
 
 #include "SkMath.h"
 
-/**    \struct SkPoint16
+/** \struct SkPoint16
 
-       SkPoint16 holds two 16 bit integer coordinates
+    SkPoint16 holds two 16 bit integer coordinates
 */
 struct SkPoint16 {
-       int16_t fX, fY;
-
-       void set(S16CPU x, S16CPU y) { fX = SkToS16(x); fY = SkToS16(y); }
-
-       /**     Rotate the point clockwise, writing the new point into dst
-               It is legal for dst == this
-       */
-       void rotateCW(SkPoint16* dst) const;
-       /**     Rotate the point clockwise, writing the new point back into the point
-       */
-       void rotateCW() { this->rotateCW(this); }
-       /**     Rotate the point counter-clockwise, writing the new point into dst.
-               It is legal for dst == this
-       */
-       void rotateCCW(SkPoint16* dst) const;
-       /**     Rotate the point counter-clockwise, writing the new point back into the point
-       */
-       void rotateCCW() { this->rotateCCW(this); }
-       /**     Negate the X and Y coordinates of the point.
-       */
-       void negate() { fX = -fX; fY = -fY; }
-       /**     Return a new point whose X and Y coordinates are the negative of the original point's
-       */
-       SkPoint16 operator-() const
-       {
-               SkPoint16 neg;
-               neg.fX = -fX;
-               neg.fY = -fY;
-               return neg;
-       }
-       /**     Add v's coordinates to this point's
-       */
-       void operator+=(const SkPoint16& v)
-       {
-               fX = SkToS16(fX + v.fX);
-               fY = SkToS16(fY + v.fY);
-       }
-       /**     Subtract v's coordinates from this point's
-       */
-       void operator-=(const SkPoint16& v)
-       {
-               fX = SkToS16(fX - v.fX);
-               fY = SkToS16(fY - v.fY);
-       }
-       /**     Returns true if the point's coordinates equal (x,y)
-       */
-       bool equals(S16CPU x, S16CPU y) const { return fX == x && fY == y; }
-       friend bool operator==(const SkPoint16& a, const SkPoint16& b)
-       {
-               return a.fX == b.fX && a.fY == b.fY;
-       }
-       friend bool operator!=(const SkPoint16& a, const SkPoint16& b)
-       {
-               return a.fX != b.fX || a.fY != b.fY;
-       }
-       /**     Returns a new point whose coordinates are the difference between a and b (a - b)
-       */
-       friend SkPoint16 operator-(const SkPoint16& a, const SkPoint16& b)
-       {
-               SkPoint16 v;
-               v.set(a.fX - b.fX, a.fY - b.fY);
-               return v;
-       }
-       /**     Returns a new point whose coordinates are the sum of a and b (a + b)
-       */
-       friend SkPoint16 operator+(const SkPoint16& a, const SkPoint16& b)
-       {
-               SkPoint16 v;
-               v.set(a.fX + b.fX, a.fY + b.fY);
-               return v;
-       }
-       /**     Returns the dot product of a and b, treating them as 2D vectors
-       */
-       static int32_t DotProduct(const SkPoint16& a, const SkPoint16& b)
-       {
-               return a.fX * b.fX + a.fY * b.fY;
-       }
-       /**     Returns the cross product of a and b, treating them as 2D vectors
-       */
-       static int32_t CrossProduct(const SkPoint16& a, const SkPoint16& b)
-       {
-               return a.fX * b.fY - a.fY * b.fX;
-       }
+    int16_t fX, fY;
+
+    void set(S16CPU x, S16CPU y) { fX = SkToS16(x); fY = SkToS16(y); }
+
+    /** Rotate the point clockwise, writing the new point into dst
+        It is legal for dst == this
+    */
+    void rotateCW(SkPoint16* dst) const;
+    /** Rotate the point clockwise, writing the new point back into the point
+    */
+    void rotateCW() { this->rotateCW(this); }
+    /** Rotate the point counter-clockwise, writing the new point into dst.
+        It is legal for dst == this
+    */
+    void rotateCCW(SkPoint16* dst) const;
+    /** Rotate the point counter-clockwise, writing the new point back into the point
+    */
+    void rotateCCW() { this->rotateCCW(this); }
+    /** Negate the X and Y coordinates of the point.
+    */
+    void negate() { fX = -fX; fY = -fY; }
+    /** Return a new point whose X and Y coordinates are the negative of the original point's
+    */
+    SkPoint16 operator-() const
+    {
+        SkPoint16 neg;
+        neg.fX = -fX;
+        neg.fY = -fY;
+        return neg;
+    }
+    /** Add v's coordinates to this point's
+    */
+    void operator+=(const SkPoint16& v)
+    {
+        fX = SkToS16(fX + v.fX);
+        fY = SkToS16(fY + v.fY);
+    }
+    /** Subtract v's coordinates from this point's
+    */
+    void operator-=(const SkPoint16& v)
+    {
+        fX = SkToS16(fX - v.fX);
+        fY = SkToS16(fY - v.fY);
+    }
+    /** Returns true if the point's coordinates equal (x,y)
+    */
+    bool equals(S16CPU x, S16CPU y) const { return fX == x && fY == y; }
+    friend bool operator==(const SkPoint16& a, const SkPoint16& b)
+    {
+        return a.fX == b.fX && a.fY == b.fY;
+    }
+    friend bool operator!=(const SkPoint16& a, const SkPoint16& b)
+    {
+        return a.fX != b.fX || a.fY != b.fY;
+    }
+    /** Returns a new point whose coordinates are the difference between a and b (a - b)
+    */
+    friend SkPoint16 operator-(const SkPoint16& a, const SkPoint16& b)
+    {
+        SkPoint16 v;
+        v.set(a.fX - b.fX, a.fY - b.fY);
+        return v;
+    }
+    /** Returns a new point whose coordinates are the sum of a and b (a + b)
+    */
+    friend SkPoint16 operator+(const SkPoint16& a, const SkPoint16& b)
+    {
+        SkPoint16 v;
+        v.set(a.fX + b.fX, a.fY + b.fY);
+        return v;
+    }
+    /** Returns the dot product of a and b, treating them as 2D vectors
+    */
+    static int32_t DotProduct(const SkPoint16& a, const SkPoint16& b)
+    {
+        return a.fX * b.fX + a.fY * b.fY;
+    }
+    /** Returns the cross product of a and b, treating them as 2D vectors
+    */
+    static int32_t CrossProduct(const SkPoint16& a, const SkPoint16& b)
+    {
+        return a.fX * b.fY - a.fY * b.fX;
+    }
 };
 
 struct SkPoint32 {
-       int32_t fX, fY;
+    int32_t fX, fY;
 
-       void set(int x, int y) { fX = x; fY = y; }
+    void set(int x, int y) { fX = x; fY = y; }
+
+    bool equals(int x, int y) const { return fX == x && fY == y; }
 };
 
 struct SkPoint {
-       SkScalar        fX, fY;
-
-       /**     Set the point's X and Y coordinates
-       */
-       void set(SkScalar x, SkScalar y) { fX = x; fY = y; }
-       /**     Set the point's X and Y coordinates by automatically promoting (x,y) to SkScalar values.
-       */
-       void iset(S16CPU x, S16CPU y) { fX = SkIntToScalar(x); fY = SkIntToScalar(y); }
-       /**     Set the point's X and Y coordinates by automatically promoting p's coordinates to SkScalar values.
-       */
-       void iset(const SkPoint16& p) { fX = SkIntToScalar(p.fX); fY = SkIntToScalar(p.fY); }
-
-       /**     Return the euclidian distance from (0,0) to the point
-       */
-       SkScalar length() const { return SkPoint::Length(fX, fY); }
-
-       /**     Set the point (vector) to be unit-length in the same direction as it
-               currently is, and return its old length. If the old length is
-               degenerately small (nearly zero), do nothing and return 0.
-       */
-       bool normalize();
-       /**     Set the point (vector) to be unit-length in the same direction as the
-               x,y params, and return their old length. If the old length is
-               degenerately small (nearly zero), do nothing and return 0.
-       */
-       bool setUnit(SkScalar x, SkScalar y);
-       /**     Scale the point to have the specified length, and return that
-               length. If the original length is
-               degenerately small (nearly zero), do nothing and return 0.
-       */
-       bool setLength(SkScalar length);
-       /**     Set the point to have the specified length in the same direction as (x,y),
-               and return the old length of (x,y). If that old length is
-               degenerately small (nearly zero), do nothing and return 0.
-       */
-       bool setLength(SkScalar x, SkScalar y, SkScalar length);
-
-       /**     Scale the point's coordinates by scale, writing the answer into dst.
-               It is legal for dst == this.
-       */
-       void scale(SkScalar scale, SkPoint* dst) const;
-       /**     Scale the point's coordinates by scale, writing the answer back into the point.
-       */
-       void scale(SkScalar scale) { this->scale(scale, this); }
-
-       /**     Rotate the point clockwise by 90 degrees, writing the answer into dst.
-               It is legal for dst == this.
-       */
-       void rotateCW(SkPoint* dst) const;
-       /**     Rotate the point clockwise by 90 degrees, writing the answer back into the point.
-       */
-       void rotateCW() { this->rotateCW(this); }
-       /**     Rotate the point counter-clockwise by 90 degrees, writing the answer into dst.
-               It is legal for dst == this.
-       */
-       void rotateCCW(SkPoint* dst) const;
-       /**     Rotate the point counter-clockwise by 90 degrees, writing the answer back into the point.
-       */
-       void rotateCCW() { this->rotateCCW(this); }
-       /**     Negate the point's coordinates
-       */
-       void negate() { fX = -fX; fY = -fY; }
-       /**     Returns a new point whose coordinates are the negative of the point's
-       */
-       SkPoint operator-() const
-       {
-               SkPoint neg;
-               neg.fX = -fX;
-               neg.fY = -fY;
-               return neg;
-       }
-
-       /**     Add v's coordinates to the point's
-       */
-       void operator+=(const SkPoint& v)
-       {
-               fX += v.fX;
-               fY += v.fY;
-       }
-       /**     Subtract v's coordinates from the point's
-       */
-       void operator-=(const SkPoint& v)
-       {
-               fX -= v.fX;
-               fY -= v.fY;
-       }
-
-       /**     Returns true if the point's coordinates equal (x,y)
-       */
-       bool equals(SkScalar x, SkScalar y) const { return fX == x && fY == y; }
-       friend bool operator==(const SkPoint& a, const SkPoint& b)
-       {
-               return a.fX == b.fX && a.fY == b.fY;
-       }
-       friend bool operator!=(const SkPoint& a, const SkPoint& b)
-       {
-               return a.fX != b.fX || a.fY != b.fY;
-       }
-
-       /**     Returns a new point whose coordinates are the difference between a's and b's (a - b)
-       */
-       friend SkPoint operator-(const SkPoint& a, const SkPoint& b)
-       {
-               SkPoint v;
-               v.set(a.fX - b.fX, a.fY - b.fY);
-               return v;
-       }
-       /**     Returns a new point whose coordinates are the sum of a's and b's (a + b)
-       */
-       friend SkPoint operator+(const SkPoint& a, const SkPoint& b)
-       {
-               SkPoint v;
-               v.set(a.fX + b.fX, a.fY + b.fY);
-               return v;
-       }
-       /**     Returns the euclidian distance from (0,0) to (x,y)
-       */
-       static SkScalar Length(SkScalar x, SkScalar y);
-       /**     Returns the euclidian distance between a and b
-       */
-       static SkScalar Distance(const SkPoint& a, const SkPoint& b)
-       {
-               return Length(a.fX - b.fX, a.fY - b.fY);
-       }
-       /**     Returns the dot product of a and b, treating them as 2D vectors
-       */
-       static SkScalar DotProduct(const SkPoint& a, const SkPoint& b)
-       {
-               return SkScalarMul(a.fX, b.fX) + SkScalarMul(a.fY, b.fY);
-       }
-       /**     Returns the cross product of a and b, treating them as 2D vectors
-       */
-       static SkScalar CrossProduct(const SkPoint& a, const SkPoint& b)
-       {
-               return SkScalarMul(a.fX, b.fY) - SkScalarMul(a.fY, b.fX);
-       }
+    SkScalar    fX, fY;
+
+    /** Set the point's X and Y coordinates
+    */
+    void set(SkScalar x, SkScalar y) { fX = x; fY = y; }
+    /** Set the point's X and Y coordinates by automatically promoting (x,y) to SkScalar values.
+    */
+    void iset(S16CPU x, S16CPU y) { fX = SkIntToScalar(x); fY = SkIntToScalar(y); }
+    /** Set the point's X and Y coordinates by automatically promoting p's coordinates to SkScalar values.
+    */
+    void iset(const SkPoint16& p) { fX = SkIntToScalar(p.fX); fY = SkIntToScalar(p.fY); }
+
+    /** Return the euclidian distance from (0,0) to the point
+    */
+    SkScalar length() const { return SkPoint::Length(fX, fY); }
+
+    /** Set the point (vector) to be unit-length in the same direction as it
+        currently is, and return its old length. If the old length is
+        degenerately small (nearly zero), do nothing and return 0.
+    */
+    bool normalize();
+    /** Set the point (vector) to be unit-length in the same direction as the
+        x,y params, and return their old length. If the old length is
+        degenerately small (nearly zero), do nothing and return 0.
+    */
+    bool setUnit(SkScalar x, SkScalar y);
+    /** Scale the point to have the specified length, and return that
+        length. If the original length is
+        degenerately small (nearly zero), do nothing and return 0.
+    */
+    bool setLength(SkScalar length);
+    /** Set the point to have the specified length in the same direction as (x,y),
+        and return the old length of (x,y). If that old length is
+        degenerately small (nearly zero), do nothing and return 0.
+    */
+    bool setLength(SkScalar x, SkScalar y, SkScalar length);
+
+    /** Scale the point's coordinates by scale, writing the answer into dst.
+        It is legal for dst == this.
+    */
+    void scale(SkScalar scale, SkPoint* dst) const;
+    /** Scale the point's coordinates by scale, writing the answer back into the point.
+    */
+    void scale(SkScalar scale) { this->scale(scale, this); }
+
+    /** Rotate the point clockwise by 90 degrees, writing the answer into dst.
+        It is legal for dst == this.
+    */
+    void rotateCW(SkPoint* dst) const;
+    /** Rotate the point clockwise by 90 degrees, writing the answer back into the point.
+    */
+    void rotateCW() { this->rotateCW(this); }
+    /** Rotate the point counter-clockwise by 90 degrees, writing the answer into dst.
+        It is legal for dst == this.
+    */
+    void rotateCCW(SkPoint* dst) const;
+    /** Rotate the point counter-clockwise by 90 degrees, writing the answer back into the point.
+    */
+    void rotateCCW() { this->rotateCCW(this); }
+    /** Negate the point's coordinates
+    */
+    void negate() { fX = -fX; fY = -fY; }
+    /** Returns a new point whose coordinates are the negative of the point's
+    */
+    SkPoint operator-() const
+    {
+        SkPoint neg;
+        neg.fX = -fX;
+        neg.fY = -fY;
+        return neg;
+    }
+
+    /** Add v's coordinates to the point's
+    */
+    void operator+=(const SkPoint& v)
+    {
+        fX += v.fX;
+        fY += v.fY;
+    }
+    /** Subtract v's coordinates from the point's
+    */
+    void operator-=(const SkPoint& v)
+    {
+        fX -= v.fX;
+        fY -= v.fY;
+    }
+
+    /** Returns true if the point's coordinates equal (x,y)
+    */
+    bool equals(SkScalar x, SkScalar y) const { return fX == x && fY == y; }
+    friend bool operator==(const SkPoint& a, const SkPoint& b)
+    {
+        return a.fX == b.fX && a.fY == b.fY;
+    }
+    friend bool operator!=(const SkPoint& a, const SkPoint& b)
+    {
+        return a.fX != b.fX || a.fY != b.fY;
+    }
+
+    /** Returns a new point whose coordinates are the difference between a's and b's (a - b)
+    */
+    friend SkPoint operator-(const SkPoint& a, const SkPoint& b)
+    {
+        SkPoint v;
+        v.set(a.fX - b.fX, a.fY - b.fY);
+        return v;
+    }
+    /** Returns a new point whose coordinates are the sum of a's and b's (a + b)
+    */
+    friend SkPoint operator+(const SkPoint& a, const SkPoint& b)
+    {
+        SkPoint v;
+        v.set(a.fX + b.fX, a.fY + b.fY);
+        return v;
+    }
+    /** Returns the euclidian distance from (0,0) to (x,y)
+    */
+    static SkScalar Length(SkScalar x, SkScalar y);
+    /** Returns the euclidian distance between a and b
+    */
+    static SkScalar Distance(const SkPoint& a, const SkPoint& b)
+    {
+        return Length(a.fX - b.fX, a.fY - b.fY);
+    }
+    /** Returns the dot product of a and b, treating them as 2D vectors
+    */
+    static SkScalar DotProduct(const SkPoint& a, const SkPoint& b)
+    {
+        return SkScalarMul(a.fX, b.fX) + SkScalarMul(a.fY, b.fY);
+    }
+    /** Returns the cross product of a and b, treating them as 2D vectors
+    */
+    static SkScalar CrossProduct(const SkPoint& a, const SkPoint& b)
+    {
+        return SkScalarMul(a.fX, b.fY) - SkScalarMul(a.fY, b.fX);
+    }
 };
 
 typedef SkPoint SkVector;
index 18f1517..65562dc 100644 (file)
@@ -1,22 +1,39 @@
+/* include/corecg/SkPostConfig.h
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #ifndef SkPostConfig_DEFINED
 #define SkPostConfig_DEFINED
 
 #if defined(SK_BUILD_FOR_WIN32) || defined(SK_BUILD_FOR_WINCE)
-       #define SK_BUILD_FOR_WIN
+    #define SK_BUILD_FOR_WIN
 #endif
 
 #if defined(SK_DEBUG) && defined(SK_RELEASE)
-       #error "cannot define both SK_DEBUG and SK_RELEASE"
+    #error "cannot define both SK_DEBUG and SK_RELEASE"
 #elif !defined(SK_DEBUG) && !defined(SK_RELEASE)
-       #error "must define either SK_DEBUG or SK_RELEASE"
+    #error "must define either SK_DEBUG or SK_RELEASE"
 #endif
 
 #if defined SK_SUPPORT_UNITTEST && !defined(SK_DEBUG)
-       #error "can't have unittests without debug"
+    #error "can't have unittests without debug"
 #endif
 
 #if defined(SK_SCALAR_IS_FIXED) && defined(SK_SCALAR_IS_FLOAT)
-       #error "cannot define both SK_SCALAR_IS_FIXED and SK_SCALAR_IS_FLOAT"
+    #error "cannot define both SK_SCALAR_IS_FIXED and SK_SCALAR_IS_FLOAT"
 #elif !defined(SK_SCALAR_IS_FIXED) && !defined(SK_SCALAR_IS_FLOAT)
     #ifdef SK_CAN_USE_FLOAT
         #define SK_SCALAR_IS_FLOAT
 #endif
 
 #if defined(SK_SCALAR_IS_FLOAT) && !defined(SK_CAN_USE_FLOAT)
-       #define SK_CAN_USE_FLOAT
-       // we do nothing in the else case: fixed-scalars can have floats or not
+    #define SK_CAN_USE_FLOAT
+    // we do nothing in the else case: fixed-scalars can have floats or not
 #endif
 
 #if defined(SK_CPU_LENDIAN) && defined(SK_CPU_BENDIAN)
-       #error "cannot define both SK_CPU_LENDIAN and SK_CPU_BENDIAN"
+    #error "cannot define both SK_CPU_LENDIAN and SK_CPU_BENDIAN"
 #elif !defined(SK_CPU_LENDIAN) && !defined(SK_CPU_BENDIAN)
-       #error "must define either SK_CPU_LENDIAN or SK_CPU_BENDIAN"
+    #error "must define either SK_CPU_LENDIAN or SK_CPU_BENDIAN"
 #endif
 
 #ifndef SkNEW
-       #define SkNEW(type_name)                                new type_name
-       #define SkNEW_ARGS(type_name, args)             new type_name args
-       #define SkDELETE(obj)                                   delete obj
+    #define SkNEW(type_name)                new type_name
+    #define SkNEW_ARGS(type_name, args)     new type_name args
+    #define SkDELETE(obj)                   delete obj
 #endif
 
 ///////////////////////////////////////////////////////////////////////////////
 
 #ifdef SK_BUILD_FOR_WIN
-       #define WIN32_LEAN_AND_MEAN
-       #include <windows.h>
-       #undef WIN32_LEAN_AND_MEAN
-
-       #ifndef SK_DEBUGBREAK
-               #define SK_DEBUGBREAK(cond)             do { if (!(cond)) DebugBreak(); } while (false)
-       #endif
-
-       #ifdef SK_BUILD_FOR_WIN32
-               #define strcasecmp(a, b)                stricmp(a, b)
-               #define strncasecmp(a, b, c)    strnicmp(a, b, c)
-       #elif defined(SK_BUILD_FOR_WINCE)
-               #define strcasecmp(a, b)                _stricmp(a, b)
-               #define strncasecmp(a, b, c)    _strnicmp(a, b, c)
-       #endif
+    #define WIN32_LEAN_AND_MEAN
+    #include <windows.h>
+    #undef WIN32_LEAN_AND_MEAN
+
+    #ifndef SK_DEBUGBREAK
+        #define SK_DEBUGBREAK(cond)     do { if (!(cond)) DebugBreak(); } while (false)
+    #endif
+
+    #ifdef SK_BUILD_FOR_WIN32
+        #define strcasecmp(a, b)        stricmp(a, b)
+        #define strncasecmp(a, b, c)    strnicmp(a, b, c)
+    #elif defined(SK_BUILD_FOR_WINCE)
+        #define strcasecmp(a, b)        _stricmp(a, b)
+        #define strncasecmp(a, b, c)    _strnicmp(a, b, c)
+    #endif
 #elif defined(SK_BUILD_FOR_MAC)
-       #include <carbon/carbon.h>
-       #ifndef SK_DEBUGBREAK
-               #define SK_DEBUGBREAK(cond)         do { if (!(cond)) sk_throw(); } while (false)
-       #endif
+    #include <carbon/carbon.h>
+    #ifndef SK_DEBUGBREAK
+        #define SK_DEBUGBREAK(cond)         do { if (!(cond)) sk_throw(); } while (false)
+    #endif
 #else
     #ifdef SK_DEBUG
         #include <assert.h>
         #ifndef SK_DEBUGBREAK
-            #define SK_DEBUGBREAK(cond)        assert(cond)
+            #define SK_DEBUGBREAK(cond) assert(cond)
         #endif
     #endif
 #endif
 
-//     stdlib macros
+//  stdlib macros
 
 #if 0
 #if !defined(strlen) && defined(SK_DEBUG)
-       extern size_t sk_strlen(const char*);
-       #define strlen(s)       sk_strlen(s)
+    extern size_t sk_strlen(const char*);
+    #define strlen(s)   sk_strlen(s)
 #endif
 #ifndef sk_strcpy
-       #define sk_strcpy(dst, src)             strcpy(dst, src)
+    #define sk_strcpy(dst, src)     strcpy(dst, src)
 #endif
 #ifndef sk_strchr
-       #define sk_strchr(s, c)                 strchr(s, c)
+    #define sk_strchr(s, c)         strchr(s, c)
 #endif
 #ifndef sk_strrchr
-       #define sk_strrchr(s, c)                strrchr(s, c)
+    #define sk_strrchr(s, c)        strrchr(s, c)
 #endif
 #ifndef sk_strcmp
-       #define sk_strcmp(s, t)                 strcmp(s, t)
+    #define sk_strcmp(s, t)         strcmp(s, t)
 #endif
 #ifndef sk_strncmp
-       #define sk_strncmp(s, t, n)             strncmp(s, t, n)
+    #define sk_strncmp(s, t, n)     strncmp(s, t, n)
 #endif
 #ifndef sk_memcpy
-       #define sk_memcpy(dst, src, n)  memcpy(dst, src, n)
+    #define sk_memcpy(dst, src, n)  memcpy(dst, src, n)
 #endif
 #ifndef memmove
-       #define memmove(dst, src, n)    memmove(dst, src, n)
+    #define memmove(dst, src, n)    memmove(dst, src, n)
 #endif
 #ifndef sk_memset
-       #define sk_memset(dst, val, n)  memset(dst, val, n)
+    #define sk_memset(dst, val, n)  memset(dst, val, n)
 #endif
 #ifndef sk_memcmp
-       #define sk_memcmp(s, t, n)              memcmp(s, t, n)
+    #define sk_memcmp(s, t, n)      memcmp(s, t, n)
 #endif
 
-#define sk_strequal(s, t)                      (!sk_strcmp(s, t))
-#define sk_strnequal(s, t, n)          (!sk_strncmp(s, t, n))
+#define sk_strequal(s, t)           (!sk_strcmp(s, t))
+#define sk_strnequal(s, t, n)       (!sk_strncmp(s, t, n))
 #endif
 
 //////////////////////////////////////////////////////////////////////////////////////////////
 
 #ifdef SK_DEBUG
 #if defined(SK_SIMULATE_FAILED_MALLOC) && defined(__cplusplus)
-       void * operator new(
+    void * operator new(
         size_t cb,
         int nBlockUse,
         const char * szFileName,
         int nLine,
-               int foo
+        int foo
         );
-       void * operator new[](
+    void * operator new[](
         size_t cb,
         int nBlockUse,
         const char * szFileName,
         int nLine,
-               int foo
+        int foo
         );
-       void operator delete(
+    void operator delete(
         void *pUserData,
-               int, const char*, int, int
+        int, const char*, int, int
         );
-       void operator delete(
+    void operator delete(
         void *pUserData
         );
-       void operator delete[]( void * p );
-       #define DEBUG_CLIENTBLOCK   new( _CLIENT_BLOCK, __FILE__, __LINE__, 0)
+    void operator delete[]( void * p );
+    #define DEBUG_CLIENTBLOCK   new( _CLIENT_BLOCK, __FILE__, __LINE__, 0)
 #else
-       #define DEBUG_CLIENTBLOCK   new( _CLIENT_BLOCK, __FILE__, __LINE__)
+    #define DEBUG_CLIENTBLOCK   new( _CLIENT_BLOCK, __FILE__, __LINE__)
 #endif
-       #define new DEBUG_CLIENTBLOCK
+    #define new DEBUG_CLIENTBLOCK
 #else
 #define DEBUG_CLIENTBLOCK
 #endif // _DEBUG
index 7e14287..10a5945 100644 (file)
@@ -1,3 +1,20 @@
+/* include/corecg/SkPreConfig.h
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #ifndef SkPreConfig_DEFINED
 #define SkPreConfig_DEFINED
 
 //////////////////////////////////////////////////////////////////////
 
 #if !defined(SK_DEBUG) && !defined(SK_RELEASE)
-       #ifdef NDEBUG
-               #define SK_RELEASE
-       #else
-               #define SK_DEBUG
-       #endif
+    #ifdef NDEBUG
+        #define SK_RELEASE
+    #else
+        #define SK_DEBUG
+    #endif
 #endif
 
 //////////////////////////////////////////////////////////////////////
 
 #ifdef SK_BUILD_FOR_WIN32
-       #define SK_SCALAR_IS_FLOAT
+    #define SK_SCALAR_IS_FLOAT
 #endif
 
 #if defined(SK_BUILD_FOR_WIN32) || defined(SK_BUILD_FOR_MAC)
-       #define SK_CAN_USE_FLOAT
+    #define SK_CAN_USE_FLOAT
     #define SK_SCALAR_IS_FIXED
-       #define SK_CAN_USE_LONGLONG
+    #define SK_CAN_USE_LONGLONG
 #endif
 
 //////////////////////////////////////////////////////////////////////
 
 #ifdef SK_CAN_USE_LONGLONG
-       #ifdef SK_BUILD_FOR_WIN32
-               #define SkLONGLONG      __int64
-       #else
-               #define SkLONGLONG      long long
-       #endif
+    #ifdef SK_BUILD_FOR_WIN32
+        #define SkLONGLONG  __int64
+    #else
+        #define SkLONGLONG  long long
+    #endif
 #endif
 
 //////////////////////////////////////////////////////////////////////
 #if !defined(SK_CPU_BENDIAN) && !defined(SK_CPU_LENDIAN)
 
 #ifdef SK_BUILD_FOR_MAC
-       #define SK_CPU_BENDIAN
+    #define SK_CPU_BENDIAN
 #else
-       #define SK_CPU_LENDIAN
+    #define SK_CPU_LENDIAN
 #endif
 
 #endif
 
-#if defined(SK_BUILD_FOR_BREW) || defined(SK_BUILD_FOR_WINCE) || (defined(SK_BUILD_FOR_SYMBIAN) && !defined(__MARM_THUMB__))
-       /* e.g. the ARM instructions have conditional execution, making tiny branches cheap */
-       #define SK_CPU_HAS_CONDITIONAL_INSTR
+#if defined(__arm__) || defined(SK_BUILD_FOR_BREW) || defined(SK_BUILD_FOR_WINCE) || (defined(SK_BUILD_FOR_SYMBIAN) && !defined(__MARM_THUMB__))
+    /* e.g. the ARM instructions have conditional execution, making tiny branches cheap */
+    #define SK_CPU_HAS_CONDITIONAL_INSTR
 #endif
 
 //////////////////////////////////////////////////////////////////////
index 362117e..449672c 100644 (file)
+/* include/corecg/SkRandom.h
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #ifndef SkRandom_DEFINED
 #define SkRandom_DEFINED
 
 #include "Sk64.h"
 
-/**    \class SkRandom
+/** \class SkRandom
 
-       Utility class that implements pseudo random 32bit numbers using a fast
-       linear equation. Unlike rand(), this class holds its own seed (initially
-       set to 0), so that multiple instances can be used with no side-effects.
+    Utility class that implements pseudo random 32bit numbers using a fast
+    linear equation. Unlike rand(), this class holds its own seed (initially
+    set to 0), so that multiple instances can be used with no side-effects.
 */
 class SkRandom {
 public:
-       SkRandom() : fSeed(0) {}
-       SkRandom(uint32_t seed) : fSeed(seed) {}
+    SkRandom() : fSeed(0) {}
+    SkRandom(uint32_t seed) : fSeed(seed) {}
 
-       /**     Return the next pseudo random number as an unsigned 32bit value.
-       */
-       uint32_t        nextU() { uint32_t r = fSeed * kMul + kAdd; fSeed = r; return r; }
-       /**     Return the next pseudo random number as a signed 32bit value.
-       */
-       int32_t nextS() { return (int32_t)this->nextU(); }
-       /**     Return the next pseudo random number as an unsigned 16bit value.
-       */
-       U16CPU nextU16() { return this->nextU() >> 16; }
-       /**     Return the next pseudo random number as a signed 16bit value.
-       */
-       S16CPU nextS16() { return this->nextS() >> 16; }
+    /** Return the next pseudo random number as an unsigned 32bit value.
+    */
+    uint32_t    nextU() { uint32_t r = fSeed * kMul + kAdd; fSeed = r; return r; }
+    /** Return the next pseudo random number as a signed 32bit value.
+    */
+    int32_t nextS() { return (int32_t)this->nextU(); }
+    /** Return the next pseudo random number as an unsigned 16bit value.
+    */
+    U16CPU nextU16() { return this->nextU() >> 16; }
+    /** Return the next pseudo random number as a signed 16bit value.
+    */
+    S16CPU nextS16() { return this->nextS() >> 16; }
 
-       /**     Return the next pseudo random number, as an unsigned value of
-               at most bitCount bits.
-               @param bitCount The maximum number of bits to be returned
-       */
-       uint32_t nextBits(unsigned bitCount)
-       {
-               SkASSERT(bitCount > 0 && bitCount <= 32);
-               return this->nextU() >> (32 - bitCount);
-       }
-       /**     Return the next pseudo random unsigned number, mapped to lie within
-               [min, max] inclusive.
-       */
-       uint32_t nextRangeU(uint32_t min, uint32_t max)
-       {
-               SkASSERT(min <= max);
-               return min + this->nextU() % (max - min + 1);
-       }
+    /** Return the next pseudo random number, as an unsigned value of
+        at most bitCount bits.
+        @param bitCount The maximum number of bits to be returned
+    */
+    uint32_t nextBits(unsigned bitCount)
+    {
+        SkASSERT(bitCount > 0 && bitCount <= 32);
+        return this->nextU() >> (32 - bitCount);
+    }
+    /** Return the next pseudo random unsigned number, mapped to lie within
+        [min, max] inclusive.
+    */
+    uint32_t nextRangeU(uint32_t min, uint32_t max)
+    {
+        SkASSERT(min <= max);
+        return min + this->nextU() % (max - min + 1);
+    }
 
-       /**     Return the next pseudo random number expressed as an unsigned SkFixed
-               in the range [0..SK_Fixed1).
-       */
-       SkFixed nextUFixed1() { return this->nextU() >> 16; }
-       /**     Return the next pseudo random number expressed as a signed SkFixed
-               in the range (-SK_Fixed1..SK_Fixed1).
-       */
-       SkFixed nextSFixed1() { return this->nextS() >> 15; }
+    /** Return the next pseudo random number expressed as an unsigned SkFixed
+        in the range [0..SK_Fixed1).
+    */
+    SkFixed nextUFixed1() { return this->nextU() >> 16; }
+    /** Return the next pseudo random number expressed as a signed SkFixed
+        in the range (-SK_Fixed1..SK_Fixed1).
+    */
+    SkFixed nextSFixed1() { return this->nextS() >> 15; }
 
-       /**     Return the next pseudo random number expressed as a SkScalar
-               in the range [0..SK_Scalar1).
-       */
-       SkScalar nextUScalar1() { return SkFixedToScalar(this->nextUFixed1()); }
-       /**     Return the next pseudo random number expressed as a SkScalar
-               in the range (-SK_Scalar1..SK_Scalar1).
-       */
-       SkScalar nextSScalar1() { return SkFixedToScalar(this->nextSFixed1()); }
+    /** Return the next pseudo random number expressed as a SkScalar
+        in the range [0..SK_Scalar1).
+    */
+    SkScalar nextUScalar1() { return SkFixedToScalar(this->nextUFixed1()); }
+    /** Return the next pseudo random number expressed as a SkScalar
+        in the range (-SK_Scalar1..SK_Scalar1).
+    */
+    SkScalar nextSScalar1() { return SkFixedToScalar(this->nextSFixed1()); }
 
-       /**     Return the next pseudo random number as a signed 64bit value.
-       */
-       void next64(Sk64* a) { SkASSERT(a); a->set(this->nextS(), this->nextU()); }
-       /**     Set the seed of the random object. The seed is initialized to 0 when the
-               object is first created, and is updated each time the next pseudo random
-               number is requested.
-       */
-       void setSeed(int32_t seed) { fSeed = (uint32_t)seed; }
+    /** Return the next pseudo random number as a signed 64bit value.
+    */
+    void next64(Sk64* a) { SkASSERT(a); a->set(this->nextS(), this->nextU()); }
+    /** Set the seed of the random object. The seed is initialized to 0 when the
+        object is first created, and is updated each time the next pseudo random
+        number is requested.
+    */
+    void setSeed(int32_t seed) { fSeed = (uint32_t)seed; }
 
 private:
-       //      "Numerical Recipes in C", 1992 page 284
-       enum {
-               kMul = 1664525,
-               kAdd = 1013904223
-       };
-       uint32_t fSeed;
+    //  "Numerical Recipes in C", 1992 page 284
+    enum {
+        kMul = 1664525,
+        kAdd = 1013904223
+    };
+    uint32_t fSeed;
 };
 
 #endif
index ec48e38..6cf9ebf 100644 (file)
+/* include/corecg/SkRect.h
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #ifndef SkRect_DEFINED
 #define SkRect_DEFINED
 
 #include "SkPoint.h"
 
-/**    \struct SkRect16
+/** \struct SkRect16
 
-       SkRect16 holds four 16 bit integer coordinates for a rectangle
+    SkRect16 holds four 16 bit integer coordinates for a rectangle
 */
 struct SkRect16 {
-       S16     fLeft, fTop, fRight, fBottom;
+    int16_t fLeft, fTop, fRight, fBottom;
 
-       /**     Returns true if the rectangle is empty (e.g. left >= right or top >= bottom)
-       */
-       bool isEmpty() const { return fLeft >= fRight || fTop >= fBottom; }
-       /**     Returns the rectangle's width. This does not check for a valid rectangle (i.e. left <= right)
-               so the result may be negative.
-       */
-       int     width() const { return fRight - fLeft; }
-       /**     Returns the rectangle's height. This does not check for a valid rectangle (i.e. top <= bottom)
-               so the result may be negative.
-       */
-       int     height() const { return fBottom - fTop; }
+    /** Returns true if the rectangle is empty (e.g. left >= right or top >= bottom)
+    */
+    bool isEmpty() const { return fLeft >= fRight || fTop >= fBottom; }
+    /** Returns the rectangle's width. This does not check for a valid rectangle (i.e. left <= right)
+        so the result may be negative.
+    */
+    int width() const { return fRight - fLeft; }
+    /** Returns the rectangle's height. This does not check for a valid rectangle (i.e. top <= bottom)
+        so the result may be negative.
+    */
+    int height() const { return fBottom - fTop; }
 
-       friend int operator==(const SkRect16& a, const SkRect16& b)
-       {
-               return !memcmp(&a, &b, sizeof(a));
-       }
-       friend int operator!=(const SkRect16& a, const SkRect16& b)
-       {
-               return memcmp(&a, &b, sizeof(a));
-       }
+    friend int operator==(const SkRect16& a, const SkRect16& b)
+    {
+        return !memcmp(&a, &b, sizeof(a));
+    }
+    friend int operator!=(const SkRect16& a, const SkRect16& b)
+    {
+        return memcmp(&a, &b, sizeof(a));
+    }
 
-       /**     Set the rectangle to (0,0,0,0)
-       */
-       void setEmpty() { memset(this, 0, sizeof(*this)); }
+    /** Set the rectangle to (0,0,0,0)
+    */
+    void setEmpty() { memset(this, 0, sizeof(*this)); }
 
-       void set(S16CPU left, S16CPU top, S16CPU right, S16CPU bottom)
-       {
-               fLeft   = SkToS16(left);
-               fTop    = SkToS16(top);
-               fRight  = SkToS16(right);
-               fBottom = SkToS16(bottom);
-       }
-       /**     Offset set the rectangle by adding dx to its left and right,
-               and adding dy to its top and bottom.
-       */
-       void offset(S16CPU dx, S16CPU dy)
-       {
-               fLeft   = SkToS16(fLeft + dx);
-               fTop    = SkToS16(fTop + dy);
-               fRight  = SkToS16(fRight + dx);
-               fBottom = SkToS16(fBottom + dy);
-       }
-       /**     Inset the rectangle by (dx,dy). If dx is positive, then the sides are moved inwards,
-               making the rectangle narrower. If dx is negative, then the sides are moved outwards,
-               making the rectangle wider. The same hods true for dy and the top and bottom.
-       */
-       void inset(S16CPU dx, S16CPU dy)
-       {
-               fLeft   = SkToS16(fLeft + dx);
-               fTop    = SkToS16(fTop + dy);
-               fRight  = SkToS16(fRight - dx);
-               fBottom = SkToS16(fBottom - dy);
-       }
-       /**     Returns true if (x,y) is inside the rectangle. The left and top are considered to be
-               inside, while the right and bottom are not. Thus for the rectangle (0, 0, 5, 10), the
-               points (0,0) and (0,9) are inside, while (-1,0) and (5,9) are not.
-       */
-       bool contains(S16CPU x, S16CPU y) const
-       {
-               return  (unsigned)(x - fLeft) < (unsigned)(fRight - fLeft) &&
-                               (unsigned)(y - fTop) < (unsigned)(fBottom - fTop);
-       }
-       /**     Returns true if the 4 specified sides of a rectangle are inside or equal to this rectangle.
-       */
-       bool contains(S16CPU left, S16CPU top, S16CPU right, S16CPU bottom) const
-       {
-               return  fLeft <= left && fTop <= top &&
-                               fRight >= right && fBottom >= bottom;
-       }
-       /**     Returns true if the specified rectangle r is inside or equal to this rectangle.
-       */
-       bool contains(const SkRect16& r) const
-       {
-               return  fLeft <= r.fLeft && fTop <= r.fTop &&
-                               fRight >= r.fRight && fBottom >= r.fBottom;
-       }
-       /**     If r intersects this rectangle, return true and set this rectangle to that
-               intersection, otherwise return false and do not change this rectangle.
-       */
-       bool intersect(const SkRect16& r);
-       /**     If rectangles a and b intersect, return true and set this rectangle to that
-               intersection, otherwise return false and do not change this rectangle.
-       */
-       bool intersect(const SkRect16& a, const SkRect16& b);
-       /**     If the rectangle specified by left,top,right,bottom intersects this rectangle,
-               return true and set this rectangle to that intersection,
-               otherwise return false and do not change this rectangle.
-       */
-       bool intersect(S16CPU left, S16CPU top, S16CPU right, S16CPU bottom);
-       /**     Returns true if a and b intersect
-       */
-       static bool Intersects(const SkRect16& a, const SkRect16& b)
-       {
-               return  a.fLeft < b.fRight && b.fLeft < a.fRight &&
-                               a.fTop < b.fBottom && b.fTop < a.fBottom;
-       }
-       void join(const SkRect16& r)
-       {
-               fLeft = SkToS16(SkMin32(fLeft, r.fLeft));
-               fTop = SkToS16(SkMin32(fTop, r.fTop));
-               fRight = SkToS16(SkMax32(fRight, r.fRight));
-               fBottom = SkToS16(SkMax32(fBottom, r.fBottom));
-       }
+    void set(S16CPU left, S16CPU top, S16CPU right, S16CPU bottom)
+    {
+        fLeft   = SkToS16(left);
+        fTop    = SkToS16(top);
+        fRight  = SkToS16(right);
+        fBottom = SkToS16(bottom);
+    }
+    /** Offset set the rectangle by adding dx to its left and right,
+        and adding dy to its top and bottom.
+    */
+    void offset(S16CPU dx, S16CPU dy)
+    {
+        fLeft   = SkToS16(fLeft + dx);
+        fTop    = SkToS16(fTop + dy);
+        fRight  = SkToS16(fRight + dx);
+        fBottom = SkToS16(fBottom + dy);
+    }
+    /** Inset the rectangle by (dx,dy). If dx is positive, then the sides are moved inwards,
+        making the rectangle narrower. If dx is negative, then the sides are moved outwards,
+        making the rectangle wider. The same hods true for dy and the top and bottom.
+    */
+    void inset(S16CPU dx, S16CPU dy)
+    {
+        fLeft   = SkToS16(fLeft + dx);
+        fTop    = SkToS16(fTop + dy);
+        fRight  = SkToS16(fRight - dx);
+        fBottom = SkToS16(fBottom - dy);
+    }
+    /** Returns true if (x,y) is inside the rectangle. The left and top are considered to be
+        inside, while the right and bottom are not. Thus for the rectangle (0, 0, 5, 10), the
+        points (0,0) and (0,9) are inside, while (-1,0) and (5,9) are not.
+    */
+    bool contains(S16CPU x, S16CPU y) const
+    {
+        return  (unsigned)(x - fLeft) < (unsigned)(fRight - fLeft) &&
+                (unsigned)(y - fTop) < (unsigned)(fBottom - fTop);
+    }
+    /** Returns true if the 4 specified sides of a rectangle are inside or equal to this rectangle.
+    */
+    bool contains(S16CPU left, S16CPU top, S16CPU right, S16CPU bottom) const
+    {
+        return  fLeft <= left && fTop <= top &&
+                fRight >= right && fBottom >= bottom;
+    }
+    /** Returns true if the specified rectangle r is inside or equal to this rectangle.
+    */
+    bool contains(const SkRect16& r) const
+    {
+        return  fLeft <= r.fLeft && fTop <= r.fTop &&
+                fRight >= r.fRight && fBottom >= r.fBottom;
+    }
+    /** If r intersects this rectangle, return true and set this rectangle to that
+        intersection, otherwise return false and do not change this rectangle.
+    */
+    bool intersect(const SkRect16& r);
+    /** If rectangles a and b intersect, return true and set this rectangle to that
+        intersection, otherwise return false and do not change this rectangle.
+    */
+    bool intersect(const SkRect16& a, const SkRect16& b);
+    /** If the rectangle specified by left,top,right,bottom intersects this rectangle,
+        return true and set this rectangle to that intersection,
+        otherwise return false and do not change this rectangle.
+    */
+    bool intersect(S16CPU left, S16CPU top, S16CPU right, S16CPU bottom);
+    /** Returns true if a and b intersect
+    */
+    static bool Intersects(const SkRect16& a, const SkRect16& b)
+    {
+        return  a.fLeft < b.fRight && b.fLeft < a.fRight &&
+                a.fTop < b.fBottom && b.fTop < a.fBottom;
+    }
+    void join(const SkRect16& r)
+    {
+        fLeft = SkToS16(SkMin32(fLeft, r.fLeft));
+        fTop = SkToS16(SkMin32(fTop, r.fTop));
+        fRight = SkToS16(SkMax32(fRight, r.fRight));
+        fBottom = SkToS16(SkMax32(fBottom, r.fBottom));
+    }
 
-       /** Swap top/bottom or left/right if there are flipped.
-               This can be called if the edges are computed separately,
-               and may have crossed over each other.
-               When this returns, left <= right && top <= bottom
-       */
-       void sort();
+    /** Swap top/bottom or left/right if there are flipped.
+        This can be called if the edges are computed separately,
+        and may have crossed over each other.
+        When this returns, left <= right && top <= bottom
+    */
+    void sort();
 };
 
-/**    \struct SkRect
+/** \struct SkRect
 */
 struct SkRect {
-       SkScalar        fLeft, fTop, fRight, fBottom;
+    SkScalar    fLeft, fTop, fRight, fBottom;
+
+    bool        isEmpty() const { return fLeft >= fRight || fTop >= fBottom; }
+    SkScalar    width() const { return fRight - fLeft; }
+    SkScalar    height() const { return fBottom - fTop; }
+    SkScalar    centerX() const { return SkScalarHalf(fLeft + fRight); }
+    SkScalar    centerY() const { return SkScalarHalf(fTop + fBottom); }
 
-       bool            isEmpty() const { return fLeft >= fRight || fTop >= fBottom; }
-       SkScalar        width() const { return fRight - fLeft; }
-       SkScalar        height() const { return fBottom - fTop; }
-       SkScalar        centerX() const { return SkScalarHalf(fLeft + fRight); }
-       SkScalar        centerY() const { return SkScalarHalf(fTop + fBottom); }
+    friend int operator==(const SkRect& a, const SkRect& b)
+    {
+        return !memcmp(&a, &b, sizeof(a));
+    }
+    friend int operator!=(const SkRect& a, const SkRect& b)
+    {
+        return memcmp(&a, &b, sizeof(a));
+    }
 
-       friend int operator==(const SkRect& a, const SkRect& b)
-       {
-               return !memcmp(&a, &b, sizeof(a));
-       }
-       friend int operator!=(const SkRect& a, const SkRect& b)
-       {
-               return memcmp(&a, &b, sizeof(a));
-       }
+    SkPoint* asPoints() { return (SkPoint*)(void*)this; }
+    const SkPoint* asPoints() const { return (const SkPoint*)(const void*)this; }
 
-       /** return the 4 points that enclose the rectangle
-       */
-       void toQuad(SkPoint quad[4]) const;
+    /** return the 4 points that enclose the rectangle
+    */
+    void toQuad(SkPoint quad[4]) const;
 
-       /**     Set this rectangle to the empty rectangle (0,0,0,0)
-       */
-       void setEmpty() { memset(this, 0, sizeof(*this)); }
+    /** Set this rectangle to the empty rectangle (0,0,0,0)
+    */
+    void setEmpty() { memset(this, 0, sizeof(*this)); }
 
-       void set(const SkRect16& src)
-       {
-               fLeft   = SkIntToScalar(src.fLeft);
-               fTop    = SkIntToScalar(src.fTop);
-               fRight  = SkIntToScalar(src.fRight);
-               fBottom = SkIntToScalar(src.fBottom);
-       }
+    void set(const SkRect16& src)
+    {
+        fLeft   = SkIntToScalar(src.fLeft);
+        fTop    = SkIntToScalar(src.fTop);
+        fRight  = SkIntToScalar(src.fRight);
+        fBottom = SkIntToScalar(src.fBottom);
+    }
 
-       void set(SkScalar left, SkScalar top, SkScalar right, SkScalar bottom)
-       {
-               fLeft   = left;
-               fTop    = top;
-               fRight  = right;
-               fBottom = bottom;
-       }
-       /**     Set this rectangle to be the bounds of the array of points.
-               If the array is empty (count == 0), then set this rectangle
-               to the empty rectangle (0,0,0,0)
-       */
-       void set(const SkPoint pts[], int count);
+    void set(SkScalar left, SkScalar top, SkScalar right, SkScalar bottom)
+    {
+        fLeft   = left;
+        fTop    = top;
+        fRight  = right;
+        fBottom = bottom;
+    }
+    /** Set this rectangle to be the bounds of the array of points.
+        If the array is empty (count == 0), then set this rectangle
+        to the empty rectangle (0,0,0,0)
+    */
+    void set(const SkPoint pts[], int count);
 
-       /**     Offset set the rectangle by adding dx to its left and right,
-               and adding dy to its top and bottom.
-       */
-       void offset(SkScalar dx, SkScalar dy)
-       {
-               fLeft   += dx;
-               fTop    += dy;
-               fRight  += dx;
-               fBottom += dy;
-       }       
-       /**     Inset the rectangle by (dx,dy). If dx is positive, then the sides are moved inwards,
-               making the rectangle narrower. If dx is negative, then the sides are moved outwards,
-               making the rectangle wider. The same hods true for dy and the top and bottom.
-       */
-       void inset(SkScalar dx, SkScalar dy)
-       {
-               fLeft   += dx;
-               fTop    += dy;
-               fRight  -= dx;
-               fBottom -= dy;
-       }
+    /** Offset set the rectangle by adding dx to its left and right,
+        and adding dy to its top and bottom.
+    */
+    void offset(SkScalar dx, SkScalar dy)
+    {
+        fLeft   += dx;
+        fTop    += dy;
+        fRight  += dx;
+        fBottom += dy;
+    }   
+    /** Inset the rectangle by (dx,dy). If dx is positive, then the sides are moved inwards,
+        making the rectangle narrower. If dx is negative, then the sides are moved outwards,
+        making the rectangle wider. The same hods true for dy and the top and bottom.
+    */
+    void inset(SkScalar dx, SkScalar dy)
+    {
+        fLeft   += dx;
+        fTop    += dy;
+        fRight  -= dx;
+        fBottom -= dy;
+    }
 
-       /**     If this rectangle intersects r, return true and set this rectangle to that
-               intersection, otherwise return false and do not change this rectangle.
-       */
-       bool intersect(const SkRect& r);
-       /**     If this rectangle intersects the rectangle specified by left, top, right, bottom,
-               return true and set this rectangle to that
-               intersection, otherwise return false and do not change this rectangle.
-       */
-       bool intersect(SkScalar left, SkScalar top, SkScalar right, SkScalar bottom);
-       /**     Return true if rectangles a and b intersect.
-       */
-       static bool Intersects(const SkRect& a, const SkRect& b)
-       {
-               return  a.fLeft < b.fRight && b.fLeft < a.fRight &&
-                               a.fTop < b.fBottom && b.fTop < a.fBottom;
-       }
+    /** If this rectangle intersects r, return true and set this rectangle to that
+        intersection, otherwise return false and do not change this rectangle.
+    */
+    bool intersect(const SkRect& r);
+    /** If this rectangle intersects the rectangle specified by left, top, right, bottom,
+        return true and set this rectangle to that
+        intersection, otherwise return false and do not change this rectangle.
+    */
+    bool intersect(SkScalar left, SkScalar top, SkScalar right, SkScalar bottom);
+    /** Return true if rectangles a and b intersect.
+    */
+    static bool Intersects(const SkRect& a, const SkRect& b)
+    {
+        return  a.fLeft < b.fRight && b.fLeft < a.fRight &&
+                a.fTop < b.fBottom && b.fTop < a.fBottom;
+    }
 
-       /**     Returns true if (p.fX,p.fY) is inside the rectangle. The left and top coordinates of
-               the rectangle are considered to be inside, while the right and bottom coordinates
-               are not. Thus for the rectangle (0, 0, 5, 10), the points (0,0) and (0,9) are inside,
-               while (-1,0) and (5,9) are not.
-       */
-       bool contains(const SkPoint& p) const
-       {
-               return  fLeft <= p.fX && p.fX < fRight &&
-                               fTop <= p.fY && p.fY < fBottom;
-       }
-       /**     Returns true if (x,y) is inside the rectangle. The left and top coordinates of
-               the rectangle are considered to be inside, while the right and bottom coordinates
-               are not. Thus for the rectangle (0, 0, 5, 10), the points (0,0) and (0,9) are inside,
-               while (-1,0) and (5,9) are not.
-       */
-       bool contains(SkScalar x, SkScalar y) const
-       {
-               return  fLeft <= x && x < fRight &&
-                               fTop <= y && y < fBottom;
-       }
-       /**     Return true if this rectangle contains r
-       */
-       bool contains(const SkRect& r) const
-       {
-               return  fLeft <= r.fLeft && fTop <= r.fTop &&
-                               fRight >= r.fRight && fBottom >= r.fBottom;
-       }
-       /**     Set the dst integer rectangle by rounding this rectangle's coordinates
-               to their nearest integer values.
-       */
-       void round(SkRect16* dst) const
-       {
-               SkASSERT(dst);
-               dst->set(SkScalarRound(fLeft), SkScalarRound(fTop), SkScalarRound(fRight), SkScalarRound(fBottom));
-       }
-       /**     Set the dst integer rectangle by rounding "out" this rectangle, choosing the floor of top and left,
-               and the ceiling of right and bototm.
-       */
-       void roundOut(SkRect16* dst) const
-       {
-               SkASSERT(dst);
-               dst->set(SkScalarFloor(fLeft), SkScalarFloor(fTop), SkScalarCeil(fRight), SkScalarCeil(fBottom));
-       }
+    /** Returns true if (p.fX,p.fY) is inside the rectangle. The left and top coordinates of
+        the rectangle are considered to be inside, while the right and bottom coordinates
+        are not. Thus for the rectangle (0, 0, 5, 10), the points (0,0) and (0,9) are inside,
+        while (-1,0) and (5,9) are not.
+    */
+    bool contains(const SkPoint& p) const
+    {
+        return  fLeft <= p.fX && p.fX < fRight &&
+                fTop <= p.fY && p.fY < fBottom;
+    }
+    /** Returns true if (x,y) is inside the rectangle. The left and top coordinates of
+        the rectangle are considered to be inside, while the right and bottom coordinates
+        are not. Thus for the rectangle (0, 0, 5, 10), the points (0,0) and (0,9) are inside,
+        while (-1,0) and (5,9) are not.
+    */
+    bool contains(SkScalar x, SkScalar y) const
+    {
+        return  fLeft <= x && x < fRight &&
+                fTop <= y && y < fBottom;
+    }
+    /** Return true if this rectangle contains r
+    */
+    bool contains(const SkRect& r) const
+    {
+        return  fLeft <= r.fLeft && fTop <= r.fTop &&
+                fRight >= r.fRight && fBottom >= r.fBottom;
+    }
+    /** Set the dst integer rectangle by rounding this rectangle's coordinates
+        to their nearest integer values.
+    */
+    void round(SkRect16* dst) const
+    {
+        SkASSERT(dst);
+        dst->set(SkScalarRound(fLeft), SkScalarRound(fTop), SkScalarRound(fRight), SkScalarRound(fBottom));
+    }
+    /** Set the dst integer rectangle by rounding "out" this rectangle, choosing the floor of top and left,
+        and the ceiling of right and bototm.
+    */
+    void roundOut(SkRect16* dst) const
+    {
+        SkASSERT(dst);
+        dst->set(SkScalarFloor(fLeft), SkScalarFloor(fTop), SkScalarCeil(fRight), SkScalarCeil(fBottom));
+    }
 
-       /** Swap top/bottom or left/right if there are flipped.
-               This can be called if the edges are computed separately,
-               and may have crossed over each other.
-               When this returns, left <= right && top <= bottom
-       */
-       void sort();
+    /** Swap top/bottom or left/right if there are flipped.
+        This can be called if the edges are computed separately,
+        and may have crossed over each other.
+        When this returns, left <= right && top <= bottom
+    */
+    void sort();
 };
 
 #endif
index 73daa9c..f61090c 100644 (file)
@@ -1,3 +1,20 @@
+/* include/corecg/SkRegion.h
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #ifndef SkRegion_DEFINED
 #define SkRegion_DEFINED
 
@@ -13,107 +30,107 @@ namespace android {
 #define SkRegion_gEmptyRunHeadPtr ((SkRegion::RunHead*)-1)
 #define SkRegion_gRectRunHeadPtr 0
 
-/**    \class SkRegion
+/** \class SkRegion
 
-       The SkRegion class encapsulates the geometric region used to specify
-       clipping areas for drawing.
+    The SkRegion class encapsulates the geometric region used to specify
+    clipping areas for drawing.
 */
 class SkRegion {
 public:
-       typedef int16_t RunType;
+    typedef int16_t RunType;
 
-       SkRegion();
-       explicit SkRegion(const SkRegion&);
-       explicit SkRegion(const SkRect16&);
-       ~SkRegion();
+    SkRegion();
+    explicit SkRegion(const SkRegion&);
+    explicit SkRegion(const SkRect16&);
+    ~SkRegion();
 
-       SkRegion& operator=(const SkRegion&);
+    SkRegion& operator=(const SkRegion&);
     
     friend int operator==(const SkRegion& a, const SkRegion& b);
     friend int operator!=(const SkRegion& a, const SkRegion& b)
     {
         return !(a == b);
     }
-       
-       // provide explicitly, so we'll have a java equivalent
-       void set(const SkRegion& src)
-       {
-               SkASSERT(&src);
-               *this = src;
-       }
-       /**     Swap the contents of this and the specified region. This operation
-               is gauarenteed to never fail.
-       */
-       void    swap(SkRegion&);
-
-       /**     Return true if this region is empty */
-       bool    isEmpty() const { return fRunHead == SkRegion_gEmptyRunHeadPtr; }
-       /**     Return true if this region is a single, non-empty rectangle */
-       bool    isRect() const { return fRunHead == SkRegion_gRectRunHeadPtr; }
-       /**     Return true if this region consists of more than 1 rectangular area */
-       bool    isComplex() const { return !this->isEmpty() && !this->isRect(); }
-       /**     Return the bounds of this region. If the region is empty, returns an
-               empty rectangle.
-       */
-       const SkRect16& getBounds() const { return fBounds; }
+    
+    // provide explicitly, so we'll have a java equivalent
+    void set(const SkRegion& src)
+    {
+        SkASSERT(&src);
+        *this = src;
+    }
+    /** Swap the contents of this and the specified region. This operation
+        is gauarenteed to never fail.
+    */
+    void    swap(SkRegion&);
+
+    /** Return true if this region is empty */
+    bool    isEmpty() const { return fRunHead == SkRegion_gEmptyRunHeadPtr; }
+    /** Return true if this region is a single, non-empty rectangle */
+    bool    isRect() const { return fRunHead == SkRegion_gRectRunHeadPtr; }
+    /** Return true if this region consists of more than 1 rectangular area */
+    bool    isComplex() const { return !this->isEmpty() && !this->isRect(); }
+    /** Return the bounds of this region. If the region is empty, returns an
+        empty rectangle.
+    */
+    const SkRect16& getBounds() const { return fBounds; }
 
     /** Returns true if the region is non-empty, and if so, sets the specified path to the
         boundary(s) of the region.
     */
     bool getBoundaryPath(SkPath* path) const;
 
-       /**     Set the region to be empty, and return false */
-       bool    setEmpty();
-       /**     If rect is non-empty, set this region to that rectangle and return true,
-               otherwise set this region to empty and return false.
-       */
-       bool    setRect(const SkRect16&);
-       /**     If left < right and top < bottom, set this region to that rectangle and
-               return true, otherwise set this region to empty and return false.
-       */
-       bool    setRect(S16CPU left, S16CPU top, S16CPU right, S16CPU bottom);
-       /**     Set this region to the specified region, and return true if it is non-empty. */
-       bool    setRegion(const SkRegion&);
-       /**     Set this region to the area described by the path, optionally clipped (if clip is
-               not nil). Return true if the resulting region is non-empty. This produces a region
-               that is identical to the pixels that would be drawn by the path (with no antialiasing).
-       */
-       bool    setPath(const SkPath&, const SkRegion* clip = nil);
-       /**     Return true if the specified x,y coordinate is inside the region.
-       */
-       bool    contains(S16CPU x, S16CPU y) const;
-       /**     Return true if this region is a single rectangle (not complex) and the specified rectangle
-               is contained by this region. Returning false is not a guarantee that the rectangle is not contained
-               by this region, but return true is a guarantee that the rectangle is contained by this region.
-       */
-       bool quickContains(const SkRect16& r) const
-       {
-               return this->isRect() && fBounds.contains(r);
-       }
-       /**     Return true if this region is a single rectangle (not complex) and the specified rectangle
-               is contained by this region. Returning false is not a guarantee that the rectangle is not contained
-               by this region, but return true is a guarantee that the rectangle is contained by this region.
-       */
-       bool quickContains(S16CPU left, S16CPU top, S16CPU right, S16CPU bottom) const
-       {
-               return this->isRect() && fBounds.contains(left, top, right, bottom);
-       }
-       /**     Return true if this region is empty, or if the specified rectangle does not intersect
-               the region. Returning false is not a guarantee that they intersect, but returning
-               true is a guarantee that they do not.
-       */
-       bool quickReject(const SkRect16& rect) const
-       {
-               return this->isEmpty() || !SkRect16::Intersects(fBounds, rect);
-       }
-       /**     Return true if this region, or rgn, is empty, or if their bounds do not intersect.
-               Returning false is not a guarantee that they intersect, but returning true is a guarantee
-               that they do not.
-       */
-       bool quickReject(const SkRegion& rgn) const
-       {
-               return this->isEmpty() || rgn.isEmpty() || !SkRect16::Intersects(fBounds, rgn.fBounds);
-       }
+    /** Set the region to be empty, and return false */
+    bool    setEmpty();
+    /** If rect is non-empty, set this region to that rectangle and return true,
+        otherwise set this region to empty and return false.
+    */
+    bool    setRect(const SkRect16&);
+    /** If left < right and top < bottom, set this region to that rectangle and
+        return true, otherwise set this region to empty and return false.
+    */
+    bool    setRect(S16CPU left, S16CPU top, S16CPU right, S16CPU bottom);
+    /** Set this region to the specified region, and return true if it is non-empty. */
+    bool    setRegion(const SkRegion&);
+    /** Set this region to the area described by the path, optionally clipped (if clip is
+        not nil). Return true if the resulting region is non-empty. This produces a region
+        that is identical to the pixels that would be drawn by the path (with no antialiasing).
+    */
+    bool    setPath(const SkPath&, const SkRegion* clip = nil);
+    /** Return true if the specified x,y coordinate is inside the region.
+    */
+    bool    contains(S16CPU x, S16CPU y) const;
+    /** Return true if this region is a single rectangle (not complex) and the specified rectangle
+        is contained by this region. Returning false is not a guarantee that the rectangle is not contained
+        by this region, but return true is a guarantee that the rectangle is contained by this region.
+    */
+    bool quickContains(const SkRect16& r) const
+    {
+        return this->isRect() && fBounds.contains(r);
+    }
+    /** Return true if this region is a single rectangle (not complex) and the specified rectangle
+        is contained by this region. Returning false is not a guarantee that the rectangle is not contained
+        by this region, but return true is a guarantee that the rectangle is contained by this region.
+    */
+    bool quickContains(S16CPU left, S16CPU top, S16CPU right, S16CPU bottom) const
+    {
+        return this->isRect() && fBounds.contains(left, top, right, bottom);
+    }
+    /** Return true if this region is empty, or if the specified rectangle does not intersect
+        the region. Returning false is not a guarantee that they intersect, but returning
+        true is a guarantee that they do not.
+    */
+    bool quickReject(const SkRect16& rect) const
+    {
+        return this->isEmpty() || !SkRect16::Intersects(fBounds, rect);
+    }
+    /** Return true if this region, or rgn, is empty, or if their bounds do not intersect.
+        Returning false is not a guarantee that they intersect, but returning true is a guarantee
+        that they do not.
+    */
+    bool quickReject(const SkRegion& rgn) const
+    {
+        return this->isEmpty() || rgn.isEmpty() || !SkRect16::Intersects(fBounds, rgn.fBounds);
+    }
     
     void translate(int dx, int dy)
     {
@@ -121,84 +138,84 @@ public:
     }
     void translate(int dx, int dy, SkRegion* dst) const;
 
-       enum Op {
-               kDifference_Op,
-               kIntersect_Op,
-               kUnion_Op,
-               kXOR_Op,
-
-               kOpCount
-       };
-       /**     Set this region to the result of applying the Opereation to this region and the specified
-               rectangle. Return true if the resulting region is non-empty.
-       */
-       bool    op(const SkRect16&, Op);
-       // helper for java, so it doesn't have to create a Rect object
-       bool    op(S16CPU left, S16CPU top, S16CPU right, S16CPU bottom, Op op)
-       {
-               SkRect16 r;
-               r.set(left, top, right, bottom);
-               return this->op(r, op);
-       }
-       /**     Set this region to the result of applying the Opereation to this region and the specified
-               region. Return true if the resulting region is non-empty.
-       */
-       bool    op(const SkRegion& rgn, Op op) { return this->op(*this, rgn, op); }
-       /**     Set this region to the result of applying the Opereation to the specified rectangle and region.
-               Return true if the resulting region is non-empty.
-       */
-       bool    op(const SkRect16&, const SkRegion&, Op);
-       /**     Set this region to the result of applying the Opereation to the specified regions.
-               Return true if the resulting region is non-empty.
-       */
-       bool    op(const SkRegion&, const SkRegion&, Op);
-
-       /**     Helper class that returns the sequence of rectangles that make up this region.
-       */
-       class Iterator {
-       public:
-               Iterator();
-               Iterator(const SkRegion&);
-               void                    reset(const SkRegion&);
-               bool                    done() { return fDone; }
-               void                    next();
-               const SkRect16& rect() const { return fRect; }
-
-       private:
-               const RunType*  fRuns;
-               SkRect16                fRect;
-               bool                    fDone;
-       };
-
-       /**     Helper class that returns the sequence of rectangles that make up this region,
-               intersected with the clip rectangle.
-       */
-       class Cliperator {
-       public:
-               Cliperator(const SkRegion&, const SkRect16& clip);
-               bool                    done() { return fDone; }
-               void                    next();
-               const SkRect16& rect() const { return fRect; }
-
-       private:
-               Iterator        fIter;
-               SkRect16        fClip;
-               SkRect16        fRect;
-               bool            fDone;
-       };
-
-       /**     Helper class that returns the sequence of scanline runs that make up this region.
-       */
-       class Spanerator {
-       public:
-               Spanerator(const SkRegion&, int y, int left, int right);
-               bool    next(int* left, int* right);
-
-       private:
-               const SkRegion::RunType* fRuns;
-               int     fLeft, fRight;
-               bool    fDone;
-       };
+    enum Op {
+        kDifference_Op,
+        kIntersect_Op,
+        kUnion_Op,
+        kXOR_Op,
+
+        kOpCount
+    };
+    /** Set this region to the result of applying the Opereation to this region and the specified
+        rectangle. Return true if the resulting region is non-empty.
+    */
+    bool    op(const SkRect16&, Op);
+    // helper for java, so it doesn't have to create a Rect object
+    bool    op(S16CPU left, S16CPU top, S16CPU right, S16CPU bottom, Op op)
+    {
+        SkRect16 r;
+        r.set(left, top, right, bottom);
+        return this->op(r, op);
+    }
+    /** Set this region to the result of applying the Opereation to this region and the specified
+        region. Return true if the resulting region is non-empty.
+    */
+    bool    op(const SkRegion& rgn, Op op) { return this->op(*this, rgn, op); }
+    /** Set this region to the result of applying the Opereation to the specified rectangle and region.
+        Return true if the resulting region is non-empty.
+    */
+    bool    op(const SkRect16&, const SkRegion&, Op);
+    /** Set this region to the result of applying the Opereation to the specified regions.
+        Return true if the resulting region is non-empty.
+    */
+    bool    op(const SkRegion&, const SkRegion&, Op);
+
+    /** Helper class that returns the sequence of rectangles that make up this region.
+    */
+    class Iterator {
+    public:
+        Iterator();
+        Iterator(const SkRegion&);
+        void            reset(const SkRegion&);
+        bool            done() { return fDone; }
+        void            next();
+        const SkRect16& rect() const { return fRect; }
+
+    private:
+        const RunType*  fRuns;
+        SkRect16        fRect;
+        bool            fDone;
+    };
+
+    /** Helper class that returns the sequence of rectangles that make up this region,
+        intersected with the clip rectangle.
+    */
+    class Cliperator {
+    public:
+        Cliperator(const SkRegion&, const SkRect16& clip);
+        bool            done() { return fDone; }
+        void            next();
+        const SkRect16& rect() const { return fRect; }
+
+    private:
+        Iterator    fIter;
+        SkRect16    fClip;
+        SkRect16    fRect;
+        bool        fDone;
+    };
+
+    /** Helper class that returns the sequence of scanline runs that make up this region.
+    */
+    class Spanerator {
+    public:
+        Spanerator(const SkRegion&, int y, int left, int right);
+        bool    next(int* left, int* right);
+
+    private:
+        const SkRegion::RunType* fRuns;
+        int     fLeft, fRight;
+        bool    fDone;
+    };
 
     /** Return the number of bytes need to write this region to a buffer.
     */
@@ -210,14 +227,14 @@ public:
         of bytes actually read.
     */
     size_t  readFromBuffer(const void* buffer);
-       
+    
     SkDEBUGCODE(void dump() const;)
-       SkDEBUGCODE(void validate() const;)
+    SkDEBUGCODE(void validate() const;)
     SkDEBUGCODE(static void UnitTest();)
 
 private:
     enum {
-        kRectRegionRuns = 6,           // need to store a region of a rect [T B L R S S]        
+        kRectRegionRuns = 6,        // need to store a region of a rect [T B L R S S]        
         kRunTypeSentinel = 0x7FFF
     };
 
@@ -226,21 +243,21 @@ private:
 
     struct RunHead;
 
-       SkRect16        fBounds;
-       RunHead*        fRunHead;
+    SkRect16    fBounds;
+    RunHead*    fRunHead;
 
-       void                    freeRuns();
-       const RunType*  getRuns(RunType tmpStorage[], int* count) const;
-       bool                    setRuns(RunType runs[], int count);
+    void            freeRuns();
+    const RunType*  getRuns(RunType tmpStorage[], int* count) const;
+    bool            setRuns(RunType runs[], int count);
 
-       int count_runtype_values(int* itop, int* ibot) const;
+    int count_runtype_values(int* itop, int* ibot) const;
     
     static void build_rect_runs(const SkRect16& bounds, RunType runs[kRectRegionRuns]);
     static bool compute_run_bounds(const RunType runs[], int count, SkRect16* bounds);
 
     friend struct RunHead;
-       friend class Iterator;
-       friend class Spanerator;
+    friend class Iterator;
+    friend class Spanerator;
     friend class SkRgnBuilder;
 };
 
index 271f1d3..f38404d 100644 (file)
+/* include/corecg/SkScalar.h
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #ifndef SkScalar_DEFINED
 #define SkScalar_DEFINED
 
 #include "SkTypes.h"
+#include "SkFixed.h"
 
-/**    \file SkScalar.h
+/** \file SkScalar.h
 
-       Types and macros for the data type SkScalar. This is the fractional numeric type
-       that, depending on the compile-time flag SK_SCALAR_IS_FLOAT, may be implemented
-       either as an IEEE float, or as a 16.16 SkFixed. The macros in this file are written
-       to allow the calling code to manipulate SkScalar values without knowing which representation
-       is in effect.
+    Types and macros for the data type SkScalar. This is the fractional numeric type
+    that, depending on the compile-time flag SK_SCALAR_IS_FLOAT, may be implemented
+    either as an IEEE float, or as a 16.16 SkFixed. The macros in this file are written
+    to allow the calling code to manipulate SkScalar values without knowing which representation
+    is in effect.
 */
 
 #ifdef SK_SCALAR_IS_FLOAT
-       #include "SkFloatingPoint.h"
-
-       /**     SkScalar is our type for fractional values and coordinates. Depending on
-               compile configurations, it is either represented as an IEEE float, or
-               as a 16.16 fixed point integer.
-       */
-       typedef float   SkScalar;
-       extern const uint32_t gIEEENotANumber;
-       extern const uint32_t gIEEEInfinity;
-
-       /**     SK_Scalar1 is defined to be 1.0 represented as an SkScalar
-       */
-       #define SK_Scalar1                              (1.0f)
-       /**     SK_Scalar1 is defined to be 1/2 represented as an SkScalar
-       */
-       #define SK_ScalarHalf                   (0.5f)
-       /**     SK_ScalarInfinity is defined to be infinity as an SkScalar
-       */
-       #define SK_ScalarInfinity                       (*(const float*)&gIEEEInfinity)
-       /**     SK_ScalarMax is defined to be the largest value representable as an SkScalar
-       */
-       #define SK_ScalarMax                    (3.4028235e+38f)
-       /**     SK_ScalarMin is defined to be the smallest value representable as an SkScalar
-       */
-       #define SK_ScalarMin                    (1.1754944e-38f)
-       /**     SK_ScalarNaN is defined to be 'Not a Number' as an SkScalar
-       */
-       #define SK_ScalarNaN                    (*(const float*)&gIEEENotANumber)
-       /**     SkScalarIsNaN(n) returns true if argument is not a number
-       */
-       static inline bool SkScalarIsNaN(float x) { return x != x; }
-       /**     SkIntToScalar(n) returns its integer argument as an SkScalar
-       */
-       #define SkIntToScalar(n)                ((float)(n))
-       /**     SkFixedToScalar(n) returns its SkFixed argument as an SkScalar
-       */
-       #define SkFixedToScalar(x)              SkFixedToFloat(x)
-       /**     SkFixedToScalar(n) returns its SkScalar argument as an SkFixed
-       */
-       #define SkScalarToFixed(x)              (SkFixed)((x) * SK_Fixed1)
-
-       #define SkScalarToFloat(n)              (n)
-       #define SkFloatToScalar(n)              (n)
-
-       /**     SkScalarFraction(x) returns the signed fractional part of the argument
-       */
-       #define SkScalarFraction(x)             sk_float_mod(x, 1.0f)
-       /**     Rounds the SkScalar to the nearest integer value
-       */
-       inline int SkScalarRound(SkScalar x)
-       {
-               if (x < 0)
-                       x -= SK_ScalarHalf;
-               else
-                       x += SK_ScalarHalf;
-               return (int)x;
-       }
-       /**     Returns the smallest integer that is >= the specified SkScalar
-       */
-       #define SkScalarCeil(x)                 (int)ceil(x)
-       /**     Returns the largest integer that is <= the specified SkScalar
-       */
-       #define SkScalarFloor(x)                (int)floor(x)
-       /**     Returns the absolute value of the specified SkScalar
-       */
-       #define SkScalarAbs(x)                  sk_float_abs(x)
-       /**     Returns the value pinned between 0 and max inclusive
-       */
-       inline SkScalar SkScalarClampMax(SkScalar x, SkScalar max) {
-               return x < 0 ? 0 : x > max ? max : x;
-       }
-       /**     Returns the value pinned between min and max inclusive
-       */
-       inline SkScalar SkScalarPin(SkScalar x, SkScalar min, SkScalar max) {
-               return x < min ? min : x > max ? max : x;
-       }
-       /**     Returns the specified SkScalar squared (x*x)
-       */
-       inline SkScalar SkScalarSquare(SkScalar x) { return x * x; }
-       /**     Returns the product of two SkScalars
-       */
-       #define SkScalarMul(a, b)               ((a) * (b))
-       /**     Returns the product of a SkScalar and an int rounded to the nearest integer value
-       */
-       #define SkScalarMulRound(a, b) SkScalarRound((a) * (b))
-       /**     Returns the product of a SkScalar and an int promoted to the next larger int
-       */
-       #define SkScalarMulCeil(a, b) SkScalarCeil((a) * (b))
-       /**     Returns the product of a SkScalar and an int truncated to the next smaller int
-       */
-       #define SkScalarMulFloor(a, b) SkScalarFloor((a) * (b))
-       /**     Returns the quotient of two SkScalars (a/b)
-       */
-       #define SkScalarDiv(a, b)               ((a) / (b))
-       /**     Returns the mod of two SkScalars (a mod b)
-       */
-       #define SkScalarMod(x,y)                sk_float_mod(x,y)
-       /**     Returns the product of the first two arguments, divided by the third argument
-       */
-       #define SkScalarMulDiv(a, b, c) ((a) * (b) / (c))
-       /**     Returns the multiplicative inverse of the SkScalar (1/x)
-       */
-       #define SkScalarInvert(x)               (SK_Scalar1 / (x))
-       /**     Returns the square root of the SkScalar
-       */
-       #define SkScalarSqrt(x)                 sk_float_sqrt(x)
-       /**     Returns the average of two SkScalars (a+b)/2
-       */
-       #define SkScalarAve(a, b)               (((a) + (b)) * 0.5f)
-       /**     Returns the geometric mean of two SkScalars
-       */
-       #define SkScalarMean(a, b)              sk_float_sqrt((a) * (b))
-       /**     Returns one half of the specified SkScalar
-       */
-       #define SkScalarHalf(a)                 ((a) * 0.5f)
-
-       #define SK_ScalarSqrt2                  1.41421356f
-       #define SK_ScalarPI                             3.14159265f
-       #define SK_ScalarTanPIOver8             0.414213562f
-       #define SK_ScalarRoot2Over2             0.707106781f
-
-       #define SkDegreesToRadians(degrees)     ((degrees) * (SK_ScalarPI / 180))
-       float SkScalarSinCos(SkScalar radians, SkScalar* cosValue);
-       #define SkScalarSin(radians)    (float)sk_float_sin(radians)
-       #define SkScalarCos(radians)    (float)sk_float_cos(radians)
-       #define SkScalarTan(radians)    (float)sk_float_tan(radians)
-       #define SkScalarASin(val)       (float)sk_float_asin(val)
-       #define SkScalarACos(val)       (float)sk_float_acos(val)
-       #define SkScalarATan2(y, x)     (float)sk_float_atan2(y,x)
-       #define SkScalarExp(x)  (float)sk_float_exp(x)
-       #define SkScalarLog(x)  (float)sk_float_log(x)
-
-       inline SkScalar SkMaxScalar(SkScalar a, SkScalar b) { return a > b ? a : b; }
-       inline SkScalar SkMinScalar(SkScalar a, SkScalar b) { return a < b ? a : b; }
+    #include "SkFloatingPoint.h"
+
+    /** SkScalar is our type for fractional values and coordinates. Depending on
+        compile configurations, it is either represented as an IEEE float, or
+        as a 16.16 fixed point integer.
+    */
+    typedef float   SkScalar;
+    extern const uint32_t gIEEENotANumber;
+    extern const uint32_t gIEEEInfinity;
+
+    /** SK_Scalar1 is defined to be 1.0 represented as an SkScalar
+    */
+    #define SK_Scalar1              (1.0f)
+    /** SK_Scalar1 is defined to be 1/2 represented as an SkScalar
+    */
+    #define SK_ScalarHalf           (0.5f)
+    /** SK_ScalarInfinity is defined to be infinity as an SkScalar
+    */
+    #define SK_ScalarInfinity           (*(const float*)&gIEEEInfinity)
+    /** SK_ScalarMax is defined to be the largest value representable as an SkScalar
+    */
+    #define SK_ScalarMax            (3.4028235e+38f)
+    /** SK_ScalarMin is defined to be the smallest value representable as an SkScalar
+    */
+    #define SK_ScalarMin            (1.1754944e-38f)
+    /** SK_ScalarNaN is defined to be 'Not a Number' as an SkScalar
+    */
+    #define SK_ScalarNaN            (*(const float*)&gIEEENotANumber)
+    /** SkScalarIsNaN(n) returns true if argument is not a number
+    */
+    static inline bool SkScalarIsNaN(float x) { return x != x; }
+    /** SkIntToScalar(n) returns its integer argument as an SkScalar
+    */
+    #define SkIntToScalar(n)        ((float)(n))
+    /** SkFixedToScalar(n) returns its SkFixed argument as an SkScalar
+    */
+    #define SkFixedToScalar(x)      SkFixedToFloat(x)
+    /** SkScalarToFixed(n) returns its SkScalar argument as an SkFixed
+    */
+    #define SkScalarToFixed(x)      (SkFixed)((x) * SK_Fixed1)
+
+    #define SkScalarToFloat(n)      (n)
+    #define SkFloatToScalar(n)      (n)
+
+    /** SkScalarFraction(x) returns the signed fractional part of the argument
+    */
+    #define SkScalarFraction(x)     sk_float_mod(x, 1.0f)
+    /** Rounds the SkScalar to the nearest integer value
+    */
+    inline int SkScalarRound(SkScalar x)
+    {
+        if (x < 0)
+            x -= SK_ScalarHalf;
+        else
+            x += SK_ScalarHalf;
+        return (int)x;
+    }
+    /** Returns the smallest integer that is >= the specified SkScalar
+    */
+    #define SkScalarCeil(x)         (int)ceil(x)
+    /** Returns the largest integer that is <= the specified SkScalar
+    */
+    #define SkScalarFloor(x)        (int)floor(x)
+    /** Returns the absolute value of the specified SkScalar
+    */
+    #define SkScalarAbs(x)          sk_float_abs(x)
+    /** Returns the value pinned between 0 and max inclusive
+    */
+    inline SkScalar SkScalarClampMax(SkScalar x, SkScalar max) {
+        return x < 0 ? 0 : x > max ? max : x;
+    }
+    /** Returns the value pinned between min and max inclusive
+    */
+    inline SkScalar SkScalarPin(SkScalar x, SkScalar min, SkScalar max) {
+        return x < min ? min : x > max ? max : x;
+    }
+    /** Returns the specified SkScalar squared (x*x)
+    */
+    inline SkScalar SkScalarSquare(SkScalar x) { return x * x; }
+    /** Returns the product of two SkScalars
+    */
+    #define SkScalarMul(a, b)       ((a) * (b))
+    /** Returns the product of a SkScalar and an int rounded to the nearest integer value
+    */
+    #define SkScalarMulRound(a, b) SkScalarRound((a) * (b))
+    /** Returns the product of a SkScalar and an int promoted to the next larger int
+    */
+    #define SkScalarMulCeil(a, b) SkScalarCeil((a) * (b))
+    /** Returns the product of a SkScalar and an int truncated to the next smaller int
+    */
+    #define SkScalarMulFloor(a, b) SkScalarFloor((a) * (b))
+    /** Returns the quotient of two SkScalars (a/b)
+    */
+    #define SkScalarDiv(a, b)       ((a) / (b))
+    /** Returns the mod of two SkScalars (a mod b)
+    */
+    #define SkScalarMod(x,y)        sk_float_mod(x,y)
+    /** Returns the product of the first two arguments, divided by the third argument
+    */
+    #define SkScalarMulDiv(a, b, c) ((a) * (b) / (c))
+    /** Returns the multiplicative inverse of the SkScalar (1/x)
+    */
+    #define SkScalarInvert(x)       (SK_Scalar1 / (x))
+    #define SkScalarFastInvert(x)   (SK_Scalar1 / (x))
+    /** Returns the square root of the SkScalar
+    */
+    #define SkScalarSqrt(x)         sk_float_sqrt(x)
+    /** Returns the average of two SkScalars (a+b)/2
+    */
+    #define SkScalarAve(a, b)       (((a) + (b)) * 0.5f)
+    /** Returns the geometric mean of two SkScalars
+    */
+    #define SkScalarMean(a, b)      sk_float_sqrt((a) * (b))
+    /** Returns one half of the specified SkScalar
+    */
+    #define SkScalarHalf(a)         ((a) * 0.5f)
+
+    #define SK_ScalarSqrt2          1.41421356f
+    #define SK_ScalarPI             3.14159265f
+    #define SK_ScalarTanPIOver8     0.414213562f
+    #define SK_ScalarRoot2Over2     0.707106781f
+
+    #define SkDegreesToRadians(degrees) ((degrees) * (SK_ScalarPI / 180))
+    float SkScalarSinCos(SkScalar radians, SkScalar* cosValue);
+    #define SkScalarSin(radians)    (float)sk_float_sin(radians)
+    #define SkScalarCos(radians)    (float)sk_float_cos(radians)
+    #define SkScalarTan(radians)    (float)sk_float_tan(radians)
+    #define SkScalarASin(val)   (float)sk_float_asin(val)
+    #define SkScalarACos(val)   (float)sk_float_acos(val)
+    #define SkScalarATan2(y, x) (float)sk_float_atan2(y,x)
+    #define SkScalarExp(x)  (float)sk_float_exp(x)
+    #define SkScalarLog(x)  (float)sk_float_log(x)
+
+    inline SkScalar SkMaxScalar(SkScalar a, SkScalar b) { return a > b ? a : b; }
+    inline SkScalar SkMinScalar(SkScalar a, SkScalar b) { return a < b ? a : b; }
 
 #else
-       #include "SkFixed.h"
-
-       typedef SkFixed SkScalar;
-
-       #define SK_Scalar1                              SK_Fixed1
-       #define SK_ScalarHalf                   SK_FixedHalf
-       #define SK_ScalarInfinity       SK_FixedMax
-       #define SK_ScalarMax                    SK_FixedMax
-       #define SK_ScalarMin                    SK_FixedMin
-       #define SK_ScalarNaN                    SK_FixedNaN
-       #define SkScalarIsNaN(x)                ((x) == SK_FixedNaN)
-       #define SkIntToScalar(n)                SkIntToFixed(n)
-       #define SkFixedToScalar(x)              (x)
-       #define SkScalarToFixed(x)              (x)
-       #ifdef SK_CAN_USE_FLOAT
-               #define SkScalarToFloat(n)      SkFixedToFloat(n)
-               #define SkFloatToScalar(n)      SkFloatToFixed(n)
-       #endif
-       #define SkScalarFraction(x)             SkFixedFraction(x)
-       #define SkScalarRound(x)                SkFixedRound(x)
-       #define SkScalarCeil(x)                 SkFixedCeil(x)
-       #define SkScalarFloor(x)                SkFixedFloor(x)
-       #define SkScalarAbs(x)                  SkFixedAbs(x)
-       #define SkScalarClampMax(x, max) SkClampMax(x, max)
-       #define SkScalarPin(x, min, max) SkPin32(x, min, max)
-       #define SkScalarSquare(x)               SkFixedSquare(x)
-       #define SkScalarMul(a, b)               SkFixedMul(a, b)
-       #define SkScalarMulRound(a, b)          SkFixedMulCommon(a, b, SK_FixedHalf)
-       #define SkScalarMulCeil(a, b)           SkFixedMulCommon(a, b, SK_Fixed1 - 1)
-       #define SkScalarMulFloor(a, b)          SkFixedMulCommon(a, b, 0)
-       #define SkScalarDiv(a, b)               SkFixedDiv(a, b)
-       #define SkScalarMod(a, b)               SkFixedMod(a, b)
-       #define SkScalarMulDiv(a, b, c) SkMulDiv(a, b, c)
-       #define SkScalarInvert(x)               SkFixedInvert(x)
-       #define SkScalarSqrt(x)                 SkFixedSqrt(x)
-       #define SkScalarAve(a, b)               SkFixedAve(a, b)
-       #define SkScalarMean(a, b)              SkFixedMean(a, b)
-       #define SkScalarHalf(a)                 ((a) >> 1)
-
-       #define SK_ScalarSqrt2                  SK_FixedSqrt2
-       #define SK_ScalarPI                             SK_FixedPI
-       #define SK_ScalarTanPIOver8             SK_FixedTanPIOver8
-       #define SK_ScalarRoot2Over2             SK_FixedRoot2Over2
-
-       #define SkDegreesToRadians(degrees)             SkFractMul(degrees, SK_FractPIOver180)
-       #define SkScalarSinCos(radians, cosPtr) SkFixedSinCos(radians, cosPtr)
-       #define SkScalarSin(radians)    SkFixedSin(radians)
-       #define SkScalarCos(radians)    SkFixedCos(radians)
-       #define SkScalarTan(val)                SkFixedTan(val)
-       #define SkScalarASin(val)               SkFixedASin(val)
-       #define SkScalarACos(val)               SkFixedACos(val)
-       #define SkScalarATan2(y, x)             SkFixedATan2(y,x)
-       #define SkScalarExp(x)                  SkFixedExp(x)
-       #define SkScalarLog(x)                  SkFixedLog(x)
-
-       #define SkMaxScalar(a, b)               SkMax32(a, b)
-       #define SkMinScalar(a, b)               SkMin32(a, b)
+    typedef SkFixed SkScalar;
+
+    #define SK_Scalar1              SK_Fixed1
+    #define SK_ScalarHalf           SK_FixedHalf
+    #define SK_ScalarInfinity   SK_FixedMax
+    #define SK_ScalarMax            SK_FixedMax
+    #define SK_ScalarMin            SK_FixedMin
+    #define SK_ScalarNaN            SK_FixedNaN
+    #define SkScalarIsNaN(x)        ((x) == SK_FixedNaN)
+    #define SkIntToScalar(n)        SkIntToFixed(n)
+    #define SkFixedToScalar(x)      (x)
+    #define SkScalarToFixed(x)      (x)
+    #ifdef SK_CAN_USE_FLOAT
+        #define SkScalarToFloat(n)  SkFixedToFloat(n)
+        #define SkFloatToScalar(n)  SkFloatToFixed(n)
+    #endif
+    #define SkScalarFraction(x)     SkFixedFraction(x)
+    #define SkScalarRound(x)        SkFixedRound(x)
+    #define SkScalarCeil(x)         SkFixedCeil(x)
+    #define SkScalarFloor(x)        SkFixedFloor(x)
+    #define SkScalarAbs(x)          SkFixedAbs(x)
+    #define SkScalarClampMax(x, max) SkClampMax(x, max)
+    #define SkScalarPin(x, min, max) SkPin32(x, min, max)
+    #define SkScalarSquare(x)       SkFixedSquare(x)
+    #define SkScalarMul(a, b)       SkFixedMul(a, b)
+    #define SkScalarMulRound(a, b)      SkFixedMulCommon(a, b, SK_FixedHalf)
+    #define SkScalarMulCeil(a, b)       SkFixedMulCommon(a, b, SK_Fixed1 - 1)
+    #define SkScalarMulFloor(a, b)      SkFixedMulCommon(a, b, 0)
+    #define SkScalarDiv(a, b)       SkFixedDiv(a, b)
+    #define SkScalarMod(a, b)       SkFixedMod(a, b)
+    #define SkScalarMulDiv(a, b, c) SkMulDiv(a, b, c)
+    #define SkScalarInvert(x)       SkFixedInvert(x)
+    #define SkScalarFastInvert(x)   SkFixedFastInvert(x)
+    #define SkScalarSqrt(x)         SkFixedSqrt(x)
+    #define SkScalarAve(a, b)       SkFixedAve(a, b)
+    #define SkScalarMean(a, b)      SkFixedMean(a, b)
+    #define SkScalarHalf(a)         ((a) >> 1)
+
+    #define SK_ScalarSqrt2          SK_FixedSqrt2
+    #define SK_ScalarPI             SK_FixedPI
+    #define SK_ScalarTanPIOver8     SK_FixedTanPIOver8
+    #define SK_ScalarRoot2Over2     SK_FixedRoot2Over2
+
+    #define SkDegreesToRadians(degrees)     SkFractMul(degrees, SK_FractPIOver180)
+    #define SkScalarSinCos(radians, cosPtr) SkFixedSinCos(radians, cosPtr)
+    #define SkScalarSin(radians)    SkFixedSin(radians)
+    #define SkScalarCos(radians)    SkFixedCos(radians)
+    #define SkScalarTan(val)        SkFixedTan(val)
+    #define SkScalarASin(val)       SkFixedASin(val)
+    #define SkScalarACos(val)       SkFixedACos(val)
+    #define SkScalarATan2(y, x)     SkFixedATan2(y,x)
+    #define SkScalarExp(x)          SkFixedExp(x)
+    #define SkScalarLog(x)          SkFixedLog(x)
+
+    #define SkMaxScalar(a, b)       SkMax32(a, b)
+    #define SkMinScalar(a, b)       SkMin32(a, b)
 #endif
 
-#define SK_ScalarNearlyZero                    (SK_Scalar1 / (1 << 12))
+#define SK_ScalarNearlyZero         (SK_Scalar1 / (1 << 12))
 
-/*     <= is slower than < for floats, so we use < for our tolerance test
+/*  <= is slower than < for floats, so we use < for our tolerance test
 */
 
 inline bool SkScalarNearlyZero(SkScalar x, SkScalar tolerance = SK_ScalarNearlyZero)
 {
-       SkASSERT(tolerance > 0);
-       return SkScalarAbs(x) < tolerance;
+    SkASSERT(tolerance > 0);
+    return SkScalarAbs(x) < tolerance;
 }
 
-/**    Linearly interpolate between A and B, based on t.
-       If t is 0, return A
-       If t is 1, return B
-       else interpolate.
-       t must be [0..SK_Scalar1]
+/** Linearly interpolate between A and B, based on t.
+    If t is 0, return A
+    If t is 1, return B
+    else interpolate.
+    t must be [0..SK_Scalar1]
 */
 inline SkScalar SkScalarInterp(SkScalar A, SkScalar B, SkScalar t)
 {
-       SkASSERT(t >= 0 && t <= SK_Scalar1);
-       return A + SkScalarMul(B - A, t);
+    SkASSERT(t >= 0 && t <= SK_Scalar1);
+    return A + SkScalarMul(B - A, t);
 }
 
 #endif
diff --git a/include/corecg/SkTSearch.h b/include/corecg/SkTSearch.h
new file mode 100644 (file)
index 0000000..fd5c824
--- /dev/null
@@ -0,0 +1,73 @@
+/* include/corecg/SkTSearch.h
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
+#ifndef SkTSearch_DEFINED
+#define SkTSearch_DEFINED
+
+#include "SkTypes.h"
+
+template <typename T>
+int SkTSearch(const T* base, int count, T target, size_t elemSize)
+{
+    SkASSERT(base != nil);
+    SkASSERT(count >= 0);
+
+    if (count <= 0)
+        return ~0;
+
+    int lo = 0;
+    int hi = count - 1;
+
+    while (lo < hi)
+    {
+        int mid = (hi + lo) >> 1;
+        const T* elem = (const T*)((const char*)base + mid * elemSize);
+
+        if (*elem < target)
+            lo = mid + 1;
+        else
+            hi = mid;
+    }
+
+    const T* elem = (const T*)((const char*)base + hi * elemSize);
+    if (*elem != target)
+    {
+        if (*elem < target)
+            hi += 1;
+        hi = ~hi;
+    }
+    return hi;
+}
+
+int SkStrSearch(const char*const* base, int count, const char target[], size_t target_len, size_t elemSize);
+int SkStrSearch(const char*const* base, int count, const char target[], size_t elemSize);
+
+/** Like SkStrSearch, but treats target as if it were all lower-case. Assumes that
+    base points to a table of lower-case strings.
+*/
+int SkStrLCSearch(const char*const* base, int count, const char target[], size_t target_len, size_t elemSize);
+int SkStrLCSearch(const char*const* base, int count, const char target[], size_t elemSize);
+
+extern "C" {
+    typedef int (*SkQSortCompareProc)(const void*, const void*);
+    void SkQSort(void* base, size_t count, size_t elemSize, SkQSortCompareProc);
+}
+
+SkDEBUGCODE(void SkQSort_UnitTest();)
+
+#endif
+
index 448638d..f183270 100644 (file)
+/* include/corecg/SkTemplates.h
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #ifndef SkTemplates_DEFINED
 #define SkTemplates_DEFINED
 
 #include "SkTypes.h"
 
-/**    \file SkTemplates.h
+/** \file SkTemplates.h
 
-       This file contains light-weight template classes for type-safe and exception-safe
-       resource management.
+    This file contains light-weight template classes for type-safe and exception-safe
+    resource management.
 */
 
 /** \class SkAutoTCallProc
 
-       Similar to SkAutoTDelete, this class is used to auto delete an object
-       when leaving the scope of the object. This is mostly useful when
-       errors occur and objects need to be cleaned up. The template uses two
-       parameters, the object, and a function that is to be called in the destructor.
-       If detach() is called then the function is not called when SkAutoTCallProc goes out
-       of scope. This also happens is the passed in object is nil.
+    Similar to SkAutoTDelete, this class is used to auto delete an object
+    when leaving the scope of the object. This is mostly useful when
+    errors occur and objects need to be cleaned up. The template uses two
+    parameters, the object, and a function that is to be called in the destructor.
+    If detach() is called then the function is not called when SkAutoTCallProc goes out
+    of scope. This also happens is the passed in object is nil.
 
 */
 template <typename T, void (*P)(T*)> class SkAutoTCallProc {
 public:
-       SkAutoTCallProc(T* obj): fObj(obj) {}
-       ~SkAutoTCallProc()
-       {
-               if (fObj)
-                       P(fObj);
-       }
-       T* detach() { T* obj = fObj; fObj = nil; return obj; }
+    SkAutoTCallProc(T* obj): fObj(obj) {}
+    ~SkAutoTCallProc()
+    {
+        if (fObj)
+            P(fObj);
+    }
+    T* detach() { T* obj = fObj; fObj = nil; return obj; }
 private:
-       T* fObj;
+    T* fObj;
 };
 
 template <typename T> class SkAutoTDelete {
 public:
-       SkAutoTDelete(T* obj) : fObj(obj) {}
-       ~SkAutoTDelete() { delete fObj; }
+    SkAutoTDelete(T* obj) : fObj(obj) {}
+    ~SkAutoTDelete() { delete fObj; }
 
-       void    free() { delete fObj; fObj = nil; }
-       T*              detach() { T* obj = fObj; fObj = nil; return obj; }
+    void    free() { delete fObj; fObj = nil; }
+    T*      detach() { T* obj = fObj; fObj = nil; return obj; }
 
 private:
-       T*      fObj;
+    T*  fObj;
 };
 
 template <typename T> class SkAutoTDeleteArray {
 public:
-       SkAutoTDeleteArray(T array[]) : fArray(array) {}
-       ~SkAutoTDeleteArray() { delete[] fArray; }
+    SkAutoTDeleteArray(T array[]) : fArray(array) {}
+    ~SkAutoTDeleteArray() { delete[] fArray; }
 
-       void    free() { delete[] fArray; fArray = nil; }
-       T*              detach() { T* array = fArray; fArray = nil; return array; }
+    void    free() { delete[] fArray; fArray = nil; }
+    T*      detach() { T* array = fArray; fArray = nil; return array; }
 
 private:
-       T*      fArray;
+    T*  fArray;
 };
 
 template <typename T> class SkAutoTArray {
 public:
-       SkAutoTArray(size_t count)
-       {
-               fArray = nil;   // init first in case we throw
-               if (count)
-                       fArray = new T[count];
+    SkAutoTArray(size_t count)
+    {
+        fArray = nil;   // init first in case we throw
+        if (count)
+            fArray = new T[count];
 #ifdef SK_DEBUG
-               fCount = count;
+        fCount = count;
 #endif
-       }
-       ~SkAutoTArray()
-       {
-               delete[] fArray;
-       }
-
-       T* get() const { return fArray; }
-       T&      operator[](int index) const { SkASSERT((unsigned)index < fCount); return fArray[index]; }
-
-       void reset()
-       {
-               if (fArray)
-               {
-                       delete[] fArray;
-                       fArray = nil;
-               }
-       }
-
-       void replace(T* array)
-       {
-               if (fArray != array)
-               {
-                       delete[] fArray;
-                       fArray = array;
-               }
-       }
-
-       /**     Call swap to exchange your pointer to an array of T with the SkAutoTArray object.
-               After this call, the SkAutoTArray object will be responsible for deleting your
-               array, and you will be responsible for deleting its.
-       */
-       void swap(T*& other)
-       {
-               T*      tmp = fArray;
-               fArray = other;
-               other = tmp;
-       }
+    }
+    ~SkAutoTArray()
+    {
+        delete[] fArray;
+    }
+
+    T* get() const { return fArray; }
+    T&  operator[](int index) const { SkASSERT((unsigned)index < fCount); return fArray[index]; }
+
+    void reset()
+    {
+        if (fArray)
+        {
+            delete[] fArray;
+            fArray = nil;
+        }
+    }
+
+    void replace(T* array)
+    {
+        if (fArray != array)
+        {
+            delete[] fArray;
+            fArray = array;
+        }
+    }
+
+    /** Call swap to exchange your pointer to an array of T with the SkAutoTArray object.
+        After this call, the SkAutoTArray object will be responsible for deleting your
+        array, and you will be responsible for deleting its.
+    */
+    void swap(T*& other)
+    {
+        T*  tmp = fArray;
+        fArray = other;
+        other = tmp;
+    }
 
 private:
 #ifdef SK_DEBUG
-       size_t fCount;
+    size_t fCount;
 #endif
-       T*      fArray;
+    T*  fArray;
 };
 
 /** Allocate a temp array on the stack/heap.
@@ -119,42 +136,45 @@ public:
     SkAutoTMalloc(size_t count)
     {
         fPtr = (T*)sk_malloc_flags(count * sizeof(T), SK_MALLOC_THROW | SK_MALLOC_TEMP);
-       }
-       ~SkAutoTMalloc()
-       {
+    }
+    ~SkAutoTMalloc()
+    {
         sk_free(fPtr);
-       }
-       T* get() const { return fPtr; }
+    }
+    T* get() const { return fPtr; }
 
 private:
-       T*  fPtr;
-       // illegal
-       SkAutoTMalloc(const SkAutoTMalloc&);
-       SkAutoTMalloc& operator=(const SkAutoTMalloc&);        
+    T*  fPtr;
+    // illegal
+    SkAutoTMalloc(const SkAutoTMalloc&);
+    SkAutoTMalloc& operator=(const SkAutoTMalloc&);        
 };
 
 template <size_t N, typename T> class SkAutoSTMalloc {
 public:
     SkAutoSTMalloc(size_t count)
     {
-               if (count <= N)
-                       fPtr = (T*)fStorage;
-               else
-                       fPtr = (T*)sk_malloc_flags(count * sizeof(T), SK_MALLOC_THROW | SK_MALLOC_TEMP);
-       }
-       ~SkAutoSTMalloc()
-       {
-               if (fPtr != (T*)fStorage)
-                       sk_free(fPtr);
-       }
-       T* get() const { return fPtr; }
+        if (count <= N)
+            fPtr = fTStorage;
+        else
+            fPtr = (T*)sk_malloc_flags(count * sizeof(T), SK_MALLOC_THROW | SK_MALLOC_TEMP);
+    }
+    ~SkAutoSTMalloc()
+    {
+        if (fPtr != fTStorage)
+            sk_free(fPtr);
+    }
+    T* get() const { return fPtr; }
 
 private:
-       T*          fPtr;
-       uint32_t        fStorage[(N*sizeof(T) + 3) >> 2];
-       // illegal
-       SkAutoSTMalloc(const SkAutoSTMalloc&);
-       SkAutoSTMalloc& operator=(const SkAutoSTMalloc&);        
+    T*          fPtr;
+    union {
+        uint32_t    fStorage32[(N*sizeof(T) + 3) >> 2];
+        T           fTStorage[1];   // do NOT want to invoke T::T()
+    };
+    // illegal
+    SkAutoSTMalloc(const SkAutoSTMalloc&);
+    SkAutoSTMalloc& operator=(const SkAutoSTMalloc&);        
 };
 
 #endif
index ac548c4..1e7bca3 100644 (file)
@@ -1,3 +1,20 @@
+/* include/corecg/SkThread.h
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #ifndef SkThread_DEFINED
 #define SkThread_DEFINED
 
@@ -11,30 +28,30 @@ int32_t sk_atomic_dec(int32_t*);
 
 class SkMutex {
 public:
-       SkMutex();
-       ~SkMutex();
+    SkMutex();
+    ~SkMutex();
 
-       void    acquire();
-       void    release();
+    void    acquire();
+    void    release();
 };
 
 ****************/
 
 class SkAutoMutexAcquire {
 public:
-       explicit SkAutoMutexAcquire(SkMutex& mutex) : fMutex(mutex)
-       {
-               mutex.acquire();
-       }
-       ~SkAutoMutexAcquire()
-       {
-               fMutex.release();
-       }
+    explicit SkAutoMutexAcquire(SkMutex& mutex) : fMutex(mutex)
+    {
+        mutex.acquire();
+    }
+    ~SkAutoMutexAcquire()
+    {
+        fMutex.release();
+    }
 private:
-       SkMutex&        fMutex;
+    SkMutex&    fMutex;
 
-       // illegal
-       SkAutoMutexAcquire& operator=(SkAutoMutexAcquire&);
+    // illegal
+    SkAutoMutexAcquire& operator=(SkAutoMutexAcquire&);
 };
 
 #endif
index bfa3899..3dd66bb 100644 (file)
@@ -1,3 +1,20 @@
+/* include/corecg/SkThread_platform.h
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #ifndef SkThread_platform_DEFINED
 #define SkThread_platform_DEFINED
 
 
 class SkMutex : android::Mutex {
 public:
-       SkMutex() {}
-       ~SkMutex() {}
+    SkMutex() {}
+    ~SkMutex() {}
 
-       void    acquire() { this->lock(); }
-       void    release() { this->unlock(); }
+    void    acquire() { this->lock(); }
+    void    release() { this->unlock(); }
 };
 
 #else   /* SkThread_empty.cpp */
@@ -25,11 +42,11 @@ int32_t sk_atomic_dec(int32_t* addr);
 
 class SkMutex {
 public:
-       SkMutex();
-       ~SkMutex();
+    SkMutex();
+    ~SkMutex();
 
-       void    acquire();
-       void    release();
+    void    acquire();
+    void    release();
 };
 
 #endif
index fe0cc38..dbb5f78 100644 (file)
@@ -1,3 +1,20 @@
+/* include/corecg/SkTypes.h
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #ifndef SkTypes_DEFINED
 #define SkTypes_DEFINED
 
@@ -8,7 +25,7 @@
 #include <stdint.h>
 #include <stdio.h>
 
-/**    \file SkTypes.h
+/** \file SkTypes.h
 */
 
 /*
 extern void  sk_out_of_memory(void);    // platform specific, does not return
 extern void  sk_throw(void);            // platform specific, does not return
 enum {
-       SK_MALLOC_TEMP  = 0x01, //!< hint to sk_malloc that the requested memory will be freed in the scope of the stack frame
-       SK_MALLOC_THROW = 0x02  //!< instructs sk_malloc to call sk_throw if the memory cannot be allocated.
+    SK_MALLOC_TEMP  = 0x01, //!< hint to sk_malloc that the requested memory will be freed in the scope of the stack frame
+    SK_MALLOC_THROW = 0x02  //!< instructs sk_malloc to call sk_throw if the memory cannot be allocated.
 };
-/**    Return a block of memory (at least 4-byte aligned) of at least the
-       specified size. If the requested memory cannot be returned, either
-       return nil (if SK_MALLOC_TEMP bit is clear) or call sk_throw()
-       (if SK_MALLOC_TEMP bit is set). To free the memory, call sk_free().
+/** Return a block of memory (at least 4-byte aligned) of at least the
+    specified size. If the requested memory cannot be returned, either
+    return nil (if SK_MALLOC_TEMP bit is clear) or call sk_throw()
+    (if SK_MALLOC_TEMP bit is set). To free the memory, call sk_free().
 */
 extern void* sk_malloc_flags(size_t size, unsigned flags);
-/**    Same as sk_malloc(), but hard coded to pass SK_MALLOC_THROW as the flag
+/** Same as sk_malloc(), but hard coded to pass SK_MALLOC_THROW as the flag
 */
 extern void* sk_malloc_throw(size_t size);
-/**    Same as standard realloc(), but this one never returns nil on failure. It will throw
-       an exception if it fails.
+/** Same as standard realloc(), but this one never returns nil on failure. It will throw
+    an exception if it fails.
 */
 extern void* sk_realloc_throw(void* buffer, size_t size);
-/**    Free memory returned by sk_malloc(). It is safe to pass nil.
+/** Free memory returned by sk_malloc(). It is safe to pass nil.
 */
 extern void  sk_free(void*);
 
 ///////////////////////////////////////////////////////////////////////
 
-#define SK_INIT_TO_AVOID_WARNING       = 0
+#define SK_INIT_TO_AVOID_WARNING    = 0
 
 #ifdef SK_DEBUG
     #define SkASSERT(cond)              SK_DEBUGBREAK(cond)
-       #define SkDEBUGCODE(code)                       code
-       #define SkDECLAREPARAM(type, var)       , type var
-       #define SkPARAM(var)                            , var
-//     #define SkDEBUGF(args           )               SkDebugf##args
-       #define SkDEBUGF(args           )               SkDebugf args
-       void SkDebugf(const char format[], ...);
-
-       #define SkAssertResult(cond)            SkASSERT(cond)
+    #define SkDEBUGCODE(code)           code
+    #define SkDECLAREPARAM(type, var)   , type var
+    #define SkPARAM(var)                , var
+//  #define SkDEBUGF(args       )       SkDebugf##args
+    #define SkDEBUGF(args       )       SkDebugf args
+    void SkDebugf(const char format[], ...);
+
+    #define SkAssertResult(cond)        SkASSERT(cond)
 #else
-       #define SkASSERT(cond)
-       #define SkDEBUGCODE(code)
-       #define SkDEBUGF(args)
-       #define SkDECLAREPARAM(type, var)
-       #define SkPARAM(var)
-
-       // unlike SkASSERT, this guy executes its condition in the non-debug build
-       #define SkAssertResult(cond)            cond
+    #define SkASSERT(cond)
+    #define SkDEBUGCODE(code)
+    #define SkDEBUGF(args)
+    #define SkDECLAREPARAM(type, var)
+    #define SkPARAM(var)
+
+    // unlike SkASSERT, this guy executes its condition in the non-debug build
+    #define SkAssertResult(cond)        cond
 #endif
 
 ///////////////////////////////////////////////////////////////////////
 
 #ifndef nil
-       #define nil                     0
+    #define nil         0
 #endif
 
 // legacy defines. will be removed before shipping
@@ -79,218 +96,231 @@ typedef uint32_t    U32;
 
 /** Fast type for signed 8 bits. Use for parameter passing and local variables, not for storage
 */
-typedef int                    S8CPU;
+typedef int         S8CPU;
 /** Fast type for unsigned 8 bits. Use for parameter passing and local variables, not for storage
 */
-typedef int                    S16CPU;
+typedef int         S16CPU;
 /** Fast type for signed 16 bits. Use for parameter passing and local variables, not for storage
 */
-typedef unsigned       U8CPU;
+typedef unsigned    U8CPU;
 /** Fast type for unsigned 16 bits. Use for parameter passing and local variables, not for storage
 */
-typedef unsigned       U16CPU;
+typedef unsigned    U16CPU;
 
 /** Meant to be faster than bool (doesn't promise to be 0 or 1, just 0 or non-zero
 */
-typedef int                    SkBool;
-/**    Meant to be a small version of bool, for storage purposes. Will be 0 or 1
+typedef int         SkBool;
+/** Meant to be a small version of bool, for storage purposes. Will be 0 or 1
 */
-typedef uint8_t                SkBool8;
+typedef uint8_t     SkBool8;
 
 #ifdef SK_DEBUG
-       int8_t      SkToS8(long);
-       uint8_t     SkToU8(size_t);
-       int16_t     SkToS16(long);
-       uint16_t        SkToU16(size_t);
-       int32_t     SkToS32(long);
-       uint32_t        SkToU32(size_t);
+    int8_t      SkToS8(long);
+    uint8_t     SkToU8(size_t);
+    int16_t     SkToS16(long);
+    uint16_t    SkToU16(size_t);
+    int32_t     SkToS32(long);
+    uint32_t    SkToU32(size_t);
 #else
-       #define SkToS8(x)       ((int8_t)(x))
-       #define SkToU8(x)       ((uint8_t)(x))
-       #define SkToS16(x)      ((int16_t)(x))
-       #define SkToU16(x)      ((uint16_t)(x))
-       #define SkToS32(x)      ((int32_t)(x))
-       #define SkToU32(x)      ((uint32_t)(x))
+    #define SkToS8(x)   ((int8_t)(x))
+    #define SkToU8(x)   ((uint8_t)(x))
+    #define SkToS16(x)  ((int16_t)(x))
+    #define SkToU16(x)  ((uint16_t)(x))
+    #define SkToS32(x)  ((int32_t)(x))
+    #define SkToU32(x)  ((uint32_t)(x))
 #endif
 
-/**    Returns 0 or 1 based on the condition
+/** Returns 0 or 1 based on the condition
 */
-#define SkToBool(cond) ((cond) != 0)
-
-#define SK_MaxS16      32767
-#define SK_MinS16      -32767
-#define SK_MaxU16      0xFFFF
-#define SK_MinU16      0
-#define SK_MaxS32      0x7FFFFFFF
-#define SK_MinS32      0x80000001
-#define SK_MaxU32      0xFFFFFFFF
-#define SK_MinU32      0
-#define SK_NaN32       0x80000000
+#define SkToBool(cond)  ((cond) != 0)
+
+#define SK_MaxS16   32767
+#define SK_MinS16   -32767
+#define SK_MaxU16   0xFFFF
+#define SK_MinU16   0
+#define SK_MaxS32   0x7FFFFFFF
+#define SK_MinS32   0x80000001
+#define SK_MaxU32   0xFFFFFFFF
+#define SK_MinU32   0
+#define SK_NaN32    0x80000000
 
 #ifndef SK_OFFSETOF
-       #define SK_OFFSETOF(type, field)        ((char*)&(((type*)1)->field) - (char*)1)
+    #define SK_OFFSETOF(type, field)    ((char*)&(((type*)1)->field) - (char*)1)
 #endif
 
-/**    Returns the number of entries in an array (not a pointer)
+/** Returns the number of entries in an array (not a pointer)
 */
-#define SK_ARRAY_COUNT(array)          (sizeof(array) / sizeof(array[0]))
+#define SK_ARRAY_COUNT(array)       (sizeof(array) / sizeof(array[0]))
 
-/**    Returns x rounded up to a multiple of 2
+/** Returns x rounded up to a multiple of 2
 */
-#define SkAlign2(x)            (((x) + 1) >> 1 << 1)
+#define SkAlign2(x)     (((x) + 1) >> 1 << 1)
 /** Returns x rounded up to a multiple of 4
 */
-#define SkAlign4(x)            (((x) + 3) >> 2 << 2)
+#define SkAlign4(x)     (((x) + 3) >> 2 << 2)
 
 typedef uint32_t SkFourByteTag;
-#define SkSetFourByteTag(a, b, c, d)   (((a) << 24) | ((b) << 16) | ((c) << 8) | (d))
+#define SkSetFourByteTag(a, b, c, d)    (((a) << 24) | ((b) << 16) | ((c) << 8) | (d))
 
-/**    32 bit integer to hold a unicode value
+/** 32 bit integer to hold a unicode value
 */
-typedef int32_t        SkUnichar;
-/**    32 bit value to hold a millisecond count
+typedef int32_t SkUnichar;
+/** 32 bit value to hold a millisecond count
 */
 typedef uint32_t SkMSec;
-/**    1 second measured in milliseconds
+/** 1 second measured in milliseconds
 */
 #define SK_MSec1 1000
-/**    maximum representable milliseconds
+/** maximum representable milliseconds
 */
 #define SK_MSecMax 0x7FFFFFFF
-/**    Returns a < b for milliseconds, correctly handling wrap-around from 0xFFFFFFFF to 0
+/** Returns a < b for milliseconds, correctly handling wrap-around from 0xFFFFFFFF to 0
 */
-#define SkMSec_LT(a, b)                ((int32_t)(a) - (int32_t)(b) < 0)
-/**    Returns a <= b for milliseconds, correctly handling wrap-around from 0xFFFFFFFF to 0
+#define SkMSec_LT(a, b)     ((int32_t)(a) - (int32_t)(b) < 0)
+/** Returns a <= b for milliseconds, correctly handling wrap-around from 0xFFFFFFFF to 0
 */
-#define SkMSec_LE(a, b)                ((int32_t)(a) - (int32_t)(b) <= 0)
+#define SkMSec_LE(a, b)     ((int32_t)(a) - (int32_t)(b) <= 0)
 
 
 /****************************************************************************
-       The rest of these only build with C++
+    The rest of these only build with C++
 */
 #ifdef __cplusplus
 
-/**    Faster than SkToBool for integral conditions. Returns 0 or 1
+/** Faster than SkToBool for integral conditions. Returns 0 or 1
 */
 inline int Sk32ToBool(uint32_t n)
 {
-       return (n | (0-n)) >> 31;
+    return (n | (0-n)) >> 31;
 }
 
 template <typename T> inline void SkTSwap(T& a, T& b)
 {
-       T c(a);
-       a = b;
-       b = c;
+    T c(a);
+    a = b;
+    b = c;
 }
 
 inline int32_t SkAbs32(int32_t value)
 {
 #ifdef SK_CPU_HAS_CONDITIONAL_INSTR
-       if (value < 0)
-               value = -value;
-       return value;
+    if (value < 0)
+        value = -value;
+    return value;
 #else
-       int32_t mask = value >> 31;
-       return (value ^ mask) - mask;
+    int32_t mask = value >> 31;
+    return (value ^ mask) - mask;
 #endif
 }
 
 inline int32_t SkMax32(int32_t a, int32_t b)
 {
-       if (a < b)
-               a = b;
-       return a;
+    if (a < b)
+        a = b;
+    return a;
 }
 
 inline int32_t SkMin32(int32_t a, int32_t b)
 {
-       if (a > b)
-               a = b;
-       return a;
+    if (a > b)
+        a = b;
+    return a;
 }
 
 inline int32_t SkSign32(int32_t a)
 {
-       return (a >> 31) | ((unsigned) -a >> 31);
+    return (a >> 31) | ((unsigned) -a >> 31);
 }
 
 inline int32_t SkFastMin32(int32_t value, int32_t max)
 {
 #ifdef SK_CPU_HAS_CONDITIONAL_INSTR
-       if (value > max)
-               value = max;
-       return value;
+    if (value > max)
+        value = max;
+    return value;
 #else
-       int diff = max - value;
-       // clear diff if it is negative (clear if value > max)
-       diff &= (diff >> 31);
-       return value + diff;
+    int diff = max - value;
+    // clear diff if it is negative (clear if value > max)
+    diff &= (diff >> 31);
+    return value + diff;
 #endif
 }
 
-/**    Returns signed 32 bit value pinned between min and max, inclusively
+/** Returns signed 32 bit value pinned between min and max, inclusively
 */
 inline int32_t SkPin32(int32_t value, int32_t min, int32_t max)
 {
 #ifdef SK_CPU_HAS_CONDITIONAL_INSTR
-       if (value < min)
-               value = min;
-       if (value > max)
-               value = max;
+    if (value < min)
+        value = min;
+    if (value > max)
+        value = max;
 #else
-       if (value < min)
-               value = min;
-       else if (value > max)
-               value = max;
+    if (value < min)
+        value = min;
+    else if (value > max)
+        value = max;
 #endif
-       return value;
+    return value;
 }
 
 inline uint32_t SkSetClear32(uint32_t flags, bool cond, unsigned shift)
 {
-       return flags & ~(1 << shift) | ((int)cond << shift);
+    SkASSERT((int)cond == 0 || (int)cond == 1);
+    return flags & ~(1 << shift) | ((int)cond << shift);
 }
 
-class SkAutoMalloc {
+class SkAutoFree {
 public:
-       SkAutoMalloc(size_t size)
-       {
-               fPtr = sk_malloc_flags(size, SK_MALLOC_THROW | SK_MALLOC_TEMP);
-       }
-       ~SkAutoMalloc()
-       {
-               sk_free(fPtr);
-       }
-       void* get() const { return fPtr; }
+    SkAutoFree() : fPtr(NULL) {}
+    explicit SkAutoFree(void* ptr) : fPtr(ptr) {}
+    ~SkAutoFree() { sk_free(fPtr); }
+    
+    void*   get() const { return fPtr; }
+    void*   set(void* ptr)
+    {
+        void* prev = fPtr;
+        fPtr = ptr;
+        return prev;
+    }
+    void*   detach() { return this->set(NULL); }
+
 private:
-       void* fPtr;
-       // illegal
-       SkAutoMalloc(const SkAutoMalloc&);
-       SkAutoMalloc& operator=(const SkAutoMalloc&);
+    void*   fPtr;
+    // illegal
+    SkAutoFree(const SkAutoFree&);
+    SkAutoFree& operator=(const SkAutoFree&);
+};
+
+class SkAutoMalloc : public SkAutoFree {
+public:
+    explicit SkAutoMalloc(size_t size)
+        : SkAutoFree(sk_malloc_flags(size, SK_MALLOC_THROW | SK_MALLOC_TEMP)) {}
+
+    SkAutoMalloc(size_t size, unsigned flags) : SkAutoFree(sk_malloc_flags(size, flags)) {}
 };
 
 template <size_t kSize> class SkAutoSMalloc {
 public:
-       SkAutoSMalloc(size_t size)
-       {
-               if (size <= kSize)
-                       fPtr = fStorage;
-               else
-                       fPtr = sk_malloc_flags(size, SK_MALLOC_THROW | SK_MALLOC_TEMP);
-       }
-       ~SkAutoSMalloc()
-       {
-               if (fPtr != (void*)fStorage)
-                       sk_free(fPtr);
-       }
-       void* get() const { return fPtr; }
+    explicit SkAutoSMalloc(size_t size)
+    {
+        if (size <= kSize)
+            fPtr = fStorage;
+        else
+            fPtr = sk_malloc_flags(size, SK_MALLOC_THROW | SK_MALLOC_TEMP);
+    }
+    ~SkAutoSMalloc()
+    {
+        if (fPtr != (void*)fStorage)
+            sk_free(fPtr);
+    }
+    void* get() const { return fPtr; }
 private:
-       void*       fPtr;
-       uint32_t        fStorage[(kSize + 3) >> 2];
-       // illegal
-       SkAutoSMalloc(const SkAutoSMalloc&);
-       SkAutoSMalloc& operator=(const SkAutoSMalloc&);
+    void*       fPtr;
+    uint32_t    fStorage[(kSize + 3) >> 2];
+    // illegal
+    SkAutoSMalloc(const SkAutoSMalloc&);
+    SkAutoSMalloc& operator=(const SkAutoSMalloc&);
 };
 
 #endif /* C++ */
index 21f1604..5615e22 100644 (file)
@@ -1,12 +1,29 @@
+/* include/corecg/SkUserConfig.h
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #ifndef SkUserConfig_DEFINED
 #define SkUserConfig_DEFINED
 
-/*     This file is included before all other headers, except for SkPreConfig.h.
-       That file uses various heuristics to make a "best guess" at settings for
-       the following build defines.
+/*  This file is included before all other headers, except for SkPreConfig.h.
+    That file uses various heuristics to make a "best guess" at settings for
+    the following build defines.
 
-       However, in this file you can override any of those decisions by either
-       defining new symbols, or #undef symbols that were already set.
+    However, in this file you can override any of those decisions by either
+    defining new symbols, or #undef symbols that were already set.
 */
 
 // experimental for now
 // android specific defines and tests
 
 #ifdef SK_FORCE_SCALARFIXED
-       #define SK_SCALAR_IS_FIXED
-       #undef SK_SCALAR_IS_FLOAT
-       #undef SK_CAN_USE_FLOAT
+    #define SK_SCALAR_IS_FIXED
+    #undef SK_SCALAR_IS_FLOAT
+    #undef SK_CAN_USE_FLOAT
 #endif
 
 #ifdef SK_FORCE_SCALARFLOAT
-       #define SK_SCALAR_IS_FLOAT
-       #define SK_CAN_USE_FLOAT
-       #undef SK_SCALAR_IS_FIXED
+    #define SK_SCALAR_IS_FLOAT
+    #define SK_CAN_USE_FLOAT
+    #undef SK_SCALAR_IS_FIXED
 #endif
 
 #ifdef ANDROID
 #endif
 
 #ifdef SK_DEBUG
-       #define SK_SUPPORT_UNITTEST
-       /* Define SK_SIMULATE_FAILED_MALLOC to have
-        * sk_malloc throw an exception. Use this to
-        * detect unhandled memory leaks. */
-       //#define SK_SIMULATE_FAILED_MALLOC
-       //#define SK_FIND_MEMORY_LEAKS
+    #define SK_SUPPORT_UNITTEST
+    /* Define SK_SIMULATE_FAILED_MALLOC to have
+     * sk_malloc throw an exception. Use this to
+     * detect unhandled memory leaks. */
+    //#define SK_SIMULATE_FAILED_MALLOC
+    //#define SK_FIND_MEMORY_LEAKS
 #endif
 
 #ifdef SK_BUILD_FOR_BREW
-       #include "SkBrewUserConfig.h"
+    #include "SkBrewUserConfig.h"
 #endif
 
 #ifdef SK_BUILD_FOR_MAC
index 3fd2885..5ab0359 100644 (file)
@@ -1,3 +1,20 @@
+/* include/graphics/Sk1DPathEffect.h
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #ifndef Sk1DPathEffect_DEFINED
 #define Sk1DPathEffect_DEFINED
 
@@ -9,30 +26,31 @@ class SkPathMeasure;
 //  This class is not exported to java.
 class Sk1DPathEffect : public SkPathEffect {
 public:
-       Sk1DPathEffect() {}
+    Sk1DPathEffect() {}
 
-       virtual bool filterPath(SkPath* dst, const SkPath& src, SkScalar* width);
+    //  This method is not exported to java.
+    virtual bool filterPath(SkPath* dst, const SkPath& src, SkScalar* width);
 
 protected:
-       /**     Called at the start of each contour, returns the initial offset
-               into that contour.
-       */
-       virtual SkScalar begin(SkScalar contourLength);
-       /**     Called with the current distance along the path, with the current matrix
-               for the point/tangent at the specified distance.
-               Return the distance to travel for the next call. If return <= 0, then that
-               contour is done.
-       */
-       virtual SkScalar next(SkPath* dst, SkScalar distance, SkPathMeasure&);
+    /** Called at the start of each contour, returns the initial offset
+        into that contour.
+    */
+    virtual SkScalar begin(SkScalar contourLength);
+    /** Called with the current distance along the path, with the current matrix
+        for the point/tangent at the specified distance.
+        Return the distance to travel for the next call. If return <= 0, then that
+        contour is done.
+    */
+    virtual SkScalar next(SkPath* dst, SkScalar distance, SkPathMeasure&);
 
-       Sk1DPathEffect(SkRBuffer& buffer) : SkPathEffect(buffer) {}
+    Sk1DPathEffect(SkRBuffer& buffer) : SkPathEffect(buffer) {}
 
 private:
-       // illegal
-       Sk1DPathEffect(const Sk1DPathEffect&);
-       Sk1DPathEffect& operator=(const Sk1DPathEffect&);
+    // illegal
+    Sk1DPathEffect(const Sk1DPathEffect&);
+    Sk1DPathEffect& operator=(const Sk1DPathEffect&);
 
-       typedef SkPathEffect INHERITED;
+    typedef SkPathEffect INHERITED;
 };
 
 class SkPath1DPathEffect : public Sk1DPathEffect {
@@ -47,7 +65,7 @@ public:
     SkPath1DPathEffect(const SkPath& path, SkScalar advance, SkScalar phase, Style);
 
     // This method is not exported to java.
-       virtual bool filterPath(SkPath* dst, const SkPath& src, SkScalar* width);
+    virtual bool filterPath(SkPath* dst, const SkPath& src, SkScalar* width);
 
 protected:
     virtual SkScalar begin(SkScalar contourLength);
index 502d4a3..dc6284d 100644 (file)
@@ -1,3 +1,20 @@
+/* include/graphics/Sk2DPathEffect.h
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #ifndef Sk2DPathEffect_DEFINED
 #define Sk2DPathEffect_DEFINED
 
 //  This class is not exported to java.
 class Sk2DPathEffect : public SkPathEffect {
 public:
-       Sk2DPathEffect(const SkMatrix& mat);
+    Sk2DPathEffect(const SkMatrix& mat);
 
-       // overrides
-       virtual bool    filterPath(SkPath* dst, const SkPath& src, SkScalar* width);
+    // overrides
+    //  This method is not exported to java.
+    virtual bool    filterPath(SkPath* dst, const SkPath& src, SkScalar* width);
 
     // overrides from SkFlattenable
-       virtual void    flatten(SkWBuffer&);
-    virtual Factory getFactory();
+    //  This method is not exported to java.
+    virtual void    flatten(SkWBuffer&);
+    
+    //  This method is not exported to java.
+       virtual Factory getFactory();
 
 protected:
-       /**     New virtual, to be overridden by subclasses.
-               This is called once from filterPath, and provides the
-               uv parameter bounds for the path. Subsequent calls to
-               next() will receive u and v values within these bounds,
-               and then a call to end() will signal the end of processing.
-       */
-       virtual void begin(const SkRect16& uvBounds, SkPath* dst);
-       virtual void next(const SkPoint& loc, int u, int v, SkPath* dst);
-       virtual void end(SkPath* dst);
-
-       /**     Low-level virtual called per span of locations in the u-direction.
-               The default implementation calls next() repeatedly with each
-               location.
-       */
-       virtual void nextSpan(int u, int v, int ucount, SkPath* dst);
-
-       const SkMatrix& getMatrix() const { return fMatrix; }
-
-       // protected so that subclasses can call this during unflattening
-       Sk2DPathEffect(SkRBuffer&);
+    /** New virtual, to be overridden by subclasses.
+        This is called once from filterPath, and provides the
+        uv parameter bounds for the path. Subsequent calls to
+        next() will receive u and v values within these bounds,
+        and then a call to end() will signal the end of processing.
+    */
+    virtual void begin(const SkRect16& uvBounds, SkPath* dst);
+    virtual void next(const SkPoint& loc, int u, int v, SkPath* dst);
+    virtual void end(SkPath* dst);
+
+    /** Low-level virtual called per span of locations in the u-direction.
+        The default implementation calls next() repeatedly with each
+        location.
+    */
+    virtual void nextSpan(int u, int v, int ucount, SkPath* dst);
+
+    const SkMatrix& getMatrix() const { return fMatrix; }
+
+    // protected so that subclasses can call this during unflattening
+    Sk2DPathEffect(SkRBuffer&);
 
 private:
-       SkMatrix        fMatrix, fInverse;
-       // illegal
-       Sk2DPathEffect(const Sk2DPathEffect&);
-       Sk2DPathEffect& operator=(const Sk2DPathEffect&);
+    SkMatrix    fMatrix, fInverse;
+    // illegal
+    Sk2DPathEffect(const Sk2DPathEffect&);
+    Sk2DPathEffect& operator=(const Sk2DPathEffect&);
 
     static SkFlattenable* CreateProc(SkRBuffer&);
 
-       friend class Sk2DPathEffectBlitter;
-       typedef SkPathEffect INHERITED;
+    friend class Sk2DPathEffectBlitter;
+    typedef SkPathEffect INHERITED;
 };
 
 #endif
index 7a70c10..fb14dd7 100644 (file)
@@ -1,3 +1,20 @@
+/* include/graphics/SkAnimator.h
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #ifndef SkAnimator_DEFINED
 #define SkAnimator_DEFINED
 
@@ -20,448 +37,448 @@ class SkDOM;
 struct SkDOMNode;
 
 /** SkElementType is the type of element: a rectangle, a color, an animator, and so on.
-       This enum is incomplete and will be fleshed out in a future release */
+    This enum is incomplete and will be fleshed out in a future release */
 enum SkElementType {
-       kElementDummyType
+    kElementDummyType
 };
 /** SkFieldType is the type of field: a scalar, a string, an integer, a boolean, and so on.
-       This enum is incomplete and will be fleshed out in a future release */
+    This enum is incomplete and will be fleshed out in a future release */
 enum SkFieldType {
-       kFieldDummyType
+    kFieldDummyType
 };
 
 /** \class SkAnimator
 
-       The SkAnimator class decodes an XML stream into a display list. The
-       display list can be drawn statically as a picture, or can drawn 
-       different elements at different times to form a moving animation.
+    The SkAnimator class decodes an XML stream into a display list. The
+    display list can be drawn statically as a picture, or can drawn 
+    different elements at different times to form a moving animation.
 
-       SkAnimator does not read the system time on its own; it relies on the
-       caller to pass the current time. The caller can pause, speed up, or
-       reverse the animation by varying the time passed in.
+    SkAnimator does not read the system time on its own; it relies on the
+    caller to pass the current time. The caller can pause, speed up, or
+    reverse the animation by varying the time passed in.
 
-       The XML describing the display list must conform to the schema 
-       described by SkAnimateSchema.xsd. 
+    The XML describing the display list must conform to the schema 
+    described by SkAnimateSchema.xsd. 
 
-       The XML must contain an <event> element to draw. Usually, it contains
-       an <event kind="onload" /> block to add some drawing elements to the
-       display list when the document is first decoded.
+    The XML must contain an <event> element to draw. Usually, it contains
+    an <event kind="onload" /> block to add some drawing elements to the
+    display list when the document is first decoded.
 
-       Here's an "Hello World" XML sample:
+    Here's an "Hello World" XML sample:
 
-       <screenplay>
-               <event kind="onload" >
-                       <text text="Hello World" y="20" />
-               </event>
-       </screenplay>
+    <screenplay>
+        <event kind="onload" >
+            <text text="Hello World" y="20" />
+        </event>
+    </screenplay>
 
-       To read and draw this sample:
+    To read and draw this sample:
 
-               // choose one of these two
-               SkAnimator animator; // declare an animator instance on the stack
-       //      SkAnimator* animator = new SkAnimator() // or one could instantiate the class
+        // choose one of these two
+        SkAnimator animator; // declare an animator instance on the stack
+    //  SkAnimator* animator = new SkAnimator() // or one could instantiate the class
 
-               // choose one of these three
-               animator.decodeMemory(buffer, size); // to read from RAM
-               animator.decodeStream(stream); // to read from a user-defined stream (e.g., a zip file)
-               animator.decodeURI(filename); // to read from a web location, or from a local text file
+        // choose one of these three
+        animator.decodeMemory(buffer, size); // to read from RAM
+        animator.decodeStream(stream); // to read from a user-defined stream (e.g., a zip file)
+        animator.decodeURI(filename); // to read from a web location, or from a local text file
 
-               // to draw to the current window:
-               SkCanvas canvas(getBitmap()); // create a canvas
-               animator.draw(canvas, &paint, 0); // draw the scene
+        // to draw to the current window:
+        SkCanvas canvas(getBitmap()); // create a canvas
+        animator.draw(canvas, &paint, 0); // draw the scene
 */
 class SkAnimator : public SkEventSink {
 public:
-       SkAnimator();
-       virtual ~SkAnimator();
-
-       /** Add a drawable extension to the graphics engine. Experimental. 
-               @param extras A derived class that implements methods that identify and instantiate the class
-       */
-       void addExtras(SkExtras* extras);
-
-       /** Read in XML from a stream, and append it to the current
-               animator. Returns false if an error was encountered.
-               Error diagnostics are stored in fErrorCode and fLineNumber.
-               @param stream  The stream to append.
-               @return true if the XML was parsed successfully.
-       */
-       bool appendStream(SkStream* stream);
-
-       /** Read in XML from memory. Returns true if the file can be 
-               read without error. Returns false if an error was encountered.
-               Error diagnostics are stored in fErrorCode and fLineNumber.
-               @param buffer  The XML text as UTF-8 characters.
-               @param size  The XML text length in bytes.
-               @return true if the XML was parsed successfully.
-       */
-       bool decodeMemory(const void* buffer, size_t size);
-
-       /** Read in XML from a stream. Returns true if the file can be 
-               read without error. Returns false if an error was encountered.
-               Error diagnostics are stored in fErrorCode and fLineNumber.
-               @param stream  The stream containg the XML text as UTF-8 characters.
-               @return true if the XML was parsed successfully.
-       */
-       virtual bool decodeStream(SkStream* stream);
-
-       /** Parse the DOM tree starting at the specified node. Returns true if it can be 
-               parsed without error. Returns false if an error was encountered.
-               Error diagnostics are stored in fErrorCode and fLineNumber.
-               @return true if the DOM was parsed successfully.
-       */
-       virtual bool decodeDOM(const SkDOM&, const SkDOMNode*);
-
-       /** Read in XML from a URI. Returns true if the file can be 
-               read without error. Returns false if an error was encountered.
-               Error diagnostics are stored in fErrorCode and fLineNumber.
-               @param uri The complete url path to be read (either ftp, http or https).
-               @return true if the XML was parsed successfully.
-       */
-       bool decodeURI(const char uri[]);
-
-       /** Pass a char event, usually a keyboard symbol, to the animator.
-               This triggers events of the form <event kind="keyChar" key="... />
-               @param ch  The character to match against <event> element "key" 
-                       attributes.
-               @return true if the event was dispatched successfully.
-       */
-       bool doCharEvent(SkUnichar ch);
-
-       /** Experimental:
-               Pass a mouse click event along with the mouse coordinates to 
-               the animator. This triggers events of the form <event kind="mouseDown" ... />
-               and other mouse events.
-               @param state The mouse state, described by SkView::Click::State : values are
-               down == 0, moved == 1, up == 2
-               @param x        The x-position of the mouse
-               @param y The y-position of the mouse
-               @return true if the event was dispatched successfully.
-       */
-       bool doClickEvent(int state, SkScalar x, SkScalar y);
-
-       /** Pass a meta-key event, such as an arrow , to the animator.
-               This triggers events of the form <event kind="keyPress" code="... />
-               @param code  The key to match against <event> element "code" 
-                       attributes.
-               @return true if the event was dispatched successfully.
-       */
-       bool doKeyEvent(SkKey code);
+    SkAnimator();
+    virtual ~SkAnimator();
+
+    /** Add a drawable extension to the graphics engine. Experimental. 
+        @param extras A derived class that implements methods that identify and instantiate the class
+    */
+    void addExtras(SkExtras* extras);
+
+    /** Read in XML from a stream, and append it to the current
+        animator. Returns false if an error was encountered.
+        Error diagnostics are stored in fErrorCode and fLineNumber.
+        @param stream  The stream to append.
+        @return true if the XML was parsed successfully.
+    */
+    bool appendStream(SkStream* stream);
+
+    /** Read in XML from memory. Returns true if the file can be 
+        read without error. Returns false if an error was encountered.
+        Error diagnostics are stored in fErrorCode and fLineNumber.
+        @param buffer  The XML text as UTF-8 characters.
+        @param size  The XML text length in bytes.
+        @return true if the XML was parsed successfully.
+    */
+    bool decodeMemory(const void* buffer, size_t size);
+
+    /** Read in XML from a stream. Returns true if the file can be 
+        read without error. Returns false if an error was encountered.
+        Error diagnostics are stored in fErrorCode and fLineNumber.
+        @param stream  The stream containg the XML text as UTF-8 characters.
+        @return true if the XML was parsed successfully.
+    */
+    virtual bool decodeStream(SkStream* stream);
+
+    /** Parse the DOM tree starting at the specified node. Returns true if it can be 
+        parsed without error. Returns false if an error was encountered.
+        Error diagnostics are stored in fErrorCode and fLineNumber.
+        @return true if the DOM was parsed successfully.
+    */
+    virtual bool decodeDOM(const SkDOM&, const SkDOMNode*);
+
+    /** Read in XML from a URI. Returns true if the file can be 
+        read without error. Returns false if an error was encountered.
+        Error diagnostics are stored in fErrorCode and fLineNumber.
+        @param uri The complete url path to be read (either ftp, http or https).
+        @return true if the XML was parsed successfully.
+    */
+    bool decodeURI(const char uri[]);
+
+    /** Pass a char event, usually a keyboard symbol, to the animator.
+        This triggers events of the form <event kind="keyChar" key="... />
+        @param ch  The character to match against <event> element "key" 
+            attributes.
+        @return true if the event was dispatched successfully.
+    */
+    bool doCharEvent(SkUnichar ch);
+
+    /** Experimental:
+        Pass a mouse click event along with the mouse coordinates to 
+        the animator. This triggers events of the form <event kind="mouseDown" ... />
+        and other mouse events.
+        @param state The mouse state, described by SkView::Click::State : values are
+        down == 0, moved == 1, up == 2
+        @param x    The x-position of the mouse
+        @param y The y-position of the mouse
+        @return true if the event was dispatched successfully.
+    */
+    bool doClickEvent(int state, SkScalar x, SkScalar y);
+
+    /** Pass a meta-key event, such as an arrow , to the animator.
+        This triggers events of the form <event kind="keyPress" code="... />
+        @param code  The key to match against <event> element "code" 
+            attributes.
+        @return true if the event was dispatched successfully.
+    */
+    bool doKeyEvent(SkKey code);
     bool doKeyUpEvent(SkKey code);
-       
-       /** Send an event to the animator. The animator's clock is set 
-               relative to the current time.
-               @return true if the event was dispatched successfully.
-       */
-       bool doUserEvent(const SkEvent& evt);
-
-       /** The possible results from the draw function. 
-       */
-       enum DifferenceType {
-               kNotDifferent,
-               kDifferent,
-               kPartiallyDifferent
-       };
-       /** Draws one frame of the animation. The first call to draw always 
-               draws the initial frame of the animation. Subsequent calls draw 
-               the offset into the animation by 
-               subtracting the initial time from the current time.
-               @param canvas  The canvas to draw into.
-               @param paint     The paint to draw with.
-               @param time  The offset into the current animation.
-               @return kNotDifferent if there are no active animations; kDifferent if there are active animations; and
-               kPartiallyDifferent if the document contains an active <bounds> element that specifies a minimal 
-               redraw area.
-       */
-       DifferenceType draw(SkCanvas* canvas, SkPaint* paint, SkMSec time);
-
-       /** Draws one frame of the animation, using a new Paint each time.
-               The first call to draw always 
-               draws the initial frame of the animation. Subsequent calls draw 
-               the offset into the animation by 
-               subtracting the initial time from the current time.
-               @param canvas  The canvas to draw into.
-               @param time  The offset into the current animation.
-               @return kNotDifferent if there are no active animations; kDifferent if there are active animations; and
-               kPartiallyDifferent if the document contains an active <bounds> element that specifies a minimal 
-               redraw area.
-       */
-       DifferenceType draw(SkCanvas* canvas, SkMSec time);
-
-       /** Experimental:
-               Helper to choose whether to return a SkView::Click handler.
-               @param x ignored
-               @param y ignored
-               @return true if a mouseDown event handler is enabled.
-       */
-       bool findClickEvent(SkScalar x, SkScalar y); 
-
-
-       /** Get the nested animator associated with this element, if any.
-               Use this to access a movie's event sink, to send events to movies.
-               @param element the value returned by getElement
-               @return the internal animator.
-       */
-       const SkAnimator* getAnimator(const SkDisplayable* element) const;
-
-       /** Returns the scalar value of the specified element's attribute[index]
-               @param element the value returned by getElement
-               @param field the value returned by getField
-               @param index the array entry
-               @return the integer value to retrieve, or SK_NaN32 if unsuccessful
-       */
-       int32_t getArrayInt(const SkDisplayable* element, const SkMemberInfo* field, int index);
-
-       /** Returns the scalar value of the specified element's attribute[index]
-               @param elementID is the value of the id attribute in the XML of this element
-               @param fieldName specifies the name of the attribute  
-               @param index the array entry
-               @return the integer value to retrieve, or SK_NaN32 if unsuccessful
-       */
-       int32_t getArrayInt(const char* elementID, const char* fieldName, int index);
-
-       /** Returns the scalar value of the specified element's attribute[index]
-               @param element the value returned by getElement
-               @param field the value returned by getField
-               @param index the array entry
-               @return the scalar value to retrieve, or SK_ScalarNaN if unsuccessful
-       */
-       SkScalar getArrayScalar(const SkDisplayable* element, const SkMemberInfo* field, int index);
-
-       /** Returns the scalar value of the specified element's attribute[index]
-               @param elementID is the value of the id attribute in the XML of this element
-               @param fieldName specifies the name of the attribute  
-               @param index the array entry
-               @return the scalar value to retrieve, or SK_ScalarNaN if unsuccessful
-       */
-       SkScalar getArrayScalar(const char* elementID, const char* fieldName, int index);
-
-       /** Returns the string value of the specified element's attribute[index]
-               @param element is a value returned by getElement
-               @param field is a value returned by getField  
-               @param index the array entry
-               @return the string value to retrieve, or null if unsuccessful
-       */
-       const char* getArrayString(const SkDisplayable* element, const SkMemberInfo* field, int index);
-
-       /** Returns the string value of the specified element's attribute[index]
-               @param elementID is the value of the id attribute in the XML of this element
-               @param fieldName specifies the name of the attribute  
-               @param index the array entry
-               @return the string value to retrieve, or null if unsuccessful
-       */
-       const char* getArrayString(const char* elementID, const char* fieldName, int index);
-
-       /** Returns the XML element corresponding to the given ID.
-               @param elementID is the value of the id attribute in the XML of this element 
-               @return the element matching the ID, or nil if the element can't be found
-       */
-       const SkDisplayable* getElement(const char* elementID);
-
-       /** Returns the element type corresponding to the XML element.
-               The element type matches the element name; for instance, <line> returns kElement_LineType
-               @param element is a value returned by getElement  
-               @return element type, or 0 if the element can't be found
-       */
-       SkElementType getElementType(const SkDisplayable* element);
-
-       /** Returns the element type corresponding to the given ID.
-               @param elementID is the value of the id attribute in the XML of this element 
-               @return element type, or 0 if the element can't be found
-       */
-       SkElementType getElementType(const char* elementID);
-
-       /** Returns the XML field of the named attribute in the XML element.
-               @param element is a value returned by getElement
-               @param fieldName is the attribute to return  
-               @return the attribute matching the fieldName, or nil if the element can't be found
-       */
-       const SkMemberInfo* getField(const SkDisplayable* element, const char* fieldName);
-
-       /** Returns the XML field of the named attribute in the XML element matching the elementID.
-               @param elementID is the value of the id attribute in the XML of this element
-               @param fieldName is the attribute to return  
-               @return the attribute matching the fieldName, or nil if the element can't be found
-       */
-       const SkMemberInfo* getField(const char* elementID, const char* fieldName);
-
-       /** Returns the value type coresponding to the element's attribute.
-               The value type matches the XML schema: and may be kField_BooleanType, kField_ScalarType, etc.
-               @param field is a value returned by getField  
-               @return the attribute type, or 0 if the element can't be found
-       */
-       SkFieldType getFieldType(const SkMemberInfo* field);
-
-       /** Returns the value type coresponding to the element's attribute.
-               @param elementID is the value of the id attribute in the XML of this element
-               @param fieldName specifies the name of the attribute  
-               @return the attribute type, or 0 if the element can't be found
-       */
-       SkFieldType getFieldType(const char* elementID, const char* fieldName);
-
-       /** Returns the recommended animation interval. Returns zero if no
-               interval is specified.
-       */
-       SkMSec getInterval();
-
-       /** Returns the partial rectangle to invalidate after drawing. Call after draw() returns
-       kIsPartiallyDifferent to do a mimimal inval(). */
-       void getInvalBounds(SkRect* inval); 
-
-       /** Returns the details of any error encountered while parsing the XML. 
-       */
-       const SkXMLParserError* getParserError();
-       
-       /** Returns the details of any error encountered while parsing the XML as string. 
-       */
-       const char* getParserErrorString();
-       
-       /** Returns the scalar value of the specified element's attribute
-               @param element is a value returned by getElement
-               @param field is a value returned by getField  
-               @return the integer value to retrieve, or SK_NaN32 if not found
-       */
-       int32_t getInt(const SkDisplayable* element, const SkMemberInfo* field);
-
-       /** Returns the scalar value of the specified element's attribute
-               @param elementID is the value of the id attribute in the XML of this element
-               @param fieldName specifies the name of the attribute  
-               @return the integer value to retrieve, or SK_NaN32 if not found
-       */
-       int32_t getInt(const char* elementID, const char* fieldName);
-
-       /** Returns the scalar value of the specified element's attribute
-               @param element is a value returned by getElement
-               @param field is a value returned by getField  
-               @return the scalar value to retrieve, or SK_ScalarNaN if not found
-       */
-       SkScalar getScalar(const SkDisplayable* element, const SkMemberInfo* field);
-
-       /** Returns the scalar value of the specified element's attribute
-               @param elementID is the value of the id attribute in the XML of this element
-               @param fieldName specifies the name of the attribute  
-               @return the scalar value to retrieve, or SK_ScalarNaN if not found
-       */
-       SkScalar getScalar(const char* elementID, const char* fieldName);
-
-       /** Returns the string value of the specified element's attribute
-               @param element is a value returned by getElement
-               @param field is a value returned by getField  
-               @return the string value to retrieve, or null if not found
-       */
-       const char* getString(const SkDisplayable* element, const SkMemberInfo* field);
-
-       /** Returns the string value of the specified element's attribute
-               @param elementID is the value of the id attribute in the XML of this element
-               @param fieldName specifies the name of the attribute  
-               @return the string value to retrieve, or null if not found
-       */
-       const char* getString(const char* elementID, const char* fieldName);
-
-       /** Gets the file default directory of the URL base path set explicitly or by reading the last URL. */
-       const char* getURIBase();
-
-       /** Resets the animator to a newly created state with no animation data. */
-       void initialize();
-
-       /** Experimental. Resets any active animations so that the next time passed is treated as 
-               time zero. */
-       void reset();
+    
+    /** Send an event to the animator. The animator's clock is set 
+        relative to the current time.
+        @return true if the event was dispatched successfully.
+    */
+    bool doUserEvent(const SkEvent& evt);
+
+    /** The possible results from the draw function. 
+    */
+    enum DifferenceType {
+        kNotDifferent,
+        kDifferent,
+        kPartiallyDifferent
+    };
+    /** Draws one frame of the animation. The first call to draw always 
+        draws the initial frame of the animation. Subsequent calls draw 
+        the offset into the animation by 
+        subtracting the initial time from the current time.
+        @param canvas  The canvas to draw into.
+        @param paint     The paint to draw with.
+        @param time  The offset into the current animation.
+        @return kNotDifferent if there are no active animations; kDifferent if there are active animations; and
+        kPartiallyDifferent if the document contains an active <bounds> element that specifies a minimal 
+        redraw area.
+    */
+    DifferenceType draw(SkCanvas* canvas, SkPaint* paint, SkMSec time);
+
+    /** Draws one frame of the animation, using a new Paint each time.
+        The first call to draw always 
+        draws the initial frame of the animation. Subsequent calls draw 
+        the offset into the animation by 
+        subtracting the initial time from the current time.
+        @param canvas  The canvas to draw into.
+        @param time  The offset into the current animation.
+        @return kNotDifferent if there are no active animations; kDifferent if there are active animations; and
+        kPartiallyDifferent if the document contains an active <bounds> element that specifies a minimal 
+        redraw area.
+    */
+    DifferenceType draw(SkCanvas* canvas, SkMSec time);
+
+    /** Experimental:
+        Helper to choose whether to return a SkView::Click handler.
+        @param x ignored
+        @param y ignored
+        @return true if a mouseDown event handler is enabled.
+    */
+    bool findClickEvent(SkScalar x, SkScalar y); 
+
+
+    /** Get the nested animator associated with this element, if any.
+        Use this to access a movie's event sink, to send events to movies.
+        @param element the value returned by getElement
+        @return the internal animator.
+    */
+    const SkAnimator* getAnimator(const SkDisplayable* element) const;
+
+    /** Returns the scalar value of the specified element's attribute[index]
+        @param element the value returned by getElement
+        @param field the value returned by getField
+        @param index the array entry
+        @return the integer value to retrieve, or SK_NaN32 if unsuccessful
+    */
+    int32_t getArrayInt(const SkDisplayable* element, const SkMemberInfo* field, int index);
+
+    /** Returns the scalar value of the specified element's attribute[index]
+        @param elementID is the value of the id attribute in the XML of this element
+        @param fieldName specifies the name of the attribute  
+        @param index the array entry
+        @return the integer value to retrieve, or SK_NaN32 if unsuccessful
+    */
+    int32_t getArrayInt(const char* elementID, const char* fieldName, int index);
+
+    /** Returns the scalar value of the specified element's attribute[index]
+        @param element the value returned by getElement
+        @param field the value returned by getField
+        @param index the array entry
+        @return the scalar value to retrieve, or SK_ScalarNaN if unsuccessful
+    */
+    SkScalar getArrayScalar(const SkDisplayable* element, const SkMemberInfo* field, int index);
+
+    /** Returns the scalar value of the specified element's attribute[index]
+        @param elementID is the value of the id attribute in the XML of this element
+        @param fieldName specifies the name of the attribute  
+        @param index the array entry
+        @return the scalar value to retrieve, or SK_ScalarNaN if unsuccessful
+    */
+    SkScalar getArrayScalar(const char* elementID, const char* fieldName, int index);
+
+    /** Returns the string value of the specified element's attribute[index]
+        @param element is a value returned by getElement
+        @param field is a value returned by getField  
+        @param index the array entry
+        @return the string value to retrieve, or null if unsuccessful
+    */
+    const char* getArrayString(const SkDisplayable* element, const SkMemberInfo* field, int index);
+
+    /** Returns the string value of the specified element's attribute[index]
+        @param elementID is the value of the id attribute in the XML of this element
+        @param fieldName specifies the name of the attribute  
+        @param index the array entry
+        @return the string value to retrieve, or null if unsuccessful
+    */
+    const char* getArrayString(const char* elementID, const char* fieldName, int index);
+
+    /** Returns the XML element corresponding to the given ID.
+        @param elementID is the value of the id attribute in the XML of this element 
+        @return the element matching the ID, or nil if the element can't be found
+    */
+    const SkDisplayable* getElement(const char* elementID);
+
+    /** Returns the element type corresponding to the XML element.
+        The element type matches the element name; for instance, <line> returns kElement_LineType
+        @param element is a value returned by getElement  
+        @return element type, or 0 if the element can't be found
+    */
+    SkElementType getElementType(const SkDisplayable* element);
+
+    /** Returns the element type corresponding to the given ID.
+        @param elementID is the value of the id attribute in the XML of this element 
+        @return element type, or 0 if the element can't be found
+    */
+    SkElementType getElementType(const char* elementID);
+
+    /** Returns the XML field of the named attribute in the XML element.
+        @param element is a value returned by getElement
+        @param fieldName is the attribute to return  
+        @return the attribute matching the fieldName, or nil if the element can't be found
+    */
+    const SkMemberInfo* getField(const SkDisplayable* element, const char* fieldName);
+
+    /** Returns the XML field of the named attribute in the XML element matching the elementID.
+        @param elementID is the value of the id attribute in the XML of this element
+        @param fieldName is the attribute to return  
+        @return the attribute matching the fieldName, or nil if the element can't be found
+    */
+    const SkMemberInfo* getField(const char* elementID, const char* fieldName);
+
+    /** Returns the value type coresponding to the element's attribute.
+        The value type matches the XML schema: and may be kField_BooleanType, kField_ScalarType, etc.
+        @param field is a value returned by getField  
+        @return the attribute type, or 0 if the element can't be found
+    */
+    SkFieldType getFieldType(const SkMemberInfo* field);
+
+    /** Returns the value type coresponding to the element's attribute.
+        @param elementID is the value of the id attribute in the XML of this element
+        @param fieldName specifies the name of the attribute  
+        @return the attribute type, or 0 if the element can't be found
+    */
+    SkFieldType getFieldType(const char* elementID, const char* fieldName);
+
+    /** Returns the recommended animation interval. Returns zero if no
+        interval is specified.
+    */
+    SkMSec getInterval();
+
+    /** Returns the partial rectangle to invalidate after drawing. Call after draw() returns
+    kIsPartiallyDifferent to do a mimimal inval(). */
+    void getInvalBounds(SkRect* inval); 
+
+    /** Returns the details of any error encountered while parsing the XML. 
+    */
+    const SkXMLParserError* getParserError();
+    
+    /** Returns the details of any error encountered while parsing the XML as string. 
+    */
+    const char* getParserErrorString();
+    
+    /** Returns the scalar value of the specified element's attribute
+        @param element is a value returned by getElement
+        @param field is a value returned by getField  
+        @return the integer value to retrieve, or SK_NaN32 if not found
+    */
+    int32_t getInt(const SkDisplayable* element, const SkMemberInfo* field);
+
+    /** Returns the scalar value of the specified element's attribute
+        @param elementID is the value of the id attribute in the XML of this element
+        @param fieldName specifies the name of the attribute  
+        @return the integer value to retrieve, or SK_NaN32 if not found
+    */
+    int32_t getInt(const char* elementID, const char* fieldName);
+
+    /** Returns the scalar value of the specified element's attribute
+        @param element is a value returned by getElement
+        @param field is a value returned by getField  
+        @return the scalar value to retrieve, or SK_ScalarNaN if not found
+    */
+    SkScalar getScalar(const SkDisplayable* element, const SkMemberInfo* field);
+
+    /** Returns the scalar value of the specified element's attribute
+        @param elementID is the value of the id attribute in the XML of this element
+        @param fieldName specifies the name of the attribute  
+        @return the scalar value to retrieve, or SK_ScalarNaN if not found
+    */
+    SkScalar getScalar(const char* elementID, const char* fieldName);
+
+    /** Returns the string value of the specified element's attribute
+        @param element is a value returned by getElement
+        @param field is a value returned by getField  
+        @return the string value to retrieve, or null if not found
+    */
+    const char* getString(const SkDisplayable* element, const SkMemberInfo* field);
+
+    /** Returns the string value of the specified element's attribute
+        @param elementID is the value of the id attribute in the XML of this element
+        @param fieldName specifies the name of the attribute  
+        @return the string value to retrieve, or null if not found
+    */
+    const char* getString(const char* elementID, const char* fieldName);
+
+    /** Gets the file default directory of the URL base path set explicitly or by reading the last URL. */
+    const char* getURIBase();
+
+    /** Resets the animator to a newly created state with no animation data. */
+    void initialize();
+
+    /** Experimental. Resets any active animations so that the next time passed is treated as 
+        time zero. */
+    void reset();
     
     /** Sets the scalar value of the specified element's attribute
-               @param elementID is the value of the id attribute in the XML of this element
-               @param fieldName specifies the name of the attribute  
-               @param array is the c-style array of integers
+        @param elementID is the value of the id attribute in the XML of this element
+        @param fieldName specifies the name of the attribute  
+        @param array is the c-style array of integers
         @param count is the length of the array
-               @return true if the value was set successfully
-       */
+        @return true if the value was set successfully
+    */
     bool setArrayInt(const char* elementID, const char* fieldName, const int* array, int count);
     
     /** Sets the scalar value of the specified element's attribute
-               @param elementID is the value of the id attribute in the XML of this element
-               @param fieldName specifies the name of the attribute  
-               @param array is the c-style array of strings
+        @param elementID is the value of the id attribute in the XML of this element
+        @param fieldName specifies the name of the attribute  
+        @param array is the c-style array of strings
         @param count is the length of the array
-               @return true if the value was set successfully
-       */
+        @return true if the value was set successfully
+    */
     bool setArrayString(const char* elementID, const char* fieldName, const char** array, int count);
     
-       /** Sets the scalar value of the specified element's attribute
-               @param elementID is the value of the id attribute in the XML of this element
-               @param fieldName specifies the name of the attribute  
-               @param data the integer value to set
-               @return true if the value was set successfully
-       */
-       bool setInt(const char* elementID, const char* fieldName, int32_t data);
-
-       /** Sets the scalar value of the specified element's attribute
-               @param elementID is the value of the id attribute in the XML of this element
-               @param fieldName specifies the name of the attribute  
-               @param data the scalar value to set
-               @return true if the value was set successfully
-       */
-       bool setScalar(const char* elementID, const char* fieldName, SkScalar data);
-
-       /** Sets the string value of the specified element's attribute
-               @param elementID is the value of the id attribute in the XML of this element
-               @param fieldName specifies the name of the attribute  
-               @param data the string value to set
-               @return true if the value was set successfully
-       */
-       bool setString(const char* elementID, const char* fieldName, const char* data);
-
-       /** Sets the file default directory of the URL base path 
-               @param path the directory path 
-       */
-       void setURIBase(const char* path);
-
-       typedef void* Handler;
+    /** Sets the scalar value of the specified element's attribute
+        @param elementID is the value of the id attribute in the XML of this element
+        @param fieldName specifies the name of the attribute  
+        @param data the integer value to set
+        @return true if the value was set successfully
+    */
+    bool setInt(const char* elementID, const char* fieldName, int32_t data);
+
+    /** Sets the scalar value of the specified element's attribute
+        @param elementID is the value of the id attribute in the XML of this element
+        @param fieldName specifies the name of the attribute  
+        @param data the scalar value to set
+        @return true if the value was set successfully
+    */
+    bool setScalar(const char* elementID, const char* fieldName, SkScalar data);
+
+    /** Sets the string value of the specified element's attribute
+        @param elementID is the value of the id attribute in the XML of this element
+        @param fieldName specifies the name of the attribute  
+        @param data the string value to set
+        @return true if the value was set successfully
+    */
+    bool setString(const char* elementID, const char* fieldName, const char* data);
+
+    /** Sets the file default directory of the URL base path 
+        @param path the directory path 
+    */
+    void setURIBase(const char* path);
+
+    typedef void* Handler;
     // This guy needs to be exported to java, so don't make it virtual
-       void setHostHandler(Handler handler) {
+    void setHostHandler(Handler handler) {
         this->onSetHostHandler(handler);
     }
 
-       /** \class Timeline
-       Returns current time to animator. To return a custom timeline, create a child
-       class and override the getMSecs method.
-       */
-       class Timeline {
-       public:
+    /** \class Timeline
+    Returns current time to animator. To return a custom timeline, create a child
+    class and override the getMSecs method.
+    */
+    class Timeline {
+    public:
         virtual ~Timeline() {}
 
-               /** Returns the current time in milliseconds */
-               virtual SkMSec getMSecs() const = 0;
-       };
-
-       /** Sets a user class to return the current time to the animator. 
-               Optional; if not called, the system clock will be used by calling SkTime::GetMSecs instead.
-               @param callBack the time function
-       */
-       void setTimeline(const Timeline& );
-
-       static void Init(bool runUnitTests);
-       static void Term();
-       
-       /** The event sink events generated by the animation are posted to. 
-               Screenplay also posts an inval event to this event sink after processing an
-               event to force a redraw.
-               @param target the event sink id
-       */
-       void setHostEventSinkID(SkEventSinkID hostID);
+        /** Returns the current time in milliseconds */
+        virtual SkMSec getMSecs() const = 0;
+    };
+
+    /** Sets a user class to return the current time to the animator. 
+        Optional; if not called, the system clock will be used by calling SkTime::GetMSecs instead.
+        @param callBack the time function
+    */
+    void setTimeline(const Timeline& );
+
+    static void Init(bool runUnitTests);
+    static void Term();
+    
+    /** The event sink events generated by the animation are posted to. 
+        Screenplay also posts an inval event to this event sink after processing an
+        event to force a redraw.
+        @param target the event sink id
+    */
+    void setHostEventSinkID(SkEventSinkID hostID);
     SkEventSinkID getHostEventSinkID() const;
-       
-       // helper
-       void setHostEventSink(SkEventSink* sink) {
-               this->setHostEventSinkID(sink ? sink->getSinkID() : 0);
-       }
-       
-       virtual void setJavaOwner(Handler owner);
-       
+    
+    // helper
+    void setHostEventSink(SkEventSink* sink) {
+        this->setHostEventSinkID(sink ? sink->getSinkID() : 0);
+    }
+    
+    virtual void setJavaOwner(Handler owner);
+    
 #ifdef SK_DEBUG
-       virtual void eventDone(const SkEvent& evt);
-       virtual bool isTrackingEvents();
-       static bool NoLeaks();
-#endif 
+    virtual void eventDone(const SkEvent& evt);
+    virtual bool isTrackingEvents();
+    static bool NoLeaks();
+#endif  
     
 protected:
     virtual void onSetHostHandler(Handler handler);
@@ -472,20 +489,20 @@ private:
 // helper functions for setters
     bool setArray(SkDisplayable* element, const SkMemberInfo* field, SkTypedArray array);
     bool setArray(const char* elementID, const char* fieldName, SkTypedArray array);
-       bool setInt(SkDisplayable* element, const SkMemberInfo* field, int32_t data);
-       bool setScalar(SkDisplayable* element, const SkMemberInfo* field, SkScalar data);
-       bool setString(SkDisplayable* element, const SkMemberInfo* field, const char* data);
+    bool setInt(SkDisplayable* element, const SkMemberInfo* field, int32_t data);
+    bool setScalar(SkDisplayable* element, const SkMemberInfo* field, SkScalar data);
+    bool setString(SkDisplayable* element, const SkMemberInfo* field, const char* data);
     
-       virtual bool onEvent(const SkEvent&);
-       SkAnimateMaker* fMaker;
-       friend class SkAnimateMaker;
-       friend class SkAnimatorScript;
-       friend class SkAnimatorScript2;
-       friend class SkApply;
-       friend class SkDisplayMovie;
-       friend class SkDisplayType;
-       friend class SkPost;
-       friend class SkXMLAnimatorWriter;
+    virtual bool onEvent(const SkEvent&);
+    SkAnimateMaker* fMaker;
+    friend class SkAnimateMaker;
+    friend class SkAnimatorScript;
+    friend class SkAnimatorScript2;
+    friend class SkApply;
+    friend class SkDisplayMovie;
+    friend class SkDisplayType;
+    friend class SkPost;
+    friend class SkXMLAnimatorWriter;
 };
 
 #endif
index 2fa7657..44e951c 100644 (file)
@@ -1,3 +1,20 @@
+/* include/graphics/SkAnimatorView.h
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #ifndef SkAnimatorView_DEFINED
 #define SkAnimatorView_DEFINED
 
 
 class SkAnimatorView : public SkView {
 public:
-                       SkAnimatorView();
-       virtual ~SkAnimatorView();
+            SkAnimatorView();
+    virtual ~SkAnimatorView();
 
-       SkAnimator*     getAnimator() const { return fAnimator; }
+    SkAnimator* getAnimator() const { return fAnimator; }
 
-       bool    decodeFile(const char path[]);
-       bool    decodeMemory(const void* buffer, size_t size);
-       bool    decodeStream(SkStream* stream);
+    bool    decodeFile(const char path[]);
+    bool    decodeMemory(const void* buffer, size_t size);
+    bool    decodeStream(SkStream* stream);
 
 protected:
-       // overrides
-       virtual bool onEvent(const SkEvent&);
-       virtual void onDraw(SkCanvas*);
-       virtual void onInflate(const SkDOM&, const SkDOM::Node*);
+    // overrides
+    virtual bool onEvent(const SkEvent&);
+    virtual void onDraw(SkCanvas*);
+    virtual void onInflate(const SkDOM&, const SkDOM::Node*);
 
 private:
-       SkAnimator*     fAnimator;
+    SkAnimator* fAnimator;
 
-       typedef SkView INHERITED;
+    typedef SkView INHERITED;
 };
 
 #endif
index fbeea47..91be3cf 100644 (file)
@@ -1,3 +1,20 @@
+/* include/graphics/SkApplication.h
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #ifndef SkApplication_DEFINED
 #define SkApplication_DEFINED
 
index 574568b..4a740d1 100644 (file)
@@ -1,3 +1,20 @@
+/* include/graphics/SkAvoidXfermode.h
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #ifndef SkAvoidXfermode_DEFINED
 #define SkAvoidXfermode_DEFINED
 
index dd6e263..3ea264d 100644 (file)
@@ -1,3 +1,20 @@
+/* include/graphics/SkBGViewArtist.h
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #ifndef SkBGViewArtist_DEFINED
 #define SkBGViewArtist_DEFINED
 
 
 class SkBGViewArtist : public SkView::Artist {
 public:
-                       SkBGViewArtist(SkColor c = SK_ColorWHITE);
-       virtual ~SkBGViewArtist();
+            SkBGViewArtist(SkColor c = SK_ColorWHITE);
+    virtual ~SkBGViewArtist();
 
-       const SkPaint&  paint() const { return fPaint; }
-       SkPaint&                paint() { return fPaint; }
+    const SkPaint&  paint() const { return fPaint; }
+    SkPaint&        paint() { return fPaint; }
 
 protected:
-       // overrides
-       virtual void onDraw(SkView*, SkCanvas*);
-       virtual void onInflate(const SkDOM&, const SkDOM::Node*);
+    // overrides
+    virtual void onDraw(SkView*, SkCanvas*);
+    virtual void onInflate(const SkDOM&, const SkDOM::Node*);
 
 private:
-       SkPaint fPaint;
+    SkPaint fPaint;
 };
 
 #endif
index 706b6b1..b1da4ba 100644 (file)
@@ -1,3 +1,20 @@
+/* include/graphics/SkBML_WXMLParser.h
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #ifndef SkBML_WXMLParser_DEFINED
 #define SkBML_WXMLParser_DEFINED
 
@@ -9,29 +26,29 @@ class SkWStream;
 
 class BML_WXMLParser : public SkXMLParser {
 public:
-       BML_WXMLParser(SkWStream& writer);
-       virtual ~BML_WXMLParser();
-       static void Write(SkStream& s, const char filename[]);
+    BML_WXMLParser(SkWStream& writer);
+    virtual ~BML_WXMLParser();
+    static void Write(SkStream& s, const char filename[]);
   
   /** @cond UNIT_TEST */
   SkDEBUGCODE(static void UnitTest();)
   /** @endcond */  
 private:
-       virtual bool onAddAttribute(const char name[], const char value[]);
-       virtual bool onEndElement(const char name[]);
-       virtual bool onStartElement(const char name[]);
-       BML_WXMLParser& operator=(const BML_WXMLParser& src);
+    virtual bool onAddAttribute(const char name[], const char value[]);
+    virtual bool onEndElement(const char name[]);
+    virtual bool onStartElement(const char name[]);
+    BML_WXMLParser& operator=(const BML_WXMLParser& src);
 #ifdef SK_DEBUG
-       int     fElemsCount, fElemsReused;
-       int     fAttrsCount, fNamesReused, fValuesReused;
+    int fElemsCount, fElemsReused;
+    int fAttrsCount, fNamesReused, fValuesReused;
 #endif
-       SkWStream&      fWriter;
-       char*           fElems[256];
-       char*           fAttrNames[256];
-       char*           fAttrValues[256];
+    SkWStream&  fWriter;
+    char*       fElems[256];
+    char*       fAttrNames[256];
+    char*       fAttrValues[256];
 
-       // important that these are U8, so we get automatic wrap-around
-       U8      fNextElem, fNextAttrName, fNextAttrValue;
+    // important that these are U8, so we get automatic wrap-around
+    U8  fNextElem, fNextAttrName, fNextAttrValue;
 };
 
 #endif // SkBML_WXMLParser_DEFINED
index 29e7f4e..e2c3e29 100644 (file)
@@ -1,3 +1,20 @@
+/* include/graphics/SkBML_XMLParser.h
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #ifndef SkBML_XMLParser_DEFINED
 #define SkBML_XMLParser_DEFINED
 
@@ -8,15 +25,15 @@ class SkXMLWriter;
 
 class BML_XMLParser {
 public:
-       /**     Read the byte XML stream and write the decompressed XML.
-       */
-       static void Read(SkStream& s, SkXMLWriter& writer);
-       /**     Read the byte XML stream and write the decompressed XML into a writable stream.
-       */
-       static void Read(SkStream& s, SkWStream& output);
-       /**     Read the byte XML stream and write the decompressed XML into an XML parser.
-       */
-       static void Read(SkStream& s, SkXMLParser& output);
+    /** Read the byte XML stream and write the decompressed XML.
+    */
+    static void Read(SkStream& s, SkXMLWriter& writer);
+    /** Read the byte XML stream and write the decompressed XML into a writable stream.
+    */
+    static void Read(SkStream& s, SkWStream& output);
+    /** Read the byte XML stream and write the decompressed XML into an XML parser.
+    */
+    static void Read(SkStream& s, SkXMLParser& output);
 };
 
 #endif // SkBML_XMLParser_DEFINED
index a7de542..2b69f2b 100644 (file)
@@ -1,3 +1,20 @@
+/* include/graphics/SkBitmap.h
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #ifndef SkBitmap_DEFINED
 #define SkBitmap_DEFINED
 
 
 class SkColorTable;
 
-/**    \class SkBitmap
+/** \class SkBitmap
 
-       The SkBitmap class specifies a raster bitmap. A bitmap has an integer width
-       and height, and a format (config), and a pointer to the actual pixels.
-       Bitmaps can be drawn into a SkCanvas, but they are also used to specify the target
-       of a SkCanvas' drawing operations.
+    The SkBitmap class specifies a raster bitmap. A bitmap has an integer width
+    and height, and a format (config), and a pointer to the actual pixels.
+    Bitmaps can be drawn into a SkCanvas, but they are also used to specify the target
+    of a SkCanvas' drawing operations.
 */
 class SkBitmap {
 public:
-       enum Config {
-               kNo_Config,         //!< bitmap has not been configured
-               kA1_Config,         //!< 1-bit per pixel, (0 is transparent, 1 is opaque)
-               kA8_Config,         //!< 8-bits per pixel, with only alpha specified (0 is transparent, 0xFF is opaque)
-               kIndex8_Config,     //!< 8-bits per pixel, using SkColorTable to specify the colors
-               kRGB_565_Config,        //!< 16-bits per pixel, (see SkColorPriv.h for packing)
-               kARGB_8888_Config,      //!< 32-bits per pixel, (see SkColorPriv.h for packing)
-
-               kConfigCount
-       };
-
-       /**     Default construct creates a bitmap with zero width and height, and no pixels.
-               Its config is set to kNo_Config.
-       */
-       SkBitmap();
-       /**     Constructor initializes the new bitmap by copying the src bitmap. All fields are copied,
-               but ownership of the pixels remains with the src bitmap.
-       */
+    enum Config {
+        kNo_Config,         //!< bitmap has not been configured
+        kA1_Config,         //!< 1-bit per pixel, (0 is transparent, 1 is opaque)
+        kA8_Config,         //!< 8-bits per pixel, with only alpha specified (0 is transparent, 0xFF is opaque)
+        kIndex8_Config,     //!< 8-bits per pixel, using SkColorTable to specify the colors
+        kRGB_565_Config,    //!< 16-bits per pixel, (see SkColorPriv.h for packing)
+        kARGB_8888_Config,  //!< 32-bits per pixel, (see SkColorPriv.h for packing)
+
+        kConfigCount
+    };
+
+    /** Default construct creates a bitmap with zero width and height, and no pixels.
+        Its config is set to kNo_Config.
+    */
+    SkBitmap();
+    /** Constructor initializes the new bitmap by copying the src bitmap. All fields are copied,
+        but ownership of the pixels remains with the src bitmap.
+    */
     //  This method is not exported to java.
-       SkBitmap(const SkBitmap& src);
-       /**     Destructor that, if getOwnsPixels() returns true, will delete the pixel's memory.
-       */
-       ~SkBitmap();
-
-       /**     Copies the src bitmap into this bitmap. Ownership of the src bitmap's pixels remains
-               with the src bitmap.
-       */
-       SkBitmap& operator=(const SkBitmap& src);
-       /**     Swap the fields of the two bitmaps. This routine is guaranteed to never fail or throw.
-       */
+    SkBitmap(const SkBitmap& src);
+    /** Destructor that, if getOwnsPixels() returns true, will delete the pixel's memory.
+    */
+    ~SkBitmap();
+
+    /** Copies the src bitmap into this bitmap. Ownership of the src bitmap's pixels remains
+        with the src bitmap.
+    */
+    SkBitmap& operator=(const SkBitmap& src);
+    /** Swap the fields of the two bitmaps. This routine is guaranteed to never fail or throw.
+    */
     //  This method is not exported to java.
-       void    swap(SkBitmap& other);
-
-       /**     Return the config for the bitmap.
-       */
-       Config  getConfig() const { return (Config)fConfig; }
-       /**     Return the bitmap's width, in pixels.
-       */
-       unsigned width() const { return fWidth; }
-       /**     Return the bitmap's height, in pixels.
-       */
-       unsigned height() const { return fHeight; }
-       /**     Return the number of bytes between subsequent rows of the bitmap.
-       */
-       unsigned rowBytes() const { return fRowBytes; }
-       /**     Return the address of the pixels for this SkBitmap. This can be set either with
-               setPixels(), where the caller owns the buffer, or with allocPixels() or resizeAlloc(),
-               which marks the pixel memory to be owned by the SkBitmap (e.g. will be freed automatically
-               when the bitmap is destroyed).
-       */
-       void*   getPixels() const { return fPixels; }
-       /**     Return the byte size of the pixels, based on the height and rowBytes
-       */
-       size_t  getSize() const { return fHeight * fRowBytes; }
+    void    swap(SkBitmap& other);
+
+    /** Return the config for the bitmap.
+    */
+    Config  getConfig() const { return (Config)fConfig; }
+    /** Return the bitmap's width, in pixels.
+    */
+    int width() const { return fWidth; }
+    /** Return the bitmap's height, in pixels.
+    */
+    int height() const { return fHeight; }
+    /** Return the number of bytes between subsequent rows of the bitmap.
+    */
+    int rowBytes() const { return fRowBytes; }
+    /** Return the address of the pixels for this SkBitmap. This can be set either with
+        setPixels(), where the caller owns the buffer, or with allocPixels() or resizeAlloc(),
+        which marks the pixel memory to be owned by the SkBitmap (e.g. will be freed automatically
+        when the bitmap is destroyed).
+    */
+    void*   getPixels() const { return fPixels; }
+    /** Return the byte size of the pixels, based on the height and rowBytes
+    */
+    size_t  getSize() const { return fHeight * fRowBytes; }
     
     /** Returns true if the bitmap is opaque (has no translucent/transparent pixels).
     */
@@ -84,289 +101,294 @@ public:
     */
     void    setIsOpaque(bool);
 
-       /**     Reset the bitmap to its initial state (see default constructor). If getOwnsPixels() returned
-               true, then the memory for the pixels is freed.
-       */
-       void    reset();
-       /**     Set the bitmap's config and dimensions. If rowBytes is 0, then an appropriate value
-               is computed based on the bitmap's config and width. If getOwnsPixels() returned true,
-               then the pixel's memory is freed.
-       */
-       void    setConfig(Config, U16CPU width, U16CPU height, U16CPU rowBytes = 0);
-       /**     Use this to assign a new pixel address for an existing bitmap. If getOwnsPixels() returned
-               true, then the previous pixel's memory is freed. The new address is "owned" by the called,
-               and getOwnsPixels() will now return false. This method is not exported to java.
-       */
-       void    setPixels(void* p);
-       /**     If this is called, then the bitmap will dynamically allocate memory for its pixels
-               based on rowBytes and height. The SkBitmap will remember that it allocated
-               this, and will automatically free it as needed, thus getOwnsPixels() will now return true.
-       */
-       void    allocPixels();
-       /**     Realloc the memory for the pixels based on the specified width and height. This
-               keeps the old value for config, and computes a rowBytes based on the config and the width.
-               This is similar, but more efficient than calling setConfig() followed by allocPixels().
-       */
+    /** Reset the bitmap to its initial state (see default constructor). If getOwnsPixels() returned
+        true, then the memory for the pixels is freed.
+    */
+    void    reset();
+    /** Set the bitmap's config and dimensions. If rowBytes is 0, then an appropriate value
+        is computed based on the bitmap's config and width. If getOwnsPixels() returned true,
+        then the pixel's memory is freed.
+    */
+    void    setConfig(Config, U16CPU width, U16CPU height, U16CPU rowBytes = 0);
+    /** Use this to assign a new pixel address for an existing bitmap. If getOwnsPixels() returned
+        true, then the previous pixel's memory is freed. The new address is "owned" by the called,
+        and getOwnsPixels() will now return false. This method is not exported to java.
+    */
+    void    setPixels(void* p);
+    /** If this is called, then the bitmap will dynamically allocate memory for its pixels
+        based on rowBytes and height. The SkBitmap will remember that it allocated
+        this, and will automatically free it as needed, thus getOwnsPixels() will now return true.
+    */
+    void    allocPixels();
+    /** Realloc the memory for the pixels based on the specified width and height. This
+        keeps the old value for config, and computes a rowBytes based on the config and the width.
+        This is similar, but more efficient than calling setConfig() followed by allocPixels().
+    */
 // not implemented
-//     void    resizeAlloc(U16CPU width, U16CPU height);
-
-       /**     Returns true if the current pixels have been allocated via allocPixels()
-               or resizeAlloc(). This method is not exported to java.
-       */
-       bool    getOwnsPixels() const;
-       /**     Call this to explicitly change the ownership rule for the pixels. This may be called
-               after one bitmap is copied into another, to specify which bitmap should handle freeing
-               the memory. This method is not exported to java.
-       */
-       void    setOwnsPixels(bool ownsPixels);
-
-       /**     Get the bitmap's colortable object.
-       
-       Return the bitmap's colortable (if any). Does not affect the colortable's
-               reference count.
-       */
-       SkColorTable* getColorTable() const { return fColorTable; }
-       /**     Assign ctable to be the colortable for the bitmap, replacing any existing reference.
-               The reference count of ctable (if it is not nil) is incremented, and any existing
-               reference has its reference count decremented. NOTE: colortable's may be assigned
-               to any bitmap, but are only interpreted for kIndex8_Config bitmaps, where they
-               are required.
-               @return the ctable argument
-       */
-       SkColorTable* setColorTable(SkColorTable* ctable);
-
-       /**     Initialize the bitmap's pixels with the specified color+alpha, automatically converting into the correct format
-               for the bitmap's config. If the config is kRGB_565_Config, then the alpha value is ignored.
-               If the config is kA8_Config, then the r,g,b parameters are ignored.
-       */
-       void eraseARGB(U8CPU a, U8CPU r, U8CPU g, U8CPU b);
-       /**     Initialize the bitmap's pixels with the specified color+alpha, automatically converting into the correct format
-               for the bitmap's config. If the config is kRGB_565_Config, then the alpha value is presumed
-               to be 0xFF. If the config is kA8_Config, then the r,g,b parameters are ignored and the
-               pixels are all set to 0xFF.
-       */
-       void eraseRGB(U8CPU r, U8CPU g, U8CPU b)
-       {
-               this->eraseARGB(0xFF, r, g, b);
-       }
-       /**     Initialize the bitmap's pixels with the specified color, automatically converting into the correct format
-               for the bitmap's config. If the config is kRGB_565_Config, then the color's alpha value is presumed
-               to be 0xFF. If the config is kA8_Config, then only the color's alpha value is used.
-       */
-       void eraseColor(SkColor c)
-       {
-               this->eraseARGB(SkColorGetA(c), SkColorGetR(c), SkColorGetG(c), SkColorGetB(c));
-       }
-
-       /**     Returns the address of the pixel specified by x,y.
-               Asserts that x,y are in range, and that the bitmap's config is either kARGB_8888_Config.
-       */
+//  void    resizeAlloc(U16CPU width, U16CPU height);
+
+    /** Returns true if the current pixels have been allocated via allocPixels()
+        or resizeAlloc(). This method is not exported to java.
+    */
+    bool    getOwnsPixels() const;
+    /** Call this to explicitly change the ownership rule for the pixels. This may be called
+        after one bitmap is copied into another, to specify which bitmap should handle freeing
+        the memory. This method is not exported to java.
+    */
+    void    setOwnsPixels(bool ownsPixels);
+
+    /** Get the bitmap's colortable object.
+    
+    Return the bitmap's colortable (if any). Does not affect the colortable's
+        reference count.
+    */
+    SkColorTable* getColorTable() const { return fColorTable; }
+    /** Assign ctable to be the colortable for the bitmap, replacing any existing reference.
+        The reference count of ctable (if it is not nil) is incremented, and any existing
+        reference has its reference count decremented. NOTE: colortable's may be assigned
+        to any bitmap, but are only interpreted for kIndex8_Config bitmaps, where they
+        are required.
+        @return the ctable argument
+    */
+    SkColorTable* setColorTable(SkColorTable* ctable);
+
+    /** Initialize the bitmap's pixels with the specified color+alpha, automatically converting into the correct format
+        for the bitmap's config. If the config is kRGB_565_Config, then the alpha value is ignored.
+        If the config is kA8_Config, then the r,g,b parameters are ignored.
+    */
+    void eraseARGB(U8CPU a, U8CPU r, U8CPU g, U8CPU b);
+    /** Initialize the bitmap's pixels with the specified color+alpha, automatically converting into the correct format
+        for the bitmap's config. If the config is kRGB_565_Config, then the alpha value is presumed
+        to be 0xFF. If the config is kA8_Config, then the r,g,b parameters are ignored and the
+        pixels are all set to 0xFF.
+    */
+    void eraseRGB(U8CPU r, U8CPU g, U8CPU b)
+    {
+        this->eraseARGB(0xFF, r, g, b);
+    }
+    /** Initialize the bitmap's pixels with the specified color, automatically converting into the correct format
+        for the bitmap's config. If the config is kRGB_565_Config, then the color's alpha value is presumed
+        to be 0xFF. If the config is kA8_Config, then only the color's alpha value is used.
+    */
+    void eraseColor(SkColor c)
+    {
+        this->eraseARGB(SkColorGetA(c), SkColorGetR(c), SkColorGetG(c), SkColorGetB(c));
+    }
+
+    /** Return a bitmap that is a quarter the size of this one
+    */
+    bool quarterSizeFiltered(SkBitmap* dst) const;
+    
+    /** Returns the address of the pixel specified by x,y.
+        Asserts that x,y are in range, and that the bitmap's config is either kARGB_8888_Config.
+    */
     //  This method is not exported to java.
-       inline uint32_t* getAddr32(int x, int y) const;
-       /**     Returns the address of the pixel specified by x,y.
-               Asserts that x,y are in range, and that the bitmap's config is kRGB_565_Config.
-       */
+    inline uint32_t* getAddr32(int x, int y) const;
+    /** Returns the address of the pixel specified by x,y.
+        Asserts that x,y are in range, and that the bitmap's config is kRGB_565_Config.
+    */
     //  This method is not exported to java.
-       inline uint16_t* getAddr16(int x, int y) const;
-       /**     Returns the address of the pixel specified by x,y.
-               Asserts that x,y are in range, and that the bitmap's config is either kA8_Config or kIndex8_Config.
-       */
+    inline uint16_t* getAddr16(int x, int y) const;
+    /** Returns the address of the pixel specified by x,y.
+        Asserts that x,y are in range, and that the bitmap's config is either kA8_Config or kIndex8_Config.
+    */
     //  This method is not exported to java.
-       inline uint8_t* getAddr8(int x, int y) const;
-       /**     Returns the color corresponding to the pixel specified by x,y.
-               Asserts that x,y are in range, and that the bitmap's config is kIndex8_Config.
-       */
+    inline uint8_t* getAddr8(int x, int y) const;
+    /** Returns the color corresponding to the pixel specified by x,y.
+        Asserts that x,y are in range, and that the bitmap's config is kIndex8_Config.
+    */
     //  This method is not exported to java.
-       inline SkPMColor getIndex8Color(int x, int y) const;
-       /**     Returns the address of the byte containing the pixel specified by x,y.
-               Asserts that x,y are in range, and that the bitmap's config is kA1_Config.
-       */
+    inline SkPMColor getIndex8Color(int x, int y) const;
+    /** Returns the address of the byte containing the pixel specified by x,y.
+        Asserts that x,y are in range, and that the bitmap's config is kA1_Config.
+    */
     //  This method is not exported to java.
-       inline uint8_t* getAddr1(int x, int y) const;
+    inline uint8_t* getAddr1(int x, int y) const;
 
-       //      OS-specific helpers
+    //  OS-specific helpers
 #ifndef SK_USE_WXWIDGETS
 #ifdef SK_BUILD_FOR_WIN
-       /**     On Windows and PocketPC builds, this will draw the SkBitmap onto the
-               specified HDC
-       */
-       void    drawToHDC(HDC, int left, int top) const;
+    /** On Windows and PocketPC builds, this will draw the SkBitmap onto the
+        specified HDC
+    */
+    void    drawToHDC(HDC, int left, int top) const;
 #elif defined(SK_BUILD_FOR_MAC)
-       /**     On Mac OS X and Carbon builds, this will draw the SkBitmap onto the
-               specified WindowRef
-       */
-       void    drawToPort(WindowRef) const;
+    /** On Mac OS X and Carbon builds, this will draw the SkBitmap onto the
+        specified WindowRef
+    */
+    void    drawToPort(WindowRef) const;
 #endif
 #endif
 
-       void            buildMipMap(bool forceRebuild);
-       unsigned        countMipLevels() const;
+    void        buildMipMap(bool forceRebuild);
+    unsigned    countMipLevels() const;
 
 private:
-       SkColorTable*   fColorTable;    // only meaningful for kIndex8
+    SkColorTable*   fColorTable;    // only meaningful for kIndex8
 
 #ifdef SK_SUPPORT_MIPMAP
-       struct MipLevel {
-               void*       fPixels;
-               uint16_t        fWidth, fHeight, fRowBytes;
-               uint8_t         fConfig, fShift;
-       };
-       enum {
-               kMaxMipLevels = 5
-       };
-       struct MipMap {
-               MipLevel        fLevel[kMaxMipLevels];
-       };
-       MipMap* fMipMap;
+    struct MipLevel {
+        void*       fPixels;
+        uint16_t    fWidth, fHeight, fRowBytes;
+        uint8_t     fConfig, fShift;
+    };
+    enum {
+        kMaxMipLevels = 5
+    };
+    struct MipMap {
+        MipLevel    fLevel[kMaxMipLevels];
+    };
+    MipMap* fMipMap;
 #endif
 
-       enum Flags {
-               kWeOwnThePixels_Flag = 0x01,
-               kWeOwnTheMipMap_Flag = 0x02,
+    enum Flags {
+        kWeOwnThePixels_Flag = 0x01,
+        kWeOwnTheMipMap_Flag = 0x02,
         kImageIsOpaque_Flag  = 0x04
-       };
+    };
 
-       void*           fPixels;
-       uint16_t        fWidth, fHeight, fRowBytes;
-       uint8_t         fConfig;
-       uint8_t         fFlags;
+    void*       fPixels;
+    uint16_t    fWidth, fHeight, fRowBytes;
+    uint8_t     fConfig;
+    uint8_t     fFlags;
 
-       const MipLevel* getMipLevel(unsigned level) const;
-
-       void freePixels();
+#ifdef SK_SUPPORT_MIPMAP
+    const MipLevel* getMipLevel(unsigned level) const;
+#endif
+    void freePixels();
 
     friend class SkBitmapShader;
 };
 
-/**    \class SkColorTable
+/** \class SkColorTable
 
-       SkColorTable holds an array SkPMColors (premultiplied 32-bit colors) used by
-       8-bit bitmaps, where the bitmap bytes are interpreted as indices into the colortable.
+    SkColorTable holds an array SkPMColors (premultiplied 32-bit colors) used by
+    8-bit bitmaps, where the bitmap bytes are interpreted as indices into the colortable.
 */
 class SkColorTable : public SkRefCnt {
 public:
-       /**     Constructs an empty color table (zero colors).
-       */
-                       SkColorTable();
-       virtual ~SkColorTable();
-
-       enum Flags {
-               kColorsAreOpaque_Flag   = 0x01  //!< if set, all of the colors in the table are opaque (alpha==0xFF)
-       };
-       /**     Returns the flag bits for the color table. These can be changed with setFlags().
-       */
-       unsigned getFlags() const { return fFlags; }
-       /**     Set the flags for the color table. See the Flags enum for possible values.
-       */
-       void    setFlags(unsigned flags);
-
-       /**     Returns the number of colors in the table.
-       */
-       int     count() const { return fCount; }
-
-       /**     Returns the specified color from the table. In the debug build, this asserts that
-               the index is in range (0 <= index < count).
-       */
-       SkPMColor operator[](int index) const
-       {
-               SkASSERT(fColors != nil && (unsigned)index < fCount);
-               return fColors[index];
-       }
-
-       /**     Specify the number of colors in the color table. This does not initialize the colors
-               to any value, just allocates memory for them. To initialize the values, either call
-               setColors(array, count), or follow setCount(count) with a call to
-               lockColors()/{set the values}/unlockColors(true).
-       */
-       void    setColors(int count) { this->setColors(nil, count); }
-       void    setColors(const SkPMColor[], int count);
-
-       /**     Return the array of colors for reading and/or writing. This must be
-               balanced by a call to unlockColors(changed?), telling the colortable if
-               the colors were changed during the lock.
-       */
-       SkPMColor* lockColors()
-       {
-               SkDEBUGCODE(fColorLockCount += 1;)
-               return fColors;
-       }
-       /**     Balancing call to lockColors(). If the colors have been changed, pass true.
-       */
-       void unlockColors(bool changed)
-       {
-               SkASSERT(fColorLockCount != 0);
-               SkDEBUGCODE(fColorLockCount -= 1;)
-       }
-
-       /** Similar to lockColors(), lock16BitCache() returns the array of
-               RGB16 colors that mirror the 32bit colors. However, this function
-               will return nil if kColorsAreOpaque_Flag is not set.
-               Also, unlike lockColors(), the returned array here cannot be modified.
-       */
-       const uint16_t* lock16BitCache();
-       /** Balancing call to lock16BitCache().
-       */
-       void            unlock16BitCache()
-       {
-               SkASSERT(f16BitCacheLockCount > 0);
-               SkDEBUGCODE(f16BitCacheLockCount -= 1);
-       }
+    /** Constructs an empty color table (zero colors).
+    */
+            SkColorTable();
+    virtual ~SkColorTable();
+
+    enum Flags {
+        kColorsAreOpaque_Flag   = 0x01  //!< if set, all of the colors in the table are opaque (alpha==0xFF)
+    };
+    /** Returns the flag bits for the color table. These can be changed with setFlags().
+    */
+    unsigned getFlags() const { return fFlags; }
+    /** Set the flags for the color table. See the Flags enum for possible values.
+    */
+    void    setFlags(unsigned flags);
+
+    /** Returns the number of colors in the table.
+    */
+    int count() const { return fCount; }
+
+    /** Returns the specified color from the table. In the debug build, this asserts that
+        the index is in range (0 <= index < count).
+    */
+    SkPMColor operator[](int index) const
+    {
+        SkASSERT(fColors != nil && (unsigned)index < fCount);
+        return fColors[index];
+    }
+
+    /** Specify the number of colors in the color table. This does not initialize the colors
+        to any value, just allocates memory for them. To initialize the values, either call
+        setColors(array, count), or follow setCount(count) with a call to
+        lockColors()/{set the values}/unlockColors(true).
+    */
+    void    setColors(int count) { this->setColors(nil, count); }
+    void    setColors(const SkPMColor[], int count);
+
+    /** Return the array of colors for reading and/or writing. This must be
+        balanced by a call to unlockColors(changed?), telling the colortable if
+        the colors were changed during the lock.
+    */
+    SkPMColor* lockColors()
+    {
+        SkDEBUGCODE(fColorLockCount += 1;)
+        return fColors;
+    }
+    /** Balancing call to lockColors(). If the colors have been changed, pass true.
+    */
+    void unlockColors(bool changed)
+    {
+        SkASSERT(fColorLockCount != 0);
+        SkDEBUGCODE(fColorLockCount -= 1;)
+    }
+
+    /** Similar to lockColors(), lock16BitCache() returns the array of
+        RGB16 colors that mirror the 32bit colors. However, this function
+        will return nil if kColorsAreOpaque_Flag is not set.
+        Also, unlike lockColors(), the returned array here cannot be modified.
+    */
+    const uint16_t* lock16BitCache();
+    /** Balancing call to lock16BitCache().
+    */
+    void        unlock16BitCache()
+    {
+        SkASSERT(f16BitCacheLockCount > 0);
+        SkDEBUGCODE(f16BitCacheLockCount -= 1);
+    }
 
 private:
-       SkPMColor*      fColors;
-       uint16_t*       f16BitCache;
-       uint16_t        fCount;
-       uint8_t     fFlags;
-       SkDEBUGCODE(int fColorLockCount;)
-       SkDEBUGCODE(int f16BitCacheLockCount;)
-
-       void inval16BitCache();
+    SkPMColor*  fColors;
+    uint16_t*   f16BitCache;
+    uint16_t    fCount;
+    uint8_t     fFlags;
+    SkDEBUGCODE(int fColorLockCount;)
+    SkDEBUGCODE(int f16BitCacheLockCount;)
+
+    void inval16BitCache();
 };
 
 //////////////////////////////////////////////////////////////////////////////////
 
 inline uint32_t* SkBitmap::getAddr32(int x, int y) const
 {
-       SkASSERT(fPixels);
-       SkASSERT(fConfig == kARGB_8888_Config);
-       SkASSERT((unsigned)x < fWidth && (unsigned)y < fHeight);
+    SkASSERT(fPixels);
+    SkASSERT(fConfig == kARGB_8888_Config);
+    SkASSERT((unsigned)x < fWidth && (unsigned)y < fHeight);
 
-       return (uint32_t*)((char*)fPixels + y * fRowBytes + (x << 2));
+    return (uint32_t*)((char*)fPixels + y * fRowBytes + (x << 2));
 }
 
 inline uint16_t* SkBitmap::getAddr16(int x, int y) const
 {
-       SkASSERT(fPixels);
-       SkASSERT(fConfig == kRGB_565_Config);
-       SkASSERT((unsigned)x < fWidth && (unsigned)y < fHeight);
+    SkASSERT(fPixels);
+    SkASSERT(fConfig == kRGB_565_Config);
+    SkASSERT((unsigned)x < fWidth && (unsigned)y < fHeight);
 
-       return (uint16_t*)((char*)fPixels + y * fRowBytes + (x << 1));
+    return (uint16_t*)((char*)fPixels + y * fRowBytes + (x << 1));
 }
 
 inline uint8_t* SkBitmap::getAddr8(int x, int y) const
 {
-       SkASSERT(fPixels);
-       SkASSERT(fConfig == kA8_Config || fConfig == kIndex8_Config);
-       SkASSERT((unsigned)x < fWidth && (unsigned)y < fHeight);
-       return (uint8_t*)fPixels + y * fRowBytes + x;
+    SkASSERT(fPixels);
+    SkASSERT(fConfig == kA8_Config || fConfig == kIndex8_Config);
+    SkASSERT((unsigned)x < fWidth && (unsigned)y < fHeight);
+    return (uint8_t*)fPixels + y * fRowBytes + x;
 }
 
 inline SkPMColor SkBitmap::getIndex8Color(int x, int y) const
 {
-       SkASSERT(fPixels);
-       SkASSERT(fConfig == kIndex8_Config);
-       SkASSERT((unsigned)x < fWidth && (unsigned)y < fHeight);
-       SkASSERT(fColorTable);
-       return (*fColorTable)[*((const uint8_t*)fPixels + y * fRowBytes + x)];
+    SkASSERT(fPixels);
+    SkASSERT(fConfig == kIndex8_Config);
+    SkASSERT((unsigned)x < fWidth && (unsigned)y < fHeight);
+    SkASSERT(fColorTable);
+    return (*fColorTable)[*((const uint8_t*)fPixels + y * fRowBytes + x)];
 }
 
 // returns the address of the byte that contains the x coordinate
 inline uint8_t* SkBitmap::getAddr1(int x, int y) const
 {
-       SkASSERT(fPixels);
-       SkASSERT(fConfig == kA1_Config);
-       SkASSERT((unsigned)x < fWidth && (unsigned)y < fHeight);
-       return (uint8_t*)fPixels + y * fRowBytes + (x >> 3);
+    SkASSERT(fPixels);
+    SkASSERT(fConfig == kA1_Config);
+    SkASSERT((unsigned)x < fWidth && (unsigned)y < fHeight);
+    return (uint8_t*)fPixels + y * fRowBytes + (x >> 3);
 }
 
 
index ffecfb6..052ae85 100644 (file)
@@ -1,3 +1,20 @@
+/* include/graphics/SkBitmapRef.h
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #ifndef SkBitmapRef_DEFINED
 #define SkBitmapRef_DEFINED 
 
@@ -5,7 +22,7 @@
 
 class SkStream;
 
-/**    Helper class to manage a cache of decoded images from the file system
+/** Helper class to manage a cache of decoded images from the file system
 */
 class SkBitmapRef : public SkRefCnt {
 public:
@@ -14,44 +31,44 @@ public:
     SkBitmapRef(const SkBitmap& src, bool transferOwnsPixels);
     virtual ~SkBitmapRef();
 
-       const SkBitmap& bitmap();
+    const SkBitmap& bitmap();
 
     static SkBitmapRef* create(const SkBitmap& src, bool transferOwnsPixels);
     static SkBitmapRef* DecodeFile(const char file[], bool forceDecode);
-    static SkBitmapRef* DecodeMemory(const void* bytes, size_t len);
-    static SkBitmapRef* DecodeStream(SkStream* stream); 
+    static SkBitmapRef* DecodeMemory(const void* bytes, size_t len, const char* name = NULL);
+    static SkBitmapRef* DecodeStream(SkStream* stream, const char* name = NULL); 
     
-    /**        Frees all cached images, asserting that all references have been removed
-       */
+    /** Frees all cached images, asserting that all references have been removed
+    */
     static void PurgeCacheAll();
 
-       /** frees one cached image, returning true, or returns false if none could be freed
-       */
-       static bool PurgeCacheOne();
+    /** frees one cached image, returning true, or returns false if none could be freed
+    */
+    static bool PurgeCacheOne();
 
 private:
-       struct Rec;
-       Rec*    fRec;
+    struct Rec;
+    Rec*    fRec;
 
-       SkBitmapRef(Rec*);
+    SkBitmapRef(Rec*);
 
-       friend class SkBitmapRef_Globals;
+    friend class SkBitmapRef_Globals;
 };
 
 class SkAutoBitmapRef {
 public:
-       SkAutoBitmapRef(const char file[], bool forceDecode)
-       {
-               fRef = SkBitmapRef::DecodeFile(file, forceDecode);
-       }
-       ~SkAutoBitmapRef() { delete fRef; }
-
-       const SkBitmap* bitmap() const
-       {
-               return fRef ? &fRef->bitmap() : nil;
-       }
+    SkAutoBitmapRef(const char file[], bool forceDecode)
+    {
+        fRef = SkBitmapRef::DecodeFile(file, forceDecode);
+    }
+    ~SkAutoBitmapRef() { delete fRef; }
+
+    const SkBitmap* bitmap() const
+    {
+        return fRef ? &fRef->bitmap() : nil;
+    }
 private:
-       SkBitmapRef*    fRef;
+    SkBitmapRef*    fRef;
 };
 
 
index 9bbba18..70b81e0 100644 (file)
@@ -1,3 +1,20 @@
+/* include/graphics/SkBlurMaskFilter.h
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #ifndef SkBlurMaskFilter_DEFINED
 #define SkBlurMaskFilter_DEFINED
 
 
 class SkBlurMaskFilter : public SkMaskFilter {
 public:
-       enum BlurStyle {
-               kNormal_BlurStyle,      //!< fuzzy inside and outside
-               kSolid_BlurStyle,       //!< solid inside, fuzzy outside
-               kOuter_BlurStyle,       //!< nothing inside, fuzzy outside
-               kInner_BlurStyle,       //!< fuzzy inside, nothing outside
-
-               kBlurStyleCount
-       };
+    enum BlurStyle {
+        kNormal_BlurStyle,  //!< fuzzy inside and outside
+        kSolid_BlurStyle,   //!< solid inside, fuzzy outside
+        kOuter_BlurStyle,   //!< nothing inside, fuzzy outside
+        kInner_BlurStyle,   //!< fuzzy inside, nothing outside
+
+        kBlurStyleCount
+    };
 
     /** Create a blur maskfilter.
         @param radius   The radius to extend the blur from the original mask. Must be > 0.
index 307a91d..400b1a7 100644 (file)
@@ -1,3 +1,20 @@
+/* include/graphics/SkBorderView.h
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #ifndef SkBorderView_DEFINED
 #define SkBorderView_DEFINED
 
 
 class SkBorderView : public SkWidgetView {
 public:
-       SkBorderView();
-       ~SkBorderView();
-       void setSkin(const char skin[]);
-       SkScalar getLeft() const { return fLeft; }
-       SkScalar getRight() const { return fRight; }
-       SkScalar getTop() const { return fTop; }
-       SkScalar getBottom() const { return fBottom; }
+    SkBorderView();
+    ~SkBorderView();
+    void setSkin(const char skin[]);
+    SkScalar getLeft() const { return fLeft; }
+    SkScalar getRight() const { return fRight; }
+    SkScalar getTop() const { return fTop; }
+    SkScalar getBottom() const { return fBottom; }
 protected:
-       //overrides
-       virtual void onInflate(const SkDOM& dom,  const SkDOM::Node* node);
-       virtual void onSizeChange();
-       virtual void onDraw(SkCanvas* canvas);
-       virtual bool onEvent(const SkEvent& evt);
+    //overrides
+    virtual void onInflate(const SkDOM& dom,  const SkDOM::Node* node);
+    virtual void onSizeChange();
+    virtual void onDraw(SkCanvas* canvas);
+    virtual bool onEvent(const SkEvent& evt);
 private:
-       SkAnimator fAnim;
-       SkScalar fLeft, fRight, fTop, fBottom;  //margin on each side
-       SkRect fMargin;
+    SkAnimator fAnim;
+    SkScalar fLeft, fRight, fTop, fBottom;  //margin on each side
+    SkRect fMargin;
 
-       typedef SkWidgetView INHERITED;
+    typedef SkWidgetView INHERITED;
 };
 
-#endif
\ No newline at end of file
+#endif
+
index 8bf9dfa..c4c4446 100644 (file)
@@ -1,3 +1,20 @@
+/* include/graphics/SkBounder.h
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #ifndef SkBounder_DEFINED
 #define SkBounder_DEFINED
 
@@ -11,34 +28,34 @@ class SkPaint;
 class SkPath;
 class SkRegion;
 
-/**    \class SkBounder
+/** \class SkBounder
 
-       Base class for intercepting the device bounds of shapes before they are drawn.
-       Install a subclass of this in your canvas.
+    Base class for intercepting the device bounds of shapes before they are drawn.
+    Install a subclass of this in your canvas.
 */
 class SkBounder : public SkRefCnt {
 public:
-       bool doIRect(const SkRect16&, const SkRegion&);
-       bool doHairline(const SkPoint&, const SkPoint&, const SkPaint&, const SkRegion&);
-       bool doRect(const SkRect&, const SkPaint&, const SkRegion&);
-       bool doPath(const SkPath&, const SkPaint&, const SkRegion&, bool doFill);
+    bool doIRect(const SkRect16&, const SkRegion&);
+    bool doHairline(const SkPoint&, const SkPoint&, const SkPaint&, const SkRegion&);
+    bool doRect(const SkRect&, const SkPaint&, const SkRegion&);
+    bool doPath(const SkPath&, const SkPaint&, const SkRegion&, bool doFill);
 
 protected:
-       /**     Override in your subclass. This is called with the device bounds of an
-               object (text, geometry, image) just before it is drawn. If your method
-               returns false, the drawing for that shape is aborted. If your method
-               returns true, drawing continues. The bounds your method receives have already
-               been transformed in to device coordinates, and clipped to the current clip.
-       */
-       virtual bool onIRect(const SkRect16&) = 0;
-
-       /**     Called after each shape has been drawn. The default implementation does
-               nothing, but your override could use this notification to signal itself
-               that the offscreen being rendered into needs to be updated to the screen.
-       */
-       virtual void commit();
-
-       friend class SkAutoBounderCommit;
+    /** Override in your subclass. This is called with the device bounds of an
+        object (text, geometry, image) just before it is drawn. If your method
+        returns false, the drawing for that shape is aborted. If your method
+        returns true, drawing continues. The bounds your method receives have already
+        been transformed in to device coordinates, and clipped to the current clip.
+    */
+    virtual bool onIRect(const SkRect16&) = 0;
+
+    /** Called after each shape has been drawn. The default implementation does
+        nothing, but your override could use this notification to signal itself
+        that the offscreen being rendered into needs to be updated to the screen.
+    */
+    virtual void commit();
+
+    friend class SkAutoBounderCommit;
 };
 
 #endif
index d39fa89..f262f41 100644 (file)
+/* include/graphics/SkCamera.h
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
+
+
+//  Inspired by Rob Johnson's most excellent QuickDraw GX sample code
+
 #ifndef SkCamera_DEFINED
 #define SkCamera_DEFINED
 
 #include "SkMatrix.h"
 #include "Sk64.h"
 
+class SkCanvas;
+
 #ifdef SK_SCALAR_IS_FIXED
-       typedef SkFract SkUnitScalar;
-       #define SK_UnitScalar1                  SK_Fract1
-       #define SkUnitScalarMul(a, b)   SkFractMul(a, b)
-       #define SkUnitScalarDiv(a, b)   SkFractDiv(a, b)
+    typedef SkFract SkUnitScalar;
+    #define SK_UnitScalar1          SK_Fract1
+    #define SkUnitScalarMul(a, b)   SkFractMul(a, b)
+    #define SkUnitScalarDiv(a, b)   SkFractDiv(a, b)
 #else
-       typedef float   SkUnitScalar;
-       #define SK_UnitScalar1                  SK_Scalar1
-       #define SkUnitScalarMul(a, b)   SkScalarMul(a, b)
-       #define SkUnitScalarDiv(a, b)   SkScalarDiv(a, b)
+    typedef float   SkUnitScalar;
+    #define SK_UnitScalar1          SK_Scalar1
+    #define SkUnitScalarMul(a, b)   SkScalarMul(a, b)
+    #define SkUnitScalarDiv(a, b)   SkScalarDiv(a, b)
 #endif
 
-//     Taken from Rob Johnson's most excellent QuickDraw GX library
-
 struct SkUnit3D {
-       SkUnitScalar    fX, fY, fZ;
-
-       void set(SkUnitScalar x, SkUnitScalar y, SkUnitScalar z)
-       {
-               fX = x; fY = y; fZ = z;
-       }
-       static SkUnitScalar Dot(const SkUnit3D&, const SkUnit3D&);
-       static void Cross(const SkUnit3D&, const SkUnit3D&, SkUnit3D* cross);
+    SkUnitScalar    fX, fY, fZ;
+
+    void set(SkUnitScalar x, SkUnitScalar y, SkUnitScalar z)
+    {
+        fX = x; fY = y; fZ = z;
+    }
+    static SkUnitScalar Dot(const SkUnit3D&, const SkUnit3D&);
+    static void Cross(const SkUnit3D&, const SkUnit3D&, SkUnit3D* cross);
 };
 
 struct SkPoint3D {
-       SkScalar        fX, fY, fZ;
+    SkScalar    fX, fY, fZ;
 
-       void set(SkScalar x, SkScalar y, SkScalar z)
-       {
-               fX = x; fY = y; fZ = z;
-       }
-       SkScalar        normalize(SkUnit3D*) const;
+    void set(SkScalar x, SkScalar y, SkScalar z)
+    {
+        fX = x; fY = y; fZ = z;
+    }
+    SkScalar    normalize(SkUnit3D*) const;
+};
+typedef SkPoint3D SkVector3D;
+
+struct SkMatrix3D {
+    SkScalar    fMat[3][4];
+    
+    void reset();
+
+    void setRow(int row, SkScalar a, SkScalar b, SkScalar c, SkScalar d = 0)
+    {
+        SkASSERT((unsigned)row < 3);
+        fMat[row][0] = a;
+        fMat[row][1] = b;
+        fMat[row][2] = c;
+        fMat[row][3] = d;
+    }
+
+    void setRotateX(SkScalar deg);
+    void setRotateY(SkScalar deg);
+    void setRotateZ(SkScalar deg);
+    void setTranslate(SkScalar x, SkScalar y, SkScalar z);
+    
+    void preRotateX(SkScalar deg);
+    void preRotateY(SkScalar deg);
+    void preRotateZ(SkScalar deg);
+    void preTranslate(SkScalar x, SkScalar y, SkScalar z);
+
+    void setConcat(const SkMatrix3D& a, const SkMatrix3D& b);
+    void mapPoint(const SkPoint3D& src, SkPoint3D* dst) const;
+    void mapVector(const SkVector3D& src, SkVector3D* dst) const;
+
+    void mapPoint(SkPoint3D* v) const
+    {
+        this->mapPoint(*v, v);
+    }
+    void mapVector(SkVector3D* v) const
+    {
+        this->mapVector(*v, v);
+    }
 };
 
 class SkPatch3D {
 public:
-       SkPatch3D();
+    SkPatch3D();
 
-       void    reset();
-       void    rotate(SkScalar radX, SkScalar radY, SkScalar radZ);
-       void    rotateDegrees(SkScalar degX, SkScalar degY, SkScalar degZ)
-       {
-               this->rotate(SkDegreesToRadians(degX),
-                                        SkDegreesToRadians(degY),
-                                        SkDegreesToRadians(degZ));
-       }
+    void    reset();
+    void    transform(const SkMatrix3D&, SkPatch3D* dst = NULL) const;
 
-       // dot a unit vector with the patch's normal
-       SkScalar        dotWith(SkScalar dx, SkScalar dy, SkScalar dz) const;
+    // dot a unit vector with the patch's normal
+    SkScalar dotWith(SkScalar dx, SkScalar dy, SkScalar dz) const;
+    SkScalar dotWith(const SkVector3D& v) const
+    {
+        return this->dotWith(v.fX, v.fY, v.fZ);
+    }
+
+    // depreicated, but still here for animator (for now)
+    void rotate(SkScalar x, SkScalar y, SkScalar z) {}
+    void rotateDegrees(SkScalar x, SkScalar y, SkScalar z) {}
 
-       SkPoint3D       fU, fV, fOrigin;
 private:
-       friend class SkCamera3D;
+public: // make public for SkDraw3D for now
+    SkVector3D  fU, fV;
+    SkPoint3D   fOrigin;
+    
+    friend class SkCamera3D;
 };
 
 class SkCamera3D {
 public:
-       SkCamera3D();
+    SkCamera3D();
+
+    void reset();
+    void update();
+    void patchToMatrix(const SkPatch3D&, SkMatrix* matrix) const;
+
+    SkPoint3D   fLocation;
+    SkPoint3D   fAxis;
+    SkPoint3D   fZenith;
+    SkPoint3D   fObserver;
+
+private:
+    mutable SkMatrix    fOrientation;
+    mutable bool        fNeedToUpdate;
+
+    void doUpdate() const;
+};
+
+class Sk3DView {
+public:
+    Sk3DView();
+    ~Sk3DView();
+
+    void save();
+    void restore();
 
-       void update();
-       void computeMatrix(const SkPatch3D&, SkMatrix* matrix) const;
+    void translate(SkScalar x, SkScalar y, SkScalar z);
+    void rotateX(SkScalar deg);
+    void rotateY(SkScalar deg);
+    void rotateZ(SkScalar deg);
 
-       SkPoint3D       fLocation;
-       SkPoint3D       fAxis;
-       SkPoint3D       fZenith;
-       SkPoint3D       fObserver;
+    void getMatrix(SkMatrix*) const;
+    void applyToCanvas(SkCanvas*) const;
 
+    SkScalar dotWithNormal(SkScalar dx, SkScalar dy, SkScalar dz) const;
+    
 private:
-       SkMatrix        fOrientation;
+    struct Rec {
+        Rec*        fNext;
+        SkMatrix3D  fMatrix;
+    };
+    Rec*        fRec;
+    Rec         fInitialRec;
+    SkCamera3D  fCamera;
 };
 
 #endif
index 11dfb99..52d5c47 100644 (file)
@@ -1,3 +1,20 @@
+/* include/graphics/SkCanvas.h
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #ifndef SkCanvas_DEFINED
 #define SkCanvas_DEFINED
 
 
 class SkBounder;
 
-/**    \class SkCanvas
+/** \class SkCanvas
 
-       The SkCanvas class holds the "draw" calls. To draw something, you need
-       4 basic components: A SkBitmap to hold the pixels, a SkCanvas to host
-       the draw calls (writing into the bitmap), a drawing primitive (e.g. SkRect, SkPath,
-       text, SkBitmap), and a paint (to describe the colors and styles for the drawing).
+    The SkCanvas class holds the "draw" calls. To draw something, you need
+    4 basic components: A SkBitmap to hold the pixels, a SkCanvas to host
+    the draw calls (writing into the bitmap), a drawing primitive (e.g. SkRect, SkPath,
+    text, SkBitmap), and a paint (to describe the colors and styles for the drawing).
 */
 class SkCanvas {
 public:
     /** Construct an empty canvas. Use setPixels() to specify a bitmap to draw into.
     */
-       SkCanvas();
+    SkCanvas();
     /** Construct a canvas with the specified bitmap to draw into.
         @param bitmap   Specifies a bitmap for the canvas to draw into. Its contents are copied to the canvas.
     */
-       SkCanvas(const SkBitmap& bitmap);
-       ~SkCanvas();
+    SkCanvas(const SkBitmap& bitmap);
+    ~SkCanvas();
 
-       /**     Return a copy of the bitmap that the canvas draws into. This does not make a copy
-               of the bitmap's pixels, but just returns the pixel's address.
+    /** Return a copy of the bitmap that the canvas draws into. This does not make a copy
+        of the bitmap's pixels, but just returns the pixel's address.
         @param bitmap   The bitmap, allocated by the caller, that receives a copy of the canvas' bitmap
                         (the one specified in the setPixels() call, or in the constructor).
-       */
-       void    getPixels(SkBitmap* bitmap) const;
-       /**     Specify a bitmap for the canvas to draw into. This routine makes a copy of the bitmap,
-               but does not copy the actual pixels. Ownership of the bitmap's pixels stays with the caller's
-               bitmap.
+    */
+    void    getPixels(SkBitmap* bitmap) const;
+    /** Specify a bitmap for the canvas to draw into. This routine makes a copy of the bitmap,
+        but does not copy the actual pixels. Ownership of the bitmap's pixels stays with the caller's
+        bitmap.
         @param bitmap   Specifies a new bitmap for the canvas to draw into. Its contents are copied to the canvas.
-       */
-       void    setPixels(const SkBitmap& bitmap);
+    */
+    void    setPixels(const SkBitmap& bitmap);
     
     /** Return true if the bitmap that the current layer draws into is always opaque
         (i.e. does not support per-pixel alpha). e.g. kARGB_8888_Config returns false,
@@ -57,126 +74,147 @@ public:
     */
     int getBitmapHeight() const { return this->getCurrBitmap().height(); }
 
-       /**     This call saves the current matrix and clip information, and pushes a copy onto a
-               private stack. Subsequent calls to translate,scale,rotate,skew,concat or clipRect,clipPath
-               all operate on this copy. When the balancing call to restore() is made, this copy is deleted
-               and the previous matrix/clip state is restored.
+    /** This call saves the current matrix and clip information, and pushes a copy onto a
+        private stack. Subsequent calls to translate,scale,rotate,skew,concat or clipRect,clipPath
+        all operate on this copy. When the balancing call to restore() is made, this copy is deleted
+        and the previous matrix/clip state is restored.
         @return The value to pass to restoreToCount() to balance this save()
-       */
-       int     save();
-       /**     This behaves the same as save(), but in addition it allocates an offscreen bitmap.
+    */
+    int     save();
+    /** This behaves the same as save(), but in addition it allocates an offscreen bitmap.
         All drawing calls are directed there, and only when the balancing call to restore() is made
         is that offscreen transfered to the canvas (or the previous layer).
         Subsequent calls to translate,scale,rotate,skew,concat or clipRect,clipPath
-               all operate on this copy. When the balancing call to restore() is made, this copy is deleted
-               and the previous matrix/clip state is restored.
+        all operate on this copy. When the balancing call to restore() is made, this copy is deleted
+        and the previous matrix/clip state is restored.
         @param bounds The maximum size the offscreen bitmap needs to be (in local coordinates)
         @param paint This is copied, and is applied to the offscreen when restore() is called.
         @return The value to pass to restoreToCount() to balance this save()
-       */
-       int     saveLayer(const SkRect& bounds, const SkPaint& paint);
-       /**     This call balances a previous call to save(), and is used to remove all modifications to
-               the matrix/clip state since the last save call. It is an error to call restore() more times
-               than save() was called.
-       */
-       void    restore();
-       /**     Returns the number of matrix/clip states on the SkCanvas' private stack. This will equal
-               # save() calls - # restore() calls.
-       */
-       int             getSaveCount() const;
-       /**     Efficient way to pop any calls to save() that happened after the save count reached saveCount.
+    */
+    int     saveLayer(const SkRect& bounds, const SkPaint& paint);
+    /** This call balances a previous call to save(), and is used to remove all modifications to
+        the matrix/clip state since the last save call. It is an error to call restore() more times
+        than save() was called.
+    */
+    void    restore();
+    /** Returns the number of matrix/clip states on the SkCanvas' private stack. This will equal
+        # save() calls - # restore() calls.
+    */
+    int     getSaveCount() const;
+    /** Efficient way to pop any calls to save() that happened after the save count reached saveCount.
         It is an error for saveCount to be less than getSaveCount()
         @param saveCount    The number of save() levels to restore from
-       */
-       void    restoreToCount(int saveCount);
+    */
+    void    restoreToCount(int saveCount);
 
-       /**     Preconcat the current matrix with the specified translation
-               @param dx       The distance to translate in X
-               @param dy       The distance to translate in Y
-               returns true if the operation succeeded (e.g. did not overflow)
-       */
-       bool    translate(SkScalar dx, SkScalar dy);
-       /**     Preconcat the current matrix with the specified scale and pivot point.
-               The pivot is the point that will remain unchanged after the scale is applied.
-               @param sx       The amount to scale in X, about the pivot point (px,py)
-               @param sy       The amount to scale in Y, about the pivot point (px,py)
-               @param px       The pivot's X coordinate
-               @param py       The pivot's Y coordinate
-               returns true if the operation succeeded (e.g. did not overflow)
-       */
-       bool    scale(SkScalar sx, SkScalar sy, SkScalar px, SkScalar py);
-       /**     Preconcat the current matrix with the specified rotation and pivot point.
-               The pivot is the point that will remain unchanged after the rotation is applied.
-               @param degrees  The amount to rotate, in degrees
-               @param px       The pivot's X coordinate
-               @param py       The pivot's Y coordinate
-               returns true if the operation succeeded (e.g. did not overflow)
-       */
-       bool    rotate(SkScalar degrees, SkScalar px, SkScalar py);
-       /**     Preconcat the current matrix with the specified skew and pivot point.
-               The pivot is the point that will remain unchanged after the skew is applied.
-               @param sx       The amount to skew in X, about the pivot point (px,py)
-               @param sy       The amount to skew in Y, about the pivot point (px,py)
-               @param px       The pivot's X coordinate
-               @param py       The pivot's Y coordinate
-               returns true if the operation succeeded (e.g. did not overflow)
-       */
-       bool    skew(SkScalar sx, SkScalar sy, SkScalar px, SkScalar py);
-       /**     Preconcat the current matrix with the specified matrix.
+    /** Preconcat the current matrix with the specified translation
+        @param dx   The distance to translate in X
+        @param dy   The distance to translate in Y
+        returns true if the operation succeeded (e.g. did not overflow)
+    */
+    bool    translate(SkScalar dx, SkScalar dy);
+    /** Preconcat the current matrix with the specified scale and pivot point.
+        The pivot is the point that will remain unchanged after the scale is applied.
+        @param sx   The amount to scale in X, about the pivot point (px,py)
+        @param sy   The amount to scale in Y, about the pivot point (px,py)
+        @param px   The pivot's X coordinate
+        @param py   The pivot's Y coordinate
+        returns true if the operation succeeded (e.g. did not overflow)
+    */
+    bool    scale(SkScalar sx, SkScalar sy, SkScalar px, SkScalar py);
+    /** Preconcat the current matrix with the specified scale.
+        @param sx   The amount to scale in X
+        @param sy   The amount to scale in Y
+        returns true if the operation succeeded (e.g. did not overflow)
+    */
+    bool    scale(SkScalar sx, SkScalar sy);
+    /** Preconcat the current matrix with the specified rotation and pivot point.
+        The pivot is the point that will remain unchanged after the rotation is applied.
+        @param degrees  The amount to rotate, in degrees
+        @param px   The pivot's X coordinate
+        @param py   The pivot's Y coordinate
+        returns true if the operation succeeded (e.g. did not overflow)
+    */
+    bool    rotate(SkScalar degrees, SkScalar px, SkScalar py);
+    /** Preconcat the current matrix with the specified rotation.
+        @param degrees  The amount to rotate, in degrees
+        returns true if the operation succeeded (e.g. did not overflow)
+    */
+    bool    rotate(SkScalar degrees);
+    /** Preconcat the current matrix with the specified skew and pivot point.
+        The pivot is the point that will remain unchanged after the skew is applied.
+        @param sx   The amount to skew in X, about the pivot point (px,py)
+        @param sy   The amount to skew in Y, about the pivot point (px,py)
+        @param px   The pivot's X coordinate
+        @param py   The pivot's Y coordinate
+        returns true if the operation succeeded (e.g. did not overflow)
+    */
+    bool    skew(SkScalar sx, SkScalar sy, SkScalar px, SkScalar py);
+    /** Preconcat the current matrix with the specified skew.
+        @param sx   The amount to skew in X
+        @param sy   The amount to skew in Y
+        returns true if the operation succeeded (e.g. did not overflow)
+    */
+    bool    skew(SkScalar sx, SkScalar sy);
+    /** Preconcat the current matrix with the specified matrix.
         @param matrix   The matrix to preconcatenate with the current matrix
         @return true if the operation succeeded (e.g. did not overflow)
-       */
-       bool    concat(const SkMatrix& matrix);
+    */
+    bool    concat(const SkMatrix& matrix);
 
-       /**     Intersect the current clip with the specified rectangle.
+    /** Intersect the current clip with the specified rectangle.
         @param rect The rect to intersect with the current clip
+        @return true if the canvas' clip is non-empty
     */
-       void    clipRect(const SkRect& rect);
-       /**     Intersect the current clip with the specified rectangle.
+    bool    clipRect(const SkRect& rect);
+    /** Intersect the current clip with the specified rectangle.
         @param left     The left side of the rectangle to intersect with the current clip
         @param top      The top side of the rectangle to intersect with the current clip
         @param right    The right side of the rectangle to intersect with the current clip
         @param bottom   The bottom side of the rectangle to intersect with the current clip
+        @return true if the canvas' clip is non-empty
     */
-       void    clipRect(SkScalar left, SkScalar top, SkScalar right, SkScalar bottom);
-       /**     Intersect the current clip with the specified path.
+    bool    clipRect(SkScalar left, SkScalar top, SkScalar right, SkScalar bottom);
+    /** Intersect the current clip with the specified path.
         @param path The path to intersect with the current clip
-       */
-       void    clipPath(const SkPath& path);
-       /**     Intersect the current clip with the specified region. Note that unlike clipRect()
+        @return true if the canvas' clip is non-empty
+    */
+    bool    clipPath(const SkPath& path);
+    /** Intersect the current clip with the specified region. Note that unlike clipRect()
         and clipPath() which transform their arguments by the current matrix, clipDeviceRgn()
         assumes its argument is already in the coordinate system of the current layer's bitmap,
         and so not transformation is performed.
         @param deviceRgn    The region to intersect with the current clip
+        @return true if the canvas' clip is non-empty
     */
-       void    clipDeviceRgn(const SkRegion& deviceRgn);
+    bool    clipDeviceRgn(const SkRegion& deviceRgn);
 
-       /**     Return true if the specified rectangle, after being transformed by the current
-               matrix, would lie completely outside of the current clip. Call this to check
-               if an area you intend to draw into is clipped out (and therefore you can skip
-               making the draw calls).
+    /** Return true if the specified rectangle, after being transformed by the current
+        matrix, would lie completely outside of the current clip. Call this to check
+        if an area you intend to draw into is clipped out (and therefore you can skip
+        making the draw calls).
         @param rect the rect to compare with the current clip
         @param antialiased  true if the rect should be considered antialiased, since that means it may
                             affect a larger area (more pixels) than non-antialiased.
         @return true if the rect (transformed by the canvas' matrix) does not intersect with the canvas' clip
-       */
-       bool    quickReject(const SkRect& rect, bool antialiased = false) const;
-       /**     Return true if the specified path, after being transformed by the current
-               matrix, would lie completely outside of the current clip. Call this to check
-               if an area you intend to draw into is clipped out (and therefore you can skip
-               making the draw calls).
+    */
+    bool    quickReject(const SkRect& rect, bool antialiased = false) const;
+    /** Return true if the specified path, after being transformed by the current
+        matrix, would lie completely outside of the current clip. Call this to check
+        if an area you intend to draw into is clipped out (and therefore you can skip
+        making the draw calls).
         Note, for speed it may return false even if the path itself might not intersect
         the clip (i.e. the bounds of the path intersects, but the path doesnot).
         @param path The path to compare with the current clip
         @param antialiased  true if the path should be considered antialiased, since that means it may
                             affect a larger area (more pixels) than non-antialiased.
         @return true if the path (transformed by the canvas' matrix) does not intersect with the canvas' clip
-       */
-       bool    quickReject(const SkPath& path, bool antialiased = false) const;
-       /**     Return true if the specified rectangle, after being transformed by the current
-               matrix, would lie completely outside of the current clip. Call this to check
-               if an area you intend to draw into is clipped out (and therefore you can skip
-               making the draw calls).
+    */
+    bool    quickReject(const SkPath& path, bool antialiased = false) const;
+    /** Return true if the specified rectangle, after being transformed by the current
+        matrix, would lie completely outside of the current clip. Call this to check
+        if an area you intend to draw into is clipped out (and therefore you can skip
+        making the draw calls).
         @param left     The left side of the rectangle to compare with the current clip
         @param top      The top side of the rectangle to compare with the current clip
         @param right    The right side of the rectangle to compare with the current clip
@@ -184,230 +222,210 @@ public:
         @param antialiased  true if the rect should be considered antialiased, since that means it may
                             affect a larger area (more pixels) than non-antialiased.
         @return true if the rect (transformed by the canvas' matrix) does not intersect with the canvas' clip
-       */
-       bool    quickReject(SkScalar left, SkScalar top, SkScalar right, SkScalar bottom, bool antialiased = false) const
+    */
+    bool    quickReject(SkScalar left, SkScalar top, SkScalar right, SkScalar bottom, bool antialiased = false) const
     {
         SkRect r;
         r.set(left, top, right, bottom);
         return this->quickReject(r, antialiased);
     }
 
-       /**     Fill the entire canvas' bitmap (restricted to the current clip) with the
-               specified RGB color, using srcover porterduff mode.
+    /** Fill the entire canvas' bitmap (restricted to the current clip) with the
+        specified RGB color, using srcover porterduff mode.
         @param r    the red component (0..255) of the color used to draw onto the canvas
         @param g    the green component (0..255) of the color used to draw onto the canvas
         @param b    the blue component (0..255) of the color used to draw onto the canvas
-       */
-       void    drawRGB(U8CPU r, U8CPU g, U8CPU b);
-       /**     Fill the entire canvas' bitmap (restricted to the current clip) with the
-               specified ARGB color, using srcover porterduff mode.
+    */
+    void    drawRGB(U8CPU r, U8CPU g, U8CPU b);
+    /** Fill the entire canvas' bitmap (restricted to the current clip) with the
+        specified ARGB color, using srcover porterduff mode.
         @param a    the alpha component (0..255) of the color used to draw onto the canvas
         @param r    the red component (0..255) of the color used to draw onto the canvas
         @param g    the green component (0..255) of the color used to draw onto the canvas
         @param b    the blue component (0..255) of the color used to draw onto the canvas
-       */
-       void    drawARGB(U8CPU a, U8CPU r, U8CPU g, U8CPU b);
-       /**     Fill the entire canvas' bitmap (restricted to the current clip) with the
-               specified color, using srcover porterduff mode.
+    */
+    void    drawARGB(U8CPU a, U8CPU r, U8CPU g, U8CPU b);
+    /** Fill the entire canvas' bitmap (restricted to the current clip) with the
+        specified color, using srcover porterduff mode.
         @param color    the color to draw onto the canvas
-       */
-       void    drawColor(SkColor color)
+    */
+    void    drawColor(SkColor color)
     {
         this->drawColor(color, SkPorterDuff::kSrcOver_Mode);
     }
-       /**     Fill the entire canvas' bitmap (restricted to the current clip) with the
-               specified color and porter-duff xfermode.
+    /** Fill the entire canvas' bitmap (restricted to the current clip) with the
+        specified color and porter-duff xfermode.
         @param color    the color to draw with
         @param mode     the porter-duff mode to apply to the color
-       */
-       void    drawColor(SkColor color, SkPorterDuff::Mode mode);
+    */
+    void    drawColor(SkColor color, SkPorterDuff::Mode mode);
 
-       /**     Fill the entire canvas' bitmap (restricted to the current clip) with the
-               specified paint. This is equivalent (but faster) to drawing an infinitely
-               large rectangle with the specified paint.
+    /** Fill the entire canvas' bitmap (restricted to the current clip) with the
+        specified paint. This is equivalent (but faster) to drawing an infinitely
+        large rectangle with the specified paint.
         @param paint    The paint used to draw onto the canvas
-       */
-       void    drawPaint(const SkPaint& paint);
-       /**     Draw a line segment with the specified start and stop points, using the specified
-               paint. NOTE: since a line is always "framed", the Style is ignored in
-               the paint.
+    */
+    void    drawPaint(const SkPaint& paint);
+    /** Draw a line segment with the specified start and stop points, using the specified
+        paint. NOTE: since a line is always "framed", the Style is ignored in
+        the paint.
         @param start    The start point of the line
         @param stop     The stop point of the line
         @param paint    The paint used to draw the line
-       */
-       void    drawLine(const SkPoint& start, const SkPoint& stop, const SkPaint& paint);
-       /**     Draw a line segment with the specified start and stop x,y coordinates, using the specified
-               paint. NOTE: since a line is always "framed", the Style is ignored in
-               the paint.
+    */
+    void    drawLine(const SkPoint& start, const SkPoint& stop, const SkPaint& paint);
+    /** Draw a line segment with the specified start and stop x,y coordinates, using the specified
+        paint. NOTE: since a line is always "framed", the Style is ignored in
+        the paint.
         @param startX   The x-coordinate of the start point of the line
         @param startY   The y-coordinate of the start point of the line
         @param endX     The x-coordinate of the end point of the line
         @param endY     The y-coordinate of the end point of the line
         @param paint    The paint used to draw the line
-       */
-       void    drawLine(SkScalar startX, SkScalar startY, SkScalar stopX, SkScalar stopY, const SkPaint& paint);
-       /**     Draw the specified SkRect using the specified paint. The rectangle will be filled
-               or framed based on the Style in the paint.
+    */
+    void    drawLine(SkScalar startX, SkScalar startY, SkScalar stopX, SkScalar stopY, const SkPaint& paint);
+    /** Draw the specified SkRect using the specified paint. The rectangle will be filled
+        or framed based on the Style in the paint.
         @param rect     The rect to be drawn
         @param paint    The paint used to draw the rect
-       */
-       void    drawRect(const SkRect& rect, const SkPaint& paint);
-       /**     Draw the specified SkRect using the specified paint. The rectangle will be filled
-               or framed based on the Style in the paint.
+    */
+    void    drawRect(const SkRect& rect, const SkPaint& paint);
+    /** Draw the specified SkRect using the specified paint. The rectangle will be filled
+        or framed based on the Style in the paint.
         @param left     The left side of the rectangle to be drawn
         @param top      The top side of the rectangle to be drawn
         @param right    The right side of the rectangle to be drawn
         @param bottom   The bottom side of the rectangle to be drawn
         @param paint    The paint used to draw the rect
-       */
-       void    drawRect(SkScalar left, SkScalar top, SkScalar right, SkScalar bottom, const SkPaint& paint);
-       /**     Draw the specified oval using the specified paint. The oval will be filled
-               or framed based on the Style in the paint.
+    */
+    void    drawRect(SkScalar left, SkScalar top, SkScalar right, SkScalar bottom, const SkPaint& paint);
+    /** Draw the specified oval using the specified paint. The oval will be filled
+        or framed based on the Style in the paint.
         @param oval     The rectangle bounds of the oval to be drawn
         @param paint    The paint used to draw the oval
-       */
-       void    drawOval(const SkRect& oval, const SkPaint&);
-       /**     Draw the specified circle using the specified paint. If radius is <= 0, then
-               nothing will be drawn. The circle will be filled
-               or framed based on the Style in the paint.
+    */
+    void    drawOval(const SkRect& oval, const SkPaint&);
+    /** Draw the specified circle using the specified paint. If radius is <= 0, then
+        nothing will be drawn. The circle will be filled
+        or framed based on the Style in the paint.
         @param cx       The x-coordinate of the center of the cirle to be drawn
         @param cy       The y-coordinate of the center of the cirle to be drawn
         @param radius   The radius of the cirle to be drawn
         @param paint    The paint used to draw the circle
-       */
-       void    drawCircle(SkScalar cx, SkScalar cy, SkScalar radius, const SkPaint& paint);
-       /**     Draw the specified round-rect using the specified paint. The round-rect will be filled
-               or framed based on the Style in the paint.
+    */
+    void    drawCircle(SkScalar cx, SkScalar cy, SkScalar radius, const SkPaint& paint);
+    /** Draw the specified arc, which will be scaled to fit inside the specified oval.
+        @param oval The bounds of oval used to define the shape and size of the arc
+        @param startAngle Starting angle (in degrees) where the arc begins
+        @param sweepAngle Sweep angle (in degrees) measured clockwise
+        @param paint    The paint used to draw the arc
+    */
+    void    drawArc(const SkRect& oval, SkScalar startAngle, SkScalar sweepAngle, const SkPaint& paint);
+    /** Draw the specified round-rect using the specified paint. The round-rect will be filled
+        or framed based on the Style in the paint.
         @param rect     The rectangular bounds of the roundRect to be drawn
-               @param rx       The x-radius of the oval used to round the corners
-               @param ry       The y-radius of the oval used to round the corners
+        @param rx       The x-radius of the oval used to round the corners
+        @param ry       The y-radius of the oval used to round the corners
         @param paint    The paint used to draw the roundRect
-       */
-       void    drawRoundRect(const SkRect& rect, SkScalar rx, SkScalar ry, const SkPaint& paint);
-       /**     Draw the specified path using the specified paint. The path will be filled
-               or framed based on the Style in the paint.
+    */
+    void    drawRoundRect(const SkRect& rect, SkScalar rx, SkScalar ry, const SkPaint& paint);
+    /** Draw the specified path using the specified paint. The path will be filled
+        or framed based on the Style in the paint.
         @param path     The path to be drawn
         @param paint    The paint used to draw the path
-       */
-       void    drawPath(const SkPath& path, const SkPaint& paint);
-       /**     Draw the specified bitmap, with its top/left corner at (x,y), using the specified paint,
+    */
+    void    drawPath(const SkPath& path, const SkPaint& paint);
+    /** Draw the specified bitmap, with its top/left corner at (x,y), using the specified paint,
         transformed by the current matrix.
         @param bitmap   The bitmap to be drawn
         @param left     The position of the left side of the bitmap being drawn
         @param top      The position of the top side of the bitmap being drawn
         @param paint    The paint used to draw the bitmap
-       */
-       void    drawBitmap(const SkBitmap& bitmap, SkScalar left, SkScalar top, const SkPaint& paint);
-       /**     Draw the specified bitmap, with its top/left corner at (x,y), transformed
+    */
+    void    drawBitmap(const SkBitmap& bitmap, SkScalar left, SkScalar top, const SkPaint& paint);
+    /** Draw the specified bitmap, with its top/left corner at (x,y), transformed
         by the current matrix. Since no paint is specified, the bitmap is drawn with no overriding
         alpha or colorfilter, and in srcover porterduff mode.
         @param bitmap   The bitmap to be drawn
         @param left     The position of the left side of the bitmap being drawn
         @param top      The position of the top side of the bitmap being drawn
-       */
-       void    drawBitmap(const SkBitmap& bitmap, SkScalar left, SkScalar top);
-       /**     Draw the specified bitmap, with its top/left corner at (x,y), NOT transformed
+    */
+    void    drawBitmap(const SkBitmap& bitmap, SkScalar left, SkScalar top);
+    /** Draw the specified bitmap, with its top/left corner at (x,y), NOT transformed
         by the current matrix. This method is not exported to java.
         @param bitmap   The bitmap to be drawn
         @param left     The position of the left side of the bitmap being drawn
         @param top      The position of the top side of the bitmap being drawn
         @param paint    The paint used to draw the bitmap
-       */
+    */
     void    drawSprite(const SkBitmap& bitmap, int left, int top, const SkPaint& paint);
-       /**     Draw the utf8-text, with origin at (x,y), using the specified paint. The origin is interpreted
-               based on the Align setting in the paint.
-               @param text     The UTF8 text to be drawn
-               @param byteLength       The number of bytes to read from the text parameter
+    /** Draw the text, with origin at (x,y), using the specified paint. The origin is interpreted
+        based on the Align setting in the paint.
+        @param text The text to be drawn
+        @param byteLength   The number of bytes to read from the text parameter
         @param x        The x-coordinate of the origin of the text being drawn
         @param y        The y-coordinate of the origin of the text being drawn
-               @param paint    The paint used for the text (e.g. color, size, style)
-       */
-       void    drawText(const char text[], size_t byteLength, SkScalar x, SkScalar y, const SkPaint& paint);
-       /**     Draw the utf8-text, with origin at (x,y), using the specified paint. The origin is interpreted
-               based on the Align setting in the paint.
-               @param text     The UTF16 text to be drawn
-               @param numberOf16BitValues      The number of 16bit values to read from the text parameter
-        @param x        The x-coordinate of the origin of the text being drawn
-        @param y        The y-coordinate of the origin of the text being drawn
-               @param paint    The paint used for the text (e.g. color, size, style)
-       */
-       void    drawText16(const uint16_t text[], size_t numberOf16BitValues, SkScalar x, SkScalar y, const SkPaint& paint);
-       /**     Draw the utf8-text, with origin at (x,y), using the specified paint. The origin is interpreted
-               based on the Align setting in the paint.
-               @param text     The UTF8 text to be drawn
-               @param byteLength       The number of bytes to read from the text parameter
-        @param pos      Array of positions, used to position each character
-               @param paint    The paint used for the text (e.g. color, size, style)
-       */
-       void    drawPosText(const char text[], size_t byteLength, const SkPoint pos[], const SkPaint& paint);
-       /**     Draw the utf8-text, with origin at (x,y), using the specified paint. The origin is interpreted
-               based on the Align setting in the paint.
-               @param text     The UTF16 text to be drawn
-               @param numberOf16BitValues      The number of 16bit values to read from the text parameter
+        @param paint    The paint used for the text (e.g. color, size, style)
+    */
+    void    drawText(const void* text, size_t byteLength, SkScalar x, SkScalar y, const SkPaint& paint);
+    /** Draw the text, with origin at (x,y), using the specified paint. The origin is interpreted
+        based on the Align setting in the paint.
+        @param text The text to be drawn
+        @param byteLength   The number of bytes to read from the text parameter
         @param pos      Array of positions, used to position each character
-               @param paint    The paint used for the text (e.g. color, size, style)
-       */
-       void    drawPosText16(const uint16_t text[], size_t numberOf16BitValues, const SkPoint pos[], const SkPaint& paint);
-       /**     Draw the utf8-text, with origin at (x,y), using the specified paint, along the specified path.
-               The paint's Align setting determins where along the path to start the text.
-               @param text     The UTF8 text to be drawn
-               @param byteLength       The number of bytes to read from the text parameter
-               @param path         The path the text should follow for its baseline
-               @param distance     The distance along the path to add to the text's starting position
-               @param paint        The paint used for the text (e.g. color, size, style)
-       */
-       void    drawTextOnPath(const char text[], size_t byteLength, const SkPath& path, SkScalar distance, const SkPaint& paint);
-       /**     Draw the utf8-text, with origin at (x,y), using the specified paint, along the specified path.
-               The paint's Align setting determins where along the path to start the text.
-               @param text     The UTF16 text to be drawn
-               @param numberOf16BitValues      The number of 16bit values to read from the text parameter
-               @param path     The path the text should follow for its baseline
-               @param offset   The distance along the path to add to the text's starting position
-               @param paint    The paint used for the text (e.g. color, size, style)
-       */
-       void    drawText16OnPath(const uint16_t text[], size_t numberOf16BitValues, const SkPath& path, SkScalar distance, const SkPaint& paint);
+        @param paint    The paint used for the text (e.g. color, size, style)
+    */
+    void    drawPosText(const void* text, size_t byteLength, const SkPoint pos[], const SkPaint& paint);
+    /** Draw the text, with origin at (x,y), using the specified paint, along the specified path.
+        The paint's Align setting determins where along the path to start the text.
+        @param text The text to be drawn
+        @param byteLength   The number of bytes to read from the text parameter
+        @param path         The path the text should follow for its baseline
+        @param distance     The distance along the path to add to the text's starting position
+        @param paint        The paint used for the text (e.g. color, size, style)
+    */
+    void    drawTextOnPath(const void* text, size_t byteLength, const SkPath& path, SkScalar distance, const SkPaint& paint);
 
-       /**     Return the current set mask, used to temporarily modify the paint's flags
-               when something is being drawin.
+    /** Return the current set mask, used to temporarily modify the paint's flags
+        when something is being drawin.
         This method is not exported to java.
-       */
-       uint32_t        getPaintSetBits() const;
-       /**     Return the current clear mask, used to temporarily modify the paint's flags
-               when something is being drawin.
+    */
+    uint32_t    getPaintSetBits() const;
+    /** Return the current clear mask, used to temporarily modify the paint's flags
+        when something is being drawin.
         This method is not exported to java.
-       */
-       uint32_t        getPaintClearBits() const;
-       /**     Set the current set and clear masks, used to temporarily modify the paint's flags
-               when something is being drawin. The setBits are applied before the clrBits.
+    */
+    uint32_t    getPaintClearBits() const;
+    /** Set the current set and clear masks, used to temporarily modify the paint's flags
+        when something is being drawin. The setBits are applied before the clrBits.
         This method is not exported to java.
-               @param setBits  A mask of bits to be OR'd into the paint's flag bits
-               @param clrBits  A mask of bits to be cleared from the paint's flag bits
-       */
-       void    setPaintSetClearBits(uint32_t setBits, uint32_t clrBits);
-       /**     Helper for getPaintSetClearBits/setPaintSetClearBits. The parameters are OR'd into
-               the current values, rather than replacing them as with setPaintSetClearBits.
+        @param setBits  A mask of bits to be OR'd into the paint's flag bits
+        @param clrBits  A mask of bits to be cleared from the paint's flag bits
+    */
+    void    setPaintSetClearBits(uint32_t setBits, uint32_t clrBits);
+    /** Helper for getPaintSetClearBits/setPaintSetClearBits. The parameters are OR'd into
+        the current values, rather than replacing them as with setPaintSetClearBits.
         This method is not exported to java.
         @param setBits  A mask of bits to be OR'd with the existing setBits on the canvas
         @param clearBits  A mask of bits to be OR'd with the existing clearBits on the canvas
-       */
-       void    orPaintSetClearBits(uint32_t setBits, uint32_t clearBits);
+    */
+    void    orPaintSetClearBits(uint32_t setBits, uint32_t clearBits);
 
-       /**     Get the current bounder object. 
-               <p />
-         The bounder's reference count is not affected.
-               @return the canva's bounder (or NULL).
-       */
-       SkBounder*      getBounder() const { return fBounder; }
-       /**     Set a new bounder (or NULL).
-               <p />
-               Pass NULL to clear any previous bounder.
-               As a convenience, the parameter passed is also returned.
-               If a previous bounder exists, its reference count is decremented.
-               If bounder is not NULL, its reference count is incremented.
-               @param bounder the new bounder (or NULL) to be installed in the canvas
-               @return the set bounder object
-       */
-       SkBounder*      setBounder(SkBounder*);
+    /** Get the current bounder object. The bounder's reference count is not affected.
+        This method is not exported to java.
+        @return the canva's bounder (or NULL).
+    */
+    SkBounder*  getBounder() const { return fBounder; }
+    /** Set a new bounder (or NULL).
+        Pass NULL to clear any previous bounder.
+        As a convenience, the parameter passed is also returned.
+        If a previous bounder exists, its reference count is decremented.
+        If bounder is not NULL, its reference count is incremented.
+        This method is not exported to java.
+        @param bounder the new bounder (or NULL) to be installed in the canvas
+        @return the set bounder object
+    */
+    SkBounder*  setBounder(SkBounder*);
 
     /** Return a reference to the bitmap that the current layer draws into.
         This method is not exported to java.
@@ -437,33 +455,33 @@ private:
     MCRec*      fMCRec;             // points to top of stack
     uint32_t    fMCRecStorage[32];  // the first N recs that can fit here mean we won't call malloc
 
-       SkBitmap        fBitmap;
-       SkBounder*      fBounder;
+    SkBitmap    fBitmap;
+    SkBounder*  fBounder;
 
-       friend class SkDraw;
+    friend class SkDraw;
 };
 
-/**    Stack helper class to automatically call restoreToCount() on the canvas
-       when this object goes out of scope. Use this to guarantee that the canvas
-       is restored to a known state.
+/** Stack helper class to automatically call restoreToCount() on the canvas
+    when this object goes out of scope. Use this to guarantee that the canvas
+    is restored to a known state.
 */
 class SkAutoCanvasRestore {
 public:
-       SkAutoCanvasRestore(SkCanvas* canvas, bool doSave) : fCanvas(canvas)
-       {
-               SkASSERT(canvas);
-               fSaveCount = canvas->getSaveCount();
-               if (doSave)
-                       canvas->save();
-       }
-       ~SkAutoCanvasRestore()
-       {
-               fCanvas->restoreToCount(fSaveCount);
-       }
+    SkAutoCanvasRestore(SkCanvas* canvas, bool doSave) : fCanvas(canvas)
+    {
+        SkASSERT(canvas);
+        fSaveCount = canvas->getSaveCount();
+        if (doSave)
+            canvas->save();
+    }
+    ~SkAutoCanvasRestore()
+    {
+        fCanvas->restoreToCount(fSaveCount);
+    }
 
 private:
-       SkCanvas*       fCanvas;
-       int                     fSaveCount;
+    SkCanvas*   fCanvas;
+    int         fSaveCount;
 };
 
 #endif
index 6df71ea..547397c 100644 (file)
@@ -1,56 +1,73 @@
+/* include/graphics/SkColor.h
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #ifndef SkColor_DEFINED
 #define SkColor_DEFINED
 
 #include "SkScalar.h"
 
-/**    \file SkColor.h
+/** \file SkColor.h
 
-       Types and macros for colors
+    Types and macros for colors
 */
 
-/**    8-bit type for an alpha value. 0xFF is 100% opaque, 0x00 is 100% transparent.
+/** 8-bit type for an alpha value. 0xFF is 100% opaque, 0x00 is 100% transparent.
 */
-typedef uint8_t        SkAlpha;
+typedef uint8_t SkAlpha;
 /** 32 bit ARGB color value, not premultiplied. The color components are always in
-       a known order. This is different from SkPMColor, which has its bytes in a configuration
-       dependent order, to match the format of kARGB32 bitmaps. SkColor is the type used to
-       specify colors in SkPaint and in gradients.
+    a known order. This is different from SkPMColor, which has its bytes in a configuration
+    dependent order, to match the format of kARGB32 bitmaps. SkColor is the type used to
+    specify colors in SkPaint and in gradients.
 */
 typedef uint32_t SkColor;
 
-/**    Return a SkColor value from 8 bit component values
+/** Return a SkColor value from 8 bit component values
 */
 static inline SkColor SkColorSetARGB(U8CPU a, U8CPU r, U8CPU g, U8CPU b)
 {
-       SkASSERT(a <= 255 && r <= 255 && g <= 255 && b <= 255);
+    SkASSERT(a <= 255 && r <= 255 && g <= 255 && b <= 255);
 
-       return (a << 24) | (r << 16) | (g << 8) | (b << 0);
+    return (a << 24) | (r << 16) | (g << 8) | (b << 0);
 }
 
-/**    Return a SkColor value from 8 bit component values, with an implied value
-       of 0xFF for alpha (fully opaque)
+/** Return a SkColor value from 8 bit component values, with an implied value
+    of 0xFF for alpha (fully opaque)
 */
-#define SkColorSetRGB(r, g, b) SkColorSetARGB(0xFF, r, g, b)
+#define SkColorSetRGB(r, g, b)  SkColorSetARGB(0xFF, r, g, b)
 
-#define SkColorGetA(color)             ((color) >> 24)                 //!< return the alpha byte from a SkColor value
-#define SkColorGetR(color)             ((color) << 8 >> 24)    //!< return the red byte from a SkColor value
-#define SkColorGetG(color)             ((color) << 16 >> 24)   //!< return the green byte from a SkColor value
-#define SkColorGetB(color)             ((color) << 24 >> 24)   //!< return the blue byte from a SkColor value
+#define SkColorGetA(color)      ((color) >> 24)         //!< return the alpha byte from a SkColor value
+#define SkColorGetR(color)      ((color) << 8 >> 24)    //!< return the red byte from a SkColor value
+#define SkColorGetG(color)      ((color) << 16 >> 24)   //!< return the green byte from a SkColor value
+#define SkColorGetB(color)      ((color) << 24 >> 24)   //!< return the blue byte from a SkColor value
 
 // common colors
 
-#define SK_ColorBLACK  0xFF000000      //!< black SkColor value
-#define SK_ColorDKGRAY 0xFF444444      //!< dark gray SkColor value
-#define SK_ColorGRAY   0xFF888888      //!< gray SkColor value
-#define SK_ColorLTGRAY 0xFFCCCCCC      //!< light gray SkColor value
-#define SK_ColorWHITE  0xFFFFFFFF      //!< white SkColor value
+#define SK_ColorBLACK   0xFF000000  //!< black SkColor value
+#define SK_ColorDKGRAY  0xFF444444  //!< dark gray SkColor value
+#define SK_ColorGRAY    0xFF888888  //!< gray SkColor value
+#define SK_ColorLTGRAY  0xFFCCCCCC  //!< light gray SkColor value
+#define SK_ColorWHITE   0xFFFFFFFF  //!< white SkColor value
 
-#define SK_ColorRED            0xFFFF0000      //!< red SkColor value
-#define SK_ColorGREEN  0xFF00FF00      //!< green SkColor value
-#define SK_ColorBLUE   0xFF0000FF      //!< blue SkColor value
-#define SK_ColorYELLOW 0xFFFFFF00      //!< yellow SkColor value
-#define SK_ColorCYAN   0xFF00FFFF      //!< cyan SkColor value
-#define SK_ColorMAGENTA        0xFFFF00FF      //!< magenta SkColor value
+#define SK_ColorRED     0xFFFF0000  //!< red SkColor value
+#define SK_ColorGREEN   0xFF00FF00  //!< green SkColor value
+#define SK_ColorBLUE    0xFF0000FF  //!< blue SkColor value
+#define SK_ColorYELLOW  0xFFFFFF00  //!< yellow SkColor value
+#define SK_ColorCYAN    0xFF00FFFF  //!< cyan SkColor value
+#define SK_ColorMAGENTA 0xFFFF00FF  //!< magenta SkColor value
 
 ////////////////////////////////////////////////////////////////////////
 
@@ -104,17 +121,17 @@ static inline SkColor SkHSVToColor(const SkScalar hsv[3])
 ////////////////////////////////////////////////////////////////////////
 
 /** 32 bit ARGB color value, premultiplied. The byte order for this value is
-       configuration dependent, matching the format of kARGB32 bitmaps. This is different
-       from SkColor, which is nonpremultiplied, and is always in the same byte order.
+    configuration dependent, matching the format of kARGB32 bitmaps. This is different
+    from SkColor, which is nonpremultiplied, and is always in the same byte order.
 */
 typedef uint32_t SkPMColor;
 
-/**    Return a SkPMColor value from unpremultiplied 8 bit component values
+/** Return a SkPMColor value from unpremultiplied 8 bit component values
 */
 SkPMColor SkPreMultiplyARGB(U8CPU a, U8CPU r, U8CPU g, U8CPU b);
-/**    Return a SkPMColor value from a SkColor value. This is done by multiplying the color
-       components by the color's alpha, and by arranging the bytes in a configuration
-       dependent order, to match the format of kARGB32 bitmaps.
+/** Return a SkPMColor value from a SkColor value. This is done by multiplying the color
+    components by the color's alpha, and by arranging the bytes in a configuration
+    dependent order, to match the format of kARGB32 bitmaps.
 */
 SkPMColor SkPreMultiplyColor(SkColor c);
 
index 91879ae..285d069 100644 (file)
@@ -1,3 +1,20 @@
+/* include/graphics/SkColorFilter.h
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #ifndef SkColorFilter_DEFINED
 #define SkColorFilter_DEFINED
 
@@ -9,9 +26,10 @@ class SkColorFilter : public SkRefCnt {
 public:
     /** Called with a scanline of colors, as if there was a shader installed.
         The implementation writes out its filtered version into result[].
+        Note: shader and result may be the same buffer.
         @param shader   array of colors, possibly generated by a shader
         @param count    the number of entries in the shader[] and result[] arrays
-        @param result   written by the filter, these are the colors that are used to draw
+        @param result   written by the filter, these are the colors that will used to draw
     */
     virtual void filterSpan(const SkPMColor shader[], int count, SkPMColor result[]);
     
index 65b5851..7561a95 100644 (file)
@@ -1,3 +1,20 @@
+/* include/graphics/SkColorPriv.h
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #ifndef SkColorPriv_DEFINED
 #define SkColorPriv_DEFINED
 
 
 inline unsigned SkAlpha255To256(U8CPU alpha)
 {
-       SkASSERT(SkToU8(alpha) == alpha);
-       return alpha + (alpha >> 7);
+    SkASSERT(SkToU8(alpha) == alpha);
+    return alpha + (alpha >> 7);
 }
 
-#define SkAlphaMul(value, alpha256)            ((value) * (alpha256) >> 8)
+#define SkAlphaMul(value, alpha256)     ((value) * (alpha256) >> 8)
 
-//     The caller may want negative values, so keep all params signed (int)
-//     so we don't accidentally slip into unsigned math and lose the sign
-//     extension when we shift (in SkAlphaMul)
+//  The caller may want negative values, so keep all params signed (int)
+//  so we don't accidentally slip into unsigned math and lose the sign
+//  extension when we shift (in SkAlphaMul)
 inline int SkAlphaBlend(int src, int dst, int scale256)
 {
-       SkASSERT((unsigned)scale256 <= 256);
-       return dst + SkAlphaMul(src - dst, scale256);
+    SkASSERT((unsigned)scale256 <= 256);
+    return dst + SkAlphaMul(src - dst, scale256);
 }
 
-#define SK_R16_BITS            5
-#define SK_G16_BITS            6
-#define SK_B16_BITS            5
+#define SK_R16_BITS     5
+#define SK_G16_BITS     6
+#define SK_B16_BITS     5
 
-#define SK_R16_SHIFT   (SK_B16_BITS + SK_G16_BITS)
-#define SK_G16_SHIFT   (SK_B16_BITS)
-#define SK_B16_SHIFT   0
+#define SK_R16_SHIFT    (SK_B16_BITS + SK_G16_BITS)
+#define SK_G16_SHIFT    (SK_B16_BITS)
+#define SK_B16_SHIFT    0
 
-#define SK_R16_MASK            ((1 << SK_R16_BITS) - 1)
-#define SK_G16_MASK            ((1 << SK_G16_BITS) - 1)
-#define SK_B16_MASK            ((1 << SK_B16_BITS) - 1)
+#define SK_R16_MASK     ((1 << SK_R16_BITS) - 1)
+#define SK_G16_MASK     ((1 << SK_G16_BITS) - 1)
+#define SK_B16_MASK     ((1 << SK_B16_BITS) - 1)
 
-#define SkGetPackedR16(color)  (((unsigned)(color) >> SK_R16_SHIFT) & SK_R16_MASK)
-#define SkGetPackedG16(color)  (((unsigned)(color) >> SK_G16_SHIFT) & SK_G16_MASK)
-#define SkGetPackedB16(color)  (((unsigned)(color) >> SK_B16_SHIFT) & SK_B16_MASK)
+#define SkGetPackedR16(color)   (((unsigned)(color) >> SK_R16_SHIFT) & SK_R16_MASK)
+#define SkGetPackedG16(color)   (((unsigned)(color) >> SK_G16_SHIFT) & SK_G16_MASK)
+#define SkGetPackedB16(color)   (((unsigned)(color) >> SK_B16_SHIFT) & SK_B16_MASK)
 
 inline uint16_t SkPackRGB16(unsigned r, unsigned g, unsigned b)
 {
-       SkASSERT(r <= SK_R16_MASK);
-       SkASSERT(g <= SK_G16_MASK);
-       SkASSERT(b <= SK_B16_MASK);
+    SkASSERT(r <= SK_R16_MASK);
+    SkASSERT(g <= SK_G16_MASK);
+    SkASSERT(b <= SK_B16_MASK);
 
-       return SkToU16((r << SK_R16_SHIFT) | (g << SK_G16_SHIFT) | (b << SK_B16_SHIFT));
+    return SkToU16((r << SK_R16_SHIFT) | (g << SK_G16_SHIFT) | (b << SK_B16_SHIFT));
 }
 
-inline int SkShouldDitherXY(int x, int y)
-{
-    return (x ^ y) & 1;
-}
+#define SK_R16_MASK_IN_PLACE        (SK_R16_MASK << SK_R16_SHIFT)
+#define SK_G16_MASK_IN_PLACE        (SK_G16_MASK << SK_G16_SHIFT)
+#define SK_B16_MASK_IN_PLACE        (SK_B16_MASK << SK_B16_SHIFT)
 
-inline uint16_t SkDitherPack888ToRGB16(U8CPU r, U8CPU g, U8CPU b)
+#define SK_R16B16_MASK_IN_PLACE     (SK_R16_MASK_IN_PLACE | SK_B16_MASK_IN_PLACE)
+
+/** Expand the 16bit color into a 32bit value that can be scaled all at once
+    by a value up to 32. Used in conjunction with SkCompact_rgb_16.
+*/
+inline uint32_t SkExpand_rgb_16(U16CPU c)
 {
-    r = ((r << 1) - ((r >> (8 - SK_R16_BITS) << (8 - SK_R16_BITS)) | (r >> SK_R16_BITS))) >> (8 - SK_R16_BITS);
-    g = ((g << 1) - ((g >> (8 - SK_G16_BITS) << (8 - SK_G16_BITS)) | (g >> SK_G16_BITS))) >> (8 - SK_G16_BITS);
-    b = ((b << 1) - ((b >> (8 - SK_B16_BITS) << (8 - SK_B16_BITS)) | (b >> SK_B16_BITS))) >> (8 - SK_B16_BITS);
+    SkASSERT(c == (uint16_t)c);
 
-   return SkPackRGB16(r, g, b);
+    return ((c & SK_G16_MASK_IN_PLACE) << 16) | (c & ~SK_G16_MASK_IN_PLACE);
 }
 
-#define SK_R16_MASK_IN_PLACE           (SK_R16_MASK << SK_R16_SHIFT)
-#define SK_G16_MASK_IN_PLACE           (SK_G16_MASK << SK_G16_SHIFT)
-#define SK_B16_MASK_IN_PLACE           (SK_B16_MASK << SK_B16_SHIFT)
-
-#define SK_R16B16_MASK_IN_PLACE                (SK_R16_MASK_IN_PLACE | SK_B16_MASK_IN_PLACE)
+/** Compress an expanded value (from SkExpand_rgb_16) back down to a 16bit
+    color value.
+*/
+static inline U16CPU SkCompact_rgb_16(uint32_t c)
+{
+    return ((c >> 16) & SK_G16_MASK_IN_PLACE) | (c & ~SK_G16_MASK_IN_PLACE);
+}
 
 inline U16CPU SkAlphaMulRGB16(U16CPU c, unsigned scale)
 {
 #if SK_G16_MASK_IN_PLACE != 0x07E0
-       return SkPackRGB16(     SkAlphaMul(SkGetPackedR16(c), scale),
-                                               SkAlphaMul(SkGetPackedG16(c), scale),
-                                               SkAlphaMul(SkGetPackedB16(c), scale));
+    return SkPackRGB16( SkAlphaMul(SkGetPackedR16(c), scale),
+                        SkAlphaMul(SkGetPackedG16(c), scale),
+                        SkAlphaMul(SkGetPackedB16(c), scale));
 #else
-       scale >>= (8 - SK_G16_BITS);
-       uint32_t rb = (c & SK_R16B16_MASK_IN_PLACE) * scale >> SK_G16_BITS;
-       uint32_t  g = (c & SK_G16_MASK_IN_PLACE) * scale >> SK_G16_BITS;
-       return (g & SK_G16_MASK_IN_PLACE) | (rb & SK_R16B16_MASK_IN_PLACE);
+    scale >>= (8 - SK_G16_BITS);
+    uint32_t rb = (c & SK_R16B16_MASK_IN_PLACE) * scale >> SK_G16_BITS;
+    uint32_t  g = (c & SK_G16_MASK_IN_PLACE) * scale >> SK_G16_BITS;
+    return (g & SK_G16_MASK_IN_PLACE) | (rb & SK_R16B16_MASK_IN_PLACE);
 #endif
 }
 
-inline U16CPU SkBlendRGB16(U16CPU src, U16CPU dst, unsigned scale)
+inline U16CPU SkBlendRGB16(U16CPU src, U16CPU dst, int srcScale)
 {
-       SkASSERT(scale <= 256);
-
-       return SkPackRGB16(     SkAlphaBlend(SkGetPackedR16(src), SkGetPackedR16(dst), scale),
-                                               SkAlphaBlend(SkGetPackedG16(src), SkGetPackedG16(dst), scale),
-                                               SkAlphaBlend(SkGetPackedB16(src), SkGetPackedB16(dst), scale));
-}
-
-/////////////////////////////////////////////////////////////////////////////////////////////
+    SkASSERT((unsigned)srcScale <= 256);
 
-#define SK_A32_BITS            8
-#define SK_R32_BITS            8
-#define SK_G32_BITS            8
-#define SK_B32_BITS            8
+    srcScale >>= 3;
 
-#ifdef TEST_INTEL_MAC
+    uint32_t es = SkExpand_rgb_16(src) * srcScale;
+    uint32_t ed = SkExpand_rgb_16(dst) * (32 - srcScale);
+    return SkCompact_rgb_16((es + ed) >> 5);
+}
 
-#define SK_A32_SHIFT   0
-#define SK_R32_SHIFT   8
-#define SK_G32_SHIFT   16
-#define SK_B32_SHIFT   24
+inline void SkBlendRGB16(const uint16_t src[], uint16_t dst[], int srcScale, int count)
+{
+    SkASSERT(count > 0);
+    SkASSERT((unsigned)srcScale <= 256);
+    srcScale >>= 3;
+    int dstScale = 32 - srcScale;
+
+    do {
+        uint32_t es = SkExpand_rgb_16(*src++) * srcScale;
+        uint32_t ed = SkExpand_rgb_16(*dst) * dstScale;
+        *dst++ = SkCompact_rgb_16((es + ed) >> 5);
+    } while (--count > 0);
+}
 
-#else
+/////////////////////////////////////////////////////////////////////////////////////////////
 
-#define SK_A32_SHIFT   24
-#define SK_R32_SHIFT   16
-#define SK_G32_SHIFT   8
-#define SK_B32_SHIFT   0
+#define SK_A32_BITS     8
+#define SK_R32_BITS     8
+#define SK_G32_BITS     8
+#define SK_B32_BITS     8
 
-#endif
+#define SK_A32_SHIFT    24
+#define SK_R32_SHIFT    16
+#define SK_G32_SHIFT    8
+#define SK_B32_SHIFT    0
 
-#define SK_A32_MASK            ((1 << SK_A32_BITS) - 1)
-#define SK_R32_MASK            ((1 << SK_R32_BITS) - 1)
-#define SK_G32_MASK            ((1 << SK_G32_BITS) - 1)
-#define SK_B32_MASK            ((1 << SK_B32_BITS) - 1)
+#define SK_A32_MASK     ((1 << SK_A32_BITS) - 1)
+#define SK_R32_MASK     ((1 << SK_R32_BITS) - 1)
+#define SK_G32_MASK     ((1 << SK_G32_BITS) - 1)
+#define SK_B32_MASK     ((1 << SK_B32_BITS) - 1)
 
-#define SkGetPackedA32(packed)         ((uint32_t)((packed) << (24 - SK_A32_SHIFT)) >> 24)
-#define SkGetPackedR32(packed)         ((uint32_t)((packed) << (24 - SK_R32_SHIFT)) >> 24)
-#define SkGetPackedG32(packed)         ((uint32_t)((packed) << (24 - SK_G32_SHIFT)) >> 24)
-#define SkGetPackedB32(packed)         ((uint32_t)((packed) << (24 - SK_B32_SHIFT)) >> 24)
+#define SkGetPackedA32(packed)      ((uint32_t)((packed) << (24 - SK_A32_SHIFT)) >> 24)
+#define SkGetPackedR32(packed)      ((uint32_t)((packed) << (24 - SK_R32_SHIFT)) >> 24)
+#define SkGetPackedG32(packed)      ((uint32_t)((packed) << (24 - SK_G32_SHIFT)) >> 24)
+#define SkGetPackedB32(packed)      ((uint32_t)((packed) << (24 - SK_B32_SHIFT)) >> 24)
 
 inline SkPMColor SkPackARGB32(U8CPU a, U8CPU r, U8CPU g, U8CPU b)
 {
-       SkASSERT(a <= SK_A32_MASK);
-       SkASSERT(r <= a);
-       SkASSERT(g <= a);
-       SkASSERT(b <= a);
+    SkASSERT(a <= SK_A32_MASK);
+    SkASSERT(r <= a);
+    SkASSERT(g <= a);
+    SkASSERT(b <= a);
 
-       return (a << SK_A32_SHIFT) | (r << SK_R32_SHIFT) | (g << SK_G32_SHIFT) | (b << SK_B32_SHIFT);
+    return (a << SK_A32_SHIFT) | (r << SK_R32_SHIFT) | (g << SK_G32_SHIFT) | (b << SK_B32_SHIFT);
 }
 
 inline uint32_t SkAlphaMulQ(uint32_t c, unsigned scale)
 {
-       uint32_t rb = ((c & 0xFF00FF) * scale) >> 8;
-       uint32_t ag = ((c >> 8) & 0xFF00FF) * scale;
-       return (rb & 0xFF00FF) | (ag & ~0xFF00FF);
+    uint32_t rb = ((c & 0xFF00FF) * scale) >> 8;
+    uint32_t ag = ((c >> 8) & 0xFF00FF) * scale;
+    return (rb & 0xFF00FF) | (ag & ~0xFF00FF);
 }
 
 inline SkPMColor SkPMSrcOver(SkPMColor src, SkPMColor dst)
 {
-       return src + SkAlphaMulQ(dst, SkAlpha255To256(255 - SkGetPackedA32(src)));
+    return src + SkAlphaMulQ(dst, SkAlpha255To256(255 - SkGetPackedA32(src)));
 }
 
 inline SkPMColor SkBlendARGB32(SkPMColor src, SkPMColor dst, U8CPU aa)
 {
-       SkASSERT((unsigned)aa <= 255);
+    SkASSERT((unsigned)aa <= 255);
 
-       unsigned src_scale = SkAlpha255To256(aa);
-       unsigned dst_scale = SkAlpha255To256(255 - SkAlphaMul(SkGetPackedA32(src), src_scale));
+    unsigned src_scale = SkAlpha255To256(aa);
+    unsigned dst_scale = SkAlpha255To256(255 - SkAlphaMul(SkGetPackedA32(src), src_scale));
 
-       return SkAlphaMulQ(src, src_scale) + SkAlphaMulQ(dst, dst_scale);
+    return SkAlphaMulQ(src, src_scale) + SkAlphaMulQ(dst, dst_scale);
 }
 
 ////////////////////////////////////////////////////////////////////////////////////////////
 // Convert a 32bit pixel to a 16bit pixel (no dither)
 
-#define SkR32ToR16(r)  ((unsigned)(r) >> (SK_R32_BITS - SK_R16_BITS))
-#define SkG32ToG16(g)  ((unsigned)(g) >> (SK_G32_BITS - SK_G16_BITS))
-#define SkB32ToB16(b)  ((unsigned)(b) >> (SK_B32_BITS - SK_B16_BITS))
+#define SkR32ToR16(r)   ((unsigned)(r) >> (SK_R32_BITS - SK_R16_BITS))
+#define SkG32ToG16(g)   ((unsigned)(g) >> (SK_G32_BITS - SK_G16_BITS))
+#define SkB32ToB16(b)   ((unsigned)(b) >> (SK_B32_BITS - SK_B16_BITS))
 
-#define SkPacked32ToR16(c)     (((unsigned)(c) >> (SK_R32_SHIFT + SK_R32_BITS - SK_R16_BITS)) & SK_R16_MASK)
-#define SkPacked32ToG16(c)     (((unsigned)(c) >> (SK_G32_SHIFT + SK_G32_BITS - SK_G16_BITS)) & SK_G16_MASK)
-#define SkPacked32ToB16(c)     (((unsigned)(c) >> (SK_B32_SHIFT + SK_B32_BITS - SK_B16_BITS)) & SK_B16_MASK)
+#define SkPacked32ToR16(c)  (((unsigned)(c) >> (SK_R32_SHIFT + SK_R32_BITS - SK_R16_BITS)) & SK_R16_MASK)
+#define SkPacked32ToG16(c)  (((unsigned)(c) >> (SK_G32_SHIFT + SK_G32_BITS - SK_G16_BITS)) & SK_G16_MASK)
+#define SkPacked32ToB16(c)  (((unsigned)(c) >> (SK_B32_SHIFT + SK_B32_BITS - SK_B16_BITS)) & SK_B16_MASK)
 
 inline U16CPU SkPixel32ToPixel16(SkPMColor src)
 {
 #if 0
-       return  (SkPacked32ToR16(src) << SK_R16_SHIFT) |
-                       (SkPacked32ToG16(src) << SK_G16_SHIFT) |
-                       (SkPacked32ToB16(src) << SK_B16_SHIFT);
-#else  // only works if the components are in the same order in both formats (i.e. foo32_shift >= foo16_shift)
-       return  ((src >> (SK_R32_SHIFT + SK_R32_BITS - SK_R16_BITS - SK_R16_SHIFT)) & (SK_R16_MASK << SK_R16_SHIFT)) |
-                       ((src >> (SK_G32_SHIFT + SK_G32_BITS - SK_G16_BITS - SK_G16_SHIFT)) & (SK_G16_MASK << SK_G16_SHIFT)) |
-                       ((src >> (SK_B32_SHIFT + SK_B32_BITS - SK_B16_BITS - SK_B16_SHIFT)) & (SK_B16_MASK << SK_B16_SHIFT));
+    return  (SkPacked32ToR16(src) << SK_R16_SHIFT) |
+            (SkPacked32ToG16(src) << SK_G16_SHIFT) |
+            (SkPacked32ToB16(src) << SK_B16_SHIFT);
+#else   // only works if the components are in the same order in both formats (i.e. foo32_shift >= foo16_shift)
+    return  ((src >> (SK_R32_SHIFT + SK_R32_BITS - SK_R16_BITS - SK_R16_SHIFT)) & (SK_R16_MASK << SK_R16_SHIFT)) |
+            ((src >> (SK_G32_SHIFT + SK_G32_BITS - SK_G16_BITS - SK_G16_SHIFT)) & (SK_G16_MASK << SK_G16_SHIFT)) |
+            ((src >> (SK_B32_SHIFT + SK_B32_BITS - SK_B16_BITS - SK_B16_SHIFT)) & (SK_B16_MASK << SK_B16_SHIFT));
 #endif
 }
 
-#define SkPixel32ToPixel16_ToU16(src)  SkToU16(SkPixel32ToPixel16(src))
+inline U16CPU SkPack888ToRGB16(U8CPU r, U8CPU g, U8CPU b)
+{
+    return  (SkR32ToR16(r) << SK_R16_SHIFT) |
+            (SkG32ToG16(g) << SK_G16_SHIFT) |
+            (SkB32ToB16(b) << SK_B16_SHIFT);
+}
+
+#define SkPixel32ToPixel16_ToU16(src)   SkToU16(SkPixel32ToPixel16(src))
+
+/////////////////////////////////////////////////////////////////////////////////////////
+// Fast dither from 32->16
+
+#define SkShouldDitherXY(x, y)  (((x) ^ (y)) & 1)
+
+inline uint16_t SkDitherPack888ToRGB16(U8CPU r, U8CPU g, U8CPU b)
+{
+    r = ((r << 1) - ((r >> (8 - SK_R16_BITS) << (8 - SK_R16_BITS)) | (r >> SK_R16_BITS))) >> (8 - SK_R16_BITS);
+    g = ((g << 1) - ((g >> (8 - SK_G16_BITS) << (8 - SK_G16_BITS)) | (g >> SK_G16_BITS))) >> (8 - SK_G16_BITS);
+    b = ((b << 1) - ((b >> (8 - SK_B16_BITS) << (8 - SK_B16_BITS)) | (b >> SK_B16_BITS))) >> (8 - SK_B16_BITS);
+
+   return SkPackRGB16(r, g, b);
+}
+
+inline uint16_t SkDitherPixel32ToPixel16(SkPMColor c)
+{
+    return SkDitherPack888ToRGB16(SkGetPackedR32(c), SkGetPackedG32(c), SkGetPackedB32(c));
+}
 
 ////////////////////////////////////////////////////////////////////////////////////////////
 // Convert a 16bit pixel to a 32bit pixel
 
 inline unsigned SkR16ToR32(unsigned r)
 {
-       return (r << (8 - SK_R16_BITS)) | (r >> (2 * SK_R16_BITS - 8));
+    return (r << (8 - SK_R16_BITS)) | (r >> (2 * SK_R16_BITS - 8));
 }
 inline unsigned SkG16ToG32(unsigned g)
 {
-       return (g << (8 - SK_G16_BITS)) | (g >> (2 * SK_G16_BITS - 8));
+    return (g << (8 - SK_G16_BITS)) | (g >> (2 * SK_G16_BITS - 8));
 }
 inline unsigned SkB16ToB32(unsigned b)
 {
-       return (b << (8 - SK_B16_BITS)) | (b >> (2 * SK_B16_BITS - 8));
+    return (b << (8 - SK_B16_BITS)) | (b >> (2 * SK_B16_BITS - 8));
 }
 
-#define SkPacked16ToR32(c)             SkR16ToR32(SkGetPackedR16(c))
-#define SkPacked16ToG32(c)             SkG16ToG32(SkGetPackedG16(c))
-#define SkPacked16ToB32(c)             SkB16ToB32(SkGetPackedB16(c))
+#define SkPacked16ToR32(c)      SkR16ToR32(SkGetPackedR16(c))
+#define SkPacked16ToG32(c)      SkG16ToG32(SkGetPackedG16(c))
+#define SkPacked16ToB32(c)      SkB16ToB32(SkGetPackedB16(c))
 
 inline SkPMColor SkPixel16ToPixel32(U16CPU src)
 {
-       SkASSERT(src == SkToU16(src));
+    SkASSERT(src == SkToU16(src));
 
-       unsigned        r = SkPacked16ToR32(src);
-       unsigned        g = SkPacked16ToG32(src);
-       unsigned        b = SkPacked16ToB32(src);
+    unsigned    r = SkPacked16ToR32(src);
+    unsigned    g = SkPacked16ToG32(src);
+    unsigned    b = SkPacked16ToB32(src);
 
-       SkASSERT((r >> (8 - SK_R16_BITS)) == SkGetPackedR16(src));
-       SkASSERT((g >> (8 - SK_G16_BITS)) == SkGetPackedG16(src));
-       SkASSERT((b >> (8 - SK_B16_BITS)) == SkGetPackedB16(src));
+    SkASSERT((r >> (8 - SK_R16_BITS)) == SkGetPackedR16(src));
+    SkASSERT((g >> (8 - SK_G16_BITS)) == SkGetPackedG16(src));
+    SkASSERT((b >> (8 - SK_B16_BITS)) == SkGetPackedB16(src));
 
-       return SkPackARGB32(0xFF, r, g, b);
+    return SkPackARGB32(0xFF, r, g, b);
 }
 
 #endif
index 4307c70..944a100 100644 (file)
@@ -1,38 +1,55 @@
+/* include/graphics/SkCornerPathEffect.h
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #ifndef SkCornerPathEffect_DEFINED
 #define SkCornerPathEffect_DEFINED
 
 #include "SkPathEffect.h"
 
-/**    \class SkCornerPathEffect
+/** \class SkCornerPathEffect
 
-       SkCornerPathEffect is a subclass of SkPathEffect that can turn sharp corners
+    SkCornerPathEffect is a subclass of SkPathEffect that can turn sharp corners
     into various treatments (e.g. rounded corners)
 */
 class SkCornerPathEffect : public SkPathEffect {
 public:
-       /**     radius must be > 0 to have an effect. It specifies the distance from each corner
+    /** radius must be > 0 to have an effect. It specifies the distance from each corner
         that should be "rounded".
-       */
-       SkCornerPathEffect(SkScalar radius);
-       virtual ~SkCornerPathEffect();
+    */
+    SkCornerPathEffect(SkScalar radius);
+    virtual ~SkCornerPathEffect();
 
-       // overrides for SkPathEffect
+    // overrides for SkPathEffect
     //  This method is not exported to java.
-       virtual bool filterPath(SkPath* dst, const SkPath& src, SkScalar* width);
+    virtual bool filterPath(SkPath* dst, const SkPath& src, SkScalar* width);
 
-       // overrides for SkFlattenable
+    // overrides for SkFlattenable
     //  This method is not exported to java.
-       virtual Factory getFactory();
+    virtual Factory getFactory();
     //  This method is not exported to java.
-       virtual void flatten(SkWBuffer&);
+    virtual void flatten(SkWBuffer&);
 
 protected:
-       SkCornerPathEffect(SkRBuffer&);
+    SkCornerPathEffect(SkRBuffer&);
 
 private:
     SkScalar    fRadius;
 
-       static SkFlattenable* CreateProc(SkRBuffer&);
+    static SkFlattenable* CreateProc(SkRBuffer&);
     
     // illegal
     SkCornerPathEffect(const SkCornerPathEffect&);
index def938d..900f9c2 100644 (file)
@@ -1,3 +1,20 @@
+/* include/graphics/SkCullPoints.h
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #ifndef SkCullPoints_DEFINED
 #define SkCullPoints_DEFINED
 
@@ -24,9 +41,10 @@ public:
     LineToResult lineTo(int x, int y, SkPoint16 pts[2]);
 
 private:
-    SkRect16    fR;
-    SkPoint16   fAsQuad[4];
-    SkPoint32   fPrevPt;    // local state
+    SkRect16    fR;             // the caller's rectangle
+    SkPoint16   fAsQuad[4];     // cache of fR as 4 points
+    SkPoint32   fPrevPt;        // private state
+    LineToResult fPrevResult;   // private state
     
     bool sect_test(int x0, int y0, int x1, int y1) const;
 };
index 6567a89..02da0e7 100644 (file)
@@ -1,3 +1,20 @@
+/* include/graphics/SkDOM.h
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #ifndef SkDOM_DEFINED
 #define SkDOM_DEFINED
 
@@ -10,73 +27,73 @@ struct SkDOMAttr;
 
 class SkDOM {
 public:
-       SkDOM();
-       ~SkDOM();
+    SkDOM();
+    ~SkDOM();
 
-       typedef SkDOMNode Node;
+    typedef SkDOMNode Node;
     typedef SkDOMAttr Attr;
 
-       /** Returns nil on failure
-       */
-       const Node* build(const char doc[], size_t len);
-       const Node* copy(const SkDOM& dom, const Node* node);
+    /** Returns nil on failure
+    */
+    const Node* build(const char doc[], size_t len);
+    const Node* copy(const SkDOM& dom, const Node* node);
 
-       const Node*     getRootNode() const;
+    const Node* getRootNode() const;
 
-       enum Type {
-               kElement_Type,
-               kText_Type
-       };
-       Type    getType(const Node*) const;
+    enum Type {
+        kElement_Type,
+        kText_Type
+    };
+    Type    getType(const Node*) const;
 
-       const char*     getName(const Node*) const;
-       const Node*     getFirstChild(const Node*, const char elem[] = nil) const;
-       const Node*     getNextSibling(const Node*, const char elem[] = nil) const;
+    const char* getName(const Node*) const;
+    const Node* getFirstChild(const Node*, const char elem[] = nil) const;
+    const Node* getNextSibling(const Node*, const char elem[] = nil) const;
 
-       const char* findAttr(const Node*, const char attrName[]) const;
+    const char* findAttr(const Node*, const char attrName[]) const;
     const Attr* getFirstAttr(const Node*) const;
     const Attr* getNextAttr(const Node*, const Attr*) const;
     const char* getAttrName(const Node*, const Attr*) const;
     const char* getAttrValue(const Node*, const Attr*) const;
-       
-       // helpers for walking children
-       int countChildren(const Node* node, const char elem[] = nil) const;
-
-       // helpers for calling SkParse
-       bool findS32(const Node*, const char name[], int32_t* value) const;
-       bool findScalars(const Node*, const char name[], SkScalar value[], int count) const;
-       bool findHex(const Node*, const char name[], uint32_t* value) const;
-       bool findBool(const Node*, const char name[], bool*) const;
-       int  findList(const Node*, const char name[], const char list[]) const;
-
-       bool findScalar(const Node* node, const char name[], SkScalar value[]) const
-       {
-               return this->findScalars(node, name, value, 1);
-       }
-
-       bool hasAttr(const Node*, const char name[], const char value[]) const;
-       bool hasS32(const Node*, const char name[], int32_t value) const;
-       bool hasScalar(const Node*, const char name[], SkScalar value) const;
-       bool hasHex(const Node*, const char name[], uint32_t value) const;
-       bool hasBool(const Node*, const char name[], bool value) const;
-
-       class AttrIter {
-       public:
-               AttrIter(const class SkDOM&, const Node*);
-               const char* next(const char** value);
-       private:
-               const Attr*     fAttr;
-               const Attr*     fStop;
-       };
-
-       SkDEBUGCODE(void dump(const Node* node = nil, int tabLevel = 0) const;)
-       SkDEBUGCODE(static void UnitTest();)
+    
+    // helpers for walking children
+    int countChildren(const Node* node, const char elem[] = nil) const;
+
+    // helpers for calling SkParse
+    bool findS32(const Node*, const char name[], int32_t* value) const;
+    bool findScalars(const Node*, const char name[], SkScalar value[], int count) const;
+    bool findHex(const Node*, const char name[], uint32_t* value) const;
+    bool findBool(const Node*, const char name[], bool*) const;
+    int  findList(const Node*, const char name[], const char list[]) const;
+
+    bool findScalar(const Node* node, const char name[], SkScalar value[]) const
+    {
+        return this->findScalars(node, name, value, 1);
+    }
+
+    bool hasAttr(const Node*, const char name[], const char value[]) const;
+    bool hasS32(const Node*, const char name[], int32_t value) const;
+    bool hasScalar(const Node*, const char name[], SkScalar value) const;
+    bool hasHex(const Node*, const char name[], uint32_t value) const;
+    bool hasBool(const Node*, const char name[], bool value) const;
+
+    class AttrIter {
+    public:
+        AttrIter(const class SkDOM&, const Node*);
+        const char* next(const char** value);
+    private:
+        const Attr* fAttr;
+        const Attr* fStop;
+    };
+
+    SkDEBUGCODE(void dump(const Node* node = nil, int tabLevel = 0) const;)
+    SkDEBUGCODE(static void UnitTest();)
 
 private:
-       SkChunkAlloc    fAlloc;
-       Node*                   fRoot;
-       friend class AttrIter;
-       friend class SkDOMParser;
+    SkChunkAlloc    fAlloc;
+    Node*           fRoot;
+    friend class AttrIter;
+    friend class SkDOMParser;
 };
 
 #endif
index 0e567ef..7ba1d39 100644 (file)
@@ -1,46 +1,63 @@
+/* include/graphics/SkDashPathEffect.h
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #ifndef SkDashPathEffect_DEFINED
 #define SkDashPathEffect_DEFINED
 
 #include "SkPathEffect.h"
 
-/**    \class SkDashPathEffect
+/** \class SkDashPathEffect
 
-       SkDashPathEffect is a subclass of SkPathEffect that implements dashing
+    SkDashPathEffect is a subclass of SkPathEffect that implements dashing
 */
 class SkDashPathEffect : public SkPathEffect {
 public:
-       /**     The intervals array must contain an even number of entries (>=2), with the even
-               indices specifying the "on" intervals, and the odd indices specifying the "off"
-               intervals. phase is an offset into the intervals array (mod the sum of all of the
-               intervals).
-               Note: only affects framed paths
-       */
-       SkDashPathEffect(const SkScalar intervals[], int count, SkScalar phase, bool scaleToFit = false);
-       virtual ~SkDashPathEffect();
-
-       // overrides for SkPathEffect
+    /** The intervals array must contain an even number of entries (>=2), with the even
+        indices specifying the "on" intervals, and the odd indices specifying the "off"
+        intervals. phase is an offset into the intervals array (mod the sum of all of the
+        intervals).
+        Note: only affects framed paths
+    */
+    SkDashPathEffect(const SkScalar intervals[], int count, SkScalar phase, bool scaleToFit = false);
+    virtual ~SkDashPathEffect();
+
+    // overrides for SkPathEffect
     //  This method is not exported to java.
-       virtual bool filterPath(SkPath* dst, const SkPath& src, SkScalar* width);
+    virtual bool filterPath(SkPath* dst, const SkPath& src, SkScalar* width);
 
-       // overrides for SkFlattenable
+    // overrides for SkFlattenable
     //  This method is not exported to java.
-       virtual Factory getFactory();
+    virtual Factory getFactory();
     //  This method is not exported to java.
-       virtual void flatten(SkWBuffer&);
+    virtual void flatten(SkWBuffer&);
 
 protected:
-       SkDashPathEffect(SkRBuffer&);
+    SkDashPathEffect(SkRBuffer&);
     
 private:
-       SkScalar*       fIntervals;
-       int32_t         fCount;
-       // computed from phase
-       SkScalar        fInitialDashLength;
-       int32_t         fInitialDashIndex;
-       SkScalar        fIntervalLength;
-       bool            fScaleToFit;
-
-       static SkFlattenable* CreateProc(SkRBuffer&);
+    SkScalar*   fIntervals;
+    int32_t     fCount;
+    // computed from phase
+    SkScalar    fInitialDashLength;
+    int32_t     fInitialDashIndex;
+    SkScalar    fIntervalLength;
+    bool        fScaleToFit;
+
+    static SkFlattenable* CreateProc(SkRBuffer&);
 
     typedef SkPathEffect INHERITED;
 };
index 0967702..bc551a8 100644 (file)
@@ -1,3 +1,20 @@
+/* include/graphics/SkDeque.h
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #ifndef SkTDeque_DEFINED
 #define SkTDeque_DEFINED
 
index b431144..f313edd 100644 (file)
@@ -1,3 +1,20 @@
+/* include/graphics/SkDescriptor.h
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #ifndef SkDescriptor_DEFINED
 #define SkDescriptor_DEFINED
 
 
 class SkDescriptor {
 public:
-       static size_t ComputeOverhead(int entryCount)
-       {
-               SkASSERT(entryCount >= 0);
-               return sizeof(SkDescriptor) + entryCount * sizeof(Entry);
-       }
-
-       static SkDescriptor* Alloc(size_t length)
-       {
-               SkASSERT(SkAlign4(length) == length);
-               SkDescriptor* desc = (SkDescriptor*)sk_malloc_throw(length);
-               return desc;
-       }
-
-       static void Free(SkDescriptor* desc)
-       {
-               sk_free(desc);
-       }
-
-       void init()
-       {
-               fLength = sizeof(SkDescriptor);
-               fCount  = 0;
-       }
-
-       U32 getLength() const { return fLength; }
-
-       void* addEntry(U32 tag, U32 length, const void* data = nil)
-       {
-               SkASSERT(tag);
-               SkASSERT(SkAlign4(length) == length);
-               SkASSERT(this->findEntry(tag, nil) == nil);
-
-               Entry*  entry = (Entry*)((char*)this + fLength);
-               entry->fTag = tag;
-               entry->fLen = length;
-               if (data)
-                       memcpy(entry + 1, data, length);
-
-               fCount += 1;
-               fLength += sizeof(Entry) + length;
-               return (entry + 1);     // return its data
-       }
-
-       void computeChecksum()
-       {
-               fChecksum = SkDescriptor::ComputeChecksum(this);
-       }
+    static size_t ComputeOverhead(int entryCount)
+    {
+        SkASSERT(entryCount >= 0);
+        return sizeof(SkDescriptor) + entryCount * sizeof(Entry);
+    }
+
+    static SkDescriptor* Alloc(size_t length)
+    {
+        SkASSERT(SkAlign4(length) == length);
+        SkDescriptor* desc = (SkDescriptor*)sk_malloc_throw(length);
+        return desc;
+    }
+
+    static void Free(SkDescriptor* desc)
+    {
+        sk_free(desc);
+    }
+
+    void init()
+    {
+        fLength = sizeof(SkDescriptor);
+        fCount  = 0;
+    }
+
+    U32 getLength() const { return fLength; }
+
+    void* addEntry(U32 tag, U32 length, const void* data = nil)
+    {
+        SkASSERT(tag);
+        SkASSERT(SkAlign4(length) == length);
+        SkASSERT(this->findEntry(tag, nil) == nil);
+
+        Entry*  entry = (Entry*)((char*)this + fLength);
+        entry->fTag = tag;
+        entry->fLen = length;
+        if (data)
+            memcpy(entry + 1, data, length);
+
+        fCount += 1;
+        fLength += sizeof(Entry) + length;
+        return (entry + 1); // return its data
+    }
+
+    void computeChecksum()
+    {
+        fChecksum = SkDescriptor::ComputeChecksum(this);
+    }
 
 #ifdef SK_DEBUG
-       void assertChecksum() const
-       {
-               SkASSERT(fChecksum == SkDescriptor::ComputeChecksum(this));
-       }
+    void assertChecksum() const
+    {
+        SkASSERT(fChecksum == SkDescriptor::ComputeChecksum(this));
+    }
 #endif
 
-       const void* findEntry(U32 tag, U32* length) const
-       {
-               const Entry* entry = (const Entry*)(this + 1);
-               int                      count = fCount;
-
-               while (--count >= 0)
-               {
-                       if (entry->fTag == tag)
-                       {
-                               if (length)
-                                       *length = entry->fLen;
-                               return entry + 1;
-                       }
-                       entry = (const Entry*)((const char*)(entry + 1) + entry->fLen);
-               }
-               return nil;
-       }
-
-       SkDescriptor* copy() const
-       {
-               SkDescriptor* desc = SkDescriptor::Alloc(fLength);
-               memcpy(desc, this, fLength);
-               return desc;
-       }
-
-       friend bool operator==(const SkDescriptor& a, const SkDescriptor& b)
-       {
-               return  a.fChecksum == b.fChecksum &&
-                               a.fLength == b.fLength &&
-                               // this assumes that fCount is the beginning of the rest of the descriptor
-                               // (after fCheckSum and fLength)
-                               memcmp(&a.fCount, &b.fCount, a.fLength - 2*sizeof(U32)) == 0;
-       }
-
-       struct Entry {
-               U32     fTag;
-               U32     fLen;
-       };
+    const void* findEntry(U32 tag, U32* length) const
+    {
+        const Entry* entry = (const Entry*)(this + 1);
+        int          count = fCount;
+
+        while (--count >= 0)
+        {
+            if (entry->fTag == tag)
+            {
+                if (length)
+                    *length = entry->fLen;
+                return entry + 1;
+            }
+            entry = (const Entry*)((const char*)(entry + 1) + entry->fLen);
+        }
+        return nil;
+    }
+
+    SkDescriptor* copy() const
+    {
+        SkDescriptor* desc = SkDescriptor::Alloc(fLength);
+        memcpy(desc, this, fLength);
+        return desc;
+    }
+
+    friend bool operator==(const SkDescriptor& a, const SkDescriptor& b)
+    {
+        return  a.fChecksum == b.fChecksum &&
+                a.fLength == b.fLength &&
+                // this assumes that fCount is the beginning of the rest of the descriptor
+                // (after fCheckSum and fLength)
+                memcmp(&a.fCount, &b.fCount, a.fLength - 2*sizeof(U32)) == 0;
+    }
+
+    struct Entry {
+        U32 fTag;
+        U32 fLen;
+    };
 
 #ifdef SK_DEBUG
-       U32 getChecksum() const { return fChecksum; }
-       U32 getCount() const { return fCount; }
+    U32 getChecksum() const { return fChecksum; }
+    U32 getCount() const { return fCount; }
 #endif
 
 private:
-       U32     fChecksum;      // must be first
-       U32     fLength;        // must be second
-       U32     fCount;
-
-       static U32 ComputeChecksum(const SkDescriptor* desc)
-       {
-               const U32*      ptr = (const U32*)desc + 1;     // skip the checksum field
-               const U32*      stop = (const U32*)((const char*)desc + desc->fLength);
-               U32                     sum = 0;
-
-               SkASSERT(ptr < stop);
-               do {
-                       sum = (sum << 1) | (sum >> 31);
-                       sum += *ptr++;
-               } while (ptr < stop);
-
-               return sum;
-       }
+    U32 fChecksum;  // must be first
+    U32 fLength;    // must be second
+    U32 fCount;
+
+    static U32 ComputeChecksum(const SkDescriptor* desc)
+    {
+        const U32*  ptr = (const U32*)desc + 1; // skip the checksum field
+        const U32*  stop = (const U32*)((const char*)desc + desc->fLength);
+        U32         sum = 0;
+
+        SkASSERT(ptr < stop);
+        do {
+            sum = (sum << 1) | (sum >> 31);
+            sum += *ptr++;
+        } while (ptr < stop);
+
+        return sum;
+    }
 };
 
 #include "SkScalerContext.h"
 
 class SkAutoDescriptor {
 public:
-       SkAutoDescriptor(size_t size)
-       {
-               if (size <= kStorageSize)
-                       fDesc = (SkDescriptor*)fStorage;
-               else
-                       fDesc = SkDescriptor::Alloc(size);
-       }
-       ~SkAutoDescriptor()
-       {
-               if (fDesc != (SkDescriptor*)fStorage)
-                       SkDescriptor::Free(fDesc);
-       }
-       SkDescriptor* getDesc() const { return fDesc; }
+    SkAutoDescriptor(size_t size)
+    {
+        if (size <= kStorageSize)
+            fDesc = fStorage;
+        else
+            fDesc = SkDescriptor::Alloc(size);
+    }
+    ~SkAutoDescriptor()
+    {
+        if (fDesc != fStorage)
+            SkDescriptor::Free(fDesc);
+    }
+    SkDescriptor* getDesc() const { return fDesc; }
 private:
-       enum {
-               kStorageSize =  sizeof(SkDescriptor)
+    enum {
+        kStorageSize =  sizeof(SkDescriptor)
                         + sizeof(SkDescriptor::Entry) + sizeof(SkScalerContext::Rec)    // for rec
                         + sizeof(SkDescriptor::Entry) + sizeof(void*)                   // for typeface
                         + 32   // slop for occational small extras
-       };
-       SkDescriptor*   fDesc;
-       U32                             fStorage[kStorageSize >> 2];
+    };
+    SkDescriptor*   fDesc;
+    union {
+        uint32_t     fStorage32[(kStorageSize + 3) >> 2];
+        SkDescriptor fStorage[1];
+    };
 };
 
 
index d358624..6a28a4f 100644 (file)
@@ -1,3 +1,20 @@
+/* include/graphics/SkDiscretePathEffect.h
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #ifndef SkDiscretePathEffect_DEFINED
 #define SkDiscretePathEffect_DEFINED
 
 */
 class SkDiscretePathEffect : public SkPathEffect {
 public:
-       /**     Break the path into segments of segLength length, and randomly move the endpoints
-               away from the original path by a maximum of deviation.
-               Note: works on filled or framed paths
-       */
-       SkDiscretePathEffect(SkScalar segLength, SkScalar deviation);
+    /** Break the path into segments of segLength length, and randomly move the endpoints
+        away from the original path by a maximum of deviation.
+        Note: works on filled or framed paths
+    */
+    SkDiscretePathEffect(SkScalar segLength, SkScalar deviation);
 
-       // overrides for SkPathEffect
+    // overrides for SkPathEffect
     //  This method is not exported to java.
-       virtual bool filterPath(SkPath* dst, const SkPath& src, SkScalar* width);
+    virtual bool filterPath(SkPath* dst, const SkPath& src, SkScalar* width);
 
-       // overrides for SkFlattenable
+    // overrides for SkFlattenable
     //  This method is not exported to java.
-       virtual Factory getFactory();
+    virtual Factory getFactory();
     //  This method is not exported to java.
-       virtual void flatten(SkWBuffer&);
+    virtual void flatten(SkWBuffer&);
 
 protected:
     SkDiscretePathEffect(SkRBuffer&);
 
 private:
-       SkScalar fSegLength, fPerterb;
+    SkScalar fSegLength, fPerterb;
 
-       static SkFlattenable* CreateProc(SkRBuffer&);
+    static SkFlattenable* CreateProc(SkRBuffer&);
     
     typedef SkPathEffect INHERITED;
 };
index 5cfa145..a039bce 100644 (file)
@@ -1,3 +1,20 @@
+/* include/graphics/SkEmbossMaskFilter.h
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #ifndef SkEmbossMaskFilter_DEFINED
 #define SkEmbossMaskFilter_DEFINED
 
 */
 class SkEmbossMaskFilter : public SkMaskFilter {
 public:
-       struct Light {
-               SkScalar        fDirection[3];  // x,y,z
-               U16                     fPad;
-               U8                      fAmbient;
-               U8                      fSpecular;              // exponent, 4.4 right now
-       };
+    struct Light {
+        SkScalar    fDirection[3];  // x,y,z
+        U16         fPad;
+        U8          fAmbient;
+        U8          fSpecular;      // exponent, 4.4 right now
+    };
 
-       SkEmbossMaskFilter(const Light& light, SkScalar blurRadius);
+    SkEmbossMaskFilter(const Light& light, SkScalar blurRadius);
 
-       // overrides from SkMaskFilter
+    // overrides from SkMaskFilter
     //  This method is not exported to java.
-       virtual SkMask::Format getFormat();
+    virtual SkMask::Format getFormat();
     //  This method is not exported to java.
-       virtual bool filterMask(SkMask* dst, const SkMask& src, const SkMatrix& matrix, SkPoint16* margin);
+    virtual bool filterMask(SkMask* dst, const SkMask& src, const SkMatrix& matrix, SkPoint16* margin);
 
-       // overrides from SkFlattenable
+    // overrides from SkFlattenable
 
     //  This method is not exported to java.
-       virtual Factory getFactory();
+    virtual Factory getFactory();
     //  This method is not exported to java.
-       virtual void flatten(SkWBuffer&);
+    virtual void flatten(SkWBuffer&);
 
 protected:
     SkEmbossMaskFilter(SkRBuffer&);
 
 private:
-       Light           fLight;
-       SkScalar        fBlurRadius;
+    Light       fLight;
+    SkScalar    fBlurRadius;
 
-       static SkFlattenable* CreateProc(SkRBuffer&);
+    static SkFlattenable* CreateProc(SkRBuffer&);
     
     typedef SkMaskFilter INHERITED;
 };
index d171015..01b0ac5 100644 (file)
@@ -1,3 +1,20 @@
+/* include/graphics/SkEvent.h
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #ifndef SkEvent_DEFINED
 #define SkEvent_DEFINED
 
 
 //class SkOSWindow;
 
-/**    Unique 32bit id used to identify an instance of SkEventSink. When events are
-       posted, they are posted to a specific sinkID. When it is time to dispatch the
-       event, the sinkID is used to find the specific SkEventSink object. If it is found,
-       its doEvent() method is called with the event.
+/** Unique 32bit id used to identify an instance of SkEventSink. When events are
+    posted, they are posted to a specific sinkID. When it is time to dispatch the
+    event, the sinkID is used to find the specific SkEventSink object. If it is found,
+    its doEvent() method is called with the event.
 */
 typedef U32 SkEventSinkID;
 
 /** \class SkEvent
 
-       SkEvents are used to communicate type-safe information to SkEventSinks.
-       SkEventSinks (including SkViews) each have a unique ID, which is stored
-       in an event. This ID is used to target the event once it has been "posted".
+    SkEvents are used to communicate type-safe information to SkEventSinks.
+    SkEventSinks (including SkViews) each have a unique ID, which is stored
+    in an event. This ID is used to target the event once it has been "posted".
 */
 class SkEvent {
 public:
-       /**     Default construct, creating an empty event.
-       */
-       SkEvent();
-       /**     Construct a new event with the specified type.
-       */
-       explicit SkEvent(const SkString& type);
-       /**     Construct a new event with the specified type.
-       */
-       explicit SkEvent(const char type[]);
-       /**     Construct a new event by copying the fields from the src event.
-       */
-       SkEvent(const SkEvent& src);
-       ~SkEvent();
-
-//     /**     Return the event's type (will never be nil) */
-//     const char*     getType() const;
-       /** Copy the event's type into the specified SkString parameter */
-       void    getType(SkString* str) const;
-       /**     Returns true if the event's type matches exactly the specified type (case sensitive) */
-       bool    isType(const SkString& str) const;
-       /**     Returns true if the event's type matches exactly the specified type (case sensitive) */
-       bool    isType(const char type[], size_t len = 0) const;
-       /**     Set the event's type to the specified string.
-               In XML, use the "type" attribute.
-       */
-       void    setType(const SkString&);
-       /**     Set the event's type to the specified string.
-               In XML, use the "type" attribute.
-       */
-       void    setType(const char type[], size_t len = 0);
-
-       /**     Return the event's unnamed 32bit field. Default value is 0 */
-       U32             getFast32() const { return f32; }
-       /**     Set the event's unnamed 32bit field. In XML, use
-               the subelement <data fast32=... />
-       */
-       void    setFast32(uint32_t x) { f32 = x; }
-
-       /**     Return true if the event contains the named 32bit field, and return the field
-               in value (if value is non-nil). If there is no matching named field, return false
-               and ignore the value parameter.
-       */
-       bool    findS32(const char name[], int32_t* value = nil) const { return fMeta.findS32(name, value); }
-       /**     Return true if the event contains the named SkScalar field, and return the field
-               in value (if value is non-nil). If there is no matching named field, return false
-               and ignore the value parameter.
-       */
-       bool    findScalar(const char name[], SkScalar* value = nil) const { return fMeta.findScalar(name, value); }
-       /**     Return true if the event contains the named SkScalar field, and return the fields
-               in value[] (if value is non-nil), and return the number of SkScalars in count (if count is non-nil).
-               If there is no matching named field, return false and ignore the value and count parameters.
-       */
-       const SkScalar* findScalars(const char name[], int* count, SkScalar values[] = nil) const { return fMeta.findScalars(name, count, values); }
-       /**     Return the value of the named string field, or if no matching named field exists, return nil.
-       */
-       const char*     findString(const char name[]) const { return fMeta.findString(name); }
-       /**     Return true if the event contains the named pointer field, and return the field
-               in value (if value is non-nil). If there is no matching named field, return false
-               and ignore the value parameter.
-       */
-       bool    findPtr(const char name[], void** value) const { return fMeta.findPtr(name, value); }
-       bool    findBool(const char name[], bool* value) const { return fMeta.findBool(name, value); }
-
-       /**     Returns true if ethe event contains the named 32bit field, and if it equals the specified value */
-       bool    hasS32(const char name[], int32_t value) const { return fMeta.hasS32(name, value); }
-       /**     Returns true if ethe event contains the named SkScalar field, and if it equals the specified value */
-       bool    hasScalar(const char name[], SkScalar value) const { return fMeta.hasScalar(name, value); }
-       /**     Returns true if ethe event contains the named string field, and if it equals (using strcmp) the specified value */
-       bool    hasString(const char name[], const char value[]) const { return fMeta.hasString(name, value); }
-       /**     Returns true if ethe event contains the named pointer field, and if it equals the specified value */
-       bool    hasPtr(const char name[], void* value) const { return fMeta.hasPtr(name, value); }
-       bool    hasBool(const char name[], bool value) const { return fMeta.hasBool(name, value); }
-
-       /**     Add/replace the named 32bit field to the event. In XML use the subelement <data name=... s32=... /> */
-       void    setS32(const char name[], int32_t value) { fMeta.setS32(name, value); }
-       /**     Add/replace the named SkScalar field to the event. In XML use the subelement <data name=... scalar=... /> */
-       void    setScalar(const char name[], SkScalar value) { fMeta.setScalar(name, value); }
-       /**     Add/replace the named SkScalar[] field to the event. */
-       SkScalar* setScalars(const char name[], int count, const SkScalar values[] = nil) { return fMeta.setScalars(name, count, values); }
-       /**     Add/replace the named string field to the event. In XML use the subelement <data name=... string=... */
-       void    setString(const char name[], const SkString& value) { fMeta.setString(name, value.c_str()); }
-       /**     Add/replace the named string field to the event. In XML use the subelement <data name=... string=... */
-       void    setString(const char name[], const char value[]) { fMeta.setString(name, value); }
-       /**     Add/replace the named pointer field to the event. There is no XML equivalent for this call */
-       void    setPtr(const char name[], void* value) { fMeta.setPtr(name, value); }
-       void    setBool(const char name[], bool value) { fMeta.setBool(name, value); }
-
-       /**     Return the underlying metadata object */
-       SkMetaData&                     getMetaData() { return fMeta; }
-       /**     Return the underlying metadata object */
-       const SkMetaData&       getMetaData() const { return fMeta; }
-
-       void tron() { SkDEBUGCODE(fDebugTrace = true;) }
-       void troff() { SkDEBUGCODE(fDebugTrace = false;) }
-       bool isDebugTrace() const
-       {
+    /** Default construct, creating an empty event.
+    */
+    SkEvent();
+    /** Construct a new event with the specified type.
+    */
+    explicit SkEvent(const SkString& type);
+    /** Construct a new event with the specified type.
+    */
+    explicit SkEvent(const char type[]);
+    /** Construct a new event by copying the fields from the src event.
+    */
+    SkEvent(const SkEvent& src);
+    ~SkEvent();
+
+//  /** Return the event's type (will never be nil) */
+//  const char* getType() const;
+    /** Copy the event's type into the specified SkString parameter */
+    void    getType(SkString* str) const;
+    /** Returns true if the event's type matches exactly the specified type (case sensitive) */
+    bool    isType(const SkString& str) const;
+    /** Returns true if the event's type matches exactly the specified type (case sensitive) */
+    bool    isType(const char type[], size_t len = 0) const;
+    /** Set the event's type to the specified string.
+        In XML, use the "type" attribute.
+    */
+    void    setType(const SkString&);
+    /** Set the event's type to the specified string.
+        In XML, use the "type" attribute.
+    */
+    void    setType(const char type[], size_t len = 0);
+
+    /** Return the event's unnamed 32bit field. Default value is 0 */
+    U32     getFast32() const { return f32; }
+    /** Set the event's unnamed 32bit field. In XML, use
+        the subelement <data fast32=... />
+    */
+    void    setFast32(uint32_t x) { f32 = x; }
+
+    /** Return true if the event contains the named 32bit field, and return the field
+        in value (if value is non-nil). If there is no matching named field, return false
+        and ignore the value parameter.
+    */
+    bool    findS32(const char name[], int32_t* value = nil) const { return fMeta.findS32(name, value); }
+    /** Return true if the event contains the named SkScalar field, and return the field
+        in value (if value is non-nil). If there is no matching named field, return false
+        and ignore the value parameter.
+    */
+    bool    findScalar(const char name[], SkScalar* value = nil) const { return fMeta.findScalar(name, value); }
+    /** Return true if the event contains the named SkScalar field, and return the fields
+        in value[] (if value is non-nil), and return the number of SkScalars in count (if count is non-nil).
+        If there is no matching named field, return false and ignore the value and count parameters.
+    */
+    const SkScalar* findScalars(const char name[], int* count, SkScalar values[] = nil) const { return fMeta.findScalars(name, count, values); }
+    /** Return the value of the named string field, or if no matching named field exists, return nil.
+    */
+    const char* findString(const char name[]) const { return fMeta.findString(name); }
+    /** Return true if the event contains the named pointer field, and return the field
+        in value (if value is non-nil). If there is no matching named field, return false
+        and ignore the value parameter.
+    */
+    bool    findPtr(const char name[], void** value) const { return fMeta.findPtr(name, value); }
+    bool    findBool(const char name[], bool* value) const { return fMeta.findBool(name, value); }
+
+    /** Returns true if ethe event contains the named 32bit field, and if it equals the specified value */
+    bool    hasS32(const char name[], int32_t value) const { return fMeta.hasS32(name, value); }
+    /** Returns true if ethe event contains the named SkScalar field, and if it equals the specified value */
+    bool    hasScalar(const char name[], SkScalar value) const { return fMeta.hasScalar(name, value); }
+    /** Returns true if ethe event contains the named string field, and if it equals (using strcmp) the specified value */
+    bool    hasString(const char name[], const char value[]) const { return fMeta.hasString(name, value); }
+    /** Returns true if ethe event contains the named pointer field, and if it equals the specified value */
+    bool    hasPtr(const char name[], void* value) const { return fMeta.hasPtr(name, value); }
+    bool    hasBool(const char name[], bool value) const { return fMeta.hasBool(name, value); }
+
+    /** Add/replace the named 32bit field to the event. In XML use the subelement <data name=... s32=... /> */
+    void    setS32(const char name[], int32_t value) { fMeta.setS32(name, value); }
+    /** Add/replace the named SkScalar field to the event. In XML use the subelement <data name=... scalar=... /> */
+    void    setScalar(const char name[], SkScalar value) { fMeta.setScalar(name, value); }
+    /** Add/replace the named SkScalar[] field to the event. */
+    SkScalar* setScalars(const char name[], int count, const SkScalar values[] = nil) { return fMeta.setScalars(name, count, values); }
+    /** Add/replace the named string field to the event. In XML use the subelement <data name=... string=... */
+    void    setString(const char name[], const SkString& value) { fMeta.setString(name, value.c_str()); }
+    /** Add/replace the named string field to the event. In XML use the subelement <data name=... string=... */
+    void    setString(const char name[], const char value[]) { fMeta.setString(name, value); }
+    /** Add/replace the named pointer field to the event. There is no XML equivalent for this call */
+    void    setPtr(const char name[], void* value) { fMeta.setPtr(name, value); }
+    void    setBool(const char name[], bool value) { fMeta.setBool(name, value); }
+
+    /** Return the underlying metadata object */
+    SkMetaData&         getMetaData() { return fMeta; }
+    /** Return the underlying metadata object */
+    const SkMetaData&   getMetaData() const { return fMeta; }
+
+    void tron() { SkDEBUGCODE(fDebugTrace = true;) }
+    void troff() { SkDEBUGCODE(fDebugTrace = false;) }
+    bool isDebugTrace() const
+    {
 #ifdef SK_DEBUG
-               return fDebugTrace;
+        return fDebugTrace;
 #else
-               return false;
+        return false;
 #endif
-       }
-
-       /**     Call this to initialize the event from the specified XML node */
-       void    inflate(const SkDOM&, const SkDOM::Node*);
-
-       SkDEBUGCODE(void dump(const char title[] = nil);)
-
-       /**     Post the specified event to the event queue, targeting the specified eventsink, with an optional
-               delay. The event must be dynamically allocated for this. It cannot be a global or on the stack.
-               After this call, ownership is transfered to the system, so the caller must not retain
-               the event's ptr. Returns false if the event could not be posted (which means it will have been deleted).
-       */
-       static bool     Post(SkEvent* evt, SkEventSinkID targetID, SkMSec delay = 0);
-       /**     Post the specified event to the event queue, targeting the specified eventsink, to be delivered on/after the
-               specified millisecond time. The event must be dynamically allocated for this. It cannot be a global or on the stack.
-               After this call, ownership is transfered to the system, so the caller must not retain
-               the event's ptr. Returns false if the event could not be posted (which means it will have been deleted).
-       */
-       static bool     PostTime(SkEvent* evt, SkEventSinkID targetID, SkMSec time);
-
-       /**     Helper method for calling SkEvent::PostTime(this, ...), where the caller specifies a delay.
-               The real "time" will be computed automatically by sampling the clock and adding its value
-               to delay.
-       */
-       bool post(SkEventSinkID sinkID, SkMSec delay = 0)
-       {
-               return SkEvent::Post(this, sinkID, delay);
-       }
-
-       void postTime(SkEventSinkID sinkID, SkMSec time)
-       {
-               SkEvent::PostTime(this, sinkID, time);
-       }
-
-       ///////////////////////////////////////////////
-       /**     Porting layer must call these functions **/
-       ///////////////////////////////////////////////
-
-       /**     Global initialization function for the SkEvent system. Should be called exactly
-               once before any other event method is called, and should be called after the
-               call to SkGraphics::Init().
-       */
-       static void             Init();
-       /**     Global cleanup function for the SkEvent system. Should be called exactly once after
-               all event methods have been called, and should be called before calling SkGraphics::Term().
-       */
-       static void             Term();
-
-       /**     Call this to process one event from the queue. If it returns true, there are more events
-               to process.
-       */
-       static bool             ProcessEvent();
-       /**     Call this whenever the requested timer has expired (requested by a call to SetQueueTimer).
-               It will post any delayed events whose time as "expired" onto the event queue.
-               It may also call SignalQueueTimer() and SignalNonEmptyQueue().
-       */
-       static void             ServiceQueueTimer();
-
-       ////////////////////////////////////////////////////
-       /**     Porting layer must implement these functions **/
-       ////////////////////////////////////////////////////
-
-       /**     Called whenever an SkEvent is posted to an empty queue, so that the OS
-               can be told to later call Dequeue().
-       */
-       static void     SignalNonEmptyQueue();
-       /**     Called whenever the delay until the next delayed event changes. If zero is
-               passed, then there are no more queued delay events.
-       */
-       static void SignalQueueTimer(SkMSec delay);
+    }
+
+    /** Call this to initialize the event from the specified XML node */
+    void    inflate(const SkDOM&, const SkDOM::Node*);
+
+    SkDEBUGCODE(void dump(const char title[] = nil);)
+
+    /** Post the specified event to the event queue, targeting the specified eventsink, with an optional
+        delay. The event must be dynamically allocated for this. It cannot be a global or on the stack.
+        After this call, ownership is transfered to the system, so the caller must not retain
+        the event's ptr. Returns false if the event could not be posted (which means it will have been deleted).
+    */
+    static bool Post(SkEvent* evt, SkEventSinkID targetID, SkMSec delay = 0);
+    /** Post the specified event to the event queue, targeting the specified eventsink, to be delivered on/after the
+        specified millisecond time. The event must be dynamically allocated for this. It cannot be a global or on the stack.
+        After this call, ownership is transfered to the system, so the caller must not retain
+        the event's ptr. Returns false if the event could not be posted (which means it will have been deleted).
+    */
+    static bool PostTime(SkEvent* evt, SkEventSinkID targetID, SkMSec time);
+
+    /** Helper method for calling SkEvent::PostTime(this, ...), where the caller specifies a delay.
+        The real "time" will be computed automatically by sampling the clock and adding its value
+        to delay.
+    */
+    bool post(SkEventSinkID sinkID, SkMSec delay = 0)
+    {
+        return SkEvent::Post(this, sinkID, delay);
+    }
+
+    void postTime(SkEventSinkID sinkID, SkMSec time)
+    {
+        SkEvent::PostTime(this, sinkID, time);
+    }
+
+    ///////////////////////////////////////////////
+    /** Porting layer must call these functions **/
+    ///////////////////////////////////////////////
+
+    /** Global initialization function for the SkEvent system. Should be called exactly
+        once before any other event method is called, and should be called after the
+        call to SkGraphics::Init().
+    */
+    static void     Init();
+    /** Global cleanup function for the SkEvent system. Should be called exactly once after
+        all event methods have been called, and should be called before calling SkGraphics::Term().
+    */
+    static void     Term();
+
+    /** Call this to process one event from the queue. If it returns true, there are more events
+        to process.
+    */
+    static bool     ProcessEvent();
+    /** Call this whenever the requested timer has expired (requested by a call to SetQueueTimer).
+        It will post any delayed events whose time as "expired" onto the event queue.
+        It may also call SignalQueueTimer() and SignalNonEmptyQueue().
+    */
+    static void     ServiceQueueTimer();
+
+    ////////////////////////////////////////////////////
+    /** Porting layer must implement these functions **/
+    ////////////////////////////////////////////////////
+
+    /** Called whenever an SkEvent is posted to an empty queue, so that the OS
+        can be told to later call Dequeue().
+    */
+    static void SignalNonEmptyQueue();
+    /** Called whenever the delay until the next delayed event changes. If zero is
+        passed, then there are no more queued delay events.
+    */
+    static void SignalQueueTimer(SkMSec delay);
 
 #ifndef SK_USE_WXWIDGETS
 #ifdef SK_BUILD_FOR_WIN
-       static bool WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
+    static bool WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
 #elif defined(SK_BUILD_FOR_UNIXx)
   static U32 HandleTimer(U32, void*);
   static bool WndProc(Display*, Window, XEvent&);
 #endif
 #else
-       // Don't know yet what this will be
-       //static bool CustomEvent();
+    // Don't know yet what this will be
+    //static bool CustomEvent();
 #endif
 
 private:
-       SkMetaData              fMeta;
-       mutable char*   fType;  // may be characters with low bit set to know that it is not a pointer
-       U32                             f32;
-       SkDEBUGCODE(bool fDebugTrace;)
-
-       // these are for our implementation of the event queue
-       SkEventSinkID   fTargetID;
-       SkMSec                  fTime;
-       SkEvent*                fNextEvent;     // either in the delay or normal event queue
-       void initialize(const char* type, size_t typeLen);
-
-       static bool Enqueue(SkEvent* evt);
-       static SkMSec EnqueueTime(SkEvent* evt, SkMSec time);
-       static SkEvent* Dequeue(SkEventSinkID* targetID);
-       static bool             QHasEvents();
+    SkMetaData      fMeta;
+    mutable char*   fType;  // may be characters with low bit set to know that it is not a pointer
+    U32             f32;
+    SkDEBUGCODE(bool fDebugTrace;)
+
+    // these are for our implementation of the event queue
+    SkEventSinkID   fTargetID;
+    SkMSec          fTime;
+    SkEvent*        fNextEvent; // either in the delay or normal event queue
+    void initialize(const char* type, size_t typeLen);
+
+    static bool Enqueue(SkEvent* evt);
+    static SkMSec EnqueueTime(SkEvent* evt, SkMSec time);
+    static SkEvent* Dequeue(SkEventSinkID* targetID);
+    static bool     QHasEvents();
 };
 
 #endif
index 6772f03..98903ec 100644 (file)
@@ -1,3 +1,20 @@
+/* include/graphics/SkEventSink.h
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #ifndef SkEventSink_DEFINED
 #define SkEventSink_DEFINED
 
 
 struct SkTagList;
 
-/**    \class SkEventSink
+/** \class SkEventSink
 
-       SkEventSink is the base class for all objects that receive SkEvents.
+    SkEventSink is the base class for all objects that receive SkEvents.
 */
 class SkEventSink : public SkRefCnt {
 public:
-                       SkEventSink();
-       virtual ~SkEventSink();
-
-       /**     Returns this eventsink's unique ID. Use this to post SkEvents to
-               this eventsink.
-       */
-       SkEventSinkID getSinkID() const { return fID; }
-
-       /**     Call this to pass an event to this object for processing. Returns true if the
-               event was handled.
-       */
-       bool doEvent(const SkEvent&);
-       /**     Returns true if the sink (or one of its subclasses) understands the event as a query.
-               If so, the sink may modify the event to communicate its "answer".
-       */
-       bool doQuery(SkEvent* query);
-
-       /**     Add sinkID to the list of listeners, to receive events from calls to sendToListeners()
-               and postToListeners(). If sinkID already exists in the listener list, no change is made.
-       */
-       void    addListenerID(SkEventSinkID sinkID);
-       /**     Copy listeners from one event sink to another, typically from parent to child.
-               @param from the event sink to copy the listeners from
-       */
-       void copyListeners(const SkEventSink& from);
-       /**     Remove sinkID from the list of listeners. If sinkID does not appear in the list,
-               no change is made.
-       */
-       void    removeListenerID(SkEventSinkID);
-       /**     Returns true if there are 1 or more listeners attached to this eventsink
-       */
-       bool    hasListeners() const;
-       /**     Posts a copy of evt to each of the eventsinks in the lisener list.
-       */
-       void    postToListeners(const SkEvent& evt, SkMSec delay = 0);
-
-       enum EventResult {
-               kHandled_EventResult,           //!< the eventsink returned true from its doEvent method
-               kNotHandled_EventResult,        //!< the eventsink returned false from its doEvent method
-               kSinkNotFound_EventResult       //!< no matching eventsink was found for the event's getSink().
-       };
-       /**     DoEvent handles searching for an eventsink object that matches the targetID.
-               If one is found, it calls the sink's doEvent method, returning
-               either kHandled_EventResult or kNotHandled_EventResult. If no matching
-               eventsink is found, kSinkNotFound_EventResult is returned.
-       */
-       static EventResult DoEvent(const SkEvent&, SkEventSinkID targetID);
-
-       /** Returns the matching eventsink, or nil if not found
-       */
-       static SkEventSink*     FindSink(SkEventSinkID);
+            SkEventSink();
+    virtual ~SkEventSink();
+
+    /** Returns this eventsink's unique ID. Use this to post SkEvents to
+        this eventsink.
+    */
+    SkEventSinkID getSinkID() const { return fID; }
+
+    /** Call this to pass an event to this object for processing. Returns true if the
+        event was handled.
+    */
+    bool doEvent(const SkEvent&);
+    /** Returns true if the sink (or one of its subclasses) understands the event as a query.
+        If so, the sink may modify the event to communicate its "answer".
+    */
+    bool doQuery(SkEvent* query);
+
+    /** Add sinkID to the list of listeners, to receive events from calls to sendToListeners()
+        and postToListeners(). If sinkID already exists in the listener list, no change is made.
+    */
+    void    addListenerID(SkEventSinkID sinkID);
+    /** Copy listeners from one event sink to another, typically from parent to child.
+        @param from the event sink to copy the listeners from
+    */
+    void copyListeners(const SkEventSink& from);
+    /** Remove sinkID from the list of listeners. If sinkID does not appear in the list,
+        no change is made.
+    */
+    void    removeListenerID(SkEventSinkID);
+    /** Returns true if there are 1 or more listeners attached to this eventsink
+    */
+    bool    hasListeners() const;
+    /** Posts a copy of evt to each of the eventsinks in the lisener list.
+    */
+    void    postToListeners(const SkEvent& evt, SkMSec delay = 0);
+
+    enum EventResult {
+        kHandled_EventResult,       //!< the eventsink returned true from its doEvent method
+        kNotHandled_EventResult,    //!< the eventsink returned false from its doEvent method
+        kSinkNotFound_EventResult   //!< no matching eventsink was found for the event's getSink().
+    };
+    /** DoEvent handles searching for an eventsink object that matches the targetID.
+        If one is found, it calls the sink's doEvent method, returning
+        either kHandled_EventResult or kNotHandled_EventResult. If no matching
+        eventsink is found, kSinkNotFound_EventResult is returned.
+    */
+    static EventResult DoEvent(const SkEvent&, SkEventSinkID targetID);
+
+    /** Returns the matching eventsink, or nil if not found
+    */
+    static SkEventSink* FindSink(SkEventSinkID);
 
 protected:
-       /**     Override this to handle events in your subclass. Be sure to call the inherited version
-               for events that you don't handle.
-       */
-       virtual bool onEvent(const SkEvent&);
-       virtual bool onQuery(SkEvent*);
+    /** Override this to handle events in your subclass. Be sure to call the inherited version
+        for events that you don't handle.
+    */
+    virtual bool onEvent(const SkEvent&);
+    virtual bool onQuery(SkEvent*);
 
-       SkTagList*      findTagList(U8CPU tag) const;
-       void            addTagList(SkTagList*);
-       void            removeTagList(U8CPU tag);
+    SkTagList*  findTagList(U8CPU tag) const;
+    void        addTagList(SkTagList*);
+    void        removeTagList(U8CPU tag);
 
 private:
-       SkEventSinkID   fID;
-       SkTagList*              fTagHead;
+    SkEventSinkID   fID;
+    SkTagList*      fTagHead;
 
-       // for our private link-list
-       SkEventSink*    fNextSink;
+    // for our private link-list
+    SkEventSink*    fNextSink;
 };
 
 #endif
index b68a361..4533420 100644 (file)
@@ -1,22 +1,39 @@
+/* include/graphics/SkFlattenable.h
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #ifndef SkFlattenable_DEFINED
 #define SkFlattenable_DEFINED
 
 #include "SkRefCnt.h"
 #include "SkBuffer.h"
 
-/**    \class SkFlattenable
+/** \class SkFlattenable
 
-       SkFlattenable is the base class for objects that need to be flattened
-       into a data stream for either transport or as part of the key to the
-       font cache.
+    SkFlattenable is the base class for objects that need to be flattened
+    into a data stream for either transport or as part of the key to the
+    font cache.
 */
 //  This class is not exported to java.
 class SkFlattenable : public SkRefCnt {
 public:
-       typedef SkFlattenable* (*Factory)(SkRBuffer&);
+    typedef SkFlattenable* (*Factory)(SkRBuffer&);
 
-       virtual Factory getFactory();
-       virtual void    flatten(SkWBuffer&);
+    virtual Factory getFactory();
+    virtual void    flatten(SkWBuffer&);
 };
 
 #endif
index 5dc8738..0a4ca05 100644 (file)
@@ -1,3 +1,20 @@
+/* include/graphics/SkFontCodec.h
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #ifndef SkFontCodec_DEFINED
 #define SkFontCodec_DEFINED
 
 
 class SkFontCodec {
 public:
-       static void Compress(SkSFNT& font, const char fileName[]);
+    static void Compress(SkSFNT& font, const char fileName[]);
 
-       /*      Format is [count] + [instruction, bitcount] * count
-               Allocated with sk_malloc()
-       */
-       static U8* BuildInstrHuffmanTable(SkSFNT&);
-       static U8* BuildOutlineHuffmanTable(SkSFNT& font);
+    /*  Format is [count] + [instruction, bitcount] * count
+        Allocated with sk_malloc()
+    */
+    static U8* BuildInstrHuffmanTable(SkSFNT&);
+    static U8* BuildOutlineHuffmanTable(SkSFNT& font);
 
-       SkDEBUGCODE(static void UnitTest();)
+    SkDEBUGCODE(static void UnitTest();)
 };
 
 #endif
index 3b3eacd..f164e38 100644 (file)
@@ -1,3 +1,20 @@
+/* include/graphics/SkFontHost.h
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #ifndef SkFontHost_DEFINED
 #define SkFontHost_DEFINED
 
@@ -8,35 +25,31 @@ class SkDescriptor;
 
 /** \class SkFontHost
 
-       This class is ported to each environment. It is responsible for bridging the gap
+    This class is ported to each environment. It is responsible for bridging the gap
     between SkTypeface and the resulting platform-specific instance of SkScalerContext.
 */
 class SkFontHost {
 public:
-       /**     Return a subclass of SkTypeface, one that can be used by your scalaracontext
-               (returned by SkFontHost::CreateScalarContext).
-        1) If family is nil, use name.
-        2) If name is nil, use family.
-        3) If both are nil, use default family.
-       */
-       static SkTypeface* CreateTypeface(const SkTypeface* family, const char name[], SkTypeface::Style);
-       /** Given a typeface (or nil), return the number of bytes needed to flatten it
+    /** Return a subclass of SkTypeface, one that can be used by your scalaracontext
+        (returned by SkFontHost::CreateScalarContext).
+        1) If family is null, use name.
+        2) If name is null, use family.
+        3) If both are null, use default family.
+    */
+    static SkTypeface* CreateTypeface(const SkTypeface* family, const char name[], SkTypeface::Style);
+    /** Given a typeface (or null), return the number of bytes needed to flatten it
         into a buffer, for the purpose of communicating information to the
-        scalercontext. If buffer is nil, then ignore it but still return the number
+        scalercontext. If buffer is null, then ignore it but still return the number
         of bytes that would be written.
     */
-       static uint32_t FlattenTypeface(const SkTypeface* face, void* buffer);
-       /**     Return a subclass of SkScalarContext
-       */
-       static SkScalerContext* CreateScalerContext(const SkDescriptor* desc);
-    
-    enum ScalerContextID {
-        kMissing_ScalerContextID = SK_UnknownAuxScalerContextID,
-        kMax_ScalerContextID = SK_MaxAuxScalerContextID
-    };
-    static ScalerContextID FindScalerContextIDForUnichar(int32_t unichar);
-
-    static SkScalerContext* CreateScalerContextFromID(ScalerContextID, const SkScalerContext::Rec&);
+    static uint32_t FlattenTypeface(const SkTypeface* face, void* buffer);
+    /** Return a subclass of SkScalarContext
+    */
+    static SkScalerContext* CreateScalerContext(const SkDescriptor* desc);
+    /** Return a scalercontext using the "fallback" font. If there is no designated
+        fallback, return null.
+    */
+    static SkScalerContext* CreateFallbackScalerContext(const SkScalerContext::Rec&);
 };
 
 #endif
index 8ac0d31..91f1359 100644 (file)
@@ -1,3 +1,20 @@
+/* include/graphics/SkGlobals.h
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #ifndef SkGlobals_DEFINED
 #define SkGlobals_DEFINED
 
 
 class SkGlobals {
 public:
-       class Rec {
-       public:
-               virtual ~Rec();
-       private:
-               Rec*    fNext;
-               U32             fTag;
-
-               friend class SkGlobals;
-       };
-
-       /**     Look for a matching Rec for the specified tag. If one is found, return it.
-               If one is not found, if create_proc is nil, return nil, else
-               call the proc, and if it returns a Rec, add it to the global list
-               and return it.
-
-               create_proc can NOT call back into SkGlobals::Find (it would deadlock)
-       */
-       static Rec*     Find(U32 tag, Rec* (*create_proc)());
-       /**     Helper for Find, when you want to assert that the Rec is already in the list
-       */
-       static Rec* Get(U32 tag)
-       {
-               Rec* rec = SkGlobals::Find(tag, nil);
-               SkASSERT(rec);
-               return rec;
-       }
-
-       // used by porting layer
-       struct BootStrap {
-               SkMutex fMutex;
-               Rec*    fHead;
-       };
+    class Rec {
+    public:
+        virtual ~Rec();
+    private:
+        Rec*    fNext;
+        U32     fTag;
+
+        friend class SkGlobals;
+    };
+
+    /** Look for a matching Rec for the specified tag. If one is found, return it.
+        If one is not found, if create_proc is nil, return nil, else
+        call the proc, and if it returns a Rec, add it to the global list
+        and return it.
+
+        create_proc can NOT call back into SkGlobals::Find (it would deadlock)
+    */
+    static Rec* Find(U32 tag, Rec* (*create_proc)());
+    /** Helper for Find, when you want to assert that the Rec is already in the list
+    */
+    static Rec* Get(U32 tag)
+    {
+        Rec* rec = SkGlobals::Find(tag, nil);
+        SkASSERT(rec);
+        return rec;
+    }
+
+    // used by porting layer
+    struct BootStrap {
+        SkMutex fMutex;
+        Rec*    fHead;
+    };
 
 private:
-       static void     Init();
-       static void Term();
-       friend class SkGraphics;
+    static void Init();
+    static void Term();
+    friend class SkGraphics;
 
-       //      This last function is implemented in the porting layer
-       static BootStrap& GetBootStrap();
+    //  This last function is implemented in the porting layer
+    static BootStrap& GetBootStrap();
 };
 
 #endif
index 7e5a722..cce4909 100644 (file)
@@ -1,3 +1,20 @@
+/* include/graphics/SkGradientShader.h
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #ifndef SkGradientShader_DEFINED
 #define SkGradientShader_DEFINED
 
 
 class SkUnitMapper;
 
-/**    \class SkGradientShader
+/** \class SkGradientShader
 
-       SkGradientShader hosts factories for creating subclasses of SkShader that
-       render linear and radial gradients.
+    SkGradientShader hosts factories for creating subclasses of SkShader that
+    render linear and radial gradients.
 */
 class SkGradientShader : public SkShader {
 public:
-       /**     Returns a shader that generates a linear gradient between the two
-               specified points.
-               <p />
-               CreateLinear returns a shader with a reference count of 1.
-               The caller should decrement the shader's reference count when done with the shader.
-               It is an error for count to be < 2.
+    /** Returns a shader that generates a linear gradient between the two
+        specified points.
+        <p />
+        CreateLinear returns a shader with a reference count of 1.
+        The caller should decrement the shader's reference count when done with the shader.
+        It is an error for count to be < 2.
         @param  pts The start and end points for the gradient.
         @param  colors  The array[count] of colors, to be distributed between the two points
         @param  pos     May be NULL. array[count] of SkScalars, or NULL, of the relative position of
@@ -26,17 +43,17 @@ public:
         @param  count   Must be >=2. The number of colors (and pos if not NULL) entries. 
         @param  mode    The tiling mode
         @param  mapper  May be NULL. Callback to modify the spread of the colors.
-       */
-       static SkShader* CreateLinear(  const SkPoint pts[2],
-                                                                       const SkColor colors[], const SkScalar pos[], int count,
-                                                                       TileMode mode,
-                                                                       SkUnitMapper* mapper = NULL);
-
-       /**     Returns a shader that generates a radial gradient given the center and radius.
-               <p />
-               CreateRadial returns a shader with a reference count of 1.
-               The caller should decrement the shader's reference count when done with the shader.
-               It is an error for colorCount to be < 2, or for radius to be <= 0.
+    */
+    static SkShader* CreateLinear(  const SkPoint pts[2],
+                                    const SkColor colors[], const SkScalar pos[], int count,
+                                    TileMode mode,
+                                    SkUnitMapper* mapper = NULL);
+
+    /** Returns a shader that generates a radial gradient given the center and radius.
+        <p />
+        CreateRadial returns a shader with a reference count of 1.
+        The caller should decrement the shader's reference count when done with the shader.
+        It is an error for colorCount to be < 2, or for radius to be <= 0.
         @param  center  The center of the circle for this gradient
         @param  radius  Must be positive. The radius of the circle for this gradient
         @param  colors  The array[count] of colors, to be distributed between the center and edge of the circle
@@ -46,11 +63,11 @@ public:
         @param  count   Must be >= 2. The number of colors (and pos if not NULL) entries
         @param  mode    The tiling mode
         @param  mapper  May be NULL. Callback to modify the spread of the colors.
-       */
-       static SkShader* CreateRadial(  const SkPoint& center, SkScalar radius,
-                                                                       const SkColor colors[], const SkScalar pos[], int count,
-                                                                       TileMode mode,
-                                                                       SkUnitMapper* mapper = NULL);
+    */
+    static SkShader* CreateRadial(  const SkPoint& center, SkScalar radius,
+                                    const SkColor colors[], const SkScalar pos[], int count,
+                                    TileMode mode,
+                                    SkUnitMapper* mapper = NULL);
 };
 
 #endif
index 96c3f11..e7c9c89 100644 (file)
@@ -1,3 +1,20 @@
+/* include/graphics/SkGraphics.h
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #ifndef SkGraphics_DEFINED
 #define SkGraphics_DEFINED
 
 
 class SkGraphics {
 public:
-       static void Init(bool runUnitTests);
-       static void Term();
+    static void Init(bool runUnitTests);
+    static void Term();
 
-       /**     Call this if the heap that the graphics engine uses is low on memory.
-               It will attempt to free some of its caches. Returns true if it was
-               able to, or false if it could do nothing.
+    /** Call this if the heap that the graphics engine uses is low on memory.
+        It will attempt to free some of its caches. Returns true if it was
+        able to, or false if it could do nothing.
 
-               This may be called from any thread, and guarantees not to call
-               new or sk_malloc (though it will hopefully call delete and/or sk_free).
-               It also will never throw an exception.
-       */
-       static bool FreeCaches(size_t bytesNeeded);
+        This may be called from any thread, and guarantees not to call
+        new or sk_malloc (though it will hopefully call delete and/or sk_free).
+        It also will never throw an exception.
+    */
+    static bool FreeCaches(size_t bytesNeeded);
 
 private:
-       /**     This is automatically called by SkGraphics::Init(), and must be
-               implemented by the host OS. This allows the host OS to register a callback
-               with the C++ runtime to call SkGraphics::FreeCaches()
-       */
-       static void InstallNewHandler();
+    /** This is automatically called by SkGraphics::Init(), and must be
+        implemented by the host OS. This allows the host OS to register a callback
+        with the C++ runtime to call SkGraphics::FreeCaches()
+    */
+    static void InstallNewHandler();
 };
 
 #endif
index e5c7f3c..eeb20d2 100644 (file)
+/* include/graphics/SkImageDecoder.h
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #ifndef SkImageDecoder_DEFINED
 #define SkImageDecoder_DEFINED
 
 #include "SkBitmap.h"
 #include "SkBitmapRef.h"
+#include "SkRefCnt.h"
 
 class SkStream;
 
-/**    \class SkImageDecoder
+/** \class SkImageDecoder
 
-       Base class for decoding compressed images into a SkBitmap
+    Base class for decoding compressed images into a SkBitmap
 */
 class SkImageDecoder {
 public:
-       virtual ~SkImageDecoder();
+    virtual ~SkImageDecoder();
+    
+    /** \class Peeker
+    
+        Base class for optional callbacks to retrive meta/chunk data out of
+        an image as it is being decoded.
+    */
+    class Peeker : public SkRefCnt {
+    public:
+        /** Return true to continue decoding, or false to indicate an error, which
+            will cause the decoder to not return the image.
+        */
+        virtual bool peek(const char tag[], const void* data, size_t length) = 0;
+    };
+
+    Peeker* getPeeker() const { return fPeeker; }
+    Peeker* setPeeker(Peeker*);
+    
+    /** \class Peeker
+    
+        Base class for optional callbacks to retrive meta/chunk data out of
+        an image as it is being decoded.
+    */
+    class Chooser : public SkRefCnt {
+    public:
+        virtual void begin(int count) {}
+        virtual void inspect(int index, SkBitmap::Config config, int width, int height) {}
+        /** Return the index of the subimage you want, or -1 to choose none of them.
+        */
+        virtual int choose() = 0;
+    };
+
+    Chooser* getChooser() const { return fChooser; }
+    Chooser* setChooser(Chooser*);
+
+    /** Given a stream, decode it into the specified bitmap.
+        If the decoder can decompress the image, it should call setConfig() on the bitmap,
+        and then call allocPixels(), which will allocated offscreen memory for the pixels.
+        It can then set the pixels with the decompressed image. If the image cannot be
+        decompressed, return false and leave the bitmap unchanged.
+    */
+    virtual bool onDecode(SkStream*, SkBitmap* bitmap, SkBitmap::Config pref) = 0;
 
-       /**     Decode the image stored in the specified file, and store the result
-               in bitmap. Return true for success or false on failure.
+    /** Given a stream, this will try to find an appropriate decoder object.
+        If none is found, the method returns NULL.
+    */
+    static SkImageDecoder* Factory(SkStream*);
 
-               If pref is kNo_Config, then the decoder is free to choose the most natural
+    /** Decode the image stored in the specified file, and store the result
+        in bitmap. Return true for success or false on failure.
+
+        If pref is kNo_Config, then the decoder is free to choose the most natural
         config given the image data. If pref something other than kNo_Config,
-               the decoder will attempt to decode the image into that format, unless
-               there is a conflict (e.g. the image has per-pixel alpha and the bitmap's
-               config does not support that), in which case the decoder will choose a
-               closest match configuration.
-       */
-       static bool DecodeFile(const char file[], SkBitmap* bitmap,
+        the decoder will attempt to decode the image into that format, unless
+        there is a conflict (e.g. the image has per-pixel alpha and the bitmap's
+        config does not support that), in which case the decoder will choose a
+        closest match configuration.
+    */
+    static bool DecodeFile(const char file[], SkBitmap* bitmap,
                            SkBitmap::Config pref = SkBitmap::kNo_Config);
-       /**     Decode the image stored in the specified memory buffer, and store the result
-               in bitmap. Return true for success or false on failure.
+    /** Decode the image stored in the specified memory buffer, and store the result
+        in bitmap. Return true for success or false on failure.
 
-               If pref is kNo_Config, then the decoder is free to choose the most natural
+        If pref is kNo_Config, then the decoder is free to choose the most natural
         config given the image data. If pref something other than kNo_Config,
-               the decoder will attempt to decode the image into that format, unless
-               there is a conflict (e.g. the image has per-pixel alpha and the bitmap's
-               config does not support that), in which case the decoder will choose a
-               closest match configuration.
-       */
-       static bool DecodeMemory(const void* buffer, size_t size, SkBitmap* bitmap,
+        the decoder will attempt to decode the image into that format, unless
+        there is a conflict (e.g. the image has per-pixel alpha and the bitmap's
+        config does not support that), in which case the decoder will choose a
+        closest match configuration.
+    */
+    static bool DecodeMemory(const void* buffer, size_t size, SkBitmap* bitmap,
                              SkBitmap::Config pref = SkBitmap::kNo_Config);
-       /**     Decode the image stored in the specified SkStream, and store the result
-               in bitmap. Return true for success or false on failure.
+    /** Decode the image stored in the specified SkStream, and store the result
+        in bitmap. Return true for success or false on failure.
 
-               If pref is kNo_Config, then the decoder is free to choose the most natural
+        If pref is kNo_Config, then the decoder is free to choose the most natural
         config given the image data. If pref something other than kNo_Config,
-               the decoder will attempt to decode the image into that format, unless
-               there is a conflict (e.g. the image has per-pixel alpha and the bitmap's
-               config does not support that), in which case the decoder will choose a
-               closest match configuration.
-       */
-       static bool DecodeStream(SkStream*, SkBitmap* bitmap,
+        the decoder will attempt to decode the image into that format, unless
+        there is a conflict (e.g. the image has per-pixel alpha and the bitmap's
+        config does not support that), in which case the decoder will choose a
+        closest match configuration.
+    */
+    static bool DecodeStream(SkStream*, SkBitmap* bitmap,
                              SkBitmap::Config pref = SkBitmap::kNo_Config);
 
-       /**     Decode the image stored at the specified URL, and store the result
-               in bitmap. Return true for success or false on failure. The URL restrictions
-               are device dependent. On Win32 and WinCE, the URL may be ftp, http or
-               https.
+    /** Decode the image stored at the specified URL, and store the result
+        in bitmap. Return true for success or false on failure. The URL restrictions
+        are device dependent. On Win32 and WinCE, the URL may be ftp, http or
+        https.
 
-               If pref is kNo_Config, then the decoder is free to choose the most natural
+        If pref is kNo_Config, then the decoder is free to choose the most natural
         config given the image data. If pref something other than kNo_Config,
-               the decoder will attempt to decode the image into that format, unless
-               there is a conflict (e.g. the image has per-pixel alpha and the bitmap's
-               config does not support that), in which case the decoder will choose a
-               closest match configuration.
-       */
-       static bool DecodeURL(const char url[], SkBitmap* bitmap,
+        the decoder will attempt to decode the image into that format, unless
+        there is a conflict (e.g. the image has per-pixel alpha and the bitmap's
+        config does not support that), in which case the decoder will choose a
+        closest match configuration.
+    */
+    static bool DecodeURL(const char url[], SkBitmap* bitmap,
                           SkBitmap::Config pref = SkBitmap::kNo_Config);
 
-       /**     Return the default config for the running device.
-               Currently this used as a suggestion to image decoders that need to guess
-               what config they should decode into.
-               Default is kNo_Config, but this can be changed with SetDeviceConfig()
-       */
-       static SkBitmap::Config GetDeviceConfig();
-       /**     Set the default config for the running device.
-               Currently this used as a suggestion to image decoders that need to guess
-               what config they should decode into.
-               Default is kNo_Config.
-               This can be queried with GetDeviceConfig()
-       */
-       static void     SetDeviceConfig(SkBitmap::Config);
+    /** Return the default config for the running device.
+        Currently this used as a suggestion to image decoders that need to guess
+        what config they should decode into.
+        Default is kNo_Config, but this can be changed with SetDeviceConfig()
+    */
+    static SkBitmap::Config GetDeviceConfig();
+    /** Set the default config for the running device.
+        Currently this used as a suggestion to image decoders that need to guess
+        what config they should decode into.
+        Default is kNo_Config.
+        This can be queried with GetDeviceConfig()
+    */
+    static void SetDeviceConfig(SkBitmap::Config);
 
   /** @cond UNIT_TEST */
-       SkDEBUGCODE(static void UnitTest();)
+    SkDEBUGCODE(static void UnitTest();)
   /** @endcond */
 
 protected:
-       SkImageDecoder();
+    SkImageDecoder();
 
-       /**     Given a stream, decode it into the specified bitmap.
-               If the decoder can decompress the image, it should call setConfig() on the bitmap,
-        and then call allocPixels(), which will allocated offscreen memory for the pixels.
-        It can then set the pixels with the decompressed image. If the image cannot be
-        decompressed, return false and leave the bitmap unchanged.
-       */
-       virtual bool onDecode(SkStream*, SkBitmap* bitmap, SkBitmap::Config pref) = 0;
+    // helper function for decoders to handle the (common) case where there is only
+    // once choice available in the image file.
+    bool chooseFromOneChoice(SkBitmap::Config config, int width, int height) const;
 
 private:
-       static SkImageDecoder* Factory(SkStream*);
+    Peeker*  fPeeker;
+    Chooser* fChooser;
+
+    // illegal
+    SkImageDecoder(const SkImageDecoder&);
+    SkImageDecoder& operator=(const SkImageDecoder&);
 };
 
 #ifdef SK_SUPPORT_IMAGE_ENCODE
@@ -105,21 +170,21 @@ class SkWStream;
 
 class SkImageEncoder {
 public:
-       enum Type {
-               kJPEG_Type,
-               kPNG_Type
-       };
-       static SkImageEncoder* Create(Type);
+    enum Type {
+        kJPEG_Type,
+        kPNG_Type
+    };
+    static SkImageEncoder* Create(Type);
 
-       virtual ~SkImageEncoder();
+    virtual ~SkImageEncoder();
 
-       /*      Quality ranges from 0..100 */
+    /*  Quality ranges from 0..100 */
 
-       bool encodeFile(const char file[], const SkBitmap&, int quality = 80);
-       bool encodeStream(SkWStream*, const SkBitmap&, int quality = 80);
+    bool encodeFile(const char file[], const SkBitmap&, int quality = 80);
+    bool encodeStream(SkWStream*, const SkBitmap&, int quality = 80);
 
 protected:
-       virtual bool onEncode(SkWStream*, const SkBitmap&, int quality) = 0;
+    virtual bool onEncode(SkWStream*, const SkBitmap&, int quality) = 0;
 };
 
 #endif /* SK_SUPPORT_IMAGE_ENCODE */
index 78ee5b7..4735330 100644 (file)
@@ -1,3 +1,20 @@
+/* include/graphics/SkImageView.h
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #ifndef SkImageView_DEFINED
 #define SkImageView_DEFINED
 
@@ -10,50 +27,50 @@ struct SkMatrix;
 
 class SkImageView : public SkView {
 public:
-                       SkImageView();
-       virtual ~SkImageView();
-
-       void    getUri(SkString*) const;
-       void    setUri(const char []);
-       void    setUri(const SkString&);
-       
-
-       enum ScaleType {
-               kMatrix_ScaleType,
-               kFitXY_ScaleType,
-               kFitStart_ScaleType,
-               kFitCenter_ScaleType,
-               kFitEnd_ScaleType
-       };
-       ScaleType       getScaleType() const { return (ScaleType)fScaleType; }
-       void            setScaleType(ScaleType);
-       
-       bool    getImageMatrix(SkMatrix*) const;
-       void    setImageMatrix(const SkMatrix*);
+            SkImageView();
+    virtual ~SkImageView();
+
+    void    getUri(SkString*) const;
+    void    setUri(const char []);
+    void    setUri(const SkString&);
+    
+
+    enum ScaleType {
+        kMatrix_ScaleType,
+        kFitXY_ScaleType,
+        kFitStart_ScaleType,
+        kFitCenter_ScaleType,
+        kFitEnd_ScaleType
+    };
+    ScaleType   getScaleType() const { return (ScaleType)fScaleType; }
+    void        setScaleType(ScaleType);
+    
+    bool    getImageMatrix(SkMatrix*) const;
+    void    setImageMatrix(const SkMatrix*);
 
 protected:
-       // overrides
-       virtual bool    onEvent(const SkEvent&);
-       virtual void    onDraw(SkCanvas*);
-       virtual void    onInflate(const SkDOM&, const SkDOMNode*);
-       
+    // overrides
+    virtual bool    onEvent(const SkEvent&);
+    virtual void    onDraw(SkCanvas*);
+    virtual void    onInflate(const SkDOM&, const SkDOMNode*);
+    
 private:
-       SkString        fUri;
-       SkMatrix*       fMatrix;        // nil or copy of caller's matrix ,,,,,
-       union {
-               SkAnimator*     fAnim;
-               SkBitmap* fBitmap;
-       } fData;
-       U8                      fScaleType;
-       SkBool8         fDataIsAnim;    // as opposed to bitmap
-       SkBool8         fUriIsValid;
-       
-       void    onUriChange();
-       bool    getDataBounds(SkRect* bounds);
-       bool    freeData();
-       bool    ensureUriIsLoaded();
-
-       typedef SkView INHERITED;
+    SkString    fUri;
+    SkMatrix*   fMatrix;    // nil or copy of caller's matrix ,,,,,
+    union {
+        SkAnimator* fAnim;
+        SkBitmap* fBitmap;
+    } fData;
+    U8          fScaleType;
+    SkBool8     fDataIsAnim;    // as opposed to bitmap
+    SkBool8     fUriIsValid;
+    
+    void    onUriChange();
+    bool    getDataBounds(SkRect* bounds);
+    bool    freeData();
+    bool    ensureUriIsLoaded();
+
+    typedef SkView INHERITED;
 };
 
 #endif
diff --git a/include/graphics/SkInterpolator.h b/include/graphics/SkInterpolator.h
deleted file mode 100644 (file)
index c224c8c..0000000
+++ /dev/null
@@ -1,98 +0,0 @@
-#ifndef SkInterpolator_DEFINED
-#define SkInterpolator_DEFINED
-
-#include "SkMath.h"
-
-class SkInterpolatorBase {
-public:
-       enum Result {
-               kNormal_Result,
-               kFreezeStart_Result,
-               kFreezeEnd_Result
-       };
-       static SkScalar Blend(SkScalar t, SkScalar blend);
-protected:
-       SkInterpolatorBase();
-       ~SkInterpolatorBase();
-public:
-       void    reset(int elemCount, int frameCount);
-
-       /**     Return the start and end time for this interpolator.
-               If there are no key frames, return false.
-               @param  startTime       If no nil, returns the time (in milliseconds) of the
-                                                       first keyframe. If there are no keyframes, this parameter
-                                                       is ignored (left unchanged).
-               @param  endTime         If no nil, returns the time (in milliseconds) of the
-                                                       last keyframe. If there are no keyframes, this parameter
-                                                       is ignored (left unchanged).
-               @return True if there are key frames, or false if there are none.
-       */
-       bool    getDuration(SkMSec* startTime, SkMSec* endTime) const;
-
-
-       /**     Set the whether the repeat is mirrored.
-               @param If true, the odd repeats interpolate from the last key frame and the first.
-       */
-       void    setMirror(bool mirror) { fFlags = SkToU8(fFlags & ~kMirror | (int) mirror); }
-
-       /**     Set the repeat count. The repeat count may be fractional.
-               @param repeatCount Multiplies the total time by this scalar.
-       */
-       void    setRepeatCount(SkScalar repeatCount) { fRepeat = repeatCount; }
-
-       /**     Set the whether the repeat is mirrored.
-               @param If true, the odd repeats interpolate from the last key frame and the first.
-       */
-       void    setReset(bool reset) { fFlags = SkToU8(fFlags & ~kReset | (int) reset); }
-
-       Result  timeToT(SkMSec time, SkScalar* T, int* index, SkBool* exact) const;
-protected:
-       enum Flags {
-               kMirror = 1,
-               kReset = 2
-       };
-       static SkScalar ComputeRelativeT(SkMSec time, SkMSec prevTime, SkMSec nextTime, SkScalar blend);
-       S16 fFrameCount;
-       U8 fElemCount;
-       U8 fFlags;
-       SkScalar fRepeat;
-       struct SkTimeCode {
-               SkMSec fTime;
-               SkScalar fBlend;
-       };
-       SkTimeCode* fTimes;             // pointer into fStorage
-       void* fStorage;
-#ifdef SK_DEBUG
-       SkTimeCode(* fTimesArray)[10];
-#endif
-};
-
-class SkInterpolator : public SkInterpolatorBase {
-public:
-       SkInterpolator();
-       SkInterpolator(int elemCount, int frameCount);
-       void    reset(int elemCount, int frameCount);
-
-       /**     Add or replace a key frame, copying the values[] data into the interpolator.
-               @param index    The index of this frame (frames must be ordered by time)
-               @param time     The millisecond time for this frame
-               @param values   The array of values [elemCount] for this frame. The data is copied
-                                               into the interpolator.
-               @param blend    A positive scalar specifying how to blend between this and the next key frame.
-                                               [0...1) is a cubic lag/log/lag blend (slow to change at the beginning and end)
-                                               1 is a linear blend (default)
-       */
-       bool    setKeyFrame(int index, SkMSec time, const SkScalar values[], SkScalar blend = SK_Scalar1);
-       Result timeToValues(SkMSec time, SkScalar values[]) const;
-       SkDEBUGCODE(static void UnitTest();)
-private:
-       SkScalar* fValues;      // pointer into fStorage
-#ifdef SK_DEBUG
-       SkScalar(* fScalarsArray)[10];
-#endif
-       typedef SkInterpolatorBase INHERITED;
-};
-
-
-#endif
-
index 89fa4d7..f584d6f 100644 (file)
@@ -1,31 +1,48 @@
+/* include/graphics/SkJS.h
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #include "SkTypes.h"
 #include "SkWindow.h"
 
 extern "C" {
-       typedef long JSWord;
-       typedef JSWord jsword;
-       typedef jsword  jsval;
-       typedef struct JSRuntime JSRuntime;
-       typedef struct JSContext JSContext;
-       typedef struct JSObject JSObject;
+    typedef long JSWord;
+    typedef JSWord jsword;
+    typedef jsword  jsval;
+    typedef struct JSRuntime JSRuntime;
+    typedef struct JSContext JSContext;
+    typedef struct JSObject JSObject;
 }
 
 class SkString;
 
 class SkJS : public SkOSWindow {
 public:
-       SkJS(void* hwnd);
-       ~SkJS();
-       SkBool EvaluateScript(const char* script, jsval* rVal);
-       SkBool ValueToString(jsval value, SkString* string);
+    SkJS(void* hwnd);
+    ~SkJS();
+    SkBool EvaluateScript(const char* script, jsval* rVal);
+    SkBool ValueToString(jsval value, SkString* string);
 #ifdef SK_DEBUG
-       static void Test(void* hwnd);
+    static void Test(void* hwnd);
 #endif
 protected:
-       void InitializeDisplayables(const SkBitmap& , JSContext *, JSObject *, JSObject *);
-       void DisposeDisplayables();
-       JSRuntime *fRuntime;
+    void InitializeDisplayables(const SkBitmap& , JSContext *, JSObject *, JSObject *);
+    void DisposeDisplayables();
+    JSRuntime *fRuntime;
     JSContext *fContext;
-       JSObject *fGlobal;
+    JSObject *fGlobal;
 };
 
index 4a1297c..2d0a8aa 100644 (file)
@@ -1,3 +1,20 @@
+/* include/graphics/SkKey.h
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #ifndef SkKey_DEFINED
 #define SkKey_DEFINED
 
 
 enum SkKey {
     //reordering these to match android.app.KeyEvent 
-       kNONE_SkKey,    //corresponds to android's UNKNOWN
+    kNONE_SkKey,    //corresponds to android's UNKNOWN
     
-       kLeftSoftKey_SkKey,
-       kRightSoftKey_SkKey,
+    kLeftSoftKey_SkKey,
+    kRightSoftKey_SkKey,
 
     kHome_SkKey,    //!< the home key - added to match android
-    kBack_SkKey,       //!< (CLR)
-       kSend_SkKey,    //!< the green (talk) key
-       kEnd_SkKey,             //!< the red key
+    kBack_SkKey,    //!< (CLR)
+    kSend_SkKey,    //!< the green (talk) key
+    kEnd_SkKey,     //!< the red key
     
-       k0_SkKey,
-       k1_SkKey,
-       k2_SkKey,
-       k3_SkKey,
-       k4_SkKey,
-       k5_SkKey,
-       k6_SkKey,
-       k7_SkKey,
-       k8_SkKey,
-       k9_SkKey,
-       kStar_SkKey,    //!< the * key
-       kHash_SkKey,    //!< the # key
-
-       kUp_SkKey,
-       kDown_SkKey,
-       kLeft_SkKey,
-       kRight_SkKey,
-
-       kOK_SkKey,              //!< the center key
+    k0_SkKey,
+    k1_SkKey,
+    k2_SkKey,
+    k3_SkKey,
+    k4_SkKey,
+    k5_SkKey,
+    k6_SkKey,
+    k7_SkKey,
+    k8_SkKey,
+    k9_SkKey,
+    kStar_SkKey,    //!< the * key
+    kHash_SkKey,    //!< the # key
+
+    kUp_SkKey,
+    kDown_SkKey,
+    kLeft_SkKey,
+    kRight_SkKey,
+
+    kOK_SkKey,      //!< the center key
 
     kVolUp_SkKey,   //!< volume up - match android
     kVolDown_SkKey, //!< volume down - same
     kPower_SkKey,   //!< power button - same
     kCamera_SkKey,  //!< camera         - same
 
-       kSkKeyCount
+    kSkKeyCount
 };
 
 #endif
index 548968a..3f0acdb 100644 (file)
@@ -1,3 +1,20 @@
+/* include/graphics/SkLayerRasterizer.h
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #ifndef SkLayerRasterizer_DEFINED
 #define SkLayerRasterizer_DEFINED
 
@@ -19,8 +36,8 @@ public:
     void addLayer(const SkPaint& paint, SkScalar dx, SkScalar dy);
 
     // overrides from SkFlattenable
-       virtual Factory getFactory();
-       virtual void    flatten(SkWBuffer&);
+    virtual Factory getFactory();
+    virtual void    flatten(SkWBuffer&);
 
 protected:
     SkLayerRasterizer(SkRBuffer&);
index 8fdf461..8080d87 100644 (file)
@@ -1,58 +1,76 @@
+/* include/graphics/SkMask.h
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #ifndef SkMask_DEFINED
 #define SkMask_DEFINED
 
 #include "SkRect.h"
 
-/**    \class SkMask
-       SkMask is used to describe alpha bitmaps, either 1bit, 8bit, or
-       the 3-channel 3D format. These are passed to SkMaskFilter objects.
+/** \class SkMask
+    SkMask is used to describe alpha bitmaps, either 1bit, 8bit, or
+    the 3-channel 3D format. These are passed to SkMaskFilter objects.
 */
 struct SkMask {
-       enum Format {
-               kBW_Format,     //!< 1bit per pixel mask (e.g. monochrome)
-               kA8_Format,     //!< 8bits per pixel mask (e.g. antialiasing)
-               k3D_Format      //!< 3 8bit per pixl planes: alpha, mul, add
-       };
+    enum Format {
+        kBW_Format, //!< 1bit per pixel mask (e.g. monochrome)
+        kA8_Format, //!< 8bits per pixel mask (e.g. antialiasing)
+        k3D_Format, //!< 3 8bit per pixl planes: alpha, mul, add
+        kLCD_Format //!< 3 bytes/pixel: r/g/b
+    };
 
-       uint8_t*        fImage;
-       SkRect16        fBounds;
-       uint16_t        fRowBytes;
-       uint8_t         fFormat;        // Format
+    uint8_t*    fImage;
+    SkRect16    fBounds;
+    uint16_t    fRowBytes;
+    uint8_t     fFormat;    // Format
 
-       /**     Return the byte size of the mask, assuming only 1 plane.
-               Does not account for k3D_Format. For that, use computeFormatImageSize()
-       */
-       size_t computeImageSize() const;
-       /**     Return the byte size of the mask, taking into account
-               any extra planes (e.g. k3D_Format).
-       */
-       size_t computeTotalImageSize() const;
+    /** Return the byte size of the mask, assuming only 1 plane.
+        Does not account for k3D_Format. For that, use computeFormatImageSize()
+    */
+    size_t computeImageSize() const;
+    /** Return the byte size of the mask, taking into account
+        any extra planes (e.g. k3D_Format).
+    */
+    size_t computeTotalImageSize() const;
 
-       /**     Returns the address of the byte that holds the specified bit.
-               Asserts that the mask is kBW_Format, and that x,y are in range.
-               x,y are in the same coordiate space as fBounds.
-       */
-       uint8_t* getAddr1(int x, int y) const
-       {
-               SkASSERT(fFormat == kBW_Format);
-               SkASSERT(fBounds.contains(x, y));
-               SkASSERT(fImage != nil);
-               return fImage + ((x - fBounds.fLeft) >> 3) + (y - fBounds.fTop) * fRowBytes;
-       }
-       /**     Returns the address of the specified byte.
-               Asserts that the mask is kA8_Format, and that x,y are in range.
-               x,y are in the same coordiate space as fBounds.
-       */
-       uint8_t* getAddr(int x, int y) const
-       {
-               SkASSERT(fFormat != kBW_Format);
-               SkASSERT(fBounds.contains(x, y));
-               SkASSERT(fImage != nil);
-               return fImage + x - fBounds.fLeft + (y - fBounds.fTop) * fRowBytes;
-       }
+    /** Returns the address of the byte that holds the specified bit.
+        Asserts that the mask is kBW_Format, and that x,y are in range.
+        x,y are in the same coordiate space as fBounds.
+    */
+    uint8_t* getAddr1(int x, int y) const
+    {
+        SkASSERT(fFormat == kBW_Format);
+        SkASSERT(fBounds.contains(x, y));
+        SkASSERT(fImage != nil);
+        return fImage + ((x - fBounds.fLeft) >> 3) + (y - fBounds.fTop) * fRowBytes;
+    }
+    /** Returns the address of the specified byte.
+        Asserts that the mask is kA8_Format, and that x,y are in range.
+        x,y are in the same coordiate space as fBounds.
+    */
+    uint8_t* getAddr(int x, int y) const
+    {
+        SkASSERT(fFormat != kBW_Format);
+        SkASSERT(fBounds.contains(x, y));
+        SkASSERT(fImage != nil);
+        return fImage + x - fBounds.fLeft + (y - fBounds.fTop) * fRowBytes;
+    }
 
-       static uint8_t* AllocImage(size_t bytes);
-       static void     FreeImage(uint8_t* image);
+    static uint8_t* AllocImage(size_t bytes);
+    static void FreeImage(uint8_t* image);
     
     enum CreateMode {
         kJustComputeBounds_CreateMode,      //!< compute bounds and return
index f844e36..4fe64c6 100644 (file)
@@ -1,3 +1,20 @@
+/* include/graphics/SkMaskFilter.h
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #ifndef SkMaskFilter_DEFINED
 #define SkMaskFilter_DEFINED
 
@@ -10,73 +27,73 @@ class SkMatrix;
 class SkPath;
 class SkRegion;
 
-/**    \class SkMaskFilter
+/** \class SkMaskFilter
 
-       SkMaskFilter is the base class for object that perform transformations on
-       an alpha-channel mask before drawing it. A subclass of SkMaskFilter may be
-       installed into a SkPaint. Once there, each time a primitive is drawn, it
-       is first scan converted into a SkMask::kA8_Format mask, and handed to the
-       filter, calling its filterMask() method. If this returns true, then the
-       new mask is used to render into the device.
+    SkMaskFilter is the base class for object that perform transformations on
+    an alpha-channel mask before drawing it. A subclass of SkMaskFilter may be
+    installed into a SkPaint. Once there, each time a primitive is drawn, it
+    is first scan converted into a SkMask::kA8_Format mask, and handed to the
+    filter, calling its filterMask() method. If this returns true, then the
+    new mask is used to render into the device.
 
-       Blur and emboss are implemented as subclasses of SkMaskFilter.
+    Blur and emboss are implemented as subclasses of SkMaskFilter.
 */
 class SkMaskFilter : public SkFlattenable {
 public:
     SkMaskFilter() {}
 
-       /**     Returns the format of the resulting mask that this subclass will return
-               when its filterMask() method is called.
-       */
-       virtual SkMask::Format  getFormat() = 0;
+    /** Returns the format of the resulting mask that this subclass will return
+        when its filterMask() method is called.
+    */
+    virtual SkMask::Format  getFormat() = 0;
 
-       /**     Create a new mask by filter the src mask.
-               If src.fImage == nil, then do not allocate or create the dst image
-               but do fill out the other fields in dstMask.
-               If you do allocate a dst image, use SkMask::AllocImage()
-               If this returns false, dst mask is ignored.
-               @param  dst     the result of the filter. If src.fImage == nil, dst should not allocate its image
-               @param src the original image to be filtered.
-               @param matrix the CTM
-               @param margin   if not nil, return the buffer dx/dy need when calculating the effect. Used when
-                                               drawing a clipped object to know how much larger to allocate the src before
-                                               applying the filter.
-               @return true if the dst mask was correctly created.
-       */
-       virtual bool filterMask(SkMask* dst, const SkMask& src, const SkMatrix&, SkPoint16* margin);
+    /** Create a new mask by filter the src mask.
+        If src.fImage == nil, then do not allocate or create the dst image
+        but do fill out the other fields in dstMask.
+        If you do allocate a dst image, use SkMask::AllocImage()
+        If this returns false, dst mask is ignored.
+        @param  dst the result of the filter. If src.fImage == nil, dst should not allocate its image
+        @param src the original image to be filtered.
+        @param matrix the CTM
+        @param margin   if not nil, return the buffer dx/dy need when calculating the effect. Used when
+                        drawing a clipped object to know how much larger to allocate the src before
+                        applying the filter.
+        @return true if the dst mask was correctly created.
+    */
+    virtual bool filterMask(SkMask* dst, const SkMask& src, const SkMatrix&, SkPoint16* margin);
 
-       /**     Helper method that, given a path in device space, will rasterize it into a kA8_Format mask
-               and then call filterMask(). If this returns true, the specified blitter will be called
-               to render that mask. Returns false if filterMask() returned false.
+    /** Helper method that, given a path in device space, will rasterize it into a kA8_Format mask
+        and then call filterMask(). If this returns true, the specified blitter will be called
+        to render that mask. Returns false if filterMask() returned false.
         This method is not exported to java.
-       */
-       bool filterPath(const SkPath& devPath, const SkMatrix& devMatrix,
-                                       const SkRegion& devClip, SkBounder*, SkBlitter* blitter);
+    */
+    bool filterPath(const SkPath& devPath, const SkMatrix& devMatrix,
+                    const SkRegion& devClip, SkBounder*, SkBlitter* blitter);
 
 protected:
     // empty for now, but lets get our subclass to remember to init us for the future
     SkMaskFilter(SkRBuffer&) {}
 };
 
-/**    \class SkAutoMaskImage
+/** \class SkAutoMaskImage
 
-       Stack class used to manage the fImage buffer in a SkMask.
-       When this object loses scope, the buffer is freed with SkMask::FreeImage().
+    Stack class used to manage the fImage buffer in a SkMask.
+    When this object loses scope, the buffer is freed with SkMask::FreeImage().
 */
 class SkAutoMaskImage {
 public:
-       SkAutoMaskImage(SkMask* mask, bool alloc)
-       {
-               if (alloc)
-                       mask->fImage = SkMask::AllocImage(mask->computeImageSize());
-               fImage = mask->fImage;
-       }
-       ~SkAutoMaskImage()
-       {
-               SkMask::FreeImage(fImage);
-       }
+    SkAutoMaskImage(SkMask* mask, bool alloc)
+    {
+        if (alloc)
+            mask->fImage = SkMask::AllocImage(mask->computeImageSize());
+        fImage = mask->fImage;
+    }
+    ~SkAutoMaskImage()
+    {
+        SkMask::FreeImage(fImage);
+    }
 private:
-       uint8_t*    fImage;
+    uint8_t*    fImage;
 };
 
 #endif
index b3b80eb..0db21f2 100644 (file)
@@ -1,3 +1,20 @@
+/* include/graphics/SkMetaData.h
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #ifndef SkMetaData_DEFINED
 #define SkMetaData_DEFINED
 
 
 class SkMetaData {
 public:
-       SkMetaData();
-       SkMetaData(const SkMetaData& src);
-       ~SkMetaData();
-
-       SkMetaData&     operator=(const SkMetaData& src);
-
-       void    reset();
-
-       bool    findS32(const char name[], int32_t* value = nil) const;
-       bool    findScalar(const char name[], SkScalar* value = nil) const;
-       const SkScalar* findScalars(const char name[], int* count, SkScalar values[] = nil) const;
-       const char*     findString(const char name[]) const;
-       bool    findPtr(const char name[], void** value = nil) const;
-       bool    findBool(const char name[], bool* value = nil) const;
-
-       bool    hasS32(const char name[], int32_t value) const
-       {
-               int32_t v;
-               return this->findS32(name, &v) && v == value;
-       }
-       bool    hasScalar(const char name[], SkScalar value) const
-       {
-               SkScalar        v;
-               return this->findScalar(name, &v) && v == value;
-       }
-       bool    hasString(const char name[], const char value[]) const
-       {
-               const char* v = this->findString(name);
-               return  v == nil && value == nil ||
-                               v != nil && value != nil && !strcmp(v, value);
-       }
-       bool    hasPtr(const char name[], void* value) const
-       {
-               void*   v;
-               return this->findPtr(name, &v) && v == value;
-       }
-       bool    hasBool(const char name[], bool value) const
-       {
-               bool    v;
-               return this->findBool(name, &v) && v == value;
-       }
-
-       void    setS32(const char name[], int32_t value);
-       void    setScalar(const char name[], SkScalar value);
-       SkScalar* setScalars(const char name[], int count, const SkScalar values[] = nil);
-       void    setString(const char name[], const char value[]);
-       void    setPtr(const char name[], void* value);
-       void    setBool(const char name[], bool value);
-
-       bool    removeS32(const char name[]);
-       bool    removeScalar(const char name[]);
-       bool    removeString(const char name[]);
-       bool    removePtr(const char name[]);
-       bool    removeBool(const char name[]);
-
-       SkDEBUGCODE(static void UnitTest();)
-
-       enum Type {
-               kS32_Type,
-               kScalar_Type,
-               kString_Type,
-               kPtr_Type,
-               kBool_Type,
-
-               kTypeCount
-       };
-
-       struct Rec;
-       class Iter;
-       friend class Iter;
-
-       class Iter {
-       public:
-               Iter() : fRec(nil) {}
-               Iter(const SkMetaData&);
-
-               /**     Reset the iterator, so that calling next() will return the first
-                       data element. This is done implicitly in the constructor.
-               */
-               void    reset(const SkMetaData&);
-
-               /**     Each time next is called, it returns the name of the next data element,
-                       or nil when there are no more elements. If non-nil is returned, then the
-                       element's type is returned (if not nil), and the number of data values
-                       is returned in count (if not nil).
-               */
-               const char*     next(Type*, int* count);
-
-       private:
-               Rec* fRec;
-       };
+    SkMetaData();
+    SkMetaData(const SkMetaData& src);
+    ~SkMetaData();
+
+    SkMetaData& operator=(const SkMetaData& src);
+
+    void    reset();
+
+    bool    findS32(const char name[], int32_t* value = nil) const;
+    bool    findScalar(const char name[], SkScalar* value = nil) const;
+    const SkScalar* findScalars(const char name[], int* count, SkScalar values[] = nil) const;
+    const char* findString(const char name[]) const;
+    bool    findPtr(const char name[], void** value = nil) const;
+    bool    findBool(const char name[], bool* value = nil) const;
+
+    bool    hasS32(const char name[], int32_t value) const
+    {
+        int32_t v;
+        return this->findS32(name, &v) && v == value;
+    }
+    bool    hasScalar(const char name[], SkScalar value) const
+    {
+        SkScalar    v;
+        return this->findScalar(name, &v) && v == value;
+    }
+    bool    hasString(const char name[], const char value[]) const
+    {
+        const char* v = this->findString(name);
+        return  v == nil && value == nil ||
+                v != nil && value != nil && !strcmp(v, value);
+    }
+    bool    hasPtr(const char name[], void* value) const
+    {
+        void*   v;
+        return this->findPtr(name, &v) && v == value;
+    }
+    bool    hasBool(const char name[], bool value) const
+    {
+        bool    v;
+        return this->findBool(name, &v) && v == value;
+    }
+
+    void    setS32(const char name[], int32_t value);
+    void    setScalar(const char name[], SkScalar value);
+    SkScalar* setScalars(const char name[], int count, const SkScalar values[] = nil);
+    void    setString(const char name[], const char value[]);
+    void    setPtr(const char name[], void* value);
+    void    setBool(const char name[], bool value);
+
+    bool    removeS32(const char name[]);
+    bool    removeScalar(const char name[]);
+    bool    removeString(const char name[]);
+    bool    removePtr(const char name[]);
+    bool    removeBool(const char name[]);
+
+    SkDEBUGCODE(static void UnitTest();)
+
+    enum Type {
+        kS32_Type,
+        kScalar_Type,
+        kString_Type,
+        kPtr_Type,
+        kBool_Type,
+
+        kTypeCount
+    };
+
+    struct Rec;
+    class Iter;
+    friend class Iter;
+
+    class Iter {
+    public:
+        Iter() : fRec(nil) {}
+        Iter(const SkMetaData&);
+
+        /** Reset the iterator, so that calling next() will return the first
+            data element. This is done implicitly in the constructor.
+        */
+        void    reset(const SkMetaData&);
+
+        /** Each time next is called, it returns the name of the next data element,
+            or nil when there are no more elements. If non-nil is returned, then the
+            element's type is returned (if not nil), and the number of data values
+            is returned in count (if not nil).
+        */
+        const char* next(Type*, int* count);
+
+    private:
+        Rec* fRec;
+    };
 
 public:
-       struct Rec {
-               Rec*        fNext;
-               uint16_t        fDataCount;     // number of elements
-               uint8_t         fDataLen;       // sizeof a single element
+    struct Rec {
+        Rec*        fNext;
+        uint16_t    fDataCount; // number of elements
+        uint8_t     fDataLen;   // sizeof a single element
 #ifdef SK_DEBUG
-               Type            fType;
+        Type        fType;
 #else
-               uint8_t         fType;
+        uint8_t     fType;
 #endif
 
 #ifdef SK_DEBUG
-               const char* fName;
-               union {
-                       int32_t     fS32;
-                       SkScalar        fScalar;
-                       const char*     fString;
-                       void*           fPtr;
-                       bool            fBool;
-               } fData;
+        const char* fName;
+        union {
+            int32_t     fS32;
+            SkScalar    fScalar;
+            const char* fString;
+            void*       fPtr;
+            bool        fBool;
+        } fData;
 #endif
 
-               const void*     data() const { return (this + 1); }
-               void*           data() { return (this + 1); }
-               const char*     name() const { return (const char*)this->data() + fDataLen * fDataCount; }
-               char*           name() { return (char*)this->data() + fDataLen * fDataCount; }
+        const void* data() const { return (this + 1); }
+        void*       data() { return (this + 1); }
+        const char* name() const { return (const char*)this->data() + fDataLen * fDataCount; }
+        char*       name() { return (char*)this->data() + fDataLen * fDataCount; }
 
-               static Rec* Alloc(size_t);
-               static void Free(Rec*);
-       };
-       Rec*    fRec;
+        static Rec* Alloc(size_t);
+        static void Free(Rec*);
+    };
+    Rec*    fRec;
 
-       const Rec* find(const char name[], Type) const;
-       void* set(const char name[], const void* data, size_t len, Type, int count);
-       bool remove(const char name[], Type);
+    const Rec* find(const char name[], Type) const;
+    void* set(const char name[], const void* data, size_t len, Type, int count);
+    bool remove(const char name[], Type);
 };
 
 #endif
index 5cc48c1..97ee0bb 100644 (file)
@@ -1,3 +1,20 @@
+/* include/graphics/SkNinePatch.h
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #ifndef SkNinePatch_DEFINED
 #define SkNinePatch_DEFINED
 
index 6baef7d..a311741 100644 (file)
@@ -1,3 +1,20 @@
+/* include/graphics/SkOSFile.h
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 // Copyright Skia Inc. 2004 - 2005
 // 
 #ifndef SkOSFile_DEFINED
 #include "SkString.h"
 
 #if defined(SK_BUILD_FOR_MAC) || defined(SK_BUILD_FOR_UNIX)
-       #include <dirent.h>
+    #include <dirent.h>
 #endif
 
 struct SkFILE;
 
 enum SkFILE_Flags {
-       kRead_SkFILE_Flag       = 0x01,
-       kWrite_SkFILE_Flag      = 0x02
+    kRead_SkFILE_Flag   = 0x01,
+    kWrite_SkFILE_Flag  = 0x02
 };
 
-SkFILE*        sk_fopen(const char path[], SkFILE_Flags);
-void   sk_fclose(SkFILE*);
+SkFILE* sk_fopen(const char path[], SkFILE_Flags);
+void    sk_fclose(SkFILE*);
 
-size_t sk_fgetsize(SkFILE*);
-/**    Return true if the file could seek back to the beginning
+size_t  sk_fgetsize(SkFILE*);
+/** Return true if the file could seek back to the beginning
 */
-bool   sk_frewind(SkFILE*);
+bool    sk_frewind(SkFILE*);
 
-size_t sk_fread(void* buffer, size_t byteCount, SkFILE*);
-size_t sk_fwrite(const void* buffer, size_t byteCount, SkFILE*);
-void   sk_fflush(SkFILE*);
+size_t  sk_fread(void* buffer, size_t byteCount, SkFILE*);
+size_t  sk_fwrite(const void* buffer, size_t byteCount, SkFILE*);
+void    sk_fflush(SkFILE*);
 
-int            sk_fseek( SkFILE*, size_t, int );
-size_t sk_ftell( SkFILE* );
+int     sk_fseek( SkFILE*, size_t, int );
+size_t  sk_ftell( SkFILE* );
 
 class SkOSFile {
 public:
-       class Iter {
-       public:
-               Iter();
-               Iter(const char path[], const char suffix[] = nil);
-               ~Iter();
+    class Iter {
+    public:
+        Iter();
+        Iter(const char path[], const char suffix[] = nil);
+        ~Iter();
 
-               void reset(const char path[], const char suffix[] = nil);
-               bool next(SkString* name, bool getDir = false);
+        void reset(const char path[], const char suffix[] = nil);
+        bool next(SkString* name, bool getDir = false);
 
-       private:
+    private:
 #ifdef SK_BUILD_FOR_WIN
-               HANDLE          fHandle;
-               U16*            fPath16;
+        HANDLE      fHandle;
+        U16*        fPath16;
 #elif defined(SK_BUILD_FOR_MAC) || defined(SK_BUILD_FOR_UNIX)
-               DIR*            fDIR;
-               SkString        fPath, fSuffix;
+        DIR*        fDIR;
+        SkString    fPath, fSuffix;
 #endif
-       };
+    };
 };
 
 class SkUTF16_Str {
 public:
-       SkUTF16_Str(const char src[]);
-       ~SkUTF16_Str()
-       {
-               sk_free(fStr);
-       }
-       const U16* get() const { return fStr; }
+    SkUTF16_Str(const char src[]);
+    ~SkUTF16_Str()
+    {
+        sk_free(fStr);
+    }
+    const U16* get() const { return fStr; }
 
 private:
-       U16*    fStr;
+    U16*    fStr;
 };
 
 #endif
index 4cf52e7..d83c2ae 100644 (file)
@@ -1,3 +1,20 @@
+/* include/graphics/SkOSMenu.h
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #ifndef SkOSMenu_DEFINED
 #define SkOSMenu_DEFINED
 
 
 class SkOSMenu {
 public:
-       explicit SkOSMenu(const char title[]);
-       ~SkOSMenu();
+    explicit SkOSMenu(const char title[]);
+    ~SkOSMenu();
 
-       const char*     getTitle() const { return fTitle; }
+    const char* getTitle() const { return fTitle; }
 
-       void    appendItem(const char title[], const char eventType[], S32 eventData);
+    void    appendItem(const char title[], const char eventType[], S32 eventData);
 
-       // called by SkOSWindow when it receives an OS menu event
-       int             countItems() const;
-       const char*     getItem(int index, U32* cmdID) const;
+    // called by SkOSWindow when it receives an OS menu event
+    int     countItems() const;
+    const char* getItem(int index, U32* cmdID) const;
 
-       SkEvent* createEvent(U32 os_cmd);
+    SkEvent* createEvent(U32 os_cmd);
 
 private:
-       const char*     fTitle;
-
-       struct Item {
-               const char*     fTitle;
-               const char*     fEventType;
-               U32                     fEventData;
-               U32                     fOSCmd; // internal
-       };
-       SkTDArray<Item> fItems;
-
-       // illegal
-       SkOSMenu(const SkOSMenu&);
-       SkOSMenu& operator=(const SkOSMenu&);
+    const char* fTitle;
+
+    struct Item {
+        const char* fTitle;
+        const char* fEventType;
+        U32         fEventData;
+        U32         fOSCmd; // internal
+    };
+    SkTDArray<Item> fItems;
+
+    // illegal
+    SkOSMenu(const SkOSMenu&);
+    SkOSMenu& operator=(const SkOSMenu&);
 };
 
 #endif
index 2e4262b..ed8a7ce 100644 (file)
@@ -1,3 +1,20 @@
+/* include/graphics/SkOSSound.h
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #ifndef SkOSSound_DEFINED
 #define SkOSSound_DEFINED
 
 
 class SkOSSound {
 public:
-       static void Play(const char path[]);
-       static void Pause();
-       static void Resume();
-       static bool TogglePause();      // returns true if we are now playing, or false if we're now paused
-       static void Stop();
+    static void Play(const char path[]);
+    static void Pause();
+    static void Resume();
+    static bool TogglePause();  // returns true if we are now playing, or false if we're now paused
+    static void Stop();
 
-       //      volume runs from 0 (silent) to 0xFF (max-volume)
-       static U8       GetVolume();
-       static void SetVolume(U8CPU volume);
+    //  volume runs from 0 (silent) to 0xFF (max-volume)
+    static U8   GetVolume();
+    static void SetVolume(U8CPU volume);
 };
 
 #endif
index b37b652..919c2e4 100644 (file)
@@ -1,3 +1,20 @@
+/* include/graphics/SkOSWindow_Mac.h
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #ifndef SkOSWindow_Mac_DEFINED
 #define SkOSWindow_Mac_DEFINED
 
 
 class SkOSWindow : public SkWindow {
 public:
-       SkOSWindow(void* hwnd);
+    SkOSWindow(void* hwnd);
 
-       void*   getHWND() const { return fHWND; }
-       void    updateSize();
+    void*   getHWND() const { return fHWND; }
+    void    updateSize();
 
-       static bool PostEvent(SkEvent* evt, SkEventSinkID, SkMSec delay);
+    static bool PostEvent(SkEvent* evt, SkEventSinkID, SkMSec delay);
 
-       static pascal OSStatus SkOSWindow::EventHandler( EventHandlerCallRef inHandler, EventRef inEvent, void* userData );
+    static pascal OSStatus SkOSWindow::EventHandler( EventHandlerCallRef inHandler, EventRef inEvent, void* userData );
 
 protected:
-       // overrides from SkWindow
-       virtual void onHandleInval(const SkRect16&);
-       // overrides from SkView
-       virtual void onAddMenu(const SkOSMenu*);
+    // overrides from SkWindow
+    virtual void onHandleInval(const SkRect16&);
+    // overrides from SkView
+    virtual void onAddMenu(const SkOSMenu*);
 
 private:
-       void*   fHWND;
+    void*   fHWND;
 
-       void    doPaint(void* ctx);
+    void    doPaint(void* ctx);
 
-       typedef SkWindow INHERITED;
+    typedef SkWindow INHERITED;
 };
 
 #endif
index 5c1b1eb..3f29f09 100644 (file)
@@ -1,3 +1,20 @@
+/* include/graphics/SkOSWindow_Unix.h
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #ifndef SkOSWindow_Unix_DEFINED
 #define SkOSWindow_Unix_DEFINED
 
@@ -12,32 +29,32 @@ struct SkUnixWindow {
 
 class SkOSWindow : public SkWindow {
 public:
-       SkOSWindow(Display* display, Window win);
+    SkOSWindow(Display* display, Window win);
 
-       void*   getHWND() const { return (void*)fUnixWindow.fWin; }
+    void*   getHWND() const { return (void*)fUnixWindow.fWin; }
   void* getDisplay() const { return (void*)fUnixWindow.fDisplay; }
   void* getUnixWindow() const { return (void*)&fUnixWindow; }
-  void setSize(int width, int height);
-       void    updateSize();
+  void  setSize(int width, int height);
+    void    updateSize();
 
-       static bool PostEvent(SkEvent* evt, SkEventSinkID, SkMSec delay);
+    static bool PostEvent(SkEvent* evt, SkEventSinkID, SkMSec delay);
 
-       static bool WndProc(SkUnixWindow* w,  XEvent &e);
+    static bool WndProc(SkUnixWindow* w,  XEvent &e);
 
 protected:
-       // overrides from SkWindow
-       virtual void onHandleInval(const SkRect16&);
-       // overrides from SkView
-       virtual void onAddMenu(const SkOSMenu*);
+    // overrides from SkWindow
+    virtual void onHandleInval(const SkRect16&);
+    // overrides from SkView
+    virtual void onAddMenu(const SkOSMenu*);
 
 private:
-       SkUnixWindow  fUnixWindow;
+    SkUnixWindow  fUnixWindow;
 
-       void    doPaint();
+    void    doPaint();
 
-       void*   fMBar;
+    void*   fMBar;
 
-       typedef SkWindow INHERITED;
+    typedef SkWindow INHERITED;
 };
 
 #endif
index b213a05..e82aa65 100644 (file)
@@ -1,3 +1,20 @@
+/* include/graphics/SkOSWindow_Win.h
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #ifndef SkOSWindow_Win_DEFINED
 #define SkOSWindow_Win_DEFINED
 
 
 class SkOSWindow : public SkWindow {
 public:
-       SkOSWindow(void* hwnd);
+    SkOSWindow(void* hwnd);
 
-       void*   getHWND() const { return fHWND; }
-       void    setSize(int width, int height);
-       void    updateSize();
+    void*   getHWND() const { return fHWND; }
+    void    setSize(int width, int height);
+    void    updateSize();
 
-       static bool PostEvent(SkEvent* evt, SkEventSinkID, SkMSec delay);
+    static bool PostEvent(SkEvent* evt, SkEventSinkID, SkMSec delay);
 
-       static bool WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
-       static bool SkOSWindow::QuitOnDeactivate(HWND hWnd);
+    static bool WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
+    static bool SkOSWindow::QuitOnDeactivate(HWND hWnd);
 
-       enum {
-               SK_WM_SkEvent = WM_APP + 1000,
-               SK_WM_SkTimerID = 0xFFFF        // just need a non-zero value
-       };
+    enum {
+        SK_WM_SkEvent = WM_APP + 1000,
+        SK_WM_SkTimerID = 0xFFFF    // just need a non-zero value
+    };
 
 protected:
-       virtual bool quitOnDeactivate() { return true; }
+    virtual bool quitOnDeactivate() { return true; }
 
-       // overrides from SkWindow
-       virtual void onHandleInval(const SkRect16&);
-       // overrides from SkView
-       virtual void onAddMenu(const SkOSMenu*);
+    // overrides from SkWindow
+    virtual void onHandleInval(const SkRect16&);
+    // overrides from SkView
+    virtual void onAddMenu(const SkOSMenu*);
 
 private:
-       void*   fHWND;
+    void*   fHWND;
 
-       void    doPaint(void* ctx);
+    void    doPaint(void* ctx);
 
-       HMENU   fMBar;
+    HMENU   fMBar;
 
-       typedef SkWindow INHERITED;
+    typedef SkWindow INHERITED;
 };
 
 #endif
index 1f526c0..d3f4f5c 100644 (file)
@@ -1,3 +1,20 @@
+/* include/graphics/SkOSWindow_wxwidgets.h
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 /*
  *  SkOSWindow_wxwidgets.h
  *  wxwidgets
 class SkOSWindow: public SkWindow
 {
 public:
-       SkOSWindow();
+    SkOSWindow();
     SkOSWindow(const wxString& title, int x, int y, int width, int height);
     ~SkOSWindow();
-       
-       wxFrame* getWXFrame() const { return fFrame; }
-       
-       void updateSize();
-       
+    
+    wxFrame* getWXFrame() const { return fFrame; }
+    
+    void updateSize();
+    
 protected:
     virtual void onHandleInval(const SkRect16&);
     virtual void onAddMenu(const SkOSMenu*);
@@ -34,4 +51,5 @@ private:
     
 };
 
-#endif
\ No newline at end of file
+#endifpedef SkWindow INHERITED;
+
index 5c1a036..bd0cc00 100644 (file)
@@ -1,3 +1,20 @@
+/* include/graphics/SkPaint.h
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #ifndef SkPaint_DEFINED
 #define SkPaint_DEFINED
 
@@ -6,6 +23,7 @@
 #include "SkPorterDuff.h"
 
 class SkColorFilter;
+struct SkGlyph;
 class SkGlyphCache;
 class SkMaskFilter;
 class SkMatrix;
@@ -13,371 +31,365 @@ class SkPath;
 class SkPathEffect;
 class SkRasterizer;
 class SkShader;
-class SkTextLayout;
 class SkTypeface;
 class SkXfermode;
 
-typedef SkUnichar (*SkUnicodeWalkerProc)(const char** text);
+typedef const SkGlyph& (*SkGlyphCacheProc)(SkGlyphCache*, const char**);
 
-/**    \class SkPaint
+/** \class SkPaint
 
-       The SkPaint class holds the style and color information about how to draw geometries, text and bitmaps.
+    The SkPaint class holds the style and color information about how to draw geometries, text and bitmaps.
 */
 class SkPaint {
 public:
-       SkPaint();
-       SkPaint(const SkPaint& paint);
-       ~SkPaint();
+    SkPaint();
+    SkPaint(const SkPaint& paint);
+    ~SkPaint();
 
-       SkPaint& operator=(const SkPaint&);
+    SkPaint& operator=(const SkPaint&);
 
-       friend int operator==(const SkPaint& a, const SkPaint& b);
-       friend int operator!=(const SkPaint& a, const SkPaint& b) { return !(a == b); }
+    friend int operator==(const SkPaint& a, const SkPaint& b);
+    friend int operator!=(const SkPaint& a, const SkPaint& b) { return !(a == b); }
 
-       /**     Restores the paint to its initial settings.
-       */
-       void    reset();
+    /** Restores the paint to its initial settings.
+    */
+    void    reset();
 
     /** FlagShift enum specifies the amount to bit-shift for a given flag setting.
         Can be used to slide a boolean value into the correct position (e.g.
         flags |= isAntiAlias << kAntiAlias_Shift;
     */
-       enum FlagShift {
-               kAntiAlias_Shift,               //!< bit position for the flag enabling antialiasing
-               kLinearText_Shift       ,       //!< bit position for the flag enabling linear-text (no gridding)
-               kUnderlineText_Shift,   //!< bit position for the flag enabling underline text
-               kStrikeThruText_Shift,  //!< bit position for the flag enabling strike-thru text
+    enum FlagShift {
+        kAntiAlias_Shift,       //!< bit position for the flag enabling antialiasing
+        kLinearText_Shift   ,   //!< bit position for the flag enabling linear-text (no gridding)
+        kUnderlineText_Shift,   //!< bit position for the flag enabling underline text
+        kStrikeThruText_Shift,  //!< bit position for the flag enabling strike-thru text
         kFakeBoldText_Shift,    //!< bit position for the flag enabling fake-bold text
+        kLCDText_Shift,
+        kNativeHintsText_Shift,
 
-               kFlagShiftCount
-       };
+        kFlagShiftCount
+    };
     
-    /** FlagMask enum specifies the bit values that are stored in the paint's flags.
+    /** Flag enum specifies the bit values that are stored in the paint's flags.
     */
-       enum FlagMask {
-               kAntiAlias_Mask         = 1 << kAntiAlias_Shift,                //!< bit mask for the flag enabling antialiasing
-               kLinearText_Mask        = 1 << kLinearText_Shift,               //!< bit mask for the flag enabling linear-text (no gridding)
-               kUnderlineText_Mask     = 1 << kUnderlineText_Shift,    //!< bit mask for the flag enabling underline text
-               kStrikeThruText_Mask= 1 << kStrikeThruText_Shift,       //!< bit mask for the flag enabling strike-thru text
-               kFakeBoldText_Mask  = 1 << kFakeBoldText_Shift,     //!< bit mask for the flag enabling fake-bold text
-
-               kAllFlagMasks = (1 << kFlagShiftCount) - 1
-       };
-
-    /** Return the paint's flags. Use the FlagMask enum to test flag values.
-        @return the paint's flags (see enums ending in _Mask for bit masks)
+    enum Flag {
+        kAntiAlias_Flag     = 1 << kAntiAlias_Shift,        //!< bit mask for the flag enabling antialiasing
+        kLinearText_Flag    = 1 << kLinearText_Shift,       //!< bit mask for the flag enabling linear-text (no gridding)
+        kUnderlineText_Flag = 1 << kUnderlineText_Shift,    //!< bit mask for the flag enabling underline text
+        kStrikeThruText_Flag= 1 << kStrikeThruText_Shift,   //!< bit mask for the flag enabling strike-thru text
+        kFakeBoldText_Flag  = 1 << kFakeBoldText_Shift,     //!< bit mask for the flag enabling fake-bold text
+        kLCDText_Flag       = 1 << kLCDText_Shift,
+        kNativeHintsText_Flag = 1 << kNativeHintsText_Shift,
+
+        kAllFlags = (1 << kFlagShiftCount) - 1
+    };
+
+    /** Return the paint's flags. Use the Flag enum to test flag values.
+        @return the paint's flags (see enums ending in _Flag for bit masks)
     */
-       uint32_t    getFlags() const { return fFlags; }
-    /** Set the paint's flags. Use the FlagMask enum to specific flag values.
-        @param flags    The new flag bits for the paint (see enums ending in _Mask for bit masks)
+    uint32_t    getFlags() const { return fFlags; }
+    /** Set the paint's flags. Use the Flag enum to specific flag values.
+        @param flags    The new flag bits for the paint (see enums ending in _Flag for bit masks)
     */
-       void    setFlags(uint32_t flags);
+    void    setFlags(uint32_t flags);
 
-       /**     Helper for getFlags(), returning true if kAntiAlias_Mask bit is set
+    /** Helper for getFlags(), returning true if kAntiAlias_Flag bit is set
         @return true if the antialias bit is set in the paint's flags.
-       */
-       bool    isAntiAliasOn() const { return SkToBool(this->getFlags() & kAntiAlias_Mask); }
-       /**     Helper for setFlags(), setting or clearing the kAntiAlias_Mask bit
+    */
+    bool    isAntiAliasOn() const { return SkToBool(this->getFlags() & kAntiAlias_Flag); }
+    /** Helper for setFlags(), setting or clearing the kAntiAlias_Flag bit
         @param aa   true to set the antialias bit in the flags, false to clear it
-       */
-       void    setAntiAliasOn(bool aa);
-       /**     Helper for getFlags(), returning true if kLinearText_Mask bit is set
+    */
+    void    setAntiAliasOn(bool aa);
+    /** Helper for getFlags(), returning true if kLinearText_Flag bit is set
         @return true if the lineartext bit is set in the paint's flags
-       */
-       bool    isLinearTextOn() const { return SkToBool(this->getFlags() & kLinearText_Mask); }
-       /**     Helper for setFlags(), setting or clearing the kLinearText_Mask bit
+    */
+    bool    isLinearTextOn() const { return SkToBool(this->getFlags() & kLinearText_Flag); }
+    /** Helper for setFlags(), setting or clearing the kLinearText_Flag bit
         @param linearText true to set the linearText bit in the paint's flags, false to clear it.
-       */
-       void    setLinearTextOn(bool linearText);
-       /**     Helper for getFlags(), returning true if kUnderlineText_Mask bit is set
+    */
+    void    setLinearTextOn(bool linearText);
+    /** Helper for getFlags(), returning true if kUnderlineText_Flag bit is set
         @return true if the underlineText bit is set in the paint's flags.
-       */
-       bool    isUnderlineTextOn() const { return SkToBool(this->getFlags() & kUnderlineText_Mask); }
-       /**     Helper for setFlags(), setting or clearing the kUnderlineText_Mask bit
+    */
+    bool    isUnderlineTextOn() const { return SkToBool(this->getFlags() & kUnderlineText_Flag); }
+    /** Helper for setFlags(), setting or clearing the kUnderlineText_Flag bit
         @param underlineText true to set the underlineText bit in the paint's flags, false to clear it.
-       */
-       void    setUnderlineTextOn(bool underlineText);
-       /**     Helper for getFlags(), returning true if kStrikeThruText_Mask bit is set
+    */
+    void    setUnderlineTextOn(bool underlineText);
+    /** Helper for getFlags(), returning true if kStrikeThruText_Flag bit is set
         @return true if the strikeThruText bit is set in the paint's flags.
-       */
-       bool    isStrikeThruTextOn() const { return SkToBool(this->getFlags() & kStrikeThruText_Mask); }
-       /**     Helper for setFlags(), setting or clearing the kStrikeThruText_Mask bit
+    */
+    bool    isStrikeThruTextOn() const { return SkToBool(this->getFlags() & kStrikeThruText_Flag); }
+    /** Helper for setFlags(), setting or clearing the kStrikeThruText_Flag bit
         @param strikeThruText   true to set the strikeThruText bit in the paint's flags, false to clear it.
-       */
-       void    setStrikeThruTextOn(bool strikeThruText);
-       /**     Helper for getFlags(), returning true if kFakeBoldText_Mask bit is set
+    */
+    void    setStrikeThruTextOn(bool strikeThruText);
+    /** Helper for getFlags(), returning true if kFakeBoldText_Flag bit is set
         @return true if the fakeBoldText bit is set in the paint's flags.
-       */
-       bool    isFakeBoldTextOn() const { return SkToBool(this->getFlags() & kFakeBoldText_Mask); }
-       /**     Helper for setFlags(), setting or clearing the kStrikeThruText_Mask bit
+    */
+    bool    isFakeBoldTextOn() const { return SkToBool(this->getFlags() & kFakeBoldText_Flag); }
+    /** Helper for setFlags(), setting or clearing the kStrikeThruText_Flag bit
         @param fakeBoldText true to set the fakeBoldText bit in the paint's flags, false to clear it.
-       */
-       void    setFakeBoldTextOn(bool fakeBoldText);
-
-       /**     Styles apply to rect, oval, path, and text.
-               Bitmaps are always drawn in "fill", and lines are always drawn in "stroke"
-       */
-       enum Style {
-               kFill_Style,                    //!< fill with the paint's color
-               kStroke_Style,                  //!< stroke with the paint's color
-               kStrokeAndFill_Style,   //!< fill and stroke with the paint's color
-
-               kStyleCount,
+    */
+    void    setFakeBoldTextOn(bool fakeBoldText);
+
+    /** Styles apply to rect, oval, path, and text.
+        Bitmaps are always drawn in "fill", and lines are always drawn in "stroke"
+    */
+    enum Style {
+        kFill_Style,            //!< fill with the paint's color
+        kStroke_Style,          //!< stroke with the paint's color
+        kStrokeAndFill_Style,   //!< fill and stroke with the paint's color
+
+        kStyleCount,
         kDefault_Style = kFill_Style,   //!< the default style setting in the paint
-       };
-       /**     Return the paint's style, used for controlling how primitives'
-               geometries are interpreted (except for drawBitmap, which always assumes
-               kFill_Style).
+    };
+    /** Return the paint's style, used for controlling how primitives'
+        geometries are interpreted (except for drawBitmap, which always assumes
+        kFill_Style).
         @return the paint's style setting (Fill, Stroke, StrokeAndFill)
-       */
-       Style   getStyle() const { return (Style)fStyle; }
-       /**     Set the paint's style, used for controlling how primitives'
-               geometries are interpreted (except for drawBitmap, which always assumes
-               Fill).
+    */
+    Style   getStyle() const { return (Style)fStyle; }
+    /** Set the paint's style, used for controlling how primitives'
+        geometries are interpreted (except for drawBitmap, which always assumes
+        Fill).
         @param style    The new style to set in the paint (Fill, Stroke, StrokeAndFill)
-       */
-       void    setStyle(Style style);
+    */
+    void    setStyle(Style style);
 
-       /**     Return the paint's color. Note that the color is a 32bit value containing alpha
-               as well as r,g,b. This 32bit value is not premultiplied, meaning that
-               its alpha can be any value, regardless of the values of r,g,b.
+    /** Return the paint's color. Note that the color is a 32bit value containing alpha
+        as well as r,g,b. This 32bit value is not premultiplied, meaning that
+        its alpha can be any value, regardless of the values of r,g,b.
         @return the paint's color (and alpha).
-       */
-       SkColor getColor() const { return fColor; }
-       /**     Helper to getColor() that just returns the color's alpha value.
+    */
+    SkColor getColor() const { return fColor; }
+    /** Helper to getColor() that just returns the color's alpha value.
         @return the alpha component of the paint's color.
-       */
-       uint8_t getAlpha() const { return SkToU8(SkColorGetA(fColor)); }
-       /**     Set the paint's color. Note that the color is a 32bit value containing alpha
-               as well as r,g,b. This 32bit value is not premultiplied, meaning that
-               its alpha can be any value, regardless of the values of r,g,b.
+    */
+    uint8_t getAlpha() const { return SkToU8(SkColorGetA(fColor)); }
+    /** Set the paint's color. Note that the color is a 32bit value containing alpha
+        as well as r,g,b. This 32bit value is not premultiplied, meaning that
+        its alpha can be any value, regardless of the values of r,g,b.
         @param color    The new color (including alpha) to set in the paint.
-       */
-       void    setColor(SkColor color);
-       /**     Helper to setColor(), that only assigns the color's alpha value, leaving its
-               r,g,b values unchanged.
+    */
+    void    setColor(SkColor color);
+    /** Helper to setColor(), that only assigns the color's alpha value, leaving its
+        r,g,b values unchanged.
         @param a    set the alpha component (0..255) of the paint's color.
-       */
-       void    setAlpha(U8CPU a);
-       /**     Helper to setColor(), that takes a,r,g,b and constructs the color value using SkColorSetARGB()
+    */
+    void    setAlpha(U8CPU a);
+    /** Helper to setColor(), that takes a,r,g,b and constructs the color value using SkColorSetARGB()
         @param a    The new alpha component (0..255) of the paint's color.
         @param r    The new red component (0..255) of the paint's color.
         @param g    The new green component (0..255) of the paint's color.
         @param b    The new blue component (0..255) of the paint's color.
-       */
-       void    setARGB(U8CPU a, U8CPU r, U8CPU g, U8CPU b);
+    */
+    void    setARGB(U8CPU a, U8CPU r, U8CPU g, U8CPU b);
 
-       /**     Return the width for stroking. 
-               <p />
-               A value of 0 strokes in hairline mode.
-               Hairlines always draws a single pixel independent of the canva's matrix.
+    /** Return the width for stroking. 
+        <p />
+        A value of 0 strokes in hairline mode.
+        Hairlines always draws a single pixel independent of the canva's matrix.
         @return the paint's stroke width, used whenever the paint's style is Stroke or StrokeAndFill.
-       */
-       SkScalar        getStrokeWidth() const { return fWidth; }
-       /**     Set the width for stroking. 
-               Pass 0 to stroke in hairline mode.
-               Hairlines always draws a single pixel independent of the canva's matrix.
-               @param width set the paint's stroke width, used whenever the paint's style is Stroke or StrokeAndFill.
-       */
-       void            setStrokeWidth(SkScalar width);
-
-       /**     Return the paint's stroke miter value. This is used to control the behavior
-               of miter joins when the joins angle is sharp.
+    */
+    SkScalar    getStrokeWidth() const { return fWidth; }
+    /** Set the width for stroking. 
+        Pass 0 to stroke in hairline mode.
+        Hairlines always draws a single pixel independent of the canva's matrix.
+        @param width set the paint's stroke width, used whenever the paint's style is Stroke or StrokeAndFill.
+    */
+    void        setStrokeWidth(SkScalar width);
+
+    /** Return the paint's stroke miter value. This is used to control the behavior
+        of miter joins when the joins angle is sharp.
         @return the paint's miter limit, used whenever the paint's style is Stroke or StrokeAndFill.
-       */
-       SkScalar        getStrokeMiter() const { return fMiterLimit; }
-       /**     Set the paint's stroke miter value. This is used to control the behavior
-               of miter joins when the joins angle is sharp. This value must be >= 0.
+    */
+    SkScalar    getStrokeMiter() const { return fMiterLimit; }
+    /** Set the paint's stroke miter value. This is used to control the behavior
+        of miter joins when the joins angle is sharp. This value must be >= 0.
         @param miter    set the miter limit on the paint, used whenever the paint's style is Stroke or StrokeAndFill.
-       */
-       void            setStrokeMiter(SkScalar miter);
+    */
+    void        setStrokeMiter(SkScalar miter);
 
     /** Cap enum specifies the settings for the paint's strokecap. This is the treatment
         that is applied to the beginning and end of each non-closed contour (e.g. lines).
     */
-       enum Cap {
-               kButt_Cap,              //!< begin and end a contour with no extension
-               kRound_Cap,             //!< begin and end a contour with a semi-circle extension
-               kSquare_Cap,    //!< begin and end a contour with a half square extension
+    enum Cap {
+        kButt_Cap,      //!< begin and end a contour with no extension
+        kRound_Cap,     //!< begin and end a contour with a semi-circle extension
+        kSquare_Cap,    //!< begin and end a contour with a half square extension
 
-               kCapCount,
-               kDefault_Cap = kButt_Cap
-       };
+        kCapCount,
+        kDefault_Cap = kButt_Cap
+    };
 
     /** Join enum specifies the settings for the paint's strokejoin. This is the treatment
         that is applied to corners in paths and rectangles.
     */
-       enum Join {
-               kMiter_Join,    //!< connect path segments with a sharp join (respects miter-limit)
-               kRound_Join,    //!< connect path segments with a round join
-               kBevel_Join,    //!< connect path segments with a flat bevel join
+    enum Join {
+        kMiter_Join,    //!< connect path segments with a sharp join (respects miter-limit)
+        kRound_Join,    //!< connect path segments with a round join
+        kBevel_Join,    //!< connect path segments with a flat bevel join
 
-               kJoinCount,
-               kDefault_Join = kMiter_Join
-       };
+        kJoinCount,
+        kDefault_Join = kMiter_Join
+    };
 
-       /**     Return the paint's stroke cap type, controlling how the start and end of stroked lines and paths
+    /** Return the paint's stroke cap type, controlling how the start and end of stroked lines and paths
         are treated.
         @return the line cap style for the paint, used whenever the paint's style is Stroke or StrokeAndFill.
-       */
-       Cap             getStrokeCap() const { return (Cap)fCapType; }
-       /**     Set the paint's stroke cap type.
+    */
+    Cap     getStrokeCap() const { return (Cap)fCapType; }
+    /** Set the paint's stroke cap type.
         @param cap  set the paint's line cap style, used whenever the paint's style is Stroke or StrokeAndFill.
-       */
-       void    setStrokeCap(Cap cap);
+    */
+    void    setStrokeCap(Cap cap);
 
-       /**     Return the paint's stroke join type.
+    /** Return the paint's stroke join type.
         @return the paint's line join style, used whenever the paint's style is Stroke or StrokeAndFill.
-       */
-       Join    getStrokeJoin() const { return (Join)fJoinType; }
-       /**     Set the paint's stroke join type.
+    */
+    Join    getStrokeJoin() const { return (Join)fJoinType; }
+    /** Set the paint's stroke join type.
         @param join set the paint's line join style, used whenever the paint's style is Stroke or StrokeAndFill.
-       */
-       void    setStrokeJoin(Join join);
+    */
+    void    setStrokeJoin(Join join);
 
-       enum FilterType {
-               kNo_FilterType,                 //!< draw bitmaps using nearest-neighbor sampling
-               kBilinear_FilterType,   //!< draw bitmaps using bilinear sampling
+    /** Applies any/all effects (patheffect, stroking) to src, returning the result in dst.
+        The result is that drawing src with this paint will be the same as drawing dst
+        with a default paint (at least from the geometric perspective).
+        @param src  input path
+        @param dst  output path (may be the same as src)
+        @return true if the path should be filled, or false if it should be drawn with a hairline (width == 0)
+    */
+    bool    getFillPath(const SkPath& src, SkPath* dst) const;
 
-               kFilterTypeCount
-       };
-       /**     Return the paint's bitmap filter type. This setting affects drawBitmap() and bitmaps
-               that appear inside a bitmap shader.
+    enum FilterType {
+        kNo_FilterType,         //!< draw bitmaps using nearest-neighbor sampling
+        kBilinear_FilterType,   //!< draw bitmaps using bilinear sampling
+
+        kFilterTypeCount
+    };
+    /** Return the paint's bitmap filter type. This setting affects drawBitmap() and bitmaps
+        that appear inside a bitmap shader.
         @return the paint's filter type, used when drawing bitmaps.
-       */
-       FilterType      getFilterType() const { return (FilterType)fFilterType; }
-       /**     Set the paint's bitmap filter type. This setting affects drawBitmap() and bitmaps
-               that appear inside a bitmap shader.
+    */
+    FilterType  getFilterType() const { return (FilterType)fFilterType; }
+    /** Set the paint's bitmap filter type. This setting affects drawBitmap() and bitmaps
+        that appear inside a bitmap shader.
         @param filterType   set the new filter type on the paint, used when drawing a bitmap
-       */
-       void            setFilterType(FilterType filterType);
-
-       /**     Get the paint's shader object.
-               <p />
-         The shader's reference count is not affected.
-               @return the paint's shader (or NULL)
-       */
-       SkShader*       getShader() const { return fShader; }
-       /**     Set or clear the shader object.
-               <p />
-               Pass NULL to clear any previous shader.
-               As a convenience, the parameter passed is also returned.
-               If a previous shader exists, its reference count is decremented.
-               If shader is not NULL, its reference count is incremented.
-               @param shader   May be NULL. the new shader to be installed in the paint
-               @return         shader
-       */
-       SkShader*       setShader(SkShader* shader);
+    */
+    void        setFilterType(FilterType filterType);
+
+    /** Get the paint's shader object.
+        <p />
+      The shader's reference count is not affected.
+        @return the paint's shader (or NULL)
+    */
+    SkShader*   getShader() const { return fShader; }
+    /** Set or clear the shader object.
+        <p />
+        Pass NULL to clear any previous shader.
+        As a convenience, the parameter passed is also returned.
+        If a previous shader exists, its reference count is decremented.
+        If shader is not NULL, its reference count is incremented.
+        @param shader   May be NULL. the new shader to be installed in the paint
+        @return         shader
+    */
+    SkShader*   setShader(SkShader* shader);
     
     /** Get the paint's colorfilter (or NULL). If there is a colorfilter, its reference
         count is not changed.
         @return the paint's colorfilter (or NULL)
     */
     SkColorFilter*  getColorFilter() const { return fColorFilter; }
-       /**     Set or clear the paint's colorfilter, returning the parameter.
-               <p />
-               If the paint already has a filter, its reference count is decremented.
-               If filter is not NULL, its reference count is incremented.
-               @param filter   May be NULL. The new filter to be installed in the paint
-               @return         filter
-       */
+    /** Set or clear the paint's colorfilter, returning the parameter.
+        <p />
+        If the paint already has a filter, its reference count is decremented.
+        If filter is not NULL, its reference count is incremented.
+        @param filter   May be NULL. The new filter to be installed in the paint
+        @return         filter
+    */
     SkColorFilter*  setColorFilter(SkColorFilter* filter);
 
-       /**     Get the paint's xfermode object.
-               <p />
-         The xfermode's reference count is not affected.
-               @return the paint's xfermode (or NULL)
-       */
-       SkXfermode*     getXfermode() const { return fXfermode; }
-       /**     Set or clear the xfermode object.
-               <p />
-               Pass NULL to clear any previous xfermode.
-               As a convenience, the parameter passed is also returned.
-               If a previous xfermode exists, its reference count is decremented.
-               If xfermode is not NULL, its reference count is incremented.
-               @param xfermode May be NULL. The new xfermode to be installed in the paint
-               @return         xfermode
-       */
-       SkXfermode*     setXfermode(SkXfermode* xfermode);
+    /** Get the paint's xfermode object.
+        <p />
+      The xfermode's reference count is not affected.
+        @return the paint's xfermode (or NULL)
+    */
+    SkXfermode* getXfermode() const { return fXfermode; }
+    /** Set or clear the xfermode object.
+        <p />
+        Pass NULL to clear any previous xfermode.
+        As a convenience, the parameter passed is also returned.
+        If a previous xfermode exists, its reference count is decremented.
+        If xfermode is not NULL, its reference count is incremented.
+        @param xfermode May be NULL. The new xfermode to be installed in the paint
+        @return         xfermode
+    */
+    SkXfermode* setXfermode(SkXfermode* xfermode);
     
     /** Helper for setXfermode, passing the corresponding xfermode object returned from the
         PorterDuff factory.
         @param mode The porter-duff mode used to create an xfermode for the paint.
         @return the resulting xfermode object (or NULL if the mode is SrcOver)
     */
-       SkXfermode* setPorterDuffXfermode(SkPorterDuff::Mode mode);
-
-       /**     Get the paint's patheffect object.
-               <p />
-         The patheffect reference count is not affected.
-               @return the paint's patheffect (or NULL)
-       */
-       SkPathEffect*   getPathEffect() const { return fPathEffect; }
-       /**     Set or clear the patheffect object.
-               <p />
-               Pass NULL to clear any previous patheffect.
-               As a convenience, the parameter passed is also returned.
-               If a previous patheffect exists, its reference count is decremented.
-               If patheffect is not NULL, its reference count is incremented.
-               @param effect   May be NULL. The new patheffect to be installed in the paint
-               @return         effect
-       */
-       SkPathEffect*   setPathEffect(SkPathEffect* effect);
-
-       /**     Get the paint's maskfilter object.
-               <p />
-         The maskfilter reference count is not affected.
-               @return the paint's maskfilter (or NULL)
-       */
-       SkMaskFilter*   getMaskFilter() const { return fMaskFilter; }
-       /**     Set or clear the maskfilter object.
-               <p />
-               Pass NULL to clear any previous maskfilter.
-               As a convenience, the parameter passed is also returned.
-               If a previous maskfilter exists, its reference count is decremented.
-               If maskfilter is not NULL, its reference count is incremented.
-               @param maskfilter   May be NULL. The new maskfilter to be installed in the paint
-               @return             maskfilter
-       */
-       SkMaskFilter*   setMaskFilter(SkMaskFilter* maskfilter);
-
-       // These attributes are for text/fonts
-
-       /**     Get the paint's typeface object.
-               <p />
-               The typeface object identifies which font to use when drawing or measuring text.
-        The typeface reference count is not affected.
-               @return the paint's typeface (or NULL)
-       */
-       SkTypeface*     getTypeface() const { return fTypeface; }
-       /**     Set or clear the typeface object.
-               <p />
-               Pass NULL to clear any previous typeface.
-               As a convenience, the parameter passed is also returned.
-               If a previous typeface exists, its reference count is decremented.
-               If typeface is not NULL, its reference count is incremented.
-               @param typeface May be NULL. The new typeface to be installed in the paint
-               @return         typeface
-       */
-       SkTypeface*     setTypeface(SkTypeface* typeface);
-
-    /** Get the paint's textlayout (or NULL).
+    SkXfermode* setPorterDuffXfermode(SkPorterDuff::Mode mode);
+
+    /** Get the paint's patheffect object.
         <p />
-        The textlayout can modify the spacing between letters and words when measured/drawn.
-        The textlayout reference count is not affected.
-        @return the paint's textlayout (or NULL)
+      The patheffect reference count is not affected.
+        @return the paint's patheffect (or NULL)
     */
-    SkTextLayout* getTextLayout() const { return fTextLayout; }
-    /** Set or clear the textlayout object.
+    SkPathEffect*   getPathEffect() const { return fPathEffect; }
+    /** Set or clear the patheffect object.
         <p />
-        Pass NULL to clear any previous textlayout.
+        Pass NULL to clear any previous patheffect.
         As a convenience, the parameter passed is also returned.
-        If a previous layout exists in the paint, its reference count is decremented.
-        If layout is not NULL, its reference count is incremented.
-        @param layout May be NULL. The new layout to be installed in the paint.
-        @return layout
+        If a previous patheffect exists, its reference count is decremented.
+        If patheffect is not NULL, its reference count is incremented.
+        @param effect   May be NULL. The new patheffect to be installed in the paint
+        @return         effect
     */
-    SkTextLayout* setTextLayout(SkTextLayout* layout);
+    SkPathEffect*   setPathEffect(SkPathEffect* effect);
+
+    /** Get the paint's maskfilter object.
+        <p />
+      The maskfilter reference count is not affected.
+        @return the paint's maskfilter (or NULL)
+    */
+    SkMaskFilter*   getMaskFilter() const { return fMaskFilter; }
+    /** Set or clear the maskfilter object.
+        <p />
+        Pass NULL to clear any previous maskfilter.
+        As a convenience, the parameter passed is also returned.
+        If a previous maskfilter exists, its reference count is decremented.
+        If maskfilter is not NULL, its reference count is incremented.
+        @param maskfilter   May be NULL. The new maskfilter to be installed in the paint
+        @return             maskfilter
+    */
+    SkMaskFilter*   setMaskFilter(SkMaskFilter* maskfilter);
+
+    // These attributes are for text/fonts
+
+    /** Get the paint's typeface object.
+        <p />
+        The typeface object identifies which font to use when drawing or measuring text.
+        The typeface reference count is not affected.
+        @return the paint's typeface (or NULL)
+    */
+    SkTypeface* getTypeface() const { return fTypeface; }
+    /** Set or clear the typeface object.
+        <p />
+        Pass NULL to clear any previous typeface.
+        As a convenience, the parameter passed is also returned.
+        If a previous typeface exists, its reference count is decremented.
+        If typeface is not NULL, its reference count is incremented.
+        @param typeface May be NULL. The new typeface to be installed in the paint
+        @return         typeface
+    */
+    SkTypeface* setTypeface(SkTypeface* typeface);
 
     /** Get the paint's rasterizer (or NULL).
         <p />
@@ -396,99 +408,101 @@ public:
     */
     SkRasterizer* setRasterizer(SkRasterizer* rasterizer);
 
-       enum Align {
-               kLeft_Align,
-               kCenter_Align,
-               kRight_Align,
+    enum Align {
+        kLeft_Align,
+        kCenter_Align,
+        kRight_Align,
 
-               kAlignCount
-       };
-       /**     Return the paint's Align value for drawing text.
+        kAlignCount
+    };
+    /** Return the paint's Align value for drawing text.
         @return the paint's Align value for drawing text.
-       */
-       Align   getTextAlign() const { return (Align)fTextAlign; }
-       /**     Set the paint's text alignment.
+    */
+    Align   getTextAlign() const { return (Align)fTextAlign; }
+    /** Set the paint's text alignment.
         @param align set the paint's Align value for drawing text.
-       */
-       void    setTextAlign(Align align);
+    */
+    void    setTextAlign(Align align);
 
-       /**     Return the paint's text size.
+    /** Return the paint's text size.
         @return the paint's text size.
-       */
-       SkScalar        getTextSize() const { return fTextSize; }
-       /**     Set the paint's text size. This value must be > 0
+    */
+    SkScalar    getTextSize() const { return fTextSize; }
+    /** Set the paint's text size. This value must be > 0
         @param textSize set the paint's text size.
-       */
-       void            setTextSize(SkScalar textSize);
+    */
+    void        setTextSize(SkScalar textSize);
 
-       /**     Return the paint's horizontal scale factor for text. The default value
-               is 1.0.
+    /** Return the paint's horizontal scale factor for text. The default value
+        is 1.0.
         @return the paint's scale factor in X for drawing/measuring text
-       */
-       SkScalar        getTextScaleX() const { return fTextScaleX; }
-       /**     Set the paint's horizontal scale factor for text. The default value
-               is 1.0. Values > 1.0 will stretch the text wider. Values < 1.0 will
-               stretch the text narrower.
+    */
+    SkScalar    getTextScaleX() const { return fTextScaleX; }
+    /** Set the paint's horizontal scale factor for text. The default value
+        is 1.0. Values > 1.0 will stretch the text wider. Values < 1.0 will
+        stretch the text narrower.
         @param scaleX   set the paint's scale factor in X for drawing/measuring text.
-       */
-       void            setTextScaleX(SkScalar scaleX);
+    */
+    void        setTextScaleX(SkScalar scaleX);
 
-       /**     Return the paint's horizontal skew factor for text. The default value
-               is 0.
+    /** Return the paint's horizontal skew factor for text. The default value
+        is 0.
         @return the paint's skew factor in X for drawing text.
-       */
-       SkScalar        getTextSkewX() const { return fTextSkewX; }
-       /**     Set the paint's horizontal skew factor for text. The default value
-               is 0. For approximating oblique text, use values around -0.25.
+    */
+    SkScalar    getTextSkewX() const { return fTextSkewX; }
+    /** Set the paint's horizontal skew factor for text. The default value
+        is 0. For approximating oblique text, use values around -0.25.
         @param skewX set the paint's skew factor in X for drawing text.
-       */
-       void            setTextSkewX(SkScalar skewX);
-
-       /**     Return the width of the utf8 text.
-        @param utf8     Address of the utf8 text
-        @param length   Number of bytes of utf8 text to measure
-               @param above    If not NULL, returns the distance above the baseline (ascent)
-               @param below    If not NULL, returns the distance below the baseline (descent)
-               @return The width of the utf8 text
-       */
-       SkScalar        measureText(const char utf8[], size_t length,
-                                                       SkScalar* above, SkScalar* below) const;
-       /**     Return the width of the utf16 text.
-        @param utf16    Address of the utf16 text
-        @param numberOf16BitValues  Number of 16bit values to measure
-               @param above    May be NULL. If not NULL, returns the distance above the baseline (ascent)
-               @param below    May be NULL. If not NULL, returns the distance below the baseline (descent)
-               @return The width of the text
-       */
-       SkScalar        measureText16(const uint16_t utf16[], size_t numberOf16BitValues,
-                                                         SkScalar* above, SkScalar* below) const;
-       /** Return the distance above (negative) the baseline (ascent) based on the current typeface and text size.
+    */
+    void        setTextSkewX(SkScalar skewX);
+
+    enum TextEncoding {
+        kUTF8_TextEncoding,
+        kUTF16_TextEncoding,
+        kGlyphID_TextEncoding
+    };
+    
+    TextEncoding    getTextEncoding() const { return (TextEncoding)fTextEncoding; }
+    void            setTextEncoding(TextEncoding encoding);
+
+    /** Convert the specified text into glyph IDs, returning the number of glyphs ID written.
+        If glyphs is NULL, it is ignore and only the count is returned.
+    */
+    int textToGlyphs(const void* text, size_t byteLength, uint16_t glyphs[]) const;
+
+    int countText(const void* text, size_t byteLength) const
+    {
+        return this->textToGlyphs(text, byteLength, NULL);
+    }
+
+    /** Return the distance above (negative) the baseline (ascent) based on the current typeface and text size.
         @return the distance above (negative) the baseline (ascent) based on the current typeface and text size.
     */
-       SkScalar ascent() const;
-       /** Return the distance below (positive) the baseline (descent) based on the current typeface and text size.
+    SkScalar ascent() const;
+    /** Return the distance below (positive) the baseline (descent) based on the current typeface and text size.
         @return the distance below (positive) the baseline (descent) based on the current typeface and text size.
     */
-       SkScalar descent() const;
+    SkScalar descent() const;
     
-       /**     Return the width of the utf8 text.
-        @param text The utf8 text to measure
-        @param byteLength   The number of bytes of text to process
-        @return the measured width of the specified text.
-       */
-       SkScalar measureText(const char text[], size_t byteLength) const
-       {
-               return this->measureText(text, byteLength, NULL, NULL);
-       }
-       /**     Return the width of the utf16 text.
-        @param text The utf16 text to measure
-        @param numberOf16BitValues   The number of 16bit values in text to process
-        @return the measured width of the specified text.
-       */
-       SkScalar measureText16(const uint16_t text[], size_t numberOf16BitValues) const
-       {
-               return this->measureText16(text, numberOf16BitValues, NULL, NULL);
-       }
+    /** Return the width of the text.
+        @param text         Address of the text
+        @param byteLength   Number of bytes of text to measure
+        @param above        If not NULL, returns the distance above the baseline (ascent)
+        @param below        If not NULL, returns the distance below the baseline (descent)
+        @return The width of the text
+    */
+    SkScalar    measureText(const void* text, size_t byteLength,
+                            SkScalar* above, SkScalar* below) const;
+
+    /** Return the width of the text.
+        @param text         Address of the text
+        @param byteLength   Number of bytes of text to measure
+        @return The width of the text
+    */
+    SkScalar measureText(const void* text, size_t byteLength) const
+    {
+        return this->measureText(text, byteLength, NULL, NULL);
+    }
     
     /** Return the advance widths for the characters in the string.
         @param text UTF8 text
@@ -498,93 +512,68 @@ public:
                         of unichars in the specified text.
         @return the number of unichars in the specified text.
     */
-    int getTextWidths(const char text[], size_t byteLength, SkScalar widths[]) const;
-    /** Return the advance widths for the characters in the string.
-        @param text UTF16 text
-        @param numberOf16BitValues   number of 16bit values to read from the UTF16 text parameter
-        @param widths   array of SkScalars to receive the advance widths of the characters.
-                        May be NULL. If not NULL, must be at least a large as the number
-                        of unichars in the specified text.
-        @return the number of unichars in the specified text.
-    */
-    int getTextWidths16(const uint16_t text[], size_t numberOf16BitValues, SkScalar widths[]) const;
+    int getTextWidths(const void* text, size_t byteLength, SkScalar widths[]) const;
 
-       /**     Return the path (outline) for the specified text.
-               Note: just like SkCanvas::drawText, this will respect the Align setting in the paint.
-       */
-       void    getTextPath(const char text[], size_t length, SkScalar x, SkScalar y, SkPath* path) const;
-
-       /**     Return the path (outline) for the specified text.
-               Note: just like SkCanvas::drawText, this will respect the Align setting in the paint.
-       */
-       void    getText16Path(const uint16_t text[], size_t numberOf16BitValues, SkScalar x, SkScalar y, SkPath* path) const;
-
-    /** Applies any/all effects (patheffect, stroking) to src, returning the result in dst.
-        The result is that drawing src with this paint will be the same as drawing dst
-        with a default paint (at least from the geometric perspective).
-        @param src  input path
-        @param dst  output path (may be the same as src)
-        @return true if the path should be filled, or false if it should be drawn with a hairline (width == 0)
+    /** Return the path (outline) for the specified text.
+        Note: just like SkCanvas::drawText, this will respect the Align setting in the paint.
     */
-    bool    getFillPath(const SkPath& src, SkPath* dst) const;
+    void getTextPath(const void* text, size_t length, SkScalar x, SkScalar y, SkPath* path) const;
 
 private:
-       SkTypeface*             fTypeface;
-       SkScalar                fTextSize;
-       SkScalar                fTextScaleX;
-       SkScalar                fTextSkewX;
-
-       SkPathEffect*   fPathEffect;
-       SkShader*               fShader;
-       SkXfermode*             fXfermode;
-       SkMaskFilter*   fMaskFilter;
+    SkTypeface*     fTypeface;
+    SkScalar        fTextSize;
+    SkScalar        fTextScaleX;
+    SkScalar        fTextSkewX;
+
+    SkPathEffect*   fPathEffect;
+    SkShader*       fShader;
+    SkXfermode*     fXfermode;
+    SkMaskFilter*   fMaskFilter;
     SkColorFilter*  fColorFilter;
-    SkTextLayout*   fTextLayout;
     SkRasterizer*   fRasterizer;
 
-       SkColor                 fColor;
-       SkScalar                fWidth;
-       SkScalar                fMiterLimit;
-       unsigned                fFlags : 5;
-       unsigned                fFilterType : 2;
-       unsigned                fTextAlign : 2;
-       unsigned                fCapType : 2;
-       unsigned                fJoinType : 2;
-       unsigned                fStyle : 2;
-
-    SkScalar privateMeasureText(SkUnicodeWalkerProc, const char text[], size_t byteLength,
-                                SkScalar* above, SkScalar* below) const;
-       void    privateGetTextPath(SkUnicodeWalkerProc, const char text[], size_t length,
-                                SkScalar x, SkScalar y, SkPath* path) const;
-    int privateGetTextWidths(const char text[], size_t byteLength,
-                             SkScalar widths[], SkUnicodeWalkerProc textProc) const;
-
-       SkGlyphCache*   detachCache(const SkMatrix*) const;
-
-       friend class SkGlyphCache;
-       enum {
-               kCanonicalTextSizeForPaths = 64
-       };
-       friend class SkDraw;
-       friend class SkTextToPathIter;
+    SkColor         fColor;
+    SkScalar        fWidth;
+    SkScalar        fMiterLimit;
+    unsigned        fFlags : kFlagShiftCount;
+    unsigned        fFilterType : 1;
+    unsigned        fTextAlign : 2;
+    unsigned        fCapType : 2;
+    unsigned        fJoinType : 2;
+    unsigned        fStyle : 2;
+    unsigned        fTextEncoding : 2;  // 3 values
+
+    SkGlyphCacheProc getGlyphCacheProc() const;
+
+    SkScalar measure_text(SkGlyphCache*, const char* text, size_t length, int* count) const;
+
+    SkGlyphCache*   detachCache(const SkMatrix*) const;
+
+    enum {
+        kCanonicalTextSizeForPaths = 64
+    };
+    friend class SkCanvas;
+    friend class SkDraw;
+    friend class SkGlyphCache;
+    friend class SkTextToPathIter;
 };
 
 class SkAutoRestorePaintFlags {
 public:
-       SkAutoRestorePaintFlags(const SkPaint& paint, uint32_t newFlags)
-       {
-               SkASSERT(&paint);
-               fPaint = (SkPaint*)&paint;      // remove constness
-               fOldFlags = paint.getFlags();
-               fPaint->setFlags(newFlags);
-       }
-       ~SkAutoRestorePaintFlags()
-       {
-               fPaint->setFlags(fOldFlags);
-       }
+    SkAutoRestorePaintFlags(const SkPaint& paint, uint32_t newFlags)
+    {
+        SkASSERT(&paint);
+        fPaint = (SkPaint*)&paint;  // remove constness
+        fOldFlags = paint.getFlags();
+        fPaint->setFlags(newFlags);
+    }
+    ~SkAutoRestorePaintFlags()
+    {
+        fPaint->setFlags(fOldFlags);
+    }
 private:
-       SkPaint* fPaint;
-       uint32_t fOldFlags;
+    SkPaint* fPaint;
+    uint32_t fOldFlags;
 };
 
 //////////////////////////////////////////////////////////////////////////
@@ -599,31 +588,31 @@ private:
 */
 class SkStrokePathEffect : public SkPathEffect {
 public:
-       SkStrokePathEffect(const SkPaint&);
-       SkStrokePathEffect(SkScalar width, SkPaint::Style, SkPaint::Join, SkPaint::Cap, SkScalar miterLimit = -1);
+    SkStrokePathEffect(const SkPaint&);
+    SkStrokePathEffect(SkScalar width, SkPaint::Style, SkPaint::Join, SkPaint::Cap, SkScalar miterLimit = -1);
 
-       // overrides
+    // overrides
     // This method is not exported to java.
-       virtual bool filterPath(SkPath* dst, const SkPath& src, SkScalar* width);
+    virtual bool filterPath(SkPath* dst, const SkPath& src, SkScalar* width);
 
-       // overrides for SkFlattenable
+    // overrides for SkFlattenable
     // This method is not exported to java.
-       virtual void flatten(SkWBuffer&);
+    virtual void flatten(SkWBuffer&);
     // This method is not exported to java.
-       virtual Factory getFactory();
+    virtual Factory getFactory();
 
 private:
-       SkScalar        fWidth, fMiter;
-       uint8_t         fStyle, fJoin, fCap;
+    SkScalar    fWidth, fMiter;
+    uint8_t     fStyle, fJoin, fCap;
 
-       static SkFlattenable* CreateProc(SkRBuffer&);
-       SkStrokePathEffect(SkRBuffer&);
+    static SkFlattenable* CreateProc(SkRBuffer&);
+    SkStrokePathEffect(SkRBuffer&);
 
-       typedef SkPathEffect INHERITED;
+    typedef SkPathEffect INHERITED;
 
-       // illegal
-       SkStrokePathEffect(const SkStrokePathEffect&);
-       SkStrokePathEffect& operator=(const SkStrokePathEffect&);
+    // illegal
+    SkStrokePathEffect(const SkStrokePathEffect&);
+    SkStrokePathEffect& operator=(const SkStrokePathEffect&);
 };
 
 #endif
index 9e513fe..b066f6a 100644 (file)
@@ -1,3 +1,20 @@
+/* include/graphics/SkParse.h
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #ifndef SkParse_DEFINED
 #define SkParse_DEFINED
 
 
 class SkParse {
 public:
-       static int Count(const char str[]); // number of scalars or int values
-       static int Count(const char str[], char separator);
-       static const char* FindColor(const char str[], SkColor* value);
-       static const char* FindHex(const char str[], uint32_t* value);
-       static const char* FindMSec(const char str[], SkMSec* value);
-       static const char* FindNamedColor(const char str[], size_t len, SkColor* color);
-       static const char* FindS32(const char str[], int32_t* value);
-       static const char* FindScalar(const char str[], SkScalar* value);
-       static const char* FindScalars(const char str[], SkScalar value[], int count);
+    static int Count(const char str[]); // number of scalars or int values
+    static int Count(const char str[], char separator);
+    static const char* FindColor(const char str[], SkColor* value);
+    static const char* FindHex(const char str[], uint32_t* value);
+    static const char* FindMSec(const char str[], SkMSec* value);
+    static const char* FindNamedColor(const char str[], size_t len, SkColor* color);
+    static const char* FindS32(const char str[], int32_t* value);
+    static const char* FindScalar(const char str[], SkScalar* value);
+    static const char* FindScalars(const char str[], SkScalar value[], int count);
 
-       static bool     FindBool(const char str[], bool* value);
-       // return the index of str in list[], or -1 if not found
-       static int      FindList(const char str[], const char list[]);
+    static bool FindBool(const char str[], bool* value);
+    // return the index of str in list[], or -1 if not found
+    static int  FindList(const char str[], const char list[]);
 #ifdef SK_SUPPORT_UNITTEST
-       static void TestColor();
-       static void UnitTest();
+    static void TestColor();
+    static void UnitTest();
 #endif
 };
 
index d5f7f68..32b84f9 100644 (file)
@@ -1,16 +1,33 @@
+/* include/graphics/SkParsePaint.h
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #ifndef SkParsePaint_DEFINED
 #define SkParsePaint_DEFINED
 
 #include "SkPaint.h"
 #include "SkDOM.h"
 
-/**    "color"                         color
-       "opacity"                       scalar  [0..1]
-       "stroke-width"          scalar  (0...inf)
-       "text-size"                     scalar  (0..inf)
-       "is-stroke"                     bool
-       "is-antialias"          bool
-       "is-lineartext"         bool
+/** "color"             color
+    "opacity"           scalar  [0..1]
+    "stroke-width"      scalar  (0...inf)
+    "text-size"         scalar  (0..inf)
+    "is-stroke"         bool
+    "is-antialias"      bool
+    "is-lineartext"     bool
 */
 void SkPaint_Inflate(SkPaint*, const SkDOM&, const SkDOM::Node*);
 
index b0a538d..081b002 100644 (file)
@@ -1,3 +1,20 @@
+/* include/graphics/SkPath.h
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #ifndef SkPath_DEFINED
 #define SkPath_DEFINED
 
 
 class SkString;
 
-/**    \class SkPath
+/** \class SkPath
 
-       The SkPath class encapsulates compound (multiple contour) geometric paths consisting
-       of straight line segments, quadratic curves, and cubic curves.
+    The SkPath class encapsulates compound (multiple contour) geometric paths consisting
+    of straight line segments, quadratic curves, and cubic curves.
 */
 class SkPath {
 public:
-       SkPath();
-       SkPath(const SkPath&);
-       ~SkPath();
+    SkPath();
+    SkPath(const SkPath&);
+    ~SkPath();
 
-       SkPath& operator=(const SkPath&);
+    SkPath& operator=(const SkPath&);
 
-       enum FillType {
-               kWinding_FillType,      //!< Specifies that "inside" is computed by a non-zero sum of signed edge crossings
-               kEvenOdd_FillType       //!< Specifies that "inside" is computed by an odd number of edge crossings
-       };
-       /**     Return the path's fill type. This is used to define how "inside" is computed.
-               The default value is kWinding_FillType.
+    enum FillType {
+        kWinding_FillType,  //!< Specifies that "inside" is computed by a non-zero sum of signed edge crossings
+        kEvenOdd_FillType   //!< Specifies that "inside" is computed by an odd number of edge crossings
+    };
+    /** Return the path's fill type. This is used to define how "inside" is computed.
+        The default value is kWinding_FillType.
         @return the path's fill type
-       */
-       FillType        getFillType() const { return (FillType)fFillType; }
-       /**     Set the path's fill type. This is used to define how "inside" is computed.
-               The default value is kWinding_FillType.
+    */
+    FillType    getFillType() const { return (FillType)fFillType; }
+    /** Set the path's fill type. This is used to define how "inside" is computed.
+        The default value is kWinding_FillType.
         @param ft The new fill type for this path
-       */
-       void            setFillType(FillType ft) { fFillType = SkToU8(ft); }
+    */
+    void        setFillType(FillType ft) { fFillType = SkToU8(ft); }
 
-       /**     Clear any lines and curves from the path, making it empty.
-               This does NOT change the fill-type setting.
-       */
-       void    reset();
-       /**     Returns true if the path is empty (contains no lines or curves)
+    /** Clear any lines and curves from the path, making it empty.
+        This does NOT change the fill-type setting.
+    */
+    void    reset();
+    /** Returns true if the path is empty (contains no lines or curves)
         @return true if the path is empty (contains no lines or curves)
-       */
-       bool    isEmpty() const;
-       /**     Returns true if the path specifies a rectangle. If so, and if rect is not nil,
-               set rect to the bounds of the path. If the path does not specify a rectangle,
-               return false and ignore rect.
-               @param rect     If not nil, returns the bounds of the path if it specifies a rectangle
-               @return true if the path specifies a rectangle
-       */
-       bool    isRect(SkRect* rect) const;
-       /**     Returns the number of points in the path. Up to max points are copied.
-               @param points If not null, receives up to max points
-               @param max The maximum number of points to copy into points
-               @return the actual number of points in the path
-       */
-       int     getPoints(SkPoint points[], int max) const;
-       //!     Swap contents of this and other. Guaranteed not to throw
-       void    swap(SkPath& other);
+    */
+    bool    isEmpty() const;
+    /** Returns true if the path specifies a rectangle. If so, and if rect is not nil,
+        set rect to the bounds of the path. If the path does not specify a rectangle,
+        return false and ignore rect.
+        @param rect If not nil, returns the bounds of the path if it specifies a rectangle
+        @return true if the path specifies a rectangle
+    */
+    bool    isRect(SkRect* rect) const;
+    /** Returns the number of points in the path. Up to max points are copied.
+        @param points If not null, receives up to max points
+        @param max The maximum number of points to copy into points
+        @return the actual number of points in the path
+    */
+    int     getPoints(SkPoint points[], int max) const;
+    //! Swap contents of this and other. Guaranteed not to throw
+    void    swap(SkPath& other);
 
-       enum BoundsType {
-               kFast_BoundsType,       //!< compute the bounds of the path's control points, may be larger than with kExact_BoundsType, but may be faster to compute
-               kExact_BoundsType       //!< compute the exact bounds of the path, may be smaller than with kFast_BoundsType, but may be slower to compute
-       };
-       /**     Compute the bounds of the path, and write the answer into bounds. If the path contains 0 or 1 points,
-               the bounds is set to (0,0,0,0)
+    enum BoundsType {
+        kFast_BoundsType,   //!< compute the bounds of the path's control points, may be larger than with kExact_BoundsType, but may be faster to compute
+        kExact_BoundsType   //!< compute the exact bounds of the path, may be smaller than with kFast_BoundsType, but may be slower to compute
+    };
+    /** Compute the bounds of the path, and write the answer into bounds. If the path contains 0 or 1 points,
+        the bounds is set to (0,0,0,0)
         @param bounds   Returns the computed bounds of the path
         @param btype    Specifies if the computed bounds should be exact (slower) or approximate (faster)
-       */
-       void    computeBounds(SkRect* bounds, BoundsType btype) const;
+    */
+    void    computeBounds(SkRect* bounds, BoundsType btype) const;
 
-       //      Construction methods
+    //  Construction methods
 
     /** Hint to the path to prepare for adding more points. This can allow the path to more efficiently grow its storage.
         @param extraPtCount The number of extra points that may be added to this path
     */
-       void    incReserve(unsigned extraPtCount);
+    void    incReserve(unsigned extraPtCount);
 
-       /**     Set the beginning of the next contour to the point (x,y).
+    /** Set the beginning of the next contour to the point (x,y).
         @param x    The x-coordinate of the start of a new contour
         @param y    The y-coordinate of the start of a new contour
-       */
-       void    moveTo(SkScalar x, SkScalar y);
+    */
+    void    moveTo(SkScalar x, SkScalar y);
     /** Set the beginning of the next contour to the point
         @param p    The start of a new contour
     */
-       void moveTo(const SkPoint& p)
-       {
-               this->moveTo(p.fX, p.fY);
-       }
-       /**     Set the beginning of the next contour relative to the last point on the previous
-               contour. If there is no previous contour, this is treated the same as moveTo().
+    void moveTo(const SkPoint& p)
+    {
+        this->moveTo(p.fX, p.fY);
+    }
+    /** Set the beginning of the next contour relative to the last point on the previous
+        contour. If there is no previous contour, this is treated the same as moveTo().
         @param dx   The amount to add to the x-coordinate of the end of the previous contour, to specify the start of a new contour
         @param dy   The amount to add to the y-coordinate of the end of the previous contour, to specify the start of a new contour
-       */
-       void    rMoveTo(SkScalar dx, SkScalar dy);
-       /**     Add a line from the last point to the specified point (x,y).
-               If no moveTo() call has been made for this contour, the first point is automatically set to (0,0).
+    */
+    void    rMoveTo(SkScalar dx, SkScalar dy);
+    /** Add a line from the last point to the specified point (x,y).
+        If no moveTo() call has been made for this contour, the first point is automatically set to (0,0).
         @param x    The x-coordinate of the end of a line
         @param y    The y-coordinate of the end of a line
-       */
-       void    lineTo(SkScalar x, SkScalar y);
-       /**     Add a line from the last point to the specified point.
-               If no moveTo() call has been made for this contour, the first point is automatically set to (0,0).
+    */
+    void    lineTo(SkScalar x, SkScalar y);
+    /** Add a line from the last point to the specified point.
+        If no moveTo() call has been made for this contour, the first point is automatically set to (0,0).
         @param p    The end of a line
-       */
-       void    lineTo(const SkPoint& p)
-       {
-               this->lineTo(p.fX, p.fY);
-       }
-       /**     Same as lineTo, but the coordinates are considered relative to the last point on this
-               contour. If there is no previous point, then a moveTo(0,0) is inserted automatically.
+    */
+    void    lineTo(const SkPoint& p)
+    {
+        this->lineTo(p.fX, p.fY);
+    }
+    /** Same as lineTo, but the coordinates are considered relative to the last point on this
+        contour. If there is no previous point, then a moveTo(0,0) is inserted automatically.
         @param dx   The amount to add to the x-coordinate of the previous point on this contour, to specify a line
         @param dy   The amount to add to the y-coordinate of the previous point on this contour, to specify a line
-       */
-       void    rLineTo(SkScalar dx, SkScalar dy);
-       /**     Add a quadratic bezier from the last point, approaching control point (x1,y1), and ending at (x2,y2).
-               If no moveTo() call has been made for this contour, the first point is automatically set to (0,0).
+    */
+    void    rLineTo(SkScalar dx, SkScalar dy);
+    /** Add a quadratic bezier from the last point, approaching control point (x1,y1), and ending at (x2,y2).
+        If no moveTo() call has been made for this contour, the first point is automatically set to (0,0).
         @param x1   The x-coordinate of the control point on a quadratic curve
         @param y1   The y-coordinate of the control point on a quadratic curve
         @param x2   The x-coordinate of the end point on a quadratic curve
         @param y2   The y-coordinate of the end point on a quadratic curve
-       */
-       void    quadTo(SkScalar x1, SkScalar y1, SkScalar x2, SkScalar y2);
-       /**     Add a quadratic bezier from the last point, approaching control point p1, and ending at p2.
-               If no moveTo() call has been made for this contour, the first point is automatically set to (0,0).
+    */
+    void    quadTo(SkScalar x1, SkScalar y1, SkScalar x2, SkScalar y2);
+    /** Add a quadratic bezier from the last point, approaching control point p1, and ending at p2.
+        If no moveTo() call has been made for this contour, the first point is automatically set to (0,0).
         @param p1   The control point on a quadratic curve
         @param p2   The end point on a quadratic curve
-       */
-       void    quadTo(const SkPoint& p1, const SkPoint& p2)
-       {
-               this->quadTo(p1.fX, p1.fY, p2.fX, p2.fY);
-       }
-       /**     Same as quadTo, but the coordinates are considered relative to the last point on this
-               contour. If there is no previous point, then a moveTo(0,0) is inserted automatically.
+    */
+    void    quadTo(const SkPoint& p1, const SkPoint& p2)
+    {
+        this->quadTo(p1.fX, p1.fY, p2.fX, p2.fY);
+    }
+    /** Same as quadTo, but the coordinates are considered relative to the last point on this
+        contour. If there is no previous point, then a moveTo(0,0) is inserted automatically.
         @param dx1   The amount to add to the x-coordinate of the last point on this contour, to specify the control point of a quadratic curve
         @param dy1   The amount to add to the y-coordinate of the last point on this contour, to specify the control point of a quadratic curve
         @param dx2   The amount to add to the x-coordinate of the last point on this contour, to specify the end point of a quadratic curve
         @param dy2   The amount to add to the y-coordinate of the last point on this contour, to specify the end point of a quadratic curve
-       */
-       void    rQuadTo(SkScalar dx1, SkScalar dy1, SkScalar dx2, SkScalar dy2);
-       /**     Add a cubic bezier from the last point, approaching control points (x1,y1) and (x2,y2), and ending at (x3,y3).
-               If no moveTo() call has been made for this contour, the first point is automatically set to (0,0).
+    */
+    void    rQuadTo(SkScalar dx1, SkScalar dy1, SkScalar dx2, SkScalar dy2);
+    /** Add a cubic bezier from the last point, approaching control points (x1,y1) and (x2,y2), and ending at (x3,y3).
+        If no moveTo() call has been made for this contour, the first point is automatically set to (0,0).
         @param x1   The x-coordinate of the 1st control point on a cubic curve
         @param y1   The y-coordinate of the 1st control point on a cubic curve
         @param x2   The x-coordinate of the 2nd control point on a cubic curve
         @param y2   The y-coordinate of the 2nd control point on a cubic curve
         @param x3   The x-coordinate of the end point on a cubic curve
         @param y3   The y-coordinate of the end point on a cubic curve
-       */
-       void    cubicTo(SkScalar x1, SkScalar y1, SkScalar x2, SkScalar y2, SkScalar x3, SkScalar y3);
-       /**     Add a cubic bezier from the last point, approaching control points p1 and p2, and ending at p3.
-               If no moveTo() call has been made for this contour, the first point is automatically set to (0,0).
+    */
+    void    cubicTo(SkScalar x1, SkScalar y1, SkScalar x2, SkScalar y2, SkScalar x3, SkScalar y3);
+    /** Add a cubic bezier from the last point, approaching control points p1 and p2, and ending at p3.
+        If no moveTo() call has been made for this contour, the first point is automatically set to (0,0).
         @param p1   The 1st control point on a cubic curve
         @param p2   The 2nd control point on a cubic curve
         @param p3   The end point on a cubic curve
-       */
-       void    cubicTo(const SkPoint& p1, const SkPoint& p2, const SkPoint& p3)
-       {
-               this->cubicTo(p1.fX, p1.fY, p2.fX, p2.fY, p3.fX, p3.fY);
-       }
-       /**     Same as cubicTo, but the coordinates are considered relative to the current point on this
-               contour. If there is no previous point, then a moveTo(0,0) is inserted automatically.
+    */
+    void    cubicTo(const SkPoint& p1, const SkPoint& p2, const SkPoint& p3)
+    {
+        this->cubicTo(p1.fX, p1.fY, p2.fX, p2.fY, p3.fX, p3.fY);
+    }
+    /** Same as cubicTo, but the coordinates are considered relative to the current point on this
+        contour. If there is no previous point, then a moveTo(0,0) is inserted automatically.
         @param dx1   The amount to add to the x-coordinate of the last point on this contour, to specify the 1st control point of a cubic curve
         @param dy1   The amount to add to the y-coordinate of the last point on this contour, to specify the 1st control point of a cubic curve
         @param dx2   The amount to add to the x-coordinate of the last point on this contour, to specify the 2nd control point of a cubic curve
         @param dy2   The amount to add to the y-coordinate of the last point on this contour, to specify the 2nd control point of a cubic curve
         @param dx3   The amount to add to the x-coordinate of the last point on this contour, to specify the end point of a cubic curve
         @param dy3   The amount to add to the y-coordinate of the last point on this contour, to specify the end point of a cubic curve
-       */
-       void    rCubicTo(SkScalar x1, SkScalar y1, SkScalar x2, SkScalar y2, SkScalar x3, SkScalar y3);
-       /**     Close the current contour. If the current point is not equal to the first point of the contour,
-               a line segment is automatically added.
-       */
-       void    close();
+    */
+    void    rCubicTo(SkScalar x1, SkScalar y1, SkScalar x2, SkScalar y2, SkScalar x3, SkScalar y3);
+    /** Append the specified arc to the path as a new contour. If the start of the path is different from the
+        path's current last point, then an automatic lineTo() is added to connect the current contour to the
+        start of the arc. However, if the path is empty, then we call moveTo() with the first point of the arc.
+        @param oval The bounds of oval used to define the shape and size of the arc
+        @param startAngle Starting angle (in degrees) where the arc begins
+        @param sweepAngle Sweep angle (in degrees) measured clockwise
+        @param forceMoveTo If true, always begin a new contour with the arc
+    */
+    void    arcTo(const SkRect& oval, SkScalar startAngle, SkScalar sweepAngle, bool forceMoveTo = false);
+    /** Close the current contour. If the current point is not equal to the first point of the contour,
+        a line segment is automatically added.
+    */
+    void    close();
 
-       enum Direction {
-               kCW_Direction,  //!< clockwise direction for adding closed contours
-               kCCW_Direction  //!< counter-clockwise direction for adding closed contours
-       };
-       /**     Add a closed rectangle contour to the path
+    enum Direction {
+        kCW_Direction,  //!< clockwise direction for adding closed contours
+        kCCW_Direction  //!< counter-clockwise direction for adding closed contours
+    };
+    /** Add a closed rectangle contour to the path
         @param rect The rectangle to add as a closed contour to the path
         @param dir  The direction to wind the rectangle's contour
-       */
-       void    addRect(const SkRect& rect, Direction dir = kCW_Direction);
-       /**     Add a closed rectangle contour to the path
+    */
+    void    addRect(const SkRect& rect, Direction dir = kCW_Direction);
+    /** Add a closed rectangle contour to the path
         @param left     The left side of a rectangle to add as a closed contour to the path
         @param top      The top of a rectangle to add as a closed contour to the path
         @param right    The right side of a rectangle to add as a closed contour to the path
         @param bottom   The bottom of a rectangle to add as a closed contour to the path
         @param dir      The direction to wind the rectangle's contour
-       */
-       void    addRect(SkScalar left, SkScalar top, SkScalar right, SkScalar bottom, Direction dir = kCW_Direction);
-       /**     Add a closed oval contour to the path
+    */
+    void    addRect(SkScalar left, SkScalar top, SkScalar right, SkScalar bottom, Direction dir = kCW_Direction);
+    /** Add a closed oval contour to the path
         @param oval The bounds of the oval to add as a closed contour to the path
         @param dir  The direction to wind the oval's contour
-       */
-       void    addOval(const SkRect& oval, Direction dir = kCW_Direction);
-       /**     Add a closed circle contour to the path
+    */
+    void    addOval(const SkRect& oval, Direction dir = kCW_Direction);
+    /** Add a closed circle contour to the path
         @param x        The x-coordinate of the center of a circle to add as a closed contour to the path
         @param y        The y-coordinate of the center of a circle to add as a closed contour to the path
         @param radius   The radius of a circle to add as a closed contour to the path
         @param dir      The direction to wind the circle's contour
-       */
-       void    addCircle(SkScalar x, SkScalar y, SkScalar radius, Direction dir = kCW_Direction);
-       /**     Add a closed round-rectangle contour to the path
+    */
+    void    addCircle(SkScalar x, SkScalar y, SkScalar radius, Direction dir = kCW_Direction);
+    /** Add the specified arc to the path as a new contour.
+        @param oval The bounds of oval used to define the shape and size of the arc
+        @param startAngle Starting angle (in degrees) where the arc begins
+        @param sweepAngle Sweep angle (in degrees) measured clockwise
+    */
+    void    addArc(const SkRect& oval, SkScalar startAngle, SkScalar sweepAngle);
+    /** Add a closed round-rectangle contour to the path
         @param rect The bounds of a round-rectangle to add as a closed contour to the path
         @param rx   The x-radius of the rounded corners on the round-rectangle
         @param ry   The y-radius of the rounded corners on the round-rectangle
         @param dir  The direction to wind the round-rectangle's contour
-       */
-       void    addRoundRect(const SkRect& rect, SkScalar rx, SkScalar ry, Direction dir = kCW_Direction);
-       /**     Add a copy of src to the path, offset by (dx,dy)
+    */
+    void    addRoundRect(const SkRect& rect, SkScalar rx, SkScalar ry, Direction dir = kCW_Direction);
+    /** Add a copy of src to the path, offset by (dx,dy)
         @param src  The path to add as a new contour
         @param dx   The amount to translate the path in X as it is added
         @param dx   The amount to translate the path in Y as it is added
-       */
-       void    addPath(const SkPath& src, SkScalar dx, SkScalar dy);
-       /**     Add a copy of src to the path
-       */
-       void    addPath(const SkPath& src) { SkMatrix m; m.reset(); this->addPath(src, m); }
-       /**     Add a copy of src to the path, transformed by matrix
+    */
+    void    addPath(const SkPath& src, SkScalar dx, SkScalar dy);
+    /** Add a copy of src to the path
+    */
+    void    addPath(const SkPath& src) { SkMatrix m; m.reset(); this->addPath(src, m); }
+    /** Add a copy of src to the path, transformed by matrix
         @param src  The path to add as a new contour
-       */
-       void    addPath(const SkPath& src, const SkMatrix& matrix);
+    */
+    void    addPath(const SkPath& src, const SkMatrix& matrix);
 
-       /**     Offset the path by (dx,dy), returning true on success
+    /** Offset the path by (dx,dy), returning true on success
         @param dx   The amount in the X direction to offset the entire path 
         @param dy   The amount in the Y direction to offset the entire path 
         @param dst  The translated path is written here
         @return true
-       */
-       bool    offset(SkScalar dx, SkScalar dy, SkPath* dst) const;
-       /**     Offset the path by (dx,dy), returning true on success
+    */
+    bool    offset(SkScalar dx, SkScalar dy, SkPath* dst) const;
+    /** Offset the path by (dx,dy), returning true on success
         @param dx   The amount in the X direction to offset the entire path 
         @param dy   The amount in the Y direction to offset the entire path 
         @return true
-       */
+    */
     bool    offset(SkScalar dx, SkScalar dy)
     {
         return this->offset(dx, dy, this);
     }
-       /**     Transform the points in this path by matrix, and write the answer into dst.
+    /** Transform the points in this path by matrix, and write the answer into dst.
         @param matrix   The matrix to apply to the path
         @param dst      The transformed path is written here
-               @return true
-       */
-       bool    transform(const SkMatrix& matrix, SkPath* dst) const;
-       /**     Transform the points in this path by matrix, and write the answer into dst.
+        @return true
+    */
+    bool    transform(const SkMatrix& matrix, SkPath* dst) const;
+    /** Transform the points in this path by matrix, and write the answer into dst.
         @param matrix   The matrix to apply to the path
-               @return true
-       */
-       bool    transform(const SkMatrix& matrix)
-       {
-               return this->transform(matrix, this);
-       }
+        @return true
+    */
+    bool    transform(const SkMatrix& matrix)
+    {
+        return this->transform(matrix, this);
+    }
 
-       /**     Return the last point on the path. If no points have been added, (0,0) is returned.
+    /** Return the last point on the path. If no points have been added, (0,0) is returned.
         @param lastPt   The last point on the path is returned here
-       */
-       void    getLastPt(SkPoint* lastPt) const;
-       /**     Set the last point on the path. If no points have been added, moveTo(x,y) is automatically called.
+    */
+    void    getLastPt(SkPoint* lastPt) const;
+    /** Set the last point on the path. If no points have been added, moveTo(x,y) is automatically called.
         @param x    The new x-coordinate for the last point
         @param y    The new y-coordinate for the last point
-       */
-       void    setLastPt(SkScalar x, SkScalar y);
-       /**     Set the last point on the path. If no points have been added, moveTo(p) is automatically called.
+    */
+    void    setLastPt(SkScalar x, SkScalar y);
+    /** Set the last point on the path. If no points have been added, moveTo(p) is automatically called.
         @param p    The new location for the last point
-       */
-       void    setLastPt(const SkPoint& p) { this->setLastPt(p.fX, p.fY); }
+    */
+    void    setLastPt(const SkPoint& p) { this->setLastPt(p.fX, p.fY); }
 
-       enum Verb {
-               kMove_Verb,             //!< iter.next returns 1 point
-               kLine_Verb,             //!< iter.next returns 2 points
-               kQuad_Verb,             //!< iter.next returns 3 points
-               kCubic_Verb,    //!< iter.next returns 4 points
-               kClose_Verb,    //!< iter.next returns 1 point (the last point)
-               kDone_Verb              //!< iter.next returns 0 points
-       };
-       /**     Iterate through all of the segments (lines, quadratics, cubics) of
-               each contours in a path.
-       */
-       class Iter {
-       public:
-                               Iter();
-                               Iter(const SkPath&, bool forceClose);
-               void    setPath(const SkPath&, bool forceClose);
+    enum Verb {
+        kMove_Verb,     //!< iter.next returns 1 point
+        kLine_Verb,     //!< iter.next returns 2 points
+        kQuad_Verb,     //!< iter.next returns 3 points
+        kCubic_Verb,    //!< iter.next returns 4 points
+        kClose_Verb,    //!< iter.next returns 1 point (the last point)
+        kDone_Verb      //!< iter.next returns 0 points
+    };
+    /** Iterate through all of the segments (lines, quadratics, cubics) of
+        each contours in a path.
+    */
+    class Iter {
+    public:
+                Iter();
+                Iter(const SkPath&, bool forceClose);
+        void    setPath(const SkPath&, bool forceClose);
 
         /** Return the next verb in this iteration of the path. When all segments have been
             visited, return kDone_Verb.
             @param  pts The point(s) representing the current verb and/or segment
             @return The verb for the current segment
         */
-               Verb    next(SkPoint pts[4]);
+        Verb    next(SkPoint pts[4]);
 
-               /**     If next() returns kLine_Verb, then this query returns
-                       true if the line was the result of a close() command
-                       (i.e. the end point is the initial moveto for this contour).
-                       If next() returned a different verb, this returns an
-                       undefined value.
+        /** If next() returns kLine_Verb, then this query returns
+            true if the line was the result of a close() command
+            (i.e. the end point is the initial moveto for this contour).
+            If next() returned a different verb, this returns an
+            undefined value.
             @return If the last call to next() returned kLine_Verb, return true if it was
                     the result of an explicit close command.
-               */
-               bool    isCloseLine() const { return SkToBool(fCloseLine); }
+        */
+        bool    isCloseLine() const { return SkToBool(fCloseLine); }
         
         /** Returns true if the current contour is closed (i.e. has a kClose_Verb)
             @return true if the current contour is closed (i.e. has a kClose_Verb)
         */
         bool    isClosedContour() const;
 
-       private:
-               const SkPoint*  fPts;
-               const uint8_t*  fVerbs;
-               const uint8_t*  fVerbStop;
-               SkPoint                 fMoveTo;
-               SkPoint                 fLastPt;
-               SkBool8                 fForceClose;
-               SkBool8                 fNeedClose;
-               SkBool8                 fNeedMoveTo;
-               SkBool8                 fCloseLine;
+    private:
+        const SkPoint*  fPts;
+        const uint8_t*  fVerbs;
+        const uint8_t*  fVerbStop;
+        SkPoint         fMoveTo;
+        SkPoint         fLastPt;
+        SkBool8         fForceClose;
+        SkBool8         fNeedClose;
+        SkBool8         fNeedMoveTo;
+        SkBool8         fCloseLine;
 
-               bool cons_moveTo(SkPoint pts[1]);
-               Verb autoClose(SkPoint pts[2]);
-       };
+        bool cons_moveTo(SkPoint pts[1]);
+        Verb autoClose(SkPoint pts[2]);
+    };
 
 #ifdef SK_DEBUG
   /** @cond UNIT_TEST */
-       void dump(bool forceClose, const char title[] = nil) const;
-       static void UnitTest();
+    void dump(bool forceClose, const char title[] = nil) const;
+    static void UnitTest();
   /** @endcond */
 #endif
 
-       /**     Return the number of bytes (padded to a multiple of 4) needed to
-               flatten the path into a block of memory. If bufferOrNil is not nil,
-               the path is written into it. The format of the buffer is private,
-               and can be used to create a new path by calling unflatten().
-       */
-       uint32_t    flatten(void* bufferOrNil) const;
-       void        unflatten(const void* buffer);
+    /** Return the number of bytes (padded to a multiple of 4) needed to
+        flatten the path into a block of memory. If bufferOrNil is not nil,
+        the path is written into it. The format of the buffer is private,
+        and can be used to create a new path by calling unflatten().
+    */
+    uint32_t    flatten(void* bufferOrNil) const;
+    void        unflatten(const void* buffer);
 
-       /**     Subdivide the path so that no segment is longer that dist.
-               If bendLines is true, then turn all line segments into curves.
-               If dst == nil, then the original path itself is modified (not const!)
-       */
-       void subdivide(SkScalar dist, bool bendLines, SkPath* dst = nil) const;
+    /** Subdivide the path so that no segment is longer that dist.
+        If bendLines is true, then turn all line segments into curves.
+        If dst == nil, then the original path itself is modified (not const!)
+    */
+    void subdivide(SkScalar dist, bool bendLines, SkPath* dst = nil) const;
 
     /** Return an SVG-compatible string of the path.
     */
     void toString(SkString*) const;
 
 private:
-       SkTDArray<SkPoint>      fPts;
-       SkTDArray<uint8_t>  fVerbs;
-       uint8_t                         fFillType;
+    SkTDArray<SkPoint>  fPts;
+    SkTDArray<uint8_t>  fVerbs;
+    uint8_t             fFillType;
 
-       friend class Iter;
-       void cons_moveto();
+    friend class Iter;
+    void cons_moveto();
 
-       friend class SkPathStroker;
-       /*      Append the first contour of path, ignoring path's initial point.
-               If no moveTo() call has been made for this contour, the first point is automatically set to (0,0).
-       */
-       void    pathTo(const SkPath& path);
-       /*      Append, in reverse order, the first contour of path, ignoring path's last point.
-               If no moveTo() call has been made for this contour, the first point is automatically set to (0,0).
-       */
-       void    reversePathTo(const SkPath&);
+    friend class SkPathStroker;
+    /*  Append the first contour of path, ignoring path's initial point.
+        If no moveTo() call has been made for this contour, the first point is automatically set to (0,0).
+    */
+    void    pathTo(const SkPath& path);
+    /*  Append, in reverse order, the first contour of path, ignoring path's last point.
+        If no moveTo() call has been made for this contour, the first point is automatically set to (0,0).
+    */
+    void    reversePathTo(const SkPath&);
 
-       friend const SkPoint* sk_get_path_points(const SkPath&, int index);
+    friend const SkPoint* sk_get_path_points(const SkPath&, int index);
 };
 
 #endif
index c560f67..2aca1c4 100644 (file)
@@ -1,3 +1,20 @@
+/* include/graphics/SkPathEffect.h
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #ifndef SkPathEffect_DEFINED
 #define SkPathEffect_DEFINED
 
@@ -7,134 +24,137 @@ class SkPath;
 
 /** \class SkPathEffect
 
-       SkPathEffect is the base class for objects in the SkPaint that affect
-       the geometry of a drawing primitive before it is transformed by the
-       canvas' matrix and drawn.
+    SkPathEffect is the base class for objects in the SkPaint that affect
+    the geometry of a drawing primitive before it is transformed by the
+    canvas' matrix and drawn.
 
-       Dashing is implemented as a subclass of SkPathEffect.
+    Dashing is implemented as a subclass of SkPathEffect.
 */
 class SkPathEffect : public SkFlattenable {
 public:
-       SkPathEffect() {}
-
-       /**     Given a src path and a width value, return true if the patheffect
-               has produced a new path (dst) and a new width value. If false is returned,
-               ignore dst and width.
-               On input, width >= 0 means the src should be stroked
-               On output, width >= 0 means the dst should be stroked
-       */
-       virtual bool filterPath(SkPath* dst, const SkPath& src, SkScalar* width);
-       /** overrides for SkFlattenable.
-               Subclasses should override this to (re)create their subclass.
-       */
     //  This method is not exported to java.
-       virtual Factory getFactory();
+    SkPathEffect() {}
+
+    /** Given a src path and a width value, return true if the patheffect
+        has produced a new path (dst) and a new width value. If false is returned,
+        ignore dst and width.
+        On input, width >= 0 means the src should be stroked
+        On output, width >= 0 means the dst should be stroked
+    */
+    //  This method is not exported to java.
+    virtual bool filterPath(SkPath* dst, const SkPath& src, SkScalar* width);
+    /** overrides for SkFlattenable.
+        Subclasses should override this to (re)create their subclass.
+    */
+    //  This method is not exported to java.
+    virtual Factory getFactory();
 
 protected:
-       // visible to our subclasses
-       SkPathEffect(SkRBuffer&) {}
+    // visible to our subclasses
+    SkPathEffect(SkRBuffer&) {}
 
 private:
-       // illegal
-       SkPathEffect(const SkPathEffect&);
-       SkPathEffect& operator=(const SkPathEffect&);
+    // illegal
+    SkPathEffect(const SkPathEffect&);
+    SkPathEffect& operator=(const SkPathEffect&);
 };
 
-/**    \class SkPairPathEffect
+/** \class SkPairPathEffect
 
-       Common baseclass for Compose and Sum. This subclass manages two pathEffects,
-       including flattening them. It does nothing in filterPath, and is only useful
-       for managing the lifetimes of its two arguments.
+    Common baseclass for Compose and Sum. This subclass manages two pathEffects,
+    including flattening them. It does nothing in filterPath, and is only useful
+    for managing the lifetimes of its two arguments.
 */
-//  This class is not exported to java.
 class SkPairPathEffect : public SkPathEffect {
 public:
-       SkPairPathEffect(SkPathEffect* pe0, SkPathEffect* pe1);
-       virtual ~SkPairPathEffect();
+    SkPairPathEffect(SkPathEffect* pe0, SkPathEffect* pe1);
+    virtual ~SkPairPathEffect();
 
-       // overrides
+    // overrides
 
     //  This method is not exported to java.
-       virtual void flatten(SkWBuffer&);
+    virtual void flatten(SkWBuffer&);
 
 protected:
-       // these are visible to our subclasses
-       SkPathEffect* fPE0, *fPE1;
-       SkPairPathEffect(SkRBuffer&);
+    // these are visible to our subclasses
+    SkPathEffect* fPE0, *fPE1;
+    SkPairPathEffect(SkRBuffer&);
     
 private:
     typedef SkPathEffect INHERITED;
 };
 
-/**    \class SkComposePathEffect
+/** \class SkComposePathEffect
 
-       This subclass of SkPathEffect composes its two arguments, to create
-       a compound pathEffect.
+    This subclass of SkPathEffect composes its two arguments, to create
+    a compound pathEffect.
 */
 class SkComposePathEffect : public SkPairPathEffect {
 public:
-       /**     Construct a pathEffect whose effect is to apply first the inner pathEffect
-               and the the outer pathEffect (e.g. outer(inner(path)))
-               The reference counts for outer and inner are both incremented in the constructor,
-               and decremented in the destructor.
-       */
-       SkComposePathEffect(SkPathEffect* outer, SkPathEffect* inner)
-               : SkPairPathEffect(outer, inner) {}
-
-       // overrides
+    /** Construct a pathEffect whose effect is to apply first the inner pathEffect
+        and the the outer pathEffect (e.g. outer(inner(path)))
+        The reference counts for outer and inner are both incremented in the constructor,
+        and decremented in the destructor.
+    */
+    SkComposePathEffect(SkPathEffect* outer, SkPathEffect* inner)
+        : SkPairPathEffect(outer, inner) {}
+
+    // overrides
     
-       virtual bool filterPath(SkPath* dst, const SkPath& src, SkScalar* width);
+    //  This method is not exported to java.
+    virtual bool filterPath(SkPath* dst, const SkPath& src, SkScalar* width);
 
-       // overrides for SkFlattenable
+    // overrides for SkFlattenable
 
     //  This method is not exported to java.
-       virtual Factory getFactory();
+    virtual Factory getFactory();
 
 private:
-       SkPathEffect* fOuter, *fInner;
+    SkPathEffect* fOuter, *fInner;
 
-       static SkFlattenable* CreateProc(SkRBuffer&);
-       SkComposePathEffect(SkRBuffer& buffer) : SkPairPathEffect(buffer) {}
+    static SkFlattenable* CreateProc(SkRBuffer&);
+    SkComposePathEffect(SkRBuffer& buffer) : SkPairPathEffect(buffer) {}
 
-       // illegal
-       SkComposePathEffect(const SkComposePathEffect&);
-       SkComposePathEffect& operator=(const SkComposePathEffect&);
+    // illegal
+    SkComposePathEffect(const SkComposePathEffect&);
+    SkComposePathEffect& operator=(const SkComposePathEffect&);
     
     typedef SkPairPathEffect INHERITED;
 };
 
-/**    \class SkSumPathEffect
+/** \class SkSumPathEffect
 
-       This subclass of SkPathEffect applies two pathEffects, one after the other.
-       Its filterPath() returns true if either of the effects succeeded.
+    This subclass of SkPathEffect applies two pathEffects, one after the other.
+    Its filterPath() returns true if either of the effects succeeded.
 */
 class SkSumPathEffect : public SkPairPathEffect {
 public:
-       /**     Construct a pathEffect whose effect is to apply two effects, in sequence.
-               (e.g. first(path) + second(path))
-               The reference counts for first and second are both incremented in the constructor,
-               and decremented in the destructor.
-       */
-       SkSumPathEffect(SkPathEffect* first, SkPathEffect* second)
-               : SkPairPathEffect(first, second) {}
-
-       // overrides
-       virtual bool filterPath(SkPath* dst, const SkPath& src, SkScalar* width);
+    /** Construct a pathEffect whose effect is to apply two effects, in sequence.
+        (e.g. first(path) + second(path))
+        The reference counts for first and second are both incremented in the constructor,
+        and decremented in the destructor.
+    */
+    SkSumPathEffect(SkPathEffect* first, SkPathEffect* second)
+        : SkPairPathEffect(first, second) {}
+
+    // overrides
+    //  This method is not exported to java.
+    virtual bool filterPath(SkPath* dst, const SkPath& src, SkScalar* width);
 
-       // overrides for SkFlattenable
+    // overrides for SkFlattenable
 
     //  This method is not exported to java.
-       virtual Factory getFactory();
+    virtual Factory getFactory();
 
 private:
-       SkPathEffect* fFirst, *fSecond;
+    SkPathEffect* fFirst, *fSecond;
 
-       static SkFlattenable* CreateProc(SkRBuffer&);
-       SkSumPathEffect(SkRBuffer& buffer) : SkPairPathEffect(buffer) {}
+    static SkFlattenable* CreateProc(SkRBuffer&);
+    SkSumPathEffect(SkRBuffer& buffer) : SkPairPathEffect(buffer) {}
 
-       // illegal
-       SkSumPathEffect(const SkSumPathEffect&);
-       SkSumPathEffect& operator=(const SkSumPathEffect&);
+    // illegal
+    SkSumPathEffect(const SkSumPathEffect&);
+    SkSumPathEffect& operator=(const SkSumPathEffect&);
 
     typedef SkPairPathEffect INHERITED;
 };
index 7d901a2..644fe5f 100644 (file)
@@ -1,3 +1,20 @@
+/* include/graphics/SkPathMeasure.h
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #ifndef SkPathMeasure_DEFINED
 #define SkPathMeasure_DEFINED
 
 
 class SkPathMeasure {
 public:
-       SkPathMeasure();
-       SkPathMeasure(const SkPath& path, bool forceClosed);
-       ~SkPathMeasure();
-
-       /** Assign a new path, or nil to have none.
-       */
-       void    setPath(const SkPath*, bool forceClosed);
-
-       /**     Return the total length of the current contour, or 0 if no path
-               is associated (e.g. resetPath(nil))
-       */
-       SkScalar getLength();
-
-       /**     Pins distance to 0 <= distance <= getLength(), and then computes
-               the corresponding position and tangent.
-               Returns false if there is no path, or a zero-length path was specified, in which case
-               position and tangent are unchanged.
-       */
-       bool getPosTan(SkScalar distance, SkPoint* position, SkVector* tangent);
-
-       enum MatrixFlags {
-               kGetPosition_MatrixFlag         = 0x01,
-               kGetTangent_MatrixFlag          = 0x02,
-               kGetPosAndTan_MatrixFlag        = kGetPosition_MatrixFlag | kGetTangent_MatrixFlag
-       };
-       /**     Pins distance to 0 <= distance <= getLength(), and then computes
-               the corresponding matrix (by calling getPosTan).
-               Returns false if there is no path, or a zero-length path was specified, in which case
-               matrix is unchanged.
-       */
-       bool getMatrix(SkScalar distance, SkMatrix* matrix, MatrixFlags flags = kGetPosAndTan_MatrixFlag);
-       /**     Given a start and stop distance, return in dst the intervening segment(s).
-               If the segment is zero-length, return false, else return true.
-               startD and stopD are pinned to legal values (0..getLength()). If startD <= stopD
-               then return false (and leave dst untouched).
-               Begin the segment with a moveTo if startWithMoveTo is true
-       */
-       bool getSegment(SkScalar startD, SkScalar stopD, SkPath* dst, bool startWithMoveTo);
-
-       /**     Return true if the current contour is closed()
-       */
-       bool isClosed();
-
-       /**     Move to the next contour in the path. Return true if one exists, or false if
-               we're done with the path.
-       */
-       bool nextContour();
+    SkPathMeasure();
+    SkPathMeasure(const SkPath& path, bool forceClosed);
+    ~SkPathMeasure();
+
+    /** Assign a new path, or nil to have none.
+    */
+    void    setPath(const SkPath*, bool forceClosed);
+
+    /** Return the total length of the current contour, or 0 if no path
+        is associated (e.g. resetPath(nil))
+    */
+    SkScalar getLength();
+
+    /** Pins distance to 0 <= distance <= getLength(), and then computes
+        the corresponding position and tangent.
+        Returns false if there is no path, or a zero-length path was specified, in which case
+        position and tangent are unchanged.
+    */
+    bool getPosTan(SkScalar distance, SkPoint* position, SkVector* tangent);
+
+    enum MatrixFlags {
+        kGetPosition_MatrixFlag     = 0x01,
+        kGetTangent_MatrixFlag      = 0x02,
+        kGetPosAndTan_MatrixFlag    = kGetPosition_MatrixFlag | kGetTangent_MatrixFlag
+    };
+    /** Pins distance to 0 <= distance <= getLength(), and then computes
+        the corresponding matrix (by calling getPosTan).
+        Returns false if there is no path, or a zero-length path was specified, in which case
+        matrix is unchanged.
+    */
+    bool getMatrix(SkScalar distance, SkMatrix* matrix, MatrixFlags flags = kGetPosAndTan_MatrixFlag);
+    /** Given a start and stop distance, return in dst the intervening segment(s).
+        If the segment is zero-length, return false, else return true.
+        startD and stopD are pinned to legal values (0..getLength()). If startD <= stopD
+        then return false (and leave dst untouched).
+        Begin the segment with a moveTo if startWithMoveTo is true
+    */
+    bool getSegment(SkScalar startD, SkScalar stopD, SkPath* dst, bool startWithMoveTo);
+
+    /** Return true if the current contour is closed()
+    */
+    bool isClosed();
+
+    /** Move to the next contour in the path. Return true if one exists, or false if
+        we're done with the path.
+    */
+    bool nextContour();
 
 #ifdef SK_DEBUG
-       void    dump();
-       static void UnitTest();
+    void    dump();
+    static void UnitTest();
 #endif
 
 private:
-       SkPath::Iter    fIter;
-       const SkPath*   fPath;
-       SkScalar                fLength;                        // relative to the current contour
-       int                             fFirstPtIndex;          // relative to the current contour
-       bool                    fIsClosed;                      // relative to the current contour
-       bool                    fForceClosed;
-
-       struct Segment {
-               SkScalar        fDistance;      // total distance up to this point
-               unsigned        fPtIndex : 15;
-               unsigned        fTValue : 15;
-               unsigned        fType : 2;
-
-               SkScalar getScalarT() const;
-       };
-       SkTDArray<Segment>      fSegments;
-
-       static const Segment* NextSegment(const Segment*);
-
-       void     buildSegments();
-       SkScalar compute_quad_segs(const SkPoint pts[3], SkScalar distance,
-                                                               int mint, int maxt, int ptIndex);
-       SkScalar compute_cubic_segs(const SkPoint pts[3], SkScalar distance,
-                                                               int mint, int maxt, int ptIndex);
-       const Segment* distanceToSegment(SkScalar distance, SkScalar* t);
-
-       // illegal (for now)
-       SkPathMeasure(const SkPathMeasure&);
-       SkPathMeasure& operator=(const SkPathMeasure&);
+    SkPath::Iter    fIter;
+    const SkPath*   fPath;
+    SkScalar        fLength;            // relative to the current contour
+    int             fFirstPtIndex;      // relative to the current contour
+    bool            fIsClosed;          // relative to the current contour
+    bool            fForceClosed;
+
+    struct Segment {
+        SkScalar    fDistance;  // total distance up to this point
+        unsigned    fPtIndex : 15;
+        unsigned    fTValue : 15;
+        unsigned    fType : 2;
+
+        SkScalar getScalarT() const;
+    };
+    SkTDArray<Segment>  fSegments;
+
+    static const Segment* NextSegment(const Segment*);
+
+    void     buildSegments();
+    SkScalar compute_quad_segs(const SkPoint pts[3], SkScalar distance,
+                                int mint, int maxt, int ptIndex);
+    SkScalar compute_cubic_segs(const SkPoint pts[3], SkScalar distance,
+                                int mint, int maxt, int ptIndex);
+    const Segment* distanceToSegment(SkScalar distance, SkScalar* t);
+
+    // illegal (for now)
+    SkPathMeasure(const SkPathMeasure&);
+    SkPathMeasure& operator=(const SkPathMeasure&);
 };
 
 #endif
index 6dbcf58..8127103 100644 (file)
@@ -1,3 +1,20 @@
+/* include/graphics/SkPorterDuff.h
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #ifndef SkPorterDuff_DEFINED
 #define SkPorterDuff_DEFINED
 
@@ -7,35 +24,35 @@ class SkXfermode;
 
 class SkPorterDuff {
 public:
-       /**     List of predefined xfermodes. In general, the algebra for the modes
-               uses the following symbols:
-               Sa, Sc  - source alpha and color
-               Da, Dc - destination alpha and color (before compositing)
-               [a, c] - Resulting (alpha, color) values
-               For these equations, the colors are in premultiplied state.
-               If no xfermode is specified, kSrcOver is assumed.
-       */
-       enum Mode {
-               kClear_Mode,    //!< [0, 0]
-               kSrc_Mode,              //!< [Sa, Sc]
-               kDst_Mode,              //!< [Da, Dc]
-               kSrcOver_Mode,  //!< [Sa + (1 - Sa)*Da, Rc = Sc + (1 - Sa)*Dc] this is the default mode
-               kDstOver_Mode,  //!< [Sa + (1 - Sa)*Da, Rc = Dc + (1 - Da)*Sc]
-               kSrcIn_Mode,    //!< [Sa * Da, Sc * Da]
-               kDstIn_Mode,    //!< [Sa * Da, Sa * Dc]
-               kSrcOut_Mode,   //!< [Sa * (1 - Da), Sc * (1 - Da)]
-               kDstOut_Mode,   //!< [Da * (1 - Sa), Dc * (1 - Sa)]
-               kSrcATop_Mode,  //!< [Da, Sc * Da + (1 - Sa) * Dc]
-               kDstATop_Mode,  //!< [Sa, Sa * Dc + Sc * (1 - Da)]
-               kXor_Mode,              //!< [Sa + Da - 2 * Sa * Da, Sc * (1 - Da) + (1 - Sa) * Dc]
+    /** List of predefined xfermodes. In general, the algebra for the modes
+        uses the following symbols:
+        Sa, Sc  - source alpha and color
+        Da, Dc - destination alpha and color (before compositing)
+        [a, c] - Resulting (alpha, color) values
+        For these equations, the colors are in premultiplied state.
+        If no xfermode is specified, kSrcOver is assumed.
+    */
+    enum Mode {
+        kClear_Mode,    //!< [0, 0]
+        kSrc_Mode,      //!< [Sa, Sc]
+        kDst_Mode,      //!< [Da, Dc]
+        kSrcOver_Mode,  //!< [Sa + (1 - Sa)*Da, Rc = Sc + (1 - Sa)*Dc] this is the default mode
+        kDstOver_Mode,  //!< [Sa + (1 - Sa)*Da, Rc = Dc + (1 - Da)*Sc]
+        kSrcIn_Mode,    //!< [Sa * Da, Sc * Da]
+        kDstIn_Mode,    //!< [Sa * Da, Sa * Dc]
+        kSrcOut_Mode,   //!< [Sa * (1 - Da), Sc * (1 - Da)]
+        kDstOut_Mode,   //!< [Da * (1 - Sa), Dc * (1 - Sa)]
+        kSrcATop_Mode,  //!< [Da, Sc * Da + (1 - Sa) * Dc]
+        kDstATop_Mode,  //!< [Sa, Sa * Dc + Sc * (1 - Da)]
+        kXor_Mode,      //!< [Sa + Da - 2 * Sa * Da, Sc * (1 - Da) + (1 - Sa) * Dc]
         kDarken_Mode,   //!< [Sa + Da - Sa\u00B7Da, Sc\u00B7(1 - Da) + Dc\u00B7(1 - Sa) + min(Sc, Dc)]
         kLighten_Mode,  //!< [Sa + Da - Sa\u00B7Da, Sc\u00B7(1 - Da) + Dc\u00B7(1 - Sa) + max(Sc, Dc)]
 
-               kModeCount
-       };
-       /**     Return an SkXfermode object for the specified mode.
-       */
-       static SkXfermode* CreateXfermode(Mode mode);
+        kModeCount
+    };
+    /** Return an SkXfermode object for the specified mode.
+    */
+    static SkXfermode* CreateXfermode(Mode mode);
     
     /** Return a function pointer to a routine that applies the specified porter-duff
         transfer mode.
index 72d15e4..343cf22 100644 (file)
@@ -1,3 +1,20 @@
+/* include/graphics/SkPrefix_Debug_Fixed.h
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #ifndef SkPrefix_Debug_Fixed_DEFINED
 #define SkPrefix_Debug_Fixed_DEFINED
 
index 81238ab..a708c21 100644 (file)
@@ -1,3 +1,20 @@
+/* include/graphics/SkPrefix_Release_Fixed.h
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #ifndef SkPrefix_Release_Fixed_DEFINED
 
 #define SkPrefix_Release_Fixed_DEFINED
index 64351c8..5783f83 100644 (file)
@@ -1,3 +1,20 @@
+/* include/graphics/SkProgressBarView.h
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #ifndef SkProgressBarView_DEFINED
 #define SkProgressBarView_DEFINED
 
 #include "SkAnimator.h"
 
 class SkProgressBarView : public SkWidgetView {
-       public:
-               SkProgressBarView();
-               //SkProgressBarView(int max);
-                               
-               //inflate: "sk-progress"
-       
-               void reset();   //reset progress to zero
-               void setProgress(int progress);
-               void changeProgress(int diff);
-               void setMax(int max);
-               
-               int getProgress() const { return fProgress; }
-               int getMax() const { return fMax; }
-       
-       protected:
-               //overrides
-               virtual void onInflate(const SkDOM& dom, const SkDOM::Node* node);
-               virtual void onSizeChange();
-               virtual void onDraw(SkCanvas* canvas);
-               virtual bool onEvent(const SkEvent& evt);
-       
-       private:
-               SkAnimator      fAnim;
-               int                     fProgress;
-               int                     fMax;
-               
-               typedef SkWidgetView INHERITED;
+    public:
+        SkProgressBarView();
+        //SkProgressBarView(int max);
+                
+        //inflate: "sk-progress"
+    
+        void reset();   //reset progress to zero
+        void setProgress(int progress);
+        void changeProgress(int diff);
+        void setMax(int max);
+        
+        int getProgress() const { return fProgress; }
+        int getMax() const { return fMax; }
+    
+    protected:
+        //overrides
+        virtual void onInflate(const SkDOM& dom, const SkDOM::Node* node);
+        virtual void onSizeChange();
+        virtual void onDraw(SkCanvas* canvas);
+        virtual bool onEvent(const SkEvent& evt);
+    
+    private:
+        SkAnimator  fAnim;
+        int         fProgress;
+        int         fMax;
+        
+        typedef SkWidgetView INHERITED;
 };
 
 
index 3a323b0..ec714bf 100644 (file)
@@ -1,3 +1,20 @@
+/* include/graphics/SkRasterizer.h
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #ifndef SkRasterizer_DEFINED
 #define SkRasterizer_DEFINED
 
index 679f955..ba6e73a 100644 (file)
+/* include/graphics/SkRefCnt.h
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #ifndef SkRefCnt_DEFINED
 #define SkRefCnt_DEFINED
 
 #include "SkTypes.h"
 
-/**    \class SkRefCnt
+/** \class SkRefCnt
 
-       SkRefCnt is the base class for objects that may be shared by multiple objects.
-       When a new owner wants a reference, it calls ref(). When an owner wants to release
-       its reference, it calls unref(). When the shared object's reference count goes to
-       zero as the result of an unref() call, its (virtual) destructor is called. It is
-       an error for the destructor to be called explicitly (or via the object going out
-       of scope on the stack or calling delete) if getRefCnt() > 1.
+    SkRefCnt is the base class for objects that may be shared by multiple objects.
+    When a new owner wants a reference, it calls ref(). When an owner wants to release
+    its reference, it calls unref(). When the shared object's reference count goes to
+    zero as the result of an unref() call, its (virtual) destructor is called. It is
+    an error for the destructor to be called explicitly (or via the object going out
+    of scope on the stack or calling delete) if getRefCnt() > 1.
 */
 class SkRefCnt {
 public:
-       /**     Default construct, initializing the reference count to 1.
-       */
-                       SkRefCnt() : fRefCnt(1) {}
-       /**      Destruct, asserting that the reference count is 1.
-       */
-       virtual ~SkRefCnt() { SkASSERT(fRefCnt == 1); }
+    /** Default construct, initializing the reference count to 1.
+    */
+            SkRefCnt() : fRefCnt(1) {}
+    /**  Destruct, asserting that the reference count is 1.
+    */
+    virtual ~SkRefCnt() { SkASSERT(fRefCnt == 1); }
 
-       /**     Return the reference count.
-       */
-       int             getRefCnt() const { return fRefCnt; }
-       /**     Increment the reference count. Must be balanced by a call to unref().
-       */
-       void    ref() const { SkASSERT(fRefCnt > 0); ++fRefCnt; }
-       /**     Decrement the reference count. If the reference count is 1 before the
-               decrement, then call delete on the object. Note that if this is the case,
-               then the object needs to have been allocated via new, and not on the stack.
-       */
-       void    unref() const
-       {
-               SkASSERT(fRefCnt > 0);
-               if (fRefCnt == 1)
-                       delete this;
-               else
-                       --fRefCnt;
-       }
+    /** Return the reference count.
+    */
+    int     getRefCnt() const { return fRefCnt; }
+    /** Increment the reference count. Must be balanced by a call to unref().
+    */
+    void    ref() const { SkASSERT(fRefCnt > 0); ++fRefCnt; }
+    /** Decrement the reference count. If the reference count is 1 before the
+        decrement, then call delete on the object. Note that if this is the case,
+        then the object needs to have been allocated via new, and not on the stack.
+    */
+    void    unref() const
+    {
+        SkASSERT(fRefCnt > 0);
+        if (fRefCnt == 1)
+            delete this;
+        else
+            --fRefCnt;
+    }
 
-       /**     Helper version of ref(), that first checks to see if this is not nil.
-               If this is nil, then do nothing.
-       */
-       void safeRef() const { if (this) this->ref(); }
-       /**     Helper version of unref(), that first checks to see if this is not nil.
-               If this is nil, then do nothing.
-       */
-       void safeUnref() const { if (this) this->unref(); }
+    /** Helper version of ref(), that first checks to see if this is not nil.
+        If this is nil, then do nothing.
+    */
+    void safeRef() const { if (this) this->ref(); }
+    /** Helper version of unref(), that first checks to see if this is not nil.
+        If this is nil, then do nothing.
+    */
+    void safeUnref() const { if (this) this->unref(); }
 
 private:
-       mutable int     fRefCnt;
+    mutable int fRefCnt;
 };
 
-/**    \class SkAutoUnref
+/** \class SkAutoUnref
 
-       SkAutoUnref is a stack-helper class that will automatically call unref() on
-       the object it points to when the SkAutoUnref object goes out of scope.
+    SkAutoUnref is a stack-helper class that will automatically call unref() on
+    the object it points to when the SkAutoUnref object goes out of scope.
 */
 class SkAutoUnref {
 public:
-       SkAutoUnref(SkRefCnt* obj) : fObj(obj) {}
-       ~SkAutoUnref();
+    SkAutoUnref(SkRefCnt* obj) : fObj(obj) {}
+    ~SkAutoUnref();
 
-       SkRefCnt*       get() const { return fObj; }
-       bool            ref();
-       bool            unref();
-       SkRefCnt*       detach();
+    SkRefCnt*   get() const { return fObj; }
+    bool        ref();
+    bool        unref();
+    SkRefCnt*   detach();
 
 private:
-       SkRefCnt*       fObj;
+    SkRefCnt*   fObj;
 };
 
-/**    Helper macro to safely assign one SkRefCnt* to another, checking for
-       nil in on each side of the assignment, and ensuring that ref() is called
-       before unref(), in case the two pointers point to the same object.
+/** Helper macro to safely assign one SkRefCnt* to another, checking for
+    nil in on each side of the assignment, and ensuring that ref() is called
+    before unref(), in case the two pointers point to the same object.
 */
-#define SkRefCnt_SafeAssign(dst, src)  \
-       do {                                                            \
-               if (src) src->ref();                    \
-               if (dst) dst->unref();                  \
-               dst = src;                                              \
-       } while (0)
+#define SkRefCnt_SafeAssign(dst, src)   \
+    do {                                \
+        if (src) src->ref();            \
+        if (dst) dst->unref();          \
+        dst = src;                      \
+    } while (0)
 
 #endif
 
index b6ae0df..4b14d04 100644 (file)
@@ -1,12 +1,29 @@
+/* include/graphics/SkSVGAttribute.h
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #ifndef SkSVGAttribute_DEFINED
 #define SkSVGAttribute_DEFINED
 
 #include "SkTypes.h"
 
 struct SkSVGAttribute {
-       const char* fName;
+    const char* fName;
 #ifdef SK_DEBUG
-       size_t fOffset;
+    size_t fOffset;
 #endif
 };
 
@@ -23,11 +40,11 @@ struct SkSVGAttribute {
 #endif
 
 #define SVG_ADD_ATTRIBUTE(attr) \
-       if (f_##attr.size() > 0) \
-               parser._addAttributeLen(#attr, f_##attr.c_str(), f_##attr.size())
+    if (f_##attr.size() > 0) \
+        parser._addAttributeLen(#attr, f_##attr.c_str(), f_##attr.size())
 
 #define SVG_ADD_ATTRIBUTE_ALIAS(attr, alias) \
-       if (f_##alias.size() > 0) \
-               parser._addAttributeLen(#attr, f_##alias.c_str(), f_##alias.size())
+    if (f_##alias.size() > 0) \
+        parser._addAttributeLen(#attr, f_##alias.c_str(), f_##alias.size())
 
 #endif // SkSVGAttribute_DEFINED
index 83b72d9..fff98cc 100644 (file)
@@ -1,3 +1,20 @@
+/* include/graphics/SkSVGBase.h
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #ifndef SkSVGBase_DEFINED
 #define SkSVGBase_DEFINED
 
@@ -7,10 +24,11 @@ class SkSVGParser;
 
 class SkSVGBase {
 public:
-       virtual ~SkSVGBase();
-       virtual void addAttribute(SkSVGParser& parser, int attrIndex, 
-               const char* attrValue, size_t attrLength);
-       virtual int getAttributes(const SkSVGAttribute** attrPtr) = 0;
+    virtual ~SkSVGBase();
+    virtual void addAttribute(SkSVGParser& parser, int attrIndex, 
+        const char* attrValue, size_t attrLength);
+    virtual int getAttributes(const SkSVGAttribute** attrPtr) = 0;
 };
 
-#endif // SkSVGBase_DEFINED
\ No newline at end of file
+#endif // SkSVGBase_DEFINEDes(const SkSVGAttribute** attrPtr) = 0;
+
index 4ec018d..2f30e42 100644 (file)
@@ -1,3 +1,20 @@
+/* include/graphics/SkSVGPaintState.h
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #ifndef SkSVGPaintState_DEFINED
 #define SkSVGPaintState_DEFINED
 
 
 class SkSVGPaint : public SkSVGBase {
 public:
-       enum Field {
-               kInitial = -1,
-               kClipPath,
-               kClipRule,
-               kEnableBackground,
-               kFill,
-               kFillRule,
-               kFilter,
-               kFontFamily,
-               kFontSize,
-               kLetterSpacing,
-               kMask,
-               kOpacity,
-               kStopColor,
-               kStopOpacity,
-               kStroke,
-               kStroke_Dasharray,
-               kStroke_Linecap,
-               kStroke_Linejoin,
-               kStroke_Miterlimit,
-               kStroke_Width,
-               kStyle,
-               kTransform,
-               kTerminal
-       };
+    enum Field {
+        kInitial = -1,
+        kClipPath,
+        kClipRule,
+        kEnableBackground,
+        kFill,
+        kFillRule,
+        kFilter,
+        kFontFamily,
+        kFontSize,
+        kLetterSpacing,
+        kMask,
+        kOpacity,
+        kStopColor,
+        kStopOpacity,
+        kStroke,
+        kStroke_Dasharray,
+        kStroke_Linecap,
+        kStroke_Linejoin,
+        kStroke_Miterlimit,
+        kStroke_Width,
+        kStyle,
+        kTransform,
+        kTerminal
+    };
 
-       SkSVGPaint();
-       virtual void addAttribute(SkSVGParser& parser, int attrIndex, 
-               const char* attrValue, size_t attrLength);
-       bool flush(SkSVGParser& , bool isFlushable, bool isDef);
-       virtual int getAttributes(const SkSVGAttribute** attrPtr); 
-       static void Push(SkSVGPaint** head, SkSVGPaint* add);
-       static void Pop(SkSVGPaint** head);
-       SkString* operator[](int index);
-       SkString fInitial;
-       SkString f_clipPath;
-       SkString f_clipRule;
-       SkString f_enableBackground;
-       SkString f_fill;
-       SkString f_fillRule;
-       SkString f_filter;
-       SkString f_fontFamily;
-       SkString f_fontSize;
-       SkString f_letterSpacing;
-       SkString f_mask;
-       SkString f_opacity;
-       SkString f_stopColor;
-       SkString f_stopOpacity;
-       SkString f_stroke;
-       SkString f_strokeDasharray;
-       SkString f_strokeLinecap;
-       SkString f_strokeLinejoin;
-       SkString f_strokeMiterlimit;
-       SkString f_strokeWidth;
-       SkString f_style; // unused, but allows array access to the rest
-       SkString f_transform;
+    SkSVGPaint();
+    virtual void addAttribute(SkSVGParser& parser, int attrIndex, 
+        const char* attrValue, size_t attrLength);
+    bool flush(SkSVGParser& , bool isFlushable, bool isDef);
+    virtual int getAttributes(const SkSVGAttribute** attrPtr); 
+    static void Push(SkSVGPaint** head, SkSVGPaint* add);
+    static void Pop(SkSVGPaint** head);
+    SkString* operator[](int index);
+    SkString fInitial;
+    SkString f_clipPath;
+    SkString f_clipRule;
+    SkString f_enableBackground;
+    SkString f_fill;
+    SkString f_fillRule;
+    SkString f_filter;
+    SkString f_fontFamily;
+    SkString f_fontSize;
+    SkString f_letterSpacing;
+    SkString f_mask;
+    SkString f_opacity;
+    SkString f_stopColor;
+    SkString f_stopOpacity;
+    SkString f_stroke;
+    SkString f_strokeDasharray;
+    SkString f_strokeLinecap;
+    SkString f_strokeLinejoin;
+    SkString f_strokeMiterlimit;
+    SkString f_strokeWidth;
+    SkString f_style; // unused, but allows array access to the rest
+    SkString f_transform;
 #ifdef SK_DEBUG
-       SkString fTerminal;
+    SkString fTerminal;
 #endif
-       SkString fTransformID;
-       static SkSVGAttribute gAttributes[];
-       static const int kAttributesSize;
+    SkString fTransformID;
+    static SkSVGAttribute gAttributes[];
+    static const int kAttributesSize;
 private:
-       void setSave(SkSVGParser& );
-       bool writeChangedAttributes(SkSVGParser& , SkSVGPaint& , bool* changed);
-       bool writeChangedElements(SkSVGParser& , SkSVGPaint& , bool* changed);
-       SkSVGPaint* fNext;
-       friend class SkSVGParser;
-       typedef SkSVGPaint BASE_CLASS;
+    void setSave(SkSVGParser& );
+    bool writeChangedAttributes(SkSVGParser& , SkSVGPaint& , bool* changed);
+    bool writeChangedElements(SkSVGParser& , SkSVGPaint& , bool* changed);
+    SkSVGPaint* fNext;
+    friend class SkSVGParser;
+    typedef SkSVGPaint BASE_CLASS;
 };
 
 #endif // SkSVGPaintState_DEFINED
index b001c22..60cbcbd 100644 (file)
@@ -1,3 +1,20 @@
+/* include/graphics/SkSVGParser.h
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #ifndef SkSVGParser_DEFINED
 #define SkSVGParser_DEFINED
 
@@ -16,50 +33,50 @@ class SkSVGElement;
 
 class SkSVGParser : public SkXMLParser {
 public:
-       SkSVGParser();
-       virtual ~SkSVGParser();
-       void _addAttribute(const char* attrName, const char* attrValue) {
-               fXMLWriter.addAttribute(attrName, attrValue); }
-       void _addAttribute(const char* attrName, SkString& attrValue) {
-               fXMLWriter.addAttribute(attrName, attrValue.c_str()); }
-       void _addAttributeLen(const char* attrName, const char* attrValue, size_t len) {
-               fXMLWriter.addAttributeLen(attrName, attrValue, len); }
-       void _endElement() { fXMLWriter.endElement(); }
-       int findAttribute(SkSVGBase* , const char* attrValue, size_t len, bool isPaint);
-       const char* getFinal();
-       SkTDict<SkSVGElement*>& getIDs() { return fIDs; }
-       SkString& getPaintLast(SkSVGPaint::Field field);
-       void _startElement(const char name[]) { fXMLWriter.startElement(name); }
-       void translate(SkSVGElement*, bool isDef);
-       void translateMatrix(SkString& , SkString* id);
-       static void ConvertToArray(SkString& vals);
+    SkSVGParser();
+    virtual ~SkSVGParser();
+    void _addAttribute(const char* attrName, const char* attrValue) {
+        fXMLWriter.addAttribute(attrName, attrValue); }
+    void _addAttribute(const char* attrName, SkString& attrValue) {
+        fXMLWriter.addAttribute(attrName, attrValue.c_str()); }
+    void _addAttributeLen(const char* attrName, const char* attrValue, size_t len) {
+        fXMLWriter.addAttributeLen(attrName, attrValue, len); }
+    void _endElement() { fXMLWriter.endElement(); }
+    int findAttribute(SkSVGBase* , const char* attrValue, size_t len, bool isPaint);
+    const char* getFinal();
+    SkTDict<SkSVGElement*>& getIDs() { return fIDs; }
+    SkString& getPaintLast(SkSVGPaint::Field field);
+    void _startElement(const char name[]) { fXMLWriter.startElement(name); }
+    void translate(SkSVGElement*, bool isDef);
+    void translateMatrix(SkString& , SkString* id);
+    static void ConvertToArray(SkString& vals);
 protected:
-       virtual bool onAddAttribute(const char name[], const char value[]);
-       bool onAddAttributeLen(const char name[], const char value[], size_t len);
-       virtual bool onEndElement(const char elem[]);
-       virtual bool onStartElement(const char elem[]);
-       bool onStartElementLen(const char elem[], size_t len);
-       virtual bool onText(const char text[], int len);
+    virtual bool onAddAttribute(const char name[], const char value[]);
+    bool onAddAttributeLen(const char name[], const char value[], size_t len);
+    virtual bool onEndElement(const char elem[]);
+    virtual bool onStartElement(const char elem[]);
+    bool onStartElementLen(const char elem[], size_t len);
+    virtual bool onText(const char text[], int len);
 private:
-       bool isStrokeAndFill(SkSVGPaint** stroke, SkSVGPaint** fill);
-       static SkSVGElement* CreateElement(SkSVGTypes type, SkSVGElement* parent);
-       static void Delete(SkTDArray<SkSVGElement*>& fChildren);
-       static SkSVGTypes GetType(const char name[], size_t len);
-       SkSVGPaint* fHead;
-       SkSVGPaint fEmptyPaint; 
-       SkSVGPaint fLastFlush;
-       SkString fLastColor;
-       SkMatrix fLastTransform;
-       SkTDArray<SkSVGElement*> fChildren;
-       SkTDict<SkSVGElement*> fIDs;
-       SkTDArray<SkSVGElement*> fParents;
-       SkDynamicMemoryWStream fStream;
-       SkXMLStreamWriter fXMLWriter;
-       SkSVGElement*   fCurrElement;
-       SkBool8 fInSVG;
-       SkBool8 fSuppressPaint;
-       friend class SkSVGPaint;
-       friend class SkSVGGradient;
+    bool isStrokeAndFill(SkSVGPaint** stroke, SkSVGPaint** fill);
+    static SkSVGElement* CreateElement(SkSVGTypes type, SkSVGElement* parent);
+    static void Delete(SkTDArray<SkSVGElement*>& fChildren);
+    static SkSVGTypes GetType(const char name[], size_t len);
+    SkSVGPaint* fHead;
+    SkSVGPaint fEmptyPaint; 
+    SkSVGPaint fLastFlush;
+    SkString fLastColor;
+    SkMatrix fLastTransform;
+    SkTDArray<SkSVGElement*> fChildren;
+    SkTDict<SkSVGElement*> fIDs;
+    SkTDArray<SkSVGElement*> fParents;
+    SkDynamicMemoryWStream fStream;
+    SkXMLStreamWriter fXMLWriter;
+    SkSVGElement*   fCurrElement;
+    SkBool8 fInSVG;
+    SkBool8 fSuppressPaint;
+    friend class SkSVGPaint;
+    friend class SkSVGGradient;
 };
 
 #endif // SkSVGParser_DEFINED
index b87bfbd..24404ad 100644 (file)
@@ -1,30 +1,47 @@
+/* include/graphics/SkSVGTypes.h
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #ifndef SkSVGTypes_DEFINED
 #define SkSVGTypes_DEFINED
 
 enum SkSVGTypes {
-       SkSVGType_Circle,
-       SkSVGType_ClipPath,
-       SkSVGType_Defs,
-       SkSVGType_Ellipse,
-       SkSVGType_FeColorMatrix,
-       SkSVGType_Filter,
-       SkSVGType_G,
-       SkSVGType_Image,
-       SkSVGType_Line,
-       SkSVGType_LinearGradient,
-       SkSVGType_Mask,
-       SkSVGType_Metadata,
-       SkSVGType_Path,
-       SkSVGType_Polygon,
-       SkSVGType_Polyline,
-       SkSVGType_RadialGradient,
-       SkSVGType_Rect,
-       SkSVGType_SVG,
-       SkSVGType_Stop,
-       SkSVGType_Symbol,
-       SkSVGType_Text,
-       SkSVGType_Tspan,
-       SkSVGType_Use
+    SkSVGType_Circle,
+    SkSVGType_ClipPath,
+    SkSVGType_Defs,
+    SkSVGType_Ellipse,
+    SkSVGType_FeColorMatrix,
+    SkSVGType_Filter,
+    SkSVGType_G,
+    SkSVGType_Image,
+    SkSVGType_Line,
+    SkSVGType_LinearGradient,
+    SkSVGType_Mask,
+    SkSVGType_Metadata,
+    SkSVGType_Path,
+    SkSVGType_Polygon,
+    SkSVGType_Polyline,
+    SkSVGType_RadialGradient,
+    SkSVGType_Rect,
+    SkSVGType_SVG,
+    SkSVGType_Stop,
+    SkSVGType_Symbol,
+    SkSVGType_Text,
+    SkSVGType_Tspan,
+    SkSVGType_Use
 };
 
 #endif // SkSVGTypes_DEFINED
index db12c73..80093e9 100644 (file)
@@ -1,3 +1,20 @@
+/* include/graphics/SkScalerContext.h
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #ifndef SkScalerContext_DEFINED
 #define SkScalerContext_DEFINED
 
@@ -11,77 +28,93 @@ class SkPaint;
 class SkPathEffect;
 class SkRasterizer;
 
-#define SK_UnknownAuxScalerContextID    0
-#define SK_MaxAuxScalerContextID        16
-
 struct SkGlyph {
-       void*       fImage;
-       SkPath*     fPath;
-       SkFixed     fAdvanceX, fAdvanceY;
+    void*       fImage;
+    SkPath*     fPath;
+    SkFixed     fAdvanceX, fAdvanceY;
 
-       uint16_t        fGlyphID;
-       uint16_t        fWidth, fHeight, fRowBytes;
-       int16_t         fTop, fLeft;
+    uint16_t    f_GlyphID;
+    uint16_t    fWidth, fHeight, fRowBytes;
+    int16_t     fTop, fLeft;
 
-       uint16_t        fCharCode;      // might go away with line layout. really wants 20bits
-       uint8_t         fMaskFormat;
-       SkBool8     fUseAuxContext; // just need 1-bit for this field
+    uint8_t     fMaskFormat;
 
-       size_t computeImageSize() const;
+    unsigned    getGlyphID(unsigned baseGlyphCount) const
+    {
+        SkASSERT(f_GlyphID >= baseGlyphCount);
+        return f_GlyphID - baseGlyphCount;
+    }
+
+    size_t computeImageSize() const;
 };
 
 class SkScalerContext {
 public:
-       struct Rec {
-               SkScalar        fTextSize, fPreScaleX, fPreSkewX;
-               SkScalar        fPost2x2[2][2];
-               SkScalar        fFrameWidth, fMiterLimit;
-               SkBool8         fUseHints;
-               SkBool8         fFrameAndFill;
-               SkBool8         fDoAA;
-               uint8_t         fStrokeJoin;
-
-               void    getMatrixFrom2x2(SkMatrix*) const;
-               void    getLocalMatrix(SkMatrix*) const;
-               void    getSingleMatrix(SkMatrix*) const;
-       };
-
-       SkScalerContext(const SkDescriptor* desc);
-       virtual ~SkScalerContext();
-
-       void    getMetrics(SkGlyph*);
-       void    getImage(const SkGlyph&);
-       void    getPath(const SkGlyph&, SkPath*);
-       void    getLineHeight(SkPoint* above, SkPoint* below);
-
-       static inline void MakeRec(const SkPaint&, const SkMatrix*, Rec* rec);
-       static SkScalerContext* Create(const SkDescriptor*);
+    enum Hints {
+        kNo_Hints,
+        kAuto_Hints,
+        kNative_Hints
+    };
+    struct Rec {
+        SkScalar    fTextSize, fPreScaleX, fPreSkewX;
+        SkScalar    fPost2x2[2][2];
+        SkScalar    fFrameWidth, fMiterLimit;
+        uint8_t     fHints;
+        SkBool8     fFrameAndFill;
+        uint8_t     fMaskFormat;
+        uint8_t     fStrokeJoin;
+
+        void    getMatrixFrom2x2(SkMatrix*) const;
+        void    getLocalMatrix(SkMatrix*) const;
+        void    getSingleMatrix(SkMatrix*) const;
+    };
+
+    SkScalerContext(const SkDescriptor* desc);
+    virtual ~SkScalerContext();
+
+    void setBaseGlyphCount(unsigned baseGlyphCount) { fBaseGlyphCount = baseGlyphCount; }
+
+    uint16_t    charToGlyphID(SkUnichar uni);
+
+    unsigned    getGlyphCount() const { return this->generateGlyphCount(); }
+    void        getMetrics(SkGlyph*);
+    void        getImage(const SkGlyph&);
+    void        getPath(const SkGlyph&, SkPath*);
+    void        getLineHeight(SkPoint* above, SkPoint* below);
+
+    static inline void MakeRec(const SkPaint&, const SkMatrix*, Rec* rec);
+    static SkScalerContext* Create(const SkDescriptor*);
 
 protected:
-       Rec     fRec;
+    Rec         fRec;
+    unsigned    fBaseGlyphCount;
 
-       virtual void generateMetrics(SkGlyph*) = 0;
-       virtual void generateImage(const SkGlyph&) = 0;
-       virtual void generatePath(const SkGlyph&, SkPath*) = 0;
-       virtual void generateLineHeight(SkPoint* above, SkPoint* below) = 0;
+    virtual unsigned generateGlyphCount() const = 0;
+    virtual uint16_t generateCharToGlyph(SkUnichar) = 0;
+    virtual void generateMetrics(SkGlyph*) = 0;
+    virtual void generateImage(const SkGlyph&) = 0;
+    virtual void generatePath(const SkGlyph&, SkPath*) = 0;
+    virtual void generateLineHeight(SkPoint* above, SkPoint* below) = 0;
 
 private:
-       SkPathEffect*   fPathEffect;
-       SkMaskFilter*   fMaskFilter;
+    SkPathEffect*   fPathEffect;
+    SkMaskFilter*   fMaskFilter;
     SkRasterizer*   fRasterizer;
-       SkScalar                fDevFrameWidth;
+    SkScalar        fDevFrameWidth;
 
     void internalGetPath(const SkGlyph& glyph, SkPath* fillPath, SkPath* devPath, SkMatrix* fillToDevMatrix);
 
-    // we index into this with scalerContextID-1
-    SkScalerContext* fAuxContext[SK_MaxAuxScalerContextID];
+    mutable SkScalerContext* fAuxScalerContext;
+
+    SkScalerContext* getGlyphContext(const SkGlyph& glyph) const;
+    SkScalerContext* loadAuxContext() const;  // return loaded fAuxScalerContext or NULL
 };
 
-#define kRec_SkDescriptorTag                   SkSetFourByteTag('s', 'r', 'e', 'c')
-#define kTypeface_SkDescriptorTag              SkSetFourByteTag('t', 'p', 'f', 'c')
-#define kPathEffect_SkDescriptorTag            SkSetFourByteTag('p', 't', 'h', 'e')
-#define kMaskFilter_SkDescriptorTag            SkSetFourByteTag('m', 's', 'k', 'f')
-#define kRasterizer_SkDescriptorTag            SkSetFourByteTag('r', 'a', 's', 't')
+#define kRec_SkDescriptorTag            SkSetFourByteTag('s', 'r', 'e', 'c')
+#define kTypeface_SkDescriptorTag       SkSetFourByteTag('t', 'p', 'f', 'c')
+#define kPathEffect_SkDescriptorTag     SkSetFourByteTag('p', 't', 'h', 'e')
+#define kMaskFilter_SkDescriptorTag     SkSetFourByteTag('m', 's', 'k', 'f')
+#define kRasterizer_SkDescriptorTag     SkSetFourByteTag('r', 'a', 's', 't')
 
 #endif
 
index ee43a3c..514ad74 100644 (file)
@@ -1,3 +1,20 @@
+/* include/graphics/SkScrollBarView.h
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #ifndef SkScrollBarView_DEFINED
 #define SkScrollBarView_DEFINED
 
 
 class SkScrollBarView : public SkWidgetView {
 public:
-       SkScrollBarView();
+    SkScrollBarView();
 
-       unsigned getStart() const { return fStartPoint; }
-       unsigned getShown() const { return fShownLength; }
-       unsigned getTotal() const { return fTotalLength; }
+    unsigned getStart() const { return fStartPoint; }
+    unsigned getShown() const { return fShownLength; }
+    unsigned getTotal() const { return fTotalLength; }
 
-       void setStart(unsigned start);  
-       void setShown(unsigned shown);
-       void setTotal(unsigned total);
-       
+    void setStart(unsigned start);  
+    void setShown(unsigned shown);
+    void setTotal(unsigned total);
+    
 protected:
-       //overrides
-       virtual void onInflate(const SkDOM& dom, const SkDOM::Node* node);
-       virtual void onSizeChange();
-       virtual void onDraw(SkCanvas* canvas);
-       virtual bool onEvent(const SkEvent& evt);
+    //overrides
+    virtual void onInflate(const SkDOM& dom, const SkDOM::Node* node);
+    virtual void onSizeChange();
+    virtual void onDraw(SkCanvas* canvas);
+    virtual bool onEvent(const SkEvent& evt);
 
 private:
-       SkAnimator      fAnim;
-       unsigned        fTotalLength, fStartPoint, fShownLength;
-       
-       void adjust();
-       
-       typedef SkWidgetView INHERITED;
+    SkAnimator  fAnim;
+    unsigned    fTotalLength, fStartPoint, fShownLength;
+    
+    void adjust();
+    
+    typedef SkWidgetView INHERITED;
 };
-#endif
\ No newline at end of file
+#endif
+
index e823a7b..4069ec2 100644 (file)
@@ -1,3 +1,20 @@
+/* include/graphics/SkShader.h
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #ifndef SkShader_DEFINED
 #define SkShader_DEFINED
 
 
 class SkPath;
 
-/**    \class SkShader
+/** \class SkShader
 
-       SkShader is the based class for objects that return horizontal spans of colors during drawing.
-       A subclass of SkShader is installed in a SkPaint calling paint.setShader(shader). After that
-       any object (other than a bitmap) that is drawn with that paint will get its color(s) from the
-       shader.
+    SkShader is the based class for objects that return horizontal spans of colors during drawing.
+    A subclass of SkShader is installed in a SkPaint calling paint.setShader(shader). After that
+    any object (other than a bitmap) that is drawn with that paint will get its color(s) from the
+    shader.
 */
 class SkShader : public SkRefCnt {
 public:
-                       SkShader();
-       virtual ~SkShader();
-
-       /**     Return the shader's optional local matrix, or nil.
-       */
-       const SkMatrix* getLocalMatrix() const { return fLocalMatrix; }
-       /**     Set the shader's optional local matrix. If the specified matrix is identity, then
-               getLocalMatrix() will return nil.
-       */
-       void setLocalMatrix(const SkMatrix&);
-
-       enum TileMode {
-               kClamp_TileMode,        //!< replicate the edge color if the shader draws outside of its original bounds
-               kRepeat_TileMode,       //!< repeat the shader's image horizontally and vertically
-               kMirror_TileMode,       //!< repeat the shader's image horizontally and vertically, alternating mirror images so that adjacent images always seam
-
-               kTileModeCount
-       };
-
-       // override these in your subclass
-
-       enum Flags {
-               kOpaqueAlpha_Flag       = 0x01, //!< set if all of the colors will be opaque (if so, kConstAlpha_Flag will not be set)
-               kConstAlpha_Flag        = 0x02, //!< set if all of the colors have the same (non-opaque) alpha
-               kHasSpan16_Flag         = 0x04, //!< set if this shader's shadeSpanOpaque16() method can be called
-
-               kFlagsMask                      = kOpaqueAlpha_Flag | kConstAlpha_Flag | kHasSpan16_Flag
-       };
-
-       /**     Called sometimes before drawing with this shader.
-               Return the type of alpha your shader will return.
-               The default implementation returns 0. Your subclass should override if it can
-               (even sometimes) report a non-zero value, since that will enable various blitters
-               to perform faster.
-       */
-       virtual U32             getFlags();
-
-       /**     Called once before drawing, with the current paint and
-               device matrix. Return true if your shader supports these
-               parameters, or false if not. If false is returned, nothing
-               will be drawn.
-       */
-       virtual bool    setContext(     const SkBitmap& device,
-                                                               const SkPaint& paint,
-                                                               const SkMatrix& matrix);
-
-       /**     Called for each span of the object being drawn. Your subclass
-               should set the appropriate colors (with premultiplied alpha) that
-               correspond to the specified device coordinates.
-       */
-       virtual void    shadeSpan(int x, int y, SkPMColor[], int count) = 0;
-       /**     Called only for 16bit devices when getFlags() returns kOpaqueAlphaFlag | kHasSpan16_Flag
-       */
-       virtual void    shadeSpanOpaque16(int x, int y, U16[], int count);
-       /**     Similar to shadeSpan, but only returns the alpha-channel for a span.
-               The default implementation calls shadeSpan() and then extracts the alpha
-               values from the returned colors.
-       */
-       virtual void    shadeSpanAlpha(int x, int y, U8 alpha[], int count);
-
-       /**     Helper function that returns true if this shader's shadeSpanOpaque16() method can
-               be called.
-       */
-       bool canCallShadeSpanOpaque16()
-       {
-               return SkShader::CanCallShadeSpanOpaque16(this->getFlags());
-       }
-
-       /**     Helper to check the flags to know if it is legal to call shadeSpanOpaque16()
-       */
-       static bool CanCallShadeSpanOpaque16(U32 flags)
-       {
-               return (flags & (kOpaqueAlpha_Flag | kHasSpan16_Flag)) == (kOpaqueAlpha_Flag | kHasSpan16_Flag);
-       }
-
-       //////////////////////////////////////////////////////////////////////////
-       //      Factory methods for stock shaders
-
-       /**     Call this to create a new shader that will draw with the specified bitmap.
-               @param src      The bitmap to use inside the shader
-               @param transferOwnershipOfPixels        If true, the shader will call setOwnsPixels(true) on its private bitmap
-                                                                                       and setOwnsPixels(false) on the src bitmap, resulting in the bitmap's pixels
-                                                                                       being disposed when the shader is deleted.
-               @param ft       The filter type to be used when scaling or rotating the bitmap when it is drawn.
-               @param tmx      The tiling mode to use when sampling the bitmap in the x-direction.
-               @param tmy      The tiling mode to use when sampling the bitmap in the y-direction.
-               @return         Returns a new shader object. Note: this function never returns nil.
-       */
-       static SkShader* CreateBitmapShader(const SkBitmap& src,
-                                                                               bool transferOwnershipOfPixels,
-                                                                               SkPaint::FilterType ft,
-                                                                               TileMode tmx, TileMode tmy);
+            SkShader();
+    virtual ~SkShader();
+
+    /** Return the shader's optional local matrix, or null.
+    */
+    const SkMatrix* getLocalMatrix() const { return fLocalMatrix; }
+    /** Set the shader's optional local matrix. If the specified matrix is identity, then
+        getLocalMatrix() will return null.
+    */
+    void setLocalMatrix(const SkMatrix&);
+
+    enum TileMode {
+        kClamp_TileMode,    //!< replicate the edge color if the shader draws outside of its original bounds
+        kRepeat_TileMode,   //!< repeat the shader's image horizontally and vertically
+        kMirror_TileMode,   //!< repeat the shader's image horizontally and vertically, alternating mirror images so that adjacent images always seam
+
+        kTileModeCount
+    };
+
+    // override these in your subclass
+
+    enum Flags {
+        kOpaqueAlpha_Flag   = 0x01, //!< set if all of the colors will be opaque (if so, kConstAlpha_Flag will not be set)
+        kHasSpan16_Flag     = 0x02  //!< set if this shader's shadeSpan16() method can be called
+    };
+
+    /** Called sometimes before drawing with this shader.
+        Return the type of alpha your shader will return.
+        The default implementation returns 0. Your subclass should override if it can
+        (even sometimes) report a non-zero value, since that will enable various blitters
+        to perform faster.
+    */
+    virtual uint32_t getFlags() { return 0; }
+
+    /** Return the alpha associated with the data returned by shadeSpan16(). If
+        kHasSpan16_Flag is not set, this value is meaningless.
+    */
+    virtual uint8_t getSpan16Alpha() const { return fPaintAlpha; }
+    
+    /** Called once before drawing, with the current paint and
+        device matrix. Return true if your shader supports these
+        parameters, or false if not. If false is returned, nothing
+        will be drawn.
+    */
+    virtual bool    setContext( const SkBitmap& device,
+                                const SkPaint& paint,
+                                const SkMatrix& matrix);
+
+    /** Called for each span of the object being drawn. Your subclass
+        should set the appropriate colors (with premultiplied alpha) that
+        correspond to the specified device coordinates.
+    */
+    virtual void    shadeSpan(int x, int y, SkPMColor[], int count) = 0;
+    /** Called only for 16bit devices when getFlags() returns kOpaqueAlphaFlag | kHasSpan16_Flag
+    */
+    virtual void    shadeSpan16(int x, int y, uint16_t[], int count);
+    /** Similar to shadeSpan, but only returns the alpha-channel for a span.
+        The default implementation calls shadeSpan() and then extracts the alpha
+        values from the returned colors.
+    */
+    virtual void    shadeSpanAlpha(int x, int y, uint8_t alpha[], int count);
+
+    /** Helper function that returns true if this shader's shadeSpan16() method can
+        be called.
+    */
+    bool canCallShadeSpan16()
+    {
+        return SkShader::CanCallShadeSpan16(this->getFlags());
+    }
+
+    /** Helper to check the flags to know if it is legal to call shadeSpan16()
+    */
+    static bool CanCallShadeSpan16(uint32_t flags)
+    {
+        return (flags & kHasSpan16_Flag) != 0;
+    }
+
+    //////////////////////////////////////////////////////////////////////////
+    //  Factory methods for stock shaders
+
+    /** Call this to create a new shader that will draw with the specified bitmap.
+        @param src  The bitmap to use inside the shader
+        @param transferOwnershipOfPixels    If true, the shader will call setOwnsPixels(true) on its private bitmap
+                                            and setOwnsPixels(false) on the src bitmap, resulting in the bitmap's pixels
+                                            being disposed when the shader is deleted.
+        @param ft   The filter type to be used when scaling or rotating the bitmap when it is drawn.
+        @param tmx  The tiling mode to use when sampling the bitmap in the x-direction.
+        @param tmy  The tiling mode to use when sampling the bitmap in the y-direction.
+        @return     Returns a new shader object. Note: this function never returns null.
+    */
+    static SkShader* CreateBitmapShader(const SkBitmap& src,
+                                        bool transferOwnershipOfPixels,
+                                        SkPaint::FilterType ft,
+                                        TileMode tmx, TileMode tmy);
 
 protected:
-       enum MatrixClass {
-               kLinear_MatrixClass,                    // no perspective
-               kFixedStepInX_MatrixClass,              // fast perspective, need to call fixedStepInX() each scanline
-               kPerspective_MatrixClass                // slow perspective, need to mappoints each pixel
-       };
-       static MatrixClass ComputeMatrixClass(const SkMatrix&);
-
-       // These can be called by your subclass after setContext() has been called
-       U8                               getPaintAlpha() const { return fPaintAlpha; }
-       SkBitmap::Config getDeviceConfig() const { return (SkBitmap::Config)fDeviceConfig; }
-       const SkMatrix&  getTotalInverse() const { return fTotalInverse; }
-       MatrixClass              getInverseClass() const { return (MatrixClass)fTotalInverseClass; }
-       SkMatrix::MapPtProc     getInverseMapPtProc() const { return fInverseMapPtProc; }
+    enum MatrixClass {
+        kLinear_MatrixClass,            // no perspective
+        kFixedStepInX_MatrixClass,      // fast perspective, need to call fixedStepInX() each scanline
+        kPerspective_MatrixClass        // slow perspective, need to mappoints each pixel
+    };
+    static MatrixClass ComputeMatrixClass(const SkMatrix&);
+
+    // These can be called by your subclass after setContext() has been called
+    uint8_t             getPaintAlpha() const { return fPaintAlpha; }
+    SkBitmap::Config    getDeviceConfig() const { return (SkBitmap::Config)fDeviceConfig; }
+    const SkMatrix&     getTotalInverse() const { return fTotalInverse; }
+    MatrixClass         getInverseClass() const { return (MatrixClass)fTotalInverseClass; }
+    SkMatrix::MapPtProc getInverseMapPtProc() const { return fInverseMapPtProc; }
 
 private:
-       SkMatrix*       fLocalMatrix;
-       SkMatrix        fTotalInverse;
-       SkMatrix::MapPtProc     fInverseMapPtProc;
-       U8                      fPaintAlpha;
-       U8                      fDeviceConfig;
-       U8                      fTotalInverseClass;
-
-       static SkShader* CreateBitmapShader(const SkBitmap& src,
-                                                                               bool transferOwnershipOfPixels,
-                                                                               SkPaint::FilterType,
-                                                                               TileMode, TileMode,
-                                                                               void* storage, size_t storageSize);
-       friend class SkAutoBitmapShaderInstall;
+    SkMatrix*           fLocalMatrix;
+    SkMatrix            fTotalInverse;
+    SkMatrix::MapPtProc fInverseMapPtProc;
+    uint8_t             fPaintAlpha;
+    uint8_t             fDeviceConfig;
+    uint8_t             fTotalInverseClass;
+
+    static SkShader* CreateBitmapShader(const SkBitmap& src,
+                                        bool transferOwnershipOfPixels,
+                                        SkPaint::FilterType,
+                                        TileMode, TileMode,
+                                        void* storage, size_t storageSize);
+    friend class SkAutoBitmapShaderInstall;
 };
 
 #endif
index e914304..05f6ef1 100644 (file)
@@ -1,21 +1,38 @@
+/* include/graphics/SkShaderExtras.h
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #ifndef SkShaderExtras_DEFINED
 #define SkShaderExtras_DEFINED
 
 #include "SkShader.h"
 
-class SkColorCombine :  public SkRefCnt {
+class SkColorComposer :  public SkRefCnt {
 public:
     /** Called with two scanlines of color. The implementation writes out its combination of
         those into the result[] scaline.
     */
-    virtual void combineSpan(const SkPMColor srcA[], const SkPMColor srcB[], int count, SkPMColor result[]) = 0;
+    virtual void composeSpan(const SkPMColor srcA[], const SkPMColor srcB[], int count, SkPMColor result[]) = 0;
 };
 
 ///////////////////////////////////////////////////////////////////////////////////////////
 
 class SkComposeShader : public SkShader {
 public:
-    SkComposeShader(SkShader* sA, SkShader* sB, SkColorCombine* combine);
+    SkComposeShader(SkShader* sA, SkShader* sB, SkColorComposer* composer);
     virtual ~SkComposeShader();
     
     // override
@@ -26,9 +43,9 @@ private:
     enum {
         COUNT = 32
     };
-    SkShader*       fShaderA;
-    SkShader*       fShaderB;
-    SkColorCombine* fCombine;
+    SkShader*           fShaderA;
+    SkShader*           fShaderB;
+    SkColorComposer*    fComposer;
 
     typedef SkShader INHERITED;
 };
index 778a32c..8bc1cf4 100644 (file)
@@ -1,3 +1,20 @@
+/* include/graphics/SkStackViewLayout.h
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #ifndef SkStackViewLayout_DEFINED
 #define SkStackViewLayout_DEFINED
 
 
 class SkStackViewLayout : public SkView::Layout {
 public:
-       SkStackViewLayout();
-
-       enum Orient {
-               kHorizontal_Orient,
-               kVertical_Orient,
-
-               kOrientCount
-       };
-       Orient  getOrient() const { return (Orient)fOrient; }
-       void    setOrient(Orient);
-
-       void            getMargin(SkRect*) const;
-       void            setMargin(const SkRect&);
-
-       SkScalar        getSpacer() const { return fSpacer; }
-       void            setSpacer(SkScalar);
-
-       /**     Controls the posititioning in the same direction as the orientation
-       */
-       enum Pack {
-               kStart_Pack,
-               kCenter_Pack,
-               kEnd_Pack,
-               
-               kPackCount
-       };
-       Pack    getPack() const { return (Pack)fPack; }
-       void    setPack(Pack);
-
-       /**     Controls the posititioning at right angles to the orientation
-       */
-       enum Align {
-               kStart_Align,
-               kCenter_Align,
-               kEnd_Align,
-               kStretch_Align,
-
-               kAlignCount
-       };
-       Align   getAlign() const { return (Align)fAlign; }
-       void    setAlign(Align);
-
-       bool    getRound() const { return SkToBool(fRound); }
-       void    setRound(bool);
+    SkStackViewLayout();
+
+    enum Orient {
+        kHorizontal_Orient,
+        kVertical_Orient,
+
+        kOrientCount
+    };
+    Orient  getOrient() const { return (Orient)fOrient; }
+    void    setOrient(Orient);
+
+    void        getMargin(SkRect*) const;
+    void        setMargin(const SkRect&);
+
+    SkScalar    getSpacer() const { return fSpacer; }
+    void        setSpacer(SkScalar);
+
+    /** Controls the posititioning in the same direction as the orientation
+    */
+    enum Pack {
+        kStart_Pack,
+        kCenter_Pack,
+        kEnd_Pack,
+        
+        kPackCount
+    };
+    Pack    getPack() const { return (Pack)fPack; }
+    void    setPack(Pack);
+
+    /** Controls the posititioning at right angles to the orientation
+    */
+    enum Align {
+        kStart_Align,
+        kCenter_Align,
+        kEnd_Align,
+        kStretch_Align,
+
+        kAlignCount
+    };
+    Align   getAlign() const { return (Align)fAlign; }
+    void    setAlign(Align);
+
+    bool    getRound() const { return SkToBool(fRound); }
+    void    setRound(bool);
 
 protected:
-       virtual void onLayoutChildren(SkView* parent);
-       virtual void onInflate(const SkDOM&, const SkDOM::Node*);
+    virtual void onLayoutChildren(SkView* parent);
+    virtual void onInflate(const SkDOM&, const SkDOM::Node*);
 
 private:
-       SkRect          fMargin;
-       SkScalar        fSpacer;
-       U8                      fOrient, fPack, fAlign, fRound;
+    SkRect      fMargin;
+    SkScalar    fSpacer;
+    U8          fOrient, fPack, fAlign, fRound;
 };
 
 class SkFillViewLayout : public SkView::Layout {
 public:
-                       SkFillViewLayout();
-       void    getMargin(SkRect*) const;
-       void    setMargin(const SkRect&);
+            SkFillViewLayout();
+    void    getMargin(SkRect*) const;
+    void    setMargin(const SkRect&);
 
 protected:
-       // overrides;
-       virtual void onLayoutChildren(SkView* parent);
-       virtual void onInflate(const SkDOM& dom, const SkDOM::Node* node);
+    // overrides;
+    virtual void onLayoutChildren(SkView* parent);
+    virtual void onInflate(const SkDOM& dom, const SkDOM::Node* node);
 
 private:
-       SkRect  fMargin;
-       typedef SkView::Layout INHERITED;
+    SkRect  fMargin;
+    typedef SkView::Layout INHERITED;
 };
 
 #endif
index d5525e1..7253de6 100644 (file)
@@ -1,3 +1,20 @@
+/* include/graphics/SkStdLib_Redirect.h
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #ifndef SkStdLib_Redirect_DEFINED
 #define SkStdLib_Redirect_DEFINED
 
@@ -5,7 +22,7 @@
 
 #include "SkTypes.h"
 
-#define fread(buffer, count, size, file)       sk_stdlib_fread(buffer, count, size, file)
+#define fread(buffer, count, size, file)    sk_stdlib_fread(buffer, count, size, file)
 #define qsort
 #define tolower
 #define setjmp
index 14c71d3..b846dd8 100644 (file)
@@ -1,3 +1,20 @@
+/* include/graphics/SkStream.h
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #ifndef SkStream_DEFINED
 #define SkStream_DEFINED
 
 
 class SkStream {
 public:
-       virtual ~SkStream() {}
-       /**     Called to rewind to the beginning of the stream. If this cannot be
-               done, return false.
-       */
-       virtual bool rewind() = 0;
-       /**     If this stream represents a file, this method returns the file's name.
-               If it does not, it returns nil (the default behavior).
-       */
-       virtual const char* getFileName();
-       /**     Called to read or skip size number of bytes. If buffer is nil, skip
-               the bytes, else copy them into buffer. If this cannot be done, return false.
-               If buffer is nil and size is zero, return the file length
-               @param buffer   If buffer is nil, ignore and just skip size bytes, otherwise copy size bytes into buffer
-               @param size     The number of bytes to skip or copy
-               @return bytes read on success
-       */
-       virtual size_t read(void* buffer, size_t size) = 0;
-       static SkStream* GetURIStream(const char prefix[], const char path[]);
-       static bool IsAbsoluteURI(const char path[]);
+    virtual ~SkStream() {}
+    /** Called to rewind to the beginning of the stream. If this cannot be
+        done, return false.
+    */
+    virtual bool rewind() = 0;
+    /** If this stream represents a file, this method returns the file's name.
+        If it does not, it returns nil (the default behavior).
+    */
+    virtual const char* getFileName();
+    /** Called to read or skip size number of bytes. If buffer is nil, skip
+        the bytes, else copy them into buffer. If this cannot be done, return false.
+        If buffer is nil and size is zero, return the file length
+        @param buffer   If buffer is nil, ignore and just skip size bytes, otherwise copy size bytes into buffer
+        @param size The number of bytes to skip or copy
+        @return bytes read on success
+    */
+    virtual size_t read(void* buffer, size_t size) = 0;
+    static SkStream* GetURIStream(const char prefix[], const char path[]);
+    static bool IsAbsoluteURI(const char path[]);
 };
 
 class SkWStream {
 public:
-       virtual ~SkWStream();
+    virtual ~SkWStream();
 
-       /**     Called to write bytes to a SkWStream. Returns true on success
-               @param buffer the address of at least size bytes to be written to the stream
-               @param size     The number of bytes in buffer to write to the stream
-               @return true on success
-       */
-       virtual bool write(const void* buffer, size_t size) = 0;
-       virtual void newline();
-       virtual void flush();
+    /** Called to write bytes to a SkWStream. Returns true on success
+        @param buffer the address of at least size bytes to be written to the stream
+        @param size The number of bytes in buffer to write to the stream
+        @return true on success
+    */
+    virtual bool write(const void* buffer, size_t size) = 0;
+    virtual void newline();
+    virtual void flush();
 
-       // helpers
+    // helpers
 
-       bool    writeText(const char text[]);
-       bool    writeDecAsText(S32);
-       bool    writeHexAsText(U32, int minDigits = 0);
-       bool    writeScalarAsText(SkScalar);
+    bool    writeText(const char text[]);
+    bool    writeDecAsText(S32);
+    bool    writeHexAsText(U32, int minDigits = 0);
+    bool    writeScalarAsText(SkScalar);
 
-       SkDEBUGCODE(static void UnitTest();)
+    SkDEBUGCODE(static void UnitTest();)
 };
 
 ////////////////////////////////////////////////////////////////////////////////////////
@@ -57,116 +74,116 @@ struct SkFILE;
 
 class SkFILEStream : public SkStream {
 public:
-       SkFILEStream(const char path[] = nil);
-       virtual ~SkFILEStream();
-
-       /**     Returns true if the current path could be opened.
-       */
-       bool isValid() const { return fFILE != nil; }
-       /**     Close the current file, and open a new file with the specified
-               path. If path is nil, just close the current file.
-       */
-       void setPath(const char path[]);
+    SkFILEStream(const char path[] = nil);
+    virtual ~SkFILEStream();
+
+    /** Returns true if the current path could be opened.
+    */
+    bool isValid() const { return fFILE != nil; }
+    /** Close the current file, and open a new file with the specified
+        path. If path is nil, just close the current file.
+    */
+    void setPath(const char path[]);
     
     SkFILE* getSkFILE() const { return fFILE; }
 
-       virtual bool rewind();
-       virtual size_t read(void* buffer, size_t size);
-       virtual const char* getFileName();
+    virtual bool rewind();
+    virtual size_t read(void* buffer, size_t size);
+    virtual const char* getFileName();
 
 private:
-       SkFILE*         fFILE;
-       SkString        fName;
+    SkFILE*     fFILE;
+    SkString    fName;
 };
 
 class SkMemoryStream : public SkStream {
 public:
-       SkMemoryStream(const void* src, size_t length);
+    SkMemoryStream(const void* src, size_t length);
 
-       virtual bool rewind();
-       virtual size_t read(void* buffer, size_t size);
+    virtual bool rewind();
+    virtual size_t read(void* buffer, size_t size);
 
 private:
-       const void* fSrc;
-       size_t fSize, fOffset;
+    const void* fSrc;
+    size_t fSize, fOffset;
 };
 
-/**    \class SkBufferStream
-       This is a wrapper class that adds buffering to another stream.
-       The caller can provide the buffer, or ask SkBufferStream to allocated/free
-       it automatically.
+/** \class SkBufferStream
+    This is a wrapper class that adds buffering to another stream.
+    The caller can provide the buffer, or ask SkBufferStream to allocated/free
+    it automatically.
 */
 class SkBufferStream : public SkStream {
 public:
-       /**     Provide the stream to be buffered (proxy), and the size of the buffer that
-               should be used. This will be allocated and freed automatically. If bufferSize is 0,
-               a default buffer size will be used.
-       */
-       SkBufferStream(SkStream& proxy, size_t bufferSize = 0);
-       /**     Provide the stream to be buffered (proxy), and a buffer and size to be used.
-               This buffer is owned by the caller, and must be at least bufferSize bytes big.
-               Passing nil for buffer will cause the buffer to be allocated/freed automatically.
-               If buffer is not nil, it is an error for bufferSize to be 0.
-       */
-       SkBufferStream(SkStream& proxy, void* buffer, size_t bufferSize);
-       virtual ~SkBufferStream();
-
-       virtual bool            rewind();
-       virtual const char*     getFileName();
-       virtual size_t          read(void* buffer, size_t size);
+    /** Provide the stream to be buffered (proxy), and the size of the buffer that
+        should be used. This will be allocated and freed automatically. If bufferSize is 0,
+        a default buffer size will be used.
+    */
+    SkBufferStream(SkStream& proxy, size_t bufferSize = 0);
+    /** Provide the stream to be buffered (proxy), and a buffer and size to be used.
+        This buffer is owned by the caller, and must be at least bufferSize bytes big.
+        Passing nil for buffer will cause the buffer to be allocated/freed automatically.
+        If buffer is not nil, it is an error for bufferSize to be 0.
+    */
+    SkBufferStream(SkStream& proxy, void* buffer, size_t bufferSize);
+    virtual ~SkBufferStream();
+
+    virtual bool        rewind();
+    virtual const char* getFileName();
+    virtual size_t      read(void* buffer, size_t size);
 private:
-       enum {
-               kDefaultBufferSize      = 128
-       };
-       // illegal
-       SkBufferStream(const SkBufferStream&);
-       SkBufferStream& operator=(const SkBufferStream&);
-
-       SkStream&       fProxy;
-       char*           fBuffer;
-       size_t          fOrigBufferSize, fBufferSize, fBufferOffset;
-       bool            fWeOwnTheBuffer;
-
-       void    init(void*, size_t);
+    enum {
+        kDefaultBufferSize  = 128
+    };
+    // illegal
+    SkBufferStream(const SkBufferStream&);
+    SkBufferStream& operator=(const SkBufferStream&);
+
+    SkStream&   fProxy;
+    char*       fBuffer;
+    size_t      fOrigBufferSize, fBufferSize, fBufferOffset;
+    bool        fWeOwnTheBuffer;
+
+    void    init(void*, size_t);
 };
 
 /////////////////////////////////////////////////////////////////////////////////////////////
 
 class SkFILEWStream : public SkWStream {
 public:
-                       SkFILEWStream(const char path[]);
-       virtual ~SkFILEWStream();
+            SkFILEWStream(const char path[]);
+    virtual ~SkFILEWStream();
 
-       /**     Returns true if the current path could be opened.
-       */
-       bool isValid() const { return fFILE != nil; }
+    /** Returns true if the current path could be opened.
+    */
+    bool isValid() const { return fFILE != nil; }
 
-       virtual bool write(const void* buffer, size_t size);
-       virtual void flush();
+    virtual bool write(const void* buffer, size_t size);
+    virtual void flush();
 private:
-       SkFILE* fFILE;
+    SkFILE* fFILE;
 };
 
 class SkMemoryWStream : public SkWStream {
 public:
-       SkMemoryWStream(void* buffer, size_t size);
-       virtual bool write(const void* buffer, size_t size);
+    SkMemoryWStream(void* buffer, size_t size);
+    virtual bool write(const void* buffer, size_t size);
     
 private:
     char*   fBuffer;
     size_t  fMaxLength;
-       size_t  fBytesWritten;
+    size_t  fBytesWritten;
 };
 
 class SkDynamicMemoryWStream : public SkWStream {
 public:
-       SkDynamicMemoryWStream();
-       virtual ~SkDynamicMemoryWStream();
-       virtual bool write(const void* buffer, size_t size);
+    SkDynamicMemoryWStream();
+    virtual ~SkDynamicMemoryWStream();
+    virtual bool write(const void* buffer, size_t size);
     // random access write
     // modifies stream and returns true if offset + size is less than or equal to getOffset()
     bool write(const void* buffer, size_t offset, size_t size); 
-       size_t getOffset() { return fBytesWritten; }
+    size_t getOffset() { return fBytesWritten; }
 
     // copy what has been written to the stream into dst
     void    copyTo(void* dst) const;
@@ -180,16 +197,16 @@ private:
     struct Block;
     Block*  fHead;
     Block*  fTail;
-       size_t  fBytesWritten;
+    size_t  fBytesWritten;
     mutable char*   fCopyToCache;
 };
 
 
 class SkDebugWStream : public SkWStream {
 public:
-       // overrides
-       virtual bool write(const void* buffer, size_t size);
-       virtual void newline();
+    // overrides
+    virtual bool write(const void* buffer, size_t size);
+    virtual void newline();
 };
 
 // for now
index 8fdef0a..45e4efa 100644 (file)
@@ -1,3 +1,20 @@
+/* include/graphics/SkStream_Win.h
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #ifndef SkStream_Win_DEFINED
 #define SkStream_Win_DEFINED
 
 /** \cond ZERO */
 class SkURLStream : public SkStream {
 public:
-       SkURLStream(const char url[] = nil);
-       virtual ~SkURLStream();
-
-       /**     Close the current URL, and open a new URL.
-               If URL is nil, just close the current URL.
-       */
-       void setURL(const char url[]);
-
-       // overrides
-       virtual bool rewind();
-       virtual size_t read(void* buffer, size_t size);
-       
+    SkURLStream(const char url[] = nil);
+    virtual ~SkURLStream();
+
+    /** Close the current URL, and open a new URL.
+        If URL is nil, just close the current URL.
+    */
+    void setURL(const char url[]);
+
+    // overrides
+    virtual bool rewind();
+    virtual size_t read(void* buffer, size_t size);
+    
 private:
-       SkString fURL;
-       HINTERNET fConnection;
-       HINTERNET fURLStream;
+    SkString fURL;
+    HINTERNET fConnection;
+    HINTERNET fURLStream;
 };
 
 /** \endcond */
index 84b8493..a1bcf9c 100644 (file)
@@ -1,9 +1,26 @@
+/* include/graphics/SkString.h
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #ifndef SkString_DEFINED
 #define SkString_DEFINED
 
 #include "SkScalar.h"
 
-/*     Some helper functions for C strings
+/*  Some helper functions for C strings
 */
 
 bool SkStrStartsWith(const char string[], const char prefix[]);
@@ -15,135 +32,136 @@ char*   SkStrAppendS32(char buffer[], int32_t);
 #define SkStrAppendScalar_MaxSize  11
 char*   SkStrAppendScalar(char buffer[], SkScalar);
 
-/**    \class SkString
+/** \class SkString
 
-       Light weight class for managing strings. Uses reference
-       counting to make string assignments and copies very fast
-       with no extra RAM cost. Assumes UTF8 encoding.
+    Light weight class for managing strings. Uses reference
+    counting to make string assignments and copies very fast
+    with no extra RAM cost. Assumes UTF8 encoding.
 */
 class SkString {
 public:
-                               SkString();
-       explicit        SkString(size_t len);
-       explicit        SkString(const char text[]);
-                               SkString(const char text[], size_t len);
-       explicit        SkString(const SkString&);
-                               ~SkString();
-
-       bool            isEmpty() const { return fRec->fLength == 0; }
-       size_t          size() const { return (size_t) fRec->fLength; }
-       const char*     c_str() const { return fRec->data(); }
-
-       bool    equals(const SkString&) const;
-       bool    equals(const char text[]) const;
-       bool    equals(const char text[], size_t len) const;
-
-       bool    startsWith(const char prefix[]) const
-       {
-               return SkStrStartsWith(fRec->data(), prefix);
-       }
-       bool    endsWith(const char suffix[]) const
-       {
-               return SkStrEndsWith(fRec->data(), suffix);
-       }
-
-       friend int operator==(const SkString& a, const SkString& b)
-       {
-               return a.equals(b);
-       }
-       friend int operator!=(const SkString& a, const SkString& b)
-       {
-               return !a.equals(b);
-       }
-
-       // these methods edit the string
-
-       SkString&       operator=(const SkString&);
-
-       char*   writable_str();
-
-       void    reset();
-       void    resize(size_t len) { this->set(nil, len); }
-       void    set(const SkString& src) { *this = src; }
-       void    set(const char text[]);
-       void    set(const char text[], size_t len);
-       void    setUTF16(const U16[]);
-
-       void    insert(size_t offset, const SkString& src) { this->insert(offset, src.c_str(), src.size()); }
-       void    insert(size_t offset, const char text[]);
-       void    insert(size_t offset, const char text[], size_t len);
-       void    insertUnichar(size_t offset, SkUnichar);
-       void    insertS32(size_t offset, S32 value);
-       void    insertHex(size_t offset, U32 value, int minDigits = 0);
-       void    insertScalar(size_t offset, SkScalar);
-
-       void    append(const SkString& str) { this->insert((size_t)-1, str); }
-       void    append(const char text[]) { this->insert((size_t)-1, text); }
-       void    append(const char text[], size_t len) { this->insert((size_t)-1, text, len); }
-       void    appendUnichar(SkUnichar uni) { this->insertUnichar((size_t)-1, uni); }
-       void    appendS32(S32 value) { this->insertS32((size_t)-1, value); }
-       void    appendHex(U32 value, int minDigits = 0) { this->insertHex((size_t)-1, value, minDigits); }
-       void    appendScalar(SkScalar value) { this->insertScalar((size_t)-1, value); }
-
-       void    prepend(const SkString& str) { this->insert(0, str); }
-       void    prepend(const char text[]) { this->insert(0, text); }
-       void    prepend(const char text[], size_t len) { this->insert(0, text, len); }
-       void    prependUnichar(SkUnichar uni) { this->insertUnichar(0, uni); }
-       void    prependS32(S32 value) { this->insertS32(0, value); }
-       void    prependHex(U32 value, int minDigits = 0) { this->insertHex(0, value, minDigits); }
-       void    prependScalar(SkScalar value) { this->insertScalar((size_t)-1, value); }
-
-       void    printf(const char format[], ...);
-
-       void    remove(size_t offset, size_t length);
-
-       /**     Swap contents between this and other. This function is guaranteed
-               to never fail or throw.
-       */
-       void    swap(SkString& other);
+                SkString();
+    explicit    SkString(size_t len);
+    explicit    SkString(const char text[]);
+                SkString(const char text[], size_t len);
+    explicit    SkString(const SkString&);
+                ~SkString();
+
+    bool        isEmpty() const { return fRec->fLength == 0; }
+    size_t      size() const { return (size_t) fRec->fLength; }
+    const char* c_str() const { return fRec->data(); }
+
+    bool    equals(const SkString&) const;
+    bool    equals(const char text[]) const;
+    bool    equals(const char text[], size_t len) const;
+
+    bool    startsWith(const char prefix[]) const
+    {
+        return SkStrStartsWith(fRec->data(), prefix);
+    }
+    bool    endsWith(const char suffix[]) const
+    {
+        return SkStrEndsWith(fRec->data(), suffix);
+    }
+
+    friend int operator==(const SkString& a, const SkString& b)
+    {
+        return a.equals(b);
+    }
+    friend int operator!=(const SkString& a, const SkString& b)
+    {
+        return !a.equals(b);
+    }
+
+    // these methods edit the string
+
+    SkString&   operator=(const SkString&);
+
+    char*   writable_str();
+
+    void    reset();
+    void    resize(size_t len) { this->set(nil, len); }
+    void    set(const SkString& src) { *this = src; }
+    void    set(const char text[]);
+    void    set(const char text[], size_t len);
+    void    setUTF16(const uint16_t[]);
+
+    void    insert(size_t offset, const SkString& src) { this->insert(offset, src.c_str(), src.size()); }
+    void    insert(size_t offset, const char text[]);
+    void    insert(size_t offset, const char text[], size_t len);
+    void    insertUnichar(size_t offset, SkUnichar);
+    void    insertS32(size_t offset, int32_t value);
+    void    insertHex(size_t offset, uint32_t value, int minDigits = 0);
+    void    insertScalar(size_t offset, SkScalar);
+
+    void    append(const SkString& str) { this->insert((size_t)-1, str); }
+    void    append(const char text[]) { this->insert((size_t)-1, text); }
+    void    append(const char text[], size_t len) { this->insert((size_t)-1, text, len); }
+    void    appendUnichar(SkUnichar uni) { this->insertUnichar((size_t)-1, uni); }
+    void    appendS32(int32_t value) { this->insertS32((size_t)-1, value); }
+    void    appendHex(uint32_t value, int minDigits = 0) { this->insertHex((size_t)-1, value, minDigits); }
+    void    appendScalar(SkScalar value) { this->insertScalar((size_t)-1, value); }
+
+    void    prepend(const SkString& str) { this->insert(0, str); }
+    void    prepend(const char text[]) { this->insert(0, text); }
+    void    prepend(const char text[], size_t len) { this->insert(0, text, len); }
+    void    prependUnichar(SkUnichar uni) { this->insertUnichar(0, uni); }
+    void    prependS32(int32_t value) { this->insertS32(0, value); }
+    void    prependHex(uint32_t value, int minDigits = 0) { this->insertHex(0, value, minDigits); }
+    void    prependScalar(SkScalar value) { this->insertScalar((size_t)-1, value); }
+
+    void    printf(const char format[], ...);
+
+    void    remove(size_t offset, size_t length);
+
+    /** Swap contents between this and other. This function is guaranteed
+        to never fail or throw.
+    */
+    void    swap(SkString& other);
 
   /** @cond UNIT_TEST */
-       SkDEBUGCODE(static void UnitTest();)
+    SkDEBUGCODE(static void UnitTest();)
   /** @endcond */
     
 private:
-#ifdef SK_DEBUG
-       const char* fStr;
-#endif
-       struct Rec {
-               U16     fLength;
-               U16     fRefCnt;
-               // data[]
-               char* data() { return (char*)(this) + sizeof(Rec); }
-               const char* data() const { return (const char*)(this) + sizeof(Rec); }
-       };
-       Rec* fRec;
+    struct Rec {
+    public:
+        uint16_t    fLength;
+        uint16_t    fRefCnt;
+        char        fBeginningOfData;
+
+        char* data() { return &fBeginningOfData; }
+        const char* data() const { return &fBeginningOfData; }
+    };
+    Rec* fRec;
 
 #ifdef SK_DEBUG
-       void validate() const;
+    const char* fStr;
+    void validate() const;
 #else
-       void validate() const {}
+    void validate() const {}
 #endif
 
-       static Rec*     AllocRec(const char text[], U16CPU len);
-       static Rec*     RefRec(Rec*);
+    static const Rec gEmptyRec;
+    static Rec* AllocRec(const char text[], U16CPU len);
+    static Rec* RefRec(Rec*);
 };
 
 class SkAutoUCS2 {
 public:
-       SkAutoUCS2(const char utf8[]);
-       ~SkAutoUCS2();
+    SkAutoUCS2(const char utf8[]);
+    ~SkAutoUCS2();
 
-       /**     This returns the number of ucs2 characters
-       */
-       int                     count() const { return fCount; }
-       /**     This returns a null terminated ucs2 string
-       */
-       const U16*      getUCS2() const { return fUCS2; }
+    /** This returns the number of ucs2 characters
+    */
+    int count() const { return fCount; }
+    /** This returns a null terminated ucs2 string
+    */
+    const uint16_t* getUCS2() const { return fUCS2; }
 
 private:
-       int             fCount;
-       U16*    fUCS2;
+    int         fCount;
+    uint16_t*   fUCS2;
 };
 
 #endif
index 8b148a4..42e1c6c 100644 (file)
@@ -1,3 +1,20 @@
+/* include/graphics/SkStroke.h
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #ifndef SkStroke_DEFINED
 #define SkStroke_DEFINED
 
 struct SkRect;
 class SkPath;
 
-#define SK_DefaultStrokeWidth          SK_Scalar1
-#define SK_DefaultMiterLimit           SkIntToScalar(4)
+#define SK_DefaultStrokeWidth       SK_Scalar1
+#define SK_DefaultMiterLimit        SkIntToScalar(4)
 
 
-/**    \class SkStroke
-       SkStroke is the utility class that constructs paths by stroking
-       geometries (lines, rects, ovals, roundrects, paths). This is
-       invoked when a geometry or text is drawn in a canvas with the
-       kStroke_Mask bit set in the paint.
+/** \class SkStroke
+    SkStroke is the utility class that constructs paths by stroking
+    geometries (lines, rects, ovals, roundrects, paths). This is
+    invoked when a geometry or text is drawn in a canvas with the
+    kStroke_Mask bit set in the paint.
 */
 class SkStroke {
 public:
-       SkStroke();
-       SkStroke(const SkPaint&);
-       SkStroke(const SkPaint&, SkScalar width);       // width overrides paint.getStrokeWidth()
+    SkStroke();
+    SkStroke(const SkPaint&);
+    SkStroke(const SkPaint&, SkScalar width);   // width overrides paint.getStrokeWidth()
 
-       SkPaint::Cap    getCap() const { return (SkPaint::Cap)fCap; }
-       void            setCap(SkPaint::Cap);
+    SkPaint::Cap    getCap() const { return (SkPaint::Cap)fCap; }
+    void        setCap(SkPaint::Cap);
 
-       SkPaint::Join   getJoin() const { return (SkPaint::Join)fJoin; }
-       void            setJoin(SkPaint::Join);
+    SkPaint::Join   getJoin() const { return (SkPaint::Join)fJoin; }
+    void        setJoin(SkPaint::Join);
 
-//     SkScalar        getMiterLimit() const { return fMiterLimit; }
-       void            setMiterLimit(SkScalar);
+//  SkScalar    getMiterLimit() const { return fMiterLimit; }
+    void        setMiterLimit(SkScalar);
 
-//     SkScalar        getWidth() const { return fWidth; }
-       void            setWidth(SkScalar);
+//  SkScalar    getWidth() const { return fWidth; }
+    void        setWidth(SkScalar);
 
-       bool            getDoFill() const { return SkToBool(fDoFill); }
-       void            setDoFill(bool doFill) { fDoFill = SkToU8(doFill); }
+    bool        getDoFill() const { return SkToBool(fDoFill); }
+    void        setDoFill(bool doFill) { fDoFill = SkToU8(doFill); }
 
-       void    strokeLine(const SkPoint& start, const SkPoint& end, SkPath*) const;
-       void    strokeRect(const SkRect& rect, SkPath*) const;
-       void    strokeOval(const SkRect& oval, SkPath*) const;
-       void    strokeRRect(const SkRect& rect, SkScalar rx, SkScalar ry, SkPath*) const;
-       void    strokePath(const SkPath& path, SkPath*) const;
+    void    strokeLine(const SkPoint& start, const SkPoint& end, SkPath*) const;
+    void    strokeRect(const SkRect& rect, SkPath*) const;
+    void    strokeOval(const SkRect& oval, SkPath*) const;
+    void    strokeRRect(const SkRect& rect, SkScalar rx, SkScalar ry, SkPath*) const;
+    void    strokePath(const SkPath& path, SkPath*) const;
 
-       ////////////////////////////////////////////////////////////////
+    ////////////////////////////////////////////////////////////////
 
 private:
-       SkScalar        fWidth, fMiterLimit;
-       U8                      fCap, fJoin;
-       SkBool8         fDoFill;
+    SkScalar    fWidth, fMiterLimit;
+    U8          fCap, fJoin;
+    SkBool8     fDoFill;
 
-       friend class SkPaint;
+    friend class SkPaint;
 };
 
 #endif
index 3cf826c..726d880 100644 (file)
@@ -1,16 +1,33 @@
+/* include/graphics/SkSystemEventTypes.h
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #ifndef SkSystemEventTypes_DEFINED
 #define SkSystemEventTypes_DEFINED
 
 /*
-       The goal of these strings is two-fold:
-       1) make funny strings (containing at least one char < 32) to avoid colliding with "user" strings
-       2) keep them <= 4 bytes, so we can avoid an allocation in SkEvent::setType()
+    The goal of these strings is two-fold:
+    1) make funny strings (containing at least one char < 32) to avoid colliding with "user" strings
+    2) keep them <= 4 bytes, so we can avoid an allocation in SkEvent::setType()
 */
-#define SK_EventType_Delay             "\xd" "lay"
-#define SK_EventType_Inval             "nv" "\xa" "l"
-#define SK_EventType_Key               "key" "\x1" 
+#define SK_EventType_Delay      "\xd" "lay"
+#define SK_EventType_Inval      "nv" "\xa" "l"
+#define SK_EventType_Key        "key" "\x1" 
 #define SK_EventType_OnEnd "on" "\xe" "n"
-#define SK_EventType_Unichar   "\xc" "har"
+#define SK_EventType_Unichar    "\xc" "har"
 #define SK_EventType_KeyUp      "key" "\xf"
 
 #endif
index d33205b..18501fd 100644 (file)
@@ -1,3 +1,20 @@
+/* include/graphics/SkTDArray.h
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #ifndef SkTDArray_DEFINED
 #define SkTDArray_DEFINED
 
 
 template <typename T> class SkTDArray {
 public:
-       SkTDArray()
-       {
-               fReserve = fCount = 0;
-               fArray = NULL;
+    SkTDArray()
+    {
+        fReserve = fCount = 0;
+        fArray = NULL;
 #ifdef SK_DEBUG
-               fData = NULL;
+        fData = NULL;
 #endif
-       }
-       SkTDArray(const T src[], U16CPU count)
-       {
-               SkASSERT(src || count == 0);
+    }
+    SkTDArray(const T src[], U16CPU count)
+    {
+        SkASSERT(src || count == 0);
 
-               fReserve = fCount = 0;
-               fArray = NULL;
+        fReserve = fCount = 0;
+        fArray = NULL;
 #ifdef SK_DEBUG
-               fData = NULL;
+        fData = NULL;
 #endif
-               if (count)
-               {
-                       fArray = (T*)sk_malloc_throw(count * sizeof(T));
+        if (count)
+        {
+            fArray = (T*)sk_malloc_throw(count * sizeof(T));
 #ifdef SK_DEBUG
-               //      fData = (T (*)[kDebugArraySize]) fArray;
-                       (T*&)fData = fArray;
+        //  fData = (T (*)[kDebugArraySize]) fArray;
+            (T*&)fData = fArray;
 #endif
-                       memcpy(fArray, src, sizeof(T) * count);
-                       fReserve = fCount = SkToU16(count);
-               }
-       }
-       SkTDArray(const SkTDArray<T>& src)
-       {
-               fReserve = fCount = 0;
-               fArray = NULL;
+            memcpy(fArray, src, sizeof(T) * count);
+            fReserve = fCount = SkToU16(count);
+        }
+    }
+    SkTDArray(const SkTDArray<T>& src)
+    {
+        fReserve = fCount = 0;
+        fArray = NULL;
 #ifdef SK_DEBUG
-               fData = NULL;
+        fData = NULL;
 #endif
-               SkTDArray<T> tmp(src.fArray, src.fCount);
-               this->swap(tmp);
-       }
-       ~SkTDArray()
-       {
-               sk_free(fArray);
-       }
+        SkTDArray<T> tmp(src.fArray, src.fCount);
+        this->swap(tmp);
+    }
+    ~SkTDArray()
+    {
+        sk_free(fArray);
+    }
 
-       SkTDArray<T>& operator=(const SkTDArray<T>& src)
-       {
-               if (this != &src)
-               {
-                       if (src.fCount > fReserve)
-                       {
-                               SkTDArray<T> tmp(src.fArray, src.fCount);
-                               this->swap(tmp);
-                       }
-                       else
-                       {
-                               memcpy(fArray, src.fArray, sizeof(T) * src.fCount);
-                               fCount = src.fCount;
-                       }
-               }
-               return *this;
-       }
+    SkTDArray<T>& operator=(const SkTDArray<T>& src)
+    {
+        if (this != &src)
+        {
+            if (src.fCount > fReserve)
+            {
+                SkTDArray<T> tmp(src.fArray, src.fCount);
+                this->swap(tmp);
+            }
+            else
+            {
+                memcpy(fArray, src.fArray, sizeof(T) * src.fCount);
+                fCount = src.fCount;
+            }
+        }
+        return *this;
+    }
 
-       friend int operator==(const SkTDArray<T>& a, const SkTDArray<T>& b)
-       {
-               return  a.fCount == b.fCount &&
-                               (a.fCount == 0 || !memcmp(a.fArray, b.fArray, a.fCount * sizeof(T)));
-       }
+    friend int operator==(const SkTDArray<T>& a, const SkTDArray<T>& b)
+    {
+        return  a.fCount == b.fCount &&
+                (a.fCount == 0 || !memcmp(a.fArray, b.fArray, a.fCount * sizeof(T)));
+    }
 
-       void swap(SkTDArray<T>& other)
-       {
-               SkTSwap(fArray, other.fArray);
+    void swap(SkTDArray<T>& other)
+    {
+        SkTSwap(fArray, other.fArray);
 #ifdef SK_DEBUG
-               SkTSwap(fData, other.fData);
+        SkTSwap(fData, other.fData);
 #endif
-               SkTSwap(fReserve, other.fReserve);
-               SkTSwap(fCount, other.fCount);
-       }
+        SkTSwap(fReserve, other.fReserve);
+        SkTSwap(fCount, other.fCount);
+    }
 
-       bool isEmpty() const { return fCount == 0; }
-       int     count() const { return fCount; }
-       T*      begin() const { return fArray; }
-       T*      end() const { return fArray ? fArray + fCount : NULL; }
-       T&      operator[](int index) const { SkASSERT((unsigned)index < fCount); return fArray[index]; }
+    bool isEmpty() const { return fCount == 0; }
+    int count() const { return fCount; }
+    T*  begin() const { return fArray; }
+    T*  end() const { return fArray ? fArray + fCount : NULL; }
+    T&  operator[](int index) const { SkASSERT((unsigned)index < fCount); return fArray[index]; }
 
-       void reset()
-       {
-               if (fArray)
-               {
-                       sk_free(fArray);
-                       fArray = NULL;
+    void reset()
+    {
+        if (fArray)
+        {
+            sk_free(fArray);
+            fArray = NULL;
 #ifdef SK_DEBUG
-                       fData = NULL;
+            fData = NULL;
 #endif
-                       fReserve = fCount = 0;
-               }
-               else
-               {
-                       SkASSERT(fReserve == 0 && fCount == 0);
-               }
-       }
+            fReserve = fCount = 0;
+        }
+        else
+        {
+            SkASSERT(fReserve == 0 && fCount == 0);
+        }
+    }
 
-       void setCount(U16CPU count)
-       {
-               if (count > fReserve)
-                       this->growBy(count - fCount);
-               else
-                       fCount = SkToU16(count);
-       }
+    void setCount(U16CPU count)
+    {
+        if (count > fReserve)
+            this->growBy(count - fCount);
+        else
+            fCount = SkToU16(count);
+    }
 
-       void setReserve(U16CPU reserve)
-       {
-               if (reserve > fReserve)
-               {
-                       SkASSERT(reserve > fCount);
-                       U16     count = fCount;
-                       this->growBy(reserve - fCount);
-                       fCount = count;
-               }
-       }
+    void setReserve(U16CPU reserve)
+    {
+        if (reserve > fReserve)
+        {
+            SkASSERT(reserve > fCount);
+            U16 count = fCount;
+            this->growBy(reserve - fCount);
+            fCount = count;
+        }
+    }
 
-       T* prepend()
-       {
-               this->growBy(1);
-               memmove(fArray + 1, fArray, (fCount - 1) * sizeof(T));
-               return fArray;
-       }
+    T* prepend()
+    {
+        this->growBy(1);
+        memmove(fArray + 1, fArray, (fCount - 1) * sizeof(T));
+        return fArray;
+    }
 
-       T* append() { return this->append(1, NULL); }
-       T* append(U16CPU count, const T* src = NULL)
-       {
-               unsigned oldCount = fCount;
-               if (count)
-               {
-                       SkASSERT(src == NULL || fArray == NULL ||
-                                       src + count <= fArray || fArray + oldCount <= src);
+    T* append() { return this->append(1, NULL); }
+    T* append(U16CPU count, const T* src = NULL)
+    {
+        unsigned oldCount = fCount;
+        if (count)
+        {
+            SkASSERT(src == NULL || fArray == NULL ||
+                    src + count <= fArray || fArray + oldCount <= src);
 
-                       this->growBy(count);
-                       if (src)
-                               memcpy(fArray + oldCount, src, sizeof(T) * count);
-               }
-               return fArray + oldCount;
-       }
-       
-       T* appendClear()
-       {
-               T* result = this->append(); 
-               *result = 0;
-               return result;
-       }
+            this->growBy(count);
+            if (src)
+                memcpy(fArray + oldCount, src, sizeof(T) * count);
+        }
+        return fArray + oldCount;
+    }
+    
+    T* appendClear()
+    {
+        T* result = this->append(); 
+        *result = 0;
+        return result;
+    }
 
-       T* insert(U16CPU index) { return this->insert(index, 1, NULL); }
-       T* insert(U16CPU index, U16CPU count, const T* src = NULL)
-       {
-               SkASSERT(count);
-               int oldCount = fCount;
-               this->growBy(count);
-               T* dst = fArray + index;
-               memmove(dst + count, dst, sizeof(T) * (oldCount - index));
-               if (src)
-                       memcpy(dst, src, sizeof(T) * count);
-               return dst;
-       }
+    T* insert(U16CPU index) { return this->insert(index, 1, NULL); }
+    T* insert(U16CPU index, U16CPU count, const T* src = NULL)
+    {
+        SkASSERT(count);
+        int oldCount = fCount;
+        this->growBy(count);
+        T* dst = fArray + index;
+        memmove(dst + count, dst, sizeof(T) * (oldCount - index));
+        if (src)
+            memcpy(dst, src, sizeof(T) * count);
+        return dst;
+    }
 
-       void remove(U16CPU index, U16CPU count = 1)
-       {
-               SkASSERT(index + count <= fCount);
-               fCount = SkToU16(fCount - count);
-               memmove(fArray + index, fArray + index + count, sizeof(T) * (fCount - index));
-       }
+    void remove(U16CPU index, U16CPU count = 1)
+    {
+        SkASSERT(index + count <= fCount);
+        fCount = SkToU16(fCount - count);
+        memmove(fArray + index, fArray + index + count, sizeof(T) * (fCount - index));
+    }
 
-       void removeShuffle(U16CPU index)
-       {
-               SkASSERT(index < fCount);
-               unsigned newCount = fCount - 1;
-               fCount = SkToU16(newCount);
-               if (index != newCount)
-                       memcpy(fArray + index, fArray + newCount, sizeof(T));
-       }
+    void removeShuffle(U16CPU index)
+    {
+        SkASSERT(index < fCount);
+        unsigned newCount = fCount - 1;
+        fCount = SkToU16(newCount);
+        if (index != newCount)
+            memcpy(fArray + index, fArray + newCount, sizeof(T));
+    }
 
-       int find(const T& elem) const
-       {
-               const T* iter = fArray;
-               const T* stop = fArray + fCount;
+    int find(const T& elem) const
+    {
+        const T* iter = fArray;
+        const T* stop = fArray + fCount;
 
-               for (; iter < stop; iter++)
-               {
-                       if (*iter == elem)
-                               return (int) (iter - fArray);
-               }
-               return -1;
-       }
+        for (; iter < stop; iter++)
+        {
+            if (*iter == elem)
+                return (int) (iter - fArray);
+        }
+        return -1;
+    }
 
-       int rfind(const T& elem) const
-       {
-               const T* iter = fArray + fCount;
-               const T* stop = fArray;
+    int rfind(const T& elem) const
+    {
+        const T* iter = fArray + fCount;
+        const T* stop = fArray;
 
-               while (iter > stop)
-               {
-                       if (*--iter == elem)
-                               return iter - stop;
-               }
-               return -1;
-       }
+        while (iter > stop)
+        {
+            if (*--iter == elem)
+                return iter - stop;
+        }
+        return -1;
+    }
 
-       // routines to treat the array like a stack
-       T*                      push() { return this->append(); }
-       void            push(T& elem) { *this->append() = elem; }
-       const T&        top() const { return (*this)[fCount - 1]; }
-       T&                      top() { return (*this)[fCount - 1]; }
-       void            pop(T* elem) { if (elem) *elem = (*this)[fCount - 1]; --fCount; }
-       void            pop() { --fCount; }
+    // routines to treat the array like a stack
+    T*          push() { return this->append(); }
+    void        push(T& elem) { *this->append() = elem; }
+    const T&    top() const { return (*this)[fCount - 1]; }
+    T&          top() { return (*this)[fCount - 1]; }
+    void        pop(T* elem) { if (elem) *elem = (*this)[fCount - 1]; --fCount; }
+    void        pop() { --fCount; }
 
-       void deleteAll()
-       {
-               T*      iter = fArray;
-               T*      stop = fArray + fCount;
-               while (iter < stop)
-               {
-                       delete (*iter);
-                       iter += 1;
-               }
-               this->reset();
-       }
+    void deleteAll()
+    {
+        T*  iter = fArray;
+        T*  stop = fArray + fCount;
+        while (iter < stop)
+        {
+            delete (*iter);
+            iter += 1;
+        }
+        this->reset();
+    }
 
-       void freeAll()
-       {
-               T*      iter = fArray;
-               T*      stop = fArray + fCount;
-               while (iter < stop)
-               {
-                       sk_free(*iter);
-                       iter += 1;
-               }
-               this->reset();
-       }
+    void freeAll()
+    {
+        T*  iter = fArray;
+        T*  stop = fArray + fCount;
+        while (iter < stop)
+        {
+            sk_free(*iter);
+            iter += 1;
+        }
+        this->reset();
+    }
 
-       void unrefAll()
-       {
-               T*      iter = fArray;
-               T*      stop = fArray + fCount;
-               while (iter < stop)
-               {
-                       (*iter)->unref();
-                       iter += 1;
-               }
-               this->reset();
-       }
+    void unrefAll()
+    {
+        T*  iter = fArray;
+        T*  stop = fArray + fCount;
+        while (iter < stop)
+        {
+            (*iter)->unref();
+            iter += 1;
+        }
+        this->reset();
+    }
 
 private:
 #ifdef SK_DEBUG
     enum {
         kDebugArraySize = 16
     };
-       T(* fData)[kDebugArraySize];
+    T(* fData)[kDebugArraySize];
 #endif
-       T*      fArray;
-       U16     fReserve, fCount;
+    T*  fArray;
+    U16 fReserve, fCount;
 
-       void growBy(U16CPU extra)
-       {
-               SkASSERT(extra);
-               SkASSERT(fCount + extra <= 0xFFFF);
+    void growBy(U16CPU extra)
+    {
+        SkASSERT(extra);
+        SkASSERT(fCount + extra <= 0xFFFF);
 
-               if (fCount + extra > fReserve)
-               {
-                       size_t size = fCount + extra + 4;
-                       size += size >> 2;
+        if (fCount + extra > fReserve)
+        {
+            size_t size = fCount + extra + 4;
+            size += size >> 2;
 
-                       fArray = (T*)sk_realloc_throw(fArray, size * sizeof(T));
+            fArray = (T*)sk_realloc_throw(fArray, size * sizeof(T));
 #ifdef SK_DEBUG
-               //      fData = (T (*)[kDebugArraySize]) fArray;
-                       (T*&)fData = fArray;
+        //  fData = (T (*)[kDebugArraySize]) fArray;
+            (T*&)fData = fArray;
 #endif
-                       fReserve = SkToU16((U16CPU)size);
-               }
-               fCount = SkToU16(fCount + extra);
-       }
+            fReserve = SkToU16((U16CPU)size);
+        }
+        fCount = SkToU16(fCount + extra);
+    }
 };
 
 #endif
index ccd7b8e..6da7ce5 100644 (file)
@@ -1,3 +1,20 @@
+/* include/graphics/SkTDStack.h
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #ifndef SkTDStack_DEFINED
 #define SkTDStack_DEFINED
 
 
 template <typename T> class SkTDStack {
 public:
-       SkTDStack() : fCount(0), fTotalCount(0)
-       {
-               fInitialRec.fNext = nil;
-               fRec = &fInitialRec;
+    SkTDStack() : fCount(0), fTotalCount(0)
+    {
+        fInitialRec.fNext = nil;
+        fRec = &fInitialRec;
 
-       //      fCount = kSlotCount;
-       }
-       ~SkTDStack()
-       {
-               Rec* rec = fRec;
-               while (rec != &fInitialRec)
-               {
-                       Rec* next = rec->fNext;
-                       sk_free(rec);
-                       rec = next;
-               }
-       }
+    //  fCount = kSlotCount;
+    }
+    ~SkTDStack()
+    {
+        Rec* rec = fRec;
+        while (rec != &fInitialRec)
+        {
+            Rec* next = rec->fNext;
+            sk_free(rec);
+            rec = next;
+        }
+    }
 
-       int count() const { return fTotalCount; }
+    int count() const { return fTotalCount; }
 
-       T* push()
-       {
-               SkASSERT(fCount <= kSlotCount);
-               if (fCount == kSlotCount)
-               {
-                       Rec* rec = (Rec*)sk_malloc_throw(sizeof(Rec));
-                       rec->fNext = fRec;
-                       fRec = rec;
-                       fCount = 0;
-               }
-               ++fTotalCount;
-               return &fRec->fSlots[fCount++];
-       }
-       void push(const T& elem) { *this->push() = elem; }
-       const T& index(int idx) const
-       {
-               SkASSERT(fRec && fCount > idx);
-               return fRec->fSlots[fCount - idx - 1];
-       }       
-       T& index(int idx)
-       {
-               SkASSERT(fRec && fCount > idx);
-               return fRec->fSlots[fCount - idx - 1];
-       }       
-       const T& top() const
-       {
-               SkASSERT(fRec && fCount > 0);
-               return fRec->fSlots[fCount - 1];
-       }
-       T& top()
-       {
-               SkASSERT(fRec && fCount > 0);
-               return fRec->fSlots[fCount - 1];
-       }
-       void pop(T* elem)
-       {
-               if (elem)
-                       *elem = fRec->fSlots[fCount - 1];
-               this->pop();
-       }
-       void pop()
-       {
-               SkASSERT(fCount > 0 && fRec);
-               --fTotalCount;
-               if (--fCount == 0)
-               {
-                       if (fRec != &fInitialRec)
-                       {
-                               Rec* rec = fRec->fNext;
-                               sk_free(fRec);
-                               fCount = kSlotCount;
-                               fRec = rec;
-                       }
-                       else
-                               SkASSERT(fTotalCount == 0);
-               }
-       }
+    T* push()
+    {
+        SkASSERT(fCount <= kSlotCount);
+        if (fCount == kSlotCount)
+        {
+            Rec* rec = (Rec*)sk_malloc_throw(sizeof(Rec));
+            rec->fNext = fRec;
+            fRec = rec;
+            fCount = 0;
+        }
+        ++fTotalCount;
+        return &fRec->fSlots[fCount++];
+    }
+    void push(const T& elem) { *this->push() = elem; }
+    const T& index(int idx) const
+    {
+        SkASSERT(fRec && fCount > idx);
+        return fRec->fSlots[fCount - idx - 1];
+    }   
+    T& index(int idx)
+    {
+        SkASSERT(fRec && fCount > idx);
+        return fRec->fSlots[fCount - idx - 1];
+    }   
+    const T& top() const
+    {
+        SkASSERT(fRec && fCount > 0);
+        return fRec->fSlots[fCount - 1];
+    }
+    T& top()
+    {
+        SkASSERT(fRec && fCount > 0);
+        return fRec->fSlots[fCount - 1];
+    }
+    void pop(T* elem)
+    {
+        if (elem)
+            *elem = fRec->fSlots[fCount - 1];
+        this->pop();
+    }
+    void pop()
+    {
+        SkASSERT(fCount > 0 && fRec);
+        --fTotalCount;
+        if (--fCount == 0)
+        {
+            if (fRec != &fInitialRec)
+            {
+                Rec* rec = fRec->fNext;
+                sk_free(fRec);
+                fCount = kSlotCount;
+                fRec = rec;
+            }
+            else
+                SkASSERT(fTotalCount == 0);
+        }
+    }
 
 private:
-       enum {
-               kSlotCount      = 8
-       };
+    enum {
+        kSlotCount  = 8
+    };
 
-       struct Rec;
-       friend struct Rec;
+    struct Rec;
+    friend struct Rec;
 
-       struct Rec {
-               Rec* fNext;
-               T        fSlots[kSlotCount];
-       };
-       Rec             fInitialRec;
-       Rec*    fRec;
-       int             fCount, fTotalCount;
+    struct Rec {
+        Rec* fNext;
+        T    fSlots[kSlotCount];
+    };
+    Rec     fInitialRec;
+    Rec*    fRec;
+    int     fCount, fTotalCount;
 };
 
 #endif
index c717ad1..5b0fb77 100644 (file)
@@ -1,3 +1,20 @@
+/* include/graphics/SkTDict.h
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #ifndef SkTDict_DEFINED
 #define SkTDict_DEFINED
 
 
 template <typename T> class SkTDict {
 public:
-       SkTDict(size_t minStringAlloc) : fStrings(minStringAlloc) {}
-
-       void reset()
-       {
-               fArray.reset();
-               fStrings.reset();
-       }
-
-       int count() const { return fArray.count(); }
-
-       bool set(const char name[], const T& value)
-       {
-               return set(name, strlen(name), value);
-       }
-
-       bool set(const char name[], size_t len, const T& value)
-       {
-               SkASSERT(name);
-
-               int index = this->find_index(name, len);
-
-               if (index >= 0)
-               {
-                       fArray[index].fValue = value;
-                       return false;
-               }
-               else
-               {
-                       Pair*   pair = fArray.insert(~index);
-                       char*   copy = (char*)fStrings.alloc(len + 1, SkChunkAlloc::kThrow_AllocFailType);
-                       memcpy(copy, name, len);
+    SkTDict(size_t minStringAlloc) : fStrings(minStringAlloc) {}
+
+    void reset()
+    {
+        fArray.reset();
+        fStrings.reset();
+    }
+
+    int count() const { return fArray.count(); }
+
+    bool set(const char name[], const T& value)
+    {
+        return set(name, strlen(name), value);
+    }
+
+    bool set(const char name[], size_t len, const T& value)
+    {
+        SkASSERT(name);
+
+        int index = this->find_index(name, len);
+
+        if (index >= 0)
+        {
+            fArray[index].fValue = value;
+            return false;
+        }
+        else
+        {
+            Pair*   pair = fArray.insert(~index);
+            char*   copy = (char*)fStrings.alloc(len + 1, SkChunkAlloc::kThrow_AllocFailType);
+            memcpy(copy, name, len);
             copy[len] = '\0';
-                       pair->fName = copy;
-                       pair->fValue = value;
-                       return true;
-               }
-       }
-
-       bool find(const char name[]) const
-       {
-               return this->find_index(name) >= 0;
-       }
-
-       bool find(const char name[], size_t len) const
-       {
-               return this->find_index(name, len) >= 0;
-       }
-
-       bool find(const char name[], T* value) const
-       {
-               return find(name, strlen(name), value);
-       }
-
-       bool find(const char name[], size_t len, T* value) const
-       {
-               int index = this->find_index(name, len);
-
-               if (index >= 0)
-               {
-                       if (value)
-                               *value = fArray[index].fValue;
-                       return true;
-               }
-               return false;
-       }
-
-       bool findKey(T& value, const char** name) const
-       {
-               Pair* end = fArray.end();
-               for (Pair* pair = fArray.begin(); pair < end; pair++) {
-                       if (pair->fValue != value)
-                               continue;
-                       *name = pair->fName;
-                       return true;
-               }
-               return false;
-       }
+            pair->fName = copy;
+            pair->fValue = value;
+            return true;
+        }
+    }
+
+    bool find(const char name[]) const
+    {
+        return this->find_index(name) >= 0;
+    }
+
+    bool find(const char name[], size_t len) const
+    {
+        return this->find_index(name, len) >= 0;
+    }
+
+    bool find(const char name[], T* value) const
+    {
+        return find(name, strlen(name), value);
+    }
+
+    bool find(const char name[], size_t len, T* value) const
+    {
+        int index = this->find_index(name, len);
+
+        if (index >= 0)
+        {
+            if (value)
+                *value = fArray[index].fValue;
+            return true;
+        }
+        return false;
+    }
+
+    bool findKey(T& value, const char** name) const
+    {
+        Pair* end = fArray.end();
+        for (Pair* pair = fArray.begin(); pair < end; pair++) {
+            if (pair->fValue != value)
+                continue;
+            *name = pair->fName;
+            return true;
+        }
+        return false;
+    }
 
 public:
-       struct Pair {
-               const char*     fName;
-               T                       fValue;
-
-               friend int operator<(const Pair& a, const Pair& b)
-               {
-                       return strcmp(a.fName, b.fName);
-               }
-               friend int operator!=(const Pair& a, const Pair& b)
-               {
-                       return strcmp(a.fName, b.fName);
-               }
-       };
-       friend class Iter;
+    struct Pair {
+        const char* fName;
+        T           fValue;
+
+        friend int operator<(const Pair& a, const Pair& b)
+        {
+            return strcmp(a.fName, b.fName);
+        }
+        friend int operator!=(const Pair& a, const Pair& b)
+        {
+            return strcmp(a.fName, b.fName);
+        }
+    };
+    friend class Iter;
 
 public:
-       class Iter {
-       public:
-               Iter(const SkTDict<T>& dict)
-               {
-                       fIter = dict.fArray.begin();
-                       fStop = dict.fArray.end();
-               }
-               const char* next(T* value)
-               {
-                       const char* name = nil;
-                       if (fIter < fStop)
-                       {
-                               name = fIter->fName;
-                               if (value)
-                                       *value = fIter->fValue;
-                               fIter += 1;
-                       }
-                       return name;
-               }
-       private:
-               Pair*   fIter;
-               Pair*   fStop;
-       };
+    class Iter {
+    public:
+        Iter(const SkTDict<T>& dict)
+        {
+            fIter = dict.fArray.begin();
+            fStop = dict.fArray.end();
+        }
+        const char* next(T* value)
+        {
+            const char* name = nil;
+            if (fIter < fStop)
+            {
+                name = fIter->fName;
+                if (value)
+                    *value = fIter->fValue;
+                fIter += 1;
+            }
+            return name;
+        }
+    private:
+        Pair*   fIter;
+        Pair*   fStop;
+    };
 
 private:
-       SkTDArray<Pair> fArray;
-       SkChunkAlloc    fStrings;
-
-       int find_index(const char name[]) const
-       {
-               return find_index(name, strlen(name));
-       }
-
-       int find_index(const char name[], size_t len) const
-       {
-               SkASSERT(name);
-
-               int     count = fArray.count();
-               int index = ~0;
-
-               if (count)
-                       index = SkStrSearch(&fArray.begin()->fName, count, name, len, sizeof(Pair));
-               return index;
-       }
-       friend class Iter;
+    SkTDArray<Pair> fArray;
+    SkChunkAlloc    fStrings;
+
+    int find_index(const char name[]) const
+    {
+        return find_index(name, strlen(name));
+    }
+
+    int find_index(const char name[], size_t len) const
+    {
+        SkASSERT(name);
+
+        int count = fArray.count();
+        int index = ~0;
+
+        if (count)
+            index = SkStrSearch(&fArray.begin()->fName, count, name, len, sizeof(Pair));
+        return index;
+    }
+    friend class Iter;
 };
 
 #endif
diff --git a/include/graphics/SkTSearch.h b/include/graphics/SkTSearch.h
deleted file mode 100644 (file)
index e76d767..0000000
+++ /dev/null
@@ -1,56 +0,0 @@
-#ifndef SkTSearch_DEFINED
-#define SkTSearch_DEFINED
-
-#include "SkTypes.h"
-
-template <typename T>
-int SkTSearch(const T* base, int count, T target, size_t elemSize)
-{
-       SkASSERT(base != nil);
-       SkASSERT(count >= 0);
-
-       if (count <= 0)
-               return ~0;
-
-       int     lo = 0;
-       int     hi = count - 1;
-
-       while (lo < hi)
-       {
-               int mid = (hi + lo) >> 1;
-               const T* elem = (const T*)((const char*)base + mid * elemSize);
-
-               if (*elem < target)
-                       lo = mid + 1;
-               else
-                       hi = mid;
-       }
-
-       const T* elem = (const T*)((const char*)base + hi * elemSize);
-       if (*elem != target)
-       {
-               if (*elem < target)
-                       hi += 1;
-               hi = ~hi;
-       }
-       return hi;
-}
-
-int SkStrSearch(const char*const* base, int count, const char target[], size_t target_len, size_t elemSize);
-int SkStrSearch(const char*const* base, int count, const char target[], size_t elemSize);
-
-/**    Like SkStrSearch, but treats target as if it were all lower-case. Assumes that
-       base points to a table of lower-case strings.
-*/
-int SkStrLCSearch(const char*const* base, int count, const char target[], size_t target_len, size_t elemSize);
-int SkStrLCSearch(const char*const* base, int count, const char target[], size_t elemSize);
-
-extern "C" {
-       typedef int (*SkQSortCompareProc)(const void*, const void*);
-       void SkQSort(void* base, size_t count, size_t elemSize, SkQSortCompareProc);
-}
-
-SkDEBUGCODE(void SkQSort_UnitTest();)
-
-#endif
-
index 1a7a3b6..f1ca4b4 100644 (file)
@@ -1,60 +1,77 @@
+/* include/graphics/SkTextBox.h
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #ifndef SkTextBox_DEFINED
 #define SkTextBox_DEFINED
 
 #include "SkCanvas.h"
 
-/**    \class SkTextBox
+/** \class SkTextBox
 
-       SkTextBox is a helper class for drawing 1 or more lines of text
-       within a rectangle. The textbox is positioned and clipped by its Frame.
-       The Margin rectangle controls where the text is drawn relative to
-       the Frame. Line-breaks occur inside the Margin rectangle.
+    SkTextBox is a helper class for drawing 1 or more lines of text
+    within a rectangle. The textbox is positioned and clipped by its Frame.
+    The Margin rectangle controls where the text is drawn relative to
+    the Frame. Line-breaks occur inside the Margin rectangle.
 
-       Spacing is a linear equation used to compute the distance between lines
-       of text. Spacing consists of two scalars: mul and add, and the spacing
-       between lines is computed as: spacing = paint.getTextSize() * mul + add
+    Spacing is a linear equation used to compute the distance between lines
+    of text. Spacing consists of two scalars: mul and add, and the spacing
+    between lines is computed as: spacing = paint.getTextSize() * mul + add
 */
 class SkTextBox {
 public:
-       SkTextBox();
+    SkTextBox();
 
-       enum Mode {
-               kOneLine_Mode,
-               kLineBreak_Mode,
+    enum Mode {
+        kOneLine_Mode,
+        kLineBreak_Mode,
 
-               kModeCount
-       };
-       Mode    getMode() const { return (Mode)fMode; }
-       void    setMode(Mode);
+        kModeCount
+    };
+    Mode    getMode() const { return (Mode)fMode; }
+    void    setMode(Mode);
 
-       enum SpacingAlign {
-               kStart_SpacingAlign,
-               kCenter_SpacingAlign,
-               kEnd_SpacingAlign,
+    enum SpacingAlign {
+        kStart_SpacingAlign,
+        kCenter_SpacingAlign,
+        kEnd_SpacingAlign,
 
-               kSpacingAlignCount
-       };
-       SpacingAlign    getSpacingAlign() const { return (SpacingAlign)fSpacingAlign; }
-       void                    setSpacingAlign(SpacingAlign);
+        kSpacingAlignCount
+    };
+    SpacingAlign    getSpacingAlign() const { return (SpacingAlign)fSpacingAlign; }
+    void            setSpacingAlign(SpacingAlign);
 
-       void    getBox(SkRect*) const;
-       void    setBox(const SkRect&);
-       void    setBox(SkScalar left, SkScalar top, SkScalar right, SkScalar bottom);
+    void    getBox(SkRect*) const;
+    void    setBox(const SkRect&);
+    void    setBox(SkScalar left, SkScalar top, SkScalar right, SkScalar bottom);
 
-       void    getSpacing(SkScalar* mul, SkScalar* add) const;
-       void    setSpacing(SkScalar mul, SkScalar add);
+    void    getSpacing(SkScalar* mul, SkScalar* add) const;
+    void    setSpacing(SkScalar mul, SkScalar add);
 
-       void    draw(SkCanvas*, const char text[], size_t len, const SkPaint&);
+    void    draw(SkCanvas*, const char text[], size_t len, const SkPaint&);
 
 private:
-       SkRect          fBox;
-       SkScalar        fSpacingMul, fSpacingAdd;
-       U8                      fMode, fSpacingAlign;
+    SkRect      fBox;
+    SkScalar    fSpacingMul, fSpacingAdd;
+    U8          fMode, fSpacingAlign;
 };
 
 class SkTextLineBreaker {
 public:
-       static int CountLines(const char text[], size_t len, const SkPaint&, SkScalar width);
+    static int CountLines(const char text[], size_t len, const SkPaint&, SkScalar width);
 };
 
 #endif
diff --git a/include/graphics/SkTextLayout.h b/include/graphics/SkTextLayout.h
deleted file mode 100644 (file)
index 4aa938e..0000000
+++ /dev/null
@@ -1,44 +0,0 @@
-#ifndef SkTextLayout_DEFINED
-#define SkTextLayout_DEFINED
-
-#include "SkRefCnt.h"
-#include "SkPaint.h"
-#include "SkScalar.h"
-
-class SkTextLayout : public SkRefCnt {
-public:
-    /** Create a textlayout that implements the CSS features of letter-spacing
-        and word-spacing. It takes values to add to the advance width for each
-        letter (charExtra) and to add to the advance width for each space
-        (spaceExtra).
-        @param charExtra    amount to add to every character's advance width
-        @param spaceExtra   amount to add to every space character's advance width
-        @return a new textlayout subclass that implements tracking
-    */
-    static SkTextLayout* CreateTrackingLayout(SkScalar charExtra, SkScalar spaceExtra);
-
-    class Rec;
-
-    int layout( const SkPaint& paint,
-                const char* text, size_t byteLength, SkUnicodeWalkerProc proc,
-                Rec rec[]);
-
-    class Rec {
-    public:
-        SkUnichar   charCode() const { return fCharCode; }
-        SkScalar    fDeltaAdvance;  //!< set by the subclass in onLayout()
-    
-    private:
-        SkUnichar   fCharCode;
-        // to be used in the future
-        uint16_t    fGlyphID;
-        uint16_t    fFlags;
-        
-        friend class SkTextLayout;
-    };
-
-protected:
-    virtual void onLayout(const SkPaint& paint, Rec rec[], int count) {}
-};
-
-#endif
index efcef8b..f1c91a0 100644 (file)
@@ -1,32 +1,49 @@
+/* include/graphics/SkTime.h
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #ifndef SkTime_DEFINED
 #define SkTime_DEFINED
 
 #include "SkTypes.h"
 
-/**    \class SkTime
-       Platform-implemented utilities to return time of day, and millisecond counter.
+/** \class SkTime
+    Platform-implemented utilities to return time of day, and millisecond counter.
 */
 class SkTime {
 public:
-       struct DateTime {
-               U16     fYear;                  //!< e.g. 2005
-               U8      fMonth;                 //!< 1..12
-               U8      fDayOfWeek;             //!< 0..6, 0==Sunday
-               U8      fDay;                   //!< 1..31
-               U8      fHour;                  //!< 0..23
-               U8      fMinute;                //!< 0..59
-               U8      fSecond;                //!< 0..59
-       };
-       static void GetDateTime(DateTime*);
-
-       static SkMSec GetMSecs();
+    struct DateTime {
+        U16 fYear;          //!< e.g. 2005
+        U8  fMonth;         //!< 1..12
+        U8  fDayOfWeek;     //!< 0..6, 0==Sunday
+        U8  fDay;           //!< 1..31
+        U8  fHour;          //!< 0..23
+        U8  fMinute;        //!< 0..59
+        U8  fSecond;        //!< 0..59
+    };
+    static void GetDateTime(DateTime*);
+
+    static SkMSec GetMSecs();
 };
 
 #if defined(SK_DEBUG) && defined(SK_BUILD_FOR_WIN32)
-       extern SkMSec gForceTickCount;
+    extern SkMSec gForceTickCount;
 #endif
 
-#define SK_TIME_FACTOR         1
+#define SK_TIME_FACTOR      1
 
 #endif
 
index 3146caf..b293d4b 100644 (file)
@@ -1,3 +1,20 @@
+/* include/graphics/SkTransparentShader.h
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #ifndef SkTransparentShader_DEFINED
 #define SkTransparentShader_DEFINED
 
 
 class SkTransparentShader : public SkShader {
 public:
-       virtual U32             getFlags();
-       virtual bool    setContext(     const SkBitmap& device,
-                                                               const SkPaint& paint,
-                                                               const SkMatrix& matrix);
-       virtual void    shadeSpan(int x, int y, SkPMColor[], int count);
-       virtual void    shadeSpanOpaque16(int x, int y, U16 span[], int count);
+    virtual uint32_t getFlags();
+    virtual bool    setContext( const SkBitmap& device,
+                                const SkPaint& paint,
+                                const SkMatrix& matrix);
+    virtual void    shadeSpan(int x, int y, SkPMColor[], int count);
+    virtual void    shadeSpan16(int x, int y, uint16_t span[], int count);
 
 private:
-       SkBitmap        fDevice;
-       U8                      fAlpha;
+    SkBitmap    fDevice;
+    uint8_t     fAlpha;
 
-       typedef SkShader INHERITED;
+    typedef SkShader INHERITED;
 };
 
 #endif
index cd0c21f..3653cf0 100644 (file)
@@ -1,3 +1,20 @@
+/* include/graphics/SkTypeface.h
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #ifndef SkTypeface_DEFINED
 #define SkTypeface_DEFINED
 
index 0bd00bb..8c73a95 100644 (file)
@@ -1,3 +1,20 @@
+/* include/graphics/SkUnitMapper.h
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #ifndef SkUnitMapper_DEFINED
 #define SkUnitMapper_DEFINED
 
 
 class SkUnitMapper : public SkRefCnt {
 public:
-       /**     Given a value in [0..0xFFFF], return a value in the same range.
-       */
-       virtual U16CPU mapUnit16(U16CPU x) = 0;
+    /** Given a value in [0..0xFFFF], return a value in the same range.
+    */
+    virtual U16CPU mapUnit16(U16CPU x) = 0;
 };
 
-/**    This returns N values between [0...1]
+/** This returns N values between [0...1]
 */
 class SkDiscreteMapper : public SkUnitMapper {
 public:
-       SkDiscreteMapper(unsigned segments);
-       // override
-       virtual U16CPU mapUnit16(U16CPU x);
+    SkDiscreteMapper(unsigned segments);
+    // override
+    virtual U16CPU mapUnit16(U16CPU x);
 private:
-       unsigned fSegments;
-       SkFract fScale;
+    unsigned fSegments;
+    SkFract fScale;
 };
 
-/**    This returns 1 - cos(x), to simulate lighting a sphere
+/** This returns 1 - cos(x), to simulate lighting a sphere
 */
 class SkFlipCosineMapper : public SkUnitMapper {
 public:
-       // override
-       virtual U16CPU mapUnit16(U16CPU x);
+    // override
+    virtual U16CPU mapUnit16(U16CPU x);
 };
 
 #endif
index 3ccba31..b9c8406 100644 (file)
@@ -1,3 +1,20 @@
+/* include/graphics/SkUtils.h
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #ifndef SkUtils_DEFINED
 #define SkUtils_DEFINED
 
@@ -16,9 +33,9 @@
     #define sk_memset16(dst, value, count)  SK_MEMSET16_REDIRECT(dst, value, count)
 #else
     /** Similar to memset(), but this function assigns a 16bit value into the buffer.
-        @param buffer  The memory to have value copied into it
-        @param value   The 16bit value to be copied into buffer
-        @param count   The number of times value should be copied into the buffer.
+        @param buffer   The memory to have value copied into it
+        @param value    The 16bit value to be copied into buffer
+        @param count    The number of times value should be copied into the buffer.
     */
     void sk_memset16(uint16_t dst[], U16CPU value, int count);
 #endif
@@ -27,9 +44,9 @@
     #define sk_memset32(dst, value, count)  SK_MEMSET32_REDIRECT(dst, value, count)
 #else
     /** Similar to memset(), but this function assigns a 32bit value into the buffer.
-        @param buffer  The memory to have value copied into it
-        @param value   The 32bit value to be copied into buffer
-        @param count   The number of times value should be copied into the buffer.
+        @param buffer   The memory to have value copied into it
+        @param value    The 32bit value to be copied into buffer
+        @param count    The number of times value should be copied into the buffer.
     */
     void sk_memset32(uint32_t dst[], uint32_t value, int count);
 #endif
 
 ///////////////////////////////////////////////////////////////////////////
 
-#define kMaxBytesInUTF8Sequence                4
+#define kMaxBytesInUTF8Sequence     4
 
 #ifdef SK_DEBUG
-       int SkUTF8_LeadByteToCount(unsigned c);
+    int SkUTF8_LeadByteToCount(unsigned c);
 #else
-       #define SkUTF8_LeadByteToCount(c)       ((((0xE5 << 24) >> ((unsigned)c >> 4 << 1)) & 3) + 1)
+    #define SkUTF8_LeadByteToCount(c)   ((((0xE5 << 24) >> ((unsigned)c >> 4 << 1)) & 3) + 1)
 #endif
 
 inline int SkUTF8_CountUTF8Bytes(const char utf8[])
 {
-       SkASSERT(utf8);
-       return SkUTF8_LeadByteToCount(*(const uint8_t*)utf8);
+    SkASSERT(utf8);
+    return SkUTF8_LeadByteToCount(*(const uint8_t*)utf8);
 }
 
-int                    SkUTF8_CountUnichars(const char utf8[]);
-int                    SkUTF8_CountUnichars(const char utf8[], size_t byteLength);
-SkUnichar      SkUTF8_ToUnichar(const char utf8[]);
-SkUnichar      SkUTF8_NextUnichar(const char**);
+int         SkUTF8_CountUnichars(const char utf8[]);
+int         SkUTF8_CountUnichars(const char utf8[], size_t byteLength);
+SkUnichar   SkUTF8_ToUnichar(const char utf8[]);
+SkUnichar   SkUTF8_NextUnichar(const char**);
 
-/**    Return the number of bytes need to convert a unichar
-       into a utf8 sequence. Will be 1..kMaxBytesInUTF8Sequence,
-       or 0 if uni is illegal.
+/** Return the number of bytes need to convert a unichar
+    into a utf8 sequence. Will be 1..kMaxBytesInUTF8Sequence,
+    or 0 if uni is illegal.
 */
-size_t         SkUTF8_FromUnichar(SkUnichar uni, char utf8[] = nil);
+size_t      SkUTF8_FromUnichar(SkUnichar uni, char utf8[] = nil);
 
 /////////////////////////////////////////////////////////////////////////////////
 
@@ -77,7 +94,7 @@ size_t      SkUTF16_ToUTF8(const uint16_t utf16[], int numberOf16BitValues, char
 class SkUtils {
 public:
 #ifdef SK_DEBUG
-       static void UnitTest();
+    static void UnitTest();
 #endif
 };
 
index a7868d6..66f8167 100644 (file)
@@ -1,3 +1,20 @@
+/* include/graphics/SkView.h
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #ifndef SkView_DEFINED
 #define SkView_DEFINED
 
 class SkCanvas;
 class SkLayerView;
 
-/**    \class SkView
+/** \class SkView
 
-       SkView is the base class for screen management. All widgets and controls inherit
-       from SkView.
+    SkView is the base class for screen management. All widgets and controls inherit
+    from SkView.
 */
 class SkView : public SkEventSink {
 public:
-       enum Flag_Shift {
-               kVisible_Shift,
-               kEnabled_Shift,
-               kFocusable_Shift,
-               kFlexH_Shift,
-               kFlexV_Shift,
-
-               kFlagShiftCount
-       };
-       enum Flag_Mask {
-               kVisible_Mask   = 1 << kVisible_Shift,          //!< set if the view is visible
-               kEnabled_Mask   = 1 << kEnabled_Shift,          //!< set if the view is enabled
-               kFocusable_Mask = 1 << kFocusable_Shift,        //!< set if the view can receive focus
-               kFlexH_Mask             = 1 << kFlexH_Shift,            //!< set if the view's width is stretchable
-               kFlexV_Mask             = 1 << kFlexV_Shift,            //!< set if the view's height is stretchable
-
-               kAllFlagMasks   = (U32)(0 - 1) >> (32 - kFlagShiftCount)
-       };
-
-                               SkView(U32 flags = 0);
-       virtual         ~SkView();
-
-       /**     Return the flags associated with the view
-       */
-       U32                     getFlags() const { return fFlags; }
-       /**     Set the flags associated with the view
-       */
-       void            setFlags(U32 flags);
-
-       /**     Helper that returns non-zero if the kVisible_Mask bit is set in the view's flags
-       */
-       int                     isVisible() const { return fFlags & kVisible_Mask; }
-       int                     isEnabled() const { return fFlags & kEnabled_Mask; }
-       int                     isFocusable() const { return fFlags & kFocusable_Mask; }
-       /**     Helper to set/clear the view's kVisible_Mask flag */
-       void            setVisibleP(bool);
-       void            setEnabledP(bool);
-       void            setFocusableP(bool);
-
-       /**     Return the view's width */
-       SkScalar        width() const { return fWidth; }
-       /**     Return the view's height */
-       SkScalar        height() const { return fHeight; }
-       /**     Set the view's width and height. These must both be >= 0. This does not affect the view's loc */
-       void            setSize(SkScalar width, SkScalar height);
-       void            setSize(const SkPoint& size) { this->setSize(size.fX, size.fY); }
-       void            setWidth(SkScalar width) { this->setSize(width, fHeight); }
-       void            setHeight(SkScalar height) { this->setSize(fWidth, height); }
-       /**     Return a rectangle set to [0, 0, width, height] */
-       void            getLocalBounds(SkRect* bounds) const;
-
-       /**     Return the view's left edge */
-       SkScalar        locX() const { return fLoc.fX; }
-       /**     Return the view's top edge */
-       SkScalar        locY() const { return fLoc.fY; }
-       /**     Set the view's left and top edge. This does not affect the view's size */
-       void            setLoc(SkScalar x, SkScalar y);
-       void            setLoc(const SkPoint& loc) { this->setLoc(loc.fX, loc.fY); }
-       void            setLocX(SkScalar x) { this->setLoc(x, fLoc.fY); }
-       void            setLocY(SkScalar y) { this->setLoc(fLoc.fX, y); }
-       /**     Offset (move) the view by the specified dx and dy. This does not affect the view's size */
-       void            offset(SkScalar dx, SkScalar dy);
-
-       /**     Call this to have the view draw into the specified canvas. */
-       void            draw(SkCanvas* canvas);
-       /**     Call this to invalidate part of all of a view, requesting that the view's
-               draw method be called. The rectangle parameter specifies the part of the view
-               that should be redrawn. If it is nil, it specifies the entire view bounds.
-       */
-       void            inval(SkRect* rectOrNil);
-
-       //      Focus management
-
-       SkView* getFocusView() const;
-       bool    hasFocus() const;
-
-       enum FocusDirection {
-               kNext_FocusDirection,
-               kPrev_FocusDirection,
-
-               kFocusDirectionCount
-       };
-       bool    acceptFocus();
-       SkView* moveFocus(FocusDirection);
-
-       //      Click handling
-
-       class Click {
-       public:
-               Click(SkView* target);
-               virtual ~Click();
-
-               const char*     getType() const { return fType; }
-               bool            isType(const char type[]) const;
-               void            setType(const char type[]);             // does NOT make a copy of the string
-               void            copyType(const char type[]);    // makes a copy of the string
-
-               enum State {
-                       kDown_State,
-                       kMoved_State,
-                       kUp_State
-               };
-               SkPoint         fOrig, fPrev, fCurr;
-               SkPoint16       fIOrig, fIPrev, fICurr;
-               State           fState;
-       private:
-               SkEventSinkID   fTargetID;
-               char*                   fType;
-               bool                    fWeOwnTheType;
-
-               void resetType();
-
-               friend class SkView;
-       };
-       Click*  findClickHandler(SkScalar x, SkScalar y);
-
-       static void     DoClickDown(Click*, int x, int y);
-       static void     DoClickMoved(Click*, int x, int y);
-       static void     DoClickUp(Click*, int x, int y);
-
-       /**     Send the event to the view's parent, and its parent etc. until one of them
-               returns true from its onEvent call. This view is returned. If no parent handles
-               the event, nil is returned.
-       */
-       SkView*         sendEventToParents(const SkEvent&);
-       /**     Depricated helper function. Just call event->post(sinkID, delay);
-       */
-       bool    postEvent(SkEvent* evt, SkEventSinkID sinkID, SkMSec delay) { return evt->post(sinkID, delay); }
-
-       //      View hierarchy management
-
-       /**     Return the view's parent, or nil if it has none. This does not affect the parent's reference count. */
-       SkView*         getParent() const { return fParent; }
-       SkView*         attachChildToFront(SkView* child);
-       /**     Attach the child view to this view, and increment the child's reference count. The child view is added
-               such that it will be drawn before all other child views.
-               The child view parameter is returned.
-       */
-       SkView*         attachChildToBack(SkView* child);
-       /**     If the view has a parent, detach the view from its parent and decrement the view's reference count.
-               If the parent was the only owner of the view, this will cause the view to be deleted.
-       */
-       void            detachFromParent();
-       /**     Attach the child view to this view, and increment the child's reference count. The child view is added
-               such that it will be drawn after all other child views.
-               The child view parameter is returned.
-       */
-       /**     Detach all child views from this view. */
-       void            detachAllChildren();
-
-       /**     Convert the specified point from global coordinates into view-local coordinates
-       */
-       void            globalToLocal(SkPoint* pt) const { if (pt) this->globalToLocal(pt->fX, pt->fY, pt); }
-       /**     Convert the specified x,y from global coordinates into view-local coordinates, returning
-               the answer in the local parameter.
-       */
-       void            globalToLocal(SkScalar globalX, SkScalar globalY, SkPoint* local) const;
-
-       /**     \class F2BIter
-       
-               Iterator that will return each of this view's children, in
-               front-to-back order (the order used for clicking). The first
-               call to next() returns the front-most child view. When
-               next() returns nil, there are no more child views.
-       */
-       class F2BIter {
-       public:
-               F2BIter(const SkView* parent);
-               SkView* next();
-       private:
-               SkView* fFirstChild, *fChild;
-       };
-
-       /**     \class B2FIter
-       
-               Iterator that will return each of this view's children, in
-               back-to-front order (the order they are drawn). The first
-               call to next() returns the back-most child view. When
-               next() returns nil, there are no more child views.
-       */
-       class B2FIter {
-       public:
-               B2FIter(const SkView* parent);
-               SkView* next();
-       private:
-               SkView* fFirstChild, *fChild;
-       };
-
-       /**     \class Artist
-       
-               Install a subclass of this in a view (calling setArtist()), and then the
-               default implementation of that view's onDraw() will invoke this object
-               automatically.
-       */
-       class Artist : public SkRefCnt {
-       public:
-               void draw(SkView*, SkCanvas*);
-               void inflate(const SkDOM&, const SkDOM::Node*);
-       protected:
-               virtual void onDraw(SkView*, SkCanvas*) = 0;
-               virtual void onInflate(const SkDOM&, const SkDOM::Node*);
-       };
-       /**     Return the artist attached to this view (or nil). The artist's reference
-               count is not affected.
-       */
-       Artist* getArtist() const;
-       /**     Attach the specified artist (or nil) to the view, replacing any existing
-               artist. If the new artist is not nil, its reference count is incremented.
-               The artist parameter is returned.
-       */
-       Artist* setArtist(Artist* artist);
-
-       /**     \class Layout
-       
-               Install a subclass of this in a view (calling setLayout()), and then the
-               default implementation of that view's onLayoutChildren() will invoke
-               this object automatically.
-       */
-       class Layout : public SkRefCnt {
-       public:
-               void layoutChildren(SkView* parent);
-               void inflate(const SkDOM&, const SkDOM::Node*);
-       protected:
-               virtual void onLayoutChildren(SkView* parent) = 0;
-               virtual void onInflate(const SkDOM&, const SkDOM::Node*);
-       };
-
-       /**     Return the layout attached to this view (or nil). The layout's reference
-               count is not affected.
-       */
-       Layout* getLayout() const;
-       /**     Attach the specified layout (or nil) to the view, replacing any existing
-               layout. If the new layout is not nil, its reference count is incremented.
-               The layout parameter is returned.
-       */
-       Layout* setLayout(Layout*, bool invokeLayoutNow = true);
-       /**     If a layout is attached to this view, call its layoutChildren() method
-       */
-       void    invokeLayout();
-
-       /**     Call this to initialize this view based on the specified XML node
-       */
-       void    inflate(const SkDOM& dom, const SkDOM::Node* node);
-       /**     After a view hierarchy is inflated, this may be called with a dictionary
-               containing pairs of <name, view*>, where the name string was the view's
-               "id" attribute when it was inflated.
-
-               This will call the virtual onPostInflate for this view, and the recursively
-               call postInflate on all of the view's children.
-       */
-       void    postInflate(const SkTDict<SkView*>& ids);
-
-       SkDEBUGCODE(void dump(bool recurse) const;)
+    enum Flag_Shift {
+        kVisible_Shift,
+        kEnabled_Shift,
+        kFocusable_Shift,
+        kFlexH_Shift,
+        kFlexV_Shift,
+
+        kFlagShiftCount
+    };
+    enum Flag_Mask {
+        kVisible_Mask   = 1 << kVisible_Shift,      //!< set if the view is visible
+        kEnabled_Mask   = 1 << kEnabled_Shift,      //!< set if the view is enabled
+        kFocusable_Mask = 1 << kFocusable_Shift,    //!< set if the view can receive focus
+        kFlexH_Mask     = 1 << kFlexH_Shift,        //!< set if the view's width is stretchable
+        kFlexV_Mask     = 1 << kFlexV_Shift,        //!< set if the view's height is stretchable
+
+        kAllFlagMasks   = (U32)(0 - 1) >> (32 - kFlagShiftCount)
+    };
+
+                SkView(U32 flags = 0);
+    virtual     ~SkView();
+
+    /** Return the flags associated with the view
+    */
+    U32         getFlags() const { return fFlags; }
+    /** Set the flags associated with the view
+    */
+    void        setFlags(U32 flags);
+
+    /** Helper that returns non-zero if the kVisible_Mask bit is set in the view's flags
+    */
+    int         isVisible() const { return fFlags & kVisible_Mask; }
+    int         isEnabled() const { return fFlags & kEnabled_Mask; }
+    int         isFocusable() const { return fFlags & kFocusable_Mask; }
+    /** Helper to set/clear the view's kVisible_Mask flag */
+    void        setVisibleP(bool);
+    void        setEnabledP(bool);
+    void        setFocusableP(bool);
+
+    /** Return the view's width */
+    SkScalar    width() const { return fWidth; }
+    /** Return the view's height */
+    SkScalar    height() const { return fHeight; }
+    /** Set the view's width and height. These must both be >= 0. This does not affect the view's loc */
+    void        setSize(SkScalar width, SkScalar height);
+    void        setSize(const SkPoint& size) { this->setSize(size.fX, size.fY); }
+    void        setWidth(SkScalar width) { this->setSize(width, fHeight); }
+    void        setHeight(SkScalar height) { this->setSize(fWidth, height); }
+    /** Return a rectangle set to [0, 0, width, height] */
+    void        getLocalBounds(SkRect* bounds) const;
+
+    /** Return the view's left edge */
+    SkScalar    locX() const { return fLoc.fX; }
+    /** Return the view's top edge */
+    SkScalar    locY() const { return fLoc.fY; }
+    /** Set the view's left and top edge. This does not affect the view's size */
+    void        setLoc(SkScalar x, SkScalar y);
+    void        setLoc(const SkPoint& loc) { this->setLoc(loc.fX, loc.fY); }
+    void        setLocX(SkScalar x) { this->setLoc(x, fLoc.fY); }
+    void        setLocY(SkScalar y) { this->setLoc(fLoc.fX, y); }
+    /** Offset (move) the view by the specified dx and dy. This does not affect the view's size */
+    void        offset(SkScalar dx, SkScalar dy);
+
+    /** Call this to have the view draw into the specified canvas. */
+    void        draw(SkCanvas* canvas);
+    /** Call this to invalidate part of all of a view, requesting that the view's
+        draw method be called. The rectangle parameter specifies the part of the view
+        that should be redrawn. If it is nil, it specifies the entire view bounds.
+    */
+    void        inval(SkRect* rectOrNil);
+
+    //  Focus management
+
+    SkView* getFocusView() const;
+    bool    hasFocus() const;
+
+    enum FocusDirection {
+        kNext_FocusDirection,
+        kPrev_FocusDirection,
+
+        kFocusDirectionCount
+    };
+    bool    acceptFocus();
+    SkView* moveFocus(FocusDirection);
+
+    //  Click handling
+
+    class Click {
+    public:
+        Click(SkView* target);
+        virtual ~Click();
+
+        const char* getType() const { return fType; }
+        bool        isType(const char type[]) const;
+        void        setType(const char type[]);     // does NOT make a copy of the string
+        void        copyType(const char type[]);    // makes a copy of the string
+
+        enum State {
+            kDown_State,
+            kMoved_State,
+            kUp_State
+        };
+        SkPoint     fOrig, fPrev, fCurr;
+        SkPoint16   fIOrig, fIPrev, fICurr;
+        State       fState;
+    private:
+        SkEventSinkID   fTargetID;
+        char*           fType;
+        bool            fWeOwnTheType;
+
+        void resetType();
+
+        friend class SkView;
+    };
+    Click*  findClickHandler(SkScalar x, SkScalar y);
+
+    static void DoClickDown(Click*, int x, int y);
+    static void DoClickMoved(Click*, int x, int y);
+    static void DoClickUp(Click*, int x, int y);
+
+    /** Send the event to the view's parent, and its parent etc. until one of them
+        returns true from its onEvent call. This view is returned. If no parent handles
+        the event, nil is returned.
+    */
+    SkView*     sendEventToParents(const SkEvent&);
+    /** Depricated helper function. Just call event->post(sinkID, delay);
+    */
+    bool    postEvent(SkEvent* evt, SkEventSinkID sinkID, SkMSec delay) { return evt->post(sinkID, delay); }
+
+    //  View hierarchy management
+
+    /** Return the view's parent, or nil if it has none. This does not affect the parent's reference count. */
+    SkView*     getParent() const { return fParent; }
+    SkView*     attachChildToFront(SkView* child);
+    /** Attach the child view to this view, and increment the child's reference count. The child view is added
+        such that it will be drawn before all other child views.
+        The child view parameter is returned.
+    */
+    SkView*     attachChildToBack(SkView* child);
+    /** If the view has a parent, detach the view from its parent and decrement the view's reference count.
+        If the parent was the only owner of the view, this will cause the view to be deleted.
+    */
+    void        detachFromParent();
+    /** Attach the child view to this view, and increment the child's reference count. The child view is added
+        such that it will be drawn after all other child views.
+        The child view parameter is returned.
+    */
+    /** Detach all child views from this view. */
+    void        detachAllChildren();
+
+    /** Convert the specified point from global coordinates into view-local coordinates
+    */
+    void        globalToLocal(SkPoint* pt) const { if (pt) this->globalToLocal(pt->fX, pt->fY, pt); }
+    /** Convert the specified x,y from global coordinates into view-local coordinates, returning
+        the answer in the local parameter.
+    */
+    void        globalToLocal(SkScalar globalX, SkScalar globalY, SkPoint* local) const;
+
+    /** \class F2BIter
+    
+        Iterator that will return each of this view's children, in
+        front-to-back order (the order used for clicking). The first
+        call to next() returns the front-most child view. When
+        next() returns nil, there are no more child views.
+    */
+    class F2BIter {
+    public:
+        F2BIter(const SkView* parent);
+        SkView* next();
+    private:
+        SkView* fFirstChild, *fChild;
+    };
+
+    /** \class B2FIter
+    
+        Iterator that will return each of this view's children, in
+        back-to-front order (the order they are drawn). The first
+        call to next() returns the back-most child view. When
+        next() returns nil, there are no more child views.
+    */
+    class B2FIter {
+    public:
+        B2FIter(const SkView* parent);
+        SkView* next();
+    private:
+        SkView* fFirstChild, *fChild;
+    };
+
+    /** \class Artist
+    
+        Install a subclass of this in a view (calling setArtist()), and then the
+        default implementation of that view's onDraw() will invoke this object
+        automatically.
+    */
+    class Artist : public SkRefCnt {
+    public:
+        void draw(SkView*, SkCanvas*);
+        void inflate(const SkDOM&, const SkDOM::Node*);
+    protected:
+        virtual void onDraw(SkView*, SkCanvas*) = 0;
+        virtual void onInflate(const SkDOM&, const SkDOM::Node*);
+    };
+    /** Return the artist attached to this view (or nil). The artist's reference
+        count is not affected.
+    */
+    Artist* getArtist() const;
+    /** Attach the specified artist (or nil) to the view, replacing any existing
+        artist. If the new artist is not nil, its reference count is incremented.
+        The artist parameter is returned.
+    */
+    Artist* setArtist(Artist* artist);
+
+    /** \class Layout
+    
+        Install a subclass of this in a view (calling setLayout()), and then the
+        default implementation of that view's onLayoutChildren() will invoke
+        this object automatically.
+    */
+    class Layout : public SkRefCnt {
+    public:
+        void layoutChildren(SkView* parent);
+        void inflate(const SkDOM&, const SkDOM::Node*);
+    protected:
+        virtual void onLayoutChildren(SkView* parent) = 0;
+        virtual void onInflate(const SkDOM&, const SkDOM::Node*);
+    };
+
+    /** Return the layout attached to this view (or nil). The layout's reference
+        count is not affected.
+    */
+    Layout* getLayout() const;
+    /** Attach the specified layout (or nil) to the view, replacing any existing
+        layout. If the new layout is not nil, its reference count is incremented.
+        The layout parameter is returned.
+    */
+    Layout* setLayout(Layout*, bool invokeLayoutNow = true);
+    /** If a layout is attached to this view, call its layoutChildren() method
+    */
+    void    invokeLayout();
+
+    /** Call this to initialize this view based on the specified XML node
+    */
+    void    inflate(const SkDOM& dom, const SkDOM::Node* node);
+    /** After a view hierarchy is inflated, this may be called with a dictionary
+        containing pairs of <name, view*>, where the name string was the view's
+        "id" attribute when it was inflated.
+
+        This will call the virtual onPostInflate for this view, and the recursively
+        call postInflate on all of the view's children.
+    */
+    void    postInflate(const SkTDict<SkView*>& ids);
+
+    SkDEBUGCODE(void dump(bool recurse) const;)
 
 protected:
-       /**     Override this to draw inside the view. Be sure to call the inherited version too */
-       virtual void    onDraw(SkCanvas*);
-       /**     Override this to be notified when the view's size changes. Be sure to call the inherited version too */
-       virtual void    onSizeChange();
-       /** Override this if you want to handle an inval request from this view or one of its children.
-               Tyically this is only overridden by the by the "window". If your subclass does handle the
-               request, return true so the request will not continue to propogate to the parent.
-       */
-       virtual bool    handleInval(const SkRect&);
-       /**     Override this if you might handle the click
-       */
-       virtual Click*  onFindClickHandler(SkScalar x, SkScalar y);
-       /**     Override this to track clicks, returning true as long as you want to track
-               the pen/mouse.
-       */
-       virtual bool    onClick(Click*);
-       /**     Override this to initialize your subclass from the XML node. Be sure to call the inherited version too */
-       virtual void    onInflate(const SkDOM& dom, const SkDOM::Node* node);
-       /** Override this if you want to perform post initialization work based on the ID dictionary built
-               during XML parsing. Be sure to call the inherited version too.
-       */
-       virtual void    onPostInflate(const SkTDict<SkView*>&);
+    /** Override this to draw inside the view. Be sure to call the inherited version too */
+    virtual void    onDraw(SkCanvas*);
+    /** Override this to be notified when the view's size changes. Be sure to call the inherited version too */
+    virtual void    onSizeChange();
+    /** Override this if you want to handle an inval request from this view or one of its children.
+        Tyically this is only overridden by the by the "window". If your subclass does handle the
+        request, return true so the request will not continue to propogate to the parent.
+    */
+    virtual bool    handleInval(const SkRect&);
+    /** Override this if you might handle the click
+    */
+    virtual Click*  onFindClickHandler(SkScalar x, SkScalar y);
+    /** Override this to track clicks, returning true as long as you want to track
+        the pen/mouse.
+    */
+    virtual bool    onClick(Click*);
+    /** Override this to initialize your subclass from the XML node. Be sure to call the inherited version too */
+    virtual void    onInflate(const SkDOM& dom, const SkDOM::Node* node);
+    /** Override this if you want to perform post initialization work based on the ID dictionary built
+        during XML parsing. Be sure to call the inherited version too.
+    */
+    virtual void    onPostInflate(const SkTDict<SkView*>&);
 
 public:
-       // default action is to inval the view
-       virtual void    onFocusChange(bool gainFocusP);
+    // default action is to inval the view
+    virtual void    onFocusChange(bool gainFocusP);
 protected:
 
-       // override these if you're acting as a layer/host
-       virtual bool    onGetFocusView(SkView**) const { return false; }
-       virtual bool    onSetFocusView(SkView*) { return false; }
+    // override these if you're acting as a layer/host
+    virtual bool    onGetFocusView(SkView**) const { return false; }
+    virtual bool    onSetFocusView(SkView*) { return false; }
 
 private:
-       SkScalar        fWidth, fHeight;
-       SkPoint         fLoc;
-       SkView*         fParent;
-       SkView*         fFirstChild;
-       SkView*         fNextSibling;
-       SkView*         fPrevSibling;
-
-       U8                      fFlags;
-       U8                      fContainsFocus;
-
-       friend class B2FIter;
-       friend class F2BIter;
-       
-       friend class SkLayerView;
-
-       bool    setFocusView(SkView* fvOrNil);
-       SkView* acceptFocus(FocusDirection);
-       void    detachFromParent_NoLayout();
+    SkScalar    fWidth, fHeight;
+    SkPoint     fLoc;
+    SkView*     fParent;
+    SkView*     fFirstChild;
+    SkView*     fNextSibling;
+    SkView*     fPrevSibling;
+
+    U8          fFlags;
+    U8          fContainsFocus;
+
+    friend class B2FIter;
+    friend class F2BIter;
+    
+    friend class SkLayerView;
+
+    bool    setFocusView(SkView* fvOrNil);
+    SkView* acceptFocus(FocusDirection);
+    void    detachFromParent_NoLayout();
 };
 
 #endif
index 5bf9f43..e2d97ce 100644 (file)
@@ -1,3 +1,20 @@
+/* include/graphics/SkViewInflate.h
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #ifndef SkViewInflate_DEFINED
 #define SkViewInflate_DEFINED
 
@@ -9,54 +26,54 @@ class SkView;
 
 class SkViewInflate {
 public: 
-                       SkViewInflate();
-       virtual ~SkViewInflate();
+            SkViewInflate();
+    virtual ~SkViewInflate();
 
-       /**     Return the tree of inflated views. If root is nil, create the root element
-               as a view, otherwise assume root is that view, and just "inflate" it.
+    /** Return the tree of inflated views. If root is nil, create the root element
+        as a view, otherwise assume root is that view, and just "inflate" it.
 
-               Returns nil if the tree cannot be built.
-       */
-       SkView* inflate(const SkDOM& dom, const SkDOM::Node* node, SkView* root = nil);
-       SkView* inflate(const char xml[], size_t len, SkView* root = nil);
+        Returns nil if the tree cannot be built.
+    */
+    SkView* inflate(const SkDOM& dom, const SkDOM::Node* node, SkView* root = nil);
+    SkView* inflate(const char xml[], size_t len, SkView* root = nil);
 
-       /**     Given an id attribute value, return the corresponding view, or nil
-               if no match is found.
-       */
-       SkView* findViewByID(const char id[]) const;
-       
-       SkDEBUGCODE(void dump() const;)
+    /** Given an id attribute value, return the corresponding view, or nil
+        if no match is found.
+    */
+    SkView* findViewByID(const char id[]) const;
+    
+    SkDEBUGCODE(void dump() const;)
 
 protected:
-       /*      Override this in your subclass to handle instantiating views
-               Call the inherited version for nodes you don't recognize.
-
-               Do not call "inflate" on the view, just return it. This will
-               get called automatically after createView returns.
-       */
-       virtual SkView* createView(const SkDOM& dom, const SkDOM::Node* node);
-       /**     Base implementation calls view->inflate(dom, node). Subclasses may override this
-               to perform additional initializations to view, either before or after calling
-               the inherited version.
-       */
-       virtual void inflateView(SkView* view, const SkDOM& dom, const SkDOM::Node* node);
+    /*  Override this in your subclass to handle instantiating views
+        Call the inherited version for nodes you don't recognize.
+
+        Do not call "inflate" on the view, just return it. This will
+        get called automatically after createView returns.
+    */
+    virtual SkView* createView(const SkDOM& dom, const SkDOM::Node* node);
+    /** Base implementation calls view->inflate(dom, node). Subclasses may override this
+        to perform additional initializations to view, either before or after calling
+        the inherited version.
+    */
+    virtual void inflateView(SkView* view, const SkDOM& dom, const SkDOM::Node* node);
 
 private:
-       enum {
-               kMinIDStrAlloc = 64
-       };
-       SkTDict<SkView*> fIDs;
+    enum {
+        kMinIDStrAlloc = 64
+    };
+    SkTDict<SkView*> fIDs;
 
-       struct IDStr {
-               SkView* fView;
-               char*   fStr;
-       };
-       SkTDArray<IDStr>        fListenTo, fBroadcastTo;
-       SkChunkAlloc            fStrings;
+    struct IDStr {
+        SkView* fView;
+        char*   fStr;
+    };
+    SkTDArray<IDStr>    fListenTo, fBroadcastTo;
+    SkChunkAlloc        fStrings;
 
-       void addIDStr(SkTDArray<IDStr>* list, SkView*, const char* str);
+    void addIDStr(SkTDArray<IDStr>* list, SkView*, const char* str);
 
-       void    rInflate(const SkDOM& dom, const SkDOM::Node* node, SkView* parent);
+    void    rInflate(const SkDOM& dom, const SkDOM::Node* node, SkView* parent);
 };
 
 #endif
index 586eb7a..37128bd 100644 (file)
@@ -1,3 +1,20 @@
+/* include/graphics/SkWidget.h
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #ifndef SkWidget_DEFINED
 #define SkWidget_DEFINED
 
 
 class SkWidget : public SkView {
 public:
-       SkWidget(U32 flags = 0) : SkView(flags | kFocusable_Mask | kEnabled_Mask) {}
+    SkWidget(U32 flags = 0) : SkView(flags | kFocusable_Mask | kEnabled_Mask) {}
 
-       /**     Call this to post the widget's event to its listeners */
-       void    postWidgetEvent();
+    /** Call this to post the widget's event to its listeners */
+    void    postWidgetEvent();
 
-       static void Init();
-       static void Term();
+    static void Init();
+    static void Term();
 protected:
-       // override to add slots to an event before posting
-       virtual void prepareWidgetEvent(SkEvent*);
-       virtual void onEnabledChange();
+    // override to add slots to an event before posting
+    virtual void prepareWidgetEvent(SkEvent*);
+    virtual void onEnabledChange();
 
-       // <event ...> to initialize the event from XML
-       virtual void onInflate(const SkDOM& dom, const SkDOM::Node* node);
+    // <event ...> to initialize the event from XML
+    virtual void onInflate(const SkDOM& dom, const SkDOM::Node* node);
 
 private:
-       SkEvent fEvent;
-       typedef SkView INHERITED;
+    SkEvent fEvent;
+    typedef SkView INHERITED;
 };
 
 class SkHasLabelWidget : public SkWidget {
 public:
-       SkHasLabelWidget(U32 flags = 0) : SkWidget(flags) {}
+    SkHasLabelWidget(U32 flags = 0) : SkWidget(flags) {}
 
-       size_t  getLabel(SkString* label = nil) const;
-       size_t  getLabel(char lable[] = nil) const;
-       void    setLabel(const SkString&);
-       void    setLabel(const char label[]);
-       void    setLabel(const char label[], size_t len);
+    size_t  getLabel(SkString* label = nil) const;
+    size_t  getLabel(char lable[] = nil) const;
+    void    setLabel(const SkString&);
+    void    setLabel(const char label[]);
+    void    setLabel(const char label[], size_t len);
 
 protected:
-       // called when the label changes
-       virtual void onLabelChange();
+    // called when the label changes
+    virtual void onLabelChange();
 
-       // overrides
-       virtual void onInflate(const SkDOM& dom, const SkDOM::Node*);
+    // overrides
+    virtual void onInflate(const SkDOM& dom, const SkDOM::Node*);
 
 private:
-       SkString        fLabel;
-       typedef SkWidget INHERITED;
+    SkString    fLabel;
+    typedef SkWidget INHERITED;
 };
 
 class SkButtonWidget : public SkHasLabelWidget {
 public:
-       SkButtonWidget(U32 flags = 0) : SkHasLabelWidget(flags), fState(kOff_State) {}
+    SkButtonWidget(U32 flags = 0) : SkHasLabelWidget(flags), fState(kOff_State) {}
 
-       enum State {
-               kOff_State,             //!< XML: buttonState="off"
-               kOn_State,              //!< XML: buttonState="on"
-               kUnknown_State  //!< XML: buttonState="unknown"
-       };
-       State   getButtonState() const { return fState; }
-       void    setButtonState(State);
+    enum State {
+        kOff_State,     //!< XML: buttonState="off"
+        kOn_State,      //!< XML: buttonState="on"
+        kUnknown_State  //!< XML: buttonState="unknown"
+    };
+    State   getButtonState() const { return fState; }
+    void    setButtonState(State);
 
 protected:
-       /** called when the label changes. default behavior is to inval the widget */
-       virtual void onButtonStateChange();
+    /** called when the label changes. default behavior is to inval the widget */
+    virtual void onButtonStateChange();
 
-       // overrides
-       virtual void onInflate(const SkDOM& dom, const SkDOM::Node*);
+    // overrides
+    virtual void onInflate(const SkDOM& dom, const SkDOM::Node*);
 
 private:
-       State   fState;
-       typedef SkHasLabelWidget INHERITED;
+    State   fState;
+    typedef SkHasLabelWidget INHERITED;
 };
 
 class SkPushButtonWidget : public SkButtonWidget {
 public:
-       SkPushButtonWidget(U32 flags = 0) : SkButtonWidget(flags) {}
+    SkPushButtonWidget(U32 flags = 0) : SkButtonWidget(flags) {}
 
 protected:
-       virtual bool onEvent(const SkEvent&);
-       virtual void onDraw(SkCanvas*);
-       virtual Click* onFindClickHandler(SkScalar x, SkScalar y);
-       virtual bool onClick(Click* click);
+    virtual bool onEvent(const SkEvent&);
+    virtual void onDraw(SkCanvas*);
+    virtual Click* onFindClickHandler(SkScalar x, SkScalar y);
+    virtual bool onClick(Click* click);
 
 private:
-       typedef SkButtonWidget INHERITED;
+    typedef SkButtonWidget INHERITED;
 };
 
 class SkCheckBoxWidget : public SkButtonWidget {
 public:
-       SkCheckBoxWidget(U32 flags = 0);
+    SkCheckBoxWidget(U32 flags = 0);
 
 protected:
-       virtual bool onEvent(const SkEvent&);
-       virtual void onDraw(SkCanvas*);
-       virtual void onInflate(const SkDOM& dom, const SkDOM::Node*);
+    virtual bool onEvent(const SkEvent&);
+    virtual void onDraw(SkCanvas*);
+    virtual void onInflate(const SkDOM& dom, const SkDOM::Node*);
 
 private:
-       typedef SkButtonWidget INHERITED;
+    typedef SkButtonWidget INHERITED;
 };
 
 #include "SkTextBox.h"
 
 class SkStaticTextView : public SkView {
 public:
-                       SkStaticTextView(U32 flags = 0);
-       virtual ~SkStaticTextView();
+            SkStaticTextView(U32 flags = 0);
+    virtual ~SkStaticTextView();
 
-       enum Mode {
-               kFixedSize_Mode,
-               kAutoWidth_Mode,
-               kAutoHeight_Mode,
+    enum Mode {
+        kFixedSize_Mode,
+        kAutoWidth_Mode,
+        kAutoHeight_Mode,
 
-               kModeCount
-       };
-       Mode    getMode() const { return (Mode)fMode; }
-       void    setMode(Mode);
+        kModeCount
+    };
+    Mode    getMode() const { return (Mode)fMode; }
+    void    setMode(Mode);
 
-       SkTextBox::SpacingAlign getSpacingAlign() const { return (SkTextBox::SpacingAlign)fSpacingAlign; }
-       void    setSpacingAlign(SkTextBox::SpacingAlign);
+    SkTextBox::SpacingAlign getSpacingAlign() const { return (SkTextBox::SpacingAlign)fSpacingAlign; }
+    void    setSpacingAlign(SkTextBox::SpacingAlign);
 
-       void    getMargin(SkPoint* margin) const;
-       void    setMargin(SkScalar dx, SkScalar dy);
+    void    getMargin(SkPoint* margin) const;
+    void    setMargin(SkScalar dx, SkScalar dy);
 
-       size_t  getText(SkString* text = nil) const;
-       size_t  getText(char text[] = nil) const;
-       void    setText(const SkString&);
-       void    setText(const char text[]);
-       void    setText(const char text[], size_t len);
+    size_t  getText(SkString* text = nil) const;
+    size_t  getText(char text[] = nil) const;
+    void    setText(const SkString&);
+    void    setText(const char text[]);
+    void    setText(const char text[], size_t len);
 
-       void    getPaint(SkPaint*) const;
-       void    setPaint(const SkPaint&);
+    void    getPaint(SkPaint*) const;
+    void    setPaint(const SkPaint&);
 
 protected:
-       // overrides
-       virtual void onDraw(SkCanvas*);
-       virtual void onInflate(const SkDOM& dom, const SkDOM::Node*);
+    // overrides
+    virtual void onDraw(SkCanvas*);
+    virtual void onInflate(const SkDOM& dom, const SkDOM::Node*);
 
 private:
-       SkPoint         fMargin;
-       SkString        fText;
-       SkPaint         fPaint;
-       U8                      fMode;
-       U8                      fSpacingAlign;
+    SkPoint     fMargin;
+    SkString    fText;
+    SkPaint     fPaint;
+    U8          fMode;
+    U8          fSpacingAlign;
 
-       void computeSize();
+    void computeSize();
 
-       typedef SkView INHERITED;
+    typedef SkView INHERITED;
 };
 
 class SkBitmapView : public SkView {
 public:
-                       SkBitmapView(U32 flags = 0);
-       virtual ~SkBitmapView();
+            SkBitmapView(U32 flags = 0);
+    virtual ~SkBitmapView();
 
-       bool    getBitmap(SkBitmap*) const;
-       void    setBitmap(const SkBitmap*, bool viewOwnsPixels);
-       bool    loadBitmapFromFile(const char path[]);
+    bool    getBitmap(SkBitmap*) const;
+    void    setBitmap(const SkBitmap*, bool viewOwnsPixels);
+    bool    loadBitmapFromFile(const char path[]);
 
 protected:
-       virtual void onDraw(SkCanvas*);
-       virtual void onInflate(const SkDOM&, const SkDOM::Node*);
+    virtual void onDraw(SkCanvas*);
+    virtual void onInflate(const SkDOM&, const SkDOM::Node*);
 
 private:
-       SkBitmap        fBitmap;
-       typedef SkView INHERITED;
+    SkBitmap    fBitmap;
+    typedef SkView INHERITED;
 };
 
 /////////////////////////////////////////////////////////////////////////////
@@ -179,143 +196,143 @@ class SkInterpolator;
 
 class SkWidgetView : public SkView {
 public:
-                       SkWidgetView(U32 flags = 0);
-       virtual ~SkWidgetView();
+            SkWidgetView(U32 flags = 0);
+    virtual ~SkWidgetView();
 
-       static const char*      GetEventType();
+    static const char*  GetEventType();
 };
 
 class SkSliderView : public SkWidgetView {
 public:
-       SkSliderView(U32 flags = 0);
+    SkSliderView(U32 flags = 0);
 
-       U16             getValue() const { return fValue; }
-       U16             getMax() const { return fMax; }
+    U16     getValue() const { return fValue; }
+    U16     getMax() const { return fMax; }
 
-       void    setMax(U16CPU max);
-       void    setValue(U16CPU value);
+    void    setMax(U16CPU max);
+    void    setValue(U16CPU value);
 
 protected:
-       virtual void    onDraw(SkCanvas*);
-       virtual Click*  onFindClickHandler(SkScalar x, SkScalar y);
-       virtual bool    onClick(Click*);
+    virtual void    onDraw(SkCanvas*);
+    virtual Click*  onFindClickHandler(SkScalar x, SkScalar y);
+    virtual bool    onClick(Click*);
 
 private:
-       U16     fValue, fMax;
+    U16 fValue, fMax;
 
-       typedef SkWidgetView INHERITED;
+    typedef SkWidgetView INHERITED;
 };
 
 //////////////////////////////////////////////////////////////////////////////
 
 class SkHasLabelView : public SkView {
 public:
-       void    getLabel(SkString*) const;
-       void    setLabel(const SkString&);
-       void    setLabel(const char label[]);
+    void    getLabel(SkString*) const;
+    void    setLabel(const SkString&);
+    void    setLabel(const char label[]);
 
 protected:
-       SkString        fLabel;
+    SkString    fLabel;
 
-       // called when the label changes
-       virtual void onLabelChange();
+    // called when the label changes
+    virtual void onLabelChange();
 
-       // overrides
-       virtual void onInflate(const SkDOM& dom, const SkDOM::Node*);
+    // overrides
+    virtual void onInflate(const SkDOM& dom, const SkDOM::Node*);
 };
 
 class SkPushButtonView : public SkHasLabelView {
 public:
-       SkPushButtonView(U32 flags = 0);
+    SkPushButtonView(U32 flags = 0);
 
 protected:
-       virtual void onDraw(SkCanvas*);
-       virtual void onInflate(const SkDOM& dom, const SkDOM::Node*);
+    virtual void onDraw(SkCanvas*);
+    virtual void onInflate(const SkDOM& dom, const SkDOM::Node*);
 };
 
 class SkCheckBoxView : public SkHasLabelView {
 public:
-       SkCheckBoxView(U32 flags = 0);
+    SkCheckBoxView(U32 flags = 0);
 
-       enum State {
-               kOff_State,
-               kOn_State,
-               kMaybe_State
-       };
-       State   getState() const { return fState; }
-       void    setState(State);
+    enum State {
+        kOff_State,
+        kOn_State,
+        kMaybe_State
+    };
+    State   getState() const { return fState; }
+    void    setState(State);
 
 protected:
-       virtual void onDraw(SkCanvas*);
-       virtual void onInflate(const SkDOM& dom, const SkDOM::Node*);
+    virtual void onDraw(SkCanvas*);
+    virtual void onInflate(const SkDOM& dom, const SkDOM::Node*);
 
 private:
-       State   fState;
+    State   fState;
 };
 
 class SkProgressView : public SkView {
 public:
-       SkProgressView(U32 flags = 0);
-       virtual ~SkProgressView();
+    SkProgressView(U32 flags = 0);
+    virtual ~SkProgressView();
 
-       U16             getValue() const { return fValue; }
-       U16             getMax() const { return fMax; }
+    U16     getValue() const { return fValue; }
+    U16     getMax() const { return fMax; }
 
-       void    setMax(U16CPU max);
-       void    setValue(U16CPU value);
+    void    setMax(U16CPU max);
+    void    setValue(U16CPU value);
 
 protected:
-       virtual void onDraw(SkCanvas*);
-       virtual void onInflate(const SkDOM& dom, const SkDOM::Node* node);
+    virtual void onDraw(SkCanvas*);
+    virtual void onInflate(const SkDOM& dom, const SkDOM::Node* node);
 
 private:
-       U16                     fValue, fMax;
-       SkShader*       fOnShader, *fOffShader;
-       SkInterpolator* fInterp;
-       bool fDoInterp;
+    U16         fValue, fMax;
+    SkShader*   fOnShader, *fOffShader;
+    SkInterpolator* fInterp;
+    bool fDoInterp;
 
-       typedef SkView INHERITED;
+    typedef SkView INHERITED;
 };
 
 class SkTextView : public SkView {
 public:
-                       SkTextView(U32 flags = 0);
-       virtual ~SkTextView();
+            SkTextView(U32 flags = 0);
+    virtual ~SkTextView();
 
-       enum AnimaDir {
-               kNeutral_AnimDir,
-               kForward_AnimDir,
-               kBackward_AnimDir,
-               kAnimDirCount
-       };
+    enum AnimaDir {
+        kNeutral_AnimDir,
+        kForward_AnimDir,
+        kBackward_AnimDir,
+        kAnimDirCount
+    };
 
-       void    getText(SkString*) const;
-       void    setText(const SkString&, AnimaDir dir = kNeutral_AnimDir);
-       void    setText(const char text[], AnimaDir dir = kNeutral_AnimDir);
-       void    setText(const char text[], size_t len, AnimaDir dir = kNeutral_AnimDir);
+    void    getText(SkString*) const;
+    void    setText(const SkString&, AnimaDir dir = kNeutral_AnimDir);
+    void    setText(const char text[], AnimaDir dir = kNeutral_AnimDir);
+    void    setText(const char text[], size_t len, AnimaDir dir = kNeutral_AnimDir);
 
-       void    getMargin(SkPoint* margin) const;
-       void    setMargin(const SkPoint&);
+    void    getMargin(SkPoint* margin) const;
+    void    setMargin(const SkPoint&);
 
-       SkPaint&        paint() { return fPaint; }
+    SkPaint&    paint() { return fPaint; }
 
 protected:
-       virtual void onDraw(SkCanvas*);
-       virtual void onInflate(const SkDOM& dom, const SkDOM::Node* node);
+    virtual void onDraw(SkCanvas*);
+    virtual void onInflate(const SkDOM& dom, const SkDOM::Node* node);
 
 private:
-       SkString fText;
-       SkPaint  fPaint;
-       SkPoint  fMargin;
-
-       class Interp;
-       Interp* fInterp;
-       bool    fDoInterp;
-       // called by the other setText methods. This guy does not check for !=
-       // before doing the assign, so the caller must check for us
-       void privSetText(const SkString&, AnimaDir dir);
-
-       typedef SkView INHERITED;
+    SkString fText;
+    SkPaint  fPaint;
+    SkPoint  fMargin;
+
+    class Interp;
+    Interp* fInterp;
+    bool    fDoInterp;
+    // called by the other setText methods. This guy does not check for !=
+    // before doing the assign, so the caller must check for us
+    void privSetText(const SkString&, AnimaDir dir);
+
+    typedef SkView INHERITED;
 };
 
 //////////////////////////////////////////////////////////
@@ -324,136 +341,136 @@ class SkEvent;
 
 class SkListSource : public SkEventSink {
 public:
-       virtual int     countRows() = 0;
-       virtual void getRow(int index, SkString* left, SkString* right) = 0;
-       virtual SkEvent* getEvent(int index);
+    virtual int countRows() = 0;
+    virtual void getRow(int index, SkString* left, SkString* right) = 0;
+    virtual SkEvent* getEvent(int index);
 
-       static SkListSource* CreateFromDir(const char path[], const char suffix[],
-                                                                               const char targetPrefix[]);
-       static SkListSource* CreateFromDOM(const SkDOM& dom, const SkDOM::Node* node);
+    static SkListSource* CreateFromDir(const char path[], const char suffix[],
+                                        const char targetPrefix[]);
+    static SkListSource* CreateFromDOM(const SkDOM& dom, const SkDOM::Node* node);
 };
 
 class SkListView : public SkWidgetView {
 public:
-                       SkListView(U32 flags = 0);
-       virtual ~SkListView();
-
-       SkScalar        getRowHeight() const { return fRowHeight; }
-       void            setRowHeight(SkScalar);
-
-       /**     Return the index of the selected row, or -1 if none
-       */
-       int             getSelection() const { return fCurrIndex; }
-       /**     Set the index of the selected row, or -1 for none
-       */
-       void    setSelection(int);
-
-       void    moveSelectionUp();
-       void    moveSelectionDown();
-
-       enum Attr {
-               kBG_Attr,
-               kNormalText_Attr,
-               kHiliteText_Attr,
-               kHiliteCell_Attr,
-               kAttrCount
-       };
-       SkPaint&        paint(Attr);
-
-       SkListSource*   getListSource() const { return fSource; }
-       SkListSource*   setListSource(SkListSource*);
+            SkListView(U32 flags = 0);
+    virtual ~SkListView();
+
+    SkScalar    getRowHeight() const { return fRowHeight; }
+    void        setRowHeight(SkScalar);
+
+    /** Return the index of the selected row, or -1 if none
+    */
+    int     getSelection() const { return fCurrIndex; }
+    /** Set the index of the selected row, or -1 for none
+    */
+    void    setSelection(int);
+
+    void    moveSelectionUp();
+    void    moveSelectionDown();
+
+    enum Attr {
+        kBG_Attr,
+        kNormalText_Attr,
+        kHiliteText_Attr,
+        kHiliteCell_Attr,
+        kAttrCount
+    };
+    SkPaint&    paint(Attr);
+
+    SkListSource*   getListSource() const { return fSource; }
+    SkListSource*   setListSource(SkListSource*);
 
 #if 0
-       enum Action {
-               kSelectionChange_Action,
-               kSelectionPicked_Action,
-               kActionCount
-       };
-       /**     If event is not nil, it is retained by the view, and a copy
-               of the event will be posted to its listeners when the specified
-               action occurs. If event is nil, then no event will be posted for
-               the specified action.
-       */
-       void    setActionEvent(Action, SkEvent* event);
+    enum Action {
+        kSelectionChange_Action,
+        kSelectionPicked_Action,
+        kActionCount
+    };
+    /** If event is not nil, it is retained by the view, and a copy
+        of the event will be posted to its listeners when the specified
+        action occurs. If event is nil, then no event will be posted for
+        the specified action.
+    */
+    void    setActionEvent(Action, SkEvent* event);
 #endif
 
 protected:
-       virtual void onDraw(SkCanvas*);
-       virtual void onSizeChange();
-       virtual bool onEvent(const SkEvent&);
-       virtual void onInflate(const SkDOM& dom, const SkDOM::Node* node);
+    virtual void onDraw(SkCanvas*);
+    virtual void onSizeChange();
+    virtual bool onEvent(const SkEvent&);
+    virtual void onInflate(const SkDOM& dom, const SkDOM::Node* node);
 
 private:
-       SkPaint                 fPaint[kAttrCount];
-       SkListSource*   fSource;
-       SkScalar                fRowHeight;
-       int                             fCurrIndex;             // logical index
-       int                             fScrollIndex;   // logical index of top-most visible row
-       int                             fVisibleRowCount;
-       SkString*               fStrCache;
-
-       void    dirtyStrCache();
-       void    ensureStrCache(int visibleCount);
-
-       int             logicalToVisualIndex(int index) const { return index - fScrollIndex; }
-       void    invalSelection();
-       bool    getRowRect(int index, SkRect*) const;
-       void    ensureSelectionIsVisible();
-
-       typedef SkWidgetView INHERITED;
+    SkPaint         fPaint[kAttrCount];
+    SkListSource*   fSource;
+    SkScalar        fRowHeight;
+    int             fCurrIndex;     // logical index
+    int             fScrollIndex;   // logical index of top-most visible row
+    int             fVisibleRowCount;
+    SkString*       fStrCache;
+
+    void    dirtyStrCache();
+    void    ensureStrCache(int visibleCount);
+
+    int     logicalToVisualIndex(int index) const { return index - fScrollIndex; }
+    void    invalSelection();
+    bool    getRowRect(int index, SkRect*) const;
+    void    ensureSelectionIsVisible();
+
+    typedef SkWidgetView INHERITED;
 };
 
 //////////////////////////////////////////////////////////
 
 class SkGridView : public SkWidgetView {
 public:
-                       SkGridView(U32 flags = 0);
-       virtual ~SkGridView();
+            SkGridView(U32 flags = 0);
+    virtual ~SkGridView();
 
-       void    getCellSize(SkPoint*) const;
-       void    setCellSize(SkScalar x, SkScalar y);
+    void    getCellSize(SkPoint*) const;
+    void    setCellSize(SkScalar x, SkScalar y);
 
-       /**     Return the index of the selected item, or -1 if none
-       */
-       int             getSelection() const { return fCurrIndex; }
-       /**     Set the index of the selected row, or -1 for none
-       */
-       void    setSelection(int);
+    /** Return the index of the selected item, or -1 if none
+    */
+    int     getSelection() const { return fCurrIndex; }
+    /** Set the index of the selected row, or -1 for none
+    */
+    void    setSelection(int);
 
-       void    moveSelectionUp();
-       void    moveSelectionDown();
+    void    moveSelectionUp();
+    void    moveSelectionDown();
 
-       enum Attr {
-               kBG_Attr,
-               kHiliteCell_Attr,
-               kAttrCount
-       };
-       SkPaint&        paint(Attr);
+    enum Attr {
+        kBG_Attr,
+        kHiliteCell_Attr,
+        kAttrCount
+    };
+    SkPaint&    paint(Attr);
 
-       SkListSource*   getListSource() const { return fSource; }
-       SkListSource*   setListSource(SkListSource*);
+    SkListSource*   getListSource() const { return fSource; }
+    SkListSource*   setListSource(SkListSource*);
 
 protected:
-       virtual void onDraw(SkCanvas*);
-       virtual void onSizeChange();
-       virtual bool onEvent(const SkEvent&);
-       virtual void onInflate(const SkDOM& dom, const SkDOM::Node* node);
+    virtual void onDraw(SkCanvas*);
+    virtual void onSizeChange();
+    virtual bool onEvent(const SkEvent&);
+    virtual void onInflate(const SkDOM& dom, const SkDOM::Node* node);
 
 private:
-       SkView*                 fScrollBar;
-       SkPaint                 fPaint[kAttrCount];
-       SkListSource*   fSource;
-       int                             fCurrIndex;             // logical index
+    SkView*         fScrollBar;
+    SkPaint         fPaint[kAttrCount];
+    SkListSource*   fSource;
+    int             fCurrIndex;     // logical index
 
-       SkPoint                 fCellSize;
-       SkPoint16               fVisibleCount;
+    SkPoint         fCellSize;
+    SkPoint16       fVisibleCount;
 
-       int             logicalToVisualIndex(int index) const { return index; }
-       void    invalSelection();
-       bool    getCellRect(int index, SkRect*) const;
-       void    ensureSelectionIsVisible();
+    int     logicalToVisualIndex(int index) const { return index; }
+    void    invalSelection();
+    bool    getCellRect(int index, SkRect*) const;
+    void    ensureSelectionIsVisible();
 
-       typedef SkWidgetView INHERITED;
+    typedef SkWidgetView INHERITED;
 };
 
 #endif
index 52a3e0d..e22cd22 100644 (file)
@@ -1,3 +1,20 @@
+/* include/graphics/SkWidgetViews.h
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #ifndef SkWidgetViews_DEFINED
 #define SkWidgetViews_DEFINED
 
 
 
 enum SkWidgetEnum {
-       kBorder_WidgetEnum,                     //!< <sk-border>
-       kButton_WidgetEnum,                     //!< <sk-button>
-       kImage_WidgetEnum,                      //!< <sk-image>
-       kList_WidgetEnum,                       //!< <sk-list>
-       kProgress_WidgetEnum,           //!< <sk-progress>
-       kScroll_WidgetEnum,                     //!< <sk-scroll>
-       kText_WidgetEnum,                       //!< <sk-text>
-       
-       kWidgetEnumCount
+    kBorder_WidgetEnum,         //!< <sk-border>
+    kButton_WidgetEnum,         //!< <sk-button>
+    kImage_WidgetEnum,          //!< <sk-image>
+    kList_WidgetEnum,           //!< <sk-list>
+    kProgress_WidgetEnum,       //!< <sk-progress>
+    kScroll_WidgetEnum,         //!< <sk-scroll>
+    kText_WidgetEnum,           //!< <sk-text>
+    
+    kWidgetEnumCount
 };
 
 //determines which skin to use
 enum SkinEnum {
-       kBorder_SkinEnum,
-       kButton_SkinEnum,
-       kProgress_SkinEnum,
-       kScroll_SkinEnum,
-       kStaticText_SkinEnum,
-       
-       kSkinEnumCount
+    kBorder_SkinEnum,
+    kButton_SkinEnum,
+    kProgress_SkinEnum,
+    kScroll_SkinEnum,
+    kStaticText_SkinEnum,
+    
+    kSkinEnumCount
 };
 
 #include "SkAnimator.h"
@@ -35,13 +52,13 @@ void init_skin_anim(SkinEnum se, SkAnimator* anim);
 void init_skin_paint(SkinEnum se, SkPaint* paint);
 void inflate_paint(const SkDOM& dom, const SkDOM::Node* node, SkPaint* paint);
 
-/**    Given an enum value, return an instance of the specified widget.
-       If the enum is out of range, returns nil
+/** Given an enum value, return an instance of the specified widget.
+    If the enum is out of range, returns nil
 */
 SkView* SkWidgetFactory(SkWidgetEnum);
-/**    Given the inflate/element name of a widget, return an instance of
-       the specified widget, or nil if name does not match any known
-       widget type.
+/** Given the inflate/element name of a widget, return an instance of
+    the specified widget, or nil if name does not match any known
+    widget type.
 */
 SkView* SkWidgetFactory(const char name[]);
 
@@ -49,95 +66,95 @@ SkView* SkWidgetFactory(const char name[]);
 
 class SkWidgetView : public SkView {
 public:
-       SkWidgetView();
+    SkWidgetView();
 
-       const char*     getLabel() const;
-       void            getLabel(SkString* label) const;
+    const char* getLabel() const;
+    void        getLabel(SkString* label) const;
 
-       void            setLabel(const char[]);
-       void            setLabel(const char[], size_t len);
-       void            setLabel(const SkString&);
+    void        setLabel(const char[]);
+    void        setLabel(const char[], size_t len);
+    void        setLabel(const SkString&);
 
-       SkEvent&                event() { return fEvent; }
-       const SkEvent&  event() const { return fEvent; }
+    SkEvent&        event() { return fEvent; }
+    const SkEvent&  event() const { return fEvent; }
 
-       /**     Returns true if the widget can post its event to its listeners.
-       */
-       bool    postWidgetEvent();
-       
-       /**     Returns the sinkID of the widgetview that posted the event, or 0
-       */
-       static SkEventSinkID GetWidgetEventSinkID(const SkEvent&);
+    /** Returns true if the widget can post its event to its listeners.
+    */
+    bool    postWidgetEvent();
+    
+    /** Returns the sinkID of the widgetview that posted the event, or 0
+    */
+    static SkEventSinkID GetWidgetEventSinkID(const SkEvent&);
 
 protected:
-       /** called when the label changes. override in subclasses. default action invals the view's bounds.
-               called with the old and new labels, before the label has actually changed.
-       */
-       virtual void onLabelChange(const char oldLabel[], const char newLabel[]);
-       /**     called before posting the event to our listeners. Override to add slots to the event
-               before posting. Return true to proceed with posting, or false to not post the event to any
-               listener. Note: the event passed in may not be the same as calling this->event().
-               Be sure to call your INHERITED method as well, so that all classes in the hierarchy get a shot
-               at modifying the event (and possibly returning false to abort).
-       */
-       virtual bool onPrepareWidgetEvent(SkEvent* evt);
-
-       // overrides
-       virtual void onInflate(const SkDOM& dom, const SkDOM::Node*);
-       
+    /** called when the label changes. override in subclasses. default action invals the view's bounds.
+        called with the old and new labels, before the label has actually changed.
+    */
+    virtual void onLabelChange(const char oldLabel[], const char newLabel[]);
+    /** called before posting the event to our listeners. Override to add slots to the event
+        before posting. Return true to proceed with posting, or false to not post the event to any
+        listener. Note: the event passed in may not be the same as calling this->event().
+        Be sure to call your INHERITED method as well, so that all classes in the hierarchy get a shot
+        at modifying the event (and possibly returning false to abort).
+    */
+    virtual bool onPrepareWidgetEvent(SkEvent* evt);
+
+    // overrides
+    virtual void onInflate(const SkDOM& dom, const SkDOM::Node*);
+    
 private:
-       SkString        fLabel;
-       SkEvent         fEvent;
-       
-       typedef SkView INHERITED;
+    SkString    fLabel;
+    SkEvent     fEvent;
+    
+    typedef SkView INHERITED;
 };
 
 ////////////////////////////////////////////////////////////////////////////////////////////////
 
 class SkButtonView : public SkWidgetView {
 public:
-       // inflate: "sk-button"
-       
+    // inflate: "sk-button"
+    
 protected:
-       // overrides
-       virtual bool onEvent(const SkEvent&);
+    // overrides
+    virtual bool onEvent(const SkEvent&);
 };
 
 ////////////////////////////////////////////////////////////////////////////////////////////////
 
 class SkCheckButtonView : public SkWidgetView {
 public:
-       SkCheckButtonView();
-
-       // inflate: "sk-checkbutton"
-       
-       enum CheckState {
-               kOff_CheckState,                //!< inflate: check-state="off"
-               kOn_CheckState,                 //!< inflate: check-state="on"
-               kUnknown_CheckState             //!< inflate: check-state="unknown"
-       };
-       CheckState      getCheckState() const { return (CheckState)fCheckState; }
-       void            setCheckState(CheckState);
-
-       /** use this to extract the CheckState from an event (i.e. one that as posted
-               by a SkCheckButtonView). Returns true if the proper slot was present in the event,
-               and sets state to that value. If no proper slot is found, returns false and does not
-               modify state.
-       */
-       static bool GetWidgetEventCheckState(const SkEvent&, CheckState* state);
+    SkCheckButtonView();
+
+    // inflate: "sk-checkbutton"
+    
+    enum CheckState {
+        kOff_CheckState,        //!< inflate: check-state="off"
+        kOn_CheckState,         //!< inflate: check-state="on"
+        kUnknown_CheckState     //!< inflate: check-state="unknown"
+    };
+    CheckState  getCheckState() const { return (CheckState)fCheckState; }
+    void        setCheckState(CheckState);
+
+    /** use this to extract the CheckState from an event (i.e. one that as posted
+        by a SkCheckButtonView). Returns true if the proper slot was present in the event,
+        and sets state to that value. If no proper slot is found, returns false and does not
+        modify state.
+    */
+    static bool GetWidgetEventCheckState(const SkEvent&, CheckState* state);
 
 protected:
-       // called when the check-state is about to change, but before it actually has
-       virtual void onCheckStateChange(CheckState oldState, CheckState newState);
+    // called when the check-state is about to change, but before it actually has
+    virtual void onCheckStateChange(CheckState oldState, CheckState newState);
 
-       // overrides
-       virtual void onInflate(const SkDOM& dom, const SkDOM::Node*);
-       virtual bool onPrepareWidgetEvent(SkEvent* evt);
-       
+    // overrides
+    virtual void onInflate(const SkDOM& dom, const SkDOM::Node*);
+    virtual bool onPrepareWidgetEvent(SkEvent* evt);
+    
 private:
-       U8      fCheckState;
-       
-       typedef SkWidgetView INHERITED;
+    U8  fCheckState;
+    
+    typedef SkWidgetView INHERITED;
 };
 
 ////////////////////////////////////////////////////////////////////////////////////////////////
@@ -145,49 +162,49 @@ private:
 
 class SkStaticTextView : public SkView {
 public:
-                       SkStaticTextView();
-       virtual ~SkStaticTextView();
+            SkStaticTextView();
+    virtual ~SkStaticTextView();
 
-       enum Mode {
-               kFixedSize_Mode,
-               kAutoWidth_Mode,
-               kAutoHeight_Mode,
+    enum Mode {
+        kFixedSize_Mode,
+        kAutoWidth_Mode,
+        kAutoHeight_Mode,
 
-               kModeCount
-       };
-       Mode    getMode() const { return (Mode)fMode; }
-       void    setMode(Mode);
+        kModeCount
+    };
+    Mode    getMode() const { return (Mode)fMode; }
+    void    setMode(Mode);
 
-       SkTextBox::SpacingAlign getSpacingAlign() const { return (SkTextBox::SpacingAlign)fSpacingAlign; }
-       void    setSpacingAlign(SkTextBox::SpacingAlign);
+    SkTextBox::SpacingAlign getSpacingAlign() const { return (SkTextBox::SpacingAlign)fSpacingAlign; }
+    void    setSpacingAlign(SkTextBox::SpacingAlign);
 
-       void    getMargin(SkPoint* margin) const;
-       void    setMargin(SkScalar dx, SkScalar dy);
+    void    getMargin(SkPoint* margin) const;
+    void    setMargin(SkScalar dx, SkScalar dy);
 
-       size_t  getText(SkString* text = nil) const;
-       size_t  getText(char text[] = nil) const;
-       void    setText(const SkString&);
-       void    setText(const char text[]);
-       void    setText(const char text[], size_t len);
+    size_t  getText(SkString* text = nil) const;
+    size_t  getText(char text[] = nil) const;
+    void    setText(const SkString&);
+    void    setText(const char text[]);
+    void    setText(const char text[], size_t len);
 
-       void    getPaint(SkPaint*) const;
-       void    setPaint(const SkPaint&);
+    void    getPaint(SkPaint*) const;
+    void    setPaint(const SkPaint&);
 
 protected:
-       // overrides
-       virtual void onDraw(SkCanvas*);
-       virtual void onInflate(const SkDOM& dom, const SkDOM::Node*);
+    // overrides
+    virtual void onDraw(SkCanvas*);
+    virtual void onInflate(const SkDOM& dom, const SkDOM::Node*);
 
 private:
-       SkPoint         fMargin;
-       SkString        fText;
-       SkPaint         fPaint;
-       U8                      fMode;
-       U8                      fSpacingAlign;
+    SkPoint     fMargin;
+    SkString    fText;
+    SkPaint     fPaint;
+    U8          fMode;
+    U8          fSpacingAlign;
 
-       void computeSize();
+    void computeSize();
 
-       typedef SkView INHERITED;
+    typedef SkView INHERITED;
 };
 
 ////////////////////////////////////////////////////////////////////////////////////////////////
@@ -198,97 +215,97 @@ class SkScrollBarView;
 
 class SkListView : public SkWidgetView {
 public:
-                       SkListView();
-       virtual ~SkListView();
-
-       bool    hasScrollBar() const { return fScrollBar != nil; }
-       void    setHasScrollBar(bool);
-       
-       /** Return the number of visible rows
-       */
-       int             getVisibleRowCount() const { return fVisibleRowCount; }
-       /**     Return the index of the selected row, or -1 if none
-       */
-       int             getSelection() const { return fCurrIndex; }
-       /**     Set the index of the selected row, or -1 for none
-       */
-       void    setSelection(int);
-       /**     If possible, move the selection up and return true,
-               else do nothing and return false
-               If nothing is selected, select the last item (unless there are no items).
-       */
-       bool    moveSelectionUp();
-       /**     If possible, move the selection down and return true,
-               else do nothing and return false.
-               If nothing is selected, select the first item (unless there are no items).
-       */
-       bool    moveSelectionDown();
-
-       SkListSource*   getListSource() const { return fSource; }
-       SkListSource*   setListSource(SkListSource*);
-
-       /**     Call this in your event handler. If the specified event is from a SkListView,
-               then it returns the index of the selected item in this list, otherwise it
-               returns -1
-       */
-       static int GetWidgetEventListIndex(const SkEvent&);
+            SkListView();
+    virtual ~SkListView();
+
+    bool    hasScrollBar() const { return fScrollBar != nil; }
+    void    setHasScrollBar(bool);
+    
+    /** Return the number of visible rows
+    */
+    int     getVisibleRowCount() const { return fVisibleRowCount; }
+    /** Return the index of the selected row, or -1 if none
+    */
+    int     getSelection() const { return fCurrIndex; }
+    /** Set the index of the selected row, or -1 for none
+    */
+    void    setSelection(int);
+    /** If possible, move the selection up and return true,
+        else do nothing and return false
+        If nothing is selected, select the last item (unless there are no items).
+    */
+    bool    moveSelectionUp();
+    /** If possible, move the selection down and return true,
+        else do nothing and return false.
+        If nothing is selected, select the first item (unless there are no items).
+    */
+    bool    moveSelectionDown();
+
+    SkListSource*   getListSource() const { return fSource; }
+    SkListSource*   setListSource(SkListSource*);
+
+    /** Call this in your event handler. If the specified event is from a SkListView,
+        then it returns the index of the selected item in this list, otherwise it
+        returns -1
+    */
+    static int GetWidgetEventListIndex(const SkEvent&);
 
 protected:
-       // overrides
-       virtual void onDraw(SkCanvas*);
-       virtual void onSizeChange();
-       virtual bool onEvent(const SkEvent&);
-       virtual void onInflate(const SkDOM& dom, const SkDOM::Node* node);
-       virtual bool onPrepareWidgetEvent(SkEvent*);
+    // overrides
+    virtual void onDraw(SkCanvas*);
+    virtual void onSizeChange();
+    virtual bool onEvent(const SkEvent&);
+    virtual void onInflate(const SkDOM& dom, const SkDOM::Node* node);
+    virtual bool onPrepareWidgetEvent(SkEvent*);
 
 private:
-       enum DirtyFlags {
-               kAnimCount_DirtyFlag    = 0x01,
-               kAnimContent_DirtyFlag  = 0x02
-       };
-       void    dirtyCache(unsigned dirtyFlags);
-       bool    ensureCache();
-
-       int             logicalToVisualIndex(int index) const { return index - fScrollIndex; }
-       void    invalSelection();
-       SkScalar getContentWidth() const;
-       bool    getRowRect(int index, SkRect*) const;
-       void    ensureSelectionIsVisible();
-       void    ensureVisibleRowCount();
-
-       struct BindingRec;
-
-       enum Heights {
-               kNormal_Height,
-               kSelected_Height
-       };
-       SkListSource*   fSource;
-       SkScrollBarView*        fScrollBar;
-       SkAnimator*             fAnims;
-       BindingRec*             fBindings;
-       SkString                fSkinName;
-       SkScalar                fHeights[2];
-       S16                             fScrollIndex, fCurrIndex;
-       U16                             fVisibleRowCount, fBindingCount;
-       SkBool8                 fAnimContentDirty;
-       SkBool8                 fAnimFocusDirty;
-
-       typedef SkWidgetView INHERITED;
+    enum DirtyFlags {
+        kAnimCount_DirtyFlag    = 0x01,
+        kAnimContent_DirtyFlag  = 0x02
+    };
+    void    dirtyCache(unsigned dirtyFlags);
+    bool    ensureCache();
+
+    int     logicalToVisualIndex(int index) const { return index - fScrollIndex; }
+    void    invalSelection();
+    SkScalar getContentWidth() const;
+    bool    getRowRect(int index, SkRect*) const;
+    void    ensureSelectionIsVisible();
+    void    ensureVisibleRowCount();
+
+    struct BindingRec;
+
+    enum Heights {
+        kNormal_Height,
+        kSelected_Height
+    };
+    SkListSource*   fSource;
+    SkScrollBarView*    fScrollBar;
+    SkAnimator*     fAnims;
+    BindingRec*     fBindings;
+    SkString        fSkinName;
+    SkScalar        fHeights[2];
+    S16             fScrollIndex, fCurrIndex;
+    U16             fVisibleRowCount, fBindingCount;
+    SkBool8         fAnimContentDirty;
+    SkBool8         fAnimFocusDirty;
+
+    typedef SkWidgetView INHERITED;
 };
 
 class SkListSource : public SkRefCnt {
 public:
-       virtual int countFields();
-       virtual void getFieldName(int index, SkString* field);
-       /**     Return the index of the named field, or -1 if not found */
-       virtual int findFieldIndex(const char field[]);
+    virtual int countFields();
+    virtual void getFieldName(int index, SkString* field);
+    /** Return the index of the named field, or -1 if not found */
+    virtual int findFieldIndex(const char field[]);
 
-       virtual int     countRecords();
-       virtual void getRecord(int rowIndex, int fieldIndex, SkString* data);
+    virtual int countRecords();
+    virtual void getRecord(int rowIndex, int fieldIndex, SkString* data);
 
-       virtual bool prepareWidgetEvent(SkEvent*, int rowIndex);
-       
-       static SkListSource* Factory(const char name[]);
+    virtual bool prepareWidgetEvent(SkEvent*, int rowIndex);
+    
+    static SkListSource* Factory(const char name[]);
 };
 
 #endif
index 8132b11..43d5a34 100644 (file)
@@ -1,3 +1,20 @@
+/* include/graphics/SkWindow.h
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #ifndef SkWindow_DEFINED
 #define SkWindow_DEFINED
 
@@ -9,7 +26,7 @@
 #include "SkTDArray.h"
 
 #ifdef SK_BUILD_FOR_WINCEx
-       #define SHOW_FPS
+    #define SHOW_FPS
 #endif
 //#define USE_GX_SCREEN
 
@@ -17,62 +34,62 @@ class SkOSMenu;
 
 class SkWindow : public SkView {
 public:
-                       SkWindow();
-       virtual ~SkWindow();
+            SkWindow();
+    virtual ~SkWindow();
 
-       const SkBitmap& getBitmap() const { return fBitmap; }
+    const SkBitmap& getBitmap() const { return fBitmap; }
 
-       void    setConfig(SkBitmap::Config);
-       void    resize(int width, int height, SkBitmap::Config config = SkBitmap::kNo_Config);
-       void    eraseARGB(U8CPU a, U8CPU r, U8CPU g, U8CPU b);
-       void    eraseRGB(U8CPU r, U8CPU g, U8CPU b);
+    void    setConfig(SkBitmap::Config);
+    void    resize(int width, int height, SkBitmap::Config config = SkBitmap::kNo_Config);
+    void    eraseARGB(U8CPU a, U8CPU r, U8CPU g, U8CPU b);
+    void    eraseRGB(U8CPU r, U8CPU g, U8CPU b);
 
-       bool    isDirty() const { return !fDirtyRgn.isEmpty(); }
-       bool    update(SkRect16* updateArea);
-       bool    handleClick(int x, int y, Click::State);
-       bool    handleChar(SkUnichar);
-       bool    handleKey(SkKey);
+    bool    isDirty() const { return !fDirtyRgn.isEmpty(); }
+    bool    update(SkRect16* updateArea);
+    bool    handleClick(int x, int y, Click::State);
+    bool    handleChar(SkUnichar);
+    bool    handleKey(SkKey);
     bool    handleKeyUp(SkKey);
-       bool    handleMenu(U32 os_cmd);
+    bool    handleMenu(U32 os_cmd);
 
-       void    addMenu(SkOSMenu*);
+    void    addMenu(SkOSMenu*);
 
 protected:
-       virtual bool onEvent(const SkEvent&);
+    virtual bool onEvent(const SkEvent&);
 
-       // called if part of our bitmap is invalidated
-       virtual void onHandleInval(const SkRect16&);
-       virtual bool onHandleChar(SkUnichar);
-       virtual bool onHandleKey(SkKey);
+    // called if part of our bitmap is invalidated
+    virtual void onHandleInval(const SkRect16&);
+    virtual bool onHandleChar(SkUnichar);
+    virtual bool onHandleKey(SkKey);
     virtual bool onHandleKeyUp(SkKey);
-       virtual void onAddMenu(const SkOSMenu*) {}
+    virtual void onAddMenu(const SkOSMenu*) {}
 
-       // overrides from SkView
-       virtual bool handleInval(const SkRect&);
-       virtual bool onGetFocusView(SkView** focus) const;
-       virtual bool onSetFocusView(SkView* focus);
+    // overrides from SkView
+    virtual bool handleInval(const SkRect&);
+    virtual bool onGetFocusView(SkView** focus) const;
+    virtual bool onSetFocusView(SkView* focus);
 
 private:
-       SkBitmap::Config        fConfig;
-       SkBitmap        fBitmap;
-       SkRegion        fDirtyRgn;
-       Click*          fClick; // to track clicks
+    SkBitmap::Config    fConfig;
+    SkBitmap    fBitmap;
+    SkRegion    fDirtyRgn;
+    Click*      fClick; // to track clicks
 
-       SkTDArray<SkOSMenu*>    fMenus;
+    SkTDArray<SkOSMenu*>    fMenus;
 
-       SkView* fFocusView;
-       bool    fWaitingOnInval;
+    SkView* fFocusView;
+    bool    fWaitingOnInval;
 
-       typedef SkView INHERITED;
+    typedef SkView INHERITED;
 };
 
 ///////////////////////////////////////////////////////////
 
 #ifndef SK_USE_WXWIDGETS
 #ifdef SK_BUILD_FOR_MAC
-       #include "SkOSWindow_Mac.h"
+    #include "SkOSWindow_Mac.h"
 #elif defined(SK_BUILD_FOR_WIN)
-       #include "SkOSWindow_Win.h"
+    #include "SkOSWindow_Win.h"
 #elif defined(SK_BUILD_FOR_UNIXx)
   #include "SkOSWindow_Unix.h"
 #endif
index 1255822..239c385 100644 (file)
@@ -1,3 +1,20 @@
+/* include/graphics/SkXMLParser.h
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #ifndef SkXMLParser_DEFINED
 #define SkXMLParser_DEFINED
 
@@ -11,69 +28,69 @@ struct SkDOMNode;
 
 class SkXMLParserError {
 public:
-       enum ErrorCode {
-               kNoError,
-               kEmptyFile,
-               kUnknownElement,
-               kUnknownAttributeName,
-               kErrorInAttributeValue,
-               kDuplicateIDs,
-               kUnknownError
-       };
+    enum ErrorCode {
+        kNoError,
+        kEmptyFile,
+        kUnknownElement,
+        kUnknownAttributeName,
+        kErrorInAttributeValue,
+        kDuplicateIDs,
+        kUnknownError
+    };
 
-       SkXMLParserError();
-       virtual ~SkXMLParserError();
-       ErrorCode getErrorCode() const { return fCode; }
-       virtual void getErrorString(SkString* str) const;
-       int getLineNumber() const { return fLineNumber; }
-       int getNativeCode() const { return fNativeCode; }
-       bool hasError() const { return fCode != kNoError || fNativeCode != -1; }
-       bool hasNoun() const { return fNoun.size() > 0; }
-       void reset();
-       void setCode(ErrorCode code) { fCode = code; }
-       void setNoun(const SkString& str) { fNoun.set(str); }
-       void setNoun(const char* ch)  { fNoun.set(ch); }
-       void setNoun(const char* ch, size_t len) { fNoun.set(ch, len); }
+    SkXMLParserError();
+    virtual ~SkXMLParserError();
+    ErrorCode getErrorCode() const { return fCode; }
+    virtual void getErrorString(SkString* str) const;
+    int getLineNumber() const { return fLineNumber; }
+    int getNativeCode() const { return fNativeCode; }
+    bool hasError() const { return fCode != kNoError || fNativeCode != -1; }
+    bool hasNoun() const { return fNoun.size() > 0; }
+    void reset();
+    void setCode(ErrorCode code) { fCode = code; }
+    void setNoun(const SkString& str) { fNoun.set(str); }
+    void setNoun(const char* ch)  { fNoun.set(ch); }
+    void setNoun(const char* ch, size_t len) { fNoun.set(ch, len); }
 protected:
-       ErrorCode fCode;
+    ErrorCode fCode;
 private:
-       int fLineNumber;
-       int fNativeCode;
-       SkString fNoun;
-       friend class SkXMLParser;
+    int fLineNumber;
+    int fNativeCode;
+    SkString fNoun;
+    friend class SkXMLParser;
 };
 
 class SkXMLParser {
 public:
-                       SkXMLParser(SkXMLParserError* parserError = nil);
-       virtual ~SkXMLParser();
+            SkXMLParser(SkXMLParserError* parserError = nil);
+    virtual ~SkXMLParser();
 
-       /**     Returns true for success
-       */
-       bool parse(const char doc[], size_t len);
-       bool parse(SkStream& docStream);
-       bool parse(const SkDOM&, const SkDOMNode*);
+    /** Returns true for success
+    */
+    bool parse(const char doc[], size_t len);
+    bool parse(SkStream& docStream);
+    bool parse(const SkDOM&, const SkDOMNode*);
 
-       static void GetNativeErrorString(int nativeErrorCode, SkString* str);
+    static void GetNativeErrorString(int nativeErrorCode, SkString* str);
 
 protected:
-       // override in subclasses; return true to stop parsing
-       virtual bool onStartElement(const char elem[]);
-       virtual bool onAddAttribute(const char name[], const char value[]);
-       virtual bool onEndElement(const char elem[]);
-       virtual bool onText(const char text[], int len);
+    // override in subclasses; return true to stop parsing
+    virtual bool onStartElement(const char elem[]);
+    virtual bool onAddAttribute(const char name[], const char value[]);
+    virtual bool onEndElement(const char elem[]);
+    virtual bool onText(const char text[], int len);
 
 public:
-       // public for ported implementation, not meant for clients to call
-       virtual bool startElement(const char elem[]);
-       virtual bool addAttribute(const char name[], const char value[]);
-       virtual bool endElement(const char elem[]);
-       virtual bool text(const char text[], int len); 
-       void* fParser;
+    // public for ported implementation, not meant for clients to call
+    virtual bool startElement(const char elem[]);
+    virtual bool addAttribute(const char name[], const char value[]);
+    virtual bool endElement(const char elem[]);
+    virtual bool text(const char text[], int len); 
+    void* fParser;
 protected:
-       SkXMLParserError* fError;
+    SkXMLParserError* fError;
 private:
-       void reportError(void* parser);
+    void reportError(void* parser);
 };
 
 #endif
index cc2c55a..77d5f81 100644 (file)
@@ -1,3 +1,20 @@
+/* include/graphics/SkXMLWriter.h
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #ifndef SkXMLWriter_DEFINED
 #define SkXMLWriter_DEFINED
 
@@ -10,66 +27,66 @@ class SkXMLParser;
 
 class SkXMLWriter {
 public:
-                       SkXMLWriter(bool doEscapeMarkup = true);
-       virtual ~SkXMLWriter();
+            SkXMLWriter(bool doEscapeMarkup = true);
+    virtual ~SkXMLWriter();
 
-       void    addS32Attribute(const char name[], S32 value);
-       void    addAttribute(const char name[], const char value[]);
-       void    addAttributeLen(const char name[], const char value[], size_t length);
-       void    addHexAttribute(const char name[], U32 value, int minDigits = 0);
-       void    addScalarAttribute(const char name[], SkScalar value);
-       void    endElement() { this->onEndElement(); }
-       void    startElement(const char elem[]);
-       void    startElementLen(const char elem[], size_t length);
-       void    writeDOM(const SkDOM&, const SkDOM::Node*, bool skipRoot);
-       void    flush();
-       virtual void writeHeader();
+    void    addS32Attribute(const char name[], S32 value);
+    void    addAttribute(const char name[], const char value[]);
+    void    addAttributeLen(const char name[], const char value[], size_t length);
+    void    addHexAttribute(const char name[], U32 value, int minDigits = 0);
+    void    addScalarAttribute(const char name[], SkScalar value);
+    void    endElement() { this->onEndElement(); }
+    void    startElement(const char elem[]);
+    void    startElementLen(const char elem[], size_t length);
+    void    writeDOM(const SkDOM&, const SkDOM::Node*, bool skipRoot);
+    void    flush();
+    virtual void writeHeader();
 
 protected:
-       virtual void onStartElementLen(const char elem[], size_t length) = 0;
-       virtual void onAddAttributeLen(const char name[], const char value[], size_t length) = 0;
-       virtual void onEndElement() = 0;
+    virtual void onStartElementLen(const char elem[], size_t length) = 0;
+    virtual void onAddAttributeLen(const char name[], const char value[], size_t length) = 0;
+    virtual void onEndElement() = 0;
 
-       struct Elem {
-               SkString        fName;
-               bool            fHasChildren;
-       };
-       void doEnd(Elem* elem);
-       bool doStart(const char name[], size_t length);
-       Elem* getEnd();
-       const char*     getHeader();
-       SkTDArray<Elem*> fElems;
+    struct Elem {
+        SkString    fName;
+        bool        fHasChildren;
+    };
+    void doEnd(Elem* elem);
+    bool doStart(const char name[], size_t length);
+    Elem* getEnd();
+    const char* getHeader();
+    SkTDArray<Elem*> fElems;
 
 private:
-       bool fDoEscapeMarkup;
-       // illegal
-       SkXMLWriter& operator=(const SkXMLWriter&);
+    bool fDoEscapeMarkup;
+    // illegal
+    SkXMLWriter& operator=(const SkXMLWriter&);
 };
 
 class SkXMLStreamWriter : public SkXMLWriter {
 public:
-       SkXMLStreamWriter(SkWStream*);
-       virtual ~SkXMLStreamWriter();
-       virtual void    writeHeader();
-       SkDEBUGCODE(static void UnitTest();)
+    SkXMLStreamWriter(SkWStream*);
+    virtual ~SkXMLStreamWriter();
+    virtual void    writeHeader();
+    SkDEBUGCODE(static void UnitTest();)
 protected:
-       virtual void onStartElementLen(const char elem[], size_t length);
-       virtual void onEndElement();
-       virtual void onAddAttributeLen(const char name[], const char value[], size_t length);
+    virtual void onStartElementLen(const char elem[], size_t length);
+    virtual void onEndElement();
+    virtual void onAddAttributeLen(const char name[], const char value[], size_t length);
 private:
-       SkWStream&              fStream;
+    SkWStream&      fStream;
 };
 
 class SkXMLParserWriter : public SkXMLWriter {
 public:
-       SkXMLParserWriter(SkXMLParser*);
-       virtual ~SkXMLParserWriter();
+    SkXMLParserWriter(SkXMLParser*);
+    virtual ~SkXMLParserWriter();
 protected:
-       virtual void onStartElementLen(const char elem[], size_t length);
-       virtual void onEndElement();
-       virtual void onAddAttributeLen(const char name[], const char value[], size_t length);
+    virtual void onStartElementLen(const char elem[], size_t length);
+    virtual void onEndElement();
+    virtual void onAddAttributeLen(const char name[], const char value[], size_t length);
 private:
-       SkXMLParser&            fParser;
+    SkXMLParser&        fParser;
 };
 
 
index 9a6faad..528bfb3 100644 (file)
@@ -1,24 +1,41 @@
+/* include/graphics/SkXfermode.h
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #ifndef SkXfermode_DEFINED
 #define SkXfermode_DEFINED
 
 #include "SkFlattenable.h"
 #include "SkColor.h"
 
-/**    \class SkXfermode
+/** \class SkXfermode
 
-       SkXfermode is the base class for objects that are called to implement custom
-       "transfer-modes" in the drawing pipeline. The static function Create(Modes)
-       can be called to return an instance of any of the predefined subclasses as
-       specified in the Modes enum. When an SkXfermode is assigned to an SkPaint, then
-       objects drawn with that paint have the xfermode applied.
+    SkXfermode is the base class for objects that are called to implement custom
+    "transfer-modes" in the drawing pipeline. The static function Create(Modes)
+    can be called to return an instance of any of the predefined subclasses as
+    specified in the Modes enum. When an SkXfermode is assigned to an SkPaint, then
+    objects drawn with that paint have the xfermode applied.
 */
 class SkXfermode : public SkFlattenable {
 public:
     SkXfermode() {}
 
-       virtual void xfer32(SkPMColor dst[], const SkPMColor src[], int count, const SkAlpha aa[]);
-       virtual void xfer16(uint16_t dst[], const SkPMColor src[], int count, const SkAlpha aa[]);
-       virtual void xferA8(SkAlpha dst[], const SkPMColor src[], int count, const SkAlpha aa[]);
+    virtual void xfer32(SkPMColor dst[], const SkPMColor src[], int count, const SkAlpha aa[]);
+    virtual void xfer16(uint16_t dst[], const SkPMColor src[], int count, const SkAlpha aa[]);
+    virtual void xferA8(SkAlpha dst[], const SkPMColor src[], int count, const SkAlpha aa[]);
     
 protected:
     SkXfermode(SkRBuffer&) {}
@@ -36,22 +53,22 @@ private:
 */
 class SkProcXfermode : public SkXfermode {
 public:
-       SkProcXfermode(SkXfermodeProc proc) : fProc(proc) {}
+    SkProcXfermode(SkXfermodeProc proc) : fProc(proc) {}
 
-       // overrides from SkXfermode
-       virtual void xfer32(SkPMColor dst[], const SkPMColor src[], int count, const SkAlpha aa[]);
-       virtual void xfer16(uint16_t dst[], const SkPMColor src[], int count, const SkAlpha aa[]);
-       virtual void xferA8(SkAlpha dst[], const SkPMColor src[], int count, const SkAlpha aa[]);
+    // overrides from SkXfermode
+    virtual void xfer32(SkPMColor dst[], const SkPMColor src[], int count, const SkAlpha aa[]);
+    virtual void xfer16(uint16_t dst[], const SkPMColor src[], int count, const SkAlpha aa[]);
+    virtual void xferA8(SkAlpha dst[], const SkPMColor src[], int count, const SkAlpha aa[]);
 
     // overrides from SkFlattenable
-       virtual Factory getFactory();
-       virtual void    flatten(SkWBuffer&);
+    virtual Factory getFactory();
+    virtual void    flatten(SkWBuffer&);
 
 protected:
     SkProcXfermode(SkRBuffer&);
 
 private:
-       SkXfermodeProc  fProc;
+    SkXfermodeProc  fProc;
     
     static SkFlattenable* CreateProc(SkRBuffer&);
 
index 2e78667..835178a 100644 (file)
@@ -9,6 +9,7 @@ LOCAL_SRC_FILES:= \
        SkDebug.cpp \
        SkDebug_stdio.cpp \
        SkFloat.cpp \
+       SkInterpolator.cpp \
        SkMath.cpp \
        SkMatrix.cpp \
        SkMemory_stdlib.cpp \
@@ -27,4 +28,10 @@ LOCAL_C_INCLUDES += \
 
 LOCAL_TARGET:= libcorecg
 
+LOCAL_CFLAGS += -fstrict-aliasing
+
+ifeq ($(DEVICE_ARCH),arm)
+       LOCAL_CFLAGS += -fomit-frame-pointer
+endif
+
 include $(BUILD_SHARED_LIBRARY)
index 3a557fb..f2d0655 100644 (file)
+/* libs/corecg/Sk64.cpp
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #include "Sk64.h"
 
-#define shift_left(hi, lo)                     \
-       hi = (hi << 1) | (lo >> 31);    \
-       lo <<= 1
+#define shift_left(hi, lo)          \
+    hi = (hi << 1) | (lo >> 31);    \
+    lo <<= 1
 
-#define shift_left_bits(hi, lo, bits)                  \
-       SkASSERT((unsigned)(bits) < 31);                                \
-       hi = (hi << (bits)) | (lo >> (32 - (bits)));    \
-       lo <<= (bits)
+#define shift_left_bits(hi, lo, bits)           \
+    SkASSERT((unsigned)(bits) < 31);                \
+    hi = (hi << (bits)) | (lo >> (32 - (bits)));    \
+    lo <<= (bits)
 
 //////////////////////////////////////////////////////////////////////
 
-int    Sk64::getClzAbs() const
+int Sk64::getClzAbs() const
 {
-       int32_t     hi = fHi;
-       uint32_t        lo = fLo;
-
-       // get abs
-       if (hi < 0)
-       {
-               hi = -hi - Sk32ToBool(lo);
-               lo = 0 - lo;
-       }
-       return hi ? SkCLZ(hi) : SkCLZ(lo) + 32;
+    int32_t     hi = fHi;
+    uint32_t    lo = fLo;
+
+    // get abs
+    if (hi < 0)
+    {
+        hi = -hi - Sk32ToBool(lo);
+        lo = 0 - lo;
+    }
+    return hi ? SkCLZ(hi) : SkCLZ(lo) + 32;
 }
 
 void Sk64::shiftLeft(unsigned bits)
 {
-       SkASSERT(bits <= 63);
-       if (bits == 0)
-               return;
-
-       if (bits >= 32)
-       {
-               fHi = fLo << (bits - 32);
-               fLo = 0;
-       }
-       else
-       {
-               fHi = (fHi << bits) | (fLo >> (32 - bits));
-               fLo <<= bits;
-       }
+    SkASSERT(bits <= 63);
+    if (bits == 0)
+        return;
+
+    if (bits >= 32)
+    {
+        fHi = fLo << (bits - 32);
+        fLo = 0;
+    }
+    else
+    {
+        fHi = (fHi << bits) | (fLo >> (32 - bits));
+        fLo <<= bits;
+    }
 }
 
 int32_t Sk64::getShiftRight(unsigned bits) const
 {
-       SkASSERT(bits <= 63);
+    SkASSERT(bits <= 63);
 
-       if (bits == 0)
-               return fLo;
+    if (bits == 0)
+        return fLo;
 
-       if (bits >= 32)
-               return fHi >> (bits - 32);
-       else
-       {
+    if (bits >= 32)
+        return fHi >> (bits - 32);
+    else
+    {
 #ifdef SK_DEBUG
-               int32_t tmp = fHi >> bits;
-               SkASSERT(tmp == 0 || tmp == -1);
+        int32_t tmp = fHi >> bits;
+        SkASSERT(tmp == 0 || tmp == -1);
 #endif
-               return (fHi << (32 - bits)) | (fLo >> bits);
-       }
+        return (fHi << (32 - bits)) | (fLo >> bits);
+    }
 }
 
 void Sk64::shiftRight(unsigned bits)
 {
-       SkASSERT(bits <= 63);
-       if (bits == 0)
-               return;
-
-       if (bits >= 32)
-       {
-               fLo = fHi >> (bits - 32);
-               fHi >>= 31;
-       }
-       else
-       {
-               fLo = (fHi << (32 - bits)) | (fLo >> bits);
-               fHi >>= bits;
-       }
+    SkASSERT(bits <= 63);
+    if (bits == 0)
+        return;
+
+    if (bits >= 32)
+    {
+        fLo = fHi >> (bits - 32);
+        fHi >>= 31;
+    }
+    else
+    {
+        fLo = (fHi << (32 - bits)) | (fLo >> bits);
+        fHi >>= bits;
+    }
 }
 
 void Sk64::roundRight(unsigned bits)
 {
-       SkASSERT(bits <= 63);
-       if (bits)
-       {
-               Sk64 one;
-               one.set(1);
-               one.shiftLeft(bits - 1);
-               this->add(one);
-               this->shiftRight(bits);
-       }
+    SkASSERT(bits <= 63);
+    if (bits)
+    {
+        Sk64 one;
+        one.set(1);
+        one.shiftLeft(bits - 1);
+        this->add(one);
+        this->shiftRight(bits);
+    }
 }
 
 int Sk64::shiftToMake32() const
 {
-       int32_t     hi = fHi;
-       uint32_t        lo = fLo;
-
-       if (hi < 0)     // make it positive
-       {
-               hi = -hi - Sk32ToBool(lo);
-               lo = 0 - lo;
-       }
-
-       if (hi == 0)
-               return lo >> 31;
-       else
-               return 33 - SkCLZ(hi);
+    int32_t     hi = fHi;
+    uint32_t    lo = fLo;
+
+    if (hi < 0) // make it positive
+    {
+        hi = -hi - Sk32ToBool(lo);
+        lo = 0 - lo;
+    }
+
+    if (hi == 0)
+        return lo >> 31;
+    else
+        return 33 - SkCLZ(hi);
 }
 
 void Sk64::negate()
 {
-       fHi = -fHi - Sk32ToBool(fLo);
-       fLo = 0 - fLo;
+    fHi = -fHi - Sk32ToBool(fLo);
+    fLo = 0 - fLo;
 }
 
 void Sk64::abs()
 {
-       if (fHi < 0)
-       {
-               fHi = -fHi - Sk32ToBool(fLo);
-               fLo = 0 - fLo;
-       }
+    if (fHi < 0)
+    {
+        fHi = -fHi - Sk32ToBool(fLo);
+        fLo = 0 - fLo;
+    }
 }
 
 ////////////////////////////////////////////////////////////////
 
 static inline int32_t round_right_16(int32_t hi, uint32_t lo)
 {
-       uint32_t sum = lo + (1 << 15);
-       hi += (sum < lo);
-       return (hi << 16) | (sum >> 16);
+    uint32_t sum = lo + (1 << 15);
+    hi += (sum < lo);
+    return (hi << 16) | (sum >> 16);
 }
 
 SkBool Sk64::isFixed() const
 {
-       Sk64 tmp = *this;
-       tmp.roundRight(16);
-       return tmp.is32();
+    Sk64 tmp = *this;
+    tmp.roundRight(16);
+    return tmp.is32();
 }
 
-SkFract        Sk64::getFract() const
+SkFract Sk64::getFract() const
 {
-       Sk64 tmp = *this;
-       tmp.roundRight(30);
-       return tmp.get32();
+    Sk64 tmp = *this;
+    tmp.roundRight(30);
+    return tmp.get32();
 }
 
 void Sk64::sub(const Sk64& a)
 {
-       fHi = fHi - a.fHi - (fLo < a.fLo);
-       fLo = fLo - a.fLo;
+    fHi = fHi - a.fHi - (fLo < a.fLo);
+    fLo = fLo - a.fLo;
 }
 
 void Sk64::rsub(const Sk64& a)
 {
-       fHi = a.fHi - fHi - (a.fLo < fLo);
-       fLo = a.fLo - fLo;
+    fHi = a.fHi - fHi - (a.fLo < fLo);
+    fLo = a.fLo - fLo;
 }
 
 void Sk64::setMul(int32_t a, int32_t b)
 {
-       int sa = a >> 31;
-       int sb = b >> 31;
-       // now make them positive
-       a = (a ^ sa) - sa;
-       b = (b ^ sb) - sb;
-
-       uint32_t        ah = a >> 16;
-       uint32_t        al = a & 0xFFFF;
-       uint32_t bh = b >> 16;
-       uint32_t bl = b & 0xFFFF;
-
-       uint32_t A = ah * bh;
-       uint32_t B = ah * bl + al * bh;
-       uint32_t C = al * bl;
-
-       /*      [  A  ]
-                  [  B  ]
-                     [  C  ]
-       */
-       fLo = C + (B << 16);
-       fHi = A + (B >>16) + (fLo < C);
-
-       if (sa != sb)
-               this->negate();
+    int sa = a >> 31;
+    int sb = b >> 31;
+    // now make them positive
+    a = (a ^ sa) - sa;
+    b = (b ^ sb) - sb;
+
+    uint32_t    ah = a >> 16;
+    uint32_t    al = a & 0xFFFF;
+    uint32_t bh = b >> 16;
+    uint32_t bl = b & 0xFFFF;
+
+    uint32_t A = ah * bh;
+    uint32_t B = ah * bl + al * bh;
+    uint32_t C = al * bl;
+
+    /*  [  A  ]
+           [  B  ]
+              [  C  ]
+    */
+    fLo = C + (B << 16);
+    fHi = A + (B >>16) + (fLo < C);
+
+    if (sa != sb)
+        this->negate();
 }
 
 void Sk64::div(int32_t denom, DivOptions option)
 {
-       SkASSERT(denom);
-
-       int32_t     hi = fHi;
-       uint32_t        lo = fLo;
-       int         sign = denom ^ hi;
-
-       denom = SkAbs32(denom);
-       if (hi < 0)
-       {
-               hi = -hi - Sk32ToBool(lo);
-               lo = 0 - lo;
-       }
-
-       if (option == kRound_DivOption) // add denom/2
-       {
-               uint32_t newLo = lo + (denom >> 1);
-               hi += (newLo < lo);
-               lo = newLo;
-       }
-
-       if (hi == 0)    // fast-case
-       {
-               if (lo < (uint32_t)denom)
-                       this->set(0, 0);
-               else
-               {
-                       this->set(0, lo / denom);
-                       if (sign < 0)
-                               this->negate();
-               }
-               return;
-       }
-
-       int     bits;
-
-       {
-               int dbits = SkCLZ(denom);
-               int nbits = SkCLZ(hi);
-
-               bits = 32 + dbits - nbits;
-               SkASSERT(bits <= 63);
-               if (bits <= 0)
-               {
-                       this->set(0, 0);
-                       return;
-               }
-               denom <<= (dbits - 1);
-               shift_left_bits(hi, lo, nbits - 1);
-       }
-
-       int32_t     rhi = 0;
-       uint32_t        rlo = 0;
-
-       do {
-               shift_left(rhi, rlo);
+    SkASSERT(denom);
+
+    int32_t     hi = fHi;
+    uint32_t    lo = fLo;
+    int         sign = denom ^ hi;
+
+    denom = SkAbs32(denom);
+    if (hi < 0)
+    {
+        hi = -hi - Sk32ToBool(lo);
+        lo = 0 - lo;
+    }
+
+    if (option == kRound_DivOption) // add denom/2
+    {
+        uint32_t newLo = lo + (denom >> 1);
+        hi += (newLo < lo);
+        lo = newLo;
+    }
+
+    if (hi == 0)    // fast-case
+    {
+        if (lo < (uint32_t)denom)
+            this->set(0, 0);
+        else
+        {
+            this->set(0, lo / denom);
+            if (sign < 0)
+                this->negate();
+        }
+        return;
+    }
+
+    int bits;
+
+    {
+        int dbits = SkCLZ(denom);
+        int nbits = SkCLZ(hi);
+
+        bits = 32 + dbits - nbits;
+        SkASSERT(bits <= 63);
+        if (bits <= 0)
+        {
+            this->set(0, 0);
+            return;
+        }
+        denom <<= (dbits - 1);
+        shift_left_bits(hi, lo, nbits - 1);
+    }
+
+    int32_t     rhi = 0;
+    uint32_t    rlo = 0;
+
+    do {
+        shift_left(rhi, rlo);
 #ifdef SK_CPU_HAS_CONDITIONAL_INSTR
-               if ((uint32_t)denom <= (uint32_t)hi)
-               {
-                       hi -= denom;
-                       rlo |= 1;
-               }
+        if ((uint32_t)denom <= (uint32_t)hi)
+        {
+            hi -= denom;
+            rlo |= 1;
+        }
 #else
-               int32_t diff = (denom - hi - 1) >> 31;
-               hi -= denom & diff;
-               rlo -= diff;
+        int32_t diff = (denom - hi - 1) >> 31;
+        hi -= denom & diff;
+        rlo -= diff;
 #endif
-               shift_left(hi, lo);
-       } while (--bits >= 0);
-       SkASSERT(rhi >= 0);
-
-       fHi = rhi;
-       fLo = rlo;
-       if (sign < 0)
-               this->negate();
+        shift_left(hi, lo);
+    } while (--bits >= 0);
+    SkASSERT(rhi >= 0);
+
+    fHi = rhi;
+    fLo = rlo;
+    if (sign < 0)
+        this->negate();
 }
 
-#define shift_left_2(a, b, c)  \
-       a = (a << 2) | (b >> 30);       \
-       b = (b << 2) | (c >> 30);       \
-       c <<= 2
+#define shift_left_2(a, b, c)   \
+    a = (a << 2) | (b >> 30);   \
+    b = (b << 2) | (c >> 30);   \
+    c <<= 2
 
 int32_t Sk64::getSqrt() const
 {
-       SkASSERT(!this->isNeg());
-
-       uint32_t        hi = fHi;
-       uint32_t lo = fLo;
-       uint32_t        sqr = 0;
-       uint32_t root = 0;
-       int     count = 31;
-
-       do {
-               root <<= 1;
-               shift_left_2(sqr, hi, lo);
-
-               uint32_t testDiv = (root << 1) + 1;
-               if (sqr >= testDiv)
-               {
-                       sqr -= testDiv;
-                       root++;
-               }
-       } while (--count >= 0);
-       SkASSERT((int32_t)root >= 0);
-
-       return root;
+    SkASSERT(!this->isNeg());
+
+    uint32_t    hi = fHi;
+    uint32_t lo = fLo;
+    uint32_t    sqr = 0;
+    uint32_t root = 0;
+    int count = 31;
+
+    do {
+        root <<= 1;
+        shift_left_2(sqr, hi, lo);
+
+        uint32_t testDiv = (root << 1) + 1;
+        if (sqr >= testDiv)
+        {
+            sqr -= testDiv;
+            root++;
+        }
+    } while (--count >= 0);
+    SkASSERT((int32_t)root >= 0);
+
+    return root;
 }
 
 #ifdef SK_CAN_USE_LONGLONG
-       SkLONGLONG Sk64::getLongLong() const
-       {
-               SkLONGLONG value = fHi;
-               value <<= 32;
-               return value | fLo;
-       }
+    SkLONGLONG Sk64::getLongLong() const
+    {
+        SkLONGLONG value = fHi;
+        value <<= 32;
+        return value | fLo;
+    }
 #endif
 
 SkFixed Sk64::getFixedDiv(const Sk64& denom) const
 {
-       Sk64    N = *this;
-       Sk64    D = denom;
-       int32_t sign = SkExtractSign(N.fHi ^ D.fHi);
-       SkFixed result;
-
-       N.abs();
-       D.abs();
-
-       // need to knock D down to just 31 bits
-       // either by rounding it to the right, or shifting N to the left
-       // then we can just call 64/32 div
-
-       int nclz = N.fHi ? SkCLZ(N.fHi) : 32;
-       int dclz = D.fHi ? SkCLZ(D.fHi) : (33 - (D.fLo >> 31));
-
-       int shiftN = nclz - 1;
-       SkASSERT(shiftN >= 0);
-       int     shiftD = 33 - dclz;
-       SkASSERT(shiftD >= 0);
-
-       if (shiftD + shiftN < 16)
-               shiftD = 16 - shiftN;
-       else
-               shiftN = 16 - shiftD;
-
-       D.roundRight(shiftD);
-       if (D.isZero())
-               result = SK_MaxS32;
-       else
-       {
-               if (shiftN >= 0)
-                       N.shiftLeft(shiftN);
-               else
-                       N.roundRight(-shiftN);
-               N.div(D.get32(), Sk64::kTrunc_DivOption);
-               if (N.is32())
-                       result = N.get32();
-               else
-                       result = SK_MaxS32;
-       }
-       return SkApplySign(result, sign);
+    Sk64    N = *this;
+    Sk64    D = denom;
+    int32_t sign = SkExtractSign(N.fHi ^ D.fHi);
+    SkFixed result;
+
+    N.abs();
+    D.abs();
+
+    // need to knock D down to just 31 bits
+    // either by rounding it to the right, or shifting N to the left
+    // then we can just call 64/32 div
+
+    int nclz = N.fHi ? SkCLZ(N.fHi) : 32;
+    int dclz = D.fHi ? SkCLZ(D.fHi) : (33 - (D.fLo >> 31));
+
+    int shiftN = nclz - 1;
+    SkASSERT(shiftN >= 0);
+    int shiftD = 33 - dclz;
+    SkASSERT(shiftD >= 0);
+
+    if (shiftD + shiftN < 16)
+        shiftD = 16 - shiftN;
+    else
+        shiftN = 16 - shiftD;
+
+    D.roundRight(shiftD);
+    if (D.isZero())
+        result = SK_MaxS32;
+    else
+    {
+        if (shiftN >= 0)
+            N.shiftLeft(shiftN);
+        else
+            N.roundRight(-shiftN);
+        N.div(D.get32(), Sk64::kTrunc_DivOption);
+        if (N.is32())
+            result = N.get32();
+        else
+            result = SK_MaxS32;
+    }
+    return SkApplySign(result, sign);
 }
 
 ///////////////////////////////////////////////////////////////////////
@@ -360,191 +377,191 @@ SkFixed Sk64::getFixedDiv(const Sk64& denom) const
 
 #ifdef SK_SUPPORT_UNITTEST
 struct BoolTable {
-       S8      zero, pos, neg, toBool, sign;
+    S8  zero, pos, neg, toBool, sign;
 };
 
 static void bool_table_test(const Sk64& a, const BoolTable& table)
 {
-       SkASSERT(a.isZero() != a.nonZero());
+    SkASSERT(a.isZero() != a.nonZero());
 
-       SkASSERT(!a.isZero() == !table.zero);
-       SkASSERT(!a.isPos() == !table.pos);
-       SkASSERT(!a.isNeg() == !table.neg);
-       SkASSERT(a.sign() == table.sign);
+    SkASSERT(!a.isZero() == !table.zero);
+    SkASSERT(!a.isPos() == !table.pos);
+    SkASSERT(!a.isNeg() == !table.neg);
+    SkASSERT(a.sign() == table.sign);
 }
 
 #ifdef SK_CAN_USE_LONGLONG
-       static SkLONGLONG asLL(const Sk64& a)
-       {
-               return ((SkLONGLONG)a.fHi << 32) | a.fLo;
-       }
+    static SkLONGLONG asLL(const Sk64& a)
+    {
+        return ((SkLONGLONG)a.fHi << 32) | a.fLo;
+    }
 #endif
 #endif
 
 void Sk64::UnitTest()
 {
 #ifdef SK_SUPPORT_UNITTEST
-       enum BoolTests {
-               kZero_BoolTest,
-               kPos_BoolTest,
-               kNeg_BoolTest
-       };
-       static const BoolTable gBoolTable[] = {
-               { 1, 0, 0, 0, 0 },
-               { 0, 1, 0, 1, 1 },
-               { 0, 0, 1, 1, -1 }
-       };
-
-       Sk64    a, b, c;
-
-       a.fHi = a.fLo = 0;
-       b.set(0);
-       c.setZero();
-       SkASSERT(a == b);
-       SkASSERT(a == c);
-       bool_table_test(a, gBoolTable[kZero_BoolTest]);
-
-       a.fHi = 0;      a.fLo = 5;
-       b.set(5);
-       SkASSERT(a == b);
-       SkASSERT(a.is32() && a.get32() == 5 && !a.is64());
-       bool_table_test(a, gBoolTable[kPos_BoolTest]);
-
-       a.fHi = -1;     a.fLo = (uint32_t)-5;
-       b.set(-5);
-       SkASSERT(a == b);
-       SkASSERT(a.is32() && a.get32() == -5 && !a.is64());
-       bool_table_test(a, gBoolTable[kNeg_BoolTest]);
-
-       a.setZero();
-       b.set(6);
-       c.set(-6);
-       SkASSERT(a != b && b != c && a != c);
-       SkASSERT(!(a == b) && !(a == b) && !(a == b));
-       SkASSERT(a < b && b > a && a <= b && b >= a);
-       SkASSERT(c < a && a > c && c <= a && a >= c);
-       SkASSERT(c < b && b > c && c <= b && b >= c);
-
-       // Now test add/sub
-
-       SkRandom        rand;
-       int                     i;
-
-       for (i = 0; i < 1000; i++)
-       {
-               int aa = rand.nextS() >> 1;
-               int bb = rand.nextS() >> 1;
-               a.set(aa);
-               b.set(bb);
-               SkASSERT(a.get32() == aa && b.get32() == bb);
-               c = a; c.add(bb);
-               SkASSERT(c.get32() == aa + bb);
-               c = a; c.add(-bb);
-               SkASSERT(c.get32() == aa - bb);
-               c = a; c.add(b);
-               SkASSERT(c.get32() == aa + bb);
-               c = a; c.sub(b);
-               SkASSERT(c.get32() == aa - bb);
-       }
+    enum BoolTests {
+        kZero_BoolTest,
+        kPos_BoolTest,
+        kNeg_BoolTest
+    };
+    static const BoolTable gBoolTable[] = {
+        { 1, 0, 0, 0, 0 },
+        { 0, 1, 0, 1, 1 },
+        { 0, 0, 1, 1, -1 }
+    };
+
+    Sk64    a, b, c;
+
+    a.fHi = a.fLo = 0;
+    b.set(0);
+    c.setZero();
+    SkASSERT(a == b);
+    SkASSERT(a == c);
+    bool_table_test(a, gBoolTable[kZero_BoolTest]);
+
+    a.fHi = 0;  a.fLo = 5;
+    b.set(5);
+    SkASSERT(a == b);
+    SkASSERT(a.is32() && a.get32() == 5 && !a.is64());
+    bool_table_test(a, gBoolTable[kPos_BoolTest]);
+
+    a.fHi = -1; a.fLo = (uint32_t)-5;
+    b.set(-5);
+    SkASSERT(a == b);
+    SkASSERT(a.is32() && a.get32() == -5 && !a.is64());
+    bool_table_test(a, gBoolTable[kNeg_BoolTest]);
+
+    a.setZero();
+    b.set(6);
+    c.set(-6);
+    SkASSERT(a != b && b != c && a != c);
+    SkASSERT(!(a == b) && !(a == b) && !(a == b));
+    SkASSERT(a < b && b > a && a <= b && b >= a);
+    SkASSERT(c < a && a > c && c <= a && a >= c);
+    SkASSERT(c < b && b > c && c <= b && b >= c);
+
+    // Now test add/sub
+
+    SkRandom    rand;
+    int         i;
+
+    for (i = 0; i < 1000; i++)
+    {
+        int aa = rand.nextS() >> 1;
+        int bb = rand.nextS() >> 1;
+        a.set(aa);
+        b.set(bb);
+        SkASSERT(a.get32() == aa && b.get32() == bb);
+        c = a; c.add(bb);
+        SkASSERT(c.get32() == aa + bb);
+        c = a; c.add(-bb);
+        SkASSERT(c.get32() == aa - bb);
+        c = a; c.add(b);
+        SkASSERT(c.get32() == aa + bb);
+        c = a; c.sub(b);
+        SkASSERT(c.get32() == aa - bb);
+    }
 
 #ifdef SK_CAN_USE_LONGLONG
-       for (i = 0; i < 1000; i++)
-       {
-               rand.next64(&a); //a.fHi >>= 1; // avoid overflow
-               rand.next64(&b); //b.fHi >>= 1; // avoid overflow
-
-               if (!(i & 3))   // want to explicitly test these cases
-               {
-                       a.fLo = 0;
-                       b.fLo = 0;
-               }
-               else if (!(i & 7))      // want to explicitly test these cases
-               {
-                       a.fHi = 0;
-                       b.fHi = 0;
-               }
-
-               SkLONGLONG aa = asLL(a);
-               SkLONGLONG bb = asLL(b);
-
-               SkASSERT((a < b) == (aa < bb));
-               SkASSERT((a <= b) == (aa <= bb));
-               SkASSERT((a > b) == (aa > bb));
-               SkASSERT((a >= b) == (aa >= bb));
-               SkASSERT((a == b) == (aa == bb));
-               SkASSERT((a != b) == (aa != bb));
-
-               c = a; c.add(b);
-               SkASSERT(asLL(c) == aa + bb);
-               c = a; c.sub(b);
-               SkASSERT(asLL(c) == aa - bb);
-               c = a; c.rsub(b);
-               SkASSERT(asLL(c) == bb - aa);
-               c = a; c.negate();
-               SkASSERT(asLL(c) == -aa);
-
-               int bits = rand.nextU() & 63;
-               c = a; c.shiftLeft(bits);
-               SkASSERT(asLL(c) == (aa << bits));
-               c = a; c.shiftRight(bits);
-               SkASSERT(asLL(c) == (aa >> bits));
-               c = a; c.roundRight(bits);
-
-               SkLONGLONG tmp;
-
-               tmp = aa;
-               if (bits > 0)
-                       tmp += (SkLONGLONG)1 << (bits - 1);
-               SkASSERT(asLL(c) == (tmp >> bits));
-
-               c.setMul(a.fHi, b.fHi);
-               tmp = (SkLONGLONG)a.fHi * b.fHi;
-               SkASSERT(asLL(c) == tmp);
-       }
-
-
-       for (i = 0; i < 100000; i++)
-       {
-               Sk64    wide;
-               int32_t denom = rand.nextS();
-
-               while (denom == 0)
-                       denom = rand.nextS();
-               wide.setMul(rand.nextS(), rand.nextS());
-               SkLONGLONG check = wide.getLongLong();
-
-               wide.div(denom, Sk64::kTrunc_DivOption);
-               check /= denom;
-               SkLONGLONG w = wide.getLongLong();
-
-               SkASSERT(check == w);
+    for (i = 0; i < 1000; i++)
+    {
+        rand.next64(&a); //a.fHi >>= 1; // avoid overflow
+        rand.next64(&b); //b.fHi >>= 1; // avoid overflow
+
+        if (!(i & 3))   // want to explicitly test these cases
+        {
+            a.fLo = 0;
+            b.fLo = 0;
+        }
+        else if (!(i & 7))  // want to explicitly test these cases
+        {
+            a.fHi = 0;
+            b.fHi = 0;
+        }
+
+        SkLONGLONG aa = asLL(a);
+        SkLONGLONG bb = asLL(b);
+
+        SkASSERT((a < b) == (aa < bb));
+        SkASSERT((a <= b) == (aa <= bb));
+        SkASSERT((a > b) == (aa > bb));
+        SkASSERT((a >= b) == (aa >= bb));
+        SkASSERT((a == b) == (aa == bb));
+        SkASSERT((a != b) == (aa != bb));
+
+        c = a; c.add(b);
+        SkASSERT(asLL(c) == aa + bb);
+        c = a; c.sub(b);
+        SkASSERT(asLL(c) == aa - bb);
+        c = a; c.rsub(b);
+        SkASSERT(asLL(c) == bb - aa);
+        c = a; c.negate();
+        SkASSERT(asLL(c) == -aa);
+
+        int bits = rand.nextU() & 63;
+        c = a; c.shiftLeft(bits);
+        SkASSERT(asLL(c) == (aa << bits));
+        c = a; c.shiftRight(bits);
+        SkASSERT(asLL(c) == (aa >> bits));
+        c = a; c.roundRight(bits);
+
+        SkLONGLONG tmp;
+
+        tmp = aa;
+        if (bits > 0)
+            tmp += (SkLONGLONG)1 << (bits - 1);
+        SkASSERT(asLL(c) == (tmp >> bits));
+
+        c.setMul(a.fHi, b.fHi);
+        tmp = (SkLONGLONG)a.fHi * b.fHi;
+        SkASSERT(asLL(c) == tmp);
+    }
+
+
+    for (i = 0; i < 100000; i++)
+    {
+        Sk64    wide;
+        int32_t denom = rand.nextS();
+
+        while (denom == 0)
+            denom = rand.nextS();
+        wide.setMul(rand.nextS(), rand.nextS());
+        SkLONGLONG check = wide.getLongLong();
+
+        wide.div(denom, Sk64::kTrunc_DivOption);
+        check /= denom;
+        SkLONGLONG w = wide.getLongLong();
+
+        SkASSERT(check == w);
 
 #ifdef SK_CAN_USE_FLOAT
-               wide.setMul(rand.nextS(), rand.nextS());
-               wide.abs();
-               denom = wide.getSqrt();
-               int32_t ck = (int32_t)sqrt((double)wide.getLongLong());
-               int     diff = denom - ck;
-               SkASSERT(SkAbs32(diff) <= 1);
-
-               wide.setMul(rand.nextS(), rand.nextS());
-               Sk64    dwide;
-               dwide.setMul(rand.nextS(), rand.nextS());
-               SkFixed fixdiv = wide.getFixedDiv(dwide);
-               double dnumer = (double)wide.getLongLong();
-               double ddenom = (double)dwide.getLongLong();
-               double ddiv = dnumer / ddenom;
-               SkFixed dfixdiv;
-               if (ddiv >= (double)SK_MaxS32 / (double)SK_Fixed1)
-                       dfixdiv = SK_MaxS32;
-               else if (ddiv <= -(double)SK_MaxS32 / (double)SK_Fixed1)
-                       dfixdiv = SK_MinS32;
-               else
-                       dfixdiv = SkFloatToFixed(dnumer / ddenom);
-               diff = fixdiv - dfixdiv;
-               SkASSERT(SkAbs32(diff) <= 1);
+        wide.setMul(rand.nextS(), rand.nextS());
+        wide.abs();
+        denom = wide.getSqrt();
+        int32_t ck = (int32_t)sqrt((double)wide.getLongLong());
+        int diff = denom - ck;
+        SkASSERT(SkAbs32(diff) <= 1);
+
+        wide.setMul(rand.nextS(), rand.nextS());
+        Sk64    dwide;
+        dwide.setMul(rand.nextS(), rand.nextS());
+        SkFixed fixdiv = wide.getFixedDiv(dwide);
+        double dnumer = (double)wide.getLongLong();
+        double ddenom = (double)dwide.getLongLong();
+        double ddiv = dnumer / ddenom;
+        SkFixed dfixdiv;
+        if (ddiv >= (double)SK_MaxS32 / (double)SK_Fixed1)
+            dfixdiv = SK_MaxS32;
+        else if (ddiv <= -(double)SK_MaxS32 / (double)SK_Fixed1)
+            dfixdiv = SK_MinS32;
+        else
+            dfixdiv = SkFloatToFixed(dnumer / ddenom);
+        diff = fixdiv - dfixdiv;
+        SkASSERT(SkAbs32(diff) <= 1);
 #endif
-       }
+    }
 #endif
 #endif
 }
index 8f4792f..a4e5f67 100644 (file)
@@ -1,3 +1,20 @@
+/* libs/corecg/SkBuffer.cpp
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #include "SkBuffer.h"
 
 ////////////////////////////////////////////////////////////////////////////////////////
@@ -45,62 +62,62 @@ size_t SkWBuffer::padToAlign4()
 
 #if 0
 #ifdef SK_DEBUG
-       static void AssertBuffer32(const void* buffer)
-       {
-               SkASSERT(buffer);
-               SkASSERT(((size_t)buffer & 3) == 0);
-       }
+    static void AssertBuffer32(const void* buffer)
+    {
+        SkASSERT(buffer);
+        SkASSERT(((size_t)buffer & 3) == 0);
+    }
 #else
-       #define AssertBuffer32(buffer)
+    #define AssertBuffer32(buffer)
 #endif
 
 void* sk_buffer_write_int32(void* buffer, int32_t value)
 {
-       AssertBuffer32(buffer);
-       *(int32_t*)buffer = value;
-       return (char*)buffer + sizeof(int32_t);
+    AssertBuffer32(buffer);
+    *(int32_t*)buffer = value;
+    return (char*)buffer + sizeof(int32_t);
 }
 
 void* sk_buffer_write_int32(void* buffer, const int32_t values[], int count)
 {
-       AssertBuffer32(buffer);
-       SkASSERT(count >= 0);
+    AssertBuffer32(buffer);
+    SkASSERT(count >= 0);
 
-       memcpy((int32_t*)buffer, values, count * sizeof(int32_t));
-       return (char*)buffer + count * sizeof(int32_t);
+    memcpy((int32_t*)buffer, values, count * sizeof(int32_t));
+    return (char*)buffer + count * sizeof(int32_t);
 }
 
-const void*    sk_buffer_read_int32(const void* buffer, int32_t* value)
+const void* sk_buffer_read_int32(const void* buffer, int32_t* value)
 {
-       AssertBuffer32(buffer);
-       if (value)
-               *value = *(const int32_t*)buffer;
-       return (const char*)buffer + sizeof(int32_t);
+    AssertBuffer32(buffer);
+    if (value)
+        *value = *(const int32_t*)buffer;
+    return (const char*)buffer + sizeof(int32_t);
 }
 
-const void*    sk_buffer_read_int32(const void* buffer, int32_t values[], int count)
+const void* sk_buffer_read_int32(const void* buffer, int32_t values[], int count)
 {
-       AssertBuffer32(buffer);
-       SkASSERT(count >= 0);
+    AssertBuffer32(buffer);
+    SkASSERT(count >= 0);
 
-       if (values)
-               memcpy(values, (const int32_t*)buffer, count * sizeof(int32_t));
-       return (const char*)buffer + count * sizeof(int32_t);
+    if (values)
+        memcpy(values, (const int32_t*)buffer, count * sizeof(int32_t));
+    return (const char*)buffer + count * sizeof(int32_t);
 }
 
 void* sk_buffer_write_ptr(void* buffer, void* ptr)
 {
-       AssertBuffer32(buffer);
-       *(void**)buffer = ptr;
-       return (char*)buffer + sizeof(void*);
+    AssertBuffer32(buffer);
+    *(void**)buffer = ptr;
+    return (char*)buffer + sizeof(void*);
 }
 
-const void*    sk_buffer_read_ptr(const void* buffer, void** ptr)
+const void* sk_buffer_read_ptr(const void* buffer, void** ptr)
 {
-       AssertBuffer32(buffer);
-       if (ptr)
-               *ptr = *(void**)buffer;
-       return (const char*)buffer + sizeof(void*);
+    AssertBuffer32(buffer);
+    if (ptr)
+        *ptr = *(void**)buffer;
+    return (const char*)buffer + sizeof(void*);
 }
 
 #endif
index cfeccc0..4b8bafa 100644 (file)
@@ -1,45 +1,62 @@
+/* libs/corecg/SkChunkAlloc.cpp
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #include "SkChunkAlloc.h"
 
 SkChunkAlloc::~SkChunkAlloc()
 {
-       this->reset();
+    this->reset();
 }
 
 void SkChunkAlloc::reset()
 {
-       Block* block = fBlock;
-
-       while (block)
-       {
-               Block* next = block->fNext;
-               sk_free(block);
-               block = next;
-       }
-       fBlock = nil;
+    Block* block = fBlock;
+
+    while (block)
+    {
+        Block* next = block->fNext;
+        sk_free(block);
+        block = next;
+    }
+    fBlock = nil;
 }
 
 void* SkChunkAlloc::alloc(size_t bytes, AllocFailType ftype)
 {
-       bytes = SkAlign4(bytes);
-
-       if (fBlock == nil || bytes > fBlock->fFreeSize)
-       {
-               size_t  size = SkMax32((S32)bytes, (S32)fMinSize);
-               Block*  block = (Block*)sk_malloc_flags(sizeof(Block) + size, ftype == kThrow_AllocFailType ? SK_MALLOC_THROW : 0);
-               if (block == nil)
-                       return nil;
-
-               block->fNext = fBlock;
-               block->fFreeSize = size;
-               block->fFreePtr = (char*)block + sizeof(Block);
-               fBlock = block;
-       }
-
-       SkASSERT(fBlock && bytes <= fBlock->fFreeSize);
-       void* ptr = fBlock->fFreePtr;
-
-       fBlock->fFreeSize -= bytes;
-       fBlock->fFreePtr += bytes;
-       return ptr;
+    bytes = SkAlign4(bytes);
+
+    if (fBlock == nil || bytes > fBlock->fFreeSize)
+    {
+        size_t  size = SkMax32((S32)bytes, (S32)fMinSize);
+        Block*  block = (Block*)sk_malloc_flags(sizeof(Block) + size, ftype == kThrow_AllocFailType ? SK_MALLOC_THROW : 0);
+        if (block == nil)
+            return nil;
+
+        block->fNext = fBlock;
+        block->fFreeSize = size;
+        block->fFreePtr = (char*)block + sizeof(Block);
+        fBlock = block;
+    }
+
+    SkASSERT(fBlock && bytes <= fBlock->fFreeSize);
+    void* ptr = fBlock->fFreePtr;
+
+    fBlock->fFreeSize -= bytes;
+    fBlock->fFreePtr += bytes;
+    return ptr;
 }
 
index 32266e9..622a381 100644 (file)
@@ -1,36 +1,53 @@
+/* libs/corecg/SkCordic.cpp
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #include "SkCordic.h"
 #include "SkMath.h"
 #include "Sk64.h"
 
 // 0x20000000 equals pi / 4
 const int32_t kATanDegrees[] = { 0x20000000,
-       0x12E4051D, 0x9FB385B, 0x51111D4, 0x28B0D43, 0x145D7E1, 0xA2F61E, 0x517C55,
-       0x28BE53, 0x145F2E, 0xA2F98, 0x517CC, 0x28BE6, 0x145F3, 0xA2F9, 0x517C,
-       0x28BE, 0x145F, 0xA2F, 0x517, 0x28B, 0x145, 0xA2, 0x51, 0x28, 0x14,
-       0xA, 0x5, 0x2, 0x1 };
+    0x12E4051D, 0x9FB385B, 0x51111D4, 0x28B0D43, 0x145D7E1, 0xA2F61E, 0x517C55,
+    0x28BE53, 0x145F2E, 0xA2F98, 0x517CC, 0x28BE6, 0x145F3, 0xA2F9, 0x517C,
+    0x28BE, 0x145F, 0xA2F, 0x517, 0x28B, 0x145, 0xA2, 0x51, 0x28, 0x14,
+    0xA, 0x5, 0x2, 0x1 };
 
-const int32_t kFixedInvGain1 = 0x18bde0bb;     // 0.607252935
+const int32_t kFixedInvGain1 = 0x18bde0bb;  // 0.607252935
 
 static void SkCircularRotation(int32_t* x0, int32_t* y0, int32_t* z0) 
 {
-       int32_t t = 0;
-       int32_t x = *x0;
-       int32_t y = *y0;
-       int32_t z = *z0;
-       const int32_t* tanPtr = kATanDegrees;
+    int32_t t = 0;
+    int32_t x = *x0;
+    int32_t y = *y0;
+    int32_t z = *z0;
+    const int32_t* tanPtr = kATanDegrees;
    do {
         int32_t x1 = y >> t;
-               int32_t y1 = x >> t;
-               int32_t tan = *tanPtr++;        
-               if (z >= 0) {
-                       x -= x1;
-                       y += y1;
-                       z -= tan;
-               } else {
-                       x += x1;
-                       y -= y1;
-                       z += tan;
-               }
+        int32_t y1 = x >> t;
+        int32_t tan = *tanPtr++;    
+        if (z >= 0) {
+            x -= x1;
+            y += y1;
+            z -= tan;
+        } else {
+            x += x1;
+            y -= y1;
+            z += tan;
+        }
    } while (++t < 16); // 30);
     *x0 = x;
     *y0 = y;
@@ -39,151 +56,151 @@ static void SkCircularRotation(int32_t* x0, int32_t* y0, int32_t* z0)
 
 SkFixed SkCordicSinCos(SkFixed radians, SkFixed* cosp)
 {
-       int32_t scaledRadians = radians * 0x28be;       // scale radians to 65536 / PI()
-       int quadrant = scaledRadians >> 30;
-       quadrant += 1;
-       if (quadrant & 2) 
-               scaledRadians = -scaledRadians + 0x80000000;
+    int32_t scaledRadians = radians * 0x28be;   // scale radians to 65536 / PI()
+    int quadrant = scaledRadians >> 30;
+    quadrant += 1;
+    if (quadrant & 2) 
+        scaledRadians = -scaledRadians + 0x80000000;
     /* |a| <= 90 degrees as a 1.31 number */
     SkFixed sin = 0;
     SkFixed cos = kFixedInvGain1;
     SkCircularRotation(&cos, &sin, &scaledRadians);
-       Sk64 scaled;
-       scaled.setMul(sin, 0x6488d);
-       sin = scaled.fHi;
-       scaled.setMul(cos, 0x6488d);
-       if (quadrant & 2)
-               scaled.fHi = - scaled.fHi;
-       *cosp = scaled.fHi;
+    Sk64 scaled;
+    scaled.setMul(sin, 0x6488d);
+    sin = scaled.fHi;
+    scaled.setMul(cos, 0x6488d);
+    if (quadrant & 2)
+        scaled.fHi = - scaled.fHi;
+    *cosp = scaled.fHi;
     return sin;
 }
 
 SkFixed SkCordicTan(SkFixed a) 
 {
-       int32_t cos;
-       int32_t sin = SkCordicSinCos(a, &cos);
-       return SkFixedDiv(sin, cos);
+    int32_t cos;
+    int32_t sin = SkCordicSinCos(a, &cos);
+    return SkFixedDiv(sin, cos);
 }
 
 static int32_t SkCircularVector(int32_t* y0, int32_t* x0, int32_t vecMode) 
 {
-       int32_t x = *x0;
-       int32_t y = *y0;
-       int32_t z = 0;
-       int32_t t = 0;
-       const int32_t* tanPtr = kATanDegrees;
+    int32_t x = *x0;
+    int32_t y = *y0;
+    int32_t z = 0;
+    int32_t t = 0;
+    const int32_t* tanPtr = kATanDegrees;
    do {
         int32_t x1 = y >> t;
-               int32_t y1 = x >> t;
-               int32_t tan = *tanPtr++;        
-               if (y < vecMode) {
-                       x -= x1;
-                       y += y1;
-                       z -= tan;
-               } else {
-                       x += x1;
-                       y -= y1;
-                       z += tan;
-               }
-   } while (++t < 16); // 30
-       Sk64 scaled;
-       scaled.setMul(z, 0x6488d); // scale back into the SkScalar space (0x100000000/0x28be)
+        int32_t y1 = x >> t;
+        int32_t tan = *tanPtr++;    
+        if (y < vecMode) {
+            x -= x1;
+            y += y1;
+            z -= tan;
+        } else {
+            x += x1;
+            y -= y1;
+            z += tan;
+        }
+   } while (++t < 16);  // 30
+    Sk64 scaled;
+    scaled.setMul(z, 0x6488d); // scale back into the SkScalar space (0x100000000/0x28be)
    return scaled.fHi;
 }
 
 SkFixed SkCordicASin(SkFixed a) {
-       int32_t sign = SkExtractSign(a);
-       int32_t z = SkFixedAbs(a);
-       if (z >= SK_Fixed1)
-               return SkApplySign(SK_FixedPI>>1, sign);
-       int32_t x = kFixedInvGain1;
-       int32_t y = 0;
-       z *= 0x28be;
-       z = SkCircularVector(&y, &x, z);
-       z = SkApplySign(z, ~sign);
-       return z;
+    int32_t sign = SkExtractSign(a);
+    int32_t z = SkFixedAbs(a);
+    if (z >= SK_Fixed1)
+        return SkApplySign(SK_FixedPI>>1, sign);
+    int32_t x = kFixedInvGain1;
+    int32_t y = 0;
+    z *= 0x28be;
+    z = SkCircularVector(&y, &x, z);
+    z = SkApplySign(z, ~sign);
+    return z;
 }
 
 SkFixed SkCordicACos(SkFixed a) {
-       int32_t z = SkCordicASin(a);
-       z = (SK_FixedPI>>1) - z;
-       return z;
+    int32_t z = SkCordicASin(a);
+    z = (SK_FixedPI>>1) - z;
+    return z;
 }
 
 SkFixed SkCordicATan2(SkFixed y, SkFixed x) {
-       if ((x | y) == 0)
-               return 0;
-       int32_t xsign = SkExtractSign(x);
-       x = SkFixedAbs(x);
-       int32_t result = SkCircularVector(&y, &x, 0);
-       if (xsign) {
-               int32_t rsign = SkExtractSign(result);
-               if (y == 0)
-                       rsign = 0;
-               SkFixed pi = SkApplySign(SK_FixedPI, rsign);
-               result = pi - result;
-       }
-       return result;
+    if ((x | y) == 0)
+        return 0;
+    int32_t xsign = SkExtractSign(x);
+    x = SkFixedAbs(x);
+    int32_t result = SkCircularVector(&y, &x, 0);
+    if (xsign) {
+        int32_t rsign = SkExtractSign(result);
+        if (y == 0)
+            rsign = 0;
+        SkFixed pi = SkApplySign(SK_FixedPI, rsign);
+        result = pi - result;
+    }
+    return result;
 }
 
 const int32_t kATanHDegrees[] = { 
-       0x1661788D, 0xA680D61, 0x51EA6FC, 0x28CBFDD, 0x1460E34,
-       0xA2FCE8, 0x517D2E, 0x28BE6E, 0x145F32,
-       0xA2F98, 0x517CC, 0x28BE6, 0x145F3, 0xA2F9, 0x517C,
-       0x28BE, 0x145F, 0xA2F, 0x517, 0x28B, 0x145, 0xA2, 0x51, 0x28, 0x14,
-       0xA, 0x5, 0x2, 0x1 };
+    0x1661788D, 0xA680D61, 0x51EA6FC, 0x28CBFDD, 0x1460E34,
+    0xA2FCE8, 0x517D2E, 0x28BE6E, 0x145F32,
+    0xA2F98, 0x517CC, 0x28BE6, 0x145F3, 0xA2F9, 0x517C,
+    0x28BE, 0x145F, 0xA2F, 0x517, 0x28B, 0x145, 0xA2, 0x51, 0x28, 0x14,
+    0xA, 0x5, 0x2, 0x1 };
 
-const int32_t kFixedInvGain2 = 0x31330AAA;     // 1.207534495
+const int32_t kFixedInvGain2 = 0x31330AAA;  // 1.207534495
 
 static void SkHyperbolic(int32_t* x0, int32_t* y0, int32_t* z0, int mode) 
 {
-       int32_t t = 1;
-       int32_t x = *x0;
-       int32_t y = *y0;
-       int32_t z = *z0;
-       const int32_t* tanPtr = kATanHDegrees;
+    int32_t t = 1;
+    int32_t x = *x0;
+    int32_t y = *y0;
+    int32_t z = *z0;
+    const int32_t* tanPtr = kATanHDegrees;
     int k = -3;
-       do {
+    do {
         int32_t x1 = y >> t;
-               int32_t y1 = x >> t;
-               int32_t tan = *tanPtr++;        
-               int count = 2 + (k >> 31);
-               if (++k == 1)
-                       k = -2;
+        int32_t y1 = x >> t;
+        int32_t tan = *tanPtr++;    
+        int count = 2 + (k >> 31);
+        if (++k == 1)
+            k = -2;
         do {
-                       if ((y >> 31) & mode | ~((z >> 31) | mode)) {
-                               x += x1;
-                               y += y1;
-                               z -= tan;
-                       } else {
-                               x -= x1;
-                               y -= y1;
-                               z += tan;
-                       }
-               } while (--count);
-       } while (++t < 30);
+            if ((y >> 31) & mode | ~((z >> 31) | mode)) {
+                x += x1;
+                y += y1;
+                z -= tan;
+            } else {
+                x -= x1;
+                y -= y1;
+                z += tan;
+            }
+        } while (--count);
+    } while (++t < 30);
     *x0 = x;
     *y0 = y;
     *z0 = z;
 }
 
 SkFixed SkCordicLog(SkFixed a) {
-       a *= 0x28be;
-       int32_t x = a + 0x28BE60DB;     // 1.0
-       int32_t y = a - 0x28BE60DB;
-       int32_t z = 0;
-       SkHyperbolic(&x, &y, &z, -1);
-       Sk64 scaled;
-       scaled.setMul(z, 0x6488d);
-       z = scaled.fHi;
-       return z << 1;
+    a *= 0x28be;
+    int32_t x = a + 0x28BE60DB; // 1.0
+    int32_t y = a - 0x28BE60DB;
+    int32_t z = 0;
+    SkHyperbolic(&x, &y, &z, -1);
+    Sk64 scaled;
+    scaled.setMul(z, 0x6488d);
+    z = scaled.fHi;
+    return z << 1;
 }
 
 SkFixed SkCordicExp(SkFixed a) {
-       int32_t cosh = kFixedInvGain2;
-       int32_t sinh = 0;
-       SkHyperbolic(&cosh, &sinh, &a, 0);
-       return cosh + sinh;
+    int32_t cosh = kFixedInvGain2;
+    int32_t sinh = 0;
+    SkHyperbolic(&cosh, &sinh, &a, 0);
+    return cosh + sinh;
 }
 
 #ifdef SK_DEBUG
@@ -196,88 +213,88 @@ void SkCordic_UnitTest()
 {
 #if defined(SK_SUPPORT_UNITTEST) && defined(SK_CAN_USE_FLOAT)
     float val;
-       for (float angle = -720; angle < 720; angle += 30) {
-               float radian = angle * 3.1415925358f / 180.0f;
-               SkFixed f_angle = (int) (radian * 65536.0f);
-       // sincos
-               float sine = sinf(radian);
-               float cosine = cosf(radian);
-               SkFixed f_cosine;
-               SkFixed f_sine = SkCordicSinCos(f_angle, &f_cosine);
-               float sine2 = (float) f_sine / 65536.0f;
-               float cosine2 = (float) f_cosine / 65536.0f;
-               float error = fabsf(sine - sine2);
-               if (error > 0.001)
-                       SkDebugf("sin error : angle = %g ; sin = %g ; cordic = %g\n", angle, sine, sine2);
-               error = fabsf(cosine - cosine2);
-               if (error > 0.001)
-                       SkDebugf("cos error : angle = %g ; cos = %g ; cordic = %g\n", angle, cosine, cosine2);
-       // tan
-               float _tan = tanf(radian);
-               SkFixed f_tan = SkCordicTan(f_angle);
-               float tan2 = (float) f_tan / 65536.0f;
-               error = fabsf(_tan - tan2);
-               if (error > 0.05 && fabsf(_tan) < 1e6)
-                       SkDebugf("tan error : angle = %g ; tan = %g ; cordic = %g\n", angle, _tan, tan2);
-       }
-       for (val = -1; val <= 1; val += .1f) {
-               SkFixed f_val = (int) (val * 65536.0f);
-       // asin
-               float arcsine = asinf(val);
-               SkFixed f_arcsine = SkCordicASin(f_val);
-               float arcsine2 = (float) f_arcsine / 65536.0f;
-               float error = fabsf(arcsine - arcsine2);
-               if (error > 0.001)
-                       SkDebugf("asin error : val = %g ; asin = %g ; cordic = %g\n", val, arcsine, arcsine2);
-       }
+    for (float angle = -720; angle < 720; angle += 30) {
+        float radian = angle * 3.1415925358f / 180.0f;
+        SkFixed f_angle = (int) (radian * 65536.0f);
+    // sincos
+        float sine = sinf(radian);
+        float cosine = cosf(radian);
+        SkFixed f_cosine;
+        SkFixed f_sine = SkCordicSinCos(f_angle, &f_cosine);
+        float sine2 = (float) f_sine / 65536.0f;
+        float cosine2 = (float) f_cosine / 65536.0f;
+        float error = fabsf(sine - sine2);
+        if (error > 0.001)
+            SkDebugf("sin error : angle = %g ; sin = %g ; cordic = %g\n", angle, sine, sine2);
+        error = fabsf(cosine - cosine2);
+        if (error > 0.001)
+            SkDebugf("cos error : angle = %g ; cos = %g ; cordic = %g\n", angle, cosine, cosine2);
+    // tan
+        float _tan = tanf(radian);
+        SkFixed f_tan = SkCordicTan(f_angle);
+        float tan2 = (float) f_tan / 65536.0f;
+        error = fabsf(_tan - tan2);
+        if (error > 0.05 && fabsf(_tan) < 1e6)
+            SkDebugf("tan error : angle = %g ; tan = %g ; cordic = %g\n", angle, _tan, tan2);
+    }
+    for (val = -1; val <= 1; val += .1f) {
+        SkFixed f_val = (int) (val * 65536.0f);
+    // asin
+        float arcsine = asinf(val);
+        SkFixed f_arcsine = SkCordicASin(f_val);
+        float arcsine2 = (float) f_arcsine / 65536.0f;
+        float error = fabsf(arcsine - arcsine2);
+        if (error > 0.001)
+            SkDebugf("asin error : val = %g ; asin = %g ; cordic = %g\n", val, arcsine, arcsine2);
+    }
 #if 1
-       for (val = -1; val <= 1; val += .1f) {
+    for (val = -1; val <= 1; val += .1f) {
 #else
-       val = .5; {
+    val = .5; {
 #endif
-               SkFixed f_val = (int) (val * 65536.0f);
-       // acos
-               float arccos = acosf(val);
-               SkFixed f_arccos = SkCordicACos(f_val);
-               float arccos2 = (float) f_arccos / 65536.0f;
-               float error = fabsf(arccos - arccos2);
-               if (error > 0.001)
-                       SkDebugf("acos error : val = %g ; acos = %g ; cordic = %g\n", val, arccos, arccos2);
-       }
-       // atan2
+        SkFixed f_val = (int) (val * 65536.0f);
+    // acos
+        float arccos = acosf(val);
+        SkFixed f_arccos = SkCordicACos(f_val);
+        float arccos2 = (float) f_arccos / 65536.0f;
+        float error = fabsf(arccos - arccos2);
+        if (error > 0.001)
+            SkDebugf("acos error : val = %g ; acos = %g ; cordic = %g\n", val, arccos, arccos2);
+    }
+    // atan2
 #if 1
-       for (val = -1000; val <= 1000; val += 500.f) {
-               for (float val2 = -1000; val2 <= 1000; val2 += 500.f) {
+    for (val = -1000; val <= 1000; val += 500.f) {
+        for (float val2 = -1000; val2 <= 1000; val2 += 500.f) {
 #else
-                       val = 0; {
-                       float val2 = -1000; {
+            val = 0; {
+            float val2 = -1000; {
 #endif
-                       SkFixed f_val = (int) (val * 65536.0f);
-                       SkFixed f_val2 = (int) (val2 * 65536.0f);
-                       float arctan = atan2f(val, val2);
-                       SkFixed f_arctan = SkCordicATan2(f_val, f_val2);
-                       float arctan2 = (float) f_arctan / 65536.0f;
-                       float error = fabsf(arctan - arctan2);
-                       if (error > 0.001)
-                               SkDebugf("atan2 error : val = %g ; val2 = %g ; atan2 = %g ; cordic = %g\n", val, val2, arctan, arctan2);
-               }
-       }
-       // log
+            SkFixed f_val = (int) (val * 65536.0f);
+            SkFixed f_val2 = (int) (val2 * 65536.0f);
+            float arctan = atan2f(val, val2);
+            SkFixed f_arctan = SkCordicATan2(f_val, f_val2);
+            float arctan2 = (float) f_arctan / 65536.0f;
+            float error = fabsf(arctan - arctan2);
+            if (error > 0.001)
+                SkDebugf("atan2 error : val = %g ; val2 = %g ; atan2 = %g ; cordic = %g\n", val, val2, arctan, arctan2);
+        }
+    }
+    // log
 #if 1
-       for (val = 0.125f; val <= 8.f; val *= 2.0f) {
+    for (val = 0.125f; val <= 8.f; val *= 2.0f) {
 #else
-       val = .5; {
+    val = .5; {
 #endif
-               SkFixed f_val = (int) (val * 65536.0f);
-       // acos
-               float log = logf(val);
-               SkFixed f_log = SkCordicLog(f_val);
-               float log2 = (float) f_log / 65536.0f;
-               float error = fabsf(log - log2);
-               if (error > 0.001)
-                       SkDebugf("log error : val = %g ; log = %g ; cordic = %g\n", val, log, log2);
-       }
-       // exp
+        SkFixed f_val = (int) (val * 65536.0f);
+    // acos
+        float log = logf(val);
+        SkFixed f_log = SkCordicLog(f_val);
+        float log2 = (float) f_log / 65536.0f;
+        float error = fabsf(log - log2);
+        if (error > 0.001)
+            SkDebugf("log error : val = %g ; log = %g ; cordic = %g\n", val, log, log2);
+    }
+    // exp
 #endif
 }
 
index 5d8dfe1..70c70b5 100644 (file)
@@ -1,3 +1,20 @@
+/* libs/corecg/SkCordic.h
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #ifndef SkCordic_DEFINED
 #define SkCordic_DEFINED
 
@@ -13,7 +30,7 @@ SkFixed SkCordicSinCos(SkFixed radians, SkFixed* cosp);
 SkFixed SkCordicTan(SkFixed a);
 
 #ifdef SK_DEBUG
-       void SkCordic_UnitTest();
+    void SkCordic_UnitTest();
 #endif
 
 #endif // SkCordic 
index 65c8910..5d5518d 100644 (file)
@@ -1,41 +1,58 @@
+/* libs/corecg/SkDebug.cpp
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #include "SkTypes.h"
 
 #ifdef SK_DEBUG
 
 int8_t SkToS8(long x)
 {
-       SkASSERT((int8_t)x == x);
-       return (int8_t)x;
+    SkASSERT((int8_t)x == x);
+    return (int8_t)x;
 }
 
 uint8_t SkToU8(size_t x)
 {
-       SkASSERT((uint8_t)x == x);
-       return (uint8_t)x;
+    SkASSERT((uint8_t)x == x);
+    return (uint8_t)x;
 }
 
 int16_t SkToS16(long x)
 {
-       SkASSERT((int16_t)x == x);
-       return (int16_t)x;
+    SkASSERT((int16_t)x == x);
+    return (int16_t)x;
 }
 
 uint16_t SkToU16(size_t x)
 {
-       SkASSERT((uint16_t)x == x);
-       return (uint16_t)x;
+    SkASSERT((uint16_t)x == x);
+    return (uint16_t)x;
 }
 
 int32_t SkToS32(long x)
 {
-       SkASSERT((int32_t)x == x);
-       return (int32_t)x;
+    SkASSERT((int32_t)x == x);
+    return (int32_t)x;
 }
 
 uint32_t SkToU32(size_t x)
 {
-       SkASSERT((uint32_t)x == x);
-       return (uint32_t)x;
+    SkASSERT((uint32_t)x == x);
+    return (uint32_t)x;
 }
 
 #endif
index 6a35857..d42e59c 100644 (file)
@@ -1,3 +1,20 @@
+/* libs/corecg/SkDebug_stdio.cpp
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #include "SkTypes.h"
 
 #if (defined(SK_BUILD_FOR_MAC) || defined(SK_BUILD_FOR_UNIX)) && defined(SK_DEBUG)
 
 void SkDebugf(const char format[], ...)
 {
-       static const size_t kBufferSize = 256;
+    static const size_t kBufferSize = 256;
 
-       char    buffer[kBufferSize + 1];
-       va_list args;
-       va_start(args, format);
-       vsnprintf(buffer, kBufferSize, format, args);
-       va_end(args);
-       fprintf(stderr, buffer);
+    char    buffer[kBufferSize + 1];
+    va_list args;
+    va_start(args, format);
+    vsnprintf(buffer, kBufferSize, format, args);
+    va_end(args);
+    fprintf(stderr, buffer);
 }
 
 #endif
index 8f1f23d..03fd96e 100644 (file)
@@ -1,3 +1,20 @@
+/* libs/corecg/SkFP.h
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #ifndef SkFP_DEFINED
 #define SkFP_DEFINED
 
 
 #ifdef SK_SCALAR_IS_FLOAT
 
-       typedef float SkFP;
-
-       #define SkIntToFloat(n)                 SkIntToScalar(n)
-       #define SkFloatRound(x)                 SkScalarRound(n)
-       #define SkFloatCeil(x)                  SkScalarCeil(n)
-       #define SkFloatFloor(x)                 SkScalarFloor(n)
-
-       #define SkFloatNeg(x)                   (-(x))
-       #define SkFloatAbs(x)                   SkScalarAbs(x)
-       #define SkFloatAdd(a, b)                ((a) + (b))
-       #define SkFloatSub(a, b)                ((a) - (b))
-       #define SkFloatMul(a, b)                ((a) * (b))
-       #define SkFloatMulInt(a, n)             ((a) * (n))
-       #define SkFloatDiv(a, b)                ((a) / (b))
-       #define SkFloatDivInt(a, n)             ((a) / (n))
-       #define SkFloatInvert(x)                SkScalarInvert(x)
-       #define SkFloatSqrt(x)                  SkScalarSqrt(x)
-       #define SkFloatCubeRoot(x)              pow(x, 1.0f/3)
-
-       #define SkFloatLT(a, b)                 ((a) < (b))
-       #define SkFloatLE(a, b)                 ((a) <= (b))
-       #define SkFloatGT(a, b)                 ((a) > (b))
-       #define SkFloatGE(a, b)                 ((a) >= (b))
-
-#else  // scalar is fixed
-
-       #include "SkFloat.h"
-
-       typedef S32     SkFP;
-
-       #define SkIntToFloat(n)                 SkFloat::SetShift(n, 0)
-       #define SkFloatRound(x)                 SkFloat::Round(x);
-       #define SkFloatCeil(x)                  SkFloat::Ceil();
-       #define SkFloatFloor(x)                 SkFloat::Floor();
-
-       #define SkScalarToFloat(n)              SkFloat::SetShift(n, -16)
-       #define SkFloatToScalar(n)              SkFloat::GetShift(n, -16)
-       #define SkFloatNeg(x)                   SkFloat::Neg(x)
-       #define SkFloatAbs(x)                   SkFloat::Abs(x)
-       #define SkFloatAdd(a, b)                SkFloat::Add(a, b)
-       #define SkFloatSub(a, b)                SkFloat::Add(a, SkFloat::Neg(b))
-       #define SkFloatMul(a, b)                SkFloat::Mul(a, b)
-       #define SkFloatMulInt(a, n)             SkFloat::MulInt(a, n)
-       #define SkFloatDiv(a, b)                SkFloat::Div(a, b)
-       #define SkFloatDivInt(a, n)             SkFloat::DivInt(a, n)
-       #define SkFloatInvert(x)                SkFloat::Invert(x)
-       #define SkFloatSqrt(x)                  SkFloat::Sqrt(x)
-       #define SkFloatCubeRoot(x)              SkFloat::CubeRoot(x)
-
-       #define SkFloatLT(a, b)                 (SkFloat::Cmp(a, b) < 0)
-       #define SkFloatLE(a, b)                 (SkFloat::Cmp(a, b) <= 0)
-       #define SkFloatGT(a, b)                 (SkFloat::Cmp(a, b) > 0)
-       #define SkFloatGE(a, b)                 (SkFloat::Cmp(a, b) >= 0)
+    typedef float SkFP;
+
+    #define SkIntToFloat(n)         SkIntToScalar(n)
+    #define SkFloatRound(x)         SkScalarRound(n)
+    #define SkFloatCeil(x)          SkScalarCeil(n)
+    #define SkFloatFloor(x)         SkScalarFloor(n)
+
+    #define SkFloatNeg(x)           (-(x))
+    #define SkFloatAbs(x)           SkScalarAbs(x)
+    #define SkFloatAdd(a, b)        ((a) + (b))
+    #define SkFloatSub(a, b)        ((a) - (b))
+    #define SkFloatMul(a, b)        ((a) * (b))
+    #define SkFloatMulInt(a, n)     ((a) * (n))
+    #define SkFloatDiv(a, b)        ((a) / (b))
+    #define SkFloatDivInt(a, n)     ((a) / (n))
+    #define SkFloatInvert(x)        SkScalarInvert(x)
+    #define SkFloatSqrt(x)          SkScalarSqrt(x)
+    #define SkFloatCubeRoot(x)      pow(x, 1.0f/3)
+
+    #define SkFloatLT(a, b)         ((a) < (b))
+    #define SkFloatLE(a, b)         ((a) <= (b))
+    #define SkFloatGT(a, b)         ((a) > (b))
+    #define SkFloatGE(a, b)         ((a) >= (b))
+
+#else   // scalar is fixed
+
+    #include "SkFloat.h"
+
+    typedef S32 SkFP;
+
+    #define SkIntToFloat(n)         SkFloat::SetShift(n, 0)
+    #define SkFloatRound(x)         SkFloat::Round(x);
+    #define SkFloatCeil(x)          SkFloat::Ceil();
+    #define SkFloatFloor(x)         SkFloat::Floor();
+
+    #define SkScalarToFloat(n)      SkFloat::SetShift(n, -16)
+    #define SkFloatToScalar(n)      SkFloat::GetShift(n, -16)
+    #define SkFloatNeg(x)           SkFloat::Neg(x)
+    #define SkFloatAbs(x)           SkFloat::Abs(x)
+    #define SkFloatAdd(a, b)        SkFloat::Add(a, b)
+    #define SkFloatSub(a, b)        SkFloat::Add(a, SkFloat::Neg(b))
+    #define SkFloatMul(a, b)        SkFloat::Mul(a, b)
+    #define SkFloatMulInt(a, n)     SkFloat::MulInt(a, n)
+    #define SkFloatDiv(a, b)        SkFloat::Div(a, b)
+    #define SkFloatDivInt(a, n)     SkFloat::DivInt(a, n)
+    #define SkFloatInvert(x)        SkFloat::Invert(x)
+    #define SkFloatSqrt(x)          SkFloat::Sqrt(x)
+    #define SkFloatCubeRoot(x)      SkFloat::CubeRoot(x)
+
+    #define SkFloatLT(a, b)         (SkFloat::Cmp(a, b) < 0)
+    #define SkFloatLE(a, b)         (SkFloat::Cmp(a, b) <= 0)
+    #define SkFloatGT(a, b)         (SkFloat::Cmp(a, b) > 0)
+    #define SkFloatGE(a, b)         (SkFloat::Cmp(a, b) >= 0)
 
 #endif
 
 #ifdef SK_DEBUG
-       void SkFP_UnitTest();
+    void SkFP_UnitTest();
 #endif
 
 #endif
index 044e982..a0e189b 100644 (file)
+/* libs/corecg/SkFloat.cpp
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #include "SkFloat.h"
 
-#define EXP_BIAS       (127+23)
+#define EXP_BIAS    (127+23)
 
 static int get_unsigned_exp(U32 packed)
 {
-       return (packed << 1 >> 24);
+    return (packed << 1 >> 24);
 }
 
 static unsigned get_unsigned_value(U32 packed)
 {
-       return (packed << 9 >> 9) | (1 << 23);
+    return (packed << 9 >> 9) | (1 << 23);
 }
 
 static int get_signed_value(S32 packed)
 {
-       return SkApplySign(get_unsigned_value(packed), SkExtractSign(packed));
+    return SkApplySign(get_unsigned_value(packed), SkExtractSign(packed));
 }
 
 /////////////////////////////////////////////////////////////////////////
 
 int SkFloat::GetShift(S32 packed, int shift)
 {
-       if (packed == 0)
-               return 0;
-
-       int     exp = get_unsigned_exp(packed) - EXP_BIAS - shift;
-       int value = get_unsigned_value(packed);
-
-       if (exp >= 0)
-       {
-               if (exp > 8)    // overflow
-                       value = SK_MaxS32;
-               else
-                       value <<= exp;
-       }
-       else
-       {
-               exp = -exp;
-               if (exp > 23)   // underflow
-                       value = 0;
-               else
-                       value >>= exp;
-       }
-       return SkApplySign(value, SkExtractSign(packed));
+    if (packed == 0)
+        return 0;
+
+    int exp = get_unsigned_exp(packed) - EXP_BIAS - shift;
+    int value = get_unsigned_value(packed);
+
+    if (exp >= 0)
+    {
+        if (exp > 8)    // overflow
+            value = SK_MaxS32;
+        else
+            value <<= exp;
+    }
+    else
+    {
+        exp = -exp;
+        if (exp > 23)   // underflow
+            value = 0;
+        else
+            value >>= exp;
+    }
+    return SkApplySign(value, SkExtractSign(packed));
 }
 
 /////////////////////////////////////////////////////////////////////////////////////
 
 S32 SkFloat::SetShift(int value, int shift)
 {
-       if (value == 0)
-               return 0;
-
-       // record the sign and make value positive
-       int     sign = SkExtractSign(value);
-       value = SkApplySign(value, sign);
-
-       if (value >> 24)        // value is too big (has more than 24 bits set)
-       {
-               int bias = 8 - SkCLZ(value);
-               SkASSERT(bias > 0 && bias < 8);
-               value >>= bias;
-               shift += bias;
-       }
-       else
-       {
-               int zeros = SkCLZ(value << 8);
-               SkASSERT(zeros >= 0 && zeros <= 23);
-               value <<= zeros;
-               shift -= zeros;
-       }
-       // now value is left-aligned to 24 bits
-       SkASSERT((value >> 23) == 1);
-
-       shift += EXP_BIAS;
-       if (shift < 0)  // underflow
-               return 0;
-       else
-       {
-               if (shift > 255)        // overflow
-               {
-                       shift = 255;
-                       value = 0x00FFFFFF;
-               }
-               S32 packed = sign << 31;                // set the sign-bit
-               packed |= shift << 23;                  // store the packed exponent
-               packed |= ((unsigned)(value << 9) >> 9);        // clear 24th bit of value (its implied)
+    if (value == 0)
+        return 0;
+
+    // record the sign and make value positive
+    int sign = SkExtractSign(value);
+    value = SkApplySign(value, sign);
+
+    if (value >> 24)    // value is too big (has more than 24 bits set)
+    {
+        int bias = 8 - SkCLZ(value);
+        SkASSERT(bias > 0 && bias < 8);
+        value >>= bias;
+        shift += bias;
+    }
+    else
+    {
+        int zeros = SkCLZ(value << 8);
+        SkASSERT(zeros >= 0 && zeros <= 23);
+        value <<= zeros;
+        shift -= zeros;
+    }
+    // now value is left-aligned to 24 bits
+    SkASSERT((value >> 23) == 1);
+
+    shift += EXP_BIAS;
+    if (shift < 0)  // underflow
+        return 0;
+    else
+    {
+        if (shift > 255)    // overflow
+        {
+            shift = 255;
+            value = 0x00FFFFFF;
+        }
+        S32 packed = sign << 31;        // set the sign-bit
+        packed |= shift << 23;          // store the packed exponent
+        packed |= ((unsigned)(value << 9) >> 9);    // clear 24th bit of value (its implied)
 
 #ifdef SK_DEBUG
-               {
-                       int     n;
-
-                       n = SkExtractSign(packed);
-                       SkASSERT(n == sign);
-                       n = get_unsigned_exp(packed);
-                       SkASSERT(n == shift);
-                       n = get_unsigned_value(packed);
-                       SkASSERT(n == value);
-               }
+        {
+            int n;
+
+            n = SkExtractSign(packed);
+            SkASSERT(n == sign);
+            n = get_unsigned_exp(packed);
+            SkASSERT(n == shift);
+            n = get_unsigned_value(packed);
+            SkASSERT(n == value);
+        }
 #endif
-               return packed;
-       }
+        return packed;
+    }
 }
 
 S32 SkFloat::Neg(S32 packed)
 {
-       if (packed)
-               packed = packed ^ (1 << 31);
-       return packed;
+    if (packed)
+        packed = packed ^ (1 << 31);
+    return packed;
 }
 
 S32 SkFloat::Add(S32 packed_a, S32 packed_b)
 {
-       if (packed_a == 0)
-               return packed_b;
-       if (packed_b == 0)
-               return packed_a;
-
-       int     exp_a = get_unsigned_exp(packed_a);
-       int     exp_b = get_unsigned_exp(packed_b);
-       int exp_diff = exp_a - exp_b;
-
-       int     shift_a = 0, shift_b = 0;
-       int     exp;
-
-       if (exp_diff >= 0)
-       {
-               if (exp_diff > 24)      // B is too small to contribute
-                       return packed_a;
-               shift_b = exp_diff;
-               exp = exp_a;
-       }
-       else
-       {
-               exp_diff = -exp_diff;
-               if (exp_diff > 24)      // A is too small to contribute
-                       return packed_b;
-               shift_a = exp_diff;
-               exp = exp_b;
-       }
-
-       int     value_a = get_signed_value(packed_a) >> shift_a;
-       int value_b = get_signed_value(packed_b) >> shift_b;
-
-       return SkFloat::SetShift(value_a + value_b, exp - EXP_BIAS);
+    if (packed_a == 0)
+        return packed_b;
+    if (packed_b == 0)
+        return packed_a;
+
+    int exp_a = get_unsigned_exp(packed_a);
+    int exp_b = get_unsigned_exp(packed_b);
+    int exp_diff = exp_a - exp_b;
+
+    int shift_a = 0, shift_b = 0;
+    int exp;
+
+    if (exp_diff >= 0)
+    {
+        if (exp_diff > 24)  // B is too small to contribute
+            return packed_a;
+        shift_b = exp_diff;
+        exp = exp_a;
+    }
+    else
+    {
+        exp_diff = -exp_diff;
+        if (exp_diff > 24)  // A is too small to contribute
+            return packed_b;
+        shift_a = exp_diff;
+        exp = exp_b;
+    }
+
+    int value_a = get_signed_value(packed_a) >> shift_a;
+    int value_b = get_signed_value(packed_b) >> shift_b;
+
+    return SkFloat::SetShift(value_a + value_b, exp - EXP_BIAS);
 }
 
 #include "Sk64.h"
 
 static inline S32 mul24(S32 a, S32 b)
 {
-       Sk64 tmp;
+    Sk64 tmp;
 
-       tmp.setMul(a, b);
-       tmp.roundRight(24);
-       return tmp.get32();
+    tmp.setMul(a, b);
+    tmp.roundRight(24);
+    return tmp.get32();
 }
 
 S32 SkFloat::Mul(S32 packed_a, S32 packed_b)
 {
-       if (packed_a == 0 || packed_b == 0)
-               return 0;
+    if (packed_a == 0 || packed_b == 0)
+        return 0;
 
-       int     exp_a = get_unsigned_exp(packed_a);
-       int     exp_b = get_unsigned_exp(packed_b);
+    int exp_a = get_unsigned_exp(packed_a);
+    int exp_b = get_unsigned_exp(packed_b);
 
-       int     value_a = get_signed_value(packed_a);
-       int value_b = get_signed_value(packed_b);
+    int value_a = get_signed_value(packed_a);
+    int value_b = get_signed_value(packed_b);
 
-       return SkFloat::SetShift(mul24(value_a, value_b), exp_a + exp_b - 2*EXP_BIAS + 24);
+    return SkFloat::SetShift(mul24(value_a, value_b), exp_a + exp_b - 2*EXP_BIAS + 24);
 }
 
 S32 SkFloat::MulInt(S32 packed, int n)
 {
-       return Mul(packed, SetShift(n, 0));
+    return Mul(packed, SetShift(n, 0));
 }
 
 S32 SkFloat::Div(S32 packed_n, S32 packed_d)
 {
-       SkASSERT(packed_d != 0);
+    SkASSERT(packed_d != 0);
 
-       if (packed_n == 0)
-               return 0;
+    if (packed_n == 0)
+        return 0;
 
-       int     exp_n = get_unsigned_exp(packed_n);
-       int     exp_d = get_unsigned_exp(packed_d);
+    int exp_n = get_unsigned_exp(packed_n);
+    int exp_d = get_unsigned_exp(packed_d);
 
-       int     value_n = get_signed_value(packed_n);
-       int value_d = get_signed_value(packed_d);
+    int value_n = get_signed_value(packed_n);
+    int value_d = get_signed_value(packed_d);
 
-       return SkFloat::SetShift(SkDivBits(value_n, value_d, 24), exp_n - exp_d - 24);
+    return SkFloat::SetShift(SkDivBits(value_n, value_d, 24), exp_n - exp_d - 24);
 }
 
 S32 SkFloat::DivInt(S32 packed, int n)
 {
-       return Div(packed, SetShift(n, 0));
+    return Div(packed, SetShift(n, 0));
 }
 
 S32 SkFloat::Invert(S32 packed)
 {
-       return Div(packed, SetShift(1, 0));
+    return Div(packed, SetShift(1, 0));
 }
 
 S32 SkFloat::Sqrt(S32 packed)
 {
-       if (packed < 0)
-       {
-               SkASSERT(!"can't sqrt a negative number");
-               return 0;
-       }
-
-       int     exp = get_unsigned_exp(packed);
-       int     value = get_unsigned_value(packed);
-
-       int nexp = exp - EXP_BIAS;
-       int root = SkSqrtBits(value << (nexp & 1), 26);
-       nexp >>= 1;
-       return SkFloat::SetShift(root, nexp - 11);
+    if (packed < 0)
+    {
+        SkASSERT(!"can't sqrt a negative number");
+        return 0;
+    }
+
+    int exp = get_unsigned_exp(packed);
+    int value = get_unsigned_value(packed);
+
+    int nexp = exp - EXP_BIAS;
+    int root = SkSqrtBits(value << (nexp & 1), 26);
+    nexp >>= 1;
+    return SkFloat::SetShift(root, nexp - 11);
 }
 
-#if defined _WIN32 && _MSC_VER >= 1300 // disable warning : unreachable code
+#if defined _WIN32 && _MSC_VER >= 1300  // disable warning : unreachable code
 #pragma warning ( push )
 #pragma warning ( disable : 4702 )
 #endif
 
 S32 SkFloat::CubeRoot(S32 packed)
 {
-       sk_throw();
-       return 0;
+    sk_throw();
+    return 0;
 }
 
 #if defined _WIN32 && _MSC_VER >= 1300
@@ -236,20 +253,20 @@ S32 SkFloat::CubeRoot(S32 packed)
 
 static inline S32 clear_high_bit(S32 n)
 {
-       return ((U32)(n << 1)) >> 1;
+    return ((U32)(n << 1)) >> 1;
 }
 
 static inline int int_sign(S32 a, S32 b)
 {
-       return a > b ? 1 : (a < b ? -1 : 0);
+    return a > b ? 1 : (a < b ? -1 : 0);
 }
 
 int SkFloat::Cmp(S32 packed_a, S32 packed_b)
 {
-       packed_a = SkApplySign(clear_high_bit(packed_a), SkExtractSign(packed_a));
-       packed_b = SkApplySign(clear_high_bit(packed_b), SkExtractSign(packed_b));
+    packed_a = SkApplySign(clear_high_bit(packed_a), SkExtractSign(packed_a));
+    packed_b = SkApplySign(clear_high_bit(packed_b), SkExtractSign(packed_b));
 
-       return int_sign(packed_a, packed_b);
+    return int_sign(packed_a, packed_b);
 }
 
 /////////////////////////////////////////////////////////////////////////////////////
@@ -265,121 +282,121 @@ int SkFloat::Cmp(S32 packed_a, S32 packed_b)
 void SkFloat::UnitTest()
 {
 #ifdef SK_SUPPORT_UNITTEST
-       SkFloat a, b, c, d;
-       int             n;
+    SkFloat a, b, c, d;
+    int     n;
 
-       a.setZero();
-       n = a.getInt();
-       SkASSERT(n == 0);
+    a.setZero();
+    n = a.getInt();
+    SkASSERT(n == 0);
 
-       b.setInt(5);
-       n = b.getInt();
-       SkASSERT(n == 5);
+    b.setInt(5);
+    n = b.getInt();
+    SkASSERT(n == 5);
 
-       c.setInt(-3);
-       n = c.getInt();
-       SkASSERT(n == -3);
+    c.setInt(-3);
+    n = c.getInt();
+    SkASSERT(n == -3);
 
-       d.setAdd(c, b);
-       SkDebugf("SkFloat: %d + %d = %d\n", c.getInt(), b.getInt(), d.getInt());        
+    d.setAdd(c, b);
+    SkDebugf("SkFloat: %d + %d = %d\n", c.getInt(), b.getInt(), d.getInt());    
 
-       SkRandom        rand;
+    SkRandom    rand;
 
 #ifdef SK_CAN_USE_FLOAT
-       int i;
-       for (i = 0; i < 1000; i++)
-       {
-               float fa, fb;
-               int     aa = rand.nextS() >> 14;
-               int bb = rand.nextS() >> 14;
-               a.setInt(aa);
-               b.setInt(bb);
-               SkASSERT(a.getInt() == aa);
-               SkASSERT(b.getInt() == bb);
-
-               c.setAdd(a, b);
-               int     cc = c.getInt();
-               SkASSERT(cc == aa + bb);
-
-               c.setSub(a, b);
-               cc = c.getInt();
-               SkASSERT(cc == aa - bb);
-
-               aa >>= 5;
-               bb >>= 5;
-               a.setInt(aa);
-               b.setInt(bb);
-               c.setMul(a, b);
-               cc = c.getInt();
-               SkASSERT(cc == aa * bb);
-               /////////////////////////////////////
-
-               aa = rand.nextS() >> 11;
-               a.setFixed(aa);
-               cc = a.getFixed();
-               SkASSERT(aa == cc);
-
-               bb = rand.nextS() >> 11;
-               b.setFixed(bb);
-               cc = b.getFixed();
-               SkASSERT(bb == cc);
-
-               cc = SkFixedMul(aa, bb);
-               c.setMul(a, b);
-               SkFixed dd = c.getFixed();
-               int diff = cc - dd;
-               SkASSERT(SkAbs32(diff) <= 1);
-
-               fa = (float)aa / 65536.0f;
-               fb = (float)bb / 65536.0f;
-               a.assertEquals(fa);
-               b.assertEquals(fb);
-               fa = a.getFloat();
-               fb = b.getFloat();
-
-               c.assertEquals(fa * fb, 1);
-
-               c.setDiv(a, b);
-               cc = SkFixedDiv(aa, bb);
-               dd = c.getFixed();
-               diff = cc - dd;
-               SkASSERT(SkAbs32(diff) <= 3);
-
-               c.assertEquals(fa / fb, 1);
-
-               SkASSERT((aa == bb) == (a == b));
-               SkASSERT((aa != bb) == (a != b));
-               SkASSERT((aa < bb) == (a < b));
-               SkASSERT((aa <= bb) == (a <= b));
-               SkASSERT((aa > bb) == (a > b));
-               SkASSERT((aa >= bb) == (a >= b));
-
-               if (aa < 0)
-               {
-                       aa = -aa;
-                       fa = -fa;
-               }
-               a.setFixed(aa);
-               c.setSqrt(a);
-               cc = SkFixedSqrt(aa);
-               dd = c.getFixed();
-               SkASSERT(dd == cc);
-
-               c.assertEquals(sk_float_sqrt(fa), 2);
-
-               // cuberoot
+    int i;
+    for (i = 0; i < 1000; i++)
+    {
+        float fa, fb;
+        int aa = rand.nextS() >> 14;
+        int bb = rand.nextS() >> 14;
+        a.setInt(aa);
+        b.setInt(bb);
+        SkASSERT(a.getInt() == aa);
+        SkASSERT(b.getInt() == bb);
+
+        c.setAdd(a, b);
+        int cc = c.getInt();
+        SkASSERT(cc == aa + bb);
+
+        c.setSub(a, b);
+        cc = c.getInt();
+        SkASSERT(cc == aa - bb);
+
+        aa >>= 5;
+        bb >>= 5;
+        a.setInt(aa);
+        b.setInt(bb);
+        c.setMul(a, b);
+        cc = c.getInt();
+        SkASSERT(cc == aa * bb);
+        /////////////////////////////////////
+
+        aa = rand.nextS() >> 11;
+        a.setFixed(aa);
+        cc = a.getFixed();
+        SkASSERT(aa == cc);
+
+        bb = rand.nextS() >> 11;
+        b.setFixed(bb);
+        cc = b.getFixed();
+        SkASSERT(bb == cc);
+
+        cc = SkFixedMul(aa, bb);
+        c.setMul(a, b);
+        SkFixed dd = c.getFixed();
+        int diff = cc - dd;
+        SkASSERT(SkAbs32(diff) <= 1);
+
+        fa = (float)aa / 65536.0f;
+        fb = (float)bb / 65536.0f;
+        a.assertEquals(fa);
+        b.assertEquals(fb);
+        fa = a.getFloat();
+        fb = b.getFloat();
+
+        c.assertEquals(fa * fb, 1);
+
+        c.setDiv(a, b);
+        cc = SkFixedDiv(aa, bb);
+        dd = c.getFixed();
+        diff = cc - dd;
+        SkASSERT(SkAbs32(diff) <= 3);
+
+        c.assertEquals(fa / fb, 1);
+
+        SkASSERT((aa == bb) == (a == b));
+        SkASSERT((aa != bb) == (a != b));
+        SkASSERT((aa < bb) == (a < b));
+        SkASSERT((aa <= bb) == (a <= b));
+        SkASSERT((aa > bb) == (a > b));
+        SkASSERT((aa >= bb) == (a >= b));
+
+        if (aa < 0)
+        {
+            aa = -aa;
+            fa = -fa;
+        }
+        a.setFixed(aa);
+        c.setSqrt(a);
+        cc = SkFixedSqrt(aa);
+        dd = c.getFixed();
+        SkASSERT(dd == cc);
+
+        c.assertEquals(sk_float_sqrt(fa), 2);
+
+        // cuberoot
 #if 0
-               a.setInt(1);
-               a.cubeRoot();
-               a.assertEquals(1.0f, 0);
-               a.setInt(8);
-               a.cubeRoot();
-               a.assertEquals(2.0f, 0);
-               a.setInt(27);
-               a.cubeRoot();
-               a.assertEquals(3.0f, 0);
+        a.setInt(1);
+        a.cubeRoot();
+        a.assertEquals(1.0f, 0);
+        a.setInt(8);
+        a.cubeRoot();
+        a.assertEquals(2.0f, 0);
+        a.setInt(27);
+        a.cubeRoot();
+        a.assertEquals(3.0f, 0);
 #endif
-       }
+    }
 #endif
 #endif
 }
index 6ff252d..0e09ed0 100644 (file)
@@ -1,3 +1,20 @@
+/* libs/corecg/SkFloat.h
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #ifndef SkFloat_DEFINED
 #define SkFloat_DEFINED
 
 
 class SkFloat {
 public:
-                       SkFloat() {}
+            SkFloat() {}
 
-       void    setZero() { fPacked = 0; }
-//     void    setShift(int value, int shift) { fPacked = SetShift(value, shift); }
-       void    setInt(int value) { fPacked = SetShift(value, 0); }
-       void    setFixed(SkFixed value) { fPacked = SetShift(value, -16); }
-       void    setFract(SkFract value) { fPacked = SetShift(value, -30); }
+    void    setZero() { fPacked = 0; }
+//  void    setShift(int value, int shift) { fPacked = SetShift(value, shift); }
+    void    setInt(int value) { fPacked = SetShift(value, 0); }
+    void    setFixed(SkFixed value) { fPacked = SetShift(value, -16); }
+    void    setFract(SkFract value) { fPacked = SetShift(value, -30); }
 
-//     int             getShift(int shift) const { return GetShift(fPacked, shift); }
-       int             getInt() const { return GetShift(fPacked, 0); }
-       SkFixed getFixed() const { return GetShift(fPacked, -16); }
-       SkFract getFract() const { return GetShift(fPacked, -30); }
+//  int     getShift(int shift) const { return GetShift(fPacked, shift); }
+    int     getInt() const { return GetShift(fPacked, 0); }
+    SkFixed getFixed() const { return GetShift(fPacked, -16); }
+    SkFract getFract() const { return GetShift(fPacked, -30); }
 
-       void    abs() { fPacked = Abs(fPacked); }
-       void    negate() { fPacked = Neg(fPacked); }
+    void    abs() { fPacked = Abs(fPacked); }
+    void    negate() { fPacked = Neg(fPacked); }
 
-       void    shiftLeft(int bits) { fPacked = Shift(fPacked, bits); }
-       void    setShiftLeft(const SkFloat& a, int bits) { fPacked = Shift(a.fPacked, bits); }
+    void    shiftLeft(int bits) { fPacked = Shift(fPacked, bits); }
+    void    setShiftLeft(const SkFloat& a, int bits) { fPacked = Shift(a.fPacked, bits); }
 
-       void    shiftRight(int bits) { fPacked = Shift(fPacked, -bits); }
-       void    setShiftRight(const SkFloat& a, int bits) { fPacked = Shift(a.fPacked, -bits); }
+    void    shiftRight(int bits) { fPacked = Shift(fPacked, -bits); }
+    void    setShiftRight(const SkFloat& a, int bits) { fPacked = Shift(a.fPacked, -bits); }
 
-       void    add(const SkFloat& a) { fPacked = Add(fPacked, a.fPacked); }
-       void    setAdd(const SkFloat& a, const SkFloat& b) { fPacked = Add(a.fPacked, b.fPacked); }
+    void    add(const SkFloat& a) { fPacked = Add(fPacked, a.fPacked); }
+    void    setAdd(const SkFloat& a, const SkFloat& b) { fPacked = Add(a.fPacked, b.fPacked); }
 
-       void    sub(const SkFloat& a) { fPacked = Add(fPacked, Neg(a.fPacked)); }
-       void    setSub(const SkFloat& a, const SkFloat& b) { fPacked = Add(a.fPacked, Neg(b.fPacked)); }
+    void    sub(const SkFloat& a) { fPacked = Add(fPacked, Neg(a.fPacked)); }
+    void    setSub(const SkFloat& a, const SkFloat& b) { fPacked = Add(a.fPacked, Neg(b.fPacked)); }
 
-       void    mul(const SkFloat& a) { fPacked = Mul(fPacked, a.fPacked); }
-       void    setMul(const SkFloat& a, const SkFloat& b) { fPacked = Mul(a.fPacked, b.fPacked); }
+    void    mul(const SkFloat& a) { fPacked = Mul(fPacked, a.fPacked); }
+    void    setMul(const SkFloat& a, const SkFloat& b) { fPacked = Mul(a.fPacked, b.fPacked); }
 
-       void    div(const SkFloat& a) { fPacked = Div(fPacked, a.fPacked); }
-       void    setDiv(const SkFloat& a, const SkFloat& b) { fPacked = Div(a.fPacked, b.fPacked); }
+    void    div(const SkFloat& a) { fPacked = Div(fPacked, a.fPacked); }
+    void    setDiv(const SkFloat& a, const SkFloat& b) { fPacked = Div(a.fPacked, b.fPacked); }
 
-       void    sqrt() { fPacked = Sqrt(fPacked); }
-       void    setSqrt(const SkFloat& a) { fPacked = Sqrt(a.fPacked); }
-       void    cubeRoot() { fPacked = CubeRoot(fPacked); }
-       void    setCubeRoot(const SkFloat& a) { fPacked = CubeRoot(a.fPacked); }
+    void    sqrt() { fPacked = Sqrt(fPacked); }
+    void    setSqrt(const SkFloat& a) { fPacked = Sqrt(a.fPacked); }
+    void    cubeRoot() { fPacked = CubeRoot(fPacked); }
+    void    setCubeRoot(const SkFloat& a) { fPacked = CubeRoot(a.fPacked); }
 
-       friend bool operator==(const SkFloat& a, const SkFloat& b) { return a.fPacked == b.fPacked; }
-       friend bool operator!=(const SkFloat& a, const SkFloat& b) { return a.fPacked != b.fPacked; }
-       friend bool operator<(const SkFloat& a, const SkFloat& b) { return Cmp(a.fPacked, b.fPacked) < 0; }
-       friend bool operator<=(const SkFloat& a, const SkFloat& b) { return Cmp(a.fPacked, b.fPacked) <= 0; }
-       friend bool operator>(const SkFloat& a, const SkFloat& b) { return Cmp(a.fPacked, b.fPacked) > 0; }
-       friend bool operator>=(const SkFloat& a, const SkFloat& b) { return Cmp(a.fPacked, b.fPacked) >= 0; }
+    friend bool operator==(const SkFloat& a, const SkFloat& b) { return a.fPacked == b.fPacked; }
+    friend bool operator!=(const SkFloat& a, const SkFloat& b) { return a.fPacked != b.fPacked; }
+    friend bool operator<(const SkFloat& a, const SkFloat& b) { return Cmp(a.fPacked, b.fPacked) < 0; }
+    friend bool operator<=(const SkFloat& a, const SkFloat& b) { return Cmp(a.fPacked, b.fPacked) <= 0; }
+    friend bool operator>(const SkFloat& a, const SkFloat& b) { return Cmp(a.fPacked, b.fPacked) > 0; }
+    friend bool operator>=(const SkFloat& a, const SkFloat& b) { return Cmp(a.fPacked, b.fPacked) >= 0; }
 
 #ifdef SK_DEBUG
-       static void UnitTest();
-
-       void assertEquals(float f, int tolerance = 0)
-       {
-               S32     s = *(S32*)&f;
-               int d = s - fPacked;
-               SkASSERT(SkAbs32(d) <= tolerance);
-       }
-       float getFloat() const
-       {
-               return *(float*)&fPacked;
-       }
+    static void UnitTest();
+
+    void assertEquals(float f, int tolerance = 0)
+    {
+        S32 s = *(S32*)&f;
+        int d = s - fPacked;
+        SkASSERT(SkAbs32(d) <= tolerance);
+    }
+    float getFloat() const
+    {
+        return *(float*)&fPacked;
+    }
 #endif
 
 private:
-       S32     fPacked;
+    S32 fPacked;
 
-       SkFloat(S32 packed) : fPacked(fPacked) {}
+    SkFloat(S32 packed) : fPacked(fPacked) {}
 
 public:
-       static int GetShift(S32 packed, int shift);
-       static S32 SetShift(int value, int shift);
-       static S32 Neg(S32);
-       static S32 Abs(S32 packed) { return (U32)(packed << 1) >> 1; }
-       static S32 Shift(S32, int bits);
-       static S32 Add(S32, S32);
-       static S32 Mul(S32, S32);
-       static S32 MulInt(S32, int);
-       static S32 Div(S32, S32);
-       static S32 DivInt(S32, int);
-       static S32 Invert(S32);
-       static S32 Sqrt(S32);
-       static S32 CubeRoot(S32);
-       static int Cmp(S32, S32);
+    static int GetShift(S32 packed, int shift);
+    static S32 SetShift(int value, int shift);
+    static S32 Neg(S32);
+    static S32 Abs(S32 packed) { return (U32)(packed << 1) >> 1; }
+    static S32 Shift(S32, int bits);
+    static S32 Add(S32, S32);
+    static S32 Mul(S32, S32);
+    static S32 MulInt(S32, int);
+    static S32 Div(S32, S32);
+    static S32 DivInt(S32, int);
+    static S32 Invert(S32);
+    static S32 Sqrt(S32);
+    static S32 CubeRoot(S32);
+    static int Cmp(S32, S32);
 };
 
 #endif
diff --git a/libs/corecg/SkInterpolator.cpp b/libs/corecg/SkInterpolator.cpp
new file mode 100644 (file)
index 0000000..90e538d
--- /dev/null
@@ -0,0 +1,343 @@
+/* libs/corecg/SkInterpolator.cpp
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
+#include "SkInterpolator.h"
+#include "SkTSearch.h"
+
+SkInterpolatorBase::SkInterpolatorBase()
+{
+    fStorage    = NULL;
+    fTimes      = NULL;
+    SkDEBUGCODE(fTimesArray = NULL;)
+}
+
+SkInterpolatorBase::~SkInterpolatorBase()
+{
+    if (fStorage)
+        sk_free(fStorage);
+}
+
+void SkInterpolatorBase::reset(int elemCount, int frameCount)
+{
+    fFlags = 0;
+    fElemCount = SkToU8(elemCount);
+    fFrameCount = SkToS16(frameCount);
+    fRepeat = SK_Scalar1;
+    if (fStorage) {
+        sk_free(fStorage);
+        fStorage = NULL;
+        fTimes = NULL;
+        SkDEBUGCODE(fTimesArray = NULL);
+    }
+}
+
+/*  Each value[] run is formated as:
+        <time (in msec)>
+        <blend>
+        <data[fElemCount]>
+
+    Totaling fElemCount+2 entries per keyframe
+*/
+
+bool SkInterpolatorBase::getDuration(SkMSec* startTime, SkMSec* endTime) const
+{
+    if (fFrameCount == 0)
+        return false;
+
+    if (startTime)
+        *startTime = fTimes[0].fTime;
+    if (endTime)
+        *endTime = fTimes[fFrameCount - 1].fTime;
+    return true;
+}
+
+SkScalar SkInterpolatorBase::ComputeRelativeT(SkMSec time, SkMSec prevTime, SkMSec nextTime,
+                                              const SkScalar blend[4])
+{
+    SkASSERT(time > prevTime && time < nextTime);
+
+    SkScalar    t = SkScalarDiv((SkScalar)(time - prevTime), (SkScalar)(nextTime - prevTime));
+    return blend ? SkUnitCubicInterp(t, blend[0], blend[1], blend[2], blend[3]) : t;
+}
+
+SkInterpolatorBase::Result SkInterpolatorBase::timeToT(SkMSec time, SkScalar* T, int* indexPtr, SkBool* exactPtr) const
+{
+    SkASSERT(fFrameCount > 0);
+    Result  result = kNormal_Result;
+    if (fRepeat != SK_Scalar1)
+    {
+        SkMSec startTime, endTime;
+        this->getDuration(&startTime, &endTime);
+        SkMSec totalTime = endTime - startTime;
+        SkMSec offsetTime = time - startTime;
+        endTime = SkScalarMulFloor(fRepeat, totalTime);
+        if (offsetTime >= endTime)
+        {
+            SkScalar fraction = SkScalarFraction(fRepeat);
+            offsetTime = fraction == 0 && fRepeat > 0 ? totalTime :
+                SkScalarMulFloor(fraction, totalTime);
+            result = kFreezeEnd_Result;
+        }
+        else
+        {
+            int mirror = fFlags & kMirror;
+            offsetTime = offsetTime % (totalTime << mirror);
+            if (offsetTime > totalTime) // can only be true if fMirror is true
+                offsetTime = (totalTime << 1) - offsetTime;
+        }
+        time = offsetTime + startTime;
+    }
+
+    int index = SkTSearch<SkMSec>(&fTimes[0].fTime, fFrameCount, time, sizeof(SkTimeCode));
+
+    bool    exact = true;
+
+    if (index < 0)
+    {
+        index = ~index;
+        if (index == 0)
+            result = kFreezeStart_Result;
+        else if (index == fFrameCount)
+        {
+            if (fFlags & kReset)
+                index = 0;
+            else
+                index -= 1;
+            result = kFreezeEnd_Result;
+        }
+        else
+            exact = false;
+    }
+    SkASSERT(index < fFrameCount);
+    const SkTimeCode* nextTime = &fTimes[index];
+    SkMSec   nextT = nextTime[0].fTime;
+    if (exact)
+        *T = 0;
+    else {
+        SkMSec prevT = nextTime[-1].fTime;
+        *T = ComputeRelativeT(time, prevT, nextT, nextTime[-1].fBlend);
+    }
+    *indexPtr = index;
+    *exactPtr = exact;
+    return result;
+}
+
+
+SkInterpolator::SkInterpolator() {
+    INHERITED::reset(0, 0);
+    fValues = NULL;
+    SkDEBUGCODE(fScalarsArray = NULL;)
+}
+
+SkInterpolator::SkInterpolator(int elemCount, int frameCount)
+{
+    SkASSERT(elemCount > 0);
+    this->reset(elemCount, frameCount);
+}
+
+void SkInterpolator::reset(int elemCount, int frameCount) {
+    INHERITED::reset(elemCount, frameCount);
+    fStorage = sk_malloc_throw((sizeof(SkScalar) * elemCount + sizeof(SkTimeCode)) * frameCount);
+    fTimes = (SkTimeCode*) fStorage;
+    fValues = (SkScalar*) ((char*) fStorage + sizeof(SkTimeCode) * frameCount);
+#ifdef SK_DEBUG
+    fTimesArray = (SkTimeCode(*)[10]) fTimes;
+    fScalarsArray = (SkScalar(*)[10]) fValues;
+#endif
+}
+
+#define SK_Fixed1Third      (SK_Scalar1/3)
+#define SK_Fixed2Third      (SK_Scalar1*2/3)
+
+static const SkScalar gIdentityBlend[4] = {
+#ifdef SK_SCALAR_IS_FLOAT
+    0.33333333f, 0.33333333f, 0.66666667f, 0.66666667f
+#else
+    SK_Fixed1Third, SK_Fixed1Third, SK_Fixed2Third, SK_Fixed2Third
+#endif
+};
+
+bool SkInterpolator::setKeyFrame(int index, SkMSec time, const SkScalar values[], const SkScalar blend[4])
+{
+    SkASSERT(values != NULL);
+    
+    if (blend == NULL)
+        blend = gIdentityBlend;
+
+    bool success = ~index == SkTSearch<SkMSec>(&fTimes->fTime, index, time, sizeof(SkTimeCode));
+    SkASSERT(success);
+    if (success) {
+        SkTimeCode* timeCode = &fTimes[index];
+        timeCode->fTime = time;
+        memcpy(timeCode->fBlend, blend, sizeof(timeCode->fBlend));
+        SkScalar* dst = &fValues[fElemCount * index];
+        memcpy(dst, values, fElemCount * sizeof(SkScalar));
+    }
+    return success;
+}
+
+SkInterpolator::Result SkInterpolator::timeToValues(SkMSec time, SkScalar values[]) const
+{
+    SkScalar T;
+    int index;
+    SkBool exact;
+    Result result = timeToT(time, &T, &index, &exact);
+    if (values)
+    {
+        const SkScalar* nextSrc = &fValues[index * fElemCount];
+
+        if (exact)
+            memcpy(values, nextSrc, fElemCount * sizeof(SkScalar));
+        else
+        {
+            SkASSERT(index > 0);
+
+            const SkScalar* prevSrc = nextSrc - fElemCount;
+
+            for (int i = fElemCount - 1; i >= 0; --i)
+                values[i] = SkScalarInterp(prevSrc[i], nextSrc[i], T);
+        }
+    }
+    return result;
+}
+
+///////////////////////////////////////////////////////////////////////////////////////
+
+typedef int Dot14;
+#define Dot14_ONE       (1 << 14)
+#define Dot14_HALF      (1 << 13)
+
+#define Dot14ToFloat(x) ((x) / 16384.f)
+
+static inline Dot14 Dot14Mul(Dot14 a, Dot14 b)
+{
+    return (a * b + Dot14_HALF) >> 14;
+}
+
+static inline Dot14 eval_cubic(Dot14 t, Dot14 A, Dot14 B, Dot14 C)
+{
+    return Dot14Mul(Dot14Mul(Dot14Mul(C, t) + B, t) + A, t);
+}
+
+static inline Dot14 pin_and_convert(SkScalar x)
+{
+    if (x <= 0)
+        return 0;
+    if (x >= SK_Scalar1)
+        return Dot14_ONE;
+    return SkScalarToFixed(x) >> 2;
+}
+
+SkScalar SkUnitCubicInterp(SkScalar value, SkScalar bx, SkScalar by, SkScalar cx, SkScalar cy)
+{
+    // pin to the unit-square, and convert to 2.14
+    Dot14 x = pin_and_convert(value);
+    
+    if (x == 0) return 0;
+    if (x == Dot14_ONE) return SK_Scalar1;
+    
+    Dot14 b = pin_and_convert(bx);
+    Dot14 c = pin_and_convert(cx);
+    
+    // Now compute our coefficients from the control points
+    //  t   -> 3b
+    //  t^2 -> 3c - 6b
+    //  t^3 -> 3b - 3c + 1
+    Dot14 A = 3*b;
+    Dot14 B = 3*(c - 2*b);
+    Dot14 C = 3*(b - c) + Dot14_ONE;
+
+    // Now search for a t value given x
+    Dot14   t = Dot14_HALF;
+    Dot14   dt = Dot14_HALF;
+    for (int i = 0; i < 13; i++)
+    {
+        dt >>= 1;
+        Dot14 guess = eval_cubic(t, A, B, C);
+        if (x < guess)
+            t -= dt;
+        else
+            t += dt;
+    }
+    
+    // Now we have t, so compute the coeff for Y and evaluate
+    b = pin_and_convert(by);
+    c = pin_and_convert(cy);
+    A = 3*b;
+    B = 3*(c - 2*b);
+    C = 3*(b - c) + Dot14_ONE;
+    return SkFixedToScalar(eval_cubic(t, A, B, C) << 2);
+}
+
+///////////////////////////////////////////////////////////////////////////////////////
+///////////////////////////////////////////////////////////////////////////////////////
+
+#ifdef SK_DEBUG
+
+#ifdef SK_SUPPORT_UNITTEST
+    static SkScalar* iset(SkScalar array[3], int a, int b, int c)
+    {
+        array[0] = SkIntToScalar(a);
+        array[1] = SkIntToScalar(b);
+        array[2] = SkIntToScalar(c);
+        return array;
+    }
+#endif
+
+void SkInterpolator::UnitTest()
+{
+#ifdef SK_SUPPORT_UNITTEST
+    SkInterpolator  inter(3, 2);
+    SkScalar        v1[3], v2[3], v[3], vv[3];
+    Result          result;
+
+    inter.setKeyFrame(0, 100, iset(v1, 10, 20, 30), 0);
+    inter.setKeyFrame(1, 200, iset(v2, 110, 220, 330));
+
+    result = inter.timeToValues(0, v);
+    SkASSERT(result == kFreezeStart_Result);
+    SkASSERT(memcmp(v, v1, sizeof(v)) == 0);
+
+    result = inter.timeToValues(99, v);
+    SkASSERT(result == kFreezeStart_Result);
+    SkASSERT(memcmp(v, v1, sizeof(v)) == 0);
+
+    result = inter.timeToValues(100, v);
+    SkASSERT(result == kNormal_Result);
+    SkASSERT(memcmp(v, v1, sizeof(v)) == 0);
+
+    result = inter.timeToValues(200, v);
+    SkASSERT(result == kNormal_Result);
+    SkASSERT(memcmp(v, v2, sizeof(v)) == 0);
+
+    result = inter.timeToValues(201, v);
+    SkASSERT(result == kFreezeEnd_Result);
+    SkASSERT(memcmp(v, v2, sizeof(v)) == 0);
+
+    result = inter.timeToValues(150, v);
+    SkASSERT(result == kNormal_Result);
+    SkASSERT(memcmp(v, iset(vv, 60, 120, 180), sizeof(v)) == 0);
+
+    result = inter.timeToValues(125, v);
+    SkASSERT(result == kNormal_Result);
+    result = inter.timeToValues(175, v);
+    SkASSERT(result == kNormal_Result);
+#endif
+}
+
+#endif
+
index 8221310..e0698ad 100644 (file)
+/* libs/corecg/SkMath.cpp
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #include "SkMath.h"
 #include "SkCordic.h"
 #include "SkFloatingPoint.h"
 #include "Sk64.h"
 
 #ifdef SK_SCALAR_IS_FLOAT
-       const uint32_t gIEEENotANumber = 0x7FFFFFFF;
-       const uint32_t gIEEEInfinity = 0x7F800000;
+    const uint32_t gIEEENotANumber = 0x7FFFFFFF;
+    const uint32_t gIEEEInfinity = 0x7F800000;
 #endif
 
-int SkCLZ(uint32_t x)
+#define sub_shift(zeros, x, n)  \
+    zeros -= n;                 \
+    x >>= n
+    
+int SkCLZ_portable(uint32_t x)
 {
-#if defined(__arm__) && !defined(__thumb) && defined(__ARM_ARCH_5T__)
-    asm( "clz %0,%0" : "=r"(x) : "0"(x) : );
-    return x;
-#else
-       if (x == 0)
-               return 32;
-
-       SkDEBUGCODE(uint32_t n = x;)
+    if (x == 0)
+        return 32;
 
-       int zeros = ((x >> 16) - 1) >> 31 << 4;
-       x <<= zeros;
-
-       int nonzero = ((x >> 24) - 1) >> 31 << 3;
-       zeros += nonzero;
-       x <<= nonzero;
+#ifdef SK_CPU_HAS_CONDITIONAL_INSTR
+    int zeros = 31;
+    if (x & 0xFFFF0000) {
+        sub_shift(zeros, x, 16);
+    }
+    if (x & 0xFF00) {
+        sub_shift(zeros, x, 8);
+    }
+    if (x & 0xF0) {
+        sub_shift(zeros, x, 4);
+    }
+    if (x & 0xC) {
+        sub_shift(zeros, x, 2);
+    }
+    if (x & 0x2) {
+        sub_shift(zeros, x, 1);
+    }
+#else
+    int zeros = ((x >> 16) - 1) >> 31 << 4;
+    x <<= zeros;
 
-       nonzero = ((x >> 28) - 1) >> 31 << 2;
-       zeros += nonzero;
-       x <<= nonzero;
+    int nonzero = ((x >> 24) - 1) >> 31 << 3;
+    zeros += nonzero;
+    x <<= nonzero;
 
-       nonzero = ((x >> 30) - 1) >> 31 << 1;
-       zeros += nonzero;
-       x <<= nonzero;
+    nonzero = ((x >> 28) - 1) >> 31 << 2;
+    zeros += nonzero;
+    x <<= nonzero;
 
-//     zeros += ((x >> 31) - 1) >> 31;
-       zeros += (~x) >> 31;
+    nonzero = ((x >> 30) - 1) >> 31 << 1;
+    zeros += nonzero;
+    x <<= nonzero;
 
-#ifdef SK_DEBUG
-       int     slow_zeros;
-
-       if (n == 0)
-               slow_zeros = 32;
-       else
-       {
-               slow_zeros = 0;
-               while ((int32_t)n > 0)
-               {
-                       slow_zeros += 1;
-                       n <<= 1;
-               }
-       }
-       SkASSERT(zeros == slow_zeros);
-#endif
-       return zeros;
+    zeros += (~x) >> 31;
 #endif
+
+    return zeros;
 }
 
 int32_t SkMulDiv(int32_t numer1, int32_t numer2, int32_t denom)
 {
-       SkASSERT(denom);
+    SkASSERT(denom);
 
-       Sk64 tmp;
-       tmp.setMul(numer1, numer2);
-       tmp.div(denom, Sk64::kTrunc_DivOption);
-       return tmp.get32();
+    Sk64 tmp;
+    tmp.setMul(numer1, numer2);
+    tmp.div(denom, Sk64::kTrunc_DivOption);
+    return tmp.get32();
 }
 
 int32_t SkMulShift(int32_t a, int32_t b, unsigned shift)
 {
-       int sign = SkExtractSign(a ^ b);
-
-       if (shift > 63)
-               return sign;
-
-       a = SkAbs32(a);
-       b = SkAbs32(b);
-
-       uint32_t ah = a >> 16;
-       uint32_t al = a & 0xFFFF;
-       uint32_t bh = b >> 16;
-       uint32_t bl = b & 0xFFFF;
-
-       uint32_t A = ah * bh;
-       uint32_t B = ah * bl + al * bh;
-       uint32_t C = al * bl;
-
-       /*      [  A  ]
-                  [  B  ]
-                     [  C  ]
-       */
-       uint32_t lo = C + (B << 16);
-       int32_t  hi = A + (B >> 16) + (lo < C);
-
-       if (sign < 0)
-       {
-               hi = -hi - Sk32ToBool(lo);
-               lo = 0 - lo;
-       }
-
-       if (shift == 0)
-       {
+    int sign = SkExtractSign(a ^ b);
+
+    if (shift > 63)
+        return sign;
+
+    a = SkAbs32(a);
+    b = SkAbs32(b);
+
+    uint32_t ah = a >> 16;
+    uint32_t al = a & 0xFFFF;
+    uint32_t bh = b >> 16;
+    uint32_t bl = b & 0xFFFF;
+
+    uint32_t A = ah * bh;
+    uint32_t B = ah * bl + al * bh;
+    uint32_t C = al * bl;
+
+    /*  [  A  ]
+           [  B  ]
+              [  C  ]
+    */
+    uint32_t lo = C + (B << 16);
+    int32_t  hi = A + (B >> 16) + (lo < C);
+
+    if (sign < 0)
+    {
+        hi = -hi - Sk32ToBool(lo);
+        lo = 0 - lo;
+    }
+
+    if (shift == 0)
+    {
 #ifdef SK_DEBUGx
-               SkASSERT(((int32_t)lo >> 31) == hi);
+        SkASSERT(((int32_t)lo >> 31) == hi);
 #endif
-               return lo;
-       }
-       else if (shift >= 32)
-               return hi >> (shift - 32);
-       else
-       {
+        return lo;
+    }
+    else if (shift >= 32)
+        return hi >> (shift - 32);
+    else
+    {
 #ifdef SK_DEBUGx
-               int32_t tmp = hi >> shift;
-               SkASSERT(tmp == 0 || tmp == -1);
+        int32_t tmp = hi >> shift;
+        SkASSERT(tmp == 0 || tmp == -1);
 #endif
-               return (hi << (32 - shift)) | (lo >> shift);
-       }
+        return (hi << (32 - shift)) | (lo >> shift);
+    }
 }
 
-#if !defined(SK_BUILD_FOR_BREW) || defined(AEE_SIMULATOR)
-SkFixed SkFixedMul(SkFixed a, SkFixed b)
+SkFixed SkFixedMul_portable(SkFixed a, SkFixed b)
 {
 #if 0
-       Sk64    tmp;
+    Sk64    tmp;
 
-       tmp.setMul(a, b);
-       tmp.shiftRight(16);
-       return tmp.fLo;
+    tmp.setMul(a, b);
+    tmp.shiftRight(16);
+    return tmp.fLo;
 #else
-       int sa = SkExtractSign(a);
-       int sb = SkExtractSign(b);
-       // now make them positive
-       a = SkApplySign(a, sa);
-       b = SkApplySign(b, sb);
+    int sa = SkExtractSign(a);
+    int sb = SkExtractSign(b);
+    // now make them positive
+    a = SkApplySign(a, sa);
+    b = SkApplySign(b, sb);
 
-       uint32_t        ah = a >> 16;
-       uint32_t        al = a & 0xFFFF;
-       uint32_t bh = b >> 16;
-       uint32_t bl = b & 0xFFFF;
+    uint32_t    ah = a >> 16;
+    uint32_t    al = a & 0xFFFF;
+    uint32_t bh = b >> 16;
+    uint32_t bl = b & 0xFFFF;
 
-       uint32_t R = ah * b + al * bh + (al * bl >> 16);
+    uint32_t R = ah * b + al * bh + (al * bl >> 16);
 
-       return SkApplySign(R, sa ^ sb);
+    return SkApplySign(R, sa ^ sb);
 #endif
 }
 
-SkFract        SkFractMul(SkFract a, SkFract b)
+SkFract SkFractMul_portable(SkFract a, SkFract b)
 {
 #if 0
-       Sk64 tmp;
-       tmp.setMul(a, b);
-       return tmp.getFract();
+    Sk64 tmp;
+    tmp.setMul(a, b);
+    return tmp.getFract();
 #else
-       int sa = SkExtractSign(a);
-       int sb = SkExtractSign(b);
-       // now make them positive
-       a = SkApplySign(a, sa);
-       b = SkApplySign(b, sb);
+    int sa = SkExtractSign(a);
+    int sb = SkExtractSign(b);
+    // now make them positive
+    a = SkApplySign(a, sa);
+    b = SkApplySign(b, sb);
 
-       uint32_t ah = a >> 16;
-       uint32_t al = a & 0xFFFF;
-       uint32_t bh = b >> 16;
-       uint32_t bl = b & 0xFFFF;
+    uint32_t ah = a >> 16;
+    uint32_t al = a & 0xFFFF;
+    uint32_t bh = b >> 16;
+    uint32_t bl = b & 0xFFFF;
 
-       uint32_t A = ah * bh;
-       uint32_t B = ah * bl + al * bh;
-       uint32_t C = al * bl;
+    uint32_t A = ah * bh;
+    uint32_t B = ah * bl + al * bh;
+    uint32_t C = al * bl;
 
-       /*      [  A  ]
-                  [  B  ]
-                     [  C  ]
-       */
-       uint32_t Lo = C + (B << 16);
-       uint32_t Hi = A + (B >>16) + (Lo < C);
+    /*  [  A  ]
+           [  B  ]
+              [  C  ]
+    */
+    uint32_t Lo = C + (B << 16);
+    uint32_t Hi = A + (B >>16) + (Lo < C);
 
-       SkASSERT((Hi >> 29) == 0);      // else overflow
+    SkASSERT((Hi >> 29) == 0);  // else overflow
 
-       int32_t R = (Hi << 2) + (Lo >> 30);
+    int32_t R = (Hi << 2) + (Lo >> 30);
 
-       return SkApplySign(R, sa ^ sb);
+    return SkApplySign(R, sa ^ sb);
 #endif
 }
-#endif
 
 int SkFixedMulCommon(SkFixed a, int b, int bias)
 {
-       // this function only works if b is 16bits
-       SkASSERT(b == (S16)b);
-       SkASSERT(b >= 0);
-
-       int sa = SkExtractSign(a);
-       a = SkApplySign(a, sa);
-       uint32_t ah = a >> 16;
-       uint32_t al = a & 0xFFFF;
-       uint32_t R = ah * b + ((al * b + bias) >> 16);
-       return SkApplySign(R, sa);
+    // this function only works if b is 16bits
+    SkASSERT(b == (S16)b);
+    SkASSERT(b >= 0);
+
+    int sa = SkExtractSign(a);
+    a = SkApplySign(a, sa);
+    uint32_t ah = a >> 16;
+    uint32_t al = a & 0xFFFF;
+    uint32_t R = ah * b + ((al * b + bias) >> 16);
+    return SkApplySign(R, sa);
+}
+
+#ifdef SK_DEBUGx
+    #define TEST_FASTINVERT
+#endif
+
+SkFixed SkFixedFastInvert(SkFixed x)
+{
+/*  Adapted (stolen) from Mathias' gglRecip()
+*/
+
+    if (x == SK_Fixed1)
+        return SK_Fixed1;
+
+    int      sign = SkExtractSign(x);
+    uint32_t a = SkApplySign(x, sign);
+
+    if (a <= 2) {
+        return SkApplySign(SK_MaxS32, sign);
+    }
+
+#ifdef TEST_FASTINVERT
+    SkFixed orig = a;
+    uint32_t slow = SkFixedDiv(SK_Fixed1, a);
+#endif
+
+    // normalize a
+    int lz = SkCLZ(a);
+    a = a << lz >> 16;
+
+    // compute 1/a approximation (0.5 <= a < 1.0) 
+    uint32_t r = 0x17400 - a;      // (2.90625 (~2.914) - 2*a) >> 1
+
+    // Newton-Raphson iteration:
+    // x = r*(2 - a*r) = ((r/2)*(1 - a*r/2))*4
+    r = ( (0x10000 - ((a*r)>>16)) * r ) >> 15;
+    r = ( (0x10000 - ((a*r)>>16)) * r ) >> (30 - lz);
+
+#ifdef TEST_FASTINVERT
+    SkDebugf("SkFixedFastInvert(%x %g) = %x %g Slow[%x %g]\n",
+                orig, orig/65536.,
+                r, r/65536.,
+                slow, slow/65536.);
+#endif
+
+    return SkApplySign(r, sign);
 }
 
 int32_t SkDivBits(int32_t numer, int32_t denom, int shift_bias)
 {
-       SkASSERT(denom != 0);
-       if (numer == 0)
-               return 0;
-               
-       SkFixed result;
-       int32_t sign;
-
-       // make numer and denom positive, and sign hold the resulting sign
-       sign = SkExtractSign(numer ^ denom);
-       numer = SkAbs32(numer);
-       denom = SkAbs32(denom);
+    SkASSERT(denom != 0);
+    if (numer == 0)
+        return 0;
+        
+    SkFixed result;
+    int32_t sign;
+
+    // make numer and denom positive, and sign hold the resulting sign
+    sign = SkExtractSign(numer ^ denom);
+    numer = SkAbs32(numer);
+    denom = SkAbs32(denom);
 
 #if 0   // faster assuming we have HW divide
-       if ((numer >> (32 - shift_bias)) == 0)
-       {
-               result = (uint32_t)(numer << shift_bias) / denom;
-       }
-       else
+    if ((numer >> (32 - shift_bias)) == 0)
+    {
+        result = (uint32_t)(numer << shift_bias) / denom;
+    }
+    else
 #endif
-       {
-               int     nbits = SkCLZ(numer) - 1;
-               int dbits = SkCLZ(denom) - 1;
-               int bits = shift_bias - nbits + dbits;
-
-               if (bits <= 0)  // answer will underflow
-                       return 0;
-               if (bits > 31)  // answer will overflow
-                       return SkApplySign(SK_MaxS32, sign);
-
-               denom <<= dbits;
-               numer <<= nbits;
-               result = 0;
-               do {
-                       result <<= 1;
-       #ifdef SK_CPU_HAS_CONDITIONAL_INSTR
-                       if ((uint32_t)denom <= (uint32_t)numer)
-                       {
-                               numer -= denom;
-                               result |= 1;
-                       }
-       #else
-                       int32_t diff = (denom - numer - 1) >> 31;
-                       result -= diff;
-                       numer -= denom & diff;
-       #endif
-                       numer <<= 1;
-               } while (--bits >= 0);
-       }
-
-       if (result < 0)
-               result = SK_MaxS32;
-       return SkApplySign(result, sign);
+    {
+        int nbits = SkCLZ(numer) - 1;
+        int dbits = SkCLZ(denom) - 1;
+        int bits = shift_bias - nbits + dbits;
+
+        if (bits <= 0)  // answer will underflow
+            return 0;
+        if (bits > 31)  // answer will overflow
+            return SkApplySign(SK_MaxS32, sign);
+
+        denom <<= dbits;
+        numer <<= nbits;
+        result = 0;
+        do {
+            result <<= 1;
+    #ifdef SK_CPU_HAS_CONDITIONAL_INSTR
+            if ((uint32_t)denom <= (uint32_t)numer)
+            {
+                numer -= denom;
+                result |= 1;
+            }
+    #else
+            int32_t diff = (denom - numer - 1) >> 31;
+            result -= diff;
+            numer -= denom & diff;
+    #endif
+            numer <<= 1;
+        } while (--bits >= 0);
+    }
+
+    if (result < 0)
+        result = SK_MaxS32;
+    return SkApplySign(result, sign);
 }
 
 /*  mod(float numer, float denom) seems to always return the sign
-       of the numer, so that's what we do too
+    of the numer, so that's what we do too
 */
 SkFixed SkFixedMod(SkFixed numer, SkFixed denom)
 {
-       int sn = SkExtractSign(numer);
-       int sd = SkExtractSign(denom);
-
-       numer = SkApplySign(numer, sn);
-       denom = SkApplySign(denom, sd);
-       
-       if (numer < denom)
-               return SkApplySign(numer, sn);
-       else if (numer == denom)
-               return 0;
-       else
-       {
-               SkFixed div = SkFixedDiv(numer, denom);
-               return SkApplySign(SkFixedMul(denom, div & 0xFFFF), sn);
-       }
+    int sn = SkExtractSign(numer);
+    int sd = SkExtractSign(denom);
+
+    numer = SkApplySign(numer, sn);
+    denom = SkApplySign(denom, sd);
+    
+    if (numer < denom)
+        return SkApplySign(numer, sn);
+    else if (numer == denom)
+        return 0;
+    else
+    {
+        SkFixed div = SkFixedDiv(numer, denom);
+        return SkApplySign(SkFixedMul(denom, div & 0xFFFF), sn);
+    }
 }
 
 /* www.worldserver.com/turk/computergraphics/FixedSqrt.pdf
 */
 int32_t SkSqrtBits(int32_t x, int count)
 {
-       SkASSERT(x >= 0 && count > 0 && (unsigned)count <= 30);
+    SkASSERT(x >= 0 && count > 0 && (unsigned)count <= 30);
 
-       uint32_t        root = 0;
-       uint32_t        remHi = 0;
-       uint32_t        remLo = x;
+    uint32_t    root = 0;
+    uint32_t    remHi = 0;
+    uint32_t    remLo = x;
 
-       do {
-               root <<= 1;
+    do {
+        root <<= 1;
 
-               remHi = (remHi<<2) | (remLo>>30);
-               remLo <<= 2;
+        remHi = (remHi<<2) | (remLo>>30);
+        remLo <<= 2;
 
-               uint32_t testDiv = (root << 1) + 1;
-               if (remHi >= testDiv)
-               {
-                       remHi -= testDiv;
-                       root++;
-               }
-       } while (--count >= 0);
+        uint32_t testDiv = (root << 1) + 1;
+        if (remHi >= testDiv)
+        {
+            remHi -= testDiv;
+            root++;
+        }
+    } while (--count >= 0);
 
-       return root;
+    return root;
 }
 
 int32_t SkCubeRootBits(int32_t value, int bits)
 {
-       SkASSERT(bits > 0);
-
-       int     sign = SkExtractSign(value);
-       value = SkApplySign(value, sign);
-
-       uint32_t root = 0;
-       uint32_t curr = (uint32_t)value >> 30;
-       value <<= 2;
-
-       do {
-               root <<= 1;
-               uint32_t guess = root * root + root;
-               guess = (guess << 1) + guess;   // guess *= 3
-               if (guess < curr)
-               {       curr -= guess + 1;
-                       root |= 1;
-               }
-               curr = (curr << 3) | ((uint32_t)value >> 29);
-               value <<= 3;
-       } while (--bits);
-
-       return SkApplySign(root, sign);
+    SkASSERT(bits > 0);
+
+    int sign = SkExtractSign(value);
+    value = SkApplySign(value, sign);
+
+    uint32_t root = 0;
+    uint32_t curr = (uint32_t)value >> 30;
+    value <<= 2;
+
+    do {
+        root <<= 1;
+        uint32_t guess = root * root + root;
+        guess = (guess << 1) + guess;   // guess *= 3
+        if (guess < curr)
+        {   curr -= guess + 1;
+            root |= 1;
+        }
+        curr = (curr << 3) | ((uint32_t)value >> 29);
+        value <<= 3;
+    } while (--bits);
+
+    return SkApplySign(root, sign);
 }
 
 SkFixed SkFixedMean(SkFixed a, SkFixed b)
 {
-       Sk64 tmp;
-       
-       tmp.setMul(a, b);
-       return tmp.getSqrt();
+    Sk64 tmp;
+    
+    tmp.setMul(a, b);
+    return tmp.getSqrt();
 }
 
 ////////////////////////////////////////////////////////////////////////////
@@ -341,136 +401,138 @@ SkFixed SkFixedMean(SkFixed a, SkFixed b)
 #ifdef SK_SCALAR_IS_FLOAT
 float SkScalarSinCos(float radians, float* cosValue)
 {
-       float sinValue = sk_float_sin(radians);
+    float sinValue = sk_float_sin(radians);
 
-       if (cosValue)
-               *cosValue = sk_float_cos(radians);
-       
-       if (SkScalarNearlyZero(*cosValue))
-               *cosValue = 0;
+    if (cosValue)
+    {
+        *cosValue = sk_float_cos(radians);
+        if (SkScalarNearlyZero(*cosValue))
+            *cosValue = 0;
+    }
 
-       if (SkScalarNearlyZero(sinValue))
-               sinValue = 0;
+    if (SkScalarNearlyZero(sinValue))
+        sinValue = 0;
 
-       return sinValue;
+    return sinValue;
 }
 #endif
 
 #define INTERP_SINTABLE
 #define BUILD_TABLE_AT_RUNTIMEx
 
-#define kTableSize     256
+#define kTableSize  256
 
 #ifdef BUILD_TABLE_AT_RUNTIME
-       static uint16_t gSkSinTable[kTableSize];
-
-       static void build_sintable(uint16_t table[])
-       {
-               for (int i = 0; i < kTableSize; i++)
-               {
-                       double  rad = i * 3.141592653589793 / (2*kTableSize);
-                       double  val = sin(rad);
-                       int             ival = (int)(val * SK_Fixed1);
-                       table[i] = SkToU16(ival);
-               }
-       }
+    static uint16_t gSkSinTable[kTableSize];
+
+    static void build_sintable(uint16_t table[])
+    {
+        for (int i = 0; i < kTableSize; i++)
+        {
+            double  rad = i * 3.141592653589793 / (2*kTableSize);
+            double  val = sin(rad);
+            int     ival = (int)(val * SK_Fixed1);
+            table[i] = SkToU16(ival);
+        }
+    }
 #else
-       #include "SkSinTable.h"
+    #include "SkSinTable.h"
 #endif
 
-#define SK_Fract1024SizeOver2PI                0x28BE60        /* floatToFract(1024 / 2PI) */
+#define SK_Fract1024SizeOver2PI     0x28BE60    /* floatToFract(1024 / 2PI) */
 
 #ifdef INTERP_SINTABLE
-static SkFixed interp_table(const uint16_t table[], int index, int partial256)
+static SkFixed interp_table(const uint16_t table[], int index, int partial255)
 {
-       SkASSERT((unsigned)index < kTableSize);
+    SkASSERT((unsigned)index < kTableSize);
+    SkASSERT((unsigned)partial255 <= 255);
 
-       SkFixed lower = table[index];
-       SkFixed upper = (index == kTableSize - 1) ? SK_Fixed1 : table[index + 1];
+    SkFixed lower = table[index];
+    SkFixed upper = (index == kTableSize - 1) ? SK_Fixed1 : table[index + 1];
 
-       SkASSERT(lower < upper);
-       SkASSERT(lower >= 0);
-       SkASSERT(upper <= SK_Fixed1);
-       SkASSERT((unsigned)partial256 <= 255);
+    SkASSERT(lower < upper);
+    SkASSERT(lower >= 0);
+    SkASSERT(upper <= SK_Fixed1);
 
-       return lower + ((upper - lower) * partial256 >> 8);
+    partial255 += (partial255 >> 7);
+    return lower + ((upper - lower) * partial255 >> 8);
 }
 #endif
 
 SkFixed SkFixedSinCos(SkFixed radians, SkFixed* cosValuePtr)
 {
-       SkASSERT(SK_ARRAY_COUNT(gSkSinTable) == kTableSize);
+    SkASSERT(SK_ARRAY_COUNT(gSkSinTable) == kTableSize);
 
 #ifdef BUILD_TABLE_AT_RUNTIME
-       static bool gFirstTime = true;
-       if (gFirstTime)
-       {
-               build_sintable(gSinTable);
-               gFirstTime = false;
-       }
+    static bool gFirstTime = true;
+    if (gFirstTime)
+    {
+        build_sintable(gSinTable);
+        gFirstTime = false;
+    }
 #endif
 
-       // make radians positive
-       SkFixed sinValue, cosValue;
-       int32_t cosSign = 0;
-       int32_t sinSign = SkExtractSign(radians);
-       radians = SkApplySign(radians, sinSign);
-       // scale it to 0...1023 ...
+    // make radians positive
+    SkFixed sinValue, cosValue;
+    int32_t cosSign = 0;
+    int32_t sinSign = SkExtractSign(radians);
+    radians = SkApplySign(radians, sinSign);
+    // scale it to 0...1023 ...
 
 #ifdef INTERP_SINTABLE
-       radians = SkMulDiv(radians, 2 * kTableSize * 256, SK_FixedPI);
-       int findex = radians & (kTableSize * 256 - 1);
-       int index = findex >> 8;
-       int partial = findex & 255;
-       sinValue = interp_table(gSkSinTable, index, partial);
-
-       findex = kTableSize * 256 - findex - 1;
-       index = findex >> 8;
-       partial = findex & 255;
-       cosValue = interp_table(gSkSinTable, index, partial);
-
-       int quad = ((unsigned)radians / (kTableSize * 256)) & 3;
+    radians = SkMulDiv(radians, 2 * kTableSize * 256, SK_FixedPI);
+    int findex = radians & (kTableSize * 256 - 1);
+    int index = findex >> 8;
+    int partial = findex & 255;
+    sinValue = interp_table(gSkSinTable, index, partial);
+
+    findex = kTableSize * 256 - findex - 1;
+    index = findex >> 8;
+    partial = findex & 255;
+    cosValue = interp_table(gSkSinTable, index, partial);
+
+    int quad = ((unsigned)radians / (kTableSize * 256)) & 3;
 #else
-       radians = SkMulDiv(radians, 2 * kTableSize, SK_FixedPI);
-       int             index = radians & (kTableSize - 1);
-
-       if (index == 0)
-       {
-               sinValue = 0;
-               cosValue = SK_Fixed1;
-       }
-       else
-       {
-               sinValue = gSkSinTable[index];
-               cosValue = gSkSinTable[kTableSize - index];
-       }
-       int quad = ((unsigned)radians / kTableSize) & 3;
+    radians = SkMulDiv(radians, 2 * kTableSize, SK_FixedPI);
+    int     index = radians & (kTableSize - 1);
+
+    if (index == 0)
+    {
+        sinValue = 0;
+        cosValue = SK_Fixed1;
+    }
+    else
+    {
+        sinValue = gSkSinTable[index];
+        cosValue = gSkSinTable[kTableSize - index];
+    }
+    int quad = ((unsigned)radians / kTableSize) & 3;
 #endif
 
-       if (quad & 1)
-               SkTSwap<SkFixed>(sinValue, cosValue);
-       if (quad & 2)
-               sinSign = ~sinSign;
-       if (((quad - 1) & 2) == 0)
-               cosSign = ~cosSign;
+    if (quad & 1)
+        SkTSwap<SkFixed>(sinValue, cosValue);
+    if (quad & 2)
+        sinSign = ~sinSign;
+    if (((quad - 1) & 2) == 0)
+        cosSign = ~cosSign;
 
-       sinValue = SkApplySign(sinValue, sinSign);
-       cosValue = SkApplySign(cosValue, cosSign);
+    // restore the sign for negative angles
+    sinValue = SkApplySign(sinValue, sinSign);
+    cosValue = SkApplySign(cosValue, cosSign);
 
 #ifdef SK_DEBUG
-       if (1)
-       {
-               SkFixed sin2 = SkFixedMul(sinValue, sinValue);
-               SkFixed cos2 = SkFixedMul(cosValue, cosValue);
-               int diff = cos2 + sin2 - SK_Fixed1;
-               SkASSERT(SkAbs32(diff) <= 8);
-       }
+    if (1)
+    {
+        SkFixed sin2 = SkFixedMul(sinValue, sinValue);
+        SkFixed cos2 = SkFixedMul(cosValue, cosValue);
+        int diff = cos2 + sin2 - SK_Fixed1;
+        SkASSERT(SkAbs32(diff) <= 7);
+    }
 #endif
 
-       // restore the sign for negative angles
-       if (cosValuePtr)
-               *cosValuePtr = cosValue;
-       return sinValue;
+    if (cosValuePtr)
+        *cosValuePtr = cosValue;
+    return sinValue;
 }
 
 ////////////////////////////////////////////////////////////////////////////
@@ -492,57 +554,72 @@ SkFixed SkFixedLog(SkFixed x) { return SkCordicLog(x); }
 #ifdef SK_CAN_USE_LONGLONG
 static int symmetric_fixmul(int a, int b)
 {
-       int sa = SkExtractSign(a);
-       int sb = SkExtractSign(b);
+    int sa = SkExtractSign(a);
+    int sb = SkExtractSign(b);
 
-       a = SkApplySign(a, sa);
-       b = SkApplySign(b, sb);
+    a = SkApplySign(a, sa);
+    b = SkApplySign(b, sb);
 
 #if 1
-       int c = (int)(((SkLONGLONG)a * b) >> 16);
-       
-       return SkApplySign(c, sa ^ sb);
+    int c = (int)(((SkLONGLONG)a * b) >> 16);
+    
+    return SkApplySign(c, sa ^ sb);
 #else
-       SkLONGLONG ab = (SkLONGLONG)a * b;
-       if (sa ^ sb)
-               ab = -ab;
-       return ab >> 16;
+    SkLONGLONG ab = (SkLONGLONG)a * b;
+    if (sa ^ sb)
+        ab = -ab;
+    return ab >> 16;
+#endif
+}
 #endif
+
+#include "SkPoint.h"
+
+#ifdef SK_SUPPORT_UNITTEST
+static void check_length(const SkPoint& p, SkScalar targetLen)
+{
+    float x = SkScalarToFloat(p.fX);
+    float y = SkScalarToFloat(p.fY);
+    float len = sk_float_sqrt(x*x + y*y);
+    
+    len /= SkScalarToFloat(targetLen);
+
+    SkASSERT(len > 0.999f && len < 1.001f);
 }
 #endif
 
 void SkMath::UnitTest()
 {
 #ifdef SK_SUPPORT_UNITTEST
-       int                     i;
-       int32_t     x;
-       SkRandom        rand;
+    int         i;
+    int32_t     x;
+    SkRandom    rand;
 
-       SkToS8(127);    SkToS8(-128);           SkToU8(255);
-       SkToS16(32767); SkToS16(-32768);        SkToU16(65535);
-       SkToS32(2*1024*1024);   SkToS32(-2*1024*1024);  SkToU32(4*1024*1024);
+    SkToS8(127);    SkToS8(-128);       SkToU8(255);
+    SkToS16(32767); SkToS16(-32768);    SkToU16(65535);
+    SkToS32(2*1024*1024);   SkToS32(-2*1024*1024);  SkToU32(4*1024*1024);
 
-       SkCordic_UnitTest();
+    SkCordic_UnitTest();
 
-       // these should assert
+    // these should assert
 #if 0
-       SkToS8(128);
-       SkToS8(-129);
-       SkToU8(256);
-       SkToU8(-5);
-
-       SkToS16(32768);
-       SkToS16(-32769);
-       SkToU16(65536);
-       SkToU16(-5);
-
-       if (sizeof(size_t) > 4)
-       {
-               SkToS32(4*1024*1024);
-               SkToS32(-4*1024*1024);
-               SkToU32(5*1024*1024);
-               SkToU32(-5);
-       }
+    SkToS8(128);
+    SkToS8(-129);
+    SkToU8(256);
+    SkToU8(-5);
+
+    SkToS16(32768);
+    SkToS16(-32769);
+    SkToU16(65536);
+    SkToU16(-5);
+
+    if (sizeof(size_t) > 4)
+    {
+        SkToS32(4*1024*1024);
+        SkToS32(-4*1024*1024);
+        SkToU32(5*1024*1024);
+        SkToU32(-5);
+    }
 #endif
 
     {
@@ -550,151 +627,168 @@ void SkMath::UnitTest()
         SkASSERT(SkScalarIsNaN(x));
     }
 
-       for (i = 1; i <= 10; i++)
-       {
-               x = SkCubeRootBits(i*i*i, 11);
-               SkASSERT(x == i);
-       }
-
-       x = SkFixedSqrt(SK_Fixed1);
-       SkASSERT(x == SK_Fixed1);
-       x = SkFixedSqrt(SK_Fixed1/4);
-       SkASSERT(x == SK_Fixed1/2);
-       x = SkFixedSqrt(SK_Fixed1*4);
-       SkASSERT(x == SK_Fixed1*2);
-
-       x = SkFractSqrt(SK_Fract1);
-       SkASSERT(x == SK_Fract1);
-       x = SkFractSqrt(SK_Fract1/4);
-       SkASSERT(x == SK_Fract1/2);
-       x = SkFractSqrt(SK_Fract1/16);
-       SkASSERT(x == SK_Fract1/4);
-
-       for (i = 1; i < 100; i++)
-       {
-               x = SkFixedSqrt(SK_Fixed1 * i * i);
-               SkASSERT(x == SK_Fixed1 * i);
-       }
-
-       for (i = 0; i < 1000; i++)
-       {
-               int value = rand.nextS16();
-               int max = rand.nextU16();
-
-               int clamp = SkClampMax(value, max);
-               int clamp2 = value < 0 ? 0 : (value > max ? max : value);
-               SkASSERT(clamp == clamp2);
-       }
+    for (i = 1; i <= 10; i++)
+    {
+        x = SkCubeRootBits(i*i*i, 11);
+        SkASSERT(x == i);
+    }
+
+    x = SkFixedSqrt(SK_Fixed1);
+    SkASSERT(x == SK_Fixed1);
+    x = SkFixedSqrt(SK_Fixed1/4);
+    SkASSERT(x == SK_Fixed1/2);
+    x = SkFixedSqrt(SK_Fixed1*4);
+    SkASSERT(x == SK_Fixed1*2);
+
+    x = SkFractSqrt(SK_Fract1);
+    SkASSERT(x == SK_Fract1);
+    x = SkFractSqrt(SK_Fract1/4);
+    SkASSERT(x == SK_Fract1/2);
+    x = SkFractSqrt(SK_Fract1/16);
+    SkASSERT(x == SK_Fract1/4);
+
+    for (i = 1; i < 100; i++)
+    {
+        x = SkFixedSqrt(SK_Fixed1 * i * i);
+        SkASSERT(x == SK_Fixed1 * i);
+    }
+
+    for (i = 0; i < 1000; i++)
+    {
+        int value = rand.nextS16();
+        int max = rand.nextU16();
+
+        int clamp = SkClampMax(value, max);
+        int clamp2 = value < 0 ? 0 : (value > max ? max : value);
+        SkASSERT(clamp == clamp2);
+    }
+    
+    for (i = 0; i < 100000; i++)
+    {
+        SkPoint p;
+        
+        p.setLength(rand.nextS(), rand.nextS(), SK_Scalar1);
+        check_length(p, SK_Scalar1);
+        p.setLength(rand.nextS() >> 13, rand.nextS() >> 13, SK_Scalar1);
+        check_length(p, SK_Scalar1);
+    }
 
 #ifdef SK_CAN_USE_LONGLONG
-       for (i = 0; i < 100000; i++)
-       {
-               SkFixed numer = rand.nextS();
-               SkFixed denom = rand.nextS();
-               SkFixed result = SkFixedDiv(numer, denom);
-               SkLONGLONG check = ((SkLONGLONG)numer << 16) / denom;
-
-               (void)SkCLZ(numer);
-               (void)SkCLZ(denom);
-
-               SkASSERT(result != (SkFixed)SK_NaN32);
-               if (check > SK_MaxS32)
-                       check = SK_MaxS32;
-               else if (check < -SK_MaxS32)
-                       check = SK_MinS32;
-               SkASSERT(result == check);
-
-               result = SkFractDiv(numer, denom);
-               check = ((SkLONGLONG)numer << 30) / denom;
-
-               SkASSERT(result != (SkFixed)SK_NaN32);
-               if (check > SK_MaxS32)
-                       check = SK_MaxS32;
-               else if (check < -SK_MaxS32)
-                       check = SK_MinS32;
-               SkASSERT(result == (int32_t)check);
-
-               // make them <= 2^24, so we don't overflow in fixmul
-               numer = numer << 8 >> 8;
-               denom = denom << 8 >> 8;
-
-               result = SkFixedMul(numer, denom);
-               SkFixed r2 = symmetric_fixmul(numer, denom);
-               SkASSERT(result == r2);
-
-               result = SkFixedMul(numer, numer);
-               r2 = SkFixedSquare(numer);
-               SkASSERT(result == r2);
-               
+    for (i = 0; i < 100000; i++)
+    {
+        SkFixed numer = rand.nextS();
+        SkFixed denom = rand.nextS();
+        SkFixed result = SkFixedDiv(numer, denom);
+        SkLONGLONG check = ((SkLONGLONG)numer << 16) / denom;
+
+        (void)SkCLZ(numer);
+        (void)SkCLZ(denom);
+
+        SkASSERT(result != (SkFixed)SK_NaN32);
+        if (check > SK_MaxS32)
+            check = SK_MaxS32;
+        else if (check < -SK_MaxS32)
+            check = SK_MinS32;
+        SkASSERT(result == (int32_t)check);
+
+        result = SkFractDiv(numer, denom);
+        check = ((SkLONGLONG)numer << 30) / denom;
+
+        SkASSERT(result != (SkFixed)SK_NaN32);
+        if (check > SK_MaxS32)
+            check = SK_MaxS32;
+        else if (check < -SK_MaxS32)
+            check = SK_MinS32;
+        SkASSERT(result == (int32_t)check);
+
+        // make them <= 2^24, so we don't overflow in fixmul
+        numer = numer << 8 >> 8;
+        denom = denom << 8 >> 8;
+
+        result = SkFixedMul(numer, denom);
+        SkFixed r2 = symmetric_fixmul(numer, denom);
+        SkASSERT(result == r2);
+
+        result = SkFixedMul(numer, numer);
+        r2 = SkFixedSquare(numer);
+        SkASSERT(result == r2);
+        
 #ifdef SK_CAN_USE_FLOAT
-               if (numer >= 0 && denom >= 0)
-               {
-                       SkFixed mean = SkFixedMean(numer, denom);
-                       float fm = sk_float_sqrt(sk_float_abs(SkFixedToFloat(numer) * SkFixedToFloat(denom)));
-                       SkFixed mean2 = SkFloatToFixed(fm);
-                       int diff = SkAbs32(mean - mean2);
-                       SkASSERT(diff <= 1);
-               }
-
-               {
-                       SkFixed mod = SkFixedMod(numer, denom);
-                       float n = SkFixedToFloat(numer);
-                       float d = SkFixedToFloat(denom);
-                       float m = sk_float_mod(n, d);
+        if (numer >= 0 && denom >= 0)
+        {
+            SkFixed mean = SkFixedMean(numer, denom);
+            float fm = sk_float_sqrt(sk_float_abs(SkFixedToFloat(numer) * SkFixedToFloat(denom)));
+            SkFixed mean2 = SkFloatToFixed(fm);
+            int diff = SkAbs32(mean - mean2);
+            SkASSERT(diff <= 1);
+        }
+
+        {
+            SkFixed mod = SkFixedMod(numer, denom);
+            float n = SkFixedToFloat(numer);
+            float d = SkFixedToFloat(denom);
+            float m = sk_float_mod(n, d);
 #if 0
-                       SkDebugf("%g mod %g = %g [%g]\n",
-                                       SkFixedToFloat(numer), SkFixedToFloat(denom),
-                                       SkFixedToFloat(mod), m);
+            SkDebugf("%g mod %g = %g [%g]\n",
+                    SkFixedToFloat(numer), SkFixedToFloat(denom),
+                    SkFixedToFloat(mod), m);
 #endif
-                       SkASSERT(mod == 0 || (mod < 0) == (m < 0)); // ensure the same sign
-                       int diff = SkAbs32(mod - SkFloatToFixed(m));
-                       SkASSERT((diff >> 7) == 0);
-               }
+            SkASSERT(mod == 0 || (mod < 0) == (m < 0)); // ensure the same sign
+            int diff = SkAbs32(mod - SkFloatToFixed(m));
+            SkASSERT((diff >> 7) == 0);
+        }
 #endif
-       }
+    }
 #endif
 
 #ifdef SK_CAN_USE_FLOAT
-       for (i = 0; i < 100000; i++)
-       {
-               SkFract x = rand.nextU() >> 1;
-               double xx = (double)x / SK_Fract1;
-               SkFract xr = SkFractSqrt(x);
-               SkFract check = SkFloatToFract(sqrt(xx));
-               SkASSERT(xr == check || xr == check-1 || xr == check+1);
-
-               xr = SkFixedSqrt(x);
-               xx = (double)x / SK_Fixed1;
-               check = SkFloatToFixed(sqrt(xx));
-               SkASSERT(xr == check || xr == check-1);
-
-               xr = SkSqrt32(x);
-               xx = (double)x;
-               check = (int32_t)sqrt(xx);
-               SkASSERT(xr == check || xr == check-1);
-       }
+    for (i = 0; i < 100000; i++)
+    {
+        SkFract x = rand.nextU() >> 1;
+        double xx = (double)x / SK_Fract1;
+        SkFract xr = SkFractSqrt(x);
+        SkFract check = SkFloatToFract(sqrt(xx));
+        SkASSERT(xr == check || xr == check-1 || xr == check+1);
+
+        xr = SkFixedSqrt(x);
+        xx = (double)x / SK_Fixed1;
+        check = SkFloatToFixed(sqrt(xx));
+        SkASSERT(xr == check || xr == check-1);
+
+        xr = SkSqrt32(x);
+        xx = (double)x;
+        check = (int32_t)sqrt(xx);
+        SkASSERT(xr == check || xr == check-1);
+    }
 #endif
 
 #if !defined(SK_SCALAR_IS_FLOAT) && defined(SK_CAN_USE_FLOAT)
-       int maxDiff = 0;
-       for (i = 0; i < 10000; i++)
-       {
-               SkFixed rads = rand.nextS() >> 10;
-               double frads = SkFixedToFloat(rads);
+    {
+        SkFixed s, c;
+        s = SkFixedSinCos(0, &c);
+        SkASSERT(s == 0);
+        SkASSERT(c == SK_Fixed1);
+    }
 
-               SkFixed s, c;
-               s = SkScalarSinCos(rads, &c);
+    int maxDiff = 0;
+    for (i = 0; i < 10000; i++)
+    {
+        SkFixed rads = rand.nextS() >> 10;
+        double frads = SkFixedToFloat(rads);
+
+        SkFixed s, c;
+        s = SkScalarSinCos(rads, &c);
 
-               double fs = sin(frads);
-               double fc = cos(frads);
+        double fs = sin(frads);
+        double fc = cos(frads);
 
-               SkFixed is = SkFloatToFixed(fs);
-               SkFixed ic = SkFloatToFixed(fc);
+        SkFixed is = SkFloatToFixed(fs);
+        SkFixed ic = SkFloatToFixed(fc);
 
-               maxDiff = SkMax32(maxDiff, SkAbs32(is - s));
-               maxDiff = SkMax32(maxDiff, SkAbs32(ic - c));
-       }
-       SkDebugf("SinCos: maximum error = %d\n", maxDiff);
+        maxDiff = SkMax32(maxDiff, SkAbs32(is - s));
+        maxDiff = SkMax32(maxDiff, SkAbs32(ic - c));
+    }
+    SkDebugf("SinCos: maximum error = %d\n", maxDiff);
 #endif
 #endif
 }
index f510e9f..3ad8e3b 100644 (file)
+/* libs/corecg/SkMatrix.cpp
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #include "SkMatrix.h"
 #include "Sk64.h"
 
 #ifdef SK_SCALAR_IS_FLOAT
-       #define kMatrix22Elem   SK_Scalar1
+    #define kMatrix22Elem   SK_Scalar1
 #else
-       #define kMatrix22Elem   SK_Fract1
+    #define kMatrix22Elem   SK_Fract1
 #endif
 
-/*             [scale-x        skew-x          trans-x]   [X]   [X']
-               [skew-y         scale-y         trans-y] * [Y] = [Y']
-               [persp-0        persp-1         persp-2]   [1]   [1 ]
+/*      [scale-x    skew-x      trans-x]   [X]   [X']
+        [skew-y     scale-y     trans-y] * [Y] = [Y']
+        [persp-0    persp-1     persp-2]   [1]   [1 ]
 */
 
-enum {
-       kMScaleX,
-       kMSkewX,
-       kMTransX,
-       kMSkewY,
-       kMScaleY,
-       kMTransY,
-       kMPersp0,
-       kMPersp1,
-       kMPersp2
-};
-
 void SkMatrix::reset()
 {
-       fMat[kMScaleX] = fMat[kMScaleY] = SK_Scalar1;
-       fMat[kMSkewX]  = fMat[kMSkewY] = 
-       fMat[kMTransX] = fMat[kMTransY] =
-       fMat[kMPersp0] = fMat[kMPersp1] = 0;
-       fMat[kMPersp2] = kMatrix22Elem;
+    fMat[kMScaleX] = fMat[kMScaleY] = SK_Scalar1;
+    fMat[kMSkewX]  = fMat[kMSkewY] = 
+    fMat[kMTransX] = fMat[kMTransY] =
+    fMat[kMPersp0] = fMat[kMPersp1] = 0;
+    fMat[kMPersp2] = kMatrix22Elem;
 }
 
 static inline int has_perspective(const SkScalar mat[9])
 {
 #ifdef SK_SCALAR_IS_FLOAT
-       return mat[kMPersp0] || mat[kMPersp1] || mat[kMPersp2] != kMatrix22Elem;
+    return mat[SkMatrix::kMPersp0] || mat[SkMatrix::kMPersp1] || mat[SkMatrix::kMPersp2] != kMatrix22Elem;
 #else
-       return mat[kMPersp0] | mat[kMPersp1] | (mat[kMPersp2] - kMatrix22Elem);
+    return mat[SkMatrix::kMPersp0] | mat[SkMatrix::kMPersp1] | (mat[SkMatrix::kMPersp2] - kMatrix22Elem);
 #endif
 }
 
+// this guy aligns with the masks, so we can compute a mask from a varaible 0/1
+enum {
+    kTranslate_Shift,
+    kScale_Shift,
+    kAffine_Shift,
+    kPerspective_Shift
+};
+
 SkMatrix::TypeMask SkMatrix::getType() const
 {
-       unsigned type = 0;
+    unsigned type = 0;
 
-       type |= (fMat[kMPersp0] || fMat[kMPersp1] || fMat[kMPersp2] != kMatrix22Elem) << kPerspective_Shift;
-       type |= (fMat[kMSkewX] || fMat[kMSkewY]) << kAffine_Shift;
-       type |= (fMat[kMScaleX] != SK_Scalar1 || fMat[kMScaleY] != SK_Scalar1) << kScale_Shift;
-       type |= (fMat[kMTransX] || fMat[kMTransY]) << kTranslate_Shift;
+    type |= (fMat[kMPersp0] || fMat[kMPersp1] || fMat[kMPersp2] != kMatrix22Elem) << kPerspective_Shift;
+    type |= (fMat[kMSkewX] || fMat[kMSkewY]) << kAffine_Shift;
+    type |= (fMat[kMScaleX] != SK_Scalar1 || fMat[kMScaleY] != SK_Scalar1) << kScale_Shift;
+    type |= (fMat[kMTransX] || fMat[kMTransY]) << kTranslate_Shift;
 
-       return (TypeMask)type;
+    return (TypeMask)type;
 }
 
 static inline bool is_identity(const SkScalar fMat[9])
 {
 #ifdef SK_SCALAR_IS_FLOAT
-       return  fMat[kMPersp0] == 0 && fMat[kMPersp1] == 0 && fMat[kMPersp2] == kMatrix22Elem &&
-                       fMat[kMSkewX] == 0 && fMat[kMSkewY] == 0 && fMat[kMTransX] == 0 && fMat[kMTransY] == 0 &&
-                       fMat[kMScaleX] == SK_Scalar1 && fMat[kMScaleY] == SK_Scalar1;
+    return  fMat[SkMatrix::kMPersp0] == 0 && fMat[SkMatrix::kMPersp1] == 0 && fMat[SkMatrix::kMPersp2] == kMatrix22Elem &&
+            fMat[SkMatrix::kMSkewX] == 0 && fMat[SkMatrix::kMSkewY] == 0 && fMat[SkMatrix::kMTransX] == 0 && fMat[SkMatrix::kMTransY] == 0 &&
+            fMat[SkMatrix::kMScaleX] == SK_Scalar1 && fMat[SkMatrix::kMScaleY] == SK_Scalar1;
 #else
-       return  !(fMat[kMPersp0] | fMat[kMPersp1] | (fMat[kMPersp2] - kMatrix22Elem) |
-                         fMat[kMSkewX] | fMat[kMSkewY] | fMat[kMTransX] | fMat[kMTransY] |
-                         (fMat[kMScaleX] - SK_Scalar1) | (fMat[kMScaleY] - SK_Scalar1));
+    return  !(fMat[SkMatrix::kMPersp0] | fMat[SkMatrix::kMPersp1] | (fMat[SkMatrix::kMPersp2] - kMatrix22Elem) |
+              fMat[SkMatrix::kMSkewX] | fMat[SkMatrix::kMSkewY] | fMat[SkMatrix::kMTransX] | fMat[SkMatrix::kMTransY] |
+              (fMat[SkMatrix::kMScaleX] - SK_Scalar1) | (fMat[SkMatrix::kMScaleY] - SK_Scalar1));
 #endif
 }
 
 bool SkMatrix::isIdentity() const
 {
-       return is_identity(fMat);
+    return is_identity(fMat);
 }
 
 ////////////////////////////////////////////////////////////////////////////////////
 
 void SkMatrix::setTranslate(SkScalar dx, SkScalar dy)
 {
-       fMat[kMTransX] = dx;
-       fMat[kMTransY] = dy;
+    fMat[kMTransX] = dx;
+    fMat[kMTransY] = dy;
 
-       fMat[kMScaleX] = fMat[kMScaleY] = SK_Scalar1;
-       fMat[kMSkewX]  = fMat[kMSkewY] = 
-       fMat[kMPersp0] = fMat[kMPersp1] = 0;
-       fMat[kMPersp2] = kMatrix22Elem;
+    fMat[kMScaleX] = fMat[kMScaleY] = SK_Scalar1;
+    fMat[kMSkewX]  = fMat[kMSkewY] = 
+    fMat[kMPersp0] = fMat[kMPersp1] = 0;
+    fMat[kMPersp2] = kMatrix22Elem;
 }
 
 bool SkMatrix::preTranslate(SkScalar dx, SkScalar dy)
 {
-       if (has_perspective(fMat))
-       {
-               SkMatrix        m;
-               m.setTranslate(dx, dy);
-               return this->preConcat(m);
-       }
-       else
-       {
-               fMat[kMTransX] += SkScalarMul(fMat[kMScaleX], dx) + SkScalarMul(fMat[kMSkewX], dy);
-               fMat[kMTransY] += SkScalarMul(fMat[kMSkewY], dx) + SkScalarMul(fMat[kMScaleY], dy);
-               return true;
-       }
+    if (has_perspective(fMat))
+    {
+        SkMatrix    m;
+        m.setTranslate(dx, dy);
+        return this->preConcat(m);
+    }
+    else
+    {
+        fMat[kMTransX] += SkScalarMul(fMat[kMScaleX], dx) + SkScalarMul(fMat[kMSkewX], dy);
+        fMat[kMTransY] += SkScalarMul(fMat[kMSkewY], dx) + SkScalarMul(fMat[kMScaleY], dy);
+        return true;
+    }
 }
 
 bool SkMatrix::postTranslate(SkScalar dx, SkScalar dy)
 {
-       if (has_perspective(fMat))
-       {
-               SkMatrix        m;
-               m.setTranslate(dx, dy);
-               return this->postConcat(m);
-       }
-       else
-       {
-               fMat[kMTransX] += dx;
-               fMat[kMTransY] += dy;
-               return true;
-       }
+    if (has_perspective(fMat))
+    {
+        SkMatrix    m;
+        m.setTranslate(dx, dy);
+        return this->postConcat(m);
+    }
+    else
+    {
+        fMat[kMTransX] += dx;
+        fMat[kMTransY] += dy;
+        return true;
+    }
 }
 
 ////////////////////////////////////////////////////////////////////////////////////
 
 void SkMatrix::setScale(SkScalar sx, SkScalar sy, SkScalar px, SkScalar py)
 {
-       fMat[kMScaleX] = sx;
-       fMat[kMScaleY] = sy;
-       fMat[kMTransX] = px - SkScalarMul(sx, px);
-       fMat[kMTransY] = py - SkScalarMul(sy, py);
-
-       fMat[kMSkewX]  = fMat[kMSkewY] = 
-       fMat[kMPersp0] = fMat[kMPersp1] = 0;
-       fMat[kMPersp2] = kMatrix22Elem;
+    fMat[kMScaleX] = sx;
+    fMat[kMScaleY] = sy;
+    fMat[kMTransX] = px - SkScalarMul(sx, px);
+    fMat[kMTransY] = py - SkScalarMul(sy, py);
+    fMat[kMPersp2] = kMatrix22Elem;
+
+    fMat[kMSkewX]  = fMat[kMSkewY] = 
+    fMat[kMPersp0] = fMat[kMPersp1] = 0;
+}
+
+void SkMatrix::setScale(SkScalar sx, SkScalar sy)
+{
+    fMat[kMScaleX] = sx;
+    fMat[kMScaleY] = sy;
+    fMat[kMPersp2] = kMatrix22Elem;
+
+    fMat[kMTransX] = fMat[kMTransY] =
+    fMat[kMSkewX]  = fMat[kMSkewY] = 
+    fMat[kMPersp0] = fMat[kMPersp1] = 0;
 }
 
 bool SkMatrix::preScale(SkScalar sx, SkScalar sy, SkScalar px, SkScalar py)
 {
-       SkMatrix        m;
-       m.setScale(sx, sy, px, py);
-       return this->preConcat(m);
+    SkMatrix    m;
+    m.setScale(sx, sy, px, py);
+    return this->preConcat(m);
+}
+
+bool SkMatrix::preScale(SkScalar sx, SkScalar sy)
+{
+    SkMatrix    m;
+    m.setScale(sx, sy);
+    return this->preConcat(m);
 }
 
 bool SkMatrix::postScale(SkScalar sx, SkScalar sy, SkScalar px, SkScalar py)
 {
-       SkMatrix        m;
-       m.setScale(sx, sy, px, py);
-       return this->postConcat(m);
+    SkMatrix    m;
+    m.setScale(sx, sy, px, py);
+    return this->postConcat(m);
+}
+
+bool SkMatrix::postScale(SkScalar sx, SkScalar sy)
+{
+    SkMatrix    m;
+    m.setScale(sx, sy);
+    return this->postConcat(m);
+}
+
+#ifdef SK_SCALAR_IS_FIXED
+    static inline SkFixed roundidiv(SkFixed numer, int denom)
+    {
+        int ns = numer >> 31;
+        int ds = denom >> 31;
+        numer = (numer ^ ns) - ns;
+        denom = (denom ^ ds) - ds;
+        
+        SkFixed answer = (numer + (denom >> 1)) / denom;
+        int as = ns ^ ds;
+        return (answer ^ as) - as;
+    }
+#else
+    static inline float roundidiv(float numer, int denom)
+    {
+        return numer / denom;
+    }
+#endif
+
+// this guy perhaps can go away, if we have a fract/high-precision way to scale matrices
+bool SkMatrix::postIDiv(int divx, int divy)
+{
+    if (divx == 0 || divy == 0)
+        return false;
+
+    fMat[kMScaleX] = roundidiv(fMat[kMScaleX], divx);
+    fMat[kMSkewX]  = roundidiv(fMat[kMSkewX],  divx);
+    fMat[kMTransX] = roundidiv(fMat[kMTransX], divx);
+
+    fMat[kMScaleY] = roundidiv(fMat[kMScaleY], divy);
+    fMat[kMSkewY]  = roundidiv(fMat[kMSkewY],  divy);
+    fMat[kMTransY] = roundidiv(fMat[kMTransY], divy);
+
+    return true;
 }
 
 ////////////////////////////////////////////////////////////////////////////////////
 
 void SkMatrix::setSinCos(SkScalar sinV, SkScalar cosV, SkScalar px, SkScalar py)
 {
-       fMat[kMScaleX]  = cosV;
-       fMat[kMSkewX]   = -sinV;
-       fMat[kMTransX]  = SkScalarMul(sinV, py) + SkScalarMul(SK_Scalar1 - cosV, px);
+    fMat[kMScaleX]  = cosV;
+    fMat[kMSkewX]   = -sinV;
+    fMat[kMTransX]  = SkScalarMul(sinV, py) + SkScalarMul(SK_Scalar1 - cosV, px);
+
+    fMat[kMSkewY]   = sinV;
+    fMat[kMScaleY]  = cosV;
+    fMat[kMTransY]  = SkScalarMul(-sinV, px) + SkScalarMul(SK_Scalar1 - cosV, py);
+
+    fMat[kMPersp0] = fMat[kMPersp1] = 0;
+    fMat[kMPersp2] = kMatrix22Elem;
+}
+
+void SkMatrix::setSinCos(SkScalar sinV, SkScalar cosV)
+{
+    fMat[kMScaleX]  = cosV;
+    fMat[kMSkewX]   = -sinV;
+    fMat[kMTransX]  = 0;
 
-       fMat[kMSkewY]   = sinV;
-       fMat[kMScaleY]  = cosV;
-       fMat[kMTransY]  = SkScalarMul(-sinV, px) + SkScalarMul(SK_Scalar1 - cosV, py);
+    fMat[kMSkewY]   = sinV;
+    fMat[kMScaleY]  = cosV;
+    fMat[kMTransY]  = 0;
 
-       fMat[kMPersp0] = fMat[kMPersp1] = 0;
-       fMat[kMPersp2] = kMatrix22Elem;
+    fMat[kMPersp0] = fMat[kMPersp1] = 0;
+    fMat[kMPersp2] = kMatrix22Elem;
 }
 
 void SkMatrix::setRotate(SkScalar degrees, SkScalar px, SkScalar py)
 {
-       SkScalar sinV, cosV;
-       sinV = SkScalarSinCos(SkDegreesToRadians(degrees), &cosV);
-       this->setSinCos(sinV, cosV, px, py);
+    SkScalar sinV, cosV;
+    sinV = SkScalarSinCos(SkDegreesToRadians(degrees), &cosV);
+    this->setSinCos(sinV, cosV, px, py);
+}
+
+void SkMatrix::setRotate(SkScalar degrees)
+{
+    SkScalar sinV, cosV;
+    sinV = SkScalarSinCos(SkDegreesToRadians(degrees), &cosV);
+    this->setSinCos(sinV, cosV);
 }
 
 bool SkMatrix::preRotate(SkScalar degrees, SkScalar px, SkScalar py)
 {
-       SkMatrix        m;
-       m.setRotate(degrees, px, py);
-       return this->preConcat(m);
+    SkMatrix    m;
+    m.setRotate(degrees, px, py);
+    return this->preConcat(m);
+}
+
+bool SkMatrix::preRotate(SkScalar degrees)
+{
+    SkMatrix    m;
+    m.setRotate(degrees);
+    return this->preConcat(m);
 }
 
 bool SkMatrix::postRotate(SkScalar degrees, SkScalar px, SkScalar py)
 {
-       SkMatrix        m;
-       m.setRotate(degrees, px, py);
-       return this->postConcat(m);
+    SkMatrix    m;
+    m.setRotate(degrees, px, py);
+    return this->postConcat(m);
+}
+
+bool SkMatrix::postRotate(SkScalar degrees)
+{
+    SkMatrix    m;
+    m.setRotate(degrees);
+    return this->postConcat(m);
 }
 
 ////////////////////////////////////////////////////////////////////////////////////
 
 void SkMatrix::setSkew(SkScalar sx, SkScalar sy, SkScalar px, SkScalar py)
 {
-       fMat[kMScaleX]  = SK_Scalar1;
-       fMat[kMSkewX]   = sx;
-       fMat[kMTransX]  = SkScalarMul(-sx, py);
+    fMat[kMScaleX]  = SK_Scalar1;
+    fMat[kMSkewX]   = sx;
+    fMat[kMTransX]  = SkScalarMul(-sx, py);
 
-       fMat[kMSkewY]   = sy;
-       fMat[kMScaleY]  = SK_Scalar1;
-       fMat[kMTransY]  = SkScalarMul(-sy, px);
+    fMat[kMSkewY]   = sy;
+    fMat[kMScaleY]  = SK_Scalar1;
+    fMat[kMTransY]  = SkScalarMul(-sy, px);
 
-       fMat[kMPersp0] = fMat[kMPersp1] = 0;
-       fMat[kMPersp2] = kMatrix22Elem;
+    fMat[kMPersp0] = fMat[kMPersp1] = 0;
+    fMat[kMPersp2] = kMatrix22Elem;
+}
+
+void SkMatrix::setSkew(SkScalar sx, SkScalar sy)
+{
+    fMat[kMScaleX]  = SK_Scalar1;
+    fMat[kMSkewX]   = sx;
+    fMat[kMTransX]  = 0;
+
+    fMat[kMSkewY]   = sy;
+    fMat[kMScaleY]  = SK_Scalar1;
+    fMat[kMTransY]  = 0;
+
+    fMat[kMPersp0] = fMat[kMPersp1] = 0;
+    fMat[kMPersp2] = kMatrix22Elem;
 }
 
 bool SkMatrix::preSkew(SkScalar sx, SkScalar sy, SkScalar px, SkScalar py)
 {
-       SkMatrix        m;
-       m.setSkew(sx, sy, px, py);
-       return this->preConcat(m);
+    SkMatrix    m;
+    m.setSkew(sx, sy, px, py);
+    return this->preConcat(m);
+}
+
+bool SkMatrix::preSkew(SkScalar sx, SkScalar sy)
+{
+    SkMatrix    m;
+    m.setSkew(sx, sy);
+    return this->preConcat(m);
 }
 
 bool SkMatrix::postSkew(SkScalar sx, SkScalar sy, SkScalar px, SkScalar py)
 {
-       SkMatrix        m;
-       m.setSkew(sx, sy, px, py);
-       return this->postConcat(m);
+    SkMatrix    m;
+    m.setSkew(sx, sy, px, py);
+    return this->postConcat(m);
+}
+
+bool SkMatrix::postSkew(SkScalar sx, SkScalar sy)
+{
+    SkMatrix    m;
+    m.setSkew(sx, sy);
+    return this->postConcat(m);
 }
 
 ////////////////////////////////////////////////////////////////////////////////////
 
 bool SkMatrix::setRectToRect(const SkRect& src, const SkRect& dst, ScaleToFit align)
 {
-       if (src.isEmpty())
-       {
-               this->reset();
-               return false;
-       }
-
-       if (dst.isEmpty())
-               memset(fMat, 0, 8 * sizeof(SkScalar));
-       else
-       {
-               SkScalar        tx, sx = SkScalarDiv(dst.width(), src.width());
-               SkScalar        ty, sy = SkScalarDiv(dst.height(), src.height());
-               bool            xLarger = false;
-
-               if (align != kFill_ScaleToFit)
-               {
-                       if (sx > sy)
-                       {
-                               xLarger = true;
-                               sx = sy;
-                       }
-                       else
-                               sy = sx;
-               }
-
-               tx = dst.fLeft - SkScalarMul(src.fLeft, sx);
-               ty = dst.fTop - SkScalarMul(src.fTop, sy);
-               if (align == kCenter_ScaleToFit || align == kEnd_ScaleToFit)
-               {
-                       SkScalar diff;
-
-                       if (xLarger)
-                               diff = dst.width() - SkScalarMul(src.width(), sy);
-                       else
-                               diff = dst.height() - SkScalarMul(src.height(), sy);
-
-                       if (align == kCenter_ScaleToFit)
-                               diff = SkScalarHalf(diff);
-
-                       if (xLarger)
-                               tx += diff;
-                       else
-                               ty += diff;
-               }
-
-               fMat[kMScaleX] = sx;
-               fMat[kMScaleY] = sy;
-               fMat[kMTransX] = tx;
-               fMat[kMTransY] = ty;
-               fMat[kMSkewX]  = fMat[kMSkewY] = 
-               fMat[kMPersp0] = fMat[kMPersp1] = 0;
-       }
-       // shared cleanup
-       fMat[kMPersp2] = kMatrix22Elem;
-       return true;
+    if (src.isEmpty())
+    {
+        this->reset();
+        return false;
+    }
+
+    if (dst.isEmpty())
+        memset(fMat, 0, 8 * sizeof(SkScalar));
+    else
+    {
+        SkScalar    tx, sx = SkScalarDiv(dst.width(), src.width());
+        SkScalar    ty, sy = SkScalarDiv(dst.height(), src.height());
+        bool        xLarger = false;
+
+        if (align != kFill_ScaleToFit)
+        {
+            if (sx > sy)
+            {
+                xLarger = true;
+                sx = sy;
+            }
+            else
+                sy = sx;
+        }
+
+        tx = dst.fLeft - SkScalarMul(src.fLeft, sx);
+        ty = dst.fTop - SkScalarMul(src.fTop, sy);
+        if (align == kCenter_ScaleToFit || align == kEnd_ScaleToFit)
+        {
+            SkScalar diff;
+
+            if (xLarger)
+                diff = dst.width() - SkScalarMul(src.width(), sy);
+            else
+                diff = dst.height() - SkScalarMul(src.height(), sy);
+
+            if (align == kCenter_ScaleToFit)
+                diff = SkScalarHalf(diff);
+
+            if (xLarger)
+                tx += diff;
+            else
+                ty += diff;
+        }
+
+        fMat[kMScaleX] = sx;
+        fMat[kMScaleY] = sy;
+        fMat[kMTransX] = tx;
+        fMat[kMTransY] = ty;
+        fMat[kMSkewX]  = fMat[kMSkewY] = 
+        fMat[kMPersp0] = fMat[kMPersp1] = 0;
+    }
+    // shared cleanup
+    fMat[kMPersp2] = kMatrix22Elem;
+    return true;
 }
 
 ////////////////////////////////////////////////////////////////////////////////////
 
 #ifdef SK_SCALAR_IS_FLOAT
-       static inline int fixmuladdmul(float a, float b, float c, float d, float* result)
-       {
-               *result = a * b + c * d;
-               return true;
-       }
-       static inline int fixmuladdmulshiftmul(float a, float b, float c, float d,
-                                                                                       int /*shift not used*/, float scale, float* result)
-       {
-               *result = (a * b + c * d) * scale;
-               return true;
-       }
-       static inline float rowcol3(const float row[], const float col[])
-       {
-               return row[0] * col[0] + row[1] * col[3] + row[2] * col[6];
-       }
-       static inline int negifaddoverflows(float& result, float a, float b)
-       {
-               result = a + b;
-               return 0;
-       }
+    static inline int fixmuladdmul(float a, float b, float c, float d, float* result)
+    {
+        *result = a * b + c * d;
+        return true;
+    }
+    static inline int fixmuladdmulshiftmul(float a, float b, float c, float d,
+                                            int /*shift not used*/, float scale, float* result)
+    {
+        *result = (a * b + c * d) * scale;
+        return true;
+    }
+    static inline float rowcol3(const float row[], const float col[])
+    {
+        return row[0] * col[0] + row[1] * col[3] + row[2] * col[6];
+    }
+    static inline int negifaddoverflows(float& result, float a, float b)
+    {
+        result = a + b;
+        return 0;
+    }
 #else
-       static inline bool fixmuladdmul(SkFixed a, SkFixed b, SkFixed c, SkFixed d, SkFixed* result)
-       {
-               Sk64    tmp1, tmp2;
-               tmp1.setMul(a, b);
-               tmp2.setMul(c, d);
-               tmp1.add(tmp2);
-               if (tmp1.isFixed())
-               {
-                       *result = tmp1.getFixed();
-                       return true;
-               }
-               return false;
-       }
-       static inline bool fixmuladdmulshiftmul(SkFixed a, SkFixed b, SkFixed c, SkFixed d,
-                                                                                       int shift, SkFixed scale, SkFixed* result)
-       {
-               Sk64    tmp1, tmp2;
-               tmp1.setMul(a, b);
-               tmp2.setMul(c, d);
-               tmp1.add(tmp2);
-
-               S32     hi = SkAbs32(tmp1.fHi);
-               int     afterShift = 16;
-               if (hi >> 15)
-               {
-                       int clz = 17 - SkCLZ(hi);
-                       SkASSERT(clz > 0 && clz <= 16);
-                       afterShift -= clz;
-                       shift += clz;
-               }
-
-               tmp1.roundRight(shift + 16);
-               SkASSERT(tmp1.is32());
-
-               tmp1.setMul(tmp1.get32(), scale);
-               tmp1.roundRight(afterShift);
-               if (tmp1.is32())
-               {
-                       *result = tmp1.get32();
-                       return true;
-               }
-               return false;
-       }
-       static inline SkFixed fracmuladdmul(SkFixed a, SkFract b, SkFixed c, SkFract d)
-       {
-               Sk64    tmp1, tmp2;
-               tmp1.setMul(a, b);
-               tmp2.setMul(c, d);
-               tmp1.add(tmp2);
-               return tmp1.getFract();
-       }
-
-       static inline SkFixed rowcol3(const SkFixed row[], const SkFixed col[])
-       {
-               Sk64    tmp1, tmp2;
-
-               tmp1.setMul(row[0], col[0]);    // N * fixed
-               tmp2.setMul(row[1], col[3]);    // N * fixed
-               tmp1.add(tmp2);
-
-               tmp2.setMul(row[2], col[6]);    // N * fract
-               tmp2.roundRight(14);                    // make it fixed
-               tmp1.add(tmp2);
-
-               return tmp1.getFixed();
-       }
-       static inline int negifaddoverflows(SkFixed& result, SkFixed a, SkFixed b)
-       {
-               SkFixed c = a + b;
-               result = c;
-               SkASSERT(((c ^ a) & (c ^ b)) >= 0);
-               return (c ^ a) & (c ^ b);
-       }
+    static inline bool fixmuladdmul(SkFixed a, SkFixed b, SkFixed c, SkFixed d, SkFixed* result)
+    {
+        Sk64    tmp1, tmp2;
+        tmp1.setMul(a, b);
+        tmp2.setMul(c, d);
+        tmp1.add(tmp2);
+        if (tmp1.isFixed())
+        {
+            *result = tmp1.getFixed();
+            return true;
+        }
+        return false;
+    }
+    static inline bool fixmuladdmulshiftmul(SkFixed a, SkFixed b, SkFixed c, SkFixed d,
+                                            int shift, SkFixed scale, SkFixed* result)
+    {
+        Sk64    tmp1, tmp2;
+        tmp1.setMul(a, b);
+        tmp2.setMul(c, d);
+        tmp1.add(tmp2);
+
+        S32 hi = SkAbs32(tmp1.fHi);
+        int afterShift = 16;
+        if (hi >> 15)
+        {
+            int clz = 17 - SkCLZ(hi);
+            SkASSERT(clz > 0 && clz <= 16);
+            afterShift -= clz;
+            shift += clz;
+        }
+
+        tmp1.roundRight(shift + 16);
+        SkASSERT(tmp1.is32());
+
+        tmp1.setMul(tmp1.get32(), scale);
+        tmp1.roundRight(afterShift);
+        if (tmp1.is32())
+        {
+            *result = tmp1.get32();
+            return true;
+        }
+        return false;
+    }
+    static inline SkFixed fracmuladdmul(SkFixed a, SkFract b, SkFixed c, SkFract d)
+    {
+        Sk64    tmp1, tmp2;
+        tmp1.setMul(a, b);
+        tmp2.setMul(c, d);
+        tmp1.add(tmp2);
+        return tmp1.getFract();
+    }
+
+    static inline SkFixed rowcol3(const SkFixed row[], const SkFixed col[])
+    {
+        Sk64    tmp1, tmp2;
+
+        tmp1.setMul(row[0], col[0]);    // N * fixed
+        tmp2.setMul(row[1], col[3]);    // N * fixed
+        tmp1.add(tmp2);
+
+        tmp2.setMul(row[2], col[6]);    // N * fract
+        tmp2.roundRight(14);            // make it fixed
+        tmp1.add(tmp2);
+
+        return tmp1.getFixed();
+    }
+    static inline int negifaddoverflows(SkFixed& result, SkFixed a, SkFixed b)
+    {
+        SkFixed c = a + b;
+        result = c;
+        SkASSERT(((c ^ a) & (c ^ b)) >= 0);
+        return (c ^ a) & (c ^ b);
+    }
 #endif
 
 static void normalize_perspective(SkScalar mat[9])
 {
-       if (SkScalarAbs(mat[kMPersp2]) > kMatrix22Elem)
-       {
-               for (int i = 0; i < 9; i++)
-                       mat[i] = SkScalarHalf(mat[i]);
-       }
+    if (SkScalarAbs(mat[SkMatrix::kMPersp2]) > kMatrix22Elem)
+    {
+        for (int i = 0; i < 9; i++)
+            mat[i] = SkScalarHalf(mat[i]);
+    }
 }
 
 bool SkMatrix::setConcat(const SkMatrix& a, const SkMatrix& b)
 {
-       TypeMask        aType = a.getType();
-       TypeMask        bType = b.getType();
-
-       if (aType == kIdentity_Mask)
-               *this = b;
-       else if (bType == kIdentity_Mask)
-               *this = a;
-       else
-       {
-               SkMatrix        tmp;
-               SkMatrix*       c = this;
-
-               if (this == &a || this == &b)
-                       c = &tmp;
-
-               if ((aType | bType) & kPerspective_Mask)
-               {
-                       c->fMat[kMScaleX] = rowcol3(&a.fMat[0], &b.fMat[0]);
-                       c->fMat[kMSkewX]  = rowcol3(&a.fMat[0], &b.fMat[1]);
-                       c->fMat[kMTransX] = rowcol3(&a.fMat[0], &b.fMat[2]);
-
-                       c->fMat[kMSkewY]  = rowcol3(&a.fMat[3], &b.fMat[0]);
-                       c->fMat[kMScaleY] = rowcol3(&a.fMat[3], &b.fMat[1]);
-                       c->fMat[kMTransY] = rowcol3(&a.fMat[3], &b.fMat[2]);
-
-                       c->fMat[kMPersp0] = rowcol3(&a.fMat[6], &b.fMat[0]);
-                       c->fMat[kMPersp1] = rowcol3(&a.fMat[6], &b.fMat[1]);
-                       c->fMat[kMPersp2] = rowcol3(&a.fMat[6], &b.fMat[2]);
-
-                       normalize_perspective(c->fMat);
-               }
-               else    // not perspective
-               {
-                       if (!fixmuladdmul(a.fMat[kMScaleX], b.fMat[kMScaleX], a.fMat[kMSkewX], b.fMat[kMSkewY], &c->fMat[kMScaleX]))
-                               return false;
-                       if (!fixmuladdmul(a.fMat[kMScaleX], b.fMat[kMSkewX], a.fMat[kMSkewX], b.fMat[kMScaleY], &c->fMat[kMSkewX]))
-                               return false;
-                       if (!fixmuladdmul(a.fMat[kMScaleX], b.fMat[kMTransX], a.fMat[kMSkewX], b.fMat[kMTransY], &c->fMat[kMTransX]))
-                               return false;
-                       if (negifaddoverflows(c->fMat[kMTransX], c->fMat[kMTransX], a.fMat[kMTransX]) < 0)
-                               return false;
-
-                       if (!fixmuladdmul(a.fMat[kMSkewY], b.fMat[kMScaleX], a.fMat[kMScaleY], b.fMat[kMSkewY], &c->fMat[kMSkewY]))
-                               return false;
-                       if (!fixmuladdmul(a.fMat[kMSkewY], b.fMat[kMSkewX], a.fMat[kMScaleY], b.fMat[kMScaleY], &c->fMat[kMScaleY]))
-                               return false;
-                       if (!fixmuladdmul(a.fMat[kMSkewY], b.fMat[kMTransX], a.fMat[kMScaleY], b.fMat[kMTransY], &c->fMat[kMTransY]))
-                               return false;
-                       if (negifaddoverflows(c->fMat[kMTransY], c->fMat[kMTransY], a.fMat[kMTransY]) < 0)
-                               return false;
-
-                       c->fMat[kMPersp0] = c->fMat[kMPersp1] = 0;
-                       c->fMat[kMPersp2] = kMatrix22Elem;
-               }
-
-               if (c == &tmp)
-                       *this = tmp;
-       }
-       return true;
+    TypeMask    aType = a.getType();
+    TypeMask    bType = b.getType();
+
+    if (0 == aType)
+        *this = b;
+    else if (0 == bType)
+        *this = a;
+    else
+    {
+        SkMatrix    tmp;
+        SkMatrix*   c = this;
+
+        if (this == &a || this == &b)
+            c = &tmp;
+
+        if ((aType | bType) & kPerspective_Mask)
+        {
+            c->fMat[kMScaleX] = rowcol3(&a.fMat[0], &b.fMat[0]);
+            c->fMat[kMSkewX]  = rowcol3(&a.fMat[0], &b.fMat[1]);
+            c->fMat[kMTransX] = rowcol3(&a.fMat[0], &b.fMat[2]);
+
+            c->fMat[kMSkewY]  = rowcol3(&a.fMat[3], &b.fMat[0]);
+            c->fMat[kMScaleY] = rowcol3(&a.fMat[3], &b.fMat[1]);
+            c->fMat[kMTransY] = rowcol3(&a.fMat[3], &b.fMat[2]);
+
+            c->fMat[kMPersp0] = rowcol3(&a.fMat[6], &b.fMat[0]);
+            c->fMat[kMPersp1] = rowcol3(&a.fMat[6], &b.fMat[1]);
+            c->fMat[kMPersp2] = rowcol3(&a.fMat[6], &b.fMat[2]);
+
+            normalize_perspective(c->fMat);
+        }
+        else    // not perspective
+        {
+            if (!fixmuladdmul(a.fMat[kMScaleX], b.fMat[kMScaleX], a.fMat[kMSkewX], b.fMat[kMSkewY], &c->fMat[kMScaleX]))
+                return false;
+            if (!fixmuladdmul(a.fMat[kMScaleX], b.fMat[kMSkewX], a.fMat[kMSkewX], b.fMat[kMScaleY], &c->fMat[kMSkewX]))
+                return false;
+            if (!fixmuladdmul(a.fMat[kMScaleX], b.fMat[kMTransX], a.fMat[kMSkewX], b.fMat[kMTransY], &c->fMat[kMTransX]))
+                return false;
+            if (negifaddoverflows(c->fMat[kMTransX], c->fMat[kMTransX], a.fMat[kMTransX]) < 0)
+                return false;
+
+            if (!fixmuladdmul(a.fMat[kMSkewY], b.fMat[kMScaleX], a.fMat[kMScaleY], b.fMat[kMSkewY], &c->fMat[kMSkewY]))
+                return false;
+            if (!fixmuladdmul(a.fMat[kMSkewY], b.fMat[kMSkewX], a.fMat[kMScaleY], b.fMat[kMScaleY], &c->fMat[kMScaleY]))
+                return false;
+            if (!fixmuladdmul(a.fMat[kMSkewY], b.fMat[kMTransX], a.fMat[kMScaleY], b.fMat[kMTransY], &c->fMat[kMTransY]))
+                return false;
+            if (negifaddoverflows(c->fMat[kMTransY], c->fMat[kMTransY], a.fMat[kMTransY]) < 0)
+                return false;
+
+            c->fMat[kMPersp0] = c->fMat[kMPersp1] = 0;
+            c->fMat[kMPersp2] = kMatrix22Elem;
+        }
+
+        if (c == &tmp)
+            *this = tmp;
+    }
+    return true;
 }
 
 bool SkMatrix::preConcat(const SkMatrix& mat)
 {
-       return this->setConcat(*this, mat);
+    return this->setConcat(*this, mat);
 }
 
 bool SkMatrix::postConcat(const SkMatrix& mat)
 {
-       return this->setConcat(mat, *this);
+    return this->setConcat(mat, *this);
 }
 
 
 ////////////////////////////////////////////////////////////////////////////////////
 
 #ifdef SK_SCALAR_IS_FLOAT
-       #define SkPerspMul(a, b)                        SkScalarMul(a, b)
-       #define SkScalarMulShift(a, b, s)       SkScalarMul(a, b)
-       static float sk_inv_determinant(const float mat[9], int isPerspective, int* /* (only used in Fixed case) */)
-       {
-               double det;
-
-               if (isPerspective)
-                       det =   mat[kMScaleX] * ((double)mat[kMScaleY] * mat[kMPersp2] - (double)mat[kMTransY] * mat[kMPersp1]) +
-                                       mat[kMSkewX] * ((double)mat[kMTransY] * mat[kMPersp0] - (double)mat[kMSkewY] * mat[kMPersp2]) +
-                                       mat[kMTransX] * ((double)mat[kMSkewY] * mat[kMPersp1] - (double)mat[kMScaleY] * mat[kMPersp0]);
-               else
-                       det =   (double)mat[kMScaleX] * mat[kMScaleY] - (double)mat[kMSkewX] * mat[kMSkewY];
-
-               if (SkScalarNearlyZero((float)det))
-                       return 0;
-               return (float)(1.0 / det);
-       }
+    #define SkPerspMul(a, b)            SkScalarMul(a, b)
+    #define SkScalarMulShift(a, b, s)   SkScalarMul(a, b)
+    static float sk_inv_determinant(const float mat[9], int isPerspective, int* /* (only used in Fixed case) */)
+    {
+        double det;
+
+        if (isPerspective)
+            det =   mat[SkMatrix::kMScaleX] * ((double)mat[SkMatrix::kMScaleY] * mat[SkMatrix::kMPersp2] - (double)mat[SkMatrix::kMTransY] * mat[SkMatrix::kMPersp1]) +
+                    mat[SkMatrix::kMSkewX] * ((double)mat[SkMatrix::kMTransY] * mat[SkMatrix::kMPersp0] - (double)mat[SkMatrix::kMSkewY] * mat[SkMatrix::kMPersp2]) +
+                    mat[SkMatrix::kMTransX] * ((double)mat[SkMatrix::kMSkewY] * mat[SkMatrix::kMPersp1] - (double)mat[SkMatrix::kMScaleY] * mat[SkMatrix::kMPersp0]);
+        else
+            det =   (double)mat[SkMatrix::kMScaleX] * mat[SkMatrix::kMScaleY] - (double)mat[SkMatrix::kMSkewX] * mat[SkMatrix::kMSkewY];
+
+        if (SkScalarNearlyZero((float)det))
+            return 0;
+        return (float)(1.0 / det);
+    }
 #else
-       #define SkPerspMul(a, b)        SkFractMul(a, b)
-       #define SkScalarMulShift(a, b, s)       SkMulShift(a, b, s)
-       static void set_muladdmul(Sk64* dst, S32 a, S32 b, S32 c, S32 d)
-       {
-               Sk64    tmp;
-
-               dst->setMul(a, b);
-               tmp.setMul(c, d);
-               dst->add(tmp);
-       }
-       static SkFixed sk_inv_determinant(const SkFixed mat[9], int isPerspective, int* shift)
-       {
-               Sk64    tmp1, tmp2;
-
-               if (isPerspective)
-               {
-                       tmp1.setMul(mat[kMScaleX], fracmuladdmul(mat[kMScaleY], mat[kMPersp2], -mat[kMTransY], mat[kMPersp1]));
-                       tmp2.setMul(mat[kMSkewX], fracmuladdmul(mat[kMTransY], mat[kMPersp0], -mat[kMSkewY], mat[kMPersp2]));
-                       tmp1.add(tmp2);
-                       tmp2.setMul(mat[kMTransX], fracmuladdmul(mat[kMSkewY], mat[kMPersp1], -mat[kMScaleY], mat[kMPersp0]));
-                       tmp1.add(tmp2);
-               }
-               else
-               {
-                       tmp1.setMul(mat[kMScaleX], mat[kMScaleY]);
-                       tmp2.setMul(mat[kMSkewX], mat[kMSkewY]);
-                       tmp1.sub(tmp2);
-               }
-
-               int     s = tmp1.getClzAbs();
-               *shift = s;
-
-               SkFixed denom;
-               if (s <= 32)
-                       denom = tmp1.getShiftRight(33 - s);
-               else
-                       denom = (S32)tmp1.fLo << (s - 33);
-
-               if (denom == 0)
-                       return 0;
-               /**     This could perhaps be a special fractdiv function, since both of its
-                       arguments are known to have bit 31 clear and bit 30 set (when they
-                       are made positive), thus eliminating the need for calling clz()
-               */
-               return SkFractDiv(SK_Fract1, denom);
-       }
+    #define SkPerspMul(a, b)    SkFractMul(a, b)
+    #define SkScalarMulShift(a, b, s)   SkMulShift(a, b, s)
+    static void set_muladdmul(Sk64* dst, S32 a, S32 b, S32 c, S32 d)
+    {
+        Sk64    tmp;
+
+        dst->setMul(a, b);
+        tmp.setMul(c, d);
+        dst->add(tmp);
+    }
+    static SkFixed sk_inv_determinant(const SkFixed mat[9], int isPerspective, int* shift)
+    {
+        Sk64    tmp1, tmp2;
+
+        if (isPerspective)
+        {
+            tmp1.setMul(mat[SkMatrix::kMScaleX], fracmuladdmul(mat[SkMatrix::kMScaleY], mat[SkMatrix::kMPersp2], -mat[SkMatrix::kMTransY], mat[SkMatrix::kMPersp1]));
+            tmp2.setMul(mat[SkMatrix::kMSkewX], fracmuladdmul(mat[SkMatrix::kMTransY], mat[SkMatrix::kMPersp0], -mat[SkMatrix::kMSkewY], mat[SkMatrix::kMPersp2]));
+            tmp1.add(tmp2);
+            tmp2.setMul(mat[SkMatrix::kMTransX], fracmuladdmul(mat[SkMatrix::kMSkewY], mat[SkMatrix::kMPersp1], -mat[SkMatrix::kMScaleY], mat[SkMatrix::kMPersp0]));
+            tmp1.add(tmp2);
+        }
+        else
+        {
+            tmp1.setMul(mat[SkMatrix::kMScaleX], mat[SkMatrix::kMScaleY]);
+            tmp2.setMul(mat[SkMatrix::kMSkewX], mat[SkMatrix::kMSkewY]);
+            tmp1.sub(tmp2);
+        }
+
+        int s = tmp1.getClzAbs();
+        *shift = s;
+
+        SkFixed denom;
+        if (s <= 32)
+            denom = tmp1.getShiftRight(33 - s);
+        else
+            denom = (S32)tmp1.fLo << (s - 33);
+
+        if (denom == 0)
+            return 0;
+        /** This could perhaps be a special fractdiv function, since both of its
+            arguments are known to have bit 31 clear and bit 30 set (when they
+            are made positive), thus eliminating the need for calling clz()
+        */
+        return SkFractDiv(SK_Fract1, denom);
+    }
 #endif
 
 bool SkMatrix::invert(SkMatrix* inv) const
 {
-       int                     isPersp = has_perspective(fMat);
-       int                     shift;
-       SkScalar        scale = sk_inv_determinant(fMat, isPersp, &shift);
-
-       if (scale == 0) // underflow
-               return false;
-
-       if (inv)
-       {
-               SkMatrix tmp;
-               if (inv == this)
-                       inv = &tmp;
-
-               if (isPersp)
-               {
-                       shift = 61 - shift;
-                       inv->fMat[kMScaleX] = SkScalarMulShift(SkPerspMul(fMat[kMScaleY], fMat[kMPersp2]) - SkPerspMul(fMat[kMTransY], fMat[kMPersp1]), scale, shift);
-                       inv->fMat[kMSkewX]  = SkScalarMulShift(SkPerspMul(fMat[kMTransX], fMat[kMPersp1]) - SkPerspMul(fMat[kMSkewX],  fMat[kMPersp2]), scale, shift);
-                       inv->fMat[kMTransX] = SkScalarMulShift(SkScalarMul(fMat[kMSkewX], fMat[kMTransY]) - SkScalarMul(fMat[kMTransX], fMat[kMScaleY]), scale, shift);
-
-                       inv->fMat[kMSkewY]  = SkScalarMulShift(SkPerspMul(fMat[kMTransY], fMat[kMPersp0]) - SkPerspMul(fMat[kMSkewY],   fMat[kMPersp2]), scale, shift);
-                       inv->fMat[kMScaleY] = SkScalarMulShift(SkPerspMul(fMat[kMScaleX], fMat[kMPersp2]) - SkPerspMul(fMat[kMTransX],  fMat[kMPersp0]), scale, shift);
-                       inv->fMat[kMTransY] = SkScalarMulShift(SkScalarMul(fMat[kMTransX], fMat[kMSkewY]) - SkScalarMul(fMat[kMScaleX], fMat[kMTransY]), scale, shift);
-
-                       inv->fMat[kMPersp0] = SkScalarMulShift(SkScalarMul(fMat[kMSkewY], fMat[kMPersp1]) - SkScalarMul(fMat[kMScaleY], fMat[kMPersp0]), scale, shift);                         
-                       inv->fMat[kMPersp1] = SkScalarMulShift(SkScalarMul(fMat[kMSkewX], fMat[kMPersp0]) - SkScalarMul(fMat[kMScaleX], fMat[kMPersp1]), scale, shift);
-                       inv->fMat[kMPersp2] = SkScalarMulShift(SkScalarMul(fMat[kMScaleX], fMat[kMScaleY]) - SkScalarMul(fMat[kMSkewX], fMat[kMSkewY]), scale, shift);
+    int         isPersp = has_perspective(fMat);
+    int         shift;
+    SkScalar    scale = sk_inv_determinant(fMat, isPersp, &shift);
+
+    if (scale == 0) // underflow
+        return false;
+
+    if (inv)
+    {
+        SkMatrix tmp;
+        if (inv == this)
+            inv = &tmp;
+
+        if (isPersp)
+        {
+            shift = 61 - shift;
+            inv->fMat[kMScaleX] = SkScalarMulShift(SkPerspMul(fMat[kMScaleY], fMat[kMPersp2]) - SkPerspMul(fMat[kMTransY], fMat[kMPersp1]), scale, shift);
+            inv->fMat[kMSkewX]  = SkScalarMulShift(SkPerspMul(fMat[kMTransX], fMat[kMPersp1]) - SkPerspMul(fMat[kMSkewX],  fMat[kMPersp2]), scale, shift);
+            inv->fMat[kMTransX] = SkScalarMulShift(SkScalarMul(fMat[kMSkewX], fMat[kMTransY]) - SkScalarMul(fMat[kMTransX], fMat[kMScaleY]), scale, shift);
+
+            inv->fMat[kMSkewY]  = SkScalarMulShift(SkPerspMul(fMat[kMTransY], fMat[kMPersp0]) - SkPerspMul(fMat[kMSkewY],   fMat[kMPersp2]), scale, shift);
+            inv->fMat[kMScaleY] = SkScalarMulShift(SkPerspMul(fMat[kMScaleX], fMat[kMPersp2]) - SkPerspMul(fMat[kMTransX],  fMat[kMPersp0]), scale, shift);
+            inv->fMat[kMTransY] = SkScalarMulShift(SkScalarMul(fMat[kMTransX], fMat[kMSkewY]) - SkScalarMul(fMat[kMScaleX], fMat[kMTransY]), scale, shift);
+
+            inv->fMat[kMPersp0] = SkScalarMulShift(SkScalarMul(fMat[kMSkewY], fMat[kMPersp1]) - SkScalarMul(fMat[kMScaleY], fMat[kMPersp0]), scale, shift);             
+            inv->fMat[kMPersp1] = SkScalarMulShift(SkScalarMul(fMat[kMSkewX], fMat[kMPersp0]) - SkScalarMul(fMat[kMScaleX], fMat[kMPersp1]), scale, shift);
+            inv->fMat[kMPersp2] = SkScalarMulShift(SkScalarMul(fMat[kMScaleX], fMat[kMScaleY]) - SkScalarMul(fMat[kMSkewX], fMat[kMSkewY]), scale, shift);
 #ifdef SK_SCALAR_IS_FIXED
-                       if (SkAbs32(inv->fMat[kMPersp2]) > SK_Fixed1)
-                       {
-                               Sk64    tmp;
+            if (SkAbs32(inv->fMat[kMPersp2]) > SK_Fixed1)
+            {
+                Sk64    tmp;
 
-                               tmp.set(SK_Fract1);
-                               tmp.shiftLeft(16);
-                               tmp.div(inv->fMat[kMPersp2], Sk64::kRound_DivOption);
+                tmp.set(SK_Fract1);
+                tmp.shiftLeft(16);
+                tmp.div(inv->fMat[kMPersp2], Sk64::kRound_DivOption);
 
-                               SkFract scale = tmp.get32();
+                SkFract scale = tmp.get32();
 
-                               for (int i = 0; i < 9; i++)
-                                       inv->fMat[i] = SkFractMul(inv->fMat[i], scale);
-                       }
-                       inv->fMat[kMPersp2] = SkFixedToFract(inv->fMat[kMPersp2]);
+                for (int i = 0; i < 9; i++)
+                    inv->fMat[i] = SkFractMul(inv->fMat[i], scale);
+            }
+            inv->fMat[kMPersp2] = SkFixedToFract(inv->fMat[kMPersp2]);
 #endif
-               }
-               else    // not perspective
-               {
+        }
+        else    // not perspective
+        {
 #ifdef SK_SCALAR_IS_FIXED
-                       Sk64    tx, ty;
-                       int             clzNumer;
-
-                       // check the 2x2 for overflow
-                       {
-                               S32     value = SkAbs32(fMat[kMScaleY]);
-                               value |= SkAbs32(fMat[kMSkewX]);
-                               value |= SkAbs32(fMat[kMScaleX]);
-                               value |= SkAbs32(fMat[kMSkewY]);
-                               clzNumer = SkCLZ(value);
-                               if (shift - clzNumer > 31)
-                                       return false;   // overflow
-                       }
-
-                       set_muladdmul(&tx, fMat[kMSkewX], fMat[kMTransY], -fMat[kMScaleY], fMat[kMTransX]);
-                       set_muladdmul(&ty, fMat[kMSkewY], fMat[kMTransX], -fMat[kMScaleX], fMat[kMTransY]);
-                       // check tx,ty for overflow
-                       clzNumer = SkCLZ(SkAbs32(tx.fHi) | SkAbs32(ty.fHi));
-                       if (shift - clzNumer > 14)
-                               return false;   // overflow
-
-                       int fixedShift = 61 - shift;
-                       int sk64shift = 44 - shift + clzNumer;
-
-                       inv->fMat[kMScaleX] = SkMulShift(fMat[kMScaleY], scale, fixedShift);
-                       inv->fMat[kMSkewX]  = SkMulShift(-fMat[kMSkewX], scale, fixedShift);
-                       inv->fMat[kMTransX] = SkMulShift(tx.getShiftRight(33 - clzNumer), scale, sk64shift);
-                               
-                       inv->fMat[kMSkewY]  = SkMulShift(-fMat[kMSkewY], scale, fixedShift);
-                       inv->fMat[kMScaleY] = SkMulShift(fMat[kMScaleX], scale, fixedShift);
-                       inv->fMat[kMTransY] = SkMulShift(ty.getShiftRight(33 - clzNumer), scale, sk64shift);
+            Sk64    tx, ty;
+            int     clzNumer;
+
+            // check the 2x2 for overflow
+            {
+                S32 value = SkAbs32(fMat[kMScaleY]);
+                value |= SkAbs32(fMat[kMSkewX]);
+                value |= SkAbs32(fMat[kMScaleX]);
+                value |= SkAbs32(fMat[kMSkewY]);
+                clzNumer = SkCLZ(value);
+                if (shift - clzNumer > 31)
+                    return false;   // overflow
+            }
+
+            set_muladdmul(&tx, fMat[kMSkewX], fMat[kMTransY], -fMat[kMScaleY], fMat[kMTransX]);
+            set_muladdmul(&ty, fMat[kMSkewY], fMat[kMTransX], -fMat[kMScaleX], fMat[kMTransY]);
+            // check tx,ty for overflow
+            clzNumer = SkCLZ(SkAbs32(tx.fHi) | SkAbs32(ty.fHi));
+            if (shift - clzNumer > 14)
+                return false;   // overflow
+
+            int fixedShift = 61 - shift;
+            int sk64shift = 44 - shift + clzNumer;
+
+            inv->fMat[kMScaleX] = SkMulShift(fMat[kMScaleY], scale, fixedShift);
+            inv->fMat[kMSkewX]  = SkMulShift(-fMat[kMSkewX], scale, fixedShift);
+            inv->fMat[kMTransX] = SkMulShift(tx.getShiftRight(33 - clzNumer), scale, sk64shift);
+                
+            inv->fMat[kMSkewY]  = SkMulShift(-fMat[kMSkewY], scale, fixedShift);
+            inv->fMat[kMScaleY] = SkMulShift(fMat[kMScaleX], scale, fixedShift);
+            inv->fMat[kMTransY] = SkMulShift(ty.getShiftRight(33 - clzNumer), scale, sk64shift);
 #else
-                       inv->fMat[kMScaleX] = SkScalarMul(fMat[kMScaleY], scale);
-                       inv->fMat[kMSkewX] = SkScalarMul(-fMat[kMSkewX], scale);
-                       if (!fixmuladdmulshiftmul(fMat[kMSkewX], fMat[kMTransY], -fMat[kMScaleY], fMat[kMTransX], shift, scale, &inv->fMat[kMTransX]))
-                               return false;
-                               
-                       inv->fMat[kMSkewY] = SkScalarMul(-fMat[kMSkewY], scale);
-                       inv->fMat[kMScaleY] = SkScalarMul(fMat[kMScaleX], scale);
-                       if (!fixmuladdmulshiftmul(fMat[kMSkewY], fMat[kMTransX], -fMat[kMScaleX], fMat[kMTransY], shift, scale, &inv->fMat[kMTransY]))
-                               return false;
+            inv->fMat[kMScaleX] = SkScalarMul(fMat[kMScaleY], scale);
+            inv->fMat[kMSkewX] = SkScalarMul(-fMat[kMSkewX], scale);
+            if (!fixmuladdmulshiftmul(fMat[kMSkewX], fMat[kMTransY], -fMat[kMScaleY], fMat[kMTransX], shift, scale, &inv->fMat[kMTransX]))
+                return false;
+                
+            inv->fMat[kMSkewY] = SkScalarMul(-fMat[kMSkewY], scale);
+            inv->fMat[kMScaleY] = SkScalarMul(fMat[kMScaleX], scale);
+            if (!fixmuladdmulshiftmul(fMat[kMSkewY], fMat[kMTransX], -fMat[kMScaleX], fMat[kMTransY], shift, scale, &inv->fMat[kMTransY]))
+                return false;
 #endif
-                       inv->fMat[kMPersp0] = 0;
-                       inv->fMat[kMPersp1] = 0;
-                       inv->fMat[kMPersp2] = kMatrix22Elem;
-               }
-
-               if (inv == &tmp)
-                       *(SkMatrix*)this = tmp;
-       }
-       return true;
+            inv->fMat[kMPersp0] = 0;
+            inv->fMat[kMPersp1] = 0;
+            inv->fMat[kMPersp2] = kMatrix22Elem;
+        }
+
+        if (inv == &tmp)
+            *(SkMatrix*)this = tmp;
+    }
+    return true;
 }
 
 ////////////////////////////////////////////////////////////////////////////////////
 
 bool SkMatrix::mapPoints(SkPoint dst[], const SkPoint src[], int count, TypeMask typeMask) const
 {
-       SkASSERT(dst && src && count > 0 || count == 0);
-       SkASSERT(src == dst || SkAbs32((S32)(src - dst)) >= count);     // no partial overlap
+    SkASSERT(dst && src && count > 0 || count == 0);
+    SkASSERT(src == dst || SkAbs32((S32)(src - dst)) >= count); // no partial overlap
 
-       if (count <= 0)
-               return true;
+    if (count <= 0)
+        return true;
 
-       bool ok = true;
+    bool ok = true;
 
-       if (typeMask & kPerspective_Mask)
-       {
+    if (typeMask & kPerspective_Mask)
+    {
 #ifdef SK_SCALAR_IS_FIXED
-               SkFixed persp2 = SkFractToFixed(fMat[kMPersp2]);
+        SkFixed persp2 = SkFractToFixed(fMat[kMPersp2]);
 #endif
-               for (int i = count - 1; i >= 0; --i)
-               {
-                       SkScalar sx = src[i].fX;
-                       SkScalar sy = src[i].fY;
-                       SkScalar x = SkScalarMul(sx, fMat[kMScaleX]) + SkScalarMul(sy, fMat[kMSkewX]) + fMat[kMTransX];
-                       SkScalar y = SkScalarMul(sx, fMat[kMSkewY]) + SkScalarMul(sy, fMat[kMScaleY]) + fMat[kMTransY];
+        for (int i = count - 1; i >= 0; --i)
+        {
+            SkScalar sx = src[i].fX;
+            SkScalar sy = src[i].fY;
+            SkScalar x = SkScalarMul(sx, fMat[kMScaleX]) + SkScalarMul(sy, fMat[kMSkewX]) + fMat[kMTransX];
+            SkScalar y = SkScalarMul(sx, fMat[kMSkewY]) + SkScalarMul(sy, fMat[kMScaleY]) + fMat[kMTransY];
 #ifdef SK_SCALAR_IS_FIXED
-                       SkFixed z = SkFractMul(sx, fMat[kMPersp0]) + SkFractMul(sy, fMat[kMPersp1]) + persp2;
+            SkFixed z = SkFractMul(sx, fMat[kMPersp0]) + SkFractMul(sy, fMat[kMPersp1]) + persp2;
 #else
-                       float z = SkScalarMul(sx, fMat[kMPersp0]) + SkScalarMul(sy, fMat[kMPersp1]) + fMat[kMPersp2];
+            float z = SkScalarMul(sx, fMat[kMPersp0]) + SkScalarMul(sy, fMat[kMPersp1]) + fMat[kMPersp2];
 #endif
-                       if (z)
-                               z = SkScalarInvert(z);
-                       dst[i].fX = SkScalarMul(x, z);
-                       dst[i].fY = SkScalarMul(y, z);
-               }
-       }
-       else if (typeMask & kAffine_Mask)
-       {
-               for (int i = count - 1; i >= 0; --i)
-               {
-                       SkScalar sx = src[i].fX;
-                       SkScalar sy = src[i].fY;
-                       dst[i].fX = SkScalarMul(sx, fMat[kMScaleX]) + SkScalarMul(sy, fMat[kMSkewX]) + fMat[kMTransX];
-                       dst[i].fY = SkScalarMul(sx, fMat[kMSkewY]) + SkScalarMul(sy, fMat[kMScaleY]) + fMat[kMTransY];
-               }
-       }
-       else if (typeMask & kScale_Mask)
-       {
-               for (int i = count - 1; i >= 0; --i)
-               {
-                       dst[i].fX = SkScalarMul(src[i].fX, fMat[kMScaleX]) + fMat[kMTransX];
-                       dst[i].fY = SkScalarMul(src[i].fY, fMat[kMScaleY]) + fMat[kMTransY];
-               }
-       }
-       else if (typeMask & kTranslate_Mask)
-       {
-               for (int i = count - 1; i >= 0; --i)
-               {
-                       dst[i].fX = src[i].fX + fMat[kMTransX];
-                       dst[i].fY = src[i].fY + fMat[kMTransY];
-               }
-       }
-       else
-       {
-               SkASSERT(typeMask == 0);
-               if (dst != src)
-                       memcpy(dst, src, count * sizeof(SkPoint));
-       }
-       return ok;
+            if (z)
+                z = SkScalarFastInvert(z);
+            dst[i].fX = SkScalarMul(x, z);
+            dst[i].fY = SkScalarMul(y, z);
+        }
+    }
+    else if (typeMask & kAffine_Mask)
+    {
+        for (int i = count - 1; i >= 0; --i)
+        {
+            SkScalar sx = src[i].fX;
+            SkScalar sy = src[i].fY;
+            dst[i].fX = SkScalarMul(sx, fMat[kMScaleX]) + SkScalarMul(sy, fMat[kMSkewX]) + fMat[kMTransX];
+            dst[i].fY = SkScalarMul(sx, fMat[kMSkewY]) + SkScalarMul(sy, fMat[kMScaleY]) + fMat[kMTransY];
+        }
+    }
+    else if (typeMask & kScale_Mask)
+    {
+        for (int i = count - 1; i >= 0; --i)
+        {
+            dst[i].fX = SkScalarMul(src[i].fX, fMat[kMScaleX]) + fMat[kMTransX];
+            dst[i].fY = SkScalarMul(src[i].fY, fMat[kMScaleY]) + fMat[kMTransY];
+        }
+    }
+    else if (typeMask & kTranslate_Mask)
+    {
+        for (int i = count - 1; i >= 0; --i)
+        {
+            dst[i].fX = src[i].fX + fMat[kMTransX];
+            dst[i].fY = src[i].fY + fMat[kMTransY];
+        }
+    }
+    else
+    {
+        SkASSERT(typeMask == 0);
+        if (dst != src)
+            memcpy(dst, src, count * sizeof(SkPoint));
+    }
+    return ok;
 }
 
 bool SkMatrix::mapVectors(SkPoint dst[], const SkPoint src[], int count, TypeMask maskType) const
 {
-       bool ok;
-
-       if (maskType & kPerspective_Mask)
-       {
-               SkPoint origin;
-
-               origin.set(0, 0);
-               ok = this->mapPoints(&origin, &origin, 1, maskType);
-
-               for (int i = count - 1; i >= 0; --i)
-               {
-                       SkPoint tmp;
-
-                       ok &= this->mapPoints(&tmp, &src[i], 1, maskType);
-                       dst[i].set(tmp.fX - origin.fX, tmp.fY - origin.fY);
-               }
-       }
-       else
-       {
-               SkMatrix tmp = *this;
-
-               tmp.fMat[kMTransX] = tmp.fMat[kMTransY] = 0;
-               ok = tmp.mapPoints(dst, src, count, maskType);
-       }
-       return ok;
+    bool ok;
+
+    if (maskType & kPerspective_Mask)
+    {
+        SkPoint origin;
+
+        origin.set(0, 0);
+        ok = this->mapPoints(&origin, &origin, 1, maskType);
+
+        for (int i = count - 1; i >= 0; --i)
+        {
+            SkPoint tmp;
+
+            ok &= this->mapPoints(&tmp, &src[i], 1, maskType);
+            dst[i].set(tmp.fX - origin.fX, tmp.fY - origin.fY);
+        }
+    }
+    else
+    {
+        SkMatrix tmp = *this;
+
+        tmp.fMat[kMTransX] = tmp.fMat[kMTransY] = 0;
+        ok = tmp.mapPoints(dst, src, count, maskType);
+    }
+    return ok;
 }
 
 bool SkMatrix::mapRect(SkRect* dst, const SkRect& src, TypeMask maskType) const
 {
-       SkASSERT(dst && &src);
-
-       bool ok;
-
-       if (RectStaysRect(maskType))
-       {
-               ok = this->mapPoints((SkPoint*)dst, (const SkPoint*)&src, 2, maskType);
-               dst->sort();
-       }
-       else
-       {
-               SkPoint quad[4];
-
-               src.toQuad(quad);
-               ok = this->mapPoints(quad, quad, 4, maskType);
-               dst->set(quad, 4);
-       }
-       return ok;
+    SkASSERT(dst && &src);
+
+    bool ok;
+
+    if (RectStaysRect(maskType))
+    {
+        ok = this->mapPoints((SkPoint*)dst, (const SkPoint*)&src, 2, maskType);
+        dst->sort();
+    }
+    else
+    {
+        SkPoint quad[4];
+
+        src.toQuad(quad);
+        ok = this->mapPoints(quad, quad, 4, maskType);
+        dst->set(quad, 4);
+    }
+    return ok;
 }
 
 SkScalar SkMatrix::mapRadius(SkScalar radius) const
 {
-       SkVector        vec[2];
+    SkVector    vec[2];
 
-       vec[0].set(radius, 0);
-       vec[1].set(0, radius);
-       this->mapVectors(vec, 2);
+    vec[0].set(radius, 0);
+    vec[1].set(0, radius);
+    this->mapVectors(vec, 2);
 
-       SkScalar d0 = vec[0].length();
-       SkScalar d1 = vec[1].length();
+    SkScalar d0 = vec[0].length();
+    SkScalar d1 = vec[1].length();
 
-       return SkScalarMean(d0, d1);
+    return SkScalarMean(d0, d1);
 }
 
 //////////////////////////////////////////////////////////////////////////////////////////
 
 void SkMatrix::Perspective_ptProc(const SkMatrix& m, SkScalar sx, SkScalar sy, SkPoint* pt)
 {
-       SkASSERT(m.getType() & kPerspective_Mask);
+    SkASSERT(m.getType() & kPerspective_Mask);
 
-       SkScalar x = SkScalarMul(sx, m.fMat[kMScaleX]) + SkScalarMul(sy, m.fMat[kMSkewX]) + m.fMat[kMTransX];
-       SkScalar y = SkScalarMul(sx, m.fMat[kMSkewY]) + SkScalarMul(sy, m.fMat[kMScaleY]) + m.fMat[kMTransY];
+    SkScalar x = SkScalarMul(sx, m.fMat[kMScaleX]) + SkScalarMul(sy, m.fMat[kMSkewX]) + m.fMat[kMTransX];
+    SkScalar y = SkScalarMul(sx, m.fMat[kMSkewY]) + SkScalarMul(sy, m.fMat[kMScaleY]) + m.fMat[kMTransY];
 #ifdef SK_SCALAR_IS_FIXED
-       SkFixed z = SkFractMul(sx, m.fMat[kMPersp0]) + SkFractMul(sy, m.fMat[kMPersp1]) + SkFractToFixed(m.fMat[kMPersp2]);
+    SkFixed z = SkFractMul(sx, m.fMat[kMPersp0]) + SkFractMul(sy, m.fMat[kMPersp1]) + SkFractToFixed(m.fMat[kMPersp2]);
 #else
-       float z = SkScalarMul(sx, m.fMat[kMPersp0]) + SkScalarMul(sy, m.fMat[kMPersp1]) + m.fMat[kMPersp2];
+    float z = SkScalarMul(sx, m.fMat[kMPersp0]) + SkScalarMul(sy, m.fMat[kMPersp1]) + m.fMat[kMPersp2];
 #endif
-       if (z)
-               z = SkScalarInvert(z);
-       pt->fX = SkScalarMul(x, z);
-       pt->fY = SkScalarMul(y, z);
+    if (z)
+        z = SkScalarFastInvert(z);
+    pt->fX = SkScalarMul(x, z);
+    pt->fY = SkScalarMul(y, z);
 }
 
 #ifdef SK_SCALAR_IS_FIXED
 static SkFixed fixmuladdmul(SkFixed a, SkFixed b, SkFixed c, SkFixed d)
 {
-       Sk64    tmp, tmp1;
+    Sk64    tmp, tmp1;
 
-       tmp.setMul(a, b);
-       tmp1.setMul(c, d);
-       return tmp.addGetFixed(tmp1);
-//     tmp.add(tmp1);
-//     return tmp.getFixed();
+    tmp.setMul(a, b);
+    tmp1.setMul(c, d);
+    return tmp.addGetFixed(tmp1);
+//  tmp.add(tmp1);
+//  return tmp.getFixed();
 }
 #endif
 
 void SkMatrix::Affine_ptProc(const SkMatrix& m, SkScalar sx, SkScalar sy, SkPoint* pt)
 {
-       SkASSERT((m.getType() & (kAffine_Mask | kPerspective_Mask)) == kAffine_Mask);
+    SkASSERT((m.getType() & (kAffine_Mask | kPerspective_Mask)) == kAffine_Mask);
 
 #ifdef SK_SCALAR_IS_FIXED
-       pt->fX = fixmuladdmul(sx, m.fMat[kMScaleX], sy, m.fMat[kMSkewX]) + m.fMat[kMTransX];
-       pt->fY = fixmuladdmul(sx, m.fMat[kMSkewY], sy, m.fMat[kMScaleY]) + m.fMat[kMTransY];
+    pt->fX = fixmuladdmul(sx, m.fMat[kMScaleX], sy, m.fMat[kMSkewX]) + m.fMat[kMTransX];
+    pt->fY = fixmuladdmul(sx, m.fMat[kMSkewY], sy, m.fMat[kMScaleY]) + m.fMat[kMTransY];
 #else
-       pt->fX = SkScalarMul(sx, m.fMat[kMScaleX]) + SkScalarMul(sy, m.fMat[kMSkewX]) + m.fMat[kMTransX];
-       pt->fY = SkScalarMul(sx, m.fMat[kMSkewY]) + SkScalarMul(sy, m.fMat[kMScaleY]) + m.fMat[kMTransY];
+    pt->fX = SkScalarMul(sx, m.fMat[kMScaleX]) + SkScalarMul(sy, m.fMat[kMSkewX]) + m.fMat[kMTransX];
+    pt->fY = SkScalarMul(sx, m.fMat[kMSkewY]) + SkScalarMul(sy, m.fMat[kMScaleY]) + m.fMat[kMTransY];
 #endif
 }
 
 void SkMatrix::Scale_ptProc(const SkMatrix& m, SkScalar sx, SkScalar sy, SkPoint* pt)
 {
-       SkASSERT((m.getType() & (kScale_Mask | kAffine_Mask | kPerspective_Mask)) == kScale_Mask);
+    SkASSERT((m.getType() & (kScale_Mask | kAffine_Mask | kPerspective_Mask)) == kScale_Mask);
 
-       pt->fX = SkScalarMul(sx, m.fMat[kMScaleX]) + m.fMat[kMTransX];
-       pt->fY = SkScalarMul(sy, m.fMat[kMScaleY]) + m.fMat[kMTransY];
+    pt->fX = SkScalarMul(sx, m.fMat[kMScaleX]) + m.fMat[kMTransX];
+    pt->fY = SkScalarMul(sy, m.fMat[kMScaleY]) + m.fMat[kMTransY];
 }
 
 void SkMatrix::Translate_ptProc(const SkMatrix& m, SkScalar sx, SkScalar sy, SkPoint* pt)
 {
-       SkASSERT(m.getType() == kTranslate_Mask);
+    SkASSERT(m.getType() == kTranslate_Mask);
 
-       pt->fX = sx + m.fMat[kMTransX];
-       pt->fY = sy + m.fMat[kMTransY];
+    pt->fX = sx + m.fMat[kMTransX];
+    pt->fY = sy + m.fMat[kMTransY];
 }
 
 void SkMatrix::Identity_ptProc(const SkMatrix& m, SkScalar sx, SkScalar sy, SkPoint* pt)
 {
-       SkASSERT(m.getType() == kIdentity_Mask);
+    SkASSERT(0 == m.getType());
 
-       pt->fX = sx;
-       pt->fY = sy;
+    pt->fX = sx;
+    pt->fY = sy;
 }
 
 SkMatrix::MapPtProc SkMatrix::getMapPtProc() const
 {
-       TypeMask typeMask = this->getType();
-
-       if (typeMask & kPerspective_Mask)
-               return Perspective_ptProc;
-       if (typeMask & kAffine_Mask)
-               return Affine_ptProc;
-       if (typeMask & kScale_Mask)
-               return Scale_ptProc;
-       if (typeMask & kTranslate_Mask)
-               return Translate_ptProc;
-       return Identity_ptProc;
+    TypeMask typeMask = this->getType();
+
+    if (typeMask & kPerspective_Mask)
+        return Perspective_ptProc;
+    if (typeMask & kAffine_Mask)
+        return Affine_ptProc;
+    if (typeMask & kScale_Mask)
+        return Scale_ptProc;
+    if (typeMask & kTranslate_Mask)
+        return Translate_ptProc;
+    return Identity_ptProc;
 }
 
 //////////////////////////////////////////////////////////////////////////////////////////
 
 // if its nearly zero (just made up 24 for that, perhaps it should be bigger or smaller)
 #ifdef SK_SCALAR_IS_FIXED
-       typedef SkFract                         SkPerspElemType;
-       #define PerspNearlyZero(x)      (SkAbs32(x) < (SK_Fract1 >> 26))
+    typedef SkFract             SkPerspElemType;
+    #define PerspNearlyZero(x)  (SkAbs32(x) < (SK_Fract1 >> 26))
 #else
-       typedef float                           SkPerspElemType;
-       #define PerspNearlyZero(x)      SkScalarNearlyZero(x, (1.0f / (1 << 26)))
+    typedef float               SkPerspElemType;
+    #define PerspNearlyZero(x)  SkScalarNearlyZero(x, (1.0f / (1 << 26)))
 #endif
 
 bool SkMatrix::fixedStepInX(SkScalar y, SkFixed* stepX, SkFixed* stepY) const
 {
-       if (PerspNearlyZero(fMat[kMPersp0]))
-       {
-               if (stepX || stepY)
-               {
-                       if (PerspNearlyZero(fMat[kMPersp1]) && PerspNearlyZero(fMat[kMPersp2] - kMatrix22Elem))
-                       {
-                               if (stepX)
-                                       *stepX = SkScalarToFixed(fMat[kMScaleX]);
-                               if (stepY)
-                                       *stepY = SkScalarToFixed(fMat[kMSkewY]);
-                       }
-                       else
-                       {
+    if (PerspNearlyZero(fMat[kMPersp0]))
+    {
+        if (stepX || stepY)
+        {
+            if (PerspNearlyZero(fMat[kMPersp1]) && PerspNearlyZero(fMat[kMPersp2] - kMatrix22Elem))
+            {
+                if (stepX)
+                    *stepX = SkScalarToFixed(fMat[kMScaleX]);
+                if (stepY)
+                    *stepY = SkScalarToFixed(fMat[kMSkewY]);
+            }
+            else
+            {
 #ifdef SK_SCALAR_IS_FIXED
-                               SkFixed z = SkFractMul(y, fMat[kMPersp1]) + SkFractToFixed(fMat[kMPersp2]);
+                SkFixed z = SkFractMul(y, fMat[kMPersp1]) + SkFractToFixed(fMat[kMPersp2]);
 #else
-                               float z = y * fMat[kMPersp1] + fMat[kMPersp2];
+                float z = y * fMat[kMPersp1] + fMat[kMPersp2];
+#endif
+                if (stepX)
+                    *stepX = SkScalarToFixed(SkScalarDiv(fMat[kMScaleX], z));
+                if (stepY)
+                    *stepY = SkScalarToFixed(SkScalarDiv(fMat[kMSkewY], z));
+            }
+        }
+        return true;
+    }
+    return false;
+}
+
+#if 0
+void SkMatrix::perspectiveLine(SkScalar x, SkScalar y, SkFixed dst[], int count) const
+{
+    if (count <= 0)
+        return;
+
+    SkPoint start, stop;        
+    SkMatrix::Perspective_ptProc(*this, x, y, &start);
+
+    SkFixed fx = SkScalarToFixed(start.fX);
+    SkFixed fy = SkScalarToFixed(start.fY);
+    
+    *dst++ = fx;
+    *dst++ = fy;
+    if (1 == count) {
+        return;
+    }
+        
+    SkMatrix::Perspective_ptProc(*this, x + SkIntToScalar(count - 1), y, &stop);
+
+    SkFixed dx = SkScalarToFixed(stop.fX - start.fX) / (count - 1);
+    SkFixed dy = SkScalarToFixed(stop.fY - start.fY) / (count - 1);
+
+    for (int i = 1; i < count; i++)
+    {
+        fx += dx;
+        *dst++ = fx;
+        fy += dy;
+        *dst++ = fy;
+    }
+}
 #endif
-                               if (stepX)
-                                       *stepX = SkScalarToFixed(SkScalarDiv(fMat[kMScaleX], z));
-                               if (stepY)
-                                       *stepY = SkScalarToFixed(SkScalarDiv(fMat[kMSkewY], z));
-                       }
-               }
-               return true;
-       }
-       return false;
+
+/////////////////////////////////////////////////////////////////////////////////////////
+
+#include "SkPerspIter.h"
+
+SkPerspIter::SkPerspIter(const SkMatrix& m, SkScalar x0, SkScalar y0, int count)
+    : fMatrix(m), fSX(x0), fSY(y0), fCount(count)
+{
+    SkPoint pt;
+
+    SkMatrix::Perspective_ptProc(m, x0, y0, &pt);
+    fX = SkScalarToFixed(pt.fX);
+    fY = SkScalarToFixed(pt.fY);
+}
+
+int SkPerspIter::next()
+{
+    int n = fCount;
+    
+    if (0 == n)
+        return 0;
+
+    SkPoint pt;
+    SkFixed x = fX;
+    SkFixed y = fY;
+    SkFixed dx, dy;
+
+    if (n >= kCount)
+    {
+        n = kCount;
+        fSX += SkIntToScalar(kCount);
+        SkMatrix::Perspective_ptProc(fMatrix, fSX, fSY, &pt);
+        fX = SkScalarToFixed(pt.fX);
+        fY = SkScalarToFixed(pt.fY);
+        dx = (fX - x) >> kShift;
+        dy = (fY - y) >> kShift;
+    }
+    else
+    {
+        fSX += SkIntToScalar(n);
+        SkMatrix::Perspective_ptProc(fMatrix, fSX, fSY, &pt);
+        fX = SkScalarToFixed(pt.fX);
+        fY = SkScalarToFixed(pt.fY);
+        dx = (fX - x) / n;
+        dy = (fY - y) / n;
+    }
+
+    SkFixed* p = fStorage;
+    for (int i = 0; i < n; i++)
+    {
+        *p++ = x; x += dx;
+        *p++ = y; y += dy;
+    }
+    
+    fCount -= n;
+    return n;
 }
 
 /////////////////////////////////////////////////////////////////////////////////////////
@@ -892,245 +1119,245 @@ bool SkMatrix::fixedStepInX(SkScalar y, SkFixed* stepX, SkFixed* stepY) const
 
 static inline void poly_to_point(SkPoint* pt, const SkPoint poly[], int count)
 {
-       SkFixed x = SK_Fixed1, y = SK_Fixed1;
-       SkPoint pt1, pt2;
-       Sk64    w1, w2;
-
-       if (count > 1)
-       {       pt1.fX = poly[1].fX - poly[0].fX;
-               pt1.fY = poly[1].fY - poly[0].fY;
-               y = SkPoint::Length(pt1.fX, pt1.fY);
-               switch (count) {
-               case 2:
-                       break;
-               case 3:
-                       pt2.fX = poly[0].fY - poly[2].fY;
-                       pt2.fY = poly[2].fX - poly[0].fX;
-                       goto CALC_X;
-               default:
-                       pt2.fX = poly[0].fY - poly[3].fY;
-                       pt2.fY = poly[3].fX - poly[0].fX;
-               CALC_X:
-                       w1.setMul(pt1.fX, pt2.fX);
-                       w2.setMul(pt1.fY, pt2.fY);
-                       w1.add(w2);
-                       w1.div(y, Sk64::kRound_DivOption);
-                       x = w1.get32();
-                       break;
-               }
-       }
-       pt->set(x, y);
+    SkFixed x = SK_Fixed1, y = SK_Fixed1;
+    SkPoint pt1, pt2;
+    Sk64    w1, w2;
+
+    if (count > 1)
+    {   pt1.fX = poly[1].fX - poly[0].fX;
+        pt1.fY = poly[1].fY - poly[0].fY;
+        y = SkPoint::Length(pt1.fX, pt1.fY);
+        switch (count) {
+        case 2:
+            break;
+        case 3:
+            pt2.fX = poly[0].fY - poly[2].fY;
+            pt2.fY = poly[2].fX - poly[0].fX;
+            goto CALC_X;
+        default:
+            pt2.fX = poly[0].fY - poly[3].fY;
+            pt2.fY = poly[3].fX - poly[0].fX;
+        CALC_X:
+            w1.setMul(pt1.fX, pt2.fX);
+            w2.setMul(pt1.fY, pt2.fY);
+            w1.add(w2);
+            w1.div(y, Sk64::kRound_DivOption);
+            x = w1.get32();
+            break;
+        }
+    }
+    pt->set(x, y);
 }
 
 static inline void Map1Pt(const SkPoint source[], SkMatrix* dst)
 {
-       dst->setTranslate(source[0].fX, source[0].fY);
+    dst->setTranslate(source[0].fX, source[0].fY);
 }
 
 void SkMatrix::Map2Pt(const SkPoint srcPt[], SkMatrix* dst, SkFixed scale)
 {
-       dst->fMat[kMScaleX] = SkFixedDiv(srcPt[1].fY - srcPt[0].fY, scale);
-       dst->fMat[kMSkewY]  = SkFixedDiv(srcPt[0].fX - srcPt[1].fX, scale);
-       dst->fMat[kMPersp0] = 0;
-       dst->fMat[kMSkewX]  = SkFixedDiv(srcPt[1].fX - srcPt[0].fX, scale);
-       dst->fMat[kMScaleY] = SkFixedDiv(srcPt[1].fY - srcPt[0].fY, scale);
-       dst->fMat[kMPersp1] = 0;
-       dst->fMat[kMTransX] = srcPt[0].fX;
-       dst->fMat[kMTransY] = srcPt[0].fY;
-       dst->fMat[kMPersp2] = SK_Fract1;
+    dst->fMat[kMScaleX] = SkFixedDiv(srcPt[1].fY - srcPt[0].fY, scale);
+    dst->fMat[kMSkewY]  = SkFixedDiv(srcPt[0].fX - srcPt[1].fX, scale);
+    dst->fMat[kMPersp0] = 0;
+    dst->fMat[kMSkewX]  = SkFixedDiv(srcPt[1].fX - srcPt[0].fX, scale);
+    dst->fMat[kMScaleY] = SkFixedDiv(srcPt[1].fY - srcPt[0].fY, scale);
+    dst->fMat[kMPersp1] = 0;
+    dst->fMat[kMTransX] = srcPt[0].fX;
+    dst->fMat[kMTransY] = srcPt[0].fY;
+    dst->fMat[kMPersp2] = SK_Fract1;
 }
 
 void SkMatrix::Map3Pt(const SkPoint srcPt[], SkMatrix* dst, SkFixed scaleX, SkFixed scaleY)
 {
-       dst->fMat[kMScaleX] = SkFixedDiv(srcPt[2].fX - srcPt[0].fX, scaleX);
-       dst->fMat[kMSkewY]  = SkFixedDiv(srcPt[2].fY - srcPt[0].fY, scaleX);
-       dst->fMat[kMPersp0] = 0;
-       dst->fMat[kMSkewX]  = SkFixedDiv(srcPt[1].fX - srcPt[0].fX, scaleY);
-       dst->fMat[kMScaleY] = SkFixedDiv(srcPt[1].fY - srcPt[0].fY, scaleY);
-       dst->fMat[kMPersp1] = 0;
-       dst->fMat[kMTransX] = srcPt[0].fX;
-       dst->fMat[kMTransY] = srcPt[0].fY;
-       dst->fMat[kMPersp2] = SK_Fract1;
+    dst->fMat[kMScaleX] = SkFixedDiv(srcPt[2].fX - srcPt[0].fX, scaleX);
+    dst->fMat[kMSkewY]  = SkFixedDiv(srcPt[2].fY - srcPt[0].fY, scaleX);
+    dst->fMat[kMPersp0] = 0;
+    dst->fMat[kMSkewX]  = SkFixedDiv(srcPt[1].fX - srcPt[0].fX, scaleY);
+    dst->fMat[kMScaleY] = SkFixedDiv(srcPt[1].fY - srcPt[0].fY, scaleY);
+    dst->fMat[kMPersp1] = 0;
+    dst->fMat[kMTransX] = srcPt[0].fX;
+    dst->fMat[kMTransY] = srcPt[0].fY;
+    dst->fMat[kMPersp2] = SK_Fract1;
 }
 
 void SkMatrix::Map4Pt(const SkPoint srcPt[], SkMatrix* dst, SkFixed scaleX, SkFixed scaleY)
 {
-       SkFract a1, a2;
-       SkFixed x0, y0, x1, y1, x2, y2;
-
-       x0 = srcPt[2].fX - srcPt[0].fX;
-       y0 = srcPt[2].fY - srcPt[0].fY;
-       x1 = srcPt[2].fX - srcPt[1].fX;
-       y1 = srcPt[2].fY - srcPt[1].fY;
-       x2 = srcPt[2].fX - srcPt[3].fX;
-       y2 = srcPt[2].fY - srcPt[3].fY;
-
-       /* check if abs(x2) > abs(y2) */
-       if ( x2 > 0 ? y2 > 0 ? x2 > y2 : x2 > -y2 : y2 > 0 ? -x2 > y2 : x2 < y2)
-               a1 = SkFractDiv(SkMulDiv(x0 - x1, y2, x2) - y0 + y1, SkMulDiv(x1, y2, x2) - y1);
-       else
-               a1 = SkFractDiv(x0 - x1 - SkMulDiv(y0 - y1, x2, y2), x1 - SkMulDiv(y1, x2, y2));
-
-       /* check if abs(x1) > abs(y1) */
-       if ( x1 > 0 ? y1 > 0 ? x1 > y1 : x1 > -y1 : y1 > 0 ? -x1 > y1 : x1 < y1)
-               a2 = SkFractDiv(y0 - y2 - SkMulDiv(x0 - x2, y1, x1), y2 - SkMulDiv(x2, y1, x1));
-       else
-               a2 = SkFractDiv(SkMulDiv(y0 - y2, x1, y1) - x0 + x2, SkMulDiv(y2, x1, y1) - x2);
-
-       dst->fMat[kMScaleX] = SkFixedDiv(SkFractMul(a2, srcPt[3].fX) + srcPt[3].fX - srcPt[0].fX, scaleX);
-       dst->fMat[kMSkewY]  = SkFixedDiv(SkFractMul(a2, srcPt[3].fY) + srcPt[3].fY - srcPt[0].fY, scaleX);
-       dst->fMat[kMPersp0] = SkFixedDiv(a2, scaleX);
-       dst->fMat[kMSkewX]  = SkFixedDiv(SkFractMul(a1, srcPt[1].fX) + srcPt[1].fX - srcPt[0].fX, scaleY);
-       dst->fMat[kMScaleY] = SkFixedDiv(SkFractMul(a1, srcPt[1].fY) + srcPt[1].fY - srcPt[0].fY, scaleY);
-       dst->fMat[kMPersp1] = SkFixedDiv(a1, scaleY);
-       dst->fMat[kMTransX] = srcPt[0].fX;
-       dst->fMat[kMTransY] = srcPt[0].fY;
-       dst->fMat[kMPersp2] = SK_Fract1;
+    SkFract a1, a2;
+    SkFixed x0, y0, x1, y1, x2, y2;
+
+    x0 = srcPt[2].fX - srcPt[0].fX;
+    y0 = srcPt[2].fY - srcPt[0].fY;
+    x1 = srcPt[2].fX - srcPt[1].fX;
+    y1 = srcPt[2].fY - srcPt[1].fY;
+    x2 = srcPt[2].fX - srcPt[3].fX;
+    y2 = srcPt[2].fY - srcPt[3].fY;
+
+    /* check if abs(x2) > abs(y2) */
+    if ( x2 > 0 ? y2 > 0 ? x2 > y2 : x2 > -y2 : y2 > 0 ? -x2 > y2 : x2 < y2)
+        a1 = SkFractDiv(SkMulDiv(x0 - x1, y2, x2) - y0 + y1, SkMulDiv(x1, y2, x2) - y1);
+    else
+        a1 = SkFractDiv(x0 - x1 - SkMulDiv(y0 - y1, x2, y2), x1 - SkMulDiv(y1, x2, y2));
+
+    /* check if abs(x1) > abs(y1) */
+    if ( x1 > 0 ? y1 > 0 ? x1 > y1 : x1 > -y1 : y1 > 0 ? -x1 > y1 : x1 < y1)
+        a2 = SkFractDiv(y0 - y2 - SkMulDiv(x0 - x2, y1, x1), y2 - SkMulDiv(x2, y1, x1));
+    else
+        a2 = SkFractDiv(SkMulDiv(y0 - y2, x1, y1) - x0 + x2, SkMulDiv(y2, x1, y1) - x2);
+
+    dst->fMat[kMScaleX] = SkFixedDiv(SkFractMul(a2, srcPt[3].fX) + srcPt[3].fX - srcPt[0].fX, scaleX);
+    dst->fMat[kMSkewY]  = SkFixedDiv(SkFractMul(a2, srcPt[3].fY) + srcPt[3].fY - srcPt[0].fY, scaleX);
+    dst->fMat[kMPersp0] = SkFixedDiv(a2, scaleX);
+    dst->fMat[kMSkewX]  = SkFixedDiv(SkFractMul(a1, srcPt[1].fX) + srcPt[1].fX - srcPt[0].fX, scaleY);
+    dst->fMat[kMScaleY] = SkFixedDiv(SkFractMul(a1, srcPt[1].fY) + srcPt[1].fY - srcPt[0].fY, scaleY);
+    dst->fMat[kMPersp1] = SkFixedDiv(a1, scaleY);
+    dst->fMat[kMTransX] = srcPt[0].fX;
+    dst->fMat[kMTransY] = srcPt[0].fY;
+    dst->fMat[kMPersp2] = SK_Fract1;
 }
 
-#else  /* Scalar is float */
+#else   /* Scalar is float */
 
 static inline void poly_to_point(SkPoint* pt, const SkPoint poly[], int count)
 {
-       float   x = 1, y = 1;
-       SkPoint pt1, pt2;
-
-       if (count > 1)
-       {       pt1.fX = poly[1].fX - poly[0].fX;
-               pt1.fY = poly[1].fY - poly[0].fY;
-               y = SkPoint::Length(pt1.fX, pt1.fY);
-               switch (count) {
-               case 2:
-                       break;
-               case 3:
-                       pt2.fX = poly[0].fY - poly[2].fY;
-                       pt2.fY = poly[2].fX - poly[0].fX;
-                       goto CALC_X;
-               default:
-                       pt2.fX = poly[0].fY - poly[3].fY;
-                       pt2.fY = poly[3].fX - poly[0].fX;
-               CALC_X:
-                       x = SkScalarDiv(SkScalarMul(pt1.fX, pt2.fX) + SkScalarMul(pt1.fY, pt2.fY), y);
-                       break;
-               }
-       }
-       pt->set(x, y);
+    float   x = 1, y = 1;
+    SkPoint pt1, pt2;
+
+    if (count > 1)
+    {   pt1.fX = poly[1].fX - poly[0].fX;
+        pt1.fY = poly[1].fY - poly[0].fY;
+        y = SkPoint::Length(pt1.fX, pt1.fY);
+        switch (count) {
+        case 2:
+            break;
+        case 3:
+            pt2.fX = poly[0].fY - poly[2].fY;
+            pt2.fY = poly[2].fX - poly[0].fX;
+            goto CALC_X;
+        default:
+            pt2.fX = poly[0].fY - poly[3].fY;
+            pt2.fY = poly[3].fX - poly[0].fX;
+        CALC_X:
+            x = SkScalarDiv(SkScalarMul(pt1.fX, pt2.fX) + SkScalarMul(pt1.fY, pt2.fY), y);
+            break;
+        }
+    }
+    pt->set(x, y);
 }
 
 static inline void Map1Pt(const SkPoint source[], SkMatrix* dst)
 {
-       dst->setTranslate(source[0].fX, source[0].fY);
+    dst->setTranslate(source[0].fX, source[0].fY);
 }
 
 void SkMatrix::Map2Pt(const SkPoint srcPt[], SkMatrix* dst, float scale)
 {
-       float invScale = 1 / scale;
-
-       dst->fMat[kMScaleX] = (srcPt[1].fY - srcPt[0].fY) * invScale;
-       dst->fMat[kMSkewY] = (srcPt[0].fX - srcPt[1].fX) * invScale;
-       dst->fMat[kMPersp0] = 0;
-       dst->fMat[kMSkewX] = (srcPt[1].fX - srcPt[0].fX) * invScale;
-       dst->fMat[kMScaleY] = (srcPt[1].fY - srcPt[0].fY) * invScale;
-       dst->fMat[kMPersp1] = 0;
-       dst->fMat[kMTransX] = srcPt[0].fX;
-       dst->fMat[kMTransY] = srcPt[0].fY;
-       dst->fMat[kMPersp2] = 1;
+    float invScale = 1 / scale;
+
+    dst->fMat[kMScaleX] = (srcPt[1].fY - srcPt[0].fY) * invScale;
+    dst->fMat[kMSkewY] = (srcPt[0].fX - srcPt[1].fX) * invScale;
+    dst->fMat[kMPersp0] = 0;
+    dst->fMat[kMSkewX] = (srcPt[1].fX - srcPt[0].fX) * invScale;
+    dst->fMat[kMScaleY] = (srcPt[1].fY - srcPt[0].fY) * invScale;
+    dst->fMat[kMPersp1] = 0;
+    dst->fMat[kMTransX] = srcPt[0].fX;
+    dst->fMat[kMTransY] = srcPt[0].fY;
+    dst->fMat[kMPersp2] = 1;
 }
 
 void SkMatrix::Map3Pt(const SkPoint srcPt[], SkMatrix* dst, float scaleX, float scaleY)
 {
-       float invScale = 1 / scaleX;
-
-       dst->fMat[kMScaleX] = (srcPt[2].fX - srcPt[0].fX) * invScale;
-       dst->fMat[kMSkewY] = (srcPt[2].fY - srcPt[0].fY) * invScale;
-       dst->fMat[kMPersp0] = 0;
-       invScale = 1 / scaleY;
-       dst->fMat[kMSkewX] = (srcPt[1].fX - srcPt[0].fX) * invScale;
-       dst->fMat[kMScaleY] = (srcPt[1].fY - srcPt[0].fY) * invScale;
-       dst->fMat[kMPersp1] = 0;
-       dst->fMat[kMTransX] = srcPt[0].fX;
-       dst->fMat[kMTransY] = srcPt[0].fY;
-       dst->fMat[kMPersp2] = 1;
+    float invScale = 1 / scaleX;
+
+    dst->fMat[kMScaleX] = (srcPt[2].fX - srcPt[0].fX) * invScale;
+    dst->fMat[kMSkewY] = (srcPt[2].fY - srcPt[0].fY) * invScale;
+    dst->fMat[kMPersp0] = 0;
+    invScale = 1 / scaleY;
+    dst->fMat[kMSkewX] = (srcPt[1].fX - srcPt[0].fX) * invScale;
+    dst->fMat[kMScaleY] = (srcPt[1].fY - srcPt[0].fY) * invScale;
+    dst->fMat[kMPersp1] = 0;
+    dst->fMat[kMTransX] = srcPt[0].fX;
+    dst->fMat[kMTransY] = srcPt[0].fY;
+    dst->fMat[kMPersp2] = 1;
 }
 
 void SkMatrix::Map4Pt(const SkPoint srcPt[], SkMatrix* dst, float scaleX, float scaleY)
 {
-       float   a1, a2;
-       float   x0, y0, x1, y1, x2, y2;
-
-       x0 = srcPt[2].fX - srcPt[0].fX;
-       y0 = srcPt[2].fY - srcPt[0].fY;
-       x1 = srcPt[2].fX - srcPt[1].fX;
-       y1 = srcPt[2].fY - srcPt[1].fY;
-       x2 = srcPt[2].fX - srcPt[3].fX;
-       y2 = srcPt[2].fY - srcPt[3].fY;
-
-       /* check if abs(x2) > abs(y2) */
-       if ( x2 > 0 ? y2 > 0 ? x2 > y2 : x2 > -y2 : y2 > 0 ? -x2 > y2 : x2 < y2)
-               a1 = SkScalarDiv(SkScalarMulDiv(x0 - x1, y2, x2) - y0 + y1, SkScalarMulDiv(x1, y2, x2) - y1);
-       else
-               a1 = SkScalarDiv(x0 - x1 - SkScalarMulDiv(y0 - y1, x2, y2), x1 - SkScalarMulDiv(y1, x2, y2));
-
-       /* check if abs(x1) > abs(y1) */
-       if ( x1 > 0 ? y1 > 0 ? x1 > y1 : x1 > -y1 : y1 > 0 ? -x1 > y1 : x1 < y1)
-               a2 = SkScalarDiv(y0 - y2 - SkScalarMulDiv(x0 - x2, y1, x1), y2 - SkScalarMulDiv(x2, y1, x1));
-       else
-               a2 = SkScalarDiv(SkScalarMulDiv(y0 - y2, x1, y1) - x0 + x2, SkScalarMulDiv(y2, x1, y1) - x2);
-
-       scaleX = 1 / scaleX;
-       dst->fMat[kMScaleX] = SkScalarMul(SkScalarMul(a2, srcPt[3].fX) + srcPt[3].fX - srcPt[0].fX, scaleX);
-       dst->fMat[kMSkewY] = SkScalarMul(SkScalarMul(a2, srcPt[3].fY) + srcPt[3].fY - srcPt[0].fY, scaleX);
-       dst->fMat[kMPersp0] = SkScalarMul(a2, scaleX);
-       scaleY = 1 / scaleY;
-       dst->fMat[kMSkewX] = SkScalarMul(SkScalarMul(a1, srcPt[1].fX) + srcPt[1].fX - srcPt[0].fX, scaleY);
-       dst->fMat[kMScaleY] = SkScalarMul(SkScalarMul(a1, srcPt[1].fY) + srcPt[1].fY - srcPt[0].fY, scaleY);
-       dst->fMat[kMPersp1] = SkScalarMul(a1, scaleY);
-       dst->fMat[kMTransX] = srcPt[0].fX;
-       dst->fMat[kMTransY] = srcPt[0].fY;
-       dst->fMat[kMPersp2] = 1;
+    float   a1, a2;
+    float   x0, y0, x1, y1, x2, y2;
+
+    x0 = srcPt[2].fX - srcPt[0].fX;
+    y0 = srcPt[2].fY - srcPt[0].fY;
+    x1 = srcPt[2].fX - srcPt[1].fX;
+    y1 = srcPt[2].fY - srcPt[1].fY;
+    x2 = srcPt[2].fX - srcPt[3].fX;
+    y2 = srcPt[2].fY - srcPt[3].fY;
+
+    /* check if abs(x2) > abs(y2) */
+    if ( x2 > 0 ? y2 > 0 ? x2 > y2 : x2 > -y2 : y2 > 0 ? -x2 > y2 : x2 < y2)
+        a1 = SkScalarDiv(SkScalarMulDiv(x0 - x1, y2, x2) - y0 + y1, SkScalarMulDiv(x1, y2, x2) - y1);
+    else
+        a1 = SkScalarDiv(x0 - x1 - SkScalarMulDiv(y0 - y1, x2, y2), x1 - SkScalarMulDiv(y1, x2, y2));
+
+    /* check if abs(x1) > abs(y1) */
+    if ( x1 > 0 ? y1 > 0 ? x1 > y1 : x1 > -y1 : y1 > 0 ? -x1 > y1 : x1 < y1)
+        a2 = SkScalarDiv(y0 - y2 - SkScalarMulDiv(x0 - x2, y1, x1), y2 - SkScalarMulDiv(x2, y1, x1));
+    else
+        a2 = SkScalarDiv(SkScalarMulDiv(y0 - y2, x1, y1) - x0 + x2, SkScalarMulDiv(y2, x1, y1) - x2);
+
+    scaleX = 1 / scaleX;
+    dst->fMat[kMScaleX] = SkScalarMul(SkScalarMul(a2, srcPt[3].fX) + srcPt[3].fX - srcPt[0].fX, scaleX);
+    dst->fMat[kMSkewY] = SkScalarMul(SkScalarMul(a2, srcPt[3].fY) + srcPt[3].fY - srcPt[0].fY, scaleX);
+    dst->fMat[kMPersp0] = SkScalarMul(a2, scaleX);
+    scaleY = 1 / scaleY;
+    dst->fMat[kMSkewX] = SkScalarMul(SkScalarMul(a1, srcPt[1].fX) + srcPt[1].fX - srcPt[0].fX, scaleY);
+    dst->fMat[kMScaleY] = SkScalarMul(SkScalarMul(a1, srcPt[1].fY) + srcPt[1].fY - srcPt[0].fY, scaleY);
+    dst->fMat[kMPersp1] = SkScalarMul(a1, scaleY);
+    dst->fMat[kMTransX] = srcPt[0].fX;
+    dst->fMat[kMTransY] = srcPt[0].fY;
+    dst->fMat[kMPersp2] = 1;
 }
 
 #endif
 
-/*     Taken from Rob Johnson's original sample code in QuickDraw GX
+/*  Taken from Rob Johnson's original sample code in QuickDraw GX
 */
 bool SkMatrix::setPolyToPoly(const SkPoint dst[], const SkPoint src[], int count)
 {
-       SkASSERT((unsigned)count <= 4);
-
-       SkPoint         tempPt;
-       SkMatrix        tempMap;
-
-       poly_to_point(&tempPt, src, count);
-       switch (count) {
-       case 0:
-               this->reset();
-               break;
-       case 1:
-               this->setTranslate(dst[0].fX - src[0].fX, dst[0].fY - src[0].fY);
-               break;
-       case 2:
-               Map2Pt(src, &tempMap, tempPt.fY);
-               if (tempMap.invert(this) == false)
-                       return false;
-               Map2Pt(dst, &tempMap, tempPt.fY);
-               goto mapMap;
-       case 3:
-               Map3Pt(src, &tempMap, tempPt.fX, tempPt.fY);
-               if (tempMap.invert(this) == false)
-                       return false;
-               Map3Pt(dst, &tempMap, tempPt.fX, tempPt.fY);
-               goto mapMap;
-       default:
-               Map4Pt(src, &tempMap, tempPt.fX, tempPt.fY);
-               if (tempMap.invert(this) == false)
-                       return false;
-               Map4Pt(dst, &tempMap, tempPt.fX, tempPt.fY);
-       mapMap:
-               this->setConcat(tempMap, *this);
-               break;
-       }
-       return true;
+    SkASSERT((unsigned)count <= 4);
+
+    SkPoint     tempPt;
+    SkMatrix    tempMap;
+
+    poly_to_point(&tempPt, src, count);
+    switch (count) {
+    case 0:
+        this->reset();
+        break;
+    case 1:
+        this->setTranslate(dst[0].fX - src[0].fX, dst[0].fY - src[0].fY);
+        break;
+    case 2:
+        Map2Pt(src, &tempMap, tempPt.fY);
+        if (tempMap.invert(this) == false)
+            return false;
+        Map2Pt(dst, &tempMap, tempPt.fY);
+        goto mapMap;
+    case 3:
+        Map3Pt(src, &tempMap, tempPt.fX, tempPt.fY);
+        if (tempMap.invert(this) == false)
+            return false;
+        Map3Pt(dst, &tempMap, tempPt.fX, tempPt.fY);
+        goto mapMap;
+    default:
+        Map4Pt(src, &tempMap, tempPt.fX, tempPt.fY);
+        if (tempMap.invert(this) == false)
+            return false;
+        Map4Pt(dst, &tempMap, tempPt.fX, tempPt.fY);
+    mapMap:
+        this->setConcat(tempMap, *this);
+        break;
+    }
+    return true;
 }
 
 ///////////////////////////////////////////////////////////////////////////////////////
@@ -1140,80 +1367,61 @@ bool SkMatrix::setPolyToPoly(const SkPoint dst[], const SkPoint src[], int count
 
 void SkMatrix::dump() const
 {
-       static const char* gTypeNames[] = {
-               "translate",
-               "scale",
-               "rotate",
-               "perspective"
-       };
-
-       SkDebugf("SkMatrix mask = ");
-       unsigned mask = this->getType();
-
-       if (mask == 0)
-               SkDebugf("identity\n");
-       else
-       {
-               for (int i = 0; i < kShiftCount; i++)
-               {
-                       if (mask & (1 << i))
-                               SkDebugf(" %s", gTypeNames[i]);
-               }
-               SkDebugf("\n");
-       }
+    SkDebugf("SkMatrix mask = ");
+    unsigned mask = this->getType();
 
 #ifdef SK_CAN_USE_FLOAT
-       SkDebugf("[%8.4f %8.4f %8.4f]\n[%8.4f %8.4f %8.4f]\n[%8.4f %8.4f %8.4f]\n",
+    SkDebugf("[%8.4f %8.4f %8.4f]\n[%8.4f %8.4f %8.4f]\n[%8.4f %8.4f %8.4f]\n",
 #ifdef SK_SCALAR_IS_FLOAT
-                       fMat[0], fMat[1], fMat[2], fMat[3], fMat[4], fMat[5],
-                       fMat[6], fMat[7], fMat[8]);
+            fMat[0], fMat[1], fMat[2], fMat[3], fMat[4], fMat[5],
+            fMat[6], fMat[7], fMat[8]);
 #else
-                       SkFixedToFloat(fMat[0]), SkFixedToFloat(fMat[1]), SkFixedToFloat(fMat[2]),
-                       SkFixedToFloat(fMat[3]), SkFixedToFloat(fMat[4]), SkFixedToFloat(fMat[5]),
-                       SkFractToFloat(fMat[6]), SkFractToFloat(fMat[7]), SkFractToFloat(fMat[8]));
+            SkFixedToFloat(fMat[0]), SkFixedToFloat(fMat[1]), SkFixedToFloat(fMat[2]),
+            SkFixedToFloat(fMat[3]), SkFixedToFloat(fMat[4]), SkFixedToFloat(fMat[5]),
+            SkFractToFloat(fMat[6]), SkFractToFloat(fMat[7]), SkFractToFloat(fMat[8]));
 #endif
 #else   // can't use float
-       SkDebugf("[%x %x %x]\n[%x %x %x]\n[%x %x %x]\n",
-                       fMat[0], fMat[1], fMat[2], fMat[3], fMat[4], fMat[5],
-                       fMat[6], fMat[7], fMat[8]);
+    SkDebugf("[%x %x %x]\n[%x %x %x]\n[%x %x %x]\n",
+            fMat[0], fMat[1], fMat[2], fMat[3], fMat[4], fMat[5],
+            fMat[6], fMat[7], fMat[8]);
 #endif
 }
 
 void SkMatrix::UnitTest()
 {
 #ifdef SK_SUPPORT_UNITTEST
-       SkMatrix        mat, inverse, iden1, iden2;
-
-       mat.reset();
-       mat.setTranslate(SK_Scalar1, SK_Scalar1);
-       mat.invert(&inverse);
-       inverse.dump();
-       iden1.setConcat(mat, inverse);
-       iden1.dump();
-
-       mat.setScale(SkIntToScalar(2), SkIntToScalar(2), 0, 0);
-       mat.invert(&inverse);
-       inverse.dump();
-       iden1.setConcat(mat, inverse);
-       iden1.dump();
-
-       mat.setScale(SK_Scalar1/2, SK_Scalar1/2, 0, 0);
-       mat.invert(&inverse);
-       inverse.dump();
-       iden1.setConcat(mat, inverse);
-       iden1.dump();
-
-       mat.setScale(SkIntToScalar(3), SkIntToScalar(5), SkIntToScalar(20), 0);
-       mat.postRotate(SkIntToScalar(25), 0, 0);
-
-       SkASSERT(mat.invert(nil));
-       mat.invert(&inverse);
-
-       iden1.setConcat(mat, inverse);
-       iden2.setConcat(inverse, mat);
-
-       iden1.dump();
-       iden2.dump();
+    SkMatrix    mat, inverse, iden1, iden2;
+
+    mat.reset();
+    mat.setTranslate(SK_Scalar1, SK_Scalar1);
+    mat.invert(&inverse);
+    inverse.dump();
+    iden1.setConcat(mat, inverse);
+    iden1.dump();
+
+    mat.setScale(SkIntToScalar(2), SkIntToScalar(2));
+    mat.invert(&inverse);
+    inverse.dump();
+    iden1.setConcat(mat, inverse);
+    iden1.dump();
+
+    mat.setScale(SK_Scalar1/2, SK_Scalar1/2);
+    mat.invert(&inverse);
+    inverse.dump();
+    iden1.setConcat(mat, inverse);
+    iden1.dump();
+
+    mat.setScale(SkIntToScalar(3), SkIntToScalar(5), SkIntToScalar(20), 0);
+    mat.postRotate(SkIntToScalar(25));
+
+    SkASSERT(mat.invert(nil));
+    mat.invert(&inverse);
+
+    iden1.setConcat(mat, inverse);
+    iden2.setConcat(inverse, mat);
+
+    iden1.dump();
+    iden2.dump();
 #endif
 }
 
index 5a03dac..737fcb7 100644 (file)
@@ -1,3 +1,20 @@
+/* libs/corecg/SkMemory_stdlib.cpp
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #include "SkTypes.h"
 #include <stdio.h>
 #include <stdlib.h>
@@ -20,60 +37,60 @@ void sk_out_of_memory(void)
 
 void* sk_malloc_throw(size_t size)
 {
-       return sk_malloc_flags(size, SK_MALLOC_THROW);
+    return sk_malloc_flags(size, SK_MALLOC_THROW);
 }
 
 void* sk_realloc_throw(void* addr, size_t size)
 {
-       SkDEBUGCODE(if (size) size += 4;)
-       SkDEBUGCODE(if (addr) addr = (char*)addr - 4;)
+    SkDEBUGCODE(if (size) size += 4;)
+    SkDEBUGCODE(if (addr) addr = (char*)addr - 4;)
 
-       void* p = realloc(addr, size);
-       if (size == 0)
-               return p;
+    void* p = realloc(addr, size);
+    if (size == 0)
+        return p;
 
-       if (p == NULL)
-               sk_throw();
+    if (p == NULL)
+        sk_throw();
 #ifdef SK_DEBUG
-       else
-       {
-               memcpy(p, "skia", 4);
-               p = (char*)p + 4;
-       }
+    else
+    {
+        memcpy(p, "skia", 4);
+        p = (char*)p + 4;
+    }
 #endif
-       return p;
+    return p;
 }
 
 void sk_free(void* p)
 {
-       if (p)
-       {
+    if (p)
+    {
 #ifdef SK_DEBUG
-               SkDEBUGCODE(p = (char*)p - 4;)
-               SkASSERT(memcmp(p, "skia", 4) == 0);
+        SkDEBUGCODE(p = (char*)p - 4;)
+        SkASSERT(memcmp(p, "skia", 4) == 0);
 #endif
-               free(p);
-       }
+        free(p);
+    }
 }
 
 void* sk_malloc_flags(size_t size, unsigned flags)
 {
-       SkDEBUGCODE(size += 4;)
-       
-       void* p = malloc(size);
-       if (p == NULL)
-       {
-               if (flags & SK_MALLOC_THROW)
-                       sk_throw();
-       }
+    SkDEBUGCODE(size += 4;)
+    
+    void* p = malloc(size);
+    if (p == NULL)
+    {
+        if (flags & SK_MALLOC_THROW)
+            sk_throw();
+    }
 #ifdef SK_DEBUG
-       else
-       {
-               memcpy(p, "skia", 4);
-               p = (char*)p + 4;
-               memset(p, 0xCD, size - 4);
-       }
+    else
+    {
+        memcpy(p, "skia", 4);
+        p = (char*)p + 4;
+        memset(p, 0xCD, size - 4);
+    }
 #endif
-       return p;
+    return p;
 }
 
index b76c4b3..f75aa5d 100644 (file)
+/* libs/corecg/SkPoint.cpp
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #include "SkPoint.h"
 
 void SkPoint16::rotateCW(SkPoint16* dst) const
 {
-       SkASSERT(dst);
+    SkASSERT(dst);
 
-       // use a tmp in case this == dst
-       S16 tmp = fX;
-       dst->fX = -fY;
-       dst->fY = tmp;
+    // use a tmp in case this == dst
+    S16 tmp = fX;
+    dst->fX = -fY;
+    dst->fY = tmp;
 }
 
 void SkPoint16::rotateCCW(SkPoint16* dst) const
 {
-       SkASSERT(dst);
+    SkASSERT(dst);
 
-       // use a tmp in case this == dst
-       S16 tmp = fX;
-       dst->fX = fY;
-       dst->fY = -tmp;
+    // use a tmp in case this == dst
+    S16 tmp = fX;
+    dst->fX = fY;
+    dst->fY = -tmp;
 }
 
 /////////////////////////////////////////////////////////////////////
 
 void SkPoint::rotateCW(SkPoint* dst) const
 {
-       SkASSERT(dst);
+    SkASSERT(dst);
 
-       // use a tmp in case this == dst
-       SkScalar tmp = fX;
-       dst->fX = -fY;
-       dst->fY = tmp;
+    // use a tmp in case this == dst
+    SkScalar tmp = fX;
+    dst->fX = -fY;
+    dst->fY = tmp;
 }
 
 void SkPoint::rotateCCW(SkPoint* dst) const
 {
-       SkASSERT(dst);
+    SkASSERT(dst);
 
-       // use a tmp in case this == dst
-       SkScalar tmp = fX;
-       dst->fX = fY;
-       dst->fY = -tmp;
+    // use a tmp in case this == dst
+    SkScalar tmp = fX;
+    dst->fX = fY;
+    dst->fY = -tmp;
 }
 
 void SkPoint::scale(SkScalar scale, SkPoint* dst) const
 {
-       SkASSERT(dst);
-       dst->set(SkScalarMul(fX, scale), SkScalarMul(fY, scale));
+    SkASSERT(dst);
+    dst->set(SkScalarMul(fX, scale), SkScalarMul(fY, scale));
 }
 
-#define kNearlyZero            (SK_Scalar1 / 8092)
+#define kNearlyZero     (SK_Scalar1 / 8092)
 
 bool SkPoint::normalize()
 {
-       return this->setLength(fX, fY, SK_Scalar1);
+    return this->setLength(fX, fY, SK_Scalar1);
 }
 
 bool SkPoint::setUnit(SkScalar x, SkScalar y)
 {
-       return this->setLength(x, y, SK_Scalar1);
+    return this->setLength(x, y, SK_Scalar1);
 }
 
 bool SkPoint::setLength(SkScalar length)
 {
-       return this->setLength(fX, fY, length);
+    return this->setLength(fX, fY, length);
 }
 
 #ifdef SK_SCALAR_IS_FLOAT
 
 SkScalar SkPoint::Length(SkScalar dx, SkScalar dy)
 {
-       return sk_float_sqrt(dx * dx + dy * dy);
+    return sk_float_sqrt(dx * dx + dy * dy);
 }
 
 bool SkPoint::setLength(float x, float y, float length)
 {
-       float mag = sk_float_sqrt(x * x + y * y);
-       if (mag > kNearlyZero)
-       {
-               length /= mag;
-               fX = x * length;
-               fY = y * length;
-               return true;
-       }
-       return false;
+    float mag = sk_float_sqrt(x * x + y * y);
+    if (mag > kNearlyZero)
+    {
+        length /= mag;
+        fX = x * length;
+        fY = y * length;
+        return true;
+    }
+    return false;
 }
 
 #else
@@ -91,148 +108,258 @@ bool SkPoint::setLength(float x, float y, float length)
 
 SkScalar SkPoint::Length(SkScalar dx, SkScalar dy)
 {
-       Sk64    tmp1, tmp2;
+    Sk64    tmp1, tmp2;
 
-       tmp1.setMul(dx, dx);
-       tmp2.setMul(dy, dy);
-       tmp1.add(tmp2);
+    tmp1.setMul(dx, dx);
+    tmp2.setMul(dy, dy);
+    tmp1.add(tmp2);
 
-       return tmp1.getSqrt();
+    return tmp1.getSqrt();
 }
 
 #ifdef SK_DEBUGx
 static SkFixed fixlen(SkFixed x, SkFixed y)
 {
-       float fx = (float)x;
-       float fy = (float)y;
+    float fx = (float)x;
+    float fy = (float)y;
+
+    return (int)floorf(sqrtf(fx*fx + fy*fy) + 0.5f);
+}
+#endif
+
+static inline uint32_t squarefixed(unsigned x)
+{
+    x >>= 16;
+    return x*x;
+}
+
+#if 1   // Newton iter for setLength
+
+static inline unsigned invsqrt_iter(unsigned V, unsigned U)
+{
+    unsigned x = V * U >> 14;
+    x = x * U >> 14;
+    x = (3 << 14) - x;
+    x = (U >> 1) * x >> 14;
+    return x;
+}
 
-       return (int)floorf(sqrtf(fx*fx + fy*fy) + 0.5f);
+static const uint16_t gInvSqrt14GuessTable[] = {
+    0x4000, 0x3c57, 0x393e, 0x3695, 0x3441, 0x3235, 0x3061,
+    0x2ebd, 0x2d41, 0x2be7, 0x2aaa, 0x2987, 0x287a, 0x2780,
+    0x2698, 0x25be, 0x24f3, 0x2434, 0x2380, 0x22d6, 0x2235,
+    0x219d, 0x210c, 0x2083, 0x2000, 0x1f82, 0x1f0b, 0x1e99,
+    0x1e2b, 0x1dc2, 0x1d5d, 0x1cfc, 0x1c9f, 0x1c45, 0x1bee,
+    0x1b9b, 0x1b4a, 0x1afc, 0x1ab0, 0x1a67, 0x1a20, 0x19dc,
+    0x1999, 0x1959, 0x191a, 0x18dd, 0x18a2, 0x1868, 0x1830,
+    0x17fa, 0x17c4, 0x1791, 0x175e, 0x172d, 0x16fd, 0x16ce
+};
+
+#define BUILD_INVSQRT_TABLEx
+#ifdef BUILD_INVSQRT_TABLE
+static void build_invsqrt14_guess_table()
+{
+    for (int i = 8; i <= 63; i++) {
+        unsigned x = SkToU16((1 << 28) / SkSqrt32(i << 25));
+        printf("0x%x, ", x);
+    }
+    printf("\n");
 }
 #endif
 
-static inline U32 squarefixed(unsigned x)
+static unsigned fast_invsqrt(uint32_t x)
 {
-       x >>= 16;
-       return x*x;
+#ifdef BUILD_INVSQRT_TABLE
+    unsigned top2 = x >> 25;
+    SkASSERT(top2 >= 8 && top2 <= 63);
+
+    static bool gOnce;
+    if (!gOnce)
+    {
+        build_invsqrt14_guess_table();
+        gOnce = true;
+    }
+#endif
+
+    unsigned V = x >> 14;   // make V .14
+
+    unsigned top = x >> 25;
+    SkASSERT(top >= 8 && top <= 63);
+    SkASSERT(top - 8 < SK_ARRAY_COUNT(gInvSqrt14GuessTable));
+    unsigned U = gInvSqrt14GuessTable[top - 8];
+    
+    U = invsqrt_iter(V, U);
+    return invsqrt_iter(V, U);
 }
 
+/*  We "normalize" x,y to be .14 values (so we can square them and stay 32bits.
+    Then we Newton-iterate this in .14 space to compute the invser-sqrt, and scale
+    by it at the end. The .14 space means we can execute our iterations and stay
+    in 32bits as well, making the multiplies much cheaper than calling  SkFixedMul.
+*/
+bool SkPoint::setLength(SkFixed ox, SkFixed oy, SkFixed length)
+{
+    if (ox == 0)
+    {
+        if (oy == 0)
+            return false;
+        this->set(0, SkApplySign(length, SkExtractSign(oy)));
+        return true;
+    }
+    if (oy == 0)
+    {
+        this->set(SkApplySign(length, SkExtractSign(ox)), 0);
+        return true;
+    }
+
+    unsigned x = SkAbs32(ox);
+    unsigned y = SkAbs32(oy);
+    int zeros = SkCLZ(x | y);
+
+    // make x,y 1.14 values so our fast sqr won't overflow
+    if (zeros > 17) {
+        x <<= zeros - 17;
+        y <<= zeros - 17; 
+    }
+    else {
+        x >>= 17 - zeros;
+        y >>= 17 - zeros;
+    }
+    SkASSERT((x | y) <= 0x7FFF);
+
+    unsigned invrt = fast_invsqrt(x*x + y*y);
+
+    x = x * invrt >> 12;
+    y = y * invrt >> 12;
+
+    if (length != SK_Fixed1)
+    {
+        x = SkFixedMul(x, length);
+        y = SkFixedMul(y, length);
+    }
+    this->set(SkApplySign(x, SkExtractSign(ox)), SkApplySign(y, SkExtractSign(oy)));
+    return true;
+}
+#else
 /*
-       Normalize x,y, and then scale them by length.
-
-       The obvious way to do this would be the following:
-               S64     tmp1, tmp2;
-               tmp1.setMul(x,x);
-               tmp2.setMul(y,y);
-               tmp1.add(tmp2);
-               len = tmp1.getSqrt();
-               x' = SkFixedDiv(x, len);
-               y' = SkFixedDiv(y, len);
-       This is fine, but slower than what we do below.
-
-       The present technique does not compute the starting length, but
-       rather fiddles with x,y iteratively, all the while checking its
-       magnitude^2 (avoiding a sqrt).
-
-       We normalize by first shifting x,y so that at least one of them
-       has bit 31 set (after taking the abs of them).
-       Then we loop, refining x,y by squaring them and comparing
-       against a very large 1.0 (1 << 28), and then adding or subtracting
-       a delta (which itself is reduced by half each time through the loop).
-       For speed we want the squaring to be with a simple integer mul. To keep
-       that from overflowing we shift our coordinates down until we are dealing
-       with at most 15 bits (2^15-1)^2 * 2 says withing 32 bits)
-       When our square is close to 1.0, we shift x,y down into fixed range.
+    Normalize x,y, and then scale them by length.
+
+    The obvious way to do this would be the following:
+        S64 tmp1, tmp2;
+        tmp1.setMul(x,x);
+        tmp2.setMul(y,y);
+        tmp1.add(tmp2);
+        len = tmp1.getSqrt();
+        x' = SkFixedDiv(x, len);
+        y' = SkFixedDiv(y, len);
+    This is fine, but slower than what we do below.
+
+    The present technique does not compute the starting length, but
+    rather fiddles with x,y iteratively, all the while checking its
+    magnitude^2 (avoiding a sqrt).
+
+    We normalize by first shifting x,y so that at least one of them
+    has bit 31 set (after taking the abs of them).
+    Then we loop, refining x,y by squaring them and comparing
+    against a very large 1.0 (1 << 28), and then adding or subtracting
+    a delta (which itself is reduced by half each time through the loop).
+    For speed we want the squaring to be with a simple integer mul. To keep
+    that from overflowing we shift our coordinates down until we are dealing
+    with at most 15 bits (2^15-1)^2 * 2 says withing 32 bits)
+    When our square is close to 1.0, we shift x,y down into fixed range.
 */
 bool SkPoint::setLength(SkFixed ox, SkFixed oy, SkFixed length)
 {
-       if (ox == 0)
-       {
-               if (oy == 0)
-                       return false;
-               this->set(0, SkApplySign(length, SkExtractSign(oy)));
-               return true;
-       }
-       if (oy == 0)
-       {
-               this->set(SkApplySign(length, SkExtractSign(ox)), 0);
-               return true;
-       }
-
-       SkFixed x = SkAbs32(ox);
-       SkFixed y = SkAbs32(oy);
-
-       // shift x,y so that the greater of them is 15bits (1.14 fixed point)
-       {
-               int shift = SkCLZ(x | y);
-               // make them .30
-               x <<= shift - 1;
-               y <<= shift - 1;
-       }
-
-       SkFixed dx = x;
-       SkFixed dy = y;
-
-       for (int i = 0; i < 17; i++)
-       {
-               dx >>= 1;
-               dy >>= 1;
-
-               U32 len2 = squarefixed(x) + squarefixed(y);
-               if (len2 >> 28)
-               {
-                       x -= dx;
-                       y -= dy;
-               }
-               else
-               {
-                       x += dx;
-                       y += dy;
-               }
-       }
-       x >>= 14;
-       y >>= 14;
-
-#ifdef SK_DEBUGx       // measure how far we are from unit-length
-       {
-               static int gMaxError;
-               static int gMaxDiff;
-
-               SkFixed len = fixlen(x, y);
-               int err = len - SK_Fixed1;
-               err = SkAbs32(err);
-
-               if (err > gMaxError)
-               {
-                       gMaxError = err;
-                       SkDebugf("gMaxError %d\n", err);
-               }
-
-               float fx = SkAbs32(ox)/65536.0f;
-               float fy = SkAbs32(oy)/65536.0f;
-               float mag = sqrtf(fx*fx + fy*fy);
-               fx /= mag;
-               fy /= mag;
-               SkFixed xx = (int)floorf(fx * 65536 + 0.5f);
-               SkFixed yy = (int)floorf(fy * 65536 + 0.5f);
-               err = SkMax32(SkAbs32(xx-x), SkAbs32(yy-y));
-               if (err > gMaxDiff)
-               {
-                       gMaxDiff = err;
-                       SkDebugf("gMaxDiff %d\n", err);
-               }
-       }
+    if (ox == 0)
+    {
+        if (oy == 0)
+            return false;
+        this->set(0, SkApplySign(length, SkExtractSign(oy)));
+        return true;
+    }
+    if (oy == 0)
+    {
+        this->set(SkApplySign(length, SkExtractSign(ox)), 0);
+        return true;
+    }
+
+    SkFixed x = SkAbs32(ox);
+    SkFixed y = SkAbs32(oy);
+
+    // shift x,y so that the greater of them is 15bits (1.14 fixed point)
+    {
+        int shift = SkCLZ(x | y);
+        // make them .30
+        x <<= shift - 1;
+        y <<= shift - 1;
+    }
+
+    SkFixed dx = x;
+    SkFixed dy = y;
+
+    for (int i = 0; i < 17; i++)
+    {
+        dx >>= 1;
+        dy >>= 1;
+
+        U32 len2 = squarefixed(x) + squarefixed(y);
+        if (len2 >> 28)
+        {
+            x -= dx;
+            y -= dy;
+        }
+        else
+        {
+            x += dx;
+            y += dy;
+        }
+    }
+    x >>= 14;
+    y >>= 14;
+
+#ifdef SK_DEBUGx    // measure how far we are from unit-length
+    {
+        static int gMaxError;
+        static int gMaxDiff;
+
+        SkFixed len = fixlen(x, y);
+        int err = len - SK_Fixed1;
+        err = SkAbs32(err);
+
+        if (err > gMaxError)
+        {
+            gMaxError = err;
+            SkDebugf("gMaxError %d\n", err);
+        }
+
+        float fx = SkAbs32(ox)/65536.0f;
+        float fy = SkAbs32(oy)/65536.0f;
+        float mag = sqrtf(fx*fx + fy*fy);
+        fx /= mag;
+        fy /= mag;
+        SkFixed xx = (int)floorf(fx * 65536 + 0.5f);
+        SkFixed yy = (int)floorf(fy * 65536 + 0.5f);
+        err = SkMax32(SkAbs32(xx-x), SkAbs32(yy-y));
+        if (err > gMaxDiff)
+        {
+            gMaxDiff = err;
+            SkDebugf("gMaxDiff %d\n", err);
+        }
+    }
 #endif
 
-       x = SkApplySign(x, SkExtractSign(ox));
-       y = SkApplySign(y, SkExtractSign(oy));
-       if (length != SK_Fixed1)
-       {
-               x = SkFixedMul(x, length);
-               y = SkFixedMul(y, length);
-       }
-       this->set(x, y);
-       return true;
+    x = SkApplySign(x, SkExtractSign(ox));
+    y = SkApplySign(y, SkExtractSign(oy));
+    if (length != SK_Fixed1)
+    {
+        x = SkFixedMul(x, length);
+        y = SkFixedMul(y, length);
+    }
+    
+    this->set(x, y);
+    return true;
 }
+#endif
 
 #endif
 
index 0a09393..e1de436 100644 (file)
+/* libs/corecg/SkRect.cpp
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #include "SkRect.h"
 
 bool SkRect16::intersect(S16CPU left, S16CPU top, S16CPU right, S16CPU bottom)
 {
-       if (fLeft < right && left < fRight && fTop < bottom && top < fBottom)
-       {
-               if (fLeft < left) fLeft = SkToS16(left);
-               if (fTop < top) fTop = SkToS16(top);
-               if (fRight > right) fRight = SkToS16(right);
-               if (fBottom > bottom) fBottom = SkToS16(bottom);
-               return true;
-       }
-       return false;
+    if (fLeft < right && left < fRight && fTop < bottom && top < fBottom)
+    {
+        if (fLeft < left) fLeft = SkToS16(left);
+        if (fTop < top) fTop = SkToS16(top);
+        if (fRight > right) fRight = SkToS16(right);
+        if (fBottom > bottom) fBottom = SkToS16(bottom);
+        return true;
+    }
+    return false;
 }
 
 bool SkRect16::intersect(const SkRect16& r)
 {
-       SkASSERT(&r);
-       return this->intersect(r.fLeft, r.fTop, r.fRight, r.fBottom);
+    SkASSERT(&r);
+    return this->intersect(r.fLeft, r.fTop, r.fRight, r.fBottom);
 }
 
 bool SkRect16::intersect(const SkRect16& a, const SkRect16& b)
 {
-       SkASSERT(&a && &b);
+    SkASSERT(&a && &b);
 
-       *this = a;
-       return this->intersect(b.fLeft, b.fTop, b.fRight, b.fBottom);
+    *this = a;
+    return this->intersect(b.fLeft, b.fTop, b.fRight, b.fBottom);
 }
 
 void SkRect16::sort()
 {
-       if (fLeft > fRight)
-               SkTSwap<S16>(fLeft, fRight);
-       if (fTop > fBottom)
-               SkTSwap<S16>(fTop, fBottom);
+    if (fLeft > fRight)
+        SkTSwap<S16>(fLeft, fRight);
+    if (fTop > fBottom)
+        SkTSwap<S16>(fTop, fBottom);
 }
 
 /////////////////////////////////////////////////////////////////////////////
 
 void SkRect::sort()
 {
-       if (fLeft > fRight)
-               SkTSwap<SkScalar>(fLeft, fRight);
-       if (fTop > fBottom)
-               SkTSwap<SkScalar>(fTop, fBottom);
+    if (fLeft > fRight)
+        SkTSwap<SkScalar>(fLeft, fRight);
+    if (fTop > fBottom)
+        SkTSwap<SkScalar>(fTop, fBottom);
 }
 
 void SkRect::toQuad(SkPoint quad[4]) const
 {
-       SkASSERT(quad);
+    SkASSERT(quad);
 
-       quad[0].set(fLeft, fTop);
-       quad[1].set(fRight, fTop);
-       quad[2].set(fRight, fBottom);
-       quad[3].set(fLeft, fBottom);
+    quad[0].set(fLeft, fTop);
+    quad[1].set(fRight, fTop);
+    quad[2].set(fRight, fBottom);
+    quad[3].set(fLeft, fBottom);
 }
 
 void SkRect::set(const SkPoint pts[], int count)
 {
-       SkASSERT(pts && count > 0 || count == 0);
-
-       if (count <= 0)
-               memset(this, 0, sizeof(SkRect));
-       else
-       {
-               SkScalar        l, t, r, b;
-
-               l = r = pts[0].fX;
-               t = b = pts[0].fY;
-
-               for (int i = 1; i < count; i++)
-               {
-                       SkScalar x = pts[i].fX;
-                       SkScalar y = pts[i].fY;
-
-                       if (x < l) l = x; else if (x > r) r = x;
-                       if (y < t) t = y; else if (y > b) b = y;
-               }
-               this->set(l, t, r, b);
-       }
+    SkASSERT(pts && count > 0 || count == 0);
+
+    if (count <= 0)
+        memset(this, 0, sizeof(SkRect));
+    else
+    {
+        SkScalar    l, t, r, b;
+
+        l = r = pts[0].fX;
+        t = b = pts[0].fY;
+
+        for (int i = 1; i < count; i++)
+        {
+            SkScalar x = pts[i].fX;
+            SkScalar y = pts[i].fY;
+
+            if (x < l) l = x; else if (x > r) r = x;
+            if (y < t) t = y; else if (y > b) b = y;
+        }
+        this->set(l, t, r, b);
+    }
 }
 
 bool SkRect::intersect(SkScalar left, SkScalar top, SkScalar right, SkScalar bottom)
 {
-       if (fLeft < right && left < fRight && fTop < bottom && top < fBottom)
-       {
-               if (fLeft < left) fLeft = left;
-               if (fTop < top) fTop = top;
-               if (fRight > right) fRight = right;
-               if (fBottom > bottom) fBottom = bottom;
-               return true;
-       }
-       return false;
+    if (fLeft < right && left < fRight && fTop < bottom && top < fBottom)
+    {
+        if (fLeft < left) fLeft = left;
+        if (fTop < top) fTop = top;
+        if (fRight > right) fRight = right;
+        if (fBottom > bottom) fBottom = bottom;
+        return true;
+    }
+    return false;
 }
 
 bool SkRect::intersect(const SkRect& r)
 {
-       SkASSERT(&r);
-       return this->intersect(r.fLeft, r.fTop, r.fRight, r.fBottom);
+    SkASSERT(&r);
+    return this->intersect(r.fLeft, r.fTop, r.fRight, r.fBottom);
 }
 
 
index 20c7c73..c6f6998 100644 (file)
@@ -1,3 +1,20 @@
+/* libs/corecg/SkRegion.cpp
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #include "SkRegionPriv.h"
 #include "SkTemplates.h"
 #include "SkThread.h"
@@ -8,108 +25,108 @@ SkDEBUGCODE(int32_t gRgnAllocCounter;)
 
 static SkRegion::RunType* skip_scanline(const SkRegion::RunType runs[])
 {
-       while (runs[0] != kRunTypeSentinel)
-       {
-               SkASSERT(runs[0] < runs[1]);    // valid span
-               runs += 2;
-       }
-       return (SkRegion::RunType*)(runs + 1);  // return past the X-sentinel
+    while (runs[0] != kRunTypeSentinel)
+    {
+        SkASSERT(runs[0] < runs[1]);    // valid span
+        runs += 2;
+    }
+    return (SkRegion::RunType*)(runs + 1);  // return past the X-sentinel
 }
 
 static SkRegion::RunType* find_y(const SkRegion::RunType runs[], int y)
 {
-       int     top = *runs++;
-       if (top <= y)
-       {
-               for (;;)
-               {
-                       int bot = *runs++;
-                       if (bot > y)
-                       {
-                               if (bot == kRunTypeSentinel || *runs == kRunTypeSentinel)
-                                       break;
-                               return (SkRegion::RunType*)runs;
-                       }
-                       top = bot;
-                       runs = skip_scanline(runs);
-               }
-       }
-       return nil;
+    int top = *runs++;
+    if (top <= y)
+    {
+        for (;;)
+        {
+            int bot = *runs++;
+            if (bot > y)
+            {
+                if (bot == kRunTypeSentinel || *runs == kRunTypeSentinel)
+                    break;
+                return (SkRegion::RunType*)runs;
+            }
+            top = bot;
+            runs = skip_scanline(runs);
+        }
+    }
+    return nil;
 }
 
 // returns true if runs are a rect
 bool SkRegion::compute_run_bounds(const SkRegion::RunType runs[], int count, SkRect16* bounds)
 {
-       assert_sentinel(runs[0], false);        // top
-
-       if (count == kRectRegionRuns)
-       {
-               assert_sentinel(runs[1], false);        // bottom
-               assert_sentinel(runs[2], false);        // left
-               assert_sentinel(runs[3], false);        // right
-               assert_sentinel(runs[4], true);
-               assert_sentinel(runs[5], true);
-
-               SkASSERT(runs[0] < runs[1]);    // valid height
-               SkASSERT(runs[2] < runs[3]);    // valid width
-
-               bounds->set(runs[2], runs[0], runs[3], runs[1]);
-               return true;
-       }
-
-       int     left = SK_MaxS32;
-       int rite = SK_MinS32;
-       int     bot;
-
-       bounds->fTop = *runs++;
-       do {
-               bot = *runs++;
-               if (*runs < kRunTypeSentinel)
-               {
-                       if (left > *runs)
-                               left = *runs;
-                       runs = skip_scanline(runs);
-                       if (rite < runs[-2])
-                               rite = runs[-2];
-               }
-               else
-                       runs += 1;      // skip X-sentinel
-       } while (runs[0] < kRunTypeSentinel);
-       bounds->fLeft = SkToS16(left);
-       bounds->fRight = SkToS16(rite);
-       bounds->fBottom = SkToS16(bot);
-       return false;
+    assert_sentinel(runs[0], false);    // top
+
+    if (count == kRectRegionRuns)
+    {
+        assert_sentinel(runs[1], false);    // bottom
+        assert_sentinel(runs[2], false);    // left
+        assert_sentinel(runs[3], false);    // right
+        assert_sentinel(runs[4], true);
+        assert_sentinel(runs[5], true);
+
+        SkASSERT(runs[0] < runs[1]);    // valid height
+        SkASSERT(runs[2] < runs[3]);    // valid width
+
+        bounds->set(runs[2], runs[0], runs[3], runs[1]);
+        return true;
+    }
+
+    int left = SK_MaxS32;
+    int rite = SK_MinS32;
+    int bot;
+
+    bounds->fTop = *runs++;
+    do {
+        bot = *runs++;
+        if (*runs < kRunTypeSentinel)
+        {
+            if (left > *runs)
+                left = *runs;
+            runs = skip_scanline(runs);
+            if (rite < runs[-2])
+                rite = runs[-2];
+        }
+        else
+            runs += 1;  // skip X-sentinel
+    } while (runs[0] < kRunTypeSentinel);
+    bounds->fLeft = SkToS16(left);
+    bounds->fRight = SkToS16(rite);
+    bounds->fBottom = SkToS16(bot);
+    return false;
 }
 
 //////////////////////////////////////////////////////////////////////////
 
 SkRegion::SkRegion()
 {
-       fBounds.set(0, 0, 0, 0);
-       fRunHead = SkRegion_gEmptyRunHeadPtr;
+    fBounds.set(0, 0, 0, 0);
+    fRunHead = SkRegion_gEmptyRunHeadPtr;
 }
 
 SkRegion::SkRegion(const SkRegion& src)
 {
-       fRunHead = SkRegion_gEmptyRunHeadPtr;   // just need a value that won't trigger sk_free(fRunHead)
+    fRunHead = SkRegion_gEmptyRunHeadPtr;   // just need a value that won't trigger sk_free(fRunHead)
     this->setRegion(src);
 }
 
 SkRegion::SkRegion(const SkRect16& rect)
 {
-       fRunHead = SkRegion_gEmptyRunHeadPtr;   // just need a value that won't trigger sk_free(fRunHead)
-       this->setRect(rect);
+    fRunHead = SkRegion_gEmptyRunHeadPtr;   // just need a value that won't trigger sk_free(fRunHead)
+    this->setRect(rect);
 }
 
 SkRegion::~SkRegion()
 {
-       this->freeRuns();
+    this->freeRuns();
 }
 
 void SkRegion::freeRuns()
 {
-       if (fRunHead->isComplex())
-       {
+    if (fRunHead->isComplex())
+    {
         SkASSERT(fRunHead->fRefCnt >= 1);
         if (sk_atomic_dec(&fRunHead->fRefCnt) == 1)
         {
@@ -118,7 +135,7 @@ void SkRegion::freeRuns()
             //SkDEBUGF(("************** gRgnAllocCounter::free %d\n", gRgnAllocCounter));
             sk_free(fRunHead);
         }
-       }
+    }
 }
 
 void SkRegion::allocateRuns(int count)
@@ -128,258 +145,258 @@ void SkRegion::allocateRuns(int count)
 
 SkRegion& SkRegion::operator=(const SkRegion& src)
 {
-       (void)this->setRegion(src);
-       return *this;
+    (void)this->setRegion(src);
+    return *this;
 }
 
 void SkRegion::swap(SkRegion& other)
 {
-       SkTSwap<SkRect16>(fBounds, other.fBounds);
-       SkTSwap<RunHead*>(fRunHead, other.fRunHead);
+    SkTSwap<SkRect16>(fBounds, other.fBounds);
+    SkTSwap<RunHead*>(fRunHead, other.fRunHead);
 }
 
 bool SkRegion::setEmpty()
 {
-       this->freeRuns();
-       fBounds.set(0, 0, 0, 0);
-       fRunHead = SkRegion_gEmptyRunHeadPtr;
-       return false;
+    this->freeRuns();
+    fBounds.set(0, 0, 0, 0);
+    fRunHead = SkRegion_gEmptyRunHeadPtr;
+    return false;
 }
 
 bool SkRegion::setRect(S16CPU left, S16CPU top, S16CPU right, S16CPU bottom)
 {
-       if (left >= right || top >= bottom)
-               return this->setEmpty();
+    if (left >= right || top >= bottom)
+        return this->setEmpty();
 
-       this->freeRuns();
-       fBounds.set(left, top, right, bottom);
-       fRunHead = SkRegion_gRectRunHeadPtr;
-       return true;
+    this->freeRuns();
+    fBounds.set(left, top, right, bottom);
+    fRunHead = SkRegion_gRectRunHeadPtr;
+    return true;
 }
 
 bool SkRegion::setRect(const SkRect16& r)
 {
-       return this->setRect(r.fLeft, r.fTop, r.fRight, r.fBottom);
+    return this->setRect(r.fLeft, r.fTop, r.fRight, r.fBottom);
 }
 
 bool SkRegion::setRegion(const SkRegion& src)
 {
-       if (this != &src)
-       {
-               this->freeRuns();
+    if (this != &src)
+    {
+        this->freeRuns();
 
-               fBounds = src.fBounds;
+        fBounds = src.fBounds;
         fRunHead = src.fRunHead;
         if (fRunHead->isComplex())
             sk_atomic_inc(&fRunHead->fRefCnt);
-       }
-       return fRunHead != SkRegion_gEmptyRunHeadPtr;
+    }
+    return fRunHead != SkRegion_gEmptyRunHeadPtr;
 }
 
 bool SkRegion::op(const SkRect16& rect, Op op)
 {
-       SkRegion tmp(rect);
+    SkRegion tmp(rect);
 
-       return this->op(*this, tmp, op);
+    return this->op(*this, tmp, op);
 }
 
 bool SkRegion::op(const SkRect16& rect, const SkRegion& rgn, Op op)
 {
-       SkRegion tmp(rect);
+    SkRegion tmp(rect);
 
-       return this->op(tmp, rgn, op);
+    return this->op(tmp, rgn, op);
 }
 
 //////////////////////////////////////////////////////////////////////////////////////
 
 int SkRegion::count_runtype_values(int* itop, int* ibot) const
 {
-       if (this == nil)
-       {
-               *itop = SK_MinS16;
-               *ibot = SK_MaxS16;
-               return 0;
-       }
-
-       int     maxT;
-
-       if (this->isRect())
-               maxT = 2;
-       else
-       {
+    if (this == nil)
+    {
+        *itop = SK_MinS16;
+        *ibot = SK_MaxS16;
+        return 0;
+    }
+
+    int maxT;
+
+    if (this->isRect())
+        maxT = 2;
+    else
+    {
         SkASSERT(this->isComplex());
-               // skip the top
-               const RunType*  runs = fRunHead->runs() + 1;
-               maxT = 0;
-
-               do {
-                       const RunType* next = skip_scanline(runs + 1);
-                       SkASSERT(next > runs);
-                       int                     T = (int)(next - runs - 1);
-                       if (maxT < T)
-                               maxT = T;
-                       runs = next;
-               } while (runs[0] < kRunTypeSentinel);
-       }
-       *itop = fBounds.fTop;
-       *ibot = fBounds.fBottom;
-       return maxT;
+        // skip the top
+        const RunType*  runs = fRunHead->runs() + 1;
+        maxT = 0;
+
+        do {
+            const RunType* next = skip_scanline(runs + 1);
+            SkASSERT(next > runs);
+            int         T = (int)(next - runs - 1);
+            if (maxT < T)
+                maxT = T;
+            runs = next;
+        } while (runs[0] < kRunTypeSentinel);
+    }
+    *itop = fBounds.fTop;
+    *ibot = fBounds.fBottom;
+    return maxT;
 }
 
 bool SkRegion::setRuns(RunType runs[], int count)
 {
-       SkASSERT(count > 0);
-
-       if (count <= 2)
-       {
-       //      SkDEBUGF(("setRuns: empty\n"));
-               assert_sentinel(runs[count-1], true);
-               return this->setEmpty();
-       }
-
-       // trim off any empty spans from the top and bottom
-       // weird I should need this, perhaps op() could be smarter...
-       if (count > kRectRegionRuns)
-       {
-               RunType* stop = runs + count;
-               assert_sentinel(runs[0], false);        // top
-               assert_sentinel(runs[1], false);        // bottom
-               if (runs[2] == kRunTypeSentinel)        // should be first left...
-               {
-                       runs += 2;      // skip empty initial span
-                       runs[0] = runs[-1];     // set new top to prev bottom
-                       assert_sentinel(runs[1], false);        // bot: a sentinal would mean two in a row
-                       assert_sentinel(runs[2], false);        // left
-                       assert_sentinel(runs[3], false);        // right
-               }
-
-               // now check for a trailing empty span
-               assert_sentinel(stop[-1], true);
-               assert_sentinel(stop[-2], true);
-               assert_sentinel(stop[-3], false);       // should be last right
-               if (stop[-4] == kRunTypeSentinel)       // eek, stop[-3] was a bottom with no x-runs
-               {
-                       stop[-3] = kRunTypeSentinel;    // kill empty last span
-                       stop -= 2;
-                       assert_sentinel(stop[-1], true);
-                       assert_sentinel(stop[-2], true);
-                       assert_sentinel(stop[-3], false);
-                       assert_sentinel(stop[-4], false);
-                       assert_sentinel(stop[-5], false);
-               }
-               count = (int)(stop - runs);
-       }
-
-       SkASSERT(count >= kRectRegionRuns);
-
-       if (compute_run_bounds(runs, count, &fBounds))
-       {
-       //      SkDEBUGF(("setRuns: rect[%d %d %d %d]\n", fBounds.fLeft, fBounds.fTop, fBounds.fRight, fBounds.fBottom));
-               return this->setRect(fBounds);
-       }
+    SkASSERT(count > 0);
+
+    if (count <= 2)
+    {
+    //  SkDEBUGF(("setRuns: empty\n"));
+        assert_sentinel(runs[count-1], true);
+        return this->setEmpty();
+    }
+
+    // trim off any empty spans from the top and bottom
+    // weird I should need this, perhaps op() could be smarter...
+    if (count > kRectRegionRuns)
+    {
+        RunType* stop = runs + count;
+        assert_sentinel(runs[0], false);    // top
+        assert_sentinel(runs[1], false);    // bottom
+        if (runs[2] == kRunTypeSentinel)    // should be first left...
+        {
+            runs += 2;  // skip empty initial span
+            runs[0] = runs[-1]; // set new top to prev bottom
+            assert_sentinel(runs[1], false);    // bot: a sentinal would mean two in a row
+            assert_sentinel(runs[2], false);    // left
+            assert_sentinel(runs[3], false);    // right
+        }
+
+        // now check for a trailing empty span
+        assert_sentinel(stop[-1], true);
+        assert_sentinel(stop[-2], true);
+        assert_sentinel(stop[-3], false);   // should be last right
+        if (stop[-4] == kRunTypeSentinel)   // eek, stop[-3] was a bottom with no x-runs
+        {
+            stop[-3] = kRunTypeSentinel;    // kill empty last span
+            stop -= 2;
+            assert_sentinel(stop[-1], true);
+            assert_sentinel(stop[-2], true);
+            assert_sentinel(stop[-3], false);
+            assert_sentinel(stop[-4], false);
+            assert_sentinel(stop[-5], false);
+        }
+        count = (int)(stop - runs);
+    }
+
+    SkASSERT(count >= kRectRegionRuns);
+
+    if (compute_run_bounds(runs, count, &fBounds))
+    {
+    //  SkDEBUGF(("setRuns: rect[%d %d %d %d]\n", fBounds.fLeft, fBounds.fTop, fBounds.fRight, fBounds.fBottom));
+        return this->setRect(fBounds);
+    }
 
     //  if we get here, we need to become a complex region
 
     if (!fRunHead->isComplex() || fRunHead->fRunCount != count)
-       {
+    {
 #ifdef SK_DEBUGx
-               SkDebugf("setRuns: rgn [");
-               {
-                       const RunType* r = runs;
-
-                       SkDebugf(" top: %d\n", *r++);
-                       while (*r < kRunTypeSentinel)
-                       {
-                               SkDebugf(" bottom: %d", *r++);
-                               while (*r < kRunTypeSentinel)
-                               {
-                                       SkDebugf(" [%d %d]", r[0], r[1]);
-                                       r += 2;
-                               }
-                               SkDebugf("\n");
-                       }
-               }
+        SkDebugf("setRuns: rgn [");
+        {
+            const RunType* r = runs;
+
+            SkDebugf(" top: %d\n", *r++);
+            while (*r < kRunTypeSentinel)
+            {
+                SkDebugf(" bottom: %d", *r++);
+                while (*r < kRunTypeSentinel)
+                {
+                    SkDebugf(" [%d %d]", r[0], r[1]);
+                    r += 2;
+                }
+                SkDebugf("\n");
+            }
+        }
 #endif
-               this->freeRuns();
+        this->freeRuns();
         this->allocateRuns(count);
-       }
-       memcpy(fRunHead->runs(), runs, count * sizeof(RunType));
+    }
+    memcpy(fRunHead->runs(), runs, count * sizeof(RunType));
 
-       SkDEBUGCODE(this->validate();)
+    SkDEBUGCODE(this->validate();)
 
-       return true;
+    return true;
 }
 
 void SkRegion::build_rect_runs(const SkRect16& bounds,
                                RunType runs[kRectRegionRuns])
 {
-       runs[0] = bounds.fTop;
-       runs[1] = bounds.fBottom;
-       runs[2] = bounds.fLeft;
-       runs[3] = bounds.fRight;
-       runs[4] = kRunTypeSentinel;
-       runs[5] = kRunTypeSentinel;
+    runs[0] = bounds.fTop;
+    runs[1] = bounds.fBottom;
+    runs[2] = bounds.fLeft;
+    runs[3] = bounds.fRight;
+    runs[4] = kRunTypeSentinel;
+    runs[5] = kRunTypeSentinel;
 }
 
 static SkRegion::RunType* find_scanline(const SkRegion::RunType runs[], S16CPU y)
 {
-       SkASSERT(y >= runs[0]); // if this fails, we didn't do a quick check on the boudns
-
-       runs += 1;      // skip top-Y
-       for (;;)
-       {
-               if (runs[0] == kRunTypeSentinel)
-                       break;
-               if (y < runs[0])
-                       return (SkRegion::RunType*)&runs[1];
-               runs = skip_scanline(runs);
-       }
-       return nil;
+    SkASSERT(y >= runs[0]); // if this fails, we didn't do a quick check on the boudns
+
+    runs += 1;  // skip top-Y
+    for (;;)
+    {
+        if (runs[0] == kRunTypeSentinel)
+            break;
+        if (y < runs[0])
+            return (SkRegion::RunType*)&runs[1];
+        runs = skip_scanline(runs);
+    }
+    return nil;
 }
 
 bool SkRegion::contains(S16CPU x, S16CPU y) const
 {
-       if (!fBounds.contains(x, y))
-               return false;
+    if (!fBounds.contains(x, y))
+        return false;
 
-       if (this->isRect())
-               return true;
+    if (this->isRect())
+        return true;
 
     SkASSERT(this->isComplex());
-       const RunType* runs = find_scanline(fRunHead->runs(), y);
-
-       if (runs)
-       {       for (;;)
-               {       if (x < runs[0])
-                               break;
-                       if (x < runs[1])
-                               return true;
-                       runs += 2;
-               }
-       }
-       return false;
+    const RunType* runs = find_scanline(fRunHead->runs(), y);
+
+    if (runs)
+    {   for (;;)
+        {   if (x < runs[0])
+                break;
+            if (x < runs[1])
+                return true;
+            runs += 2;
+        }
+    }
+    return false;
 }
 
 const SkRegion::RunType* SkRegion::getRuns(RunType tmpStorage[], int* count) const
 {
-       SkASSERT(tmpStorage && count);
-
-       if (this->isEmpty())
-       {
-               tmpStorage[0] = kRunTypeSentinel;
-               *count = 1;
-       }
-       else if (this->isRect())
-       {
-               build_rect_runs(fBounds, tmpStorage);
-               *count = kRectRegionRuns;
-       }
-       else
-       {
-               *count = fRunHead->fRunCount;
-               tmpStorage = fRunHead->runs();
-       }
-       return tmpStorage;
+    SkASSERT(tmpStorage && count);
+
+    if (this->isEmpty())
+    {
+        tmpStorage[0] = kRunTypeSentinel;
+        *count = 1;
+    }
+    else if (this->isRect())
+    {
+        build_rect_runs(fBounds, tmpStorage);
+        *count = kRectRegionRuns;
+    }
+    else
+    {
+        *count = fRunHead->fRunCount;
+        tmpStorage = fRunHead->runs();
+    }
+    return tmpStorage;
 }
 
 /////////////////////////////////////////////////////////////////////////////////////
@@ -466,7 +483,7 @@ void SkRegion::translate(int dx, int dy, SkRegion* dst) const
 
 /////////////////////////////////////////////////////////////////////////////////////
 
-#if defined _WIN32 && _MSC_VER >= 1300 // disable warning : local variable used without having been initialized
+#if defined _WIN32 && _MSC_VER >= 1300  // disable warning : local variable used without having been initialized
 #pragma warning ( push )
 #pragma warning ( disable : 4701 )
 #endif
@@ -474,10 +491,10 @@ void SkRegion::translate(int dx, int dy, SkRegion* dst) const
 #ifdef SK_DEBUG
 static void assert_valid_pair(S16CPU left, S16CPU rite)
 {
-       SkASSERT(left == kRunTypeSentinel || left < rite);
+    SkASSERT(left == kRunTypeSentinel || left < rite);
 }
 #else
-       #define assert_valid_pair(left, rite)
+    #define assert_valid_pair(left, rite)
 #endif
 
 struct spanRec {
@@ -506,70 +523,70 @@ struct spanRec {
 
     void next()
     {
-               assert_valid_pair(fA_left, fA_rite);
-               assert_valid_pair(fB_left, fB_rite);
+        assert_valid_pair(fA_left, fA_rite);
+        assert_valid_pair(fB_left, fB_rite);
 
-               int             inside, left, rite SK_INIT_TO_AVOID_WARNING;
-               bool    a_flush = false;
-               bool    b_flush = false;
+        int     inside, left, rite SK_INIT_TO_AVOID_WARNING;
+        bool    a_flush = false;
+        bool    b_flush = false;
         
         int a_left = fA_left;
         int a_rite = fA_rite;
         int b_left = fB_left;
         int b_rite = fB_rite;
 
-               if (a_left < b_left)
-               {
-                       inside = 1;
-                       left = a_left;
-                       if (a_rite <= b_left)   // [...] <...>
-                       {
-                               rite = a_rite;
-                               a_flush = true;
-                       }
-                       else // [...<..]...> or [...<...>...]
-                               rite = a_left = b_left;
-               }
-               else if (b_left < a_left)
-               {
-                       inside = 2;
-                       left = b_left;
-                       if (b_rite <= a_left)   // [...] <...>
-                       {
-                               rite = b_rite;
-                               b_flush = true;
-                       }
-                       else // [...<..]...> or [...<...>...]
-                               rite = b_left = a_left;
-               }
-               else    // a_left == b_left
-               {
-                       inside = 3;
-                       left = a_left;  // or b_left
-                       if (a_rite <= b_rite)
-                       {
-                               rite = b_left = a_rite;
-                               a_flush = true;
-                       }
-                       if (b_rite <= a_rite)
-                       {
-                               rite = a_left = b_rite;
-                               b_flush = true;
-                       }
-               }
-
-               if (a_flush)
-               {
-                       a_left = *fA_runs++;
-                       a_rite = *fA_runs++;
-               }
-               if (b_flush)
-               {
-                       b_left = *fB_runs++;
-                       b_rite = *fB_runs++;
-               }
-
-               SkASSERT(left <= rite);
+        if (a_left < b_left)
+        {
+            inside = 1;
+            left = a_left;
+            if (a_rite <= b_left)   // [...] <...>
+            {
+                rite = a_rite;
+                a_flush = true;
+            }
+            else // [...<..]...> or [...<...>...]
+                rite = a_left = b_left;
+        }
+        else if (b_left < a_left)
+        {
+            inside = 2;
+            left = b_left;
+            if (b_rite <= a_left)   // [...] <...>
+            {
+                rite = b_rite;
+                b_flush = true;
+            }
+            else // [...<..]...> or [...<...>...]
+                rite = b_left = a_left;
+        }
+        else    // a_left == b_left
+        {
+            inside = 3;
+            left = a_left;  // or b_left
+            if (a_rite <= b_rite)
+            {
+                rite = b_left = a_rite;
+                a_flush = true;
+            }
+            if (b_rite <= a_rite)
+            {
+                rite = a_left = b_rite;
+                b_flush = true;
+            }
+        }
+
+        if (a_flush)
+        {
+            a_left = *fA_runs++;
+            a_rite = *fA_runs++;
+        }
+        if (b_flush)
+        {
+            b_left = *fB_runs++;
+            b_rite = *fB_runs++;
+        }
+
+        SkASSERT(left <= rite);
         
         // now update our state
         fA_left = a_left;
@@ -593,30 +610,30 @@ static SkRegion::RunType* operate_on_span(const SkRegion::RunType a_runs[],
     
     rec.init(a_runs, b_runs);
 
-       while (!rec.done())
-       {
+    while (!rec.done())
+    {
         rec.next();
         
         int left = rec.fLeft;
         int rite = rec.fRite;
         
-               // add left,rite to our dst buffer (checking for coincidence
-               if ((unsigned)(rec.fInside - min) <= (unsigned)(max - min) &&
-                       left < rite)    // skip if equal
-               {
-                       if (firstInterval || dst[-1] < left)
-                       {
-                               *dst++ = SkToS16(left);
-                               *dst++ = SkToS16(rite);
-                               firstInterval = false;
-                       }
-                       else    // update the right edge
-                               dst[-1] = SkToS16(rite);
-               }
-       }
-
-       *dst++ = kRunTypeSentinel;
-       return dst;
+        // add left,rite to our dst buffer (checking for coincidence
+        if ((unsigned)(rec.fInside - min) <= (unsigned)(max - min) &&
+            left < rite)    // skip if equal
+        {
+            if (firstInterval || dst[-1] < left)
+            {
+                *dst++ = SkToS16(left);
+                *dst++ = SkToS16(rite);
+                firstInterval = false;
+            }
+            else    // update the right edge
+                dst[-1] = SkToS16(rite);
+        }
+    }
+
+    *dst++ = kRunTypeSentinel;
+    return dst;
 }
 
 #if defined _WIN32 && _MSC_VER >= 1300
@@ -625,63 +642,63 @@ static SkRegion::RunType* operate_on_span(const SkRegion::RunType a_runs[],
 
 class RgnOper {
 public:
-       RgnOper(S16CPU top, SkRegion::RunType dst[], SkRegion::Op op)
-       {
-               fStartDst = dst;
-               fPrevDst = dst + 1;
-               fPrevLen = 0;           // will never match a length from operate_on_span
-               fTop = SkToS16(top);    // just a first guess, we might update this
-
-               static const struct {
-                       U8      fMin;
-                       U8      fMax;
-               } gOpMinMax[] = {
-                       { 1, 1 },       // Difference
-                       { 3, 3 },       // Intersection
-                       { 1, 3 },       // Union
-                       { 1, 2 }        // XOR
-               };
-               
-               SkASSERT((unsigned)op < SkRegion::kOpCount);
-               fMin = gOpMinMax[op].fMin;
-               fMax = gOpMinMax[op].fMax;
-       }
-
-       void addSpan(S16CPU bottom, const SkRegion::RunType a_runs[], const SkRegion::RunType b_runs[])
-       {
-               SkRegion::RunType*      start = fPrevDst + fPrevLen + 1;        // skip X values and slot for the next Y
-               SkRegion::RunType*      stop = operate_on_span(a_runs, b_runs, start, fMin, fMax);
-               size_t              len = stop - start;
-
-               if (fPrevLen == len && !memcmp(fPrevDst, start, len * sizeof(SkRegion::RunType)))       // update Y value
-                       fPrevDst[-1] = SkToS16(bottom);
-               else    // accept the new span
-               {
-                       if (len == 1 && fPrevLen == 0)
-                               fTop = SkToS16(bottom); // just update our bottom
-                       else
-                       {
-                               start[-1] = SkToS16(bottom);
-                               fPrevDst = start;
-                               fPrevLen = len;
-                       }
-               }
-       }
+    RgnOper(S16CPU top, SkRegion::RunType dst[], SkRegion::Op op)
+    {
+        fStartDst = dst;
+        fPrevDst = dst + 1;
+        fPrevLen = 0;       // will never match a length from operate_on_span
+        fTop = SkToS16(top);    // just a first guess, we might update this
+
+        static const struct {
+            U8  fMin;
+            U8  fMax;
+        } gOpMinMax[] = {
+            { 1, 1 },   // Difference
+            { 3, 3 },   // Intersection
+            { 1, 3 },   // Union
+            { 1, 2 }    // XOR
+        };
+        
+        SkASSERT((unsigned)op < SkRegion::kOpCount);
+        fMin = gOpMinMax[op].fMin;
+        fMax = gOpMinMax[op].fMax;
+    }
+
+    void addSpan(S16CPU bottom, const SkRegion::RunType a_runs[], const SkRegion::RunType b_runs[])
+    {
+        SkRegion::RunType*  start = fPrevDst + fPrevLen + 1;    // skip X values and slot for the next Y
+        SkRegion::RunType*  stop = operate_on_span(a_runs, b_runs, start, fMin, fMax);
+        size_t              len = stop - start;
+
+        if (fPrevLen == len && !memcmp(fPrevDst, start, len * sizeof(SkRegion::RunType)))   // update Y value
+            fPrevDst[-1] = SkToS16(bottom);
+        else    // accept the new span
+        {
+            if (len == 1 && fPrevLen == 0)
+                fTop = SkToS16(bottom); // just update our bottom
+            else
+            {
+                start[-1] = SkToS16(bottom);
+                fPrevDst = start;
+                fPrevLen = len;
+            }
+        }
+    }
     
-       int flush()
-       {
-               fStartDst[0] = fTop;
-               fPrevDst[fPrevLen] = kRunTypeSentinel;
-               return (int)(fPrevDst - fStartDst + fPrevLen + 1);
-       }
+    int flush()
+    {
+        fStartDst[0] = fTop;
+        fPrevDst[fPrevLen] = kRunTypeSentinel;
+        return (int)(fPrevDst - fStartDst + fPrevLen + 1);
+    }
 
-       U8              fMin, fMax;
+    U8      fMin, fMax;
 
 private:
-       SkRegion::RunType*      fStartDst;
-       SkRegion::RunType*      fPrevDst;
-       size_t              fPrevLen;
-       SkRegion::RunType   fTop;
+    SkRegion::RunType*  fStartDst;
+    SkRegion::RunType*  fPrevDst;
+    size_t              fPrevLen;
+    SkRegion::RunType   fTop;
 };
 
 static int operate( const SkRegion::RunType a_runs[],
@@ -689,168 +706,168 @@ static int operate( const SkRegion::RunType a_runs[],
                     SkRegion::RunType dst[],
                     SkRegion::Op op)
 {
-       const SkRegion::RunType sentinel = kRunTypeSentinel;
+    const SkRegion::RunType sentinel = kRunTypeSentinel;
 
-       int     a_top = *a_runs++;
-       int     a_bot = *a_runs++;
-       int b_top = *b_runs++;
-       int b_bot = *b_runs++;
+    int a_top = *a_runs++;
+    int a_bot = *a_runs++;
+    int b_top = *b_runs++;
+    int b_bot = *b_runs++;
 
-       assert_sentinel(a_top, false);
-       assert_sentinel(a_bot, false);
-       assert_sentinel(b_top, false);
-       assert_sentinel(b_bot, false);
+    assert_sentinel(a_top, false);
+    assert_sentinel(a_bot, false);
+    assert_sentinel(b_top, false);
+    assert_sentinel(b_bot, false);
 
-       RgnOper oper(SkMin32(a_top, b_top), dst, op);
+    RgnOper oper(SkMin32(a_top, b_top), dst, op);
     
     bool firstInterval = true;
     int prevBot = kRunTypeSentinel; // so we fail the first test
     
-       while (a_bot < kRunTypeSentinel || b_bot < kRunTypeSentinel)
-       {
-               int                     top, bot SK_INIT_TO_AVOID_WARNING;
-               const SkRegion::RunType*        run0 = &sentinel;
-               const SkRegion::RunType*        run1 = &sentinel;
-               bool            a_flush = false;
-               bool            b_flush = false;
+    while (a_bot < kRunTypeSentinel || b_bot < kRunTypeSentinel)
+    {
+        int         top, bot SK_INIT_TO_AVOID_WARNING;
+        const SkRegion::RunType*    run0 = &sentinel;
+        const SkRegion::RunType*    run1 = &sentinel;
+        bool        a_flush = false;
+        bool        b_flush = false;
         int         inside;
 
-               if (a_top < b_top)
-               {
+        if (a_top < b_top)
+        {
             inside = 1;
             top = a_top;
-                       run0 = a_runs;
-                       if (a_bot <= b_top)     // [...] <...>
-                       {
-                               bot = a_bot;
-                               a_flush = true;
-                       }
-                       else // [...<..]...> or [...<...>...]
-                               bot = a_top = b_top;
-               }
-               else if (b_top < a_top)
-               {
+            run0 = a_runs;
+            if (a_bot <= b_top) // [...] <...>
+            {
+                bot = a_bot;
+                a_flush = true;
+            }
+            else // [...<..]...> or [...<...>...]
+                bot = a_top = b_top;
+        }
+        else if (b_top < a_top)
+        {
             inside = 2;
             top = b_top;
-                       run1 = b_runs;
-                       if (b_bot <= a_top)     // [...] <...>
-                       {
-                               bot = b_bot;
-                               b_flush = true;
-                       }
-                       else // [...<..]...> or [...<...>...]
-                               bot = b_top = a_top;
-               }
-               else    // a_top == b_top
-               {
+            run1 = b_runs;
+            if (b_bot <= a_top) // [...] <...>
+            {
+                bot = b_bot;
+                b_flush = true;
+            }
+            else // [...<..]...> or [...<...>...]
+                bot = b_top = a_top;
+        }
+        else    // a_top == b_top
+        {
             inside = 3;
             top = a_top;    // or b_top
-                       run0 = a_runs;
-                       run1 = b_runs;
-                       if (a_bot <= b_bot)
-                       {
-                               bot = b_top = a_bot;
-                               a_flush = true;
-                       }
-                       if (b_bot <= a_bot)
-                       {
-                               bot = a_top = b_bot;
-                               b_flush = true;
-                       }
-               }
+            run0 = a_runs;
+            run1 = b_runs;
+            if (a_bot <= b_bot)
+            {
+                bot = b_top = a_bot;
+                a_flush = true;
+            }
+            if (b_bot <= a_bot)
+            {
+                bot = a_top = b_bot;
+                b_flush = true;
+            }
+        }
         
         if (top > prevBot)
             oper.addSpan(top, &sentinel, &sentinel);
 
-//             if ((unsigned)(inside - oper.fMin) <= (unsigned)(oper.fMax - oper.fMin))
+//      if ((unsigned)(inside - oper.fMin) <= (unsigned)(oper.fMax - oper.fMin))
         {
-                       oper.addSpan(bot, run0, run1);
+            oper.addSpan(bot, run0, run1);
             firstInterval = false;
         }
 
-               if (a_flush)
-               {
-                       a_runs = skip_scanline(a_runs);
-                       a_top = a_bot;
-                       a_bot = *a_runs++;
-                       if (a_bot == kRunTypeSentinel)
-                               a_top = a_bot;
-               }
-               if (b_flush)
-               {
-                       b_runs = skip_scanline(b_runs);
-                       b_top = b_bot;
-                       b_bot = *b_runs++;
-                       if (b_bot == kRunTypeSentinel)
-                               b_top = b_bot;
-               }
+        if (a_flush)
+        {
+            a_runs = skip_scanline(a_runs);
+            a_top = a_bot;
+            a_bot = *a_runs++;
+            if (a_bot == kRunTypeSentinel)
+                a_top = a_bot;
+        }
+        if (b_flush)
+        {
+            b_runs = skip_scanline(b_runs);
+            b_top = b_bot;
+            b_bot = *b_runs++;
+            if (b_bot == kRunTypeSentinel)
+                b_top = b_bot;
+        }
         
         prevBot = bot;
-       }
-       return oper.flush();
+    }
+    return oper.flush();
 }
 
 bool SkRegion::op(const SkRegion& rgna, const SkRegion& rgnb, Op op)
 {
-       SkDEBUGCODE(this->validate();)
-
-       SkASSERT((unsigned)op < kOpCount);
-
-       SkRect16        bounds;
-       bool            a_empty = rgna.isEmpty();
-       bool            b_empty = rgnb.isEmpty();
-       bool            a_rect = rgna.isRect();
-       bool            b_rect = rgnb.isRect();
-
-       switch (op) {
-       case kDifference_Op:
-               if (a_empty)
-                       return this->setEmpty();
-               if (b_empty || !SkRect16::Intersects(rgna.fBounds, rgnb.fBounds))
-                       return this->setRegion(rgna);
-               break;
-
-       case kIntersect_Op:
-               if ((a_empty | b_empty) || !bounds.intersect(rgna.fBounds, rgnb.fBounds))
-                       return this->setEmpty();
-               if (a_rect & b_rect)
-                       return this->setRect(bounds);
-               break;
-
-       case kUnion_Op:
-               if (a_empty)
-                       return this->setRegion(rgnb);
-               if (b_empty)
-                       return this->setRegion(rgna);
-               if (a_rect && rgna.fBounds.contains(rgnb.fBounds))
-                       return this->setRegion(rgna);
-               if (b_rect && rgnb.fBounds.contains(rgna.fBounds))
-                       return this->setRegion(rgnb);
-               break;
-
-       case kXOR_Op:
-               if (a_empty)
-                       return this->setRegion(rgnb);
-               if (b_empty)
-                       return this->setRegion(rgna);
-               break;
-       default:
-               break;
-       }
-
-       RunType tmpA[kRectRegionRuns];
-       RunType tmpB[kRectRegionRuns];
-
-       int     a_count, b_count;
-       const RunType* a_runs = rgna.getRuns(tmpA, &a_count);
-       const RunType* b_runs = rgnb.getRuns(tmpB, &b_count);
-
-       int     dstCount = 3 * SkMax32(a_count, b_count);
-       SkAutoSTMalloc<32, RunType>     array(dstCount);
-
-       int count = operate(a_runs, b_runs, array.get(), op);
-       SkASSERT(count <= dstCount);
-       return this->setRuns(array.get(), count);
+    SkDEBUGCODE(this->validate();)
+
+    SkASSERT((unsigned)op < kOpCount);
+
+    SkRect16    bounds;
+    bool        a_empty = rgna.isEmpty();
+    bool        b_empty = rgnb.isEmpty();
+    bool        a_rect = rgna.isRect();
+    bool        b_rect = rgnb.isRect();
+
+    switch (op) {
+    case kDifference_Op:
+        if (a_empty)
+            return this->setEmpty();
+        if (b_empty || !SkRect16::Intersects(rgna.fBounds, rgnb.fBounds))
+            return this->setRegion(rgna);
+        break;
+
+    case kIntersect_Op:
+        if ((a_empty | b_empty) || !bounds.intersect(rgna.fBounds, rgnb.fBounds))
+            return this->setEmpty();
+        if (a_rect & b_rect)
+            return this->setRect(bounds);
+        break;
+
+    case kUnion_Op:
+        if (a_empty)
+            return this->setRegion(rgnb);
+        if (b_empty)
+            return this->setRegion(rgna);
+        if (a_rect && rgna.fBounds.contains(rgnb.fBounds))
+            return this->setRegion(rgna);
+        if (b_rect && rgnb.fBounds.contains(rgna.fBounds))
+            return this->setRegion(rgnb);
+        break;
+
+    case kXOR_Op:
+        if (a_empty)
+            return this->setRegion(rgnb);
+        if (b_empty)
+            return this->setRegion(rgna);
+        break;
+    default:
+        break;
+    }
+
+    RunType tmpA[kRectRegionRuns];
+    RunType tmpB[kRectRegionRuns];
+
+    int a_count, b_count;
+    const RunType* a_runs = rgna.getRuns(tmpA, &a_count);
+    const RunType* b_runs = rgnb.getRuns(tmpB, &b_count);
+
+    int dstCount = 3 * SkMax32(a_count, b_count);
+    SkAutoSTMalloc<32, RunType> array(dstCount);
+
+    int count = operate(a_runs, b_runs, array.get(), op);
+    SkASSERT(count <= dstCount);
+    return this->setRuns(array.get(), count);
 }
 
 //////////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -923,46 +940,46 @@ size_t SkRegion::readFromBuffer(const void* storage)
 
 static const SkRegion::RunType* validate_line(const SkRegion::RunType run[], const SkRect16& bounds)
 {
-       SkASSERT(*run >= bounds.fTop);
-       SkASSERT(*run <= bounds.fBottom);
-       run += 1;
-       while (*run < kRunTypeSentinel)
-       {
-               SkASSERT(run[0] < run[1]);
-               SkASSERT(run[0] >= bounds.fLeft);
-               SkASSERT(run[1] <= bounds.fRight);
-               run += 2;
-       }
-       return run + 1; // skip sentinel
+    SkASSERT(*run >= bounds.fTop);
+    SkASSERT(*run <= bounds.fBottom);
+    run += 1;
+    while (*run < kRunTypeSentinel)
+    {
+        SkASSERT(run[0] < run[1]);
+        SkASSERT(run[0] >= bounds.fLeft);
+        SkASSERT(run[1] <= bounds.fRight);
+        run += 2;
+    }
+    return run + 1; // skip sentinel
 }
 
 void SkRegion::validate() const
 {
-       if (this->isEmpty())
-       {
+    if (this->isEmpty())
+    {
         // check for explicit empty (the zero rect), so we can compare rects to know when
         // two regions are equal (i.e. emptyRectA == emptyRectB)
         // this is stricter than just asserting fBounds.isEmpty()
-               SkASSERT(fBounds.fLeft == 0 && fBounds.fTop == 0 && fBounds.fRight == 0 && fBounds.fBottom == 0);
-       }
-       else
-       {
-               SkASSERT(!fBounds.isEmpty());
-               if (!this->isRect())
-               {
+        SkASSERT(fBounds.fLeft == 0 && fBounds.fTop == 0 && fBounds.fRight == 0 && fBounds.fBottom == 0);
+    }
+    else
+    {
+        SkASSERT(!fBounds.isEmpty());
+        if (!this->isRect())
+        {
             SkASSERT(fRunHead->fRefCnt >= 1);
             SkASSERT(fRunHead->fRunCount >= kRectRegionRuns);
 
-                       const RunType* run = fRunHead->runs();
-                       const RunType* stop = run + fRunHead->fRunCount;
-                       
-                       SkASSERT(*run++ == fBounds.fTop);
-                       do {
-                               run = validate_line(run, fBounds);
-                       } while (*run < kRunTypeSentinel);
-                       SkASSERT(run + 1 == stop);
-               }
-       }
+            const RunType* run = fRunHead->runs();
+            const RunType* stop = run + fRunHead->fRunCount;
+            
+            SkASSERT(*run++ == fBounds.fTop);
+            do {
+                run = validate_line(run, fBounds);
+            } while (*run < kRunTypeSentinel);
+            SkASSERT(run + 1 == stop);
+        }
+    }
 }
 
 void SkRegion::dump() const
@@ -988,181 +1005,181 @@ void SkRegion::dump() const
 
 SkRegion::Iterator::Iterator(const SkRegion& rgn)
 {
-       if (rgn.isEmpty())
-               fDone = true;
-       else
-       {
-               fDone = false;
-               if (rgn.isRect())
-               {
-                       fRect = rgn.fBounds;
-                       fRuns = nil;
-               }
-               else
-               {
-                       fRuns = rgn.fRunHead->runs();
-                       fRect.set(fRuns[2], fRuns[0], fRuns[3], fRuns[1]);
-                       fRuns += 4;
-               }
-       }
+    if (rgn.isEmpty())
+        fDone = true;
+    else
+    {
+        fDone = false;
+        if (rgn.isRect())
+        {
+            fRect = rgn.fBounds;
+            fRuns = nil;
+        }
+        else
+        {
+            fRuns = rgn.fRunHead->runs();
+            fRect.set(fRuns[2], fRuns[0], fRuns[3], fRuns[1]);
+            fRuns += 4;
+        }
+    }
 }
 
 void SkRegion::Iterator::next()
 {
-       if (fDone) return;
-
-       if (fRuns == nil)       // rect case
-       {
-               fDone = true;
-               return;
-       }
-
-       const RunType* runs = fRuns;
-
-       if (runs[0] < kRunTypeSentinel) // valid X value
-       {
-               fRect.fLeft = runs[0];
-               fRect.fRight = runs[1];
-               runs += 2;
-       }
-       else    // we're at the end of a line
-       {
-               runs += 1;
-               if (runs[0] < kRunTypeSentinel) // valid Y value
-               {
-                       if (runs[1] == kRunTypeSentinel)        // empty line
-                       {
-                               fRect.fTop = runs[0];
-                               runs += 2;
-                       }
-                       else
-                               fRect.fTop = fRect.fBottom;
-       
-                       fRect.fBottom = runs[0];
-                       assert_sentinel(runs[1], false);
-                       fRect.fLeft = runs[1];
-                       fRect.fRight = runs[2];
-                       runs += 3;
-               }
-               else    // end of rgn
-                       fDone = true;
-       }
-       fRuns = runs;
+    if (fDone) return;
+
+    if (fRuns == nil)   // rect case
+    {
+        fDone = true;
+        return;
+    }
+
+    const RunType* runs = fRuns;
+
+    if (runs[0] < kRunTypeSentinel) // valid X value
+    {
+        fRect.fLeft = runs[0];
+        fRect.fRight = runs[1];
+        runs += 2;
+    }
+    else    // we're at the end of a line
+    {
+        runs += 1;
+        if (runs[0] < kRunTypeSentinel) // valid Y value
+        {
+            if (runs[1] == kRunTypeSentinel)    // empty line
+            {
+                fRect.fTop = runs[0];
+                runs += 2;
+            }
+            else
+                fRect.fTop = fRect.fBottom;
+    
+            fRect.fBottom = runs[0];
+            assert_sentinel(runs[1], false);
+            fRect.fLeft = runs[1];
+            fRect.fRight = runs[2];
+            runs += 3;
+        }
+        else    // end of rgn
+            fDone = true;
+    }
+    fRuns = runs;
 }
 
 SkRegion::Cliperator::Cliperator(const SkRegion& rgn, const SkRect16& clip)
-       : fIter(rgn), fClip(clip), fDone(true)
+    : fIter(rgn), fClip(clip), fDone(true)
 {
-       const SkRect16& r = fIter.rect();
-
-       while (!fIter.done())
-       {
-               if (r.fTop >= clip.fBottom)
-                       break;
-               if (fRect.intersect(clip, r))
-               {
-                       fDone = false;
-                       break;
-               }
-               fIter.next();
-       }
+    const SkRect16& r = fIter.rect();
+
+    while (!fIter.done())
+    {
+        if (r.fTop >= clip.fBottom)
+            break;
+        if (fRect.intersect(clip, r))
+        {
+            fDone = false;
+            break;
+        }
+        fIter.next();
+    }
 }
 
 void SkRegion::Cliperator::next()
 {
-       if (fDone) return;
-
-       const SkRect16& r = fIter.rect();
-
-       fDone = true;
-       fIter.next();
-       while (!fIter.done())
-       {
-               if (r.fTop >= fClip.fBottom)
-                       break;
-               if (fRect.intersect(fClip, r))
-               {
-                       fDone = false;
-                       break;
-               }
-               fIter.next();
-       }
+    if (fDone) return;
+
+    const SkRect16& r = fIter.rect();
+
+    fDone = true;
+    fIter.next();
+    while (!fIter.done())
+    {
+        if (r.fTop >= fClip.fBottom)
+            break;
+        if (fRect.intersect(fClip, r))
+        {
+            fDone = false;
+            break;
+        }
+        fIter.next();
+    }
 }
 
 //////////////////////////////////////////////////////////////////////
 
 SkRegion::Spanerator::Spanerator(const SkRegion& rgn, int y, int left, int right)
 {
-       const SkRect16& r = rgn.getBounds();
-
-       fDone = true;
-       if (!rgn.isEmpty() && y >= r.fTop && y < r.fBottom && right > r.fLeft && left < r.fRight)
-       {
-               if (rgn.isRect())
-               {
-                       if (left < r.fLeft)
-                               left = r.fLeft;
-                       if (right > r.fRight)
-                               right = r.fRight;
-
-                       fLeft = left;
-                       fRight = right;
-                       fRuns = nil;    // means we're a rect, not a rgn
-                       fDone = false;
-               }
-               else
-               {
-                       const SkRegion::RunType* runs = find_y(rgn.fRunHead->runs(), y);
-                       if (runs)
-                       {
-                               for (;;)
-                               {
-                                       if (runs[0] >= right)   // runs[0..1] is to the right of the span, so we're done
-                                               break;
-                                       if (runs[1] <= left)    // runs[0..1] is to the left of the span, so continue
-                                       {
-                                               runs += 2;
-                                               continue;
-                                       }
-                                       // runs[0..1] intersects the span
-                                       fRuns = runs;
-                                       fLeft = left;
-                                       fRight = right;
-                                       fDone = false;
-                                       break;
-                               }
-                       }
-               }
-       }
+    const SkRect16& r = rgn.getBounds();
+
+    fDone = true;
+    if (!rgn.isEmpty() && y >= r.fTop && y < r.fBottom && right > r.fLeft && left < r.fRight)
+    {
+        if (rgn.isRect())
+        {
+            if (left < r.fLeft)
+                left = r.fLeft;
+            if (right > r.fRight)
+                right = r.fRight;
+
+            fLeft = left;
+            fRight = right;
+            fRuns = nil;    // means we're a rect, not a rgn
+            fDone = false;
+        }
+        else
+        {
+            const SkRegion::RunType* runs = find_y(rgn.fRunHead->runs(), y);
+            if (runs)
+            {
+                for (;;)
+                {
+                    if (runs[0] >= right)   // runs[0..1] is to the right of the span, so we're done
+                        break;
+                    if (runs[1] <= left)    // runs[0..1] is to the left of the span, so continue
+                    {
+                        runs += 2;
+                        continue;
+                    }
+                    // runs[0..1] intersects the span
+                    fRuns = runs;
+                    fLeft = left;
+                    fRight = right;
+                    fDone = false;
+                    break;
+                }
+            }
+        }
+    }
 }
 
 bool SkRegion::Spanerator::next(int* left, int* right)
 {
-       if (fDone) return false;
-
-       if (fRuns == nil)       // we're a rect
-       {
-               fDone = true;   // ok, now we're done
-               if (left) *left = fLeft;
-               if (right) *right = fRight;
-               return true;    // this interval is legal
-       }
-
-       const SkRegion::RunType* runs = fRuns;
-
-       if (runs[0] >= fRight)
-       {
-               fDone = true;
-               return false;
-       }
-
-       SkASSERT(runs[1] > fLeft);
-
-       if (left)
-               *left = SkMax32(fLeft, runs[0]);
-       if (right)
-               *right = SkMin32(fRight, runs[1]);
-       fRuns = runs + 2;
-       return true;
+    if (fDone) return false;
+
+    if (fRuns == nil)   // we're a rect
+    {
+        fDone = true;   // ok, now we're done
+        if (left) *left = fLeft;
+        if (right) *right = fRight;
+        return true;    // this interval is legal
+    }
+
+    const SkRegion::RunType* runs = fRuns;
+
+    if (runs[0] >= fRight)
+    {
+        fDone = true;
+        return false;
+    }
+
+    SkASSERT(runs[1] > fLeft);
+
+    if (left)
+        *left = SkMax32(fLeft, runs[0]);
+    if (right)
+        *right = SkMin32(fRight, runs[1]);
+    fRuns = runs + 2;
+    return true;
 }
 
index 7626a35..30f0e7f 100644 (file)
@@ -1,11 +1,28 @@
+/* libs/corecg/SkRegionPriv.h
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #ifndef SkRegionPriv_DEFINED
 #define SkRegionPriv_DEFINED
 
 #include "SkRegion.h"
 #include "SkThread.h"
 
-#define kRunTypeSentinel       0x7FFF
-#define assert_sentinel(value, isSentinel)     SkASSERT(((value) == kRunTypeSentinel) == isSentinel)
+#define kRunTypeSentinel    0x7FFF
+#define assert_sentinel(value, isSentinel)  SkASSERT(((value) == kRunTypeSentinel) == isSentinel)
 
 //SkDEBUGCODE(extern int32_t gRgnAllocCounter;)
 
index 2c4c11d..c0d2723 100644 (file)
+/* libs/corecg/SkSinTable.h
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #ifndef SkSinTable_DEFINED
 #define SkSinTable_DEFINED
 
 #include "SkTypes.h"
 
 /* Fixed point values (low 16 bits) of sin(radians) for
-       radians in [0...PI/2)
+    radians in [0...PI/2)
 */
 static const U16 gSkSinTable[256] = {
-       0x0000,
-       0x0192,
-       0x0324,
-       0x04B6,
-       0x0648,
-       0x07DA,
-       0x096C,
-       0x0AFE,
-       0x0C8F,
-       0x0E21,
-       0x0FB2,
-       0x1144,
-       0x12D5,
-       0x1466,
-       0x15F6,
-       0x1787,
-       0x1917,
-       0x1AA7,
-       0x1C37,
-       0x1DC7,
-       0x1F56,
-       0x20E5,
-       0x2273,
-       0x2402,
-       0x2590,
-       0x271D,
-       0x28AA,
-       0x2A37,
-       0x2BC4,
-       0x2D50,
-       0x2EDB,
-       0x3066,
-       0x31F1,
-       0x337B,
-       0x3505,
-       0x368E,
-       0x3817,
-       0x399F,
-       0x3B26,
-       0x3CAD,
-       0x3E33,
-       0x3FB9,
-       0x413E,
-       0x42C3,
-       0x4447,
-       0x45CA,
-       0x474D,
-       0x48CE,
-       0x4A50,
-       0x4BD0,
-       0x4D50,
-       0x4ECF,
-       0x504D,
-       0x51CA,
-       0x5347,
-       0x54C3,
-       0x563E,
-       0x57B8,
-       0x5931,
-       0x5AAA,
-       0x5C22,
-       0x5D98,
-       0x5F0E,
-       0x6083,
-       0x61F7,
-       0x636A,
-       0x64DC,
-       0x664D,
-       0x67BD,
-       0x692D,
-       0x6A9B,
-       0x6C08,
-       0x6D74,
-       0x6EDF,
-       0x7049,
-       0x71B1,
-       0x7319,
-       0x7480,
-       0x75E5,
-       0x774A,
-       0x78AD,
-       0x7A0F,
-       0x7B70,
-       0x7CD0,
-       0x7E2E,
-       0x7F8B,
-       0x80E7,
-       0x8242,
-       0x839C,
-       0x84F4,
-       0x864B,
-       0x87A1,
-       0x88F5,
-       0x8A48,
-       0x8B9A,
-       0x8CEA,
-       0x8E39,
-       0x8F87,
-       0x90D3,
-       0x921E,
-       0x9368,
-       0x94B0,
-       0x95F6,
-       0x973C,
-       0x987F,
-       0x99C2,
-       0x9B02,
-       0x9C42,
-       0x9D7F,
-       0x9EBC,
-       0x9FF6,
-       0xA12F,
-       0xA267,
-       0xA39D,
-       0xA4D2,
-       0xA605,
-       0xA736,
-       0xA866,
-       0xA994,
-       0xAAC0,
-       0xABEB,
-       0xAD14,
-       0xAE3B,
-       0xAF61,
-       0xB085,
-       0xB1A8,
-       0xB2C8,
-       0xB3E7,
-       0xB504,
-       0xB620,
-       0xB73A,
-       0xB852,
-       0xB968,
-       0xBA7C,
-       0xBB8F,
-       0xBCA0,
-       0xBDAE,
-       0xBEBC,
-       0xBFC7,
-       0xC0D0,
-       0xC1D8,
-       0xC2DE,
-       0xC3E2,
-       0xC4E3,
-       0xC5E4,
-       0xC6E2,
-       0xC7DE,
-       0xC8D8,
-       0xC9D1,
-       0xCAC7,
-       0xCBBB,
-       0xCCAE,
-       0xCD9F,
-       0xCE8D,
-       0xCF7A,
-       0xD064,
-       0xD14D,
-       0xD233,
-       0xD318,
-       0xD3FA,
-       0xD4DB,
-       0xD5B9,
-       0xD695,
-       0xD770,
-       0xD848,
-       0xD91E,
-       0xD9F2,
-       0xDAC4,
-       0xDB94,
-       0xDC61,
-       0xDD2D,
-       0xDDF6,
-       0xDEBE,
-       0xDF83,
-       0xE046,
-       0xE106,
-       0xE1C5,
-       0xE282,
-       0xE33C,
-       0xE3F4,
-       0xE4AA,
-       0xE55E,
-       0xE60F,
-       0xE6BE,
-       0xE76B,
-       0xE816,
-       0xE8BF,
-       0xE965,
-       0xEA09,
-       0xEAAB,
-       0xEB4B,
-       0xEBE8,
-       0xEC83,
-       0xED1C,
-       0xEDB2,
-       0xEE46,
-       0xEED8,
-       0xEF68,
-       0xEFF5,
-       0xF080,
-       0xF109,
-       0xF18F,
-       0xF213,
-       0xF294,
-       0xF314,
-       0xF391,
-       0xF40B,
-       0xF484,
-       0xF4FA,
-       0xF56D,
-       0xF5DE,
-       0xF64D,
-       0xF6BA,
-       0xF724,
-       0xF78B,
-       0xF7F1,
-       0xF853,
-       0xF8B4,
-       0xF912,
-       0xF96E,
-       0xF9C7,
-       0xFA1E,
-       0xFA73,
-       0xFAC5,
-       0xFB14,
-       0xFB61,
-       0xFBAC,
-       0xFBF5,
-       0xFC3B,
-       0xFC7E,
-       0xFCBF,
-       0xFCFE,
-       0xFD3A,
-       0xFD74,
-       0xFDAB,
-       0xFDE0,
-       0xFE13,
-       0xFE43,
-       0xFE70,
-       0xFE9B,
-       0xFEC4,
-       0xFEEA,
-       0xFF0E,
-       0xFF2F,
-       0xFF4E,
-       0xFF6A,
-       0xFF84,
-       0xFF9C,
-       0xFFB1,
-       0xFFC3,
-       0xFFD3,
-       0xFFE1,
-       0xFFEC,
-       0xFFF4,
-       0xFFFB,
-       0xFFFE
+    0x0000,
+    0x0192,
+    0x0324,
+    0x04B6,
+    0x0648,
+    0x07DA,
+    0x096C,
+    0x0AFE,
+    0x0C8F,
+    0x0E21,
+    0x0FB2,
+    0x1144,
+    0x12D5,
+    0x1466,
+    0x15F6,
+    0x1787,
+    0x1917,
+    0x1AA7,
+    0x1C37,
+    0x1DC7,
+    0x1F56,
+    0x20E5,
+    0x2273,
+    0x2402,
+    0x2590,
+    0x271D,
+    0x28AA,
+    0x2A37,
+    0x2BC4,
+    0x2D50,
+    0x2EDB,
+    0x3066,
+    0x31F1,
+    0x337B,
+    0x3505,
+    0x368E,
+    0x3817,
+    0x399F,
+    0x3B26,
+    0x3CAD,
+    0x3E33,
+    0x3FB9,
+    0x413E,
+    0x42C3,
+    0x4447,
+    0x45CA,
+    0x474D,
+    0x48CE,
+    0x4A50,
+    0x4BD0,
+    0x4D50,
+    0x4ECF,
+    0x504D,
+    0x51CA,
+    0x5347,
+    0x54C3,
+    0x563E,
+    0x57B8,
+    0x5931,
+    0x5AAA,
+    0x5C22,
+    0x5D98,
+    0x5F0E,
+    0x6083,
+    0x61F7,
+    0x636A,
+    0x64DC,
+    0x664D,
+    0x67BD,
+    0x692D,
+    0x6A9B,
+    0x6C08,
+    0x6D74,
+    0x6EDF,
+    0x7049,
+    0x71B1,
+    0x7319,
+    0x7480,
+    0x75E5,
+    0x774A,
+    0x78AD,
+    0x7A0F,
+    0x7B70,
+    0x7CD0,
+    0x7E2E,
+    0x7F8B,
+    0x80E7,
+    0x8242,
+    0x839C,
+    0x84F4,
+    0x864B,
+    0x87A1,
+    0x88F5,
+    0x8A48,
+    0x8B9A,
+    0x8CEA,
+    0x8E39,
+    0x8F87,
+    0x90D3,
+    0x921E,
+    0x9368,
+    0x94B0,
+    0x95F6,
+    0x973C,
+    0x987F,
+    0x99C2,
+    0x9B02,
+    0x9C42,
+    0x9D7F,
+    0x9EBC,
+    0x9FF6,
+    0xA12F,
+    0xA267,
+    0xA39D,
+    0xA4D2,
+    0xA605,
+    0xA736,
+    0xA866,
+    0xA994,
+    0xAAC0,
+    0xABEB,
+    0xAD14,
+    0xAE3B,
+    0xAF61,
+    0xB085,
+    0xB1A8,
+    0xB2C8,
+    0xB3E7,
+    0xB504,
+    0xB620,
+    0xB73A,
+    0xB852,
+    0xB968,
+    0xBA7C,
+    0xBB8F,
+    0xBCA0,
+    0xBDAE,
+    0xBEBC,
+    0xBFC7,
+    0xC0D0,
+    0xC1D8,
+    0xC2DE,
+    0xC3E2,
+    0xC4E3,
+    0xC5E4,
+    0xC6E2,
+    0xC7DE,
+    0xC8D8,
+    0xC9D1,
+    0xCAC7,
+    0xCBBB,
+    0xCCAE,
+    0xCD9F,
+    0xCE8D,
+    0xCF7A,
+    0xD064,
+    0xD14D,
+    0xD233,
+    0xD318,
+    0xD3FA,
+    0xD4DB,
+    0xD5B9,
+    0xD695,
+    0xD770,
+    0xD848,
+    0xD91E,
+    0xD9F2,
+    0xDAC4,
+    0xDB94,
+    0xDC61,
+    0xDD2D,
+    0xDDF6,
+    0xDEBE,
+    0xDF83,
+    0xE046,
+    0xE106,
+    0xE1C5,
+    0xE282,
+    0xE33C,
+    0xE3F4,
+    0xE4AA,
+    0xE55E,
+    0xE60F,
+    0xE6BE,
+    0xE76B,
+    0xE816,
+    0xE8BF,
+    0xE965,
+    0xEA09,
+    0xEAAB,
+    0xEB4B,
+    0xEBE8,
+    0xEC83,
+    0xED1C,
+    0xEDB2,
+    0xEE46,
+    0xEED8,
+    0xEF68,
+    0xEFF5,
+    0xF080,
+    0xF109,
+    0xF18F,
+    0xF213,
+    0xF294,
+    0xF314,
+    0xF391,
+    0xF40B,
+    0xF484,
+    0xF4FA,
+    0xF56D,
+    0xF5DE,
+    0xF64D,
+    0xF6BA,
+    0xF724,
+    0xF78B,
+    0xF7F1,
+    0xF853,
+    0xF8B4,
+    0xF912,
+    0xF96E,
+    0xF9C7,
+    0xFA1E,
+    0xFA73,
+    0xFAC5,
+    0xFB14,
+    0xFB61,
+    0xFBAC,
+    0xFBF5,
+    0xFC3B,
+    0xFC7E,
+    0xFCBF,
+    0xFCFE,
+    0xFD3A,
+    0xFD74,
+    0xFDAB,
+    0xFDE0,
+    0xFE13,
+    0xFE43,
+    0xFE70,
+    0xFE9B,
+    0xFEC4,
+    0xFEEA,
+    0xFF0E,
+    0xFF2F,
+    0xFF4E,
+    0xFF6A,
+    0xFF84,
+    0xFF9C,
+    0xFFB1,
+    0xFFC3,
+    0xFFD3,
+    0xFFE1,
+    0xFFEC,
+    0xFFF4,
+    0xFFFB,
+    0xFFFE
 };
 
 #endif
index bdfbf6d..44f05bb 100644 (file)
@@ -1,3 +1,20 @@
+/* libs/corecg/SkTSort.h
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #ifndef SkTSort_DEFINED
 #define SkTSort_DEFINED
 
 template <typename T>
 void SkTHeapSort_SiftDown(T array[], int root, int bottom)
 {
-       int     root2 = root << 1;
-
-       while (root2 <= bottom)
-       {
-               int     maxChild;
-
-               if (root2 == bottom)
-                       maxChild = root2;
-               else if (array[root2] > array[root2 + 1])
-                       maxChild = root2;
-               else
-                       maxChild = root2 + 1;
-
-               if (array[root] < array[maxChild])
-               {
-                       SkTSwap<T>(array[root], array[maxChild]);
-                       root = maxChild;
-                       root2 = root << 1;
-               }
-               else
-                       break;
-       }
+    int root2 = root << 1;
+
+    while (root2 <= bottom)
+    {
+        int maxChild;
+
+        if (root2 == bottom)
+            maxChild = root2;
+        else if (array[root2] > array[root2 + 1])
+            maxChild = root2;
+        else
+            maxChild = root2 + 1;
+
+        if (array[root] < array[maxChild])
+        {
+            SkTSwap<T>(array[root], array[maxChild]);
+            root = maxChild;
+            root2 = root << 1;
+        }
+        else
+            break;
+    }
 }
 
 template <typename T>
 void SkTHeapSort(T array[], int count)
 {
-       int i;
+    int i;
 
-       for (i = count/2 - 1; i >= 0; --i)
-               SkTHeapSort_SiftDown<T>(array, i, count);
+    for (i = count/2 - 1; i >= 0; --i)
+        SkTHeapSort_SiftDown<T>(array, i, count);
 
-       for (i = count - 2; i >= 0; --i)
-       {
-               SkTSwap<T>(array[0], array[i + 1]);
-               SkTHeapSort_SiftDown<T>(array, 0, i);
-       }
+    for (i = count - 2; i >= 0; --i)
+    {
+        SkTSwap<T>(array[0], array[i + 1]);
+        SkTHeapSort_SiftDown<T>(array, 0, i);
+    }
 }
 
 #endif
index 7bccd3a..1aeb4b5 100644 (file)
@@ -23,6 +23,8 @@ LOCAL_SRC_FILES:= \
        images/SkImageDecoder_libgif.cpp \
        images/SkImageDecoder_libjpeg.cpp \
        images/SkImageDecoder_libpng.cpp \
+       images/SkImageDecoder_libico.cpp \
+       images/SkImageDecoder_zbm.cpp \
        images/SkStream.cpp \
        sgl/SkAlphaRuns.cpp \
        sgl/SkBitmap.cpp \
@@ -68,27 +70,14 @@ LOCAL_SRC_FILES:= \
        sgl/SkStroke.cpp \
        sgl/SkStrokerPriv.cpp \
        sgl/SkTSearch.cpp \
-    sgl/SkTextLayout.cpp \
        sgl/SkUtils.cpp \
        sgl/SkXfermode.cpp \
-       views/SkEvent.cpp \
-    views/SkEventSink.cpp \
-    views/SkMetaData.cpp \
-    views/SkTagList.cpp \
-    views/SkTextBox.cpp \
        ports/SkImageDecoder_Factory.cpp \
-       ports/SkFontHost.cpp \
+       ports/SkFontHost_android.cpp \
        ports/SkFontHost_FreeType.cpp \
        ports/SkGlobals_global.cpp \
        ports/SkOSFile_stdio.cpp \
-       ports/SkOSEvent_android.cpp \
-       ports/SkTime_Unix.cpp \
-       ports/SkXMLParser_expat.cpp \
-       xml/SkDOM.cpp \
-       xml/SkXMLParser.cpp \
-       xml/SkXMLWriter.cpp \
-       xml/SkParseColor.cpp \
-       xml/SkParse.cpp
+       ports/SkTime_Unix.cpp
 
 LOCAL_SHARED_LIBRARIES := \
        libutils \
@@ -121,8 +110,10 @@ else
        LOCAL_CFLAGS += -fpic
 endif
 
+LOCAL_CFLAGS += -fstrict-aliasing
+
 ifeq ($(DEVICE_ARCH),arm)
-       LOCAL_CFLAGS += -DFMS_ARCH_ANDROID_ARM
+       LOCAL_CFLAGS += -DFMS_ARCH_ANDROID_ARM -fomit-frame-pointer
 endif
 
 # TODO RELEASE_BUILD isn't right
index aa593bf..5500798 100644 (file)
@@ -1,3 +1,20 @@
+/* libs/graphics/animator/SkAnimate.h
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #ifndef SkAnimate_DEFINED
 #define SkAnimate_DEFINED
 
 #include "SkUtils.h"
 
 class SkAnimate : public SkAnimateBase {
-       DECLARE_MEMBER_INFO(Animate);
-       SkAnimate();
-       virtual ~SkAnimate();
-       virtual int components();
+    DECLARE_MEMBER_INFO(Animate);
+    SkAnimate();
+    virtual ~SkAnimate();
+    virtual int components();
 #ifdef SK_DUMP_ENABLED
-       virtual void dump(SkAnimateMaker* );
+    virtual void dump(SkAnimateMaker* );
 #endif
-       virtual void onEndElement(SkAnimateMaker& maker);
+    virtual void onEndElement(SkAnimateMaker& maker);
 protected:
-       bool resolveCommon(SkAnimateMaker& );
-       int fComponents;
+    bool resolveCommon(SkAnimateMaker& );
+    int fComponents;
 private:
-       typedef SkAnimateBase INHERITED;
+    typedef SkAnimateBase INHERITED;
 };
 
 #endif // SkAnimateField_DEFINED
index 85f676f..61dea4b 100644 (file)
@@ -1,3 +1,20 @@
+/* libs/graphics/animator/SkAnimateActive.cpp
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #include "SkAnimateActive.h"
 #include "SkAnimateBase.h"
 #include "SkAnimateMaker.h"
 // SkActive holds array of interpolators
 
 SkActive::SkActive(SkApply& apply, SkAnimateMaker& maker) : fApply(apply),
-       fMaxTime(0), fMaker(maker), fDrawIndex(0), fDrawMax(0) {
+    fMaxTime(0), fMaker(maker), fDrawIndex(0), fDrawMax(0) {
 }
 
 void SkActive::init() 
 {
-       fAnimators = fApply.fAnimators;
-       int animators = fAnimators.count();
-       fInterpolators.setCount(animators);
-       memset(fInterpolators.begin(), 0, animators * sizeof(SkOperandInterpolator*));
-       fState.setCount(animators);
-       int index;
-       for (index = 0; index < animators; index++)
-               fInterpolators[index] = SkNEW(SkOperandInterpolator);
-       initState(&fApply, 0);
-//     for (index = 0; index < animators; index++)
-//             fState[index].bumpSave();
-       SkASSERT(fInterpolators.count() == fAnimators.count());
+    fAnimators = fApply.fAnimators;
+    int animators = fAnimators.count();
+    fInterpolators.setCount(animators);
+    memset(fInterpolators.begin(), 0, animators * sizeof(SkOperandInterpolator*));
+    fState.setCount(animators);
+    int index;
+    for (index = 0; index < animators; index++)
+        fInterpolators[index] = SkNEW(SkOperandInterpolator);
+    initState(&fApply, 0);
+//  for (index = 0; index < animators; index++)
+//      fState[index].bumpSave();
+    SkASSERT(fInterpolators.count() == fAnimators.count());
 }
 
 SkActive::~SkActive() {
-       int index;
-       for (index = 0; index < fSaveRestore.count(); index++)
-               delete[] fSaveRestore[index];
-       for (index = 0; index < fSaveInterpolators.count(); index++)
-               delete[] fSaveInterpolators[index];
-       for (index = 0; index < fInterpolators.count(); index++)
-               delete fInterpolators[index];
+    int index;
+    for (index = 0; index < fSaveRestore.count(); index++)
+        delete[] fSaveRestore[index];
+    for (index = 0; index < fSaveInterpolators.count(); index++)
+        delete[] fSaveInterpolators[index];
+    for (index = 0; index < fInterpolators.count(); index++)
+        delete fInterpolators[index];
 }
 
 void SkActive::advance() {
-       if (fDrawMax < fDrawIndex)
-               fDrawMax = fDrawIndex;
-       fDrawIndex += fAnimators.count();
+    if (fDrawMax < fDrawIndex)
+        fDrawMax = fDrawIndex;
+    fDrawIndex += fAnimators.count();
 }
 
 void SkActive::append(SkApply* apply) {
-       int oldCount = fAnimators.count();
-       SkTDAnimateArray& animates = apply->fAnimators;
-       int newCount = animates.count();
-       int index;
-       int total = oldCount + newCount;
-       if (total == 0)
-               return;
-       fInterpolators.setCount(total);
-       memset(&fInterpolators.begin()[oldCount], 0, newCount * sizeof(SkOperandInterpolator*));
-       for (index = oldCount; index < total; index++)
-               fInterpolators[index] = SkNEW(SkOperandInterpolator);
-       fAnimators.setCount(total);
-       memcpy(&fAnimators[oldCount], animates.begin(), sizeof(fAnimators[0]) *
-               newCount);
-       fState.setCount(total);
-       initState(apply, oldCount);
-       SkASSERT(fApply.scope == apply->scope);
-       for (index = 0; index < newCount; index++) {
-               SkAnimateBase* test = animates[index];
-//             SkASSERT(fApply.scope == test->fTarget || fApply.scope->contains(test->fTarget));
-               SkActive::SkState& testState = fState[oldCount + index];
-               for (int inner = 0; inner < oldCount; inner++) {
-                       SkAnimateBase* oldGuard = fAnimators[inner];
-                       SkActive::SkState& oldState = fState[inner];
-                       if (oldGuard->fTarget == test->fTarget && oldGuard->fFieldInfo == test->fFieldInfo &&
-                                       testState.fBegin == oldState.fBegin) {
-                               delete fInterpolators[inner];
-                               fInterpolators.remove(inner);
-                               fAnimators.remove(inner);
-                               testState.fSave = oldState.fSave;
-                               if (oldState.fUnpostedEndEvent) {
-//                                     SkDEBUGF(("%8x %8x active append: post on end\n", this, oldGuard));
-                                       fMaker.postOnEnd(oldGuard, oldState.fBegin + oldState.fDuration);
-                               }
-                               fState.remove(inner);
-                               if (fApply.restore) {
-                                       int saveIndex = fSaveRestore.count();
-                                       SkASSERT(fSaveInterpolators.count() == saveIndex);
-                                       saveIndex += inner;
-                                       do {
-                                               saveIndex -= oldCount;
-                                               delete[] fSaveRestore[saveIndex];
-                                               fSaveRestore.remove(saveIndex);
-                                               delete[] fSaveInterpolators[saveIndex]; 
-                                               fSaveInterpolators.remove(saveIndex);
-                                       } while (saveIndex > 0);
-                               }
-                               oldCount--;
-                               break;
-                       }
-               }
-       }
-//     total = oldCount + newCount;
-//     for (index = oldCount; index < total; index++)
-//             fState[index].bumpSave();
-       SkASSERT(fInterpolators.count() == fAnimators.count());
+    int oldCount = fAnimators.count();
+    SkTDAnimateArray& animates = apply->fAnimators;
+    int newCount = animates.count();
+    int index;
+    int total = oldCount + newCount;
+    if (total == 0)
+        return;
+    fInterpolators.setCount(total);
+    memset(&fInterpolators.begin()[oldCount], 0, newCount * sizeof(SkOperandInterpolator*));
+    for (index = oldCount; index < total; index++)
+        fInterpolators[index] = SkNEW(SkOperandInterpolator);
+    fAnimators.setCount(total);
+    memcpy(&fAnimators[oldCount], animates.begin(), sizeof(fAnimators[0]) *
+        newCount);
+    fState.setCount(total);
+    initState(apply, oldCount);
+    SkASSERT(fApply.scope == apply->scope);
+    for (index = 0; index < newCount; index++) {
+        SkAnimateBase* test = animates[index];
+//      SkASSERT(fApply.scope == test->fTarget || fApply.scope->contains(test->fTarget));
+        SkActive::SkState& testState = fState[oldCount + index];
+        for (int inner = 0; inner < oldCount; inner++) {
+            SkAnimateBase* oldGuard = fAnimators[inner];
+            SkActive::SkState& oldState = fState[inner];
+            if (oldGuard->fTarget == test->fTarget && oldGuard->fFieldInfo == test->fFieldInfo &&
+                    testState.fBegin == oldState.fBegin) {
+                delete fInterpolators[inner];
+                fInterpolators.remove(inner);
+                fAnimators.remove(inner);
+                testState.fSave = oldState.fSave;
+                if (oldState.fUnpostedEndEvent) {
+//                  SkDEBUGF(("%8x %8x active append: post on end\n", this, oldGuard));
+                    fMaker.postOnEnd(oldGuard, oldState.fBegin + oldState.fDuration);
+                }
+                fState.remove(inner);
+                if (fApply.restore) {
+                    int saveIndex = fSaveRestore.count();
+                    SkASSERT(fSaveInterpolators.count() == saveIndex);
+                    saveIndex += inner;
+                    do {
+                        saveIndex -= oldCount;
+                        delete[] fSaveRestore[saveIndex];
+                        fSaveRestore.remove(saveIndex);
+                        delete[] fSaveInterpolators[saveIndex]; 
+                        fSaveInterpolators.remove(saveIndex);
+                    } while (saveIndex > 0);
+                }
+                oldCount--;
+                break;
+            }
+        }
+    }
+//  total = oldCount + newCount;
+//  for (index = oldCount; index < total; index++)
+//      fState[index].bumpSave();
+    SkASSERT(fInterpolators.count() == fAnimators.count());
 }
 
 void SkActive::appendSave(int oldCount) {
-       SkASSERT(fDrawMax == 0);        // if true, we can optimize below quite a bit
-       int newCount = fAnimators.count();
-       int saveIndex = fSaveRestore.count();
-       SkASSERT(fSaveInterpolators.count() == saveIndex);
-       int records = saveIndex / oldCount;
-       int newTotal = records * newCount;
-       fSaveRestore.setCount(newTotal);
-       do {
-               saveIndex -= oldCount;
-               newTotal -= newCount;
-               SkASSERT(saveIndex >= 0);
-               SkASSERT(newTotal >= 0);
-               memmove(&fSaveRestore[newTotal], &fSaveRestore[saveIndex], oldCount);
-               memset(&fSaveRestore[newTotal + oldCount], 0, 
-                       sizeof(fSaveRestore[0]) * (newCount - oldCount));
-               memmove(&fSaveInterpolators[newTotal], 
-                       &fSaveInterpolators[saveIndex], oldCount);
-               memset(&fSaveInterpolators[newTotal + oldCount], 0, 
-                       sizeof(fSaveRestore[0]) * (newCount - oldCount));
-       } while (saveIndex > 0);
-       SkASSERT(newTotal == 0);
+    SkASSERT(fDrawMax == 0);    // if true, we can optimize below quite a bit
+    int newCount = fAnimators.count();
+    int saveIndex = fSaveRestore.count();
+    SkASSERT(fSaveInterpolators.count() == saveIndex);
+    int records = saveIndex / oldCount;
+    int newTotal = records * newCount;
+    fSaveRestore.setCount(newTotal);
+    do {
+        saveIndex -= oldCount;
+        newTotal -= newCount;
+        SkASSERT(saveIndex >= 0);
+        SkASSERT(newTotal >= 0);
+        memmove(&fSaveRestore[newTotal], &fSaveRestore[saveIndex], oldCount);
+        memset(&fSaveRestore[newTotal + oldCount], 0, 
+            sizeof(fSaveRestore[0]) * (newCount - oldCount));
+        memmove(&fSaveInterpolators[newTotal], 
+            &fSaveInterpolators[saveIndex], oldCount);
+        memset(&fSaveInterpolators[newTotal + oldCount], 0, 
+            sizeof(fSaveRestore[0]) * (newCount - oldCount));
+    } while (saveIndex > 0);
+    SkASSERT(newTotal == 0);
 }
 
 void SkActive::calcDurations(int index) 
 {
-       SkAnimateBase* animate = fAnimators[index];
-       SkMSec duration = animate->dur;
-       SkState& state = fState[index];
-       if (state.fMode == SkApply::kMode_immediate || state.fMode == SkApply::kMode_create)
-               duration = state.fSteps ? state.fSteps * SK_MSec1 : 1;
-//     else if (state.fMode == SkApply::kMode_hold) {
-//             int entries = animate->entries();
-//             SkScriptValue value;
-//             value.fOperand = animate->getValues()[entries - 1];
-//             value.fType = animate->getValuesType();
-//             bool result = SkScriptEngine::ConvertTo(nil, SkType_Int, &value);
-//             SkASSERT(result);
-//             duration = value.fOperand.fS32 * SK_MSec1;
-//     }
-       state.fDuration = duration;
-       SkMSec maxTime = state.fBegin + duration;
-       if (fMaxTime < maxTime)
-               fMaxTime = maxTime;
+    SkAnimateBase* animate = fAnimators[index];
+    SkMSec duration = animate->dur;
+    SkState& state = fState[index];
+    if (state.fMode == SkApply::kMode_immediate || state.fMode == SkApply::kMode_create)
+        duration = state.fSteps ? state.fSteps * SK_MSec1 : 1;
+//  else if (state.fMode == SkApply::kMode_hold) {
+//      int entries = animate->entries();
+//      SkScriptValue value;
+//      value.fOperand = animate->getValues()[entries - 1];
+//      value.fType = animate->getValuesType();
+//      bool result = SkScriptEngine::ConvertTo(nil, SkType_Int, &value);
+//      SkASSERT(result);
+//      duration = value.fOperand.fS32 * SK_MSec1;
+//  }
+    state.fDuration = duration;
+    SkMSec maxTime = state.fBegin + duration;
+    if (fMaxTime < maxTime)
+        fMaxTime = maxTime;
 }
 
 void SkActive::create(SkDrawable* drawable, SkMSec time) {
-       fApply.fLastTime = time;
-       fApply.refresh(fMaker);
-       for (int index = 0; index < fAnimators.count(); index++) {
-               SkAnimateBase* animate = fAnimators[index];
-               SkOperandInterpolator& interpolator = *fInterpolators[index];
-               int count = animate->components();
-               if (animate->formula.size() > 0) {
-                       SkTDOperandArray values;
-                       values.setCount(count);
-                       bool success = animate->fFieldInfo->setValue(fMaker, &values, 0, 0, nil, 
-                               animate->getValuesType(), animate->formula);
-                       SkASSERT(success);
-                       fApply.applyValues(index, values.begin(), count, animate->getValuesType(), time);
-               } else {
-                       SkAutoSTMalloc<16, SkOperand> values(count);
-                       interpolator.timeToValues(time, values.get());
-                       fApply.applyValues(index, values.get(), count, animate->getValuesType(), time);
-               }
-       }
-       drawable->enable(fMaker);
-       SkASSERT(fAnimators.count() == fInterpolators.count());
+    fApply.fLastTime = time;
+    fApply.refresh(fMaker);
+    for (int index = 0; index < fAnimators.count(); index++) {
+        SkAnimateBase* animate = fAnimators[index];
+        SkOperandInterpolator& interpolator = *fInterpolators[index];
+        int count = animate->components();
+        if (animate->formula.size() > 0) {
+            SkTDOperandArray values;
+            values.setCount(count);
+            bool success = animate->fFieldInfo->setValue(fMaker, &values, 0, 0, nil, 
+                animate->getValuesType(), animate->formula);
+            SkASSERT(success);
+            fApply.applyValues(index, values.begin(), count, animate->getValuesType(), time);
+        } else {
+            SkAutoSTMalloc<16, SkOperand> values(count);
+            interpolator.timeToValues(time, values.get());
+            fApply.applyValues(index, values.get(), count, animate->getValuesType(), time);
+        }
+    }
+    drawable->enable(fMaker);
+    SkASSERT(fAnimators.count() == fInterpolators.count());
 }
 
 bool SkActive::immediate(bool enable) {
-       SkMSec time = 0;
-       bool result = false;
-       SkDrawable* drawable = fApply.scope;
-       SkMSec final = fMaxTime;
-       do {
-               bool applied = fAnimators.count() == 0;
-               fApply.fLastTime = time;
-               fApply.refresh(fMaker);
-               for (int index = 0; index < fAnimators.count(); index++) {
-                       SkAnimateBase* animate = fAnimators[index];
-                       SkState& state = fState[index];
-                       if (state.fMode != SkApply::kMode_immediate)
-                               continue;
-                       if (state.fBegin > time)
-                               continue;
-                       if (time > state.fBegin + state.fDuration)
-                               continue;
-                       applied = true;
-                       SkOperandInterpolator& interpolator = *fInterpolators[index];
-                       int count = animate->components();
-                       if (animate->formula.size() > 0) {
-                               SkTDOperandArray values;
-                               values.setCount(count);
-                               bool success = animate->fFieldInfo->setValue(fMaker, &values, 0, 0, nil, 
-                                       animate->getValuesType(), animate->formula);
-                               SkASSERT(success);
-                               fApply.applyValues(index, values.begin(), count, animate->getValuesType(), time);
-                       } else {
-                               SkAutoSTMalloc<16, SkOperand> values(count);
-                               interpolator.timeToValues(time, values.get());
-                               fApply.applyValues(index, values.get(), count, animate->getValuesType(), time);
-                       }
-               }
-               if (enable)
-                       drawable->enable(fMaker);
-               else if (applied)
-                       result |= drawable->draw(fMaker);
-               time += SK_MSec1;
-       } while (time <= final);
-       return result;
+    SkMSec time = 0;
+    bool result = false;
+    SkDrawable* drawable = fApply.scope;
+    SkMSec final = fMaxTime;
+    do {
+        bool applied = fAnimators.count() == 0;
+        fApply.fLastTime = time;
+        fApply.refresh(fMaker);
+        for (int index = 0; index < fAnimators.count(); index++) {
+            SkAnimateBase* animate = fAnimators[index];
+            SkState& state = fState[index];
+            if (state.fMode != SkApply::kMode_immediate)
+                continue;
+            if (state.fBegin > time)
+                continue;
+            if (time > state.fBegin + state.fDuration)
+                continue;
+            applied = true;
+            SkOperandInterpolator& interpolator = *fInterpolators[index];
+            int count = animate->components();
+            if (animate->formula.size() > 0) {
+                SkTDOperandArray values;
+                values.setCount(count);
+                bool success = animate->fFieldInfo->setValue(fMaker, &values, 0, 0, nil, 
+                    animate->getValuesType(), animate->formula);
+                SkASSERT(success);
+                fApply.applyValues(index, values.begin(), count, animate->getValuesType(), time);
+            } else {
+                SkAutoSTMalloc<16, SkOperand> values(count);
+                interpolator.timeToValues(time, values.get());
+                fApply.applyValues(index, values.get(), count, animate->getValuesType(), time);
+            }
+        }
+        if (enable)
+            drawable->enable(fMaker);
+        else if (applied)
+            result |= drawable->draw(fMaker);
+        time += SK_MSec1;
+    } while (time <= final);
+    return result;
 }
 
 void SkActive::fixInterpolator(SkBool save) {
-       int animators = fAnimators.count();
-       for (int index = 0; index < animators; index++) {
-               SkAnimateBase* animate = fAnimators[index];
-               if (save) { // saved slots increased
-                       animate->refresh(fMaker);
-                       SkOperand* values = animate->getValues();
-                       setInterpolator(index, values);
-                       saveInterpolatorValues(index);
-               } else
-                       restoreInterpolatorValues(index);
-       }
+    int animators = fAnimators.count();
+    for (int index = 0; index < animators; index++) {
+        SkAnimateBase* animate = fAnimators[index];
+        if (save) { // saved slots increased
+            animate->refresh(fMaker);
+            SkOperand* values = animate->getValues();
+            setInterpolator(index, values);
+            saveInterpolatorValues(index);
+        } else
+            restoreInterpolatorValues(index);
+    }
 }
 
 SkMSec SkActive::getTime(SkMSec inTime, int animatorIndex) {
-       fState[animatorIndex].fTicks = inTime;
-       return inTime - fState[animatorIndex].fStartTime;
+    fState[animatorIndex].fTicks = inTime;
+    return inTime - fState[animatorIndex].fStartTime;
 }
 
 bool SkActive::initializeSave() {
-       int animators = fAnimators.count();
-       int activeTotal = fDrawIndex + animators;
-       int oldCount = fSaveRestore.count();
-       if (oldCount < activeTotal) {
-               fSaveRestore.setCount(activeTotal);
-               memset(&fSaveRestore[oldCount], 0, sizeof(fSaveRestore[0]) * (activeTotal - oldCount));
-               SkASSERT(fSaveInterpolators.count() == oldCount);
-               fSaveInterpolators.setCount(activeTotal);
-               memset(&fSaveInterpolators[oldCount], 0, 
-                       sizeof(fSaveInterpolators[0]) * (activeTotal - oldCount));
-               return true;
-       }
-       return false;
+    int animators = fAnimators.count();
+    int activeTotal = fDrawIndex + animators;
+    int oldCount = fSaveRestore.count();
+    if (oldCount < activeTotal) {
+        fSaveRestore.setCount(activeTotal);
+        memset(&fSaveRestore[oldCount], 0, sizeof(fSaveRestore[0]) * (activeTotal - oldCount));
+        SkASSERT(fSaveInterpolators.count() == oldCount);
+        fSaveInterpolators.setCount(activeTotal);
+        memset(&fSaveInterpolators[oldCount], 0, 
+            sizeof(fSaveInterpolators[0]) * (activeTotal - oldCount));
+        return true;
+    }
+    return false;
 }
 
 void SkActive::initState(SkApply* apply, int offset) {
-       int count = fState.count();
-       for (int index = offset; index < count; index++) {
-               SkState& state = fState[index];
-               SkAnimateBase* animate = fAnimators[index];
+    int count = fState.count();
+    for (int index = offset; index < count; index++) {
+        SkState& state = fState[index];
+        SkAnimateBase* animate = fAnimators[index];
 #if 0 // def SK_DEBUG
-               if (animate->fHasEndEvent)
-                       SkDebugf("%8x %8x active initState:\n", this, animate);
+        if (animate->fHasEndEvent)
+            SkDebugf("%8x %8x active initState:\n", this, animate);
 #endif
-               SkOperand* from = animate->getValues();
-               state.fStartTime = state.fBegin = apply->begin + animate->begin;
-               state.fMode = apply->mode;
-               state.fTransition = apply->transition;
+        SkOperand* from = animate->getValues();
+        state.fStartTime = state.fBegin = apply->begin + animate->begin;
+        state.fMode = apply->mode;
+        state.fTransition = apply->transition;
 #if 0
-               state.fPickup = (SkBool8) apply->pickup;
+        state.fPickup = (SkBool8) apply->pickup;
 #endif
-               state.fRestore = (SkBool8) apply->restore;
-               state.fSave = apply->begin;
-               state.fStarted = false;
-               state.fSteps = apply->steps;
-               state.fTicks = 0;
-               state.fUnpostedEndEvent = (SkBool8) animate->fHasEndEvent; 
-               calcDurations(index);
-               setInterpolator(index, from);
-       }
-       if (count == 0 && (apply->mode == SkApply::kMode_immediate || apply->mode == SkApply::kMode_create))
-               fMaxTime = apply->begin + apply->steps * SK_MSec1;
+        state.fRestore = (SkBool8) apply->restore;
+        state.fSave = apply->begin;
+        state.fStarted = false;
+        state.fSteps = apply->steps;
+        state.fTicks = 0;
+        state.fUnpostedEndEvent = (SkBool8) animate->fHasEndEvent; 
+        calcDurations(index);
+        setInterpolator(index, from);
+    }
+    if (count == 0 && (apply->mode == SkApply::kMode_immediate || apply->mode == SkApply::kMode_create))
+        fMaxTime = apply->begin + apply->steps * SK_MSec1;
 }
 
 void SkActive::pickUp(SkActive* existing) {
-       SkTDOperandArray existingValues;
-       for (int index = 0; index < fAnimators.count(); index++) {
-               SkAnimateBase* animate = fAnimators[index];
-               SkASSERT(animate->getValuesType() == SkType_Float);
-               int components = animate->components();
-               SkOperand* from = animate->getValues();
-               SkOperand* to = &from[animate->components()];
-               existingValues.setCount(components);
-               existing->fInterpolators[index]->timeToValues(
-                       existing->fState[index].fTicks - existing->fState[index].fStartTime, existingValues.begin());
-               SkScalar originalSum = 0;
-               SkScalar workingSum = 0;
-               for (int cIndex = 0; cIndex < components; cIndex++) {
-                       SkScalar delta = to[cIndex].fScalar - from[cIndex].fScalar;
-                       originalSum += SkScalarMul(delta, delta);
-                       delta = to[cIndex].fScalar - existingValues[cIndex].fScalar;
-                       workingSum += SkScalarMul(delta, delta);
-               }
-               if (workingSum < originalSum) {
-                       SkScalar originalDistance = SkScalarSqrt(originalSum);
-                       SkScalar workingDistance = SkScalarSqrt(workingSum);
-                       existing->fState[index].fDuration = (SkMSec) SkScalarMulDiv(fState[index].fDuration, 
-                               workingDistance, originalDistance);
-               }
-               fInterpolators[index]->reset(components, 2, SkType_Float);
-               fInterpolators[index]->setKeyFrame(0, 0, existingValues.begin(), animate->blend[0]);
-               fInterpolators[index]->setKeyFrame(1, fState[index].fDuration, to, animate->blend[0]);
-       }
+    SkTDOperandArray existingValues;
+    for (int index = 0; index < fAnimators.count(); index++) {
+        SkAnimateBase* animate = fAnimators[index];
+        SkASSERT(animate->getValuesType() == SkType_Float);
+        int components = animate->components();
+        SkOperand* from = animate->getValues();
+        SkOperand* to = &from[animate->components()];
+        existingValues.setCount(components);
+        existing->fInterpolators[index]->timeToValues(
+            existing->fState[index].fTicks - existing->fState[index].fStartTime, existingValues.begin());
+        SkScalar originalSum = 0;
+        SkScalar workingSum = 0;
+        for (int cIndex = 0; cIndex < components; cIndex++) {
+            SkScalar delta = to[cIndex].fScalar - from[cIndex].fScalar;
+            originalSum += SkScalarMul(delta, delta);
+            delta = to[cIndex].fScalar - existingValues[cIndex].fScalar;
+            workingSum += SkScalarMul(delta, delta);
+        }
+        if (workingSum < originalSum) {
+            SkScalar originalDistance = SkScalarSqrt(originalSum);
+            SkScalar workingDistance = SkScalarSqrt(workingSum);
+            existing->fState[index].fDuration = (SkMSec) SkScalarMulDiv(fState[index].fDuration, 
+                workingDistance, originalDistance);
+        }
+        fInterpolators[index]->reset(components, 2, SkType_Float);
+        fInterpolators[index]->setKeyFrame(0, 0, existingValues.begin(), animate->blend[0]);
+        fInterpolators[index]->setKeyFrame(1, fState[index].fDuration, to, animate->blend[0]);
+    }
 }
 
 void SkActive::resetInterpolators() {
-       int animators = fAnimators.count();
-       for (int index = 0; index < animators; index++) {
-               SkAnimateBase* animate = fAnimators[index];
-               SkOperand* values = animate->getValues();
-               setInterpolator(index, values);
-       }
+    int animators = fAnimators.count();
+    for (int index = 0; index < animators; index++) {
+        SkAnimateBase* animate = fAnimators[index];
+        SkOperand* values = animate->getValues();
+        setInterpolator(index, values);
+    }
 }
 
 void SkActive::resetState() {
-       fDrawIndex = 0;
-       int count = fState.count();
-       for (int index = 0; index < count; index++) {
-               SkState& state = fState[index];
-               SkAnimateBase* animate = fAnimators[index];
+    fDrawIndex = 0;
+    int count = fState.count();
+    for (int index = 0; index < count; index++) {
+        SkState& state = fState[index];
+        SkAnimateBase* animate = fAnimators[index];
 #if 0 // def SK_DEBUG
-               if (animate->fHasEndEvent)
-                       SkDebugf("%8x %8x active resetState: has end event\n", this, animate);
+        if (animate->fHasEndEvent)
+            SkDebugf("%8x %8x active resetState: has end event\n", this, animate);
 #endif
-               state.fStartTime = state.fBegin = fApply.begin + animate->begin;
-               state.fStarted = false;
-               state.fTicks = 0;
-       }
+        state.fStartTime = state.fBegin = fApply.begin + animate->begin;
+        state.fStarted = false;
+        state.fTicks = 0;
+    }
 }
 
 void SkActive::restoreInterpolatorValues(int index) {
-       SkOperandInterpolator& interpolator = *fInterpolators[index];
-       index += fDrawIndex ;
-       int count = interpolator.getValuesCount();
-       memcpy(interpolator.getValues(), fSaveInterpolators[index], count * sizeof(SkOperand));
+    SkOperandInterpolator& interpolator = *fInterpolators[index];
+    index += fDrawIndex ;
+    int count = interpolator.getValuesCount();
+    memcpy(interpolator.getValues(), fSaveInterpolators[index], count * sizeof(SkOperand));
 }
 
 void SkActive::saveInterpolatorValues(int index) {
-       SkOperandInterpolator& interpolator = *fInterpolators[index];
-       index += fDrawIndex ;
-       int count = interpolator.getValuesCount();
-       SkOperand* cache = new SkOperand[count];        // this should use sk_malloc/sk_free since SkOperand does not have a constructor/destructor
-       fSaveInterpolators[index] = cache;
-       memcpy(cache,   interpolator.getValues(), count * sizeof(SkOperand));
+    SkOperandInterpolator& interpolator = *fInterpolators[index];
+    index += fDrawIndex ;
+    int count = interpolator.getValuesCount();
+    SkOperand* cache = new SkOperand[count];    // this should use sk_malloc/sk_free since SkOperand does not have a constructor/destructor
+    fSaveInterpolators[index] = cache;
+    memcpy(cache,   interpolator.getValues(), count * sizeof(SkOperand));
 }
 
 void SkActive::setInterpolator(int index, SkOperand* from) {
-       if (from == nil) // legitimate for set string
-               return;
-       SkAnimateBase* animate = fAnimators[index];
-       int entries = animate->entries();
-       SkASSERT(entries > 0);
-       SkMSec duration = fState[index].fDuration;
-       int components = animate->components();
-       SkOperandInterpolator& interpolator = *fInterpolators[index];
-       interpolator.reset(components, entries == 1 ? 2 : entries, animate->getValuesType()); 
-       interpolator.setMirror(SkToBool(animate->fMirror));
-       interpolator.setReset(SkToBool(animate->fReset));
-       interpolator.setRepeatCount(animate->repeat);
-       if (entries == 1) {
-               interpolator.setKeyFrame(0, 0, from, animate->blend[0]);
-               interpolator.setKeyFrame(1, duration, from, animate->blend[0]);
-               return;
-       }
-       for (int entry = 0; entry < entries; entry++) {
-               int blendIndex = SkMin32(animate->blend.count() - 1, entry);
-               interpolator.setKeyFrame(entry, entry * duration / (entries - 1), from, 
-                       animate->blend[blendIndex]);
-               from += components;
-       }
+    if (from == nil) // legitimate for set string
+        return;
+    SkAnimateBase* animate = fAnimators[index];
+    int entries = animate->entries();
+    SkASSERT(entries > 0);
+    SkMSec duration = fState[index].fDuration;
+    int components = animate->components();
+    SkOperandInterpolator& interpolator = *fInterpolators[index];
+    interpolator.reset(components, entries == 1 ? 2 : entries, animate->getValuesType()); 
+    interpolator.setMirror(SkToBool(animate->fMirror));
+    interpolator.setReset(SkToBool(animate->fReset));
+    interpolator.setRepeatCount(animate->repeat);
+    if (entries == 1) {
+        interpolator.setKeyFrame(0, 0, from, animate->blend[0]);
+        interpolator.setKeyFrame(1, duration, from, animate->blend[0]);
+        return;
+    }
+    for (int entry = 0; entry < entries; entry++) {
+        int blendIndex = SkMin32(animate->blend.count() - 1, entry);
+        interpolator.setKeyFrame(entry, entry * duration / (entries - 1), from, 
+            animate->blend[blendIndex]);
+        from += components;
+    }
 }
 
 void SkActive::setSteps(int steps) {
-       int count = fState.count();
-       fMaxTime = 0;
-       for (int index = 0; index < count; index++) {
-               SkState& state = fState[index];
-               state.fSteps = steps;
-               calcDurations(index);
-       }
+    int count = fState.count();
+    fMaxTime = 0;
+    for (int index = 0; index < count; index++) {
+        SkState& state = fState[index];
+        state.fSteps = steps;
+        calcDurations(index);
+    }
 }
 
 void SkActive::start() {
-       int count = fState.count();
-       SkASSERT(count == fAnimators.count());
-       SkASSERT(count == fInterpolators.count());
-       for (int index = 0; index < count; index++) {
-               SkState& state = fState[index];
-               if (state.fStarted)
-                       continue;
-               state.fStarted = true;
+    int count = fState.count();
+    SkASSERT(count == fAnimators.count());
+    SkASSERT(count == fInterpolators.count());
+    for (int index = 0; index < count; index++) {
+        SkState& state = fState[index];
+        if (state.fStarted)
+            continue;
+        state.fStarted = true;
 #if defined SK_DEBUG && defined SK_DEBUG_ANIMATION_TIMING
-               SkString debugOut;
-               SkMSec time = fMaker.getAppTime();
-               debugOut.appendS32(time - fMaker.fDebugTimeBase);
-               debugOut.append(" active start adjust delay id=");
-               debugOut.append(fApply._id);
-               debugOut.append("; ");
-               debugOut.append(fAnimators[index]->_id);
-               debugOut.append("=");
-               debugOut.appendS32(fAnimators[index]->fStart - fMaker.fDebugTimeBase);
-               debugOut.append(":");
-               debugOut.appendS32(state.fStartTime);
+        SkString debugOut;
+        SkMSec time = fMaker.getAppTime();
+        debugOut.appendS32(time - fMaker.fDebugTimeBase);
+        debugOut.append(" active start adjust delay id=");
+        debugOut.append(fApply._id);
+        debugOut.append("; ");
+        debugOut.append(fAnimators[index]->_id);
+        debugOut.append("=");
+        debugOut.appendS32(fAnimators[index]->fStart - fMaker.fDebugTimeBase);
+        debugOut.append(":");
+        debugOut.appendS32(state.fStartTime);
 #endif
-               if (state.fStartTime > 0) {
-                       SkMSec future = fAnimators[index]->fStart + state.fStartTime;
-                       if (future > fMaker.fEnableTime)
-                               fMaker.notifyInvalTime(future);
-                       else
-                               fMaker.notifyInval();
+        if (state.fStartTime > 0) {
+            SkMSec future = fAnimators[index]->fStart + state.fStartTime;
+            if (future > fMaker.fEnableTime)
+                fMaker.notifyInvalTime(future);
+            else
+                fMaker.notifyInval();
 #if defined SK_DEBUG && defined SK_DEBUG_ANIMATION_TIMING
-                       debugOut.append(":");
-                       debugOut.appendS32(future - fMaker.fDebugTimeBase);
+            debugOut.append(":");
+            debugOut.appendS32(future - fMaker.fDebugTimeBase);
 #endif
-               }
-               if (state.fStartTime >= fMaker.fAdjustedStart) {
-                       state.fStartTime -= fMaker.fAdjustedStart;
+        }
+        if (state.fStartTime >= fMaker.fAdjustedStart) {
+            state.fStartTime -= fMaker.fAdjustedStart;
 #if defined SK_DEBUG && defined SK_DEBUG_ANIMATION_TIMING
-                       debugOut.append(" (less adjust = ");
-                       debugOut.appendS32(fMaker.fAdjustedStart);
+            debugOut.append(" (less adjust = ");
+            debugOut.appendS32(fMaker.fAdjustedStart);
 #endif
-               }
-               state.fStartTime += fAnimators[index]->fStart;
+        }
+        state.fStartTime += fAnimators[index]->fStart;
 #if defined SK_DEBUG && defined SK_DEBUG_ANIMATION_TIMING
-               debugOut.append(") new start = ");
-               debugOut.appendS32(state.fStartTime - fMaker.fDebugTimeBase);
-               SkDebugf("%s\n", debugOut.c_str());
-//             SkASSERT((int) (state.fStartTime - fMaker.fDebugTimeBase) >= 0);
+        debugOut.append(") new start = ");
+        debugOut.appendS32(state.fStartTime - fMaker.fDebugTimeBase);
+        SkDebugf("%s\n", debugOut.c_str());
+//      SkASSERT((int) (state.fStartTime - fMaker.fDebugTimeBase) >= 0);
 #endif
-       }
-       SkASSERT(fAnimators.count() == fInterpolators.count());
+    }
+    SkASSERT(fAnimators.count() == fInterpolators.count());
 }
 
 #ifdef SK_DEBUG
 void SkActive::validate() {
-       int count = fState.count();
-       SkASSERT(count == fAnimators.count());
-       SkASSERT(count == fInterpolators.count());
-       for (int index = 0; index < count; index++) {
-               SkASSERT(fAnimators[index]);
-               SkASSERT(fInterpolators[index]);
-//             SkAnimateBase* test = fAnimators[index];
-//             SkASSERT(fApply.scope == test->fTarget || fApply.scope->contains(test->fTarget));
-       }
+    int count = fState.count();
+    SkASSERT(count == fAnimators.count());
+    SkASSERT(count == fInterpolators.count());
+    for (int index = 0; index < count; index++) {
+        SkASSERT(fAnimators[index]);
+        SkASSERT(fInterpolators[index]);
+//      SkAnimateBase* test = fAnimators[index];
+//      SkASSERT(fApply.scope == test->fTarget || fApply.scope->contains(test->fTarget));
+    }
 }
 #endif
 
@@ -466,27 +483,27 @@ void SkActive::validate() {
 // value for the new one somehow.
 
 //void SkActive::SkState::bumpSave() {
-//     if (fMode != SkApply::kMode_hold) 
-//             return;
-//     if (fTransition == SkApply::kTransition_reverse) {
-//             if (fSave > 0)
-//                     fSave -= SK_MSec1;
-//     } else if (fSave < fDuration)
-//             fSave += SK_MSec1;
+//  if (fMode != SkApply::kMode_hold) 
+//      return;
+//  if (fTransition == SkApply::kTransition_reverse) {
+//      if (fSave > 0)
+//          fSave -= SK_MSec1;
+//  } else if (fSave < fDuration)
+//      fSave += SK_MSec1;
 //}
 
 SkMSec SkActive::SkState::getRelativeTime(SkMSec time) {
-       SkMSec result = time;
-//     if (fMode == SkApply::kMode_hold)
-//             result = fSave;
-//     else
-       if (fTransition == SkApply::kTransition_reverse) {
-               if (SkMSec_LT(fDuration, time))
-                       result = 0;
-               else
-                       result = fDuration - time;
-       }
-       return result;
+    SkMSec result = time;
+//  if (fMode == SkApply::kMode_hold)
+//      result = fSave;
+//  else
+    if (fTransition == SkApply::kTransition_reverse) {
+        if (SkMSec_LT(fDuration, time))
+            result = 0;
+        else
+            result = fDuration - time;
+    }
+    return result;
 }
 
 
index 3bdf933..a454a38 100644 (file)
@@ -1,3 +1,20 @@
+/* libs/graphics/animator/SkAnimateActive.h
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #ifndef SkAnimateActive_DEFINED
 #define SkAnimateActive_DEFINED
 
@@ -9,62 +26,62 @@ class SkAnimateMaker;
 
 class SkActive {
 public:
-       SkActive(SkApply& , SkAnimateMaker& );
-       ~SkActive();
-       void advance();
-       void append(SkApply* );
-       void calcDurations(int index);
-       void create(SkDrawable* scope, SkMSec time);
-       bool draw() { return immediate(false); }
-       bool enable() { return immediate(true); }
-       void init( );
-       SkMSec getTime(SkMSec inTime, int animatorIndex);
-       void pickUp(SkActive* existing);
-       void reset() { fDrawIndex = 0; }
-       void setInterpolator(int index, SkOperand* from);
-       void start();
+    SkActive(SkApply& , SkAnimateMaker& );
+    ~SkActive();
+    void advance();
+    void append(SkApply* );
+    void calcDurations(int index);
+    void create(SkDrawable* scope, SkMSec time);
+    bool draw() { return immediate(false); }
+    bool enable() { return immediate(true); }
+    void init( );
+    SkMSec getTime(SkMSec inTime, int animatorIndex);
+    void pickUp(SkActive* existing);
+    void reset() { fDrawIndex = 0; }
+    void setInterpolator(int index, SkOperand* from);
+    void start();
 #ifdef SK_DEBUG
-       void validate();
+    void validate();
 #endif
 private:
-       void appendSave(int oldCount);
-       void fixInterpolator(SkBool save);
-       bool immediate(bool enable);
-       bool initializeSave();
-       void initState(SkApply* , int offset);
-       void resetInterpolators();
-       void resetState();
-       void restoreInterpolatorValues(int index);
-       void saveInterpolatorValues(int index);
-       void setSteps(int steps);
-       struct SkState {
-//             void bumpSave();
-               SkMSec getRelativeTime(SkMSec time);
-               SkApply::Mode fMode;
-               SkApply::Transition fTransition;
-               SkBool8 fPickup;
-               SkBool8 fRestore;
-               SkBool8 fStarted;
-               SkBool8 fUnpostedEndEvent;
-               S32 fSteps;
-               SkMSec fBegin;
-               SkMSec fStartTime;
-               SkMSec fDuration;
-               SkMSec fSave;
-               SkMSec fTicks;
-       };
-       SkActive& operator= (const SkActive& );
-       SkTDArray<SkOperandInterpolator*> fInterpolators;
-       SkApply& fApply;
-       SkTDArray<SkState> fState;      // one per animator
-       SkTDOperandPtrArray fSaveRestore;       // if apply has restore="true"
-       SkTDOperandPtrArray fSaveInterpolators;
-       SkTDAnimateArray fAnimators;
-       SkMSec fMaxTime;        // greatest of all animation durations; only used by immediate mode
-       SkAnimateMaker& fMaker;
-       int fDrawIndex;
-       int fDrawMax;
-       friend class SkApply;
+    void appendSave(int oldCount);
+    void fixInterpolator(SkBool save);
+    bool immediate(bool enable);
+    bool initializeSave();
+    void initState(SkApply* , int offset);
+    void resetInterpolators();
+    void resetState();
+    void restoreInterpolatorValues(int index);
+    void saveInterpolatorValues(int index);
+    void setSteps(int steps);
+    struct SkState {
+//      void bumpSave();
+        SkMSec getRelativeTime(SkMSec time);
+        SkApply::Mode fMode;
+        SkApply::Transition fTransition;
+        SkBool8 fPickup;
+        SkBool8 fRestore;
+        SkBool8 fStarted;
+        SkBool8 fUnpostedEndEvent;
+        S32 fSteps;
+        SkMSec fBegin;
+        SkMSec fStartTime;
+        SkMSec fDuration;
+        SkMSec fSave;
+        SkMSec fTicks;
+    };
+    SkActive& operator= (const SkActive& );
+    SkTDArray<SkOperandInterpolator*> fInterpolators;
+    SkApply& fApply;
+    SkTDArray<SkState> fState;  // one per animator
+    SkTDOperandPtrArray fSaveRestore;   // if apply has restore="true"
+    SkTDOperandPtrArray fSaveInterpolators;
+    SkTDAnimateArray fAnimators;
+    SkMSec fMaxTime;    // greatest of all animation durations; only used by immediate mode
+    SkAnimateMaker& fMaker;
+    int fDrawIndex;
+    int fDrawMax;
+    friend class SkApply;
 };
 
 #endif // SkAnimateActive_DEFINED
index fd3bd67..5fee329 100644 (file)
@@ -1,3 +1,20 @@
+/* libs/graphics/animator/SkAnimateBase.cpp
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #include "SkAnimateBase.h"
 #include "SkAnimateMaker.h"
 #include "SkAnimateProperties.h"
 #if SK_USE_CONDENSED_INFO == 0
 
 const SkMemberInfo SkAnimateBase::fInfo[] = {
-       SK_MEMBER(begin, MSec),
-       SK_MEMBER_ARRAY(blend, Float),
-       SK_MEMBER(dur, MSec),
-       SK_MEMBER_PROPERTY(dynamic, Boolean),
-       SK_MEMBER(field, String),       // name of member info in target
-       SK_MEMBER(formula, DynamicString),
-       SK_MEMBER(from, DynamicString),
-       SK_MEMBER(lval, DynamicString),
-       SK_MEMBER_PROPERTY(mirror, Boolean),
-       SK_MEMBER(repeat, Float),
-       SK_MEMBER_PROPERTY(reset, Boolean),
-       SK_MEMBER_PROPERTY(step, Int),
-       SK_MEMBER(target, DynamicString),
-       SK_MEMBER(to, DynamicString),
-       SK_MEMBER_PROPERTY(values, DynamicString)
+    SK_MEMBER(begin, MSec),
+    SK_MEMBER_ARRAY(blend, Float),
+    SK_MEMBER(dur, MSec),
+    SK_MEMBER_PROPERTY(dynamic, Boolean),
+    SK_MEMBER(field, String),   // name of member info in target
+    SK_MEMBER(formula, DynamicString),
+    SK_MEMBER(from, DynamicString),
+    SK_MEMBER(lval, DynamicString),
+    SK_MEMBER_PROPERTY(mirror, Boolean),
+    SK_MEMBER(repeat, Float),
+    SK_MEMBER_PROPERTY(reset, Boolean),
+    SK_MEMBER_PROPERTY(step, Int),
+    SK_MEMBER(target, DynamicString),
+    SK_MEMBER(to, DynamicString),
+    SK_MEMBER_PROPERTY(values, DynamicString)
 };
 
 #endif
@@ -30,137 +47,137 @@ const SkMemberInfo SkAnimateBase::fInfo[] = {
 DEFINE_GET_MEMBER(SkAnimateBase);
 
 SkAnimateBase::SkAnimateBase() : begin(0), dur(1), repeat(SK_Scalar1),
-               fApply(nil), fFieldInfo(nil), fFieldOffset(0), fStart((SkMSec) -1), fTarget(nil), 
-               fChanged(0), fDelayed(0), fDynamic(0), fHasEndEvent(0), fHasValues(0), 
-               fMirror(0), fReset(0), fResetPending(0), fTargetIsScope(0) {
-       blend.setCount(1);
-       blend[0] = SK_Scalar1;
+        fApply(nil), fFieldInfo(nil), fFieldOffset(0), fStart((SkMSec) -1), fTarget(nil), 
+        fChanged(0), fDelayed(0), fDynamic(0), fHasEndEvent(0), fHasValues(0), 
+        fMirror(0), fReset(0), fResetPending(0), fTargetIsScope(0) {
+    blend.setCount(1);
+    blend[0] = SK_Scalar1;
 }
 
 SkAnimateBase::~SkAnimateBase() {
-       SkDisplayTypes type = fValues.getType();
-       if (type == SkType_String || type == SkType_DynamicString) {
-               SkASSERT(fValues.count() == 1);
-               delete fValues[0].fString;
-       }
+    SkDisplayTypes type = fValues.getType();
+    if (type == SkType_String || type == SkType_DynamicString) {
+        SkASSERT(fValues.count() == 1);
+        delete fValues[0].fString;
+    }
 }
 
 int SkAnimateBase::components() { 
-       return 1; 
+    return 1; 
 }
 
 SkDisplayable* SkAnimateBase::deepCopy(SkAnimateMaker* maker) {
-       SkAnimateBase* result = (SkAnimateBase*) INHERITED::deepCopy(maker);
-       result->fApply = fApply;
-       result->fFieldInfo =fFieldInfo;
-       result->fHasValues = false;
-       return result;
+    SkAnimateBase* result = (SkAnimateBase*) INHERITED::deepCopy(maker);
+    result->fApply = fApply;
+    result->fFieldInfo =fFieldInfo;
+    result->fHasValues = false;
+    return result;
 }
 
 void SkAnimateBase::dirty() {
-       fChanged = true;
+    fChanged = true;
 }
 
 #ifdef SK_DUMP_ENABLED
 void SkAnimateBase::dump(SkAnimateMaker* maker) {
-       dumpBase(maker);
-       if (target.size() > 0)
-               SkDebugf("target=\"%s\" ", target.c_str());
+    dumpBase(maker);
+    if (target.size() > 0)
+        SkDebugf("target=\"%s\" ", target.c_str());
     else if (fTarget && strcmp(fTarget->id, ""))
         SkDebugf("target=\"%s\" ", fTarget->id);
-       if (lval.size() > 0)
-               SkDebugf("lval=\"%s\" ", lval.c_str());
-       if (field.size() > 0)
-               SkDebugf("field=\"%s\" ", field.c_str());
+    if (lval.size() > 0)
+        SkDebugf("lval=\"%s\" ", lval.c_str());
+    if (field.size() > 0)
+        SkDebugf("field=\"%s\" ", field.c_str());
     else if (fFieldInfo)
         SkDebugf("field=\"%s\" ", fFieldInfo->fName);
-       if (formula.size() > 0)
-               SkDebugf("formula=\"%s\" ", formula.c_str());
+    if (formula.size() > 0)
+        SkDebugf("formula=\"%s\" ", formula.c_str());
     else {
         if (from.size() > 0)
             SkDebugf("from=\"%s\" ", from.c_str());
-               SkDebugf("to=\"%s\" ", to.c_str());
-       }
-       if (begin != 0) {
+        SkDebugf("to=\"%s\" ", to.c_str());
+    }
+    if (begin != 0) {
 #ifdef SK_CAN_USE_FLOAT
-               SkDebugf("begin=\"%g\" ", SkScalarToFloat(SkScalarDiv(begin,1000)));
+        SkDebugf("begin=\"%g\" ", SkScalarToFloat(SkScalarDiv(begin,1000)));
 #else
-               SkDebugf("begin=\"%x\" ", SkScalarDiv(begin,1000));
+        SkDebugf("begin=\"%x\" ", SkScalarDiv(begin,1000));
 #endif
     }
 }
 #endif
 
 SkDisplayable* SkAnimateBase::getParent() const {
-       return (SkDisplayable*) fApply;
+    return (SkDisplayable*) fApply;
 }
 
 bool SkAnimateBase::getProperty(int index, SkScriptValue* value) const {
-       int boolResult;
-       switch (index) {
-               case SK_PROPERTY(dynamic):
-                       boolResult = fDynamic;
-                       goto returnBool;
-               case SK_PROPERTY(mirror):
-                       boolResult = fMirror;
-                       goto returnBool;
-               case SK_PROPERTY(reset):
-                       boolResult = fReset;
+    int boolResult;
+    switch (index) {
+        case SK_PROPERTY(dynamic):
+            boolResult = fDynamic;
+            goto returnBool;
+        case SK_PROPERTY(mirror):
+            boolResult = fMirror;
+            goto returnBool;
+        case SK_PROPERTY(reset):
+            boolResult = fReset;
 returnBool:
-                       value->fOperand.fS32 = SkToBool(boolResult);
-                       value->fType = SkType_Boolean;
-                       break;
-               case SK_PROPERTY(step):
-                       if (fApply == nil)
-                               return false;    // !!! notify there's an error?
-                       fApply->getStep(value);
-                       break;
-               case SK_PROPERTY(values):
-                       value->fOperand.fString = (SkString*) &to;
-                       value->fType = SkType_String;
-                       break;
-               default:
-                       SkASSERT(0);
-                       return false;
-       }
-       return true;
+            value->fOperand.fS32 = SkToBool(boolResult);
+            value->fType = SkType_Boolean;
+            break;
+        case SK_PROPERTY(step):
+            if (fApply == nil)
+                return false;    // !!! notify there's an error?
+            fApply->getStep(value);
+            break;
+        case SK_PROPERTY(values):
+            value->fOperand.fString = (SkString*) &to;
+            value->fType = SkType_String;
+            break;
+        default:
+            SkASSERT(0);
+            return false;
+    }
+    return true;
 }
 
 bool SkAnimateBase::hasExecute() const 
 {
-       return false; 
+    return false; 
 }
 
 void SkAnimateBase::onEndElement(SkAnimateMaker& maker) {
-       fChanged = false;
-       setTarget(maker);
-       if (field.size()) {
-               SkASSERT(fTarget);
-               fFieldInfo = fTarget->getMember(field.c_str());
-               field.reset();
-       }
-       if (lval.size()) {
-               // lval must be of the form x[y]
-               const char* lvalStr = lval.c_str();
-               const char* arrayEnd = strchr(lvalStr, '[');
-               if (arrayEnd == nil)
-                       return; //should this return an error?
-               size_t arrayNameLen = arrayEnd - lvalStr;
-               SkString arrayStr(lvalStr, arrayNameLen);
-               SkASSERT(fTarget);  //this return an error?
-               fFieldInfo = fTarget->getMember(arrayStr.c_str());
-               SkString scriptStr(arrayEnd + 1, lval.size() - arrayNameLen - 2);
-               SkAnimatorScript::EvaluateInt(maker, this, scriptStr.c_str(), &fFieldOffset);
-       }
+    fChanged = false;
+    setTarget(maker);
+    if (field.size()) {
+        SkASSERT(fTarget);
+        fFieldInfo = fTarget->getMember(field.c_str());
+        field.reset();
+    }
+    if (lval.size()) {
+        // lval must be of the form x[y]
+        const char* lvalStr = lval.c_str();
+        const char* arrayEnd = strchr(lvalStr, '[');
+        if (arrayEnd == nil)
+            return; //should this return an error?
+        size_t arrayNameLen = arrayEnd - lvalStr;
+        SkString arrayStr(lvalStr, arrayNameLen);
+        SkASSERT(fTarget);  //this return an error?
+        fFieldInfo = fTarget->getMember(arrayStr.c_str());
+        SkString scriptStr(arrayEnd + 1, lval.size() - arrayNameLen - 2);
+        SkAnimatorScript::EvaluateInt(maker, this, scriptStr.c_str(), &fFieldOffset);
+    }
 }
 
 void SkAnimateBase::packARGB(SkScalar array[], int count, SkTDOperandArray* converted) 
 { 
-       SkASSERT(count == 4);
-       converted->setCount(1);
-       SkColor color = SkColorSetARGB(SkScalarRound(array[0]), SkScalarRound(array[1]), 
-               SkScalarRound(array[2]), SkScalarRound(array[3]));
-       (*converted)[0].fS32 = color;
+    SkASSERT(count == 4);
+    converted->setCount(1);
+    SkColor color = SkColorSetARGB(SkScalarRound(array[0]), SkScalarRound(array[1]), 
+        SkScalarRound(array[2]), SkScalarRound(array[3]));
+    (*converted)[0].fS32 = color;
 }
 
 
@@ -169,62 +186,62 @@ void SkAnimateBase::refresh(SkAnimateMaker& ) {
 }
 
 bool SkAnimateBase::setParent(SkDisplayable* apply) {
-       SkASSERT(apply->isApply());
-       fApply = (SkApply*) apply;
-       return false;
+    SkASSERT(apply->isApply());
+    fApply = (SkApply*) apply;
+    return false;
 }
 
 bool SkAnimateBase::setProperty(int index, SkScriptValue& value) {
-       bool boolValue = SkToBool(value.fOperand.fS32);
-       switch (index) {
-               case SK_PROPERTY(dynamic):
-                       fDynamic = boolValue;
-                       goto checkForBool;
-               case SK_PROPERTY(values):
-                       fHasValues = true;
-                       SkASSERT(value.fType == SkType_String);
-                       to = *value.fOperand.fString;
-                       break;
-               case SK_PROPERTY(mirror):
-                       fMirror = boolValue;
-                       goto checkForBool;
-               case SK_PROPERTY(reset):
-                       fReset = boolValue;
+    bool boolValue = SkToBool(value.fOperand.fS32);
+    switch (index) {
+        case SK_PROPERTY(dynamic):
+            fDynamic = boolValue;
+            goto checkForBool;
+        case SK_PROPERTY(values):
+            fHasValues = true;
+            SkASSERT(value.fType == SkType_String);
+            to = *value.fOperand.fString;
+            break;
+        case SK_PROPERTY(mirror):
+            fMirror = boolValue;
+            goto checkForBool;
+        case SK_PROPERTY(reset):
+            fReset = boolValue;
 checkForBool:
-                       SkASSERT(value.fType == SkType_Boolean);
-                       break;
-               default:
-                       return false;
-       }
-       return true;
+            SkASSERT(value.fType == SkType_Boolean);
+            break;
+        default:
+            return false;
+    }
+    return true;
 }
 
 void SkAnimateBase::setTarget(SkAnimateMaker& maker) {
-       if (target.size()) {
-               SkAnimatorScript engine(maker, this, SkType_Displayable);
-               const char* script = target.c_str();
-               SkScriptValue scriptValue;
-               bool success = engine.evaluateScript(&script, &scriptValue);
-               if (success && scriptValue.fType == SkType_Displayable)
-                       fTarget = scriptValue.fOperand.fDrawable;
-               else if (maker.find(target.c_str(), (SkDisplayable**) &fTarget) == false) {
-                       if (fApply->getMode() == SkApply::kMode_create)
-                               return; // may not be an error
-                       if (engine.getError() != SkScriptEngine::kNoError)
-                               maker.setScriptError(engine);
-                       else {
-                               maker.setErrorNoun(target);
-                               maker.setErrorCode(SkDisplayXMLParserError::kTargetIDNotFound);
-                       }
-                       return;
-               }
-               if (fApply && fApply->getMode() != SkApply::kMode_create)
-                       target.reset();
-       }
+    if (target.size()) {
+        SkAnimatorScript engine(maker, this, SkType_Displayable);
+        const char* script = target.c_str();
+        SkScriptValue scriptValue;
+        bool success = engine.evaluateScript(&script, &scriptValue);
+        if (success && scriptValue.fType == SkType_Displayable)
+            fTarget = scriptValue.fOperand.fDrawable;
+        else if (maker.find(target.c_str(), (SkDisplayable**) &fTarget) == false) {
+            if (fApply->getMode() == SkApply::kMode_create)
+                return; // may not be an error
+            if (engine.getError() != SkScriptEngine::kNoError)
+                maker.setScriptError(engine);
+            else {
+                maker.setErrorNoun(target);
+                maker.setErrorCode(SkDisplayXMLParserError::kTargetIDNotFound);
+            }
+            return;
+        }
+        if (fApply && fApply->getMode() != SkApply::kMode_create)
+            target.reset();
+    }
 }
 
 bool SkAnimateBase::targetNeedsInitialization() const { 
-       return false; 
+    return false; 
 }
 
 
index 510b593..5f7b1ec 100644 (file)
@@ -1,3 +1,20 @@
+/* libs/graphics/animator/SkAnimateBase.h
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #ifndef SkAnimateBase_DEFINED
 #define SkAnimateBase_DEFINED
 
@@ -11,64 +28,64 @@ class SkDrawable;
 
 class SkAnimateBase : public SkDisplayable {
 public:
-       DECLARE_MEMBER_INFO(AnimateBase);
-       SkAnimateBase();
-       virtual ~SkAnimateBase();
-       virtual int components();
-       virtual SkDisplayable* deepCopy(SkAnimateMaker* );
-       virtual void dirty();
+    DECLARE_MEMBER_INFO(AnimateBase);
+    SkAnimateBase();
+    virtual ~SkAnimateBase();
+    virtual int components();
+    virtual SkDisplayable* deepCopy(SkAnimateMaker* );
+    virtual void dirty();
 #ifdef SK_DUMP_ENABLED
-       virtual void dump(SkAnimateMaker* );
+    virtual void dump(SkAnimateMaker* );
 #endif
-       int entries() { return fValues.count() / components(); }
-       virtual bool hasExecute() const;
-       bool isDynamic() const { return SkToBool(fDynamic); }
-       virtual SkDisplayable* getParent() const;
-       virtual bool getProperty(int index, SkScriptValue* value) const;
-       SkMSec getStart() const { return fStart; }
-       SkOperand* getValues() { return fValues.begin(); }
-       SkDisplayTypes getValuesType() { return fValues.getType(); }
-       virtual void onEndElement(SkAnimateMaker& );
-       void packARGB(SkScalar [], int count, SkTDOperandArray* );
-       virtual void refresh(SkAnimateMaker& );
-       void setChanged(bool changed) { fChanged = changed; }
-       void setHasEndEvent() { fHasEndEvent = true; }
-       virtual bool setParent(SkDisplayable* );
-       virtual bool setProperty(int index, SkScriptValue& value);
-       void setTarget(SkAnimateMaker& );
-       virtual bool targetNeedsInitialization() const;
+    int entries() { return fValues.count() / components(); }
+    virtual bool hasExecute() const;
+    bool isDynamic() const { return SkToBool(fDynamic); }
+    virtual SkDisplayable* getParent() const;
+    virtual bool getProperty(int index, SkScriptValue* value) const;
+    SkMSec getStart() const { return fStart; }
+    SkOperand* getValues() { return fValues.begin(); }
+    SkDisplayTypes getValuesType() { return fValues.getType(); }
+    virtual void onEndElement(SkAnimateMaker& );
+    void packARGB(SkScalar [], int count, SkTDOperandArray* );
+    virtual void refresh(SkAnimateMaker& );
+    void setChanged(bool changed) { fChanged = changed; }
+    void setHasEndEvent() { fHasEndEvent = true; }
+    virtual bool setParent(SkDisplayable* );
+    virtual bool setProperty(int index, SkScriptValue& value);
+    void setTarget(SkAnimateMaker& );
+    virtual bool targetNeedsInitialization() const;
 protected:
-       SkMSec begin;
-       SkTDScalarArray blend;
-       SkMSec dur;
-       // !!! make field part of a union with fFieldInfo, or fValues, something known later?
-       SkString field; // temporary; once target is known, this is reset
-       SkString formula;
-       SkString from;
-       SkString lval;
-       SkScalar repeat;
-       SkString target;        // temporary; once target is known, this is reset
-       SkString to;
-       SkApply* fApply;
-       const SkMemberInfo* fFieldInfo;
-       int fFieldOffset;
-       SkMSec fStart;  // corrected time when this apply was enabled
-       SkDrawable* fTarget;
-       SkTypedArray fValues;
-       unsigned fChanged : 1; // true when value referenced by script has changed
-       unsigned fDelayed : 1;  // enabled, but undrawn pending delay
-       unsigned fDynamic : 1;
-       unsigned fHasEndEvent : 1;
-       unsigned fHasValues : 1;                // set if 'values' passed instead of 'to'
-       unsigned fMirror : 1;
-       unsigned fReset : 1;
-       unsigned fResetPending : 1;
-       unsigned fTargetIsScope : 1;
+    SkMSec begin;
+    SkTDScalarArray blend;
+    SkMSec dur;
+    // !!! make field part of a union with fFieldInfo, or fValues, something known later?
+    SkString field; // temporary; once target is known, this is reset
+    SkString formula;
+    SkString from;
+    SkString lval;
+    SkScalar repeat;
+    SkString target;    // temporary; once target is known, this is reset
+    SkString to;
+    SkApply* fApply;
+    const SkMemberInfo* fFieldInfo;
+    int fFieldOffset;
+    SkMSec fStart;  // corrected time when this apply was enabled
+    SkDrawable* fTarget;
+    SkTypedArray fValues;
+    unsigned fChanged : 1; // true when value referenced by script has changed
+    unsigned fDelayed : 1;  // enabled, but undrawn pending delay
+    unsigned fDynamic : 1;
+    unsigned fHasEndEvent : 1;
+    unsigned fHasValues : 1;        // set if 'values' passed instead of 'to'
+    unsigned fMirror : 1;
+    unsigned fReset : 1;
+    unsigned fResetPending : 1;
+    unsigned fTargetIsScope : 1;
 private:
-       typedef SkDisplayable INHERITED;
-       friend class SkActive;
-       friend class SkApply;
-       friend class SkDisplayList;
+    typedef SkDisplayable INHERITED;
+    friend class SkActive;
+    friend class SkApply;
+    friend class SkDisplayList;
 };
 
 #endif // SkAnimateBase_DEFINED
index b2b6355..65f5911 100644 (file)
@@ -1,3 +1,20 @@
+/* libs/graphics/animator/SkAnimateField.cpp
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #include "SkAnimate.h"
 #include "SkAnimateMaker.h"
 #include "SkDrawable.h"
@@ -6,7 +23,7 @@
 #if SK_USE_CONDENSED_INFO == 0
 
 const SkMemberInfo SkAnimate::fInfo[] = {
-       SK_MEMBER_INHERITED
+    SK_MEMBER_INHERITED
 };
 
 #endif
@@ -20,26 +37,26 @@ SkAnimate::~SkAnimate() {
 }
 
 int SkAnimate::components() { 
-       return fComponents; 
+    return fComponents; 
 }
 
 #ifdef SK_DUMP_ENABLED
 void SkAnimate::dump(SkAnimateMaker* maker) {
-       INHERITED::dump(maker); //from animateBase
+    INHERITED::dump(maker); //from animateBase
     //SkSet inherits from this class
-       if (getType() != SkType_Set) {
+    if (getType() != SkType_Set) {
         if (fMirror)
             SkDebugf("mirror=\"true\" ");
         if (fReset)
             SkDebugf("reset=\"true\" ");
 #ifdef SK_CAN_USE_FLOAT
-               SkDebugf("dur=\"%g\" ", SkScalarToFloat(SkScalarDiv(dur,1000)));
-               if (repeat != SK_Scalar1)
-                       SkDebugf("repeat=\"%g\" ", SkScalarToFloat(repeat));
+        SkDebugf("dur=\"%g\" ", SkScalarToFloat(SkScalarDiv(dur,1000)));
+        if (repeat != SK_Scalar1)
+            SkDebugf("repeat=\"%g\" ", SkScalarToFloat(repeat));
 #else
-               SkDebugf("dur=\"%x\" ", SkScalarDiv(dur,1000));
-               if (repeat != SK_Scalar1)
-                       SkDebugf("repeat=\"%x\" ", repeat);
+        SkDebugf("dur=\"%x\" ", SkScalarDiv(dur,1000));
+        if (repeat != SK_Scalar1)
+            SkDebugf("repeat=\"%x\" ", repeat);
 #endif
         //if (fHasValues)
         //    SkDebugf("values=\"%s\" ", values);
@@ -59,55 +76,55 @@ void SkAnimate::dump(SkAnimateMaker* maker) {
             SkDebugf("]\" ");
         }
         SkDebugf("/>\n");//i assume that if it IS, we will do it separately
-       }
+    }
 }
 #endif
 
 bool SkAnimate::resolveCommon(SkAnimateMaker& maker) {
-       if (fTarget == nil)     // if nil, recall onEndElement after apply closes and sets target to scope
-               return false;
-       INHERITED::onEndElement(maker);
-       return maker.hasError() == false;
+    if (fTarget == nil) // if nil, recall onEndElement after apply closes and sets target to scope
+        return false;
+    INHERITED::onEndElement(maker);
+    return maker.hasError() == false;
 }
 
 void SkAnimate::onEndElement(SkAnimateMaker& maker) {
-       bool resolved = resolveCommon(maker);
-       if (resolved && fFieldInfo == nil) {
-               maker.setErrorNoun(field);
-               maker.setErrorCode(SkDisplayXMLParserError::kFieldNotInTarget);
-       }
-       if (resolved == false || fFieldInfo == nil)
-               return;
-       SkDisplayTypes outType = fFieldInfo->getType();
-       if (fHasValues) {
-               SkASSERT(to.size() > 0);
-               fFieldInfo->setValue(maker, &fValues, 0, 0, nil, outType, to);
-               SkASSERT(0);
-               // !!! this needs to set fComponents 
-               return;
-       }
-       fComponents = fFieldInfo->getCount();
-       if (fFieldInfo->fType == SkType_Array) {
-               SkTypedArray* array = (SkTypedArray*) fFieldInfo->memberData(fTarget);
-               int count = array->count();
-               if (count > 0)
-                       fComponents = count;
-       }
-       if (outType == SkType_ARGB) {
-               fComponents <<= 2;      // four color components
-               outType = SkType_Float;
-       }
-       fValues.setType(outType);
-       if (formula.size() > 0){
-               fComponents = 1;
-               from.set("0");
-               to.set("dur");
-               outType = SkType_MSec;
-       }
-       int max = fComponents * 2;
-       fValues.setCount(max);
-       memset(fValues.begin(), 0, max * sizeof(fValues.begin()[0]));
-       fFieldInfo->setValue(maker, &fValues, fFieldOffset, max, this, outType, from);
-       fFieldInfo->setValue(maker, &fValues, fComponents + fFieldOffset, max, this, outType, to);
+    bool resolved = resolveCommon(maker);
+    if (resolved && fFieldInfo == nil) {
+        maker.setErrorNoun(field);
+        maker.setErrorCode(SkDisplayXMLParserError::kFieldNotInTarget);
+    }
+    if (resolved == false || fFieldInfo == nil)
+        return;
+    SkDisplayTypes outType = fFieldInfo->getType();
+    if (fHasValues) {
+        SkASSERT(to.size() > 0);
+        fFieldInfo->setValue(maker, &fValues, 0, 0, nil, outType, to);
+        SkASSERT(0);
+        // !!! this needs to set fComponents 
+        return;
+    }
+    fComponents = fFieldInfo->getCount();
+    if (fFieldInfo->fType == SkType_Array) {
+        SkTypedArray* array = (SkTypedArray*) fFieldInfo->memberData(fTarget);
+        int count = array->count();
+        if (count > 0)
+            fComponents = count;
+    }
+    if (outType == SkType_ARGB) {
+        fComponents <<= 2;  // four color components
+        outType = SkType_Float;
+    }
+    fValues.setType(outType);
+    if (formula.size() > 0){
+        fComponents = 1;
+        from.set("0");
+        to.set("dur");
+        outType = SkType_MSec;
+    }
+    int max = fComponents * 2;
+    fValues.setCount(max);
+    memset(fValues.begin(), 0, max * sizeof(fValues.begin()[0]));
+    fFieldInfo->setValue(maker, &fValues, fFieldOffset, max, this, outType, from);
+    fFieldInfo->setValue(maker, &fValues, fComponents + fFieldOffset, max, this, outType, to);
 }
 
index e66f7df..3868444 100644 (file)
@@ -1,3 +1,20 @@
+/* libs/graphics/animator/SkAnimateMaker.cpp
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #include "SkAnimateMaker.h"
 #include "SkAnimator.h"
 #include "SkAnimatorScript.h"
 #include "SkTime.h"
 
 class DefaultTimeline : public SkAnimator::Timeline {
-       virtual SkMSec getMSecs() const {
-               return SkTime::GetMSecs();
-       }
+    virtual SkMSec getMSecs() const {
+        return SkTime::GetMSecs();
+    }
 } gDefaultTimeline;
 
 SkAnimateMaker::SkAnimateMaker(SkAnimator* animator, SkCanvas* canvas, SkPaint* paint)
-       : fActiveEvent(NULL), fAdjustedStart(0), fCanvas(canvas), fEnableTime(0), 
-               fHostEventSinkID(0), fMinimumInterval((SkMSec) -1), fPaint(paint), fParentMaker(NULL),
-               fTimeline(&gDefaultTimeline), fInInclude(false), fInMovie(false),
-               fFirstScriptError(false), fLoaded(false), fIDs(256), fAnimator(animator)
+    : fActiveEvent(NULL), fAdjustedStart(0), fCanvas(canvas), fEnableTime(0), 
+        fHostEventSinkID(0), fMinimumInterval((SkMSec) -1), fPaint(paint), fParentMaker(NULL),
+        fTimeline(&gDefaultTimeline), fInInclude(false), fInMovie(false),
+        fFirstScriptError(false), fLoaded(false), fIDs(256), fAnimator(animator)
 {
-       fScreenplay.time = 0;
+    fScreenplay.time = 0;
 #if defined SK_DEBUG && defined SK_DEBUG_ANIMATION_TIMING
-       fDebugTimeBase = (SkMSec) -1;
+    fDebugTimeBase = (SkMSec) -1;
 #endif
 #ifdef SK_DUMP_ENABLED
-       fDumpEvents = fDumpGConditions = fDumpPosts = false;
+    fDumpEvents = fDumpGConditions = fDumpPosts = false;
 #endif
 }
 
 SkAnimateMaker::~SkAnimateMaker() {
-       deleteMembers();
+    deleteMembers();
 }
 
 #if 0
 SkMSec SkAnimateMaker::adjustDelay(SkMSec expectedBase, SkMSec delay) {
-       SkMSec appTime = (*fTimeCallBack)();
-       if (appTime)
-               delay -= appTime - expectedBase;
-       if (delay < 0)
-               delay = 0;
-       return delay;
+    SkMSec appTime = (*fTimeCallBack)();
+    if (appTime)
+        delay -= appTime - expectedBase;
+    if (delay < 0)
+        delay = 0;
+    return delay;
 }
 #endif
 
 void SkAnimateMaker::appendActive(SkActive* active) {
-       fDisplayList.append(active);
+    fDisplayList.append(active);
 }
 
 void SkAnimateMaker::clearExtraPropertyCallBack(SkDisplayTypes type) {
-       SkExtras** end = fExtras.end();
-       for (SkExtras** extraPtr = fExtras.begin(); extraPtr < end; extraPtr++) {
-               SkExtras* extra = *extraPtr;
-               if (extra->definesType(type)) {
-                       extra->fExtraCallBack = NULL;
-                       extra->fExtraStorage = NULL;
-                       break;
-               }
-       }
+    SkExtras** end = fExtras.end();
+    for (SkExtras** extraPtr = fExtras.begin(); extraPtr < end; extraPtr++) {
+        SkExtras* extra = *extraPtr;
+        if (extra->definesType(type)) {
+            extra->fExtraCallBack = NULL;
+            extra->fExtraStorage = NULL;
+            break;
+        }
+    }
 }
 
 bool SkAnimateMaker::computeID(SkDisplayable* displayable, SkDisplayable* parent, SkString* newID) {
-       const char* script;
+    const char* script;
   if (findKey(displayable, &script) == false)
-               return true;
-       return SkAnimatorScript::EvaluateString(*this, displayable, parent, script, newID);
+        return true;
+    return SkAnimatorScript::EvaluateString(*this, displayable, parent, script, newID);
 }
 
 SkDisplayable* SkAnimateMaker::createInstance(const char name[], size_t len) {
-       SkDisplayTypes type = SkDisplayType::GetType(this, name, len );
-       if ((int)type >= 0) 
-               return SkDisplayType::CreateInstance(this, type);
-       return NULL;
+    SkDisplayTypes type = SkDisplayType::GetType(this, name, len );
+    if ((int)type >= 0) 
+        return SkDisplayType::CreateInstance(this, type);
+    return NULL;
 }
 
 // differs from SkAnimator::decodeStream in that it does not reset error state
 bool SkAnimateMaker::decodeStream(SkStream* stream)
 {
-       SkDisplayXMLParser parser(*this);
-       return parser.parse(*stream);
+    SkDisplayXMLParser parser(*this);
+    return parser.parse(*stream);
 }
 
 // differs from SkAnimator::decodeURI in that it does not set URI base
 bool SkAnimateMaker::decodeURI(const char uri[]) {
-//     SkDebugf("animator decode %s\n", uri);
-       SkStream* stream = SkStream::GetURIStream(fPrefix.c_str(), uri);
-       SkAutoTDelete<SkStream> autoDel(stream);
-       bool success = decodeStream(stream);
-       if (hasError() && fError.hasNoun() == false)
-               fError.setNoun(uri);
-       return success;
+//  SkDebugf("animator decode %s\n", uri);
+    SkStream* stream = SkStream::GetURIStream(fPrefix.c_str(), uri);
+    SkAutoTDelete<SkStream> autoDel(stream);
+    bool success = decodeStream(stream);
+    if (hasError() && fError.hasNoun() == false)
+        fError.setNoun(uri);
+    return success;
 }
 
 #if defined SK_DEBUG && 0
@@ -101,256 +118,256 @@ bool SkAnimateMaker::decodeURI(const char uri[]) {
 #include "SkTSearch.h"
 
 extern "C" {
-       int compare_disp(const void* a, const void* b) {
-               return *(const SkDisplayable**)a - *(const SkDisplayable**)b;
-       }
+    int compare_disp(const void* a, const void* b) {
+        return *(const SkDisplayable**)a - *(const SkDisplayable**)b;
+    }
 }
 #endif
 
 void SkAnimateMaker::delayEnable(SkApply* apply, SkMSec time) {
-       int index = fDelayed.find(apply);
-       if (index < 0)
-               *fDelayed.append() = apply;
-       (new SkEvent(SK_EventType_Delay))->postTime(fAnimator->getSinkID(), time);
+    int index = fDelayed.find(apply);
+    if (index < 0)
+        *fDelayed.append() = apply;
+    (new SkEvent(SK_EventType_Delay))->postTime(fAnimator->getSinkID(), time);
 }
 
 void SkAnimateMaker::deleteMembers() {
-       int index;
+    int index;
 #if defined SK_DEBUG && 0
-       //this code checks to see if helpers are among the children, but it is not complete -
-       //it should check the children of the children
-       int result;
-       SkTDArray<SkDisplayable*> children(fChildren.begin(), fChildren.count());
-       SkQSort(children.begin(), children.count(), sizeof(SkDisplayable*),compare_disp);
-       for (index = 0; index < fHelpers.count(); index++) {
-               SkDisplayable* helper = fHelpers[index];
-               result = SkTSearch(children.begin(), children.count(), helper, sizeof(SkDisplayable*));
-               SkASSERT(result < 0);
-       }
+    //this code checks to see if helpers are among the children, but it is not complete -
+    //it should check the children of the children
+    int result;
+    SkTDArray<SkDisplayable*> children(fChildren.begin(), fChildren.count());
+    SkQSort(children.begin(), children.count(), sizeof(SkDisplayable*),compare_disp);
+    for (index = 0; index < fHelpers.count(); index++) {
+        SkDisplayable* helper = fHelpers[index];
+        result = SkTSearch(children.begin(), children.count(), helper, sizeof(SkDisplayable*));
+        SkASSERT(result < 0);
+    }
 #endif
-       for (index = 0; index < fChildren.count(); index++) {
-               SkDisplayable* child = fChildren[index];
-               delete child;
-       }
-       for (index = 0; index < fHelpers.count(); index++) {
-               SkDisplayable* helper = fHelpers[index];
-               delete helper;
-       }
-       for (index = 0; index < fExtras.count(); index++) {
-               SkExtras* extras = fExtras[index];
-               delete extras;
-       }
+    for (index = 0; index < fChildren.count(); index++) {
+        SkDisplayable* child = fChildren[index];
+        delete child;
+    }
+    for (index = 0; index < fHelpers.count(); index++) {
+        SkDisplayable* helper = fHelpers[index];
+        delete helper;
+    }
+    for (index = 0; index < fExtras.count(); index++) {
+        SkExtras* extras = fExtras[index];
+        delete extras;
+    }
 }
 
 void SkAnimateMaker::doDelayedEvent() {
-       fEnableTime = getAppTime();
-       for (int index = 0; index < fDelayed.count(); ) {
-               SkDisplayable* child = fDelayed[index];
-               SkASSERT(child->isApply());
-               SkApply* apply = (SkApply*) child;
-               apply->interpolate(*this, fEnableTime);
-               if (apply->hasDelayedAnimator())
-                       index++;
-               else
-                       fDelayed.remove(index);
-       }
+    fEnableTime = getAppTime();
+    for (int index = 0; index < fDelayed.count(); ) {
+        SkDisplayable* child = fDelayed[index];
+        SkASSERT(child->isApply());
+        SkApply* apply = (SkApply*) child;
+        apply->interpolate(*this, fEnableTime);
+        if (apply->hasDelayedAnimator())
+            index++;
+        else
+            fDelayed.remove(index);
+    }
 }
 
 bool SkAnimateMaker::doEvent(const SkEvent& event) {
-       return (!fInMovie || fLoaded) && fAnimator->doEvent(event);
+    return (!fInMovie || fLoaded) && fAnimator->doEvent(event);
 }
 
 #ifdef SK_DUMP_ENABLED
 void SkAnimateMaker::dump(const char* match) {
-               SkTDict<SkDisplayable*>::Iter iter(fIDs);
-               const char* name;
-               SkDisplayable* result;
-               while ((name = iter.next(&result)) != NULL) {
-                       if (strcmp(match,name) == 0)
+        SkTDict<SkDisplayable*>::Iter iter(fIDs);
+        const char* name;
+        SkDisplayable* result;
+        while ((name = iter.next(&result)) != NULL) {
+            if (strcmp(match,name) == 0)
                 result->dump(this);
-               }
+        }
 }
 #endif
 
 int SkAnimateMaker::dynamicProperty(SkString& nameStr, SkDisplayable** displayablePtr ) {
-       const char* name = nameStr.c_str();
-       const char* dot = strchr(name, '.');
-       SkASSERT(dot);
-       SkDisplayable* displayable;
-       if (find(name, dot - name, &displayable) == false) {
-               SkASSERT(0);
-               return 0;
-       }
-       const char* fieldName = dot + 1;
-       const SkMemberInfo* memberInfo = displayable->getMember(fieldName);
-       *displayablePtr = displayable;
-       return (int) memberInfo->fOffset;
+    const char* name = nameStr.c_str();
+    const char* dot = strchr(name, '.');
+    SkASSERT(dot);
+    SkDisplayable* displayable;
+    if (find(name, dot - name, &displayable) == false) {
+        SkASSERT(0);
+        return 0;
+    }
+    const char* fieldName = dot + 1;
+    const SkMemberInfo* memberInfo = displayable->getMember(fieldName);
+    *displayablePtr = displayable;
+    return (int) memberInfo->fOffset;
 }
 
 SkMSec SkAnimateMaker::getAppTime() const {
-       return fTimeline->getMSecs();
+    return fTimeline->getMSecs();
 }
 
 #ifdef SK_DEBUG
 SkAnimator* SkAnimateMaker::getRoot()
 {
-       SkAnimateMaker* maker = this;
-       while (maker->fParentMaker)
-               maker = maker->fParentMaker;
-       return maker == this ? NULL : maker->fAnimator;
+    SkAnimateMaker* maker = this;
+    while (maker->fParentMaker)
+        maker = maker->fParentMaker;
+    return maker == this ? NULL : maker->fAnimator;
 }
 #endif
 
 void SkAnimateMaker::helperAdd(SkDisplayable* trackMe) {
-       SkASSERT(fHelpers.find(trackMe) < 0);
-       *fHelpers.append() = trackMe;
+    SkASSERT(fHelpers.find(trackMe) < 0);
+    *fHelpers.append() = trackMe;
 }
 
 void SkAnimateMaker::helperRemove(SkDisplayable* alreadyTracked) {
-       int helperIndex = fHelpers.find(alreadyTracked);
-       if (helperIndex >= 0)
-               fHelpers.remove(helperIndex);
+    int helperIndex = fHelpers.find(alreadyTracked);
+    if (helperIndex >= 0)
+        fHelpers.remove(helperIndex);
 }
 
 #if 0
 void SkAnimateMaker::loadMovies() {
-       for (SkDisplayable** dispPtr = fMovies.begin(); dispPtr < fMovies.end(); dispPtr++) {
-               SkDisplayable* displayable = *dispPtr;
-               SkASSERT(displayable->getType() == SkType_Movie);
-               SkDisplayMovie* movie = (SkDisplayMovie*) displayable;
-               SkAnimateMaker* movieMaker = movie->fMovie.fMaker;
-               movieMaker->fEvents.doEvent(*movieMaker, SkDisplayEvent::kOnload, NULL);
-               movieMaker->fEvents.removeEvent(SkDisplayEvent::kOnload, NULL);
-               movieMaker->loadMovies();
-       }
+    for (SkDisplayable** dispPtr = fMovies.begin(); dispPtr < fMovies.end(); dispPtr++) {
+        SkDisplayable* displayable = *dispPtr;
+        SkASSERT(displayable->getType() == SkType_Movie);
+        SkDisplayMovie* movie = (SkDisplayMovie*) displayable;
+        SkAnimateMaker* movieMaker = movie->fMovie.fMaker;
+        movieMaker->fEvents.doEvent(*movieMaker, SkDisplayEvent::kOnload, NULL);
+        movieMaker->fEvents.removeEvent(SkDisplayEvent::kOnload, NULL);
+        movieMaker->loadMovies();
+    }
 }
 #endif
 
 void SkAnimateMaker::notifyInval() {
-       if (fHostEventSinkID)
-               fAnimator->onEventPost(new SkEvent(SK_EventType_Inval), fHostEventSinkID);
+    if (fHostEventSinkID)
+        fAnimator->onEventPost(new SkEvent(SK_EventType_Inval), fHostEventSinkID);
 }
 
 void SkAnimateMaker::notifyInvalTime(SkMSec time) {
-       if (fHostEventSinkID)
-               fAnimator->onEventPostTime(new SkEvent(SK_EventType_Inval), fHostEventSinkID, time);
+    if (fHostEventSinkID)
+        fAnimator->onEventPostTime(new SkEvent(SK_EventType_Inval), fHostEventSinkID, time);
 }
 
 void SkAnimateMaker::postOnEnd(SkAnimateBase* animate, SkMSec end) {
-               SkEvent evt;
-               evt.setS32("time", animate->getStart() + end);
-               evt.setPtr("anim", animate);
-               evt.setType(SK_EventType_OnEnd);
-               SkEventSinkID sinkID = fAnimator->getSinkID();
-               fAnimator->onEventPost(new SkEvent(evt), sinkID);
+        SkEvent evt;
+        evt.setS32("time", animate->getStart() + end);
+        evt.setPtr("anim", animate);
+        evt.setType(SK_EventType_OnEnd);
+        SkEventSinkID sinkID = fAnimator->getSinkID();
+        fAnimator->onEventPost(new SkEvent(evt), sinkID);
 }
 
 void SkAnimateMaker::reset() {
-       deleteMembers();
-       fChildren.reset();
-       fHelpers.reset();
-       fIDs.reset();
-       fEvents.reset();
-       fDisplayList.hardReset();
+    deleteMembers();
+    fChildren.reset();
+    fHelpers.reset();
+    fIDs.reset();
+    fEvents.reset();
+    fDisplayList.hardReset();
 }
 
 void SkAnimateMaker::removeActive(SkActive* active) {
-       if (active == NULL)
-               return;
-       fDisplayList.remove(active);
+    if (active == NULL)
+        return;
+    fDisplayList.remove(active);
 }
 
 bool SkAnimateMaker::resolveID(SkDisplayable* displayable, SkDisplayable* original) {
-       SkString newID;
-       bool success = computeID(original, NULL, &newID);
-       if (success)
-               setID(displayable, newID);
-       return success;
+    SkString newID;
+    bool success = computeID(original, NULL, &newID);
+    if (success)
+        setID(displayable, newID);
+    return success;
 }
 
 void SkAnimateMaker::setErrorString() {
-       fErrorString.reset();
-       if (fError.hasError()) {
-               SkString err;
-               if (fFileName.size() > 0)
-                       fErrorString.set(fFileName.c_str());
-               else
-                       fErrorString.set("screenplay error");
-               int line = fError.getLineNumber();
-               if (line >= 0) {
-                       fErrorString.append(", ");
-                       fErrorString.append("line ");
-                       fErrorString.appendS32(line);
-               }
-               fErrorString.append(": ");
-               fError.getErrorString(&err);
-               fErrorString.append(err);
+    fErrorString.reset();
+    if (fError.hasError()) {
+        SkString err;
+        if (fFileName.size() > 0)
+            fErrorString.set(fFileName.c_str());
+        else
+            fErrorString.set("screenplay error");
+        int line = fError.getLineNumber();
+        if (line >= 0) {
+            fErrorString.append(", ");
+            fErrorString.append("line ");
+            fErrorString.appendS32(line);
+        }
+        fErrorString.append(": ");
+        fError.getErrorString(&err);
+        fErrorString.append(err);
 #if defined SK_DEBUG
-               SkDebugf("%s\n", fErrorString.c_str());
+        SkDebugf("%s\n", fErrorString.c_str());
 #endif
-       
+    } 
 }
 
 void SkAnimateMaker::setEnableTime(SkMSec appTime, SkMSec expectedTime) {
 #if defined SK_DEBUG && defined SK_DEBUG_ANIMATION_TIMING
-       SkString debugOut;
-       SkMSec time = getAppTime();
-       debugOut.appendS32(time - fDebugTimeBase);
-       debugOut.append(" set enable old enable=");
-       debugOut.appendS32(fEnableTime - fDebugTimeBase);
-       debugOut.append(" old adjust=");
-       debugOut.appendS32(fAdjustedStart);
-       debugOut.append(" new enable=");
-       debugOut.appendS32(expectedTime - fDebugTimeBase);
-       debugOut.append(" new adjust=");
-       debugOut.appendS32(appTime - expectedTime);
-       SkDebugf("%s\n", debugOut.c_str());
+    SkString debugOut;
+    SkMSec time = getAppTime();
+    debugOut.appendS32(time - fDebugTimeBase);
+    debugOut.append(" set enable old enable=");
+    debugOut.appendS32(fEnableTime - fDebugTimeBase);
+    debugOut.append(" old adjust=");
+    debugOut.appendS32(fAdjustedStart);
+    debugOut.append(" new enable=");
+    debugOut.appendS32(expectedTime - fDebugTimeBase);
+    debugOut.append(" new adjust=");
+    debugOut.appendS32(appTime - expectedTime);
+    SkDebugf("%s\n", debugOut.c_str());
 #endif
-       fAdjustedStart = appTime - expectedTime;
-       fEnableTime = expectedTime;
-       SkDisplayable** firstMovie = fMovies.begin();
-       SkDisplayable** endMovie = fMovies.end();
-       for (SkDisplayable** ptr = firstMovie; ptr < endMovie; ptr++) {
-               SkDisplayMovie* movie = (SkDisplayMovie*) *ptr;
-               movie->fMovie.fMaker->setEnableTime(appTime, expectedTime);
-       }
+    fAdjustedStart = appTime - expectedTime;
+    fEnableTime = expectedTime;
+    SkDisplayable** firstMovie = fMovies.begin();
+    SkDisplayable** endMovie = fMovies.end();
+    for (SkDisplayable** ptr = firstMovie; ptr < endMovie; ptr++) {
+        SkDisplayMovie* movie = (SkDisplayMovie*) *ptr;
+        movie->fMovie.fMaker->setEnableTime(appTime, expectedTime);
+    }
 }
 
 void SkAnimateMaker::setExtraPropertyCallBack(SkDisplayTypes type, 
-               SkScriptEngine::_propertyCallBack callBack, void* userStorage) {
-       SkExtras** end = fExtras.end();
-       for (SkExtras** extraPtr = fExtras.begin(); extraPtr < end; extraPtr++) {
-               SkExtras* extra = *extraPtr;
-               if (extra->definesType(type)) {
-                       extra->fExtraCallBack = callBack;
-                       extra->fExtraStorage = userStorage;
-                       break;
-               }
-       }
+        SkScriptEngine::_propertyCallBack callBack, void* userStorage) {
+    SkExtras** end = fExtras.end();
+    for (SkExtras** extraPtr = fExtras.begin(); extraPtr < end; extraPtr++) {
+        SkExtras* extra = *extraPtr;
+        if (extra->definesType(type)) {
+            extra->fExtraCallBack = callBack;
+            extra->fExtraStorage = userStorage;
+            break;
+        }
+    }
 }
 
 void SkAnimateMaker::setID(SkDisplayable* displayable, const SkString& newID) {
-       fIDs.set(newID.c_str(), displayable);
+    fIDs.set(newID.c_str(), displayable);
 #ifdef SK_DEBUG
-       displayable->_id.set(newID);
-       displayable->id = displayable->_id.c_str();
+    displayable->_id.set(newID);
+    displayable->id = displayable->_id.c_str();
 #endif
 }
 
 void SkAnimateMaker::setScriptError(const SkScriptEngine& engine) {
-       SkString errorString;
+    SkString errorString;
 #ifdef SK_DEBUG
-       engine.getErrorString(&errorString);
+    engine.getErrorString(&errorString);
 #endif
-       setErrorNoun(errorString);
-       setErrorCode(SkDisplayXMLParserError::kErrorInScript);
+    setErrorNoun(errorString);
+    setErrorCode(SkDisplayXMLParserError::kErrorInScript);
 }
 
 bool SkAnimateMaker::GetStep(const char* token, size_t len, void* stepPtr, SkScriptValue* value) {
-       if (SK_LITERAL_STR_EQUAL("step", token, len)) {
-               value->fOperand.fS32 = *(S32*) stepPtr;
-               value->fType = SkType_Int;
-               return true;
-       }
-       return false;
+    if (SK_LITERAL_STR_EQUAL("step", token, len)) {
+        value->fOperand.fS32 = *(S32*) stepPtr;
+        value->fType = SkType_Int;
+        return true;
+    }
+    return false;
 }
index acc2c54..60ccacd 100644 (file)
@@ -1,3 +1,20 @@
+/* libs/graphics/animator/SkAnimateMaker.h
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #ifndef SkAnimateMaker_DEFINED
 #define SkAnimateMaker_DEFINED
 
@@ -32,121 +49,121 @@ class SkStream;
 
 class SkAnimateMaker {
 public:
-       SkAnimateMaker(SkAnimator* animator, SkCanvas* canvas, SkPaint* paint);
-       ~SkAnimateMaker();
-       void appendActive(SkActive* );
-       void childrenAdd(SkDisplayable* child) { *fChildren.append() = child; }
-       void clearExtraPropertyCallBack(SkDisplayTypes type);
-       bool computeID(SkDisplayable* displayable, SkDisplayable* parent, SkString* newID);
-       SkDisplayable* createInstance(const char name[], size_t len);
-       bool decodeStream(SkStream* stream);
-       bool decodeURI(const char uri[]);
-       void delayEnable(SkApply* apply, SkMSec time);
-       void doDelayedEvent();
-       bool doEvent(const SkEvent& event);
+    SkAnimateMaker(SkAnimator* animator, SkCanvas* canvas, SkPaint* paint);
+    ~SkAnimateMaker();
+    void appendActive(SkActive* );
+    void childrenAdd(SkDisplayable* child) { *fChildren.append() = child; }
+    void clearExtraPropertyCallBack(SkDisplayTypes type);
+    bool computeID(SkDisplayable* displayable, SkDisplayable* parent, SkString* newID);
+    SkDisplayable* createInstance(const char name[], size_t len);
+    bool decodeStream(SkStream* stream);
+    bool decodeURI(const char uri[]);
+    void delayEnable(SkApply* apply, SkMSec time);
+    void doDelayedEvent();
+    bool doEvent(const SkEvent& event);
 #ifdef SK_DUMP_ENABLED
-       void dump(const char* match);
+    void dump(const char* match);
 #endif
-       int dynamicProperty(SkString& nameStr, SkDisplayable**  );
-       bool find(const char* str, SkDisplayable** displayablePtr) const { 
-               return fIDs.find(str, displayablePtr);
-       }
-       bool find(const char* str, size_t len, SkDisplayable** displayablePtr) const { 
-               return fIDs.find(str, len, displayablePtr);
-       }
-       bool findKey(SkDisplayable* displayable, const char** string) const {
-               return fIDs.findKey(displayable, string);
-       }
-//     bool find(SkString& string, SkDisplayable** displayablePtr) { 
-//             return fIDs.find(string.c_str(), displayablePtr);
-//     }
-       SkAnimator* getAnimator() { return fAnimator; }
-       SkMSec getAppTime() const; // call caller to get current time
+    int dynamicProperty(SkString& nameStr, SkDisplayable**  );
+    bool find(const char* str, SkDisplayable** displayablePtr) const { 
+        return fIDs.find(str, displayablePtr);
+    }
+    bool find(const char* str, size_t len, SkDisplayable** displayablePtr) const { 
+        return fIDs.find(str, len, displayablePtr);
+    }
+    bool findKey(SkDisplayable* displayable, const char** string) const {
+        return fIDs.findKey(displayable, string);
+    }
+//  bool find(SkString& string, SkDisplayable** displayablePtr) { 
+//      return fIDs.find(string.c_str(), displayablePtr);
+//  }
+    SkAnimator* getAnimator() { return fAnimator; }
+    SkMSec getAppTime() const; // call caller to get current time
 #ifdef SK_DEBUG
-       SkAnimator* getRoot();
+    SkAnimator* getRoot();
 #endif
-       SkXMLParserError::ErrorCode getErrorCode() const { return fError.getErrorCode(); }
-       SkMSec getInTime() { return fDisplayList.getTime(); }
-       int getNativeCode() const { return fError.getNativeCode(); }
-       bool hasError() { return fError.hasError(); }
-       void helperAdd(SkDisplayable* trackMe);
-       void helperRemove(SkDisplayable* alreadyTracked);
-       void idsSet(const char* attrValue, size_t len, SkDisplayable* displayable) { 
-               fIDs.set(attrValue, len, displayable); }
-//     void loadMovies();
-       void notifyInval();
-       void notifyInvalTime(SkMSec time);
-       void postOnEnd(SkAnimateBase* animate, SkMSec end);
-       void removeActive(SkActive* );
-       void reset();
-       bool resolveID(SkDisplayable* displayable, SkDisplayable* original);
-       void setEnableTime(SkMSec appTime, SkMSec expectedTime);
-       void setErrorCode(SkXMLParserError::ErrorCode err) { if (fError.hasError() == false) fError.INHERITED::setCode(err); }
-       void setErrorCode(SkDisplayXMLParserError::ErrorCode err) { if (fError.hasError() == false) fError.setCode(err); }
-       void setErrorNoun(const SkString& str) { if (fError.hasError() == false) fError.setNoun(str); }
-       void setErrorString();
-       void setExtraPropertyCallBack(SkDisplayTypes type, SkScriptEngine::_propertyCallBack , void* userStorage);
-       void setID(SkDisplayable* displayable, const SkString& newID);
-       void setInnerError(SkAnimateMaker* maker, const SkString& str) { fError.setInnerError(maker, str); }
-       void setScriptError(const SkScriptEngine& );
+    SkXMLParserError::ErrorCode getErrorCode() const { return fError.getErrorCode(); }
+    SkMSec getInTime() { return fDisplayList.getTime(); }
+    int getNativeCode() const { return fError.getNativeCode(); }
+    bool hasError() { return fError.hasError(); }
+    void helperAdd(SkDisplayable* trackMe);
+    void helperRemove(SkDisplayable* alreadyTracked);
+    void idsSet(const char* attrValue, size_t len, SkDisplayable* displayable) { 
+        fIDs.set(attrValue, len, displayable); }
+//  void loadMovies();
+    void notifyInval();
+    void notifyInvalTime(SkMSec time);
+    void postOnEnd(SkAnimateBase* animate, SkMSec end);
+    void removeActive(SkActive* );
+    void reset();
+    bool resolveID(SkDisplayable* displayable, SkDisplayable* original);
+    void setEnableTime(SkMSec appTime, SkMSec expectedTime);
+    void setErrorCode(SkXMLParserError::ErrorCode err) { if (fError.hasError() == false) fError.INHERITED::setCode(err); }
+    void setErrorCode(SkDisplayXMLParserError::ErrorCode err) { if (fError.hasError() == false) fError.setCode(err); }
+    void setErrorNoun(const SkString& str) { if (fError.hasError() == false) fError.setNoun(str); }
+    void setErrorString();
+    void setExtraPropertyCallBack(SkDisplayTypes type, SkScriptEngine::_propertyCallBack , void* userStorage);
+    void setID(SkDisplayable* displayable, const SkString& newID);
+    void setInnerError(SkAnimateMaker* maker, const SkString& str) { fError.setInnerError(maker, str); }
+    void setScriptError(const SkScriptEngine& );
 #ifdef SK_DEBUG
-       void validate() { fDisplayList.validate(); }
+    void validate() { fDisplayList.validate(); }
 #else
-       void validate() {}
+    void validate() {}
 #endif
-       SkDisplayEvent* fActiveEvent;
-       SkMSec fAdjustedStart;
-       SkBitmap fBitmap;
-       SkCanvas* fCanvas;
-       SkMSec fEnableTime;
-       int fEndDepth;  // passed parameter to onEndElement
-       SkEvents fEvents;
-       SkDisplayList fDisplayList;
-       SkEventSinkID fHostEventSinkID;
-       SkMSec fMinimumInterval;
-       SkPaint* fPaint;
-       SkAnimateMaker* fParentMaker;
-       SkString fPrefix;
-       SkDisplayScreenplay fScreenplay;
-       const SkAnimator::Timeline* fTimeline;
+    SkDisplayEvent* fActiveEvent;
+    SkMSec fAdjustedStart;
+    SkBitmap fBitmap;
+    SkCanvas* fCanvas;
+    SkMSec fEnableTime;
+    int fEndDepth;  // passed parameter to onEndElement
+    SkEvents fEvents;
+    SkDisplayList fDisplayList;
+    SkEventSinkID fHostEventSinkID;
+    SkMSec fMinimumInterval;
+    SkPaint* fPaint;
+    SkAnimateMaker* fParentMaker;
+    SkString fPrefix;
+    SkDisplayScreenplay fScreenplay;
+    const SkAnimator::Timeline* fTimeline;
     SkBool8 fInInclude;
-       SkBool8 fInMovie;
-       SkBool8 fFirstScriptError;
+    SkBool8 fInMovie;
+    SkBool8 fFirstScriptError;
 #if defined SK_DEBUG && defined SK_DEBUG_ANIMATION_TIMING
-       SkMSec fDebugTimeBase;
+    SkMSec fDebugTimeBase;
 #endif
 #ifdef SK_DUMP_ENABLED
-       SkString fDumpAnimated;
-       SkBool8 fDumpEvents;
-       SkBool8 fDumpGConditions;
-       SkBool8 fDumpPosts;
+    SkString fDumpAnimated;
+    SkBool8 fDumpEvents;
+    SkBool8 fDumpGConditions;
+    SkBool8 fDumpPosts;
 #endif
 private:
-       void deleteMembers();
-       static bool GetStep(const char* token, size_t len, void* stepPtr, SkScriptValue* );
-       SkAnimateMaker& operator=(SkAnimateMaker& );
-       SkTDDisplayableArray fChildren;
-       SkTDDisplayableArray fDelayed; // SkApply that contain delayed enable events
-       SkDisplayXMLParserError fError;
-       SkString fErrorString;
-       SkTDArray<SkExtras*> fExtras;
-       SkString fFileName;
-       SkTDDisplayableArray fHelpers;  // helper displayables
-       SkBool8 fLoaded;
-       SkTDDisplayableArray fMovies;
-       SkTDict<SkDisplayable*> fIDs;
-       SkAnimator* fAnimator;
-       friend class SkAdd;
-       friend class SkAnimateBase;
-       friend class SkDisplayXMLParser;
-       friend class SkAnimator;
-       friend class SkAnimatorScript;
-       friend class SkApply;
-       friend class SkDisplayMovie;
-       friend class SkDisplayType;
-       friend class SkEvents;
-       friend class SkGroup;
-       friend struct SkMemberInfo;
+    void deleteMembers();
+    static bool GetStep(const char* token, size_t len, void* stepPtr, SkScriptValue* );
+    SkAnimateMaker& operator=(SkAnimateMaker& );
+    SkTDDisplayableArray fChildren;
+    SkTDDisplayableArray fDelayed; // SkApply that contain delayed enable events
+    SkDisplayXMLParserError fError;
+    SkString fErrorString;
+    SkTDArray<SkExtras*> fExtras;
+    SkString fFileName;
+    SkTDDisplayableArray fHelpers;  // helper displayables
+    SkBool8 fLoaded;
+    SkTDDisplayableArray fMovies;
+    SkTDict<SkDisplayable*> fIDs;
+    SkAnimator* fAnimator;
+    friend class SkAdd;
+    friend class SkAnimateBase;
+    friend class SkDisplayXMLParser;
+    friend class SkAnimator;
+    friend class SkAnimatorScript;
+    friend class SkApply;
+    friend class SkDisplayMovie;
+    friend class SkDisplayType;
+    friend class SkEvents;
+    friend class SkGroup;
+    friend struct SkMemberInfo;
 };
 
 #endif // SkAnimateMaker_DEFINED
index 17bc777..a49d2b3 100644 (file)
@@ -1,12 +1,29 @@
+/* libs/graphics/animator/SkAnimateProperties.h
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #ifndef SkAnimateProperties_DEFINED
 #define SkAnimateProperties_DEFINED
 
 enum SkAnimateBase_Properties {
-       SK_PROPERTY(dynamic),
-       SK_PROPERTY(mirror),
-       SK_PROPERTY(reset),
-       SK_PROPERTY(step),
-       SK_PROPERTY(values)
+    SK_PROPERTY(dynamic),
+    SK_PROPERTY(mirror),
+    SK_PROPERTY(reset),
+    SK_PROPERTY(step),
+    SK_PROPERTY(values)
 };
 
 #endif // SkAnimateProperties_DEFINED
index 4de2de5..f1c598f 100644 (file)
@@ -1,3 +1,20 @@
+/* libs/graphics/animator/SkAnimateSet.cpp
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #include "SkAnimateSet.h"
 #include "SkAnimateMaker.h"
 #include "SkAnimateProperties.h"
 #if SK_USE_CONDENSED_INFO == 0
 
 const SkMemberInfo SkSet::fInfo[] = {
-       SK_MEMBER(begin, MSec),
-       SK_MEMBER(dur, MSec),
-       SK_MEMBER_PROPERTY(dynamic, Boolean),
-       SK_MEMBER(field, String),
-//     SK_MEMBER(formula, DynamicString),
-       SK_MEMBER(lval, DynamicString),
-//     SK_MEMBER_PROPERTY(reset, Boolean),
-       SK_MEMBER_PROPERTY(step, Int),
-       SK_MEMBER(target, DynamicString),
-       SK_MEMBER(to, DynamicString)
+    SK_MEMBER(begin, MSec),
+    SK_MEMBER(dur, MSec),
+    SK_MEMBER_PROPERTY(dynamic, Boolean),
+    SK_MEMBER(field, String),
+//  SK_MEMBER(formula, DynamicString),
+    SK_MEMBER(lval, DynamicString),
+//  SK_MEMBER_PROPERTY(reset, Boolean),
+    SK_MEMBER_PROPERTY(step, Int),
+    SK_MEMBER(target, DynamicString),
+    SK_MEMBER(to, DynamicString)
 };
 
 #endif
@@ -23,17 +40,17 @@ const SkMemberInfo SkSet::fInfo[] = {
 DEFINE_GET_MEMBER(SkSet);
 
 SkSet::SkSet() {
-       dur = 1; 
+    dur = 1; 
 }
 
 #ifdef SK_DUMP_ENABLED
 void SkSet::dump(SkAnimateMaker* maker) {
-       INHERITED::dump(maker);
-       if (dur != 1) {
+    INHERITED::dump(maker);
+    if (dur != 1) {
 #ifdef SK_CAN_USE_FLOAT
-               SkDebugf("dur=\"%g\" ", SkScalarToFloat(SkScalarDiv(dur,1000)));
+        SkDebugf("dur=\"%g\" ", SkScalarToFloat(SkScalarDiv(dur,1000)));
 #else
-               SkDebugf("dur=\"%x\" ", SkScalarDiv(dur,1000));
+        SkDebugf("dur=\"%x\" ", SkScalarDiv(dur,1000));
 #endif
     }
     //don't want double />\n's
@@ -43,39 +60,39 @@ void SkSet::dump(SkAnimateMaker* maker) {
 #endif
 
 void SkSet::refresh(SkAnimateMaker& maker) {
-       fFieldInfo->setValue(maker, &fValues, 0, fFieldInfo->fCount, nil, 
-               fFieldInfo->getType(), to);
+    fFieldInfo->setValue(maker, &fValues, 0, fFieldInfo->fCount, nil, 
+        fFieldInfo->getType(), to);
 }
 
 void SkSet::onEndElement(SkAnimateMaker& maker) {
-       if (resolveCommon(maker) == false)
-               return;
-       if (fFieldInfo == nil) {
-               maker.setErrorCode(SkDisplayXMLParserError::kFieldNotInTarget);
-               return;
-       }
-       fReset = dur != 1;
-       SkDisplayTypes outType = fFieldInfo->getType();
-       int comps = outType == SkType_String || outType == SkType_DynamicString ? 1 :
-               fFieldInfo->getSize((const SkDisplayable*) fTarget) / sizeof(int);
-       if (fValues.getType() == SkType_Unknown) {
-               fValues.setType(outType);
-               fValues.setCount(comps);
-               if (outType == SkType_String || outType == SkType_DynamicString)
-                       fValues[0].fString = SkNEW(SkString);
-               else
-                       memset(fValues.begin(), 0, fValues.count() * sizeof(fValues.begin()[0]));
-       } else {
-               SkASSERT(fValues.getType() == outType);
-               if (fFieldInfo->fType == SkType_Array)
-                       comps = fValues.count();
-               else
-                       SkASSERT(fValues.count() == comps);
-       }
-       if (formula.size() > 0) {
-               comps = 1;
-               outType = SkType_MSec;
-       }
-       fFieldInfo->setValue(maker, &fValues, fFieldOffset, comps, this, outType, formula.size() > 0 ? formula : to);
-       fComponents = fValues.count();
+    if (resolveCommon(maker) == false)
+        return;
+    if (fFieldInfo == nil) {
+        maker.setErrorCode(SkDisplayXMLParserError::kFieldNotInTarget);
+        return;
+    }
+    fReset = dur != 1;
+    SkDisplayTypes outType = fFieldInfo->getType();
+    int comps = outType == SkType_String || outType == SkType_DynamicString ? 1 :
+        fFieldInfo->getSize((const SkDisplayable*) fTarget) / sizeof(int);
+    if (fValues.getType() == SkType_Unknown) {
+        fValues.setType(outType);
+        fValues.setCount(comps);
+        if (outType == SkType_String || outType == SkType_DynamicString)
+            fValues[0].fString = SkNEW(SkString);
+        else
+            memset(fValues.begin(), 0, fValues.count() * sizeof(fValues.begin()[0]));
+    } else {
+        SkASSERT(fValues.getType() == outType);
+        if (fFieldInfo->fType == SkType_Array)
+            comps = fValues.count();
+        else
+            SkASSERT(fValues.count() == comps);
+    }
+    if (formula.size() > 0) {
+        comps = 1;
+        outType = SkType_MSec;
+    }
+    fFieldInfo->setValue(maker, &fValues, fFieldOffset, comps, this, outType, formula.size() > 0 ? formula : to);
+    fComponents = fValues.count();
 }
index 476459f..8e88b41 100644 (file)
@@ -1,18 +1,35 @@
+/* libs/graphics/animator/SkAnimateSet.h
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #ifndef SkAnimateSet_DEFINED
 #define SkAnimateSet_DEFINED
 
 #include "SkAnimate.h"
 
 class SkSet : public SkAnimate {
-       DECLARE_MEMBER_INFO(Set);
-       SkSet();
+    DECLARE_MEMBER_INFO(Set);
+    SkSet();
 #ifdef SK_DUMP_ENABLED
-       virtual void dump(SkAnimateMaker* );
+    virtual void dump(SkAnimateMaker* );
 #endif
-       virtual void onEndElement(SkAnimateMaker& );
-       virtual void refresh(SkAnimateMaker& );
+    virtual void onEndElement(SkAnimateMaker& );
+    virtual void refresh(SkAnimateMaker& );
 private:
-       typedef SkAnimate INHERITED;
+    typedef SkAnimate INHERITED;
 };
 
 #endif // SkAnimateSet_DEFINED
index 17f6855..0c04b0f 100644 (file)
@@ -1,3 +1,20 @@
+/* libs/graphics/animator/SkAnimator.cpp
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #include "SkAnimator.h"
 #include "SkAnimateMaker.h"
 #include "SkCanvas.h"
@@ -7,7 +24,7 @@
 #include "SkDisplayXMLParser.h"
 #include "SkStream.h"
 #include "SkScript.h"
-#include "SkScript2.h" //      compiled script experiment
+#include "SkScript2.h" //   compiled script experiment
 #include "SkSystemEventTypes.h"
 #include "SkTypedArray.h"
 #ifdef ANDROID
 #endif
 
 #if defined SK_BUILD_FOR_WIN32 && defined SK_DEBUG
-       #define _static
-       extern const char gMathPrimerText[];
-       extern const char gMathPrimerBinary[];
+    #define _static
+    extern const char gMathPrimerText[];
+    extern const char gMathPrimerBinary[];
 #else
-       #define _static static
+    #define _static static
 #endif
 
 #if !defined SK_BUILD_FOR_BREW || defined SK_DEBUG
-       _static const char gMathPrimerText[] = 
-       "<screenplay>"
-               "<Math id=\"Math\"/>"
-               "<Number id=\"Number\"/>"
-       "</screenplay>";
+    _static const char gMathPrimerText[] = 
+    "<screenplay>"
+        "<Math id=\"Math\"/>"
+        "<Number id=\"Number\"/>"
+    "</screenplay>";
 #endif
 
 #if defined SK_BUILD_FOR_BREW || defined SK_DEBUG
-       _static const char gMathPrimerBinary[] = 
-       "\x0Ascreenplay\x04Mathbid\x04Math@@";  // !!! now out of date -- does not include Number
+    _static const char gMathPrimerBinary[] = 
+    "\x0Ascreenplay\x04Mathbid\x04Math@@";  // !!! now out of date -- does not include Number
 #endif
 
 #if defined SK_BUILD_FOR_BREW
-       #define gMathPrimer gMathPrimerBinary
+    #define gMathPrimer gMathPrimerBinary
 #else
-       #define gMathPrimer gMathPrimerText
+    #define gMathPrimer gMathPrimerText
 #endif
 
 SkAnimator::SkAnimator() : fMaker(nil) {
-       initialize();
+    initialize();
 }
 
 SkAnimator::~SkAnimator() {
-       SkDELETE(fMaker);
+    SkDELETE(fMaker);
 }
 
 void SkAnimator::addExtras(SkExtras* extras) {
-       *fMaker->fExtras.append() = extras;
+    *fMaker->fExtras.append() = extras;
 }
 
 bool SkAnimator::appendStream(SkStream* stream) {
-       return decodeStream(stream);
+    return decodeStream(stream);
 }
 
 bool SkAnimator::decodeMemory(const void* buffer, size_t size)
 {
-       fMaker->fFileName.reset();
-       SkDisplayXMLParser parser(*fMaker);
-       return parser.parse((const char*)buffer, size);
+    fMaker->fFileName.reset();
+    SkDisplayXMLParser parser(*fMaker);
+    return parser.parse((const char*)buffer, size);
 }
 
 bool SkAnimator::decodeStream(SkStream* stream)
 {
-       SkDisplayXMLParser parser(*fMaker);
-       bool result = parser.parse(*stream);
-       fMaker->setErrorString();
-       return result;
+    SkDisplayXMLParser parser(*fMaker);
+    bool result = parser.parse(*stream);
+    fMaker->setErrorString();
+    return result;
 }
 
 bool SkAnimator::decodeDOM(const SkDOM& dom, const SkDOMNode* node)
 {
-       fMaker->fFileName.reset();
-       SkDisplayXMLParser parser(*fMaker);
-       return parser.parse(dom, node);
+    fMaker->fFileName.reset();
+    SkDisplayXMLParser parser(*fMaker);
+    return parser.parse(dom, node);
 }
 
 bool SkAnimator::decodeURI(const char uri[]) {
-//     SkDebugf("animator decode %s\n", uri);
-       SkStream* stream = SkStream::GetURIStream(fMaker->fPrefix.c_str(), uri);
-       SkAutoTDelete<SkStream> autoDel(stream);
-       setURIBase(uri);
-       return decodeStream(stream);
+//  SkDebugf("animator decode %s\n", uri);
+    SkStream* stream = SkStream::GetURIStream(fMaker->fPrefix.c_str(), uri);
+    SkAutoTDelete<SkStream> autoDel(stream);
+    setURIBase(uri);
+    return decodeStream(stream);
 }
 
 bool SkAnimator::doCharEvent(SkUnichar code) {
-       if (code == 0)
-               return false;
-       struct SkEventState state;
-       state.fCode = code;
-       fMaker->fEnableTime = fMaker->getAppTime();
-       bool result = fMaker->fEvents.doEvent(*fMaker, SkDisplayEvent::kKeyChar, &state);
-       fMaker->notifyInval();
-       return result;
+    if (code == 0)
+        return false;
+    struct SkEventState state;
+    state.fCode = code;
+    fMaker->fEnableTime = fMaker->getAppTime();
+    bool result = fMaker->fEvents.doEvent(*fMaker, SkDisplayEvent::kKeyChar, &state);
+    fMaker->notifyInval();
+    return result;
 }
 
 bool SkAnimator::doClickEvent(int clickState, SkScalar x, SkScalar y) {
-       SkASSERT(clickState >= 0 && clickState <= 2);
-       struct SkEventState state;
-       state.fX = x;
-       state.fY = y;
-       fMaker->fEnableTime = fMaker->getAppTime();
-       bool result = fMaker->fEvents.doEvent(*fMaker, 
-               clickState == 0 ? SkDisplayEvent::kMouseDown : 
-               clickState == 1 ? SkDisplayEvent::kMouseDrag : 
-               SkDisplayEvent::kMouseUp, &state);
-       fMaker->notifyInval();
-       return result;
+    SkASSERT(clickState >= 0 && clickState <= 2);
+    struct SkEventState state;
+    state.fX = x;
+    state.fY = y;
+    fMaker->fEnableTime = fMaker->getAppTime();
+    bool result = fMaker->fEvents.doEvent(*fMaker, 
+        clickState == 0 ? SkDisplayEvent::kMouseDown : 
+        clickState == 1 ? SkDisplayEvent::kMouseDrag : 
+        SkDisplayEvent::kMouseUp, &state);
+    fMaker->notifyInval();
+    return result;
 }
 
 bool SkAnimator::doKeyEvent(SkKey code) {
-       if (code == 0)
-               return false;
-       struct SkEventState state;
-       state.fCode = code;
-       fMaker->fEnableTime = fMaker->getAppTime();
-       bool result = fMaker->fEvents.doEvent(*fMaker, SkDisplayEvent::kKeyPress, &state);
-       fMaker->notifyInval();
-       return result;
+    if (code == 0)
+        return false;
+    struct SkEventState state;
+    state.fCode = code;
+    fMaker->fEnableTime = fMaker->getAppTime();
+    bool result = fMaker->fEvents.doEvent(*fMaker, SkDisplayEvent::kKeyPress, &state);
+    fMaker->notifyInval();
+    return result;
 }
 
 bool SkAnimator::doKeyUpEvent(SkKey code) {
@@ -138,255 +155,255 @@ bool SkAnimator::doKeyUpEvent(SkKey code) {
 }
 
 bool SkAnimator::doUserEvent(const SkEvent& evt) {
-       fMaker->fEnableTime = fMaker->getAppTime();
-       return onEvent(evt);
+    fMaker->fEnableTime = fMaker->getAppTime();
+    return onEvent(evt);
 }
 
 SkAnimator::DifferenceType SkAnimator::draw(SkCanvas* canvas, SkPaint* paint, SkMSec time) {
-       if (paint == nil)
-               return draw(canvas, time);
-       fMaker->fScreenplay.time = time;
-       fMaker->fCanvas = canvas;
-       fMaker->fPaint = paint;
-       fMaker->fCanvas->getPixels(&fMaker->fBitmap);
-       fMaker->fDisplayList.fHasUnion = false;
-       int result = fMaker->fDisplayList.draw(*fMaker, time);
-       if (result)
-               result += fMaker->fDisplayList.fHasUnion;
-       return (DifferenceType) result;
+    if (paint == nil)
+        return draw(canvas, time);
+    fMaker->fScreenplay.time = time;
+    fMaker->fCanvas = canvas;
+    fMaker->fPaint = paint;
+    fMaker->fCanvas->getPixels(&fMaker->fBitmap);
+    fMaker->fDisplayList.fHasUnion = false;
+    int result = fMaker->fDisplayList.draw(*fMaker, time);
+    if (result)
+        result += fMaker->fDisplayList.fHasUnion;
+    return (DifferenceType) result;
 }
 
 SkAnimator::DifferenceType SkAnimator::draw(SkCanvas* canvas, SkMSec time) {
-       SkPaint paint;
-       return draw(canvas, &paint, time);
+    SkPaint paint;
+    return draw(canvas, &paint, time);
 }
-       
+    
 #ifdef SK_DEBUG
 void SkAnimator::eventDone(const SkEvent& ) {
 }
 #endif
 
 bool SkAnimator::findClickEvent(SkScalar x, SkScalar y) {
-       struct SkEventState state;
-       state.fDisable = true;
-       state.fX = x;
-       state.fY = y;
-       fMaker->fEnableTime = fMaker->getAppTime();
-       bool result = fMaker->fEvents.doEvent(*fMaker, SkDisplayEvent::kMouseDown, &state);
-       fMaker->notifyInval();
-       return result;
+    struct SkEventState state;
+    state.fDisable = true;
+    state.fX = x;
+    state.fY = y;
+    fMaker->fEnableTime = fMaker->getAppTime();
+    bool result = fMaker->fEvents.doEvent(*fMaker, SkDisplayEvent::kMouseDown, &state);
+    fMaker->notifyInval();
+    return result;
 }
 
 const SkAnimator* SkAnimator::getAnimator(const SkDisplayable* displayable) const {
-       if (displayable->getType() != SkType_Movie)
-               return nil;
-       const SkDisplayMovie* movie = (const SkDisplayMovie*) displayable;
-       return movie->getAnimator();
+    if (displayable->getType() != SkType_Movie)
+        return nil;
+    const SkDisplayMovie* movie = (const SkDisplayMovie*) displayable;
+    return movie->getAnimator();
 }
 
 const SkDisplayable* SkAnimator::getElement(const char* id) {
-       SkDisplayable* element;
-       if (fMaker->find(id, &element) == false)
-               return nil;
-       return (const SkDisplayable*) element;
+    SkDisplayable* element;
+    if (fMaker->find(id, &element) == false)
+        return nil;
+    return (const SkDisplayable*) element;
 }
 
 SkElementType SkAnimator::getElementType(const SkDisplayable* ae) {
-       SkDisplayable* element = (SkDisplayable*) ae;
-       const SkMemberInfo* info = SkDisplayType::GetMembers(fMaker, element->getType(), nil);
-       return (SkElementType) SkDisplayType::Find(fMaker, info);
+    SkDisplayable* element = (SkDisplayable*) ae;
+    const SkMemberInfo* info = SkDisplayType::GetMembers(fMaker, element->getType(), nil);
+    return (SkElementType) SkDisplayType::Find(fMaker, info);
 }
 
 SkElementType SkAnimator::getElementType(const char* id) {
-       const SkDisplayable* element = getElement(id);
-       return getElementType(element);
+    const SkDisplayable* element = getElement(id);
+    return getElementType(element);
 }
 
 const SkMemberInfo* SkAnimator::getField(const SkDisplayable* ae, const char* field) {
-       SkDisplayable* element = (SkDisplayable*) ae;
-       const SkMemberInfo* info = element->getMember(field);
-       return (const SkMemberInfo*) info;
+    SkDisplayable* element = (SkDisplayable*) ae;
+    const SkMemberInfo* info = element->getMember(field);
+    return (const SkMemberInfo*) info;
 }
 
 const SkMemberInfo* SkAnimator::getField(const char* elementID, const char* field) {
-       const SkDisplayable* element = getElement(elementID);
-       return getField(element, field);
+    const SkDisplayable* element = getElement(elementID);
+    return getField(element, field);
 }
 
 SkFieldType SkAnimator::getFieldType(const SkMemberInfo* ai) {
-       const SkMemberInfo* info = (const SkMemberInfo*) ai;
-       return (SkFieldType) info->getType();
+    const SkMemberInfo* info = (const SkMemberInfo*) ai;
+    return (SkFieldType) info->getType();
 }
 
 SkFieldType SkAnimator::getFieldType(const char* id, const char* fieldID) {
-       const SkMemberInfo* field = getField(id, fieldID);
-       return getFieldType(field);
+    const SkMemberInfo* field = getField(id, fieldID);
+    return getFieldType(field);
 }
 
  static bool getArrayCommon(const SkDisplayable* ae, const SkMemberInfo* ai,
-        int index, SkOperand* operand, SkDisplayTypes type) {
-       const SkDisplayable* element = (const SkDisplayable*) ae;
-       const SkMemberInfo* info = (const SkMemberInfo*) ai;
-       SkASSERT(info->fType == SkType_Array);
-       return info->getArrayValue(element, index, operand);
+     int index, SkOperand* operand, SkDisplayTypes type) {
+    const SkDisplayable* element = (const SkDisplayable*) ae;
+    const SkMemberInfo* info = (const SkMemberInfo*) ai;
+    SkASSERT(info->fType == SkType_Array);
+    return info->getArrayValue(element, index, operand);
 }
 
 int32_t SkAnimator::getArrayInt(const SkDisplayable* ae, 
-               const SkMemberInfo* ai, int index) {
-       SkOperand operand;
-       bool result = getArrayCommon(ae, ai, index, &operand, SkType_Int);
-       return result ? operand.fS32 : SK_NaN32;
+        const SkMemberInfo* ai, int index) {
+    SkOperand operand;
+    bool result = getArrayCommon(ae, ai, index, &operand, SkType_Int);
+    return result ? operand.fS32 : SK_NaN32;
 }
 
 int32_t SkAnimator::getArrayInt(const char* id, const char* fieldID, int index) {
-       const SkDisplayable* element = getElement(id);
-       if (element == nil)
-               return SK_NaN32;
-       const SkMemberInfo* field = getField(element, fieldID);
-       if (field == nil)
-               return SK_NaN32;
-       return getArrayInt(element, field, index);
+    const SkDisplayable* element = getElement(id);
+    if (element == nil)
+        return SK_NaN32;
+    const SkMemberInfo* field = getField(element, fieldID);
+    if (field == nil)
+        return SK_NaN32;
+    return getArrayInt(element, field, index);
 }
 
 SkScalar SkAnimator::getArrayScalar(const SkDisplayable* ae, 
-               const SkMemberInfo* ai, int index) {
-       SkOperand operand;
-       bool result = getArrayCommon(ae, ai, index, &operand, SkType_Float);
-       return result ? operand.fScalar : SK_ScalarNaN;
+        const SkMemberInfo* ai, int index) {
+    SkOperand operand;
+    bool result = getArrayCommon(ae, ai, index, &operand, SkType_Float);
+    return result ? operand.fScalar : SK_ScalarNaN;
 }
 
 SkScalar SkAnimator::getArrayScalar(const char* id, const char* fieldID, int index) {
-       const SkDisplayable* element = getElement(id);
-       if (element == nil)
-               return SK_ScalarNaN;
-       const SkMemberInfo* field = getField(element, fieldID);
-       if (field == nil)
-               return SK_ScalarNaN;
-       return getArrayScalar(element, field, index);
+    const SkDisplayable* element = getElement(id);
+    if (element == nil)
+        return SK_ScalarNaN;
+    const SkMemberInfo* field = getField(element, fieldID);
+    if (field == nil)
+        return SK_ScalarNaN;
+    return getArrayScalar(element, field, index);
 }
 
 const char* SkAnimator::getArrayString(const SkDisplayable* ae, 
-               const SkMemberInfo* ai, int index) {
-       SkOperand operand;
-       bool result = getArrayCommon(ae, ai, index, &operand, SkType_String);
-       return result ? operand.fString->c_str() : nil;
+        const SkMemberInfo* ai, int index) {
+    SkOperand operand;
+    bool result = getArrayCommon(ae, ai, index, &operand, SkType_String);
+    return result ? operand.fString->c_str() : nil;
 }
 
 const char* SkAnimator::getArrayString(const char* id, const char* fieldID, int index) {
-       const SkDisplayable* element = getElement(id);
-       if (element == nil)
-               return nil;
-       const SkMemberInfo* field = getField(element, fieldID);
-       if (field == nil)
-               return nil;
-       return getArrayString(element, field, index);
+    const SkDisplayable* element = getElement(id);
+    if (element == nil)
+        return nil;
+    const SkMemberInfo* field = getField(element, fieldID);
+    if (field == nil)
+        return nil;
+    return getArrayString(element, field, index);
 }
 
 SkMSec SkAnimator::getInterval() {
-       return fMaker->fMinimumInterval == (SkMSec) -1 ? 0 : fMaker->fMinimumInterval;
+    return fMaker->fMinimumInterval == (SkMSec) -1 ? 0 : fMaker->fMinimumInterval;
 }
 
 void SkAnimator::getInvalBounds(SkRect* inval) {
-       if (fMaker->fDisplayList.fHasUnion) {
-               inval->fLeft = SkIntToScalar(fMaker->fDisplayList.fInvalBounds.fLeft);
-               inval->fTop = SkIntToScalar(fMaker->fDisplayList.fInvalBounds.fTop);
-               inval->fRight = SkIntToScalar(fMaker->fDisplayList.fInvalBounds.fRight);
-               inval->fBottom = SkIntToScalar(fMaker->fDisplayList.fInvalBounds.fBottom);
-       } else {
-               inval->fLeft = inval->fTop = -SK_ScalarMax;
-               inval->fRight = inval->fBottom = SK_ScalarMax;
-       }
+    if (fMaker->fDisplayList.fHasUnion) {
+        inval->fLeft = SkIntToScalar(fMaker->fDisplayList.fInvalBounds.fLeft);
+        inval->fTop = SkIntToScalar(fMaker->fDisplayList.fInvalBounds.fTop);
+        inval->fRight = SkIntToScalar(fMaker->fDisplayList.fInvalBounds.fRight);
+        inval->fBottom = SkIntToScalar(fMaker->fDisplayList.fInvalBounds.fBottom);
+    } else {
+        inval->fLeft = inval->fTop = -SK_ScalarMax;
+        inval->fRight = inval->fBottom = SK_ScalarMax;
+    }
 }
 
 const SkXMLParserError* SkAnimator::getParserError() {
-       return &fMaker->fError;
+    return &fMaker->fError;
 }
 
 const char* SkAnimator::getParserErrorString() {
-       if (fMaker->fErrorString.size() == 0 && fMaker->fError.hasError())
-               fMaker->setErrorString();
-       return fMaker->fErrorString.c_str();
+    if (fMaker->fErrorString.size() == 0 && fMaker->fError.hasError())
+        fMaker->setErrorString();
+    return fMaker->fErrorString.c_str();
 }
 
 int32_t SkAnimator::getInt(const SkDisplayable* element, const SkMemberInfo* info) {
-       if (info->fType != SkType_MemberProperty) {
-               SkOperand operand;
-               if (info->getType() == SkType_Int) {
-                       info->getValue(element, &operand, 1);
-                       return operand.fS32;
-               }
-               return SK_NaN32;
-       }
-       SkScriptValue scriptValue;
-       bool success = element->getProperty(info->propertyIndex(), &scriptValue);
-       if (success && scriptValue.fType == SkType_Int)
-               return scriptValue.fOperand.fS32;
-       return SK_NaN32;
+    if (info->fType != SkType_MemberProperty) {
+        SkOperand operand;
+        if (info->getType() == SkType_Int) {
+            info->getValue(element, &operand, 1);
+            return operand.fS32;
+        }
+        return SK_NaN32;
+    }
+    SkScriptValue scriptValue;
+    bool success = element->getProperty(info->propertyIndex(), &scriptValue);
+    if (success && scriptValue.fType == SkType_Int)
+        return scriptValue.fOperand.fS32;
+    return SK_NaN32;
 }
 
 int32_t SkAnimator::getInt(const char* id, const char* fieldID) {
-       const SkDisplayable* element = getElement(id);
-       if (element == nil)
-               return SK_NaN32;
-       const SkMemberInfo* field = getField(element, fieldID);
-       if (field == nil)
-               return SK_NaN32;
-       return getInt(element, field);
+    const SkDisplayable* element = getElement(id);
+    if (element == nil)
+        return SK_NaN32;
+    const SkMemberInfo* field = getField(element, fieldID);
+    if (field == nil)
+        return SK_NaN32;
+    return getInt(element, field);
 }
 
 SkScalar SkAnimator::getScalar(const SkDisplayable* element, const SkMemberInfo* info) {
-       if (info->fType != SkType_MemberProperty) {
-               SkOperand operand;
-               if (info->getType() == SkType_Float) {
-                       info->getValue(element, &operand, 1);
-                       return operand.fScalar;
-               }
-               return SK_ScalarNaN;
-       }
-       SkScriptValue scriptValue;
-       bool success = element->getProperty(info->propertyIndex(), &scriptValue);
-       if (success && scriptValue.fType == SkType_Float)
-               return scriptValue.fOperand.fScalar;
-       return SK_ScalarNaN;
+    if (info->fType != SkType_MemberProperty) {
+        SkOperand operand;
+        if (info->getType() == SkType_Float) {
+            info->getValue(element, &operand, 1);
+            return operand.fScalar;
+        }
+        return SK_ScalarNaN;
+    }
+    SkScriptValue scriptValue;
+    bool success = element->getProperty(info->propertyIndex(), &scriptValue);
+    if (success && scriptValue.fType == SkType_Float)
+        return scriptValue.fOperand.fScalar;
+    return SK_ScalarNaN;
 }
 
 SkScalar SkAnimator::getScalar(const char* id, const char* fieldID) {
-       const SkDisplayable* element = getElement(id);
-       if (element == nil)
-               return SK_ScalarNaN;
-       const SkMemberInfo* field = getField(element, fieldID);
-       if (field == nil)
-               return SK_ScalarNaN;
-       return getScalar(element, field);
+    const SkDisplayable* element = getElement(id);
+    if (element == nil)
+        return SK_ScalarNaN;
+    const SkMemberInfo* field = getField(element, fieldID);
+    if (field == nil)
+        return SK_ScalarNaN;
+    return getScalar(element, field);
 }
 
 const char* SkAnimator::getString(const SkDisplayable* ae, 
-               const SkMemberInfo* ai) {
-       const SkDisplayable* element = (const SkDisplayable*) ae;
-       const SkMemberInfo* info = (const SkMemberInfo*) ai;
-       SkString* temp;
-       info->getString(element, &temp);
-       return temp->c_str();
+        const SkMemberInfo* ai) {
+    const SkDisplayable* element = (const SkDisplayable*) ae;
+    const SkMemberInfo* info = (const SkMemberInfo*) ai;
+    SkString* temp;
+    info->getString(element, &temp);
+    return temp->c_str();
 }
 
 const char* SkAnimator::getString(const char* id, const char* fieldID) {
-       const SkDisplayable* element = getElement(id);
-       if (element == nil)
-               return nil;
-       const SkMemberInfo* field = getField(element, fieldID);
-       if (field == nil)
-               return nil;
-       return getString(element, field);
+    const SkDisplayable* element = getElement(id);
+    if (element == nil)
+        return nil;
+    const SkMemberInfo* field = getField(element, fieldID);
+    if (field == nil)
+        return nil;
+    return getString(element, field);
 }
 
 const char* SkAnimator::getURIBase() {
-       return fMaker->fPrefix.c_str();
+    return fMaker->fPrefix.c_str();
 }
 
 void SkAnimator::initialize() {
-       SkDELETE(fMaker);
-       fMaker = SkNEW_ARGS(SkAnimateMaker, (this, nil, nil));
-       decodeMemory(gMathPrimer, sizeof(gMathPrimer)-1);
+    SkDELETE(fMaker);
+    fMaker = SkNEW_ARGS(SkAnimateMaker, (this, nil, nil));
+    decodeMemory(gMathPrimer, sizeof(gMathPrimer)-1);
 #ifdef ANDROID
     InitializeSkExtraPathEffects(this);
 #endif
@@ -395,117 +412,117 @@ void SkAnimator::initialize() {
 
 #ifdef SK_DEBUG
 bool SkAnimator::isTrackingEvents() {
-       return false;
+    return false;
 }
 #endif
 
 bool SkAnimator::onEvent(const SkEvent& evt) {
 #ifdef SK_DEBUG
-       SkAnimator* root = fMaker->getRoot();
-       if (root == nil)
-               root = this;
-       if (root->isTrackingEvents())
-               root->eventDone(evt);
+    SkAnimator* root = fMaker->getRoot();
+    if (root == nil)
+        root = this;
+    if (root->isTrackingEvents())
+        root->eventDone(evt);
 #endif
-       if (evt.isType(SK_EventType_OnEnd)) {
-               SkEventState eventState;
-               bool success = evt.findPtr("anim", (void**) &eventState.fDisplayable);
-               SkASSERT(success);
-               success = evt.findS32("time", (int32_t*) &fMaker->fEnableTime);
-               SkASSERT(success);
-               fMaker->fAdjustedStart = fMaker->getAppTime() - fMaker->fEnableTime;
-               fMaker->fEvents.doEvent(*fMaker, SkDisplayEvent::kOnEnd, &eventState);
-               fMaker->fAdjustedStart = 0;
-               goto inval;
-       }
-       if (evt.isType(SK_EventType_Delay)) {
-               fMaker->doDelayedEvent();
-               goto inval;
-       }
-       {
-               const char* id = evt.findString("id");
-               if (id == nil)
-                       return false;
-               SkDisplayable** firstMovie = fMaker->fMovies.begin();
-               SkDisplayable** endMovie = fMaker->fMovies.end();
-               for (SkDisplayable** ptr = firstMovie; ptr < endMovie; ptr++) {
-                       SkDisplayMovie* movie = (SkDisplayMovie*) *ptr;
-                       movie->doEvent(evt);
-               }
-               {
-                       SkDisplayable* event;
-                       if (fMaker->find(id, &event) == false)
-                               return false;
-       #if defined SK_DEBUG && defined SK_DEBUG_ANIMATION_TIMING
-                       SkString debugOut;
-                       SkMSec realTime = fMaker->getAppTime();
-                       debugOut.appendS32(realTime - fMaker->fDebugTimeBase);
-                       debugOut.append(" onEvent id=");
-                       debugOut.append(id);
-       #endif
-                       SkMSec time = evt.getFast32();
-                       if (time != 0) {
-                               SkMSec app  = fMaker->getAppTime();
-                               fMaker->setEnableTime(app, time);
-       #if defined SK_DEBUG && defined SK_DEBUG_ANIMATION_TIMING
-                               debugOut.append(" time=");
-                               debugOut.appendS32(time - fMaker->fDebugTimeBase);
-                               debugOut.append(" adjust=");
-                               debugOut.appendS32(fMaker->fAdjustedStart);
-       #endif
-                       }
-       #if defined SK_DEBUG && defined SK_DEBUG_ANIMATION_TIMING
-                       SkDebugf("%s\n", debugOut.c_str());
-       #endif
-                       SkASSERT(event->isEvent());
-                       SkDisplayEvent* displayEvent = (SkDisplayEvent*) event;
-                       displayEvent->populateInput(*fMaker, evt);
-                       displayEvent->enableEvent(*fMaker);
-               }
-       }
+    if (evt.isType(SK_EventType_OnEnd)) {
+        SkEventState eventState;
+        bool success = evt.findPtr("anim", (void**) &eventState.fDisplayable);
+        SkASSERT(success);
+        success = evt.findS32("time", (int32_t*) &fMaker->fEnableTime);
+        SkASSERT(success);
+        fMaker->fAdjustedStart = fMaker->getAppTime() - fMaker->fEnableTime;
+        fMaker->fEvents.doEvent(*fMaker, SkDisplayEvent::kOnEnd, &eventState);
+        fMaker->fAdjustedStart = 0;
+        goto inval;
+    }
+    if (evt.isType(SK_EventType_Delay)) {
+        fMaker->doDelayedEvent();
+        goto inval;
+    }
+    {
+        const char* id = evt.findString("id");
+        if (id == nil)
+            return false;
+        SkDisplayable** firstMovie = fMaker->fMovies.begin();
+        SkDisplayable** endMovie = fMaker->fMovies.end();
+        for (SkDisplayable** ptr = firstMovie; ptr < endMovie; ptr++) {
+            SkDisplayMovie* movie = (SkDisplayMovie*) *ptr;
+            movie->doEvent(evt);
+        }
+        {
+            SkDisplayable* event;
+            if (fMaker->find(id, &event) == false)
+                return false;
+    #if defined SK_DEBUG && defined SK_DEBUG_ANIMATION_TIMING
+            SkString debugOut;
+            SkMSec realTime = fMaker->getAppTime();
+            debugOut.appendS32(realTime - fMaker->fDebugTimeBase);
+            debugOut.append(" onEvent id=");
+            debugOut.append(id);
+    #endif
+            SkMSec time = evt.getFast32();
+            if (time != 0) {
+                SkMSec app  = fMaker->getAppTime();
+                fMaker->setEnableTime(app, time);
+    #if defined SK_DEBUG && defined SK_DEBUG_ANIMATION_TIMING
+                debugOut.append(" time=");
+                debugOut.appendS32(time - fMaker->fDebugTimeBase);
+                debugOut.append(" adjust=");
+                debugOut.appendS32(fMaker->fAdjustedStart);
+    #endif
+            }
+    #if defined SK_DEBUG && defined SK_DEBUG_ANIMATION_TIMING
+            SkDebugf("%s\n", debugOut.c_str());
+    #endif
+            SkASSERT(event->isEvent());
+            SkDisplayEvent* displayEvent = (SkDisplayEvent*) event;
+            displayEvent->populateInput(*fMaker, evt);
+            displayEvent->enableEvent(*fMaker);
+        }
+    }
 inval:
-       fMaker->notifyInval();
-       return true;
+    fMaker->notifyInval();
+    return true;
 }
 
 void SkAnimator::onEventPost(SkEvent* evt, SkEventSinkID sinkID)
 {
 #ifdef SK_DEBUG
-       SkAnimator* root = fMaker->getRoot();
-       if (root) {
-               root->onEventPost(evt, sinkID);
-               return;
-       }
+    SkAnimator* root = fMaker->getRoot();
+    if (root) {
+        root->onEventPost(evt, sinkID);
+        return;
+    }
 #else
-       SkASSERT(sinkID == this->getSinkID() || this->getHostEventSinkID() == sinkID);
+    SkASSERT(sinkID == this->getSinkID() || this->getHostEventSinkID() == sinkID);
 #endif
-       SkEvent::Post(evt, sinkID);
+    SkEvent::Post(evt, sinkID);
 }
 
 void SkAnimator::onEventPostTime(SkEvent* evt, SkEventSinkID sinkID, SkMSec time)
 {
 #ifdef SK_DEBUG
-       SkAnimator* root = fMaker->getRoot();
-       if (root) {
-               root->onEventPostTime(evt, sinkID, time);
-               return;
-       }
+    SkAnimator* root = fMaker->getRoot();
+    if (root) {
+        root->onEventPostTime(evt, sinkID, time);
+        return;
+    }
 #else
-       SkASSERT(sinkID == this->getSinkID() || this->getHostEventSinkID() == sinkID);
+    SkASSERT(sinkID == this->getSinkID() || this->getHostEventSinkID() == sinkID);
 #endif
-       SkEvent::PostTime(evt, sinkID, time);
+    SkEvent::PostTime(evt, sinkID, time);
 }
 
 void SkAnimator::reset() {
-       fMaker->fDisplayList.reset();
+    fMaker->fDisplayList.reset();
 }
 
 SkEventSinkID SkAnimator::getHostEventSinkID() const {
-       return fMaker->fHostEventSinkID; 
+    return fMaker->fHostEventSinkID; 
 }
 
 void SkAnimator::setHostEventSinkID(SkEventSinkID target) {
-       fMaker->fHostEventSinkID = target; 
+    fMaker->fHostEventSinkID = target; 
 }
 
 void SkAnimator::onSetHostHandler(Handler ) {
@@ -565,102 +582,102 @@ bool SkAnimator::setArray(const char* id, const char* fieldID, SkTypedArray arra
 }
 
 bool SkAnimator::setInt(SkDisplayable* element, const SkMemberInfo* info, int32_t s32) {
-       if (info->fType != SkType_MemberProperty) {
-               SkOperand operand;
-               operand.fS32 = s32;
-               SkASSERT(info->getType() == SkType_Int);
-               info->setValue(element, &operand, 1);
-       } else {
-               SkScriptValue scriptValue;
-               scriptValue.fType = SkType_Int;
-               scriptValue.fOperand.fS32 = s32;
-               element->setProperty(info->propertyIndex(), scriptValue);
-       }
-       return true;
+    if (info->fType != SkType_MemberProperty) {
+        SkOperand operand;
+        operand.fS32 = s32;
+        SkASSERT(info->getType() == SkType_Int);
+        info->setValue(element, &operand, 1);
+    } else {
+        SkScriptValue scriptValue;
+        scriptValue.fType = SkType_Int;
+        scriptValue.fOperand.fS32 = s32;
+        element->setProperty(info->propertyIndex(), scriptValue);
+    }
+    return true;
 }
 
 bool SkAnimator::setInt(const char* id, const char* fieldID, int32_t s32) {
-       SkDisplayable* element = (SkDisplayable*) getElement(id);
-       if (element == nil)
-               return false;
-       const SkMemberInfo* field = getField(element, fieldID);
-       if (field == nil)
-               return false;
-       return setInt(element, field, s32);
+    SkDisplayable* element = (SkDisplayable*) getElement(id);
+    if (element == nil)
+        return false;
+    const SkMemberInfo* field = getField(element, fieldID);
+    if (field == nil)
+        return false;
+    return setInt(element, field, s32);
 }
 
 bool SkAnimator::setScalar(SkDisplayable* element, const SkMemberInfo* info, SkScalar scalar) {
-       if (info->fType != SkType_MemberProperty) {
-               SkOperand operand;
-               operand.fScalar = scalar;
-               SkASSERT(info->getType() == SkType_Float);
-               info->setValue(element, &operand, 1);
-       } else {
-               SkScriptValue scriptValue;
-               scriptValue.fType = SkType_Float;
-               scriptValue.fOperand.fScalar = scalar;
-               element->setProperty(info->propertyIndex(), scriptValue);
-       }
-       return true;
+    if (info->fType != SkType_MemberProperty) {
+        SkOperand operand;
+        operand.fScalar = scalar;
+        SkASSERT(info->getType() == SkType_Float);
+        info->setValue(element, &operand, 1);
+    } else {
+        SkScriptValue scriptValue;
+        scriptValue.fType = SkType_Float;
+        scriptValue.fOperand.fScalar = scalar;
+        element->setProperty(info->propertyIndex(), scriptValue);
+    }
+    return true;
 }
 
 bool SkAnimator::setScalar(const char* id, const char* fieldID, SkScalar scalar) {
-       SkDisplayable* element = (SkDisplayable*) getElement(id);
-       if (element == nil)
-               return false;
-       const SkMemberInfo* field = getField(element, fieldID);
-       if (field == nil)
-               return false;
-       return setScalar(element, field, scalar);
+    SkDisplayable* element = (SkDisplayable*) getElement(id);
+    if (element == nil)
+        return false;
+    const SkMemberInfo* field = getField(element, fieldID);
+    if (field == nil)
+        return false;
+    return setScalar(element, field, scalar);
 }
 
 bool SkAnimator::setString(SkDisplayable* element, 
-               const SkMemberInfo* info, const char* str) {
-       // !!! until this is fixed, can't call script with global references from here 
-       info->setValue(*fMaker, nil, 0, info->fCount, element, info->getType(), str, strlen(str));
-       return true;
+        const SkMemberInfo* info, const char* str) {
+    // !!! until this is fixed, can't call script with global references from here 
+    info->setValue(*fMaker, nil, 0, info->fCount, element, info->getType(), str, strlen(str));
+    return true;
 }
 
 bool SkAnimator::setString(const char* id, const char* fieldID, const char* str) {
-       SkDisplayable* element = (SkDisplayable*) getElement(id);
-       if (element == nil)
-               return false;
-       const SkMemberInfo* field = getField(element, fieldID);
-       if (field == nil)
-               return false;
-       return setString(element, field, str);
+    SkDisplayable* element = (SkDisplayable*) getElement(id);
+    if (element == nil)
+        return false;
+    const SkMemberInfo* field = getField(element, fieldID);
+    if (field == nil)
+        return false;
+    return setString(element, field, str);
 }
 
 void SkAnimator::setTimeline(const Timeline& timeline) {
-       fMaker->fTimeline = &timeline;
+    fMaker->fTimeline = &timeline;
 }
 
 void SkAnimator::setURIBase(const char* uri) {
-       if (uri)
-       {
-               const char* tail = strrchr(uri, '/');
-               if (tail) {
-                       SkString prefix(uri, tail - uri + 1);
-                       if (SkStream::IsAbsoluteURI(uri))
-                               fMaker->fPrefix.reset();
-                       fMaker->fPrefix.append(prefix);
-                       fMaker->fFileName.set(tail + 1);
-               } else
-                       fMaker->fFileName.set(uri);
-       }
+    if (uri)
+    {
+        const char* tail = strrchr(uri, '/');
+        if (tail) {
+            SkString prefix(uri, tail - uri + 1);
+            if (SkStream::IsAbsoluteURI(uri))
+                fMaker->fPrefix.reset();
+            fMaker->fPrefix.append(prefix);
+            fMaker->fFileName.set(tail + 1);
+        } else
+            fMaker->fFileName.set(uri);
+    }
 }
 
 #ifdef SK_DEBUG
 bool SkAnimator::NoLeaks() {
 #ifdef SK_BUILD_FOR_MAC
-       if (SkDisplayable::fAllocations.count() == 0)
-               return true;
-//     return SkDisplayable::fAllocationCount == 0;
-       SkDebugf("!!! leaked %d displayables:\n", SkDisplayable::fAllocations.count());
-       for (SkDisplayable** leak = SkDisplayable::fAllocations.begin(); leak < SkDisplayable::fAllocations.end(); leak++)
-               SkDebugf("%08x %s\n", *leak, (*leak)->id);
+    if (SkDisplayable::fAllocations.count() == 0)
+        return true;
+//  return SkDisplayable::fAllocationCount == 0;
+    SkDebugf("!!! leaked %d displayables:\n", SkDisplayable::fAllocations.count());
+    for (SkDisplayable** leak = SkDisplayable::fAllocations.begin(); leak < SkDisplayable::fAllocations.end(); leak++)
+        SkDebugf("%08x %s\n", *leak, (*leak)->id);
 #endif
-       return false;
+    return false;
 }
 #endif
 
@@ -670,31 +687,31 @@ bool SkAnimator::NoLeaks() {
 #include "SkParse.h"
 #include "SkMemberInfo.h"
 
-#define unittestline(type)     { #type , type::UnitTest }
+#define unittestline(type)  { #type , type::UnitTest }
 #endif
 
 
 void SkAnimator::Init(bool runUnitTests) {
 #ifdef SK_SUPPORT_UNITTEST
-       if (runUnitTests == false)
-               return;
-       static const struct {
-               const char*     fTypeName;
-               void (*fUnitTest)( );
-       } gUnitTests[] = {
-               unittestline(SkBase64),
-               unittestline(SkDisplayType),
-               unittestline(SkParse),
-               unittestline(SkScriptEngine),
-//             unittestline(SkScriptEngine2),  // compiled script experiment
-               unittestline(SkAnimatorScript)
-       };
-       for (int i = 0; i < (int)SK_ARRAY_COUNT(gUnitTests); i++)
-       {
-               SkDebugf("SkAnimator: Running UnitTest for %s\n", gUnitTests[i].fTypeName);
-               gUnitTests[i].fUnitTest();
-               SkDebugf("SkAnimator: End UnitTest for %s\n", gUnitTests[i].fTypeName);
-       }
+    if (runUnitTests == false)
+        return;
+    static const struct {
+        const char* fTypeName;
+        void (*fUnitTest)( );
+    } gUnitTests[] = {
+        unittestline(SkBase64),
+        unittestline(SkDisplayType),
+        unittestline(SkParse),
+        unittestline(SkScriptEngine),
+//      unittestline(SkScriptEngine2),  // compiled script experiment
+        unittestline(SkAnimatorScript)
+    };
+    for (int i = 0; i < (int)SK_ARRAY_COUNT(gUnitTests); i++)
+    {
+        SkDebugf("SkAnimator: Running UnitTest for %s\n", gUnitTests[i].fTypeName);
+        gUnitTests[i].fUnitTest();
+        SkDebugf("SkAnimator: End UnitTest for %s\n", gUnitTests[i].fTypeName);
+    }
 #endif
 }
 
index cce5723..808a596 100644 (file)
@@ -1,3 +1,20 @@
+/* libs/graphics/animator/SkAnimatorScript.cpp
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #include "SkAnimatorScript.h"
 #include "SkAnimateBase.h"
 #include "SkAnimateMaker.h"
 #include "SkParse.h"
 
 static const SkDisplayEnumMap gEnumMaps[] = {
-       { SkType_AddMode, "indirect|immediate" },
-       { SkType_Align, "left|center|right" },
-       { SkType_ApplyMode, "create|immediate|once" },
-       { SkType_ApplyTransition, "normal|reverse" },
-       { SkType_BitmapEncoding, "jpeg|png" },
-       { SkType_BitmapFormat, "none|A1|A8|Index8|RGB16|RGB32" },
-       { SkType_Boolean, "false|true" },
-       { SkType_Cap, "butt|round|square" },
-       { SkType_EventCode, "none|leftSoftKey|rightSoftKey|home|back|send|end|key0|key1|key2|key3|key4|key5|key6|key7|key8|key9|star|hash|up|down|left|right|OK|volUp|volDown|camera" },
-       { SkType_EventKind, "none|keyChar|keyPress|keyPressUp|mouseDown|mouseDrag|mouseMove|mouseUp|onEnd|onLoad|user" },
-       { SkType_EventMode, "deferred|immediate" },
-       { SkType_FillType, "winding|evenOdd" },
-       { SkType_FilterType, "none|bilinear" },
+    { SkType_AddMode, "indirect|immediate" },
+    { SkType_Align, "left|center|right" },
+    { SkType_ApplyMode, "create|immediate|once" },
+    { SkType_ApplyTransition, "normal|reverse" },
+    { SkType_BitmapEncoding, "jpeg|png" },
+    { SkType_BitmapFormat, "none|A1|A8|Index8|RGB16|RGB32" },
+    { SkType_Boolean, "false|true" },
+    { SkType_Cap, "butt|round|square" },
+    { SkType_EventCode, "none|leftSoftKey|rightSoftKey|home|back|send|end|key0|key1|key2|key3|key4|key5|key6|key7|key8|key9|star|hash|up|down|left|right|OK|volUp|volDown|camera" },
+    { SkType_EventKind, "none|keyChar|keyPress|keyPressUp|mouseDown|mouseDrag|mouseMove|mouseUp|onEnd|onLoad|user" },
+    { SkType_EventMode, "deferred|immediate" },
+    { SkType_FillType, "winding|evenOdd" },
+    { SkType_FilterType, "none|bilinear" },
     { SkType_FontStyle, "normal|bold|italic|boldItalic" },
-       { SkType_FromPathMode, "normal|angle|position" },
-       { SkType_Join, "miter|round|blunt" },
-       { SkType_MaskFilterBlurStyle, "normal|solid|outer|inner" },
-       { SkType_PathDirection, "cw|ccw" },
-       { SkType_Style, "fill|stroke|strokeAndFill" },
-       { SkType_TextBoxAlign, "start|center|end" },
-       { SkType_TextBoxMode, "oneLine|lineBreak" },
-       { SkType_TileMode, "clamp|repeat|mirror" },
-       { SkType_Xfermode, "clear|src|dst|srcOver|dstOver|srcIn|dstIn|srcOut|dstOut|"
-               "srcATop|dstATop|xor|darken|lighten" },
+    { SkType_FromPathMode, "normal|angle|position" },
+    { SkType_Join, "miter|round|blunt" },
+    { SkType_MaskFilterBlurStyle, "normal|solid|outer|inner" },
+    { SkType_PathDirection, "cw|ccw" },
+    { SkType_Style, "fill|stroke|strokeAndFill" },
+    { SkType_TextBoxAlign, "start|center|end" },
+    { SkType_TextBoxMode, "oneLine|lineBreak" },
+    { SkType_TileMode, "clamp|repeat|mirror" },
+    { SkType_Xfermode, "clear|src|dst|srcOver|dstOver|srcIn|dstIn|srcOut|dstOut|"
+        "srcATop|dstATop|xor|darken|lighten" },
 };
 
 static int gEnumMapCount = SK_ARRAY_COUNT(gEnumMaps);
@@ -38,433 +55,433 @@ static int gEnumMapCount = SK_ARRAY_COUNT(gEnumMaps);
 SkAnimatorScript::SkAnimatorScript(SkAnimateMaker& maker, SkDisplayable* working, SkDisplayTypes type)
     : SkScriptEngine(SkScriptEngine::ToOpType(type)), fMaker(maker), fParent(NULL), fWorking(working)
 {
-       memberCallBack(EvalMember, (void*) this);
-       memberFunctionCallBack(EvalMemberFunction, (void*) this);
-       boxCallBack(Box, (void*) this);
-       unboxCallBack(Unbox, (void*) &maker);
-       propertyCallBack(EvalID, (void*) this); // must be first (entries are prepended, will be last), since it never fails
-       propertyCallBack(Infinity, (void*) this);
-       propertyCallBack(NaN, (void*) this);
-       functionCallBack(Eval, (void*) this);
-       functionCallBack(IsFinite, (void*) this);
-       functionCallBack(IsNaN, (void*) this);
-       if (type == SkType_ARGB) {
-               functionCallBack(EvalRGB, (void*) this);
-               propertyCallBack(EvalNamedColor, (void*) &maker.fIDs);
-       }
-       if (SkDisplayType::IsEnum(&maker, type)) {
-               // !!! for SpiderMonkey, iterate through the enum values, and map them to globals
-               const SkDisplayEnumMap& map = GetEnumValues(type);
-               propertyCallBack(EvalEnum, (void*) map.fValues); 
-       
-       for (SkExtras** extraPtr = maker.fExtras.begin(); extraPtr < maker.fExtras.end(); extraPtr++) {
-               SkExtras* extra = *extraPtr;
-               if (extra->fExtraCallBack)
-                       propertyCallBack(extra->fExtraCallBack, extra->fExtraStorage);
-       }
+    memberCallBack(EvalMember, (void*) this);
+    memberFunctionCallBack(EvalMemberFunction, (void*) this);
+    boxCallBack(Box, (void*) this);
+    unboxCallBack(Unbox, (void*) &maker);
+    propertyCallBack(EvalID, (void*) this); // must be first (entries are prepended, will be last), since it never fails
+    propertyCallBack(Infinity, (void*) this);
+    propertyCallBack(NaN, (void*) this);
+    functionCallBack(Eval, (void*) this);
+    functionCallBack(IsFinite, (void*) this);
+    functionCallBack(IsNaN, (void*) this);
+    if (type == SkType_ARGB) {
+        functionCallBack(EvalRGB, (void*) this);
+        propertyCallBack(EvalNamedColor, (void*) &maker.fIDs);
+    }
+    if (SkDisplayType::IsEnum(&maker, type)) {
+        // !!! for SpiderMonkey, iterate through the enum values, and map them to globals
+        const SkDisplayEnumMap& map = GetEnumValues(type);
+        propertyCallBack(EvalEnum, (void*) map.fValues); 
+    } 
+    for (SkExtras** extraPtr = maker.fExtras.begin(); extraPtr < maker.fExtras.end(); extraPtr++) {
+        SkExtras* extra = *extraPtr;
+        if (extra->fExtraCallBack)
+            propertyCallBack(extra->fExtraCallBack, extra->fExtraStorage);
+    }
 }
 
 SkAnimatorScript::~SkAnimatorScript() {
-       for (SkDisplayable** dispPtr = fTrackDisplayable.begin(); dispPtr < fTrackDisplayable.end(); dispPtr++)
-               delete *dispPtr;
+    for (SkDisplayable** dispPtr = fTrackDisplayable.begin(); dispPtr < fTrackDisplayable.end(); dispPtr++)
+        delete *dispPtr;
 }
 
 bool SkAnimatorScript::evaluate(const char* original, SkScriptValue* result, SkDisplayTypes type) {
-               const char* script = original;
-               bool success = evaluateScript(&script, result);
-               if (success == false || result->fType != type) {
-                       fMaker.setScriptError(*this);
-                       return false;
-               }
-               return true;
+        const char* script = original;
+        bool success = evaluateScript(&script, result);
+        if (success == false || result->fType != type) {
+            fMaker.setScriptError(*this);
+            return false;
+        }
+        return true;
 }
 
 bool SkAnimatorScript::Box(void* user, SkScriptValue* scriptValue) {
-       SkAnimatorScript* engine = (SkAnimatorScript*) user;
-       SkDisplayTypes type = scriptValue->fType;
-       SkDisplayable* displayable;
-       switch (type) {
-               case SkType_Array: {
-                       SkDisplayArray* boxedValue = new SkDisplayArray(*scriptValue->fOperand.fArray);
-                       displayable = boxedValue;
-                       } break;
-               case SkType_Boolean: {
-                       SkDisplayBoolean* boxedValue = new SkDisplayBoolean;
-                       displayable = boxedValue;
-                       boxedValue->value = !! scriptValue->fOperand.fS32;
-                       } break;
-               case SkType_Int: {
-                       SkDisplayInt* boxedValue = new SkDisplayInt;
-                       displayable = boxedValue;
-                       boxedValue->value = scriptValue->fOperand.fS32;
-                       } break;
-               case SkType_Float: {
-                       SkDisplayFloat* boxedValue = new SkDisplayFloat;
-                       displayable = boxedValue;
-                       boxedValue->value = scriptValue->fOperand.fScalar;
-                       } break;
-               case SkType_String: {
-                       SkDisplayString* boxedValue = new SkDisplayString(*scriptValue->fOperand.fString);
-                       displayable = boxedValue;
-                       } break;
-               case SkType_Displayable: 
-                       scriptValue->fOperand.fObject = scriptValue->fOperand.fDisplayable;
-                       scriptValue->fType = SkType_Displayable;
-                       return true;
-               default:
-                       SkASSERT(0);
-                       return false;
-       }
-       engine->track(displayable);
-       scriptValue->fOperand.fObject = displayable;
-       scriptValue->fType = SkType_Displayable;
-       return true;
+    SkAnimatorScript* engine = (SkAnimatorScript*) user;
+    SkDisplayTypes type = scriptValue->fType;
+    SkDisplayable* displayable;
+    switch (type) {
+        case SkType_Array: {
+            SkDisplayArray* boxedValue = new SkDisplayArray(*scriptValue->fOperand.fArray);
+            displayable = boxedValue;
+            } break;
+        case SkType_Boolean: {
+            SkDisplayBoolean* boxedValue = new SkDisplayBoolean;
+            displayable = boxedValue;
+            boxedValue->value = !! scriptValue->fOperand.fS32;
+            } break;
+        case SkType_Int: {
+            SkDisplayInt* boxedValue = new SkDisplayInt;
+            displayable = boxedValue;
+            boxedValue->value = scriptValue->fOperand.fS32;
+            } break;
+        case SkType_Float: {
+            SkDisplayFloat* boxedValue = new SkDisplayFloat;
+            displayable = boxedValue;
+            boxedValue->value = scriptValue->fOperand.fScalar;
+            } break;
+        case SkType_String: {
+            SkDisplayString* boxedValue = new SkDisplayString(*scriptValue->fOperand.fString);
+            displayable = boxedValue;
+            } break;
+        case SkType_Displayable: 
+            scriptValue->fOperand.fObject = scriptValue->fOperand.fDisplayable;
+            scriptValue->fType = SkType_Displayable;
+            return true;
+        default:
+            SkASSERT(0);
+            return false;
+    }
+    engine->track(displayable);
+    scriptValue->fOperand.fObject = displayable;
+    scriptValue->fType = SkType_Displayable;
+    return true;
 }
 
 bool SkAnimatorScript::Eval(const char* function, size_t len, SkTDArray<SkScriptValue>& params, 
-               void* eng, SkScriptValue* value) {
-       if (SK_LITERAL_STR_EQUAL("eval", function, len) == false)
-               return false;
-       if (params.count() != 1)
-               return false;
-       SkAnimatorScript* host = (SkAnimatorScript*) eng;
-       SkAnimatorScript engine(host->fMaker, host->fWorking, SkScriptEngine::ToDisplayType(host->fReturnType));
-       SkScriptValue* scriptValue = params.begin();
-       bool success = true;
-       if (scriptValue->fType == SkType_String) {
-               const char* script = scriptValue->fOperand.fString->c_str();
-               success = engine.evaluateScript(&script, value);
-       } else
-               *value = *scriptValue;
-       return success;
+        void* eng, SkScriptValue* value) {
+    if (SK_LITERAL_STR_EQUAL("eval", function, len) == false)
+        return false;
+    if (params.count() != 1)
+        return false;
+    SkAnimatorScript* host = (SkAnimatorScript*) eng;
+    SkAnimatorScript engine(host->fMaker, host->fWorking, SkScriptEngine::ToDisplayType(host->fReturnType));
+    SkScriptValue* scriptValue = params.begin();
+    bool success = true;
+    if (scriptValue->fType == SkType_String) {
+        const char* script = scriptValue->fOperand.fString->c_str();
+        success = engine.evaluateScript(&script, value);
+    } else
+        *value = *scriptValue;
+    return success;
 }
 
 bool SkAnimatorScript::EvalEnum(const char* token, size_t len, void* callBack, SkScriptValue* value) {
-       const char* tokens = (const char*) callBack;
-       value->fType = SkType_Int;
-       if (MapEnums(tokens, token, len, (int*)&value->fOperand.fS32))
-               return true; 
-       return false;
+    const char* tokens = (const char*) callBack;
+    value->fType = SkType_Int;
+    if (MapEnums(tokens, token, len, (int*)&value->fOperand.fS32))
+        return true; 
+    return false;
 }
 
 bool SkAnimatorScript::EvalID(const char* token, size_t len, void* user, SkScriptValue* value) {
-       SkAnimatorScript* engine = (SkAnimatorScript*) user;
-       SkTDict<SkDisplayable*>* ids = &engine->fMaker.fIDs;
-       SkDisplayable* displayable;
-       bool success = ids->find(token, len, &displayable); 
-       if (success == false) {
-               displayable = engine->fWorking;
-               if (SK_LITERAL_STR_EQUAL("parent", token, len)) {
-                       SkDisplayable* parent = displayable->getParent();
-                       if (parent == false)
-                               parent = engine->fParent;
-                       if (parent) {
-                               value->fOperand.fDisplayable = parent;
-                               value->fType = SkType_Displayable;
-                               return true;
-                       }
-               }
-               if (displayable && EvalMember(token, len, displayable, engine, value))
-                       return true;
-               value->fOperand.fString = NULL;
-               value->fType = SkType_String;   
-       } else {
-               SkDisplayable* working = engine->fWorking;
-               value->fOperand.fDisplayable = displayable;
-               value->fType = SkType_Displayable;
-               if (displayable->canContainDependents() && working && working->isAnimate()) {
-                       SkAnimateBase* animator = (SkAnimateBase*) working;
-                       if (animator->isDynamic()) {
-                               SkDisplayDepend* depend = (SkDisplayDepend* ) displayable;
-                               depend->addDependent(working);
-                       }
-               }
-       }
-       return true;
+    SkAnimatorScript* engine = (SkAnimatorScript*) user;
+    SkTDict<SkDisplayable*>* ids = &engine->fMaker.fIDs;
+    SkDisplayable* displayable;
+    bool success = ids->find(token, len, &displayable); 
+    if (success == false) {
+        displayable = engine->fWorking;
+        if (SK_LITERAL_STR_EQUAL("parent", token, len)) {
+            SkDisplayable* parent = displayable->getParent();
+            if (parent == false)
+                parent = engine->fParent;
+            if (parent) {
+                value->fOperand.fDisplayable = parent;
+                value->fType = SkType_Displayable;
+                return true;
+            }
+        }
+        if (displayable && EvalMember(token, len, displayable, engine, value))
+            return true;
+        value->fOperand.fString = NULL;
+        value->fType = SkType_String;   
+    } else {
+        SkDisplayable* working = engine->fWorking;
+        value->fOperand.fDisplayable = displayable;
+        value->fType = SkType_Displayable;
+        if (displayable->canContainDependents() && working && working->isAnimate()) {
+            SkAnimateBase* animator = (SkAnimateBase*) working;
+            if (animator->isDynamic()) {
+                SkDisplayDepend* depend = (SkDisplayDepend* ) displayable;
+                depend->addDependent(working);
+            }
+        }
+    }
+    return true;
 }
 
 bool SkAnimatorScript::EvalNamedColor(const char* token, size_t len, void* callback, SkScriptValue* value) {
-               value->fType = SkType_Int;
-       if (SkParse::FindNamedColor(token, len, (SkColor*) &value->fOperand.fS32) != NULL)
-               return true;
-       return false;
+        value->fType = SkType_Int;
+    if (SkParse::FindNamedColor(token, len, (SkColor*) &value->fOperand.fS32) != NULL)
+        return true;
+    return false;
 }
 
 bool SkAnimatorScript::EvalRGB(const char* function, size_t len, SkTDArray<SkScriptValue>& params, 
-               void* eng, SkScriptValue* value) {
-       if (SK_LITERAL_STR_EQUAL("rgb", function, len) == false)
-               return false;
-       if (params.count() != 3)
-               return false;
-       SkScriptEngine* engine = (SkScriptEngine*) eng;
-       unsigned result = 0xFF000000;
-       int shift = 16;
-       for (SkScriptValue* valuePtr = params.begin(); valuePtr < params.end(); valuePtr++) {
-               engine->convertTo(SkType_Int, valuePtr);
-               result |= SkClampMax(valuePtr->fOperand.fS32, 255) << shift;
-               shift -= 8;
-       }
-       value->fOperand.fS32 = result;
-       value->fType = SkType_Int;
-       return true;
+        void* eng, SkScriptValue* value) {
+    if (SK_LITERAL_STR_EQUAL("rgb", function, len) == false)
+        return false;
+    if (params.count() != 3)
+        return false;
+    SkScriptEngine* engine = (SkScriptEngine*) eng;
+    unsigned result = 0xFF000000;
+    int shift = 16;
+    for (SkScriptValue* valuePtr = params.begin(); valuePtr < params.end(); valuePtr++) {
+        engine->convertTo(SkType_Int, valuePtr);
+        result |= SkClampMax(valuePtr->fOperand.fS32, 255) << shift;
+        shift -= 8;
+    }
+    value->fOperand.fS32 = result;
+    value->fType = SkType_Int;
+    return true;
 }
 
 bool SkAnimatorScript::EvalMemberCommon(SkScriptEngine* engine, const SkMemberInfo* info, 
-               SkDisplayable* displayable, SkScriptValue* value) {
-       SkDisplayTypes original;
-       SkDisplayTypes type = original = (SkDisplayTypes) info->getType();
-       if (info->fType == SkType_Array)
-               type = SkType_Array;
-       switch (type) {
-               case SkType_ARGB:
-                       type = SkType_Int;
-               case SkType_Boolean:
-               case SkType_Int:
-               case SkType_MSec:
-               case SkType_Float:
-                       SkASSERT(info->getCount() == 1);
-                       if (info->fType != SkType_MemberProperty && info->fType != SkType_MemberFunction) 
-                               value->fOperand.fS32 = *(int32_t*) info->memberData(displayable);       // OK for SkScalar too
-                       if (type == SkType_MSec) {
-                               value->fOperand.fScalar = SkScalarDiv((SkScalar) value->fOperand.fS32, 1000); // dividing two ints is the same as dividing two scalars 
-                               type = SkType_Float;
-                       }
-                       break;
-               case SkType_String: {
-                       SkString* displayableString;
-                       if (info->fType != SkType_MemberProperty && info->fType != SkType_MemberFunction) {
-                               info->getString(displayable, &displayableString);
-                               value->fOperand.fString = new SkString(*displayableString);
-                       }
-                       } break;
-               case SkType_Array: {
-                       SkASSERT(info->fType != SkType_MemberProperty); // !!! incomplete
-                       SkTDOperandArray* displayableArray = (SkTDOperandArray*) info->memberData(displayable);
-                       if (displayable->getType() == SkType_Array) {
-                               SkDisplayArray* typedArray = (SkDisplayArray*) displayable;
-                               original = typedArray->values.getType();
-                       }
-                       SkASSERT(original != SkType_Unknown);
-                       SkTypedArray* array = value->fOperand.fArray = new SkTypedArray(original);
-                       engine->track(array);
-                       int count = displayableArray->count();
-                       if (count > 0) {
-                               array->setCount(count);
-                               memcpy(array->begin(), displayableArray->begin(), count * sizeof(SkOperand));
-                       }
-                       } break;
-               default:
-                       SkASSERT(0); // unimplemented
-       }
-       value->fType = type;
-       return true;
+        SkDisplayable* displayable, SkScriptValue* value) {
+    SkDisplayTypes original;
+    SkDisplayTypes type = original = (SkDisplayTypes) info->getType();
+    if (info->fType == SkType_Array)
+        type = SkType_Array;
+    switch (type) {
+        case SkType_ARGB:
+            type = SkType_Int;
+        case SkType_Boolean:
+        case SkType_Int:
+        case SkType_MSec:
+        case SkType_Float:
+            SkASSERT(info->getCount() == 1);
+            if (info->fType != SkType_MemberProperty && info->fType != SkType_MemberFunction) 
+                value->fOperand.fS32 = *(int32_t*) info->memberData(displayable);   // OK for SkScalar too
+            if (type == SkType_MSec) {
+                value->fOperand.fScalar = SkScalarDiv((SkScalar) value->fOperand.fS32, 1000); // dividing two ints is the same as dividing two scalars 
+                type = SkType_Float;
+            }
+            break;
+        case SkType_String: {
+            SkString* displayableString;
+            if (info->fType != SkType_MemberProperty && info->fType != SkType_MemberFunction) {
+                info->getString(displayable, &displayableString);
+                value->fOperand.fString = new SkString(*displayableString);
+            }
+            } break;
+        case SkType_Array: {
+            SkASSERT(info->fType != SkType_MemberProperty); // !!! incomplete
+            SkTDOperandArray* displayableArray = (SkTDOperandArray*) info->memberData(displayable);
+            if (displayable->getType() == SkType_Array) {
+                SkDisplayArray* typedArray = (SkDisplayArray*) displayable;
+                original = typedArray->values.getType();
+            }
+            SkASSERT(original != SkType_Unknown);
+            SkTypedArray* array = value->fOperand.fArray = new SkTypedArray(original);
+            engine->track(array);
+            int count = displayableArray->count();
+            if (count > 0) {
+                array->setCount(count);
+                memcpy(array->begin(), displayableArray->begin(), count * sizeof(SkOperand));
+            }
+            } break;
+        default:
+            SkASSERT(0); // unimplemented
+    }
+    value->fType = type;
+    return true;
 }
 
 bool SkAnimatorScript::EvalMember(const char* member, size_t len, void* object, void* eng, 
-               SkScriptValue* value) {
-       SkScriptEngine* engine = (SkScriptEngine*) eng;
-       SkDisplayable* displayable = (SkDisplayable*) object;
-       SkString name(member, len);
-       SkDisplayable* named = displayable->contains(name);
-       if (named) {
-               value->fOperand.fDisplayable = named;
-               value->fType = SkType_Displayable;
-               return true;
-       }
-       const SkMemberInfo* info = displayable->getMember(name.c_str());
-       if (info == NULL)
-               return false;
-       if (info->fType == SkType_MemberProperty) {
-               if (displayable->getProperty(info->propertyIndex(), value) == false) {
-                       SkASSERT(0);
-                       return false;
-               }
-       }
-       return EvalMemberCommon(engine, info, displayable, value);
+        SkScriptValue* value) {
+    SkScriptEngine* engine = (SkScriptEngine*) eng;
+    SkDisplayable* displayable = (SkDisplayable*) object;
+    SkString name(member, len);
+    SkDisplayable* named = displayable->contains(name);
+    if (named) {
+        value->fOperand.fDisplayable = named;
+        value->fType = SkType_Displayable;
+        return true;
+    }
+    const SkMemberInfo* info = displayable->getMember(name.c_str());
+    if (info == NULL)
+        return false;
+    if (info->fType == SkType_MemberProperty) {
+        if (displayable->getProperty(info->propertyIndex(), value) == false) {
+            SkASSERT(0);
+            return false;
+        }
+    }
+    return EvalMemberCommon(engine, info, displayable, value);
 }
 
 bool SkAnimatorScript::EvalMemberFunction(const char* member, size_t len, void* object, 
-               SkTDArray<SkScriptValue>& params, void* eng, SkScriptValue* value) {
-       SkScriptEngine* engine = (SkScriptEngine*) eng;
-       SkDisplayable* displayable = (SkDisplayable*) object;
-       SkString name(member, len);
-       const SkMemberInfo* info = displayable->getMember(name.c_str());
-       SkASSERT(info != NULL); /* !!! error handling unimplemented */
-       if (info->fType != SkType_MemberFunction) {
-               SkASSERT(0);
-               return false;
-       }
-       displayable->executeFunction(displayable, info->functionIndex(), params, info->getType(), 
-               value);
-       return EvalMemberCommon(engine, info, displayable, value);
+        SkTDArray<SkScriptValue>& params, void* eng, SkScriptValue* value) {
+    SkScriptEngine* engine = (SkScriptEngine*) eng;
+    SkDisplayable* displayable = (SkDisplayable*) object;
+    SkString name(member, len);
+    const SkMemberInfo* info = displayable->getMember(name.c_str());
+    SkASSERT(info != NULL); /* !!! error handling unimplemented */
+    if (info->fType != SkType_MemberFunction) {
+        SkASSERT(0);
+        return false;
+    }
+    displayable->executeFunction(displayable, info->functionIndex(), params, info->getType(), 
+        value);
+    return EvalMemberCommon(engine, info, displayable, value);
 }
 
 bool SkAnimatorScript::EvaluateDisplayable(SkAnimateMaker& maker, SkDisplayable* displayable, const char* script, SkDisplayable** result) {
-       SkAnimatorScript engine(maker, displayable, SkType_Displayable);
-       SkScriptValue value;
-       bool success = engine.evaluate(script, &value, SkType_Displayable);
-       if (success)
-               *result = value.fOperand.fDisplayable;
-       return success;
+    SkAnimatorScript engine(maker, displayable, SkType_Displayable);
+    SkScriptValue value;
+    bool success = engine.evaluate(script, &value, SkType_Displayable);
+    if (success)
+        *result = value.fOperand.fDisplayable;
+    return success;
 }
 
 bool SkAnimatorScript::EvaluateInt(SkAnimateMaker& maker, SkDisplayable* displayable, const char* script, int32_t* result) {
-       SkAnimatorScript engine(maker, displayable, SkType_Int);
-       SkScriptValue value;
-       bool success = engine.evaluate(script, &value, SkType_Int);
-       if (success)
-               *result = value.fOperand.fS32;
-       return success;
+    SkAnimatorScript engine(maker, displayable, SkType_Int);
+    SkScriptValue value;
+    bool success = engine.evaluate(script, &value, SkType_Int);
+    if (success)
+        *result = value.fOperand.fS32;
+    return success;
 }
 
 bool SkAnimatorScript::EvaluateFloat(SkAnimateMaker& maker, SkDisplayable* displayable, const char* script, SkScalar* result) {
-       SkAnimatorScript engine(maker, displayable, SkType_Float);
-       SkScriptValue value;
-       bool success = engine.evaluate(script, &value, SkType_Float);
-       if (success)
-               *result = value.fOperand.fScalar;
-       return success;
+    SkAnimatorScript engine(maker, displayable, SkType_Float);
+    SkScriptValue value;
+    bool success = engine.evaluate(script, &value, SkType_Float);
+    if (success)
+        *result = value.fOperand.fScalar;
+    return success;
 }
 
 bool SkAnimatorScript::EvaluateString(SkAnimateMaker& maker, SkDisplayable* displayable, const char* script, SkString* result) {
-       SkAnimatorScript engine(maker, displayable, SkType_String);
-       SkScriptValue value;
-       bool success = engine.evaluate(script, &value, SkType_String);
-       if (success)
-               result->set(*(value.fOperand.fString));
+    SkAnimatorScript engine(maker, displayable, SkType_String);
+    SkScriptValue value;
+    bool success = engine.evaluate(script, &value, SkType_String);
+    if (success)
+        result->set(*(value.fOperand.fString));
   return success;
 }
 
 bool SkAnimatorScript::EvaluateString(SkAnimateMaker& maker, SkDisplayable* displayable, SkDisplayable* parent, const char* script, SkString* result) {
-       SkAnimatorScript engine(maker, displayable, SkType_String);
-       engine.fParent = parent;
-       SkScriptValue value;
-       bool success = engine.evaluate(script, &value, SkType_String);
-       if (success)
-               result->set(*(value.fOperand.fString));
+    SkAnimatorScript engine(maker, displayable, SkType_String);
+    engine.fParent = parent;
+    SkScriptValue value;
+    bool success = engine.evaluate(script, &value, SkType_String);
+    if (success)
+        result->set(*(value.fOperand.fString));
   return success;
 }
 
 const SkDisplayEnumMap& SkAnimatorScript::GetEnumValues(SkDisplayTypes type) {
-       int index = SkTSearch<SkDisplayTypes>(&gEnumMaps[0].fType, gEnumMapCount, type, 
-               sizeof(SkDisplayEnumMap));
-       SkASSERT(index >= 0);
-       return gEnumMaps[index];
+    int index = SkTSearch<SkDisplayTypes>(&gEnumMaps[0].fType, gEnumMapCount, type, 
+        sizeof(SkDisplayEnumMap));
+    SkASSERT(index >= 0);
+    return gEnumMaps[index];
 }
 
 bool SkAnimatorScript::Infinity(const char* token, size_t len, void* user, SkScriptValue* value) {
-       if (SK_LITERAL_STR_EQUAL("Infinity", token, len) == false)
-               return false;
-       value->fType = SkType_Float;
-       value->fOperand.fScalar = SK_ScalarInfinity;
-       return true;
+    if (SK_LITERAL_STR_EQUAL("Infinity", token, len) == false)
+        return false;
+    value->fType = SkType_Float;
+    value->fOperand.fScalar = SK_ScalarInfinity;
+    return true;
 }
 
 bool SkAnimatorScript::IsFinite(const char* function, size_t len, SkTDArray<SkScriptValue>& params, 
-               void* eng, SkScriptValue* value) {
-       if (SK_LITERAL_STR_EQUAL(function, "isFinite", len) == false)
-               return false;
-       if (params.count() != 1)
-               return false;
-       SkScriptValue* scriptValue = params.begin();
-       SkDisplayTypes type = scriptValue->fType;
-       SkScalar scalar = scriptValue->fOperand.fScalar;
-       value->fType = SkType_Int;
-       value->fOperand.fS32 = type == SkType_Float ? SkScalarIsNaN(scalar) == false && 
-               SkScalarAbs(scalar) != SK_ScalarInfinity        : type == SkType_Int;
-       return true;
+        void* eng, SkScriptValue* value) {
+    if (SK_LITERAL_STR_EQUAL(function, "isFinite", len) == false)
+        return false;
+    if (params.count() != 1)
+        return false;
+    SkScriptValue* scriptValue = params.begin();
+    SkDisplayTypes type = scriptValue->fType;
+    SkScalar scalar = scriptValue->fOperand.fScalar;
+    value->fType = SkType_Int;
+    value->fOperand.fS32 = type == SkType_Float ? SkScalarIsNaN(scalar) == false && 
+        SkScalarAbs(scalar) != SK_ScalarInfinity    : type == SkType_Int;
+    return true;
 }
 
 bool SkAnimatorScript::IsNaN(const char* function, size_t len, SkTDArray<SkScriptValue>& params, 
-               void* eng, SkScriptValue* value) {
-       if (SK_LITERAL_STR_EQUAL("isNaN", function, len) == false)
-               return false;
-       if (params.count() != 1)
-               return false;
-       SkScriptValue* scriptValue = params.begin();
-       value->fType = SkType_Int;
-       value->fOperand.fS32 = scriptValue->fType == SkType_Float ? SkScalarIsNaN(scriptValue->fOperand.fScalar) : 0;
-       return true;
+        void* eng, SkScriptValue* value) {
+    if (SK_LITERAL_STR_EQUAL("isNaN", function, len) == false)
+        return false;
+    if (params.count() != 1)
+        return false;
+    SkScriptValue* scriptValue = params.begin();
+    value->fType = SkType_Int;
+    value->fOperand.fS32 = scriptValue->fType == SkType_Float ? SkScalarIsNaN(scriptValue->fOperand.fScalar) : 0;
+    return true;
 }
 
 bool SkAnimatorScript::MapEnums(const char* ptr, const char* match, size_t len, int* value) {
-       int index = 0;
-       bool more = true;
-       do {
-               const char* last = strchr(ptr, '|');
-               if (last == NULL) {
-                       last = &ptr[strlen(ptr)];
-                       more = false;
-               }
-               size_t length = last - ptr;
-               if (len == length && strncmp(ptr, match, length) == 0) {
-                       *value = index;
-                       return true;
-               }
-               index++;
-               ptr = last + 1;
-       } while (more);
-       return false;
+    int index = 0;
+    bool more = true;
+    do {
+        const char* last = strchr(ptr, '|');
+        if (last == NULL) {
+            last = &ptr[strlen(ptr)];
+            more = false;
+        }
+        size_t length = last - ptr;
+        if (len == length && strncmp(ptr, match, length) == 0) {
+            *value = index;
+            return true;
+        }
+        index++;
+        ptr = last + 1;
+    } while (more);
+    return false;
 }
 
 bool SkAnimatorScript::NaN(const char* token, size_t len, void* user, SkScriptValue* value) {
-       if (SK_LITERAL_STR_EQUAL("NaN", token, len) == false)
-               return false;
-       value->fType = SkType_Float;
-       value->fOperand.fScalar = SK_ScalarNaN;
-       return true;
+    if (SK_LITERAL_STR_EQUAL("NaN", token, len) == false)
+        return false;
+    value->fType = SkType_Float;
+    value->fOperand.fScalar = SK_ScalarNaN;
+    return true;
 }
 
 #if 0
 bool SkAnimatorScript::ObjectToString(void* object, void* user, SkScriptValue* value) {
-       SkTDict<SkDisplayable*>* ids = (SkTDict<SkDisplayable*>*) user;
-       SkDisplayable* displayable = (SkDisplayable*) object;
-       const char* key;
-       bool success = ids->findKey(displayable, &key); 
-       if (success == false)
-               return false;
-       value->fOperand.fString =       new SkString(key);
-       value->fType = SkType_String;
-       return true;
+    SkTDict<SkDisplayable*>* ids = (SkTDict<SkDisplayable*>*) user;
+    SkDisplayable* displayable = (SkDisplayable*) object;
+    const char* key;
+    bool success = ids->findKey(displayable, &key); 
+    if (success == false)
+        return false;
+    value->fOperand.fString =   new SkString(key);
+    value->fType = SkType_String;
+    return true;
 }
 #endif
 
 bool SkAnimatorScript::Unbox(void* m, SkScriptValue* scriptValue) {
-       SkAnimateMaker* maker = (SkAnimateMaker*) m;
-       SkASSERT((unsigned) scriptValue->fType == (unsigned) SkType_Displayable);
-       SkDisplayable* displayable = (SkDisplayable*) scriptValue->fOperand.fObject;
-       SkDisplayTypes type = displayable->getType();
-       switch (displayable->getType()) {
-               case SkType_Array: {
-                       SkDisplayArray* boxedValue = (SkDisplayArray*) displayable;
-                       scriptValue->fOperand.fArray = &boxedValue->values;
-                       } break;
-               case SkType_Boolean: {
-                       SkDisplayBoolean* boxedValue = (SkDisplayBoolean*) displayable;
-                       scriptValue->fOperand.fS32 = boxedValue->value;
-                       } break;
-               case SkType_Int: {
-                       SkDisplayInt* boxedValue = (SkDisplayInt*) displayable;
-                       scriptValue->fOperand.fS32 = boxedValue->value;
-                       } break;
-               case SkType_Float: {
-                       SkDisplayFloat* boxedValue = (SkDisplayFloat*) displayable;
-                       scriptValue->fOperand.fScalar = boxedValue->value;
-                       } break;
-               case SkType_String: {
-                       SkDisplayString* boxedValue = (SkDisplayString*) displayable;
-                       scriptValue->fOperand.fString = SkNEW_ARGS(SkString, (boxedValue->value));
-                       } break;
-               default: {
-                       const char* id;
-                       bool success = maker->findKey(displayable, &id);
-                       SkASSERT(success);
-                       scriptValue->fOperand.fString = SkNEW_ARGS(SkString, (id));
-                       type = SkType_String;
-               }
-       }
-       scriptValue->fType = type;
-       return true;
+    SkAnimateMaker* maker = (SkAnimateMaker*) m;
+    SkASSERT((unsigned) scriptValue->fType == (unsigned) SkType_Displayable);
+    SkDisplayable* displayable = (SkDisplayable*) scriptValue->fOperand.fObject;
+    SkDisplayTypes type = displayable->getType();
+    switch (displayable->getType()) {
+        case SkType_Array: {
+            SkDisplayArray* boxedValue = (SkDisplayArray*) displayable;
+            scriptValue->fOperand.fArray = &boxedValue->values;
+            } break;
+        case SkType_Boolean: {
+            SkDisplayBoolean* boxedValue = (SkDisplayBoolean*) displayable;
+            scriptValue->fOperand.fS32 = boxedValue->value;
+            } break;
+        case SkType_Int: {
+            SkDisplayInt* boxedValue = (SkDisplayInt*) displayable;
+            scriptValue->fOperand.fS32 = boxedValue->value;
+            } break;
+        case SkType_Float: {
+            SkDisplayFloat* boxedValue = (SkDisplayFloat*) displayable;
+            scriptValue->fOperand.fScalar = boxedValue->value;
+            } break;
+        case SkType_String: {
+            SkDisplayString* boxedValue = (SkDisplayString*) displayable;
+            scriptValue->fOperand.fString = SkNEW_ARGS(SkString, (boxedValue->value));
+            } break;
+        default: {
+            const char* id;
+            bool success = maker->findKey(displayable, &id);
+            SkASSERT(success);
+            scriptValue->fOperand.fString = SkNEW_ARGS(SkString, (id));
+            type = SkType_String;
+        }
+    }
+    scriptValue->fType = type;
+    return true;
 }
 
 #if defined SK_SUPPORT_UNITTEST
@@ -473,33 +490,33 @@ bool SkAnimatorScript::Unbox(void* m, SkScriptValue* scriptValue) {
 
 static const char scriptTestSetup[]  = 
 "<screenplay>\n"
-       "<text id='label' text='defg'/>\n"
-       "<add id='addLabel' use='label'/>\n"
-       "<text id='text1' text='test'/>\n"
-       "<apply scope='addLabel'>\n"
-               "<set target='label' field='text' to='#script:text1.text'/>\n"
-       "</apply>\n"
-       "<apply>\n"
-               "<paint id='labelPaint'>\n"
-                       "<emboss id='emboss' direction='[1,1,1]'  />\n"
-               "</paint>\n"
-               "<animate id='animation' field='direction' target='emboss' from='[1,1,1]' to='[-1,1,1]' dur='1'/>\n"
-               "<set lval='direction[0]' target='emboss' to='-1' />\n"
-       "</apply>\n"
-       "<color id='testColor' color='0 ? rgb(0,0,0) : rgb(255,255,255)' />\n"
-       "<color id='xColor' color='rgb(12,34,56)' />\n"
-       "<array id='emptyArray' />\n"
-       "<array id='intArray' values='[1, 4, 6]' />\n"
-       "<int id='idx' value='2' />\n"
-       "<int id='idy' value='2' />\n"
-       "<string id='alpha' value='abc' />\n"
-       "<rect id='testRect' left='Math.cos(0)' top='2' right='12' bottom='5' />\n"
-       "<event id='evt'>\n"
-               "<input name='x' />\n"
-               "<apply scope='idy'>\n"
-                       "<set field='value' to='evt.x.int' />\n"
-               "</apply>\n"
-       "</event>\n"
+    "<text id='label' text='defg'/>\n"
+    "<add id='addLabel' use='label'/>\n"
+    "<text id='text1' text='test'/>\n"
+    "<apply scope='addLabel'>\n"
+        "<set target='label' field='text' to='#script:text1.text'/>\n"
+    "</apply>\n"
+    "<apply>\n"
+        "<paint id='labelPaint'>\n"
+            "<emboss id='emboss' direction='[1,1,1]'  />\n"
+        "</paint>\n"
+        "<animate id='animation' field='direction' target='emboss' from='[1,1,1]' to='[-1,1,1]' dur='1'/>\n"
+        "<set lval='direction[0]' target='emboss' to='-1' />\n"
+    "</apply>\n"
+    "<color id='testColor' color='0 ? rgb(0,0,0) : rgb(255,255,255)' />\n"
+    "<color id='xColor' color='rgb(12,34,56)' />\n"
+    "<array id='emptyArray' />\n"
+    "<array id='intArray' values='[1, 4, 6]' />\n"
+    "<int id='idx' value='2' />\n"
+    "<int id='idy' value='2' />\n"
+    "<string id='alpha' value='abc' />\n"
+    "<rect id='testRect' left='Math.cos(0)' top='2' right='12' bottom='5' />\n"
+    "<event id='evt'>\n"
+        "<input name='x' />\n"
+        "<apply scope='idy'>\n"
+            "<set field='value' to='evt.x.int' />\n"
+        "</apply>\n"
+    "</event>\n"
 "</screenplay>";
 
 #if !defined(SK_BUILD_FOR_BREW)
@@ -507,81 +524,81 @@ static const char scriptTestSetup[]  =
 #define DEFAULT_ANSWER   , 0
 
 static const SkScriptNAnswer scriptTests[]  = {
-       { "label.text.length == 4", SkType_Int, 1 DEFAULT_ANSWER DEFAULT_ANSWER },
-//     { "labelPaint.measureText(label.text) > 0 ? labelPaint.measureText(label.text)+10 : 40", SkType_Float, 0, SkIntToScalar(0x23)  },
-       {       "Number.POSITIVE_INFINITY >= Number.MAX_VALUE ? 1 : 0", SkType_Int, 1 DEFAULT_ANSWER DEFAULT_ANSWER },
-       {       "Infinity >= Number.MAX_VALUE ? 1 : 0", SkType_Int, 1 DEFAULT_ANSWER DEFAULT_ANSWER },
-       {       "Number.NEGATIVE_INFINITY <= -Number.MAX_VALUE ? 1 : 0", SkType_Int, 1 DEFAULT_ANSWER DEFAULT_ANSWER },
-       {       "Number.MIN_VALUE > 0 ? 1 : 0", SkType_Int, 1 DEFAULT_ANSWER DEFAULT_ANSWER },
-       {       "isNaN(Number.NaN)", SkType_Int, 1 DEFAULT_ANSWER DEFAULT_ANSWER },
-       {       "isNaN(NaN)", SkType_Int, 1 DEFAULT_ANSWER DEFAULT_ANSWER },
-       {       "Math.sin(0)", SkType_Float, 0, SkIntToScalar(0) DEFAULT_ANSWER },
-       {       "alpha+alpha", SkType_String, 0, 0, "abcabc" },
-       {       "intArray[4]", SkType_Unknown DEFAULT_ANSWER DEFAULT_ANSWER DEFAULT_ANSWER },
-       {       "emptyArray[4]", SkType_Unknown DEFAULT_ANSWER DEFAULT_ANSWER DEFAULT_ANSWER },
-       {       "idx", SkType_Int, 2 DEFAULT_ANSWER DEFAULT_ANSWER },
-       {       "intArray.length", SkType_Int, 3 DEFAULT_ANSWER DEFAULT_ANSWER },
-       {       "intArray.values[0]", SkType_Int, 1 DEFAULT_ANSWER DEFAULT_ANSWER },
-       {       "intArray[0]", SkType_Int, 1 DEFAULT_ANSWER DEFAULT_ANSWER },
-       {       "idx.value", SkType_Int, 2 DEFAULT_ANSWER DEFAULT_ANSWER },
-       {       "alpha.value", SkType_String, 0, 0, "abc" },
-       {       "alpha", SkType_String, 0, 0, "abc" },
-       {       "alpha.value+alpha.value", SkType_String, 0, 0, "abcabc" },
-       {       "alpha+idx", SkType_String, 0, 0, "abc2" },
-       {       "idx+alpha", SkType_String, 0, 0, "2abc" },
-       {       "intArray[idx]", SkType_Int, 6 DEFAULT_ANSWER DEFAULT_ANSWER },
-       {       "alpha.slice(1,2)", SkType_String, 0, 0, "b" },
-       {       "alpha.value.slice(1,2)", SkType_String, 0, 0, "b" },
-       {       "testRect.left+2", SkType_Float, 0, SkIntToScalar(3) DEFAULT_ANSWER },
-       {       "0 ? Math.sin(0) : 1", SkType_Int, 1 DEFAULT_ANSWER DEFAULT_ANSWER },
-       {       "0 ? intArray[0] : 1", SkType_Int, 1 DEFAULT_ANSWER DEFAULT_ANSWER },
-       {       "0 ? intArray.values[0] : 1", SkType_Int, 1 DEFAULT_ANSWER DEFAULT_ANSWER },
-       {       "0 ? idx : 1", SkType_Int, 1 DEFAULT_ANSWER DEFAULT_ANSWER },
-       {       "0 ? idx.value : 1", SkType_Int, 1 DEFAULT_ANSWER DEFAULT_ANSWER },
-       {       "0 ? alpha.slice(1,2) : 1", SkType_Int, 1 DEFAULT_ANSWER DEFAULT_ANSWER },
-       {       "0 ? alpha.value.slice(1,2) : 1", SkType_Int, 1 DEFAULT_ANSWER DEFAULT_ANSWER },
-       { "idy", SkType_Int, 3 DEFAULT_ANSWER DEFAULT_ANSWER }
+    { "label.text.length == 4", SkType_Int, 1 DEFAULT_ANSWER DEFAULT_ANSWER },
+//  { "labelPaint.measureText(label.text) > 0 ? labelPaint.measureText(label.text)+10 : 40", SkType_Float, 0, SkIntToScalar(0x23)  },
+    {   "Number.POSITIVE_INFINITY >= Number.MAX_VALUE ? 1 : 0", SkType_Int, 1 DEFAULT_ANSWER DEFAULT_ANSWER },
+    {   "Infinity >= Number.MAX_VALUE ? 1 : 0", SkType_Int, 1 DEFAULT_ANSWER DEFAULT_ANSWER },
+    {   "Number.NEGATIVE_INFINITY <= -Number.MAX_VALUE ? 1 : 0", SkType_Int, 1 DEFAULT_ANSWER DEFAULT_ANSWER },
+    {   "Number.MIN_VALUE > 0 ? 1 : 0", SkType_Int, 1 DEFAULT_ANSWER DEFAULT_ANSWER },
+    {   "isNaN(Number.NaN)", SkType_Int, 1 DEFAULT_ANSWER DEFAULT_ANSWER },
+    {   "isNaN(NaN)", SkType_Int, 1 DEFAULT_ANSWER DEFAULT_ANSWER },
+    {   "Math.sin(0)", SkType_Float, 0, SkIntToScalar(0) DEFAULT_ANSWER },
+    {   "alpha+alpha", SkType_String, 0, 0, "abcabc" },
+    {   "intArray[4]", SkType_Unknown DEFAULT_ANSWER DEFAULT_ANSWER DEFAULT_ANSWER },
+    {   "emptyArray[4]", SkType_Unknown DEFAULT_ANSWER DEFAULT_ANSWER DEFAULT_ANSWER },
+    {   "idx", SkType_Int, 2 DEFAULT_ANSWER DEFAULT_ANSWER },
+    {   "intArray.length", SkType_Int, 3 DEFAULT_ANSWER DEFAULT_ANSWER },
+    {   "intArray.values[0]", SkType_Int, 1 DEFAULT_ANSWER DEFAULT_ANSWER },
+    {   "intArray[0]", SkType_Int, 1 DEFAULT_ANSWER DEFAULT_ANSWER },
+    {   "idx.value", SkType_Int, 2 DEFAULT_ANSWER DEFAULT_ANSWER },
+    {   "alpha.value", SkType_String, 0, 0, "abc" },
+    {   "alpha", SkType_String, 0, 0, "abc" },
+    {   "alpha.value+alpha.value", SkType_String, 0, 0, "abcabc" },
+    {   "alpha+idx", SkType_String, 0, 0, "abc2" },
+    {   "idx+alpha", SkType_String, 0, 0, "2abc" },
+    {   "intArray[idx]", SkType_Int, 6 DEFAULT_ANSWER DEFAULT_ANSWER },
+    {   "alpha.slice(1,2)", SkType_String, 0, 0, "b" },
+    {   "alpha.value.slice(1,2)", SkType_String, 0, 0, "b" },
+    {   "testRect.left+2", SkType_Float, 0, SkIntToScalar(3) DEFAULT_ANSWER },
+    {   "0 ? Math.sin(0) : 1", SkType_Int, 1 DEFAULT_ANSWER DEFAULT_ANSWER },
+    {   "0 ? intArray[0] : 1", SkType_Int, 1 DEFAULT_ANSWER DEFAULT_ANSWER },
+    {   "0 ? intArray.values[0] : 1", SkType_Int, 1 DEFAULT_ANSWER DEFAULT_ANSWER },
+    {   "0 ? idx : 1", SkType_Int, 1 DEFAULT_ANSWER DEFAULT_ANSWER },
+    {   "0 ? idx.value : 1", SkType_Int, 1 DEFAULT_ANSWER DEFAULT_ANSWER },
+    {   "0 ? alpha.slice(1,2) : 1", SkType_Int, 1 DEFAULT_ANSWER DEFAULT_ANSWER },
+    {   "0 ? alpha.value.slice(1,2) : 1", SkType_Int, 1 DEFAULT_ANSWER DEFAULT_ANSWER },
+    { "idy", SkType_Int, 3 DEFAULT_ANSWER DEFAULT_ANSWER }
 };
 #endif
 
-#define SkScriptNAnswer_testCount      SK_ARRAY_COUNT(scriptTests)
+#define SkScriptNAnswer_testCount   SK_ARRAY_COUNT(scriptTests)
 
 void SkAnimatorScript::UnitTest() {
 #if !defined(SK_BUILD_FOR_BREW) && defined(SK_SUPPORT_UNITTEST)
-       SkAnimator animator;
-       SkASSERT(animator.decodeMemory(scriptTestSetup, sizeof(scriptTestSetup)-1));
-       SkEvent evt;
-       evt.setString("id", "evt");
-       evt.setS32("x", 3);
-       animator.doUserEvent(evt);
-       // set up animator with memory script above, then run value tests
-       for (unsigned index = 0; index < SkScriptNAnswer_testCount; index++) {
-               SkAnimatorScript engine(*animator.fMaker, NULL, scriptTests[index].fType);
-               SkScriptValue value;
-               const char* script = scriptTests[index].fScript;
-               bool success = engine.evaluateScript(&script, &value);
-               if (success == false) {
-                       SkDebugf("script failed: %s\n", scriptTests[index].fScript);
-                       SkASSERT(scriptTests[index].fType == SkType_Unknown);
-                       continue;
-               }
-               SkASSERT(value.fType == scriptTests[index].fType);
-               SkScalar error;
-               switch (value.fType) {
-                       case SkType_Int:
-                               SkASSERT(value.fOperand.fS32 == scriptTests[index].fIntAnswer);
-                               break;
-                       case SkType_Float:
-                               error = SkScalarAbs(value.fOperand.fScalar - scriptTests[index].fScalarAnswer);
-                               SkASSERT(error < SK_Scalar1 / 10000);
-                               break;
-                       case SkType_String:
-                               SkASSERT(strcmp(value.fOperand.fString->c_str(), scriptTests[index].fStringAnswer) == 0);
-                               break;
-                       default:
-                               SkASSERT(0);
-               }
-       }
+    SkAnimator animator;
+    SkASSERT(animator.decodeMemory(scriptTestSetup, sizeof(scriptTestSetup)-1));
+    SkEvent evt;
+    evt.setString("id", "evt");
+    evt.setS32("x", 3);
+    animator.doUserEvent(evt);
+    // set up animator with memory script above, then run value tests
+    for (unsigned index = 0; index < SkScriptNAnswer_testCount; index++) {
+        SkAnimatorScript engine(*animator.fMaker, NULL, scriptTests[index].fType);
+        SkScriptValue value;
+        const char* script = scriptTests[index].fScript;
+        bool success = engine.evaluateScript(&script, &value);
+        if (success == false) {
+            SkDebugf("script failed: %s\n", scriptTests[index].fScript);
+            SkASSERT(scriptTests[index].fType == SkType_Unknown);
+            continue;
+        }
+        SkASSERT(value.fType == scriptTests[index].fType);
+        SkScalar error;
+        switch (value.fType) {
+            case SkType_Int:
+                SkASSERT(value.fOperand.fS32 == scriptTests[index].fIntAnswer);
+                break;
+            case SkType_Float:
+                error = SkScalarAbs(value.fOperand.fScalar - scriptTests[index].fScalarAnswer);
+                SkASSERT(error < SK_Scalar1 / 10000);
+                break;
+            case SkType_String:
+                SkASSERT(strcmp(value.fOperand.fString->c_str(), scriptTests[index].fStringAnswer) == 0);
+                break;
+            default:
+                SkASSERT(0);
+        }
+    }
 #endif
 }
 
index 2a02a2f..b3e946b 100644 (file)
@@ -1,3 +1,20 @@
+/* libs/graphics/animator/SkAnimatorScript.h
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #ifndef SkAnimatorScript_DEFINED
 #define SkAnimatorScript_DEFINED
 
@@ -9,57 +26,57 @@ class SkAnimateMaker;
 struct SkMemberInfo;
 
 struct SkDisplayEnumMap {
-       SkDisplayTypes fType;
-       const char* fValues;
+    SkDisplayTypes fType;
+    const char* fValues;
 };
 
 class SkAnimatorScript : public SkScriptEngine {
 public:
-       SkAnimatorScript(SkAnimateMaker& , SkDisplayable* , SkDisplayTypes type);
-       ~SkAnimatorScript();
-       bool evaluate(const char* script, SkScriptValue* , SkDisplayTypes type);
-       void track(SkDisplayable* displayable) { 
-               SkASSERT(fTrackDisplayable.find(displayable) < 0);  
-               *fTrackDisplayable.append() = displayable; }
-       static bool EvaluateDisplayable(SkAnimateMaker& , SkDisplayable* , const char* script, SkDisplayable** );
-       static bool EvaluateFloat(SkAnimateMaker& , SkDisplayable* , const char* script, SkScalar* );
-       static bool EvaluateInt(SkAnimateMaker& , SkDisplayable* , const char* script, int32_t* );
-       static bool EvaluateString(SkAnimateMaker& , SkDisplayable* , const char* script, SkString* );
-       static bool EvaluateString(SkAnimateMaker& , SkDisplayable* , SkDisplayable* parent, const char* script, SkString* );
-       static bool MapEnums(const char* ptr, const char* match, size_t len, int* value);
+    SkAnimatorScript(SkAnimateMaker& , SkDisplayable* , SkDisplayTypes type);
+    ~SkAnimatorScript();
+    bool evaluate(const char* script, SkScriptValue* , SkDisplayTypes type);
+    void track(SkDisplayable* displayable) { 
+        SkASSERT(fTrackDisplayable.find(displayable) < 0);  
+        *fTrackDisplayable.append() = displayable; }
+    static bool EvaluateDisplayable(SkAnimateMaker& , SkDisplayable* , const char* script, SkDisplayable** );
+    static bool EvaluateFloat(SkAnimateMaker& , SkDisplayable* , const char* script, SkScalar* );
+    static bool EvaluateInt(SkAnimateMaker& , SkDisplayable* , const char* script, int32_t* );
+    static bool EvaluateString(SkAnimateMaker& , SkDisplayable* , const char* script, SkString* );
+    static bool EvaluateString(SkAnimateMaker& , SkDisplayable* , SkDisplayable* parent, const char* script, SkString* );
+    static bool MapEnums(const char* ptr, const char* match, size_t len, int* value);
 protected:
-       static bool Box(void* user, SkScriptValue* );
-       static bool Eval(const char* function, size_t len, SkTDArray<SkScriptValue>& params, 
-               void* callBack, SkScriptValue* );
-       static bool EvalEnum(const char* token, size_t len, void* callBack, SkScriptValue* );
-       static bool EvalID(const char* token, size_t len, void* callBack, SkScriptValue* );
-       static bool EvalMember(const char* member, size_t len, void* object, void* eng, 
-               SkScriptValue* value);
-       static bool EvalMemberCommon(SkScriptEngine* , const SkMemberInfo* info, 
-               SkDisplayable* displayable, SkScriptValue* value);
-       static bool EvalMemberFunction(const char* member, size_t len, void* object, 
-               SkTDArray<SkScriptValue>& params, void* user, SkScriptValue* value);
-       static bool EvalNamedColor(const char* token, size_t len, void* callBack, SkScriptValue* );
-       static bool EvalRGB(const char* function, size_t len, SkTDArray<SkScriptValue>& params, 
-               void* callBack, SkScriptValue* );
-       static const SkDisplayEnumMap& GetEnumValues(SkDisplayTypes type); 
-       static bool Infinity(const char* token, size_t len, void* callBack, SkScriptValue* );
-       static bool IsFinite(const char* function, size_t len, SkTDArray<SkScriptValue>& params, 
-               void* callBack, SkScriptValue* );
-       static bool IsNaN(const char* function, size_t len, SkTDArray<SkScriptValue>& params, 
-               void* callBack, SkScriptValue* );
-       static bool NaN(const char* token, size_t len, void* callBack, SkScriptValue* );
-       static bool Unbox(void* , SkScriptValue* scriptValue);
-       SkTDDisplayableArray fTrackDisplayable;
-       SkAnimateMaker& fMaker;
-       SkDisplayable* fParent;
-       SkDisplayable* fWorking;
+    static bool Box(void* user, SkScriptValue* );
+    static bool Eval(const char* function, size_t len, SkTDArray<SkScriptValue>& params, 
+        void* callBack, SkScriptValue* );
+    static bool EvalEnum(const char* token, size_t len, void* callBack, SkScriptValue* );
+    static bool EvalID(const char* token, size_t len, void* callBack, SkScriptValue* );
+    static bool EvalMember(const char* member, size_t len, void* object, void* eng, 
+        SkScriptValue* value);
+    static bool EvalMemberCommon(SkScriptEngine* , const SkMemberInfo* info, 
+        SkDisplayable* displayable, SkScriptValue* value);
+    static bool EvalMemberFunction(const char* member, size_t len, void* object, 
+        SkTDArray<SkScriptValue>& params, void* user, SkScriptValue* value);
+    static bool EvalNamedColor(const char* token, size_t len, void* callBack, SkScriptValue* );
+    static bool EvalRGB(const char* function, size_t len, SkTDArray<SkScriptValue>& params, 
+        void* callBack, SkScriptValue* );
+    static const SkDisplayEnumMap& GetEnumValues(SkDisplayTypes type); 
+    static bool Infinity(const char* token, size_t len, void* callBack, SkScriptValue* );
+    static bool IsFinite(const char* function, size_t len, SkTDArray<SkScriptValue>& params, 
+        void* callBack, SkScriptValue* );
+    static bool IsNaN(const char* function, size_t len, SkTDArray<SkScriptValue>& params, 
+        void* callBack, SkScriptValue* );
+    static bool NaN(const char* token, size_t len, void* callBack, SkScriptValue* );
+    static bool Unbox(void* , SkScriptValue* scriptValue);
+    SkTDDisplayableArray fTrackDisplayable;
+    SkAnimateMaker& fMaker;
+    SkDisplayable* fParent;
+    SkDisplayable* fWorking;
 private:
-       friend class SkDump;
-       friend struct SkScriptNAnswer;
+    friend class SkDump;
+    friend struct SkScriptNAnswer;
 #ifdef SK_SUPPORT_UNITTEST
 public:
-       static void UnitTest();
+    static void UnitTest();
 #endif
 };
 
index 664841a..a3d81d4 100644 (file)
@@ -1,12 +1,29 @@
+/* libs/graphics/animator/SkBase64.cpp
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #include "SkBase64.h"
 
 #define DecodePad -2
 #define EncodePad 64
 
 static const char encode[] = 
-       "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
-       "abcdefghijklmnopqrstuvwxyz"
-       "0123456789+/=";
+    "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
+    "abcdefghijklmnopqrstuvwxyz"
+    "0123456789+/=";
 
 static const signed char decodeData[] = {
     62, -1, -1, -1, 63,
@@ -20,151 +37,151 @@ static const signed char decodeData[] = {
 SkBase64::SkBase64() : fLength((size_t) -1), fData(nil) {
 }
 
-#if defined _WIN32 && _MSC_VER >= 1300 // disable 'two', etc. may be used without having been initialized
+#if defined _WIN32 && _MSC_VER >= 1300  // disable 'two', etc. may be used without having been initialized
 #pragma warning ( push )
 #pragma warning ( disable : 4701 )
 #endif
 
 SkBase64::Error SkBase64::decode(const void* srcPtr, size_t size, bool writeDestination) {
-       unsigned char* dst = (unsigned char*) fData;
-       const unsigned char* dstStart = (const unsigned char*) fData;
-       const unsigned char* src = (const unsigned char*) srcPtr;
-       bool padTwo = false;
-       bool padThree = false;
-       const unsigned char* end = src + size;
-       while (src < end) {
-               unsigned char bytes[4];
-               int byte = 0;
-               do {
-                       unsigned char srcByte = *src++;
-                       if (srcByte == 0)
-                               goto goHome;
-                       if (srcByte <= ' ')
-                               continue; // treat as white space
-                       if (srcByte < '+' || srcByte > 'z')
-                               return kBadCharError;
-                       signed char decoded = decodeData[srcByte - '+'];
-                       bytes[byte] = decoded;
-                       if (decoded < 0) {
-                               if (decoded == DecodePad) 
-                                       goto handlePad;
-                               return kBadCharError;
-                       } else
-                               byte++;
-                       if (*src)
-                               continue;
-                       if (byte == 0)
-                               goto goHome;
-                       if (byte == 4)
-                               break;
+    unsigned char* dst = (unsigned char*) fData;
+    const unsigned char* dstStart = (const unsigned char*) fData;
+    const unsigned char* src = (const unsigned char*) srcPtr;
+    bool padTwo = false;
+    bool padThree = false;
+    const unsigned char* end = src + size;
+    while (src < end) {
+        unsigned char bytes[4];
+        int byte = 0;
+        do {
+            unsigned char srcByte = *src++;
+            if (srcByte == 0)
+                goto goHome;
+            if (srcByte <= ' ')
+                continue; // treat as white space
+            if (srcByte < '+' || srcByte > 'z')
+                return kBadCharError;
+            signed char decoded = decodeData[srcByte - '+'];
+            bytes[byte] = decoded;
+            if (decoded < 0) {
+                if (decoded == DecodePad) 
+                    goto handlePad;
+                return kBadCharError;
+            } else
+                byte++;
+            if (*src)
+                continue;
+            if (byte == 0)
+                goto goHome;
+            if (byte == 4)
+                break;
 handlePad:
-                       if (byte < 2)
-                               return kPadError;
-                       padThree = true;
-                       if (byte == 2)
-                               padTwo = true;
-                       break;
-               } while (byte < 4);
-               int two, three;
-               if (writeDestination) {
-                       int one = (U8) (bytes[0] << 2);
-                       two = bytes[1];
-                       one |= two >> 4;
-                       two = (U8) (two << 4);
-                       three = bytes[2];
-                       two |= three >> 2;
-                       three = (U8) (three << 6);
-                       three |= bytes[3];
-                       SkASSERT(one < 256 && two < 256 && three < 256);
-                       *dst = (unsigned char) one;
-               }
-               dst++;
-               if (padTwo) 
-                       break;
-               if (writeDestination)
-                       *dst = (unsigned char) two;
-               dst++;
-               if (padThree)
-                       break;
-               if (writeDestination)
-                       *dst = (unsigned char) three;
-               dst++;
-       }
+            if (byte < 2)
+                return kPadError;
+            padThree = true;
+            if (byte == 2)
+                padTwo = true;
+            break;
+        } while (byte < 4);
+        int two, three;
+        if (writeDestination) {
+            int one = (U8) (bytes[0] << 2);
+            two = bytes[1];
+            one |= two >> 4;
+            two = (U8) (two << 4);
+            three = bytes[2];
+            two |= three >> 2;
+            three = (U8) (three << 6);
+            three |= bytes[3];
+            SkASSERT(one < 256 && two < 256 && three < 256);
+            *dst = (unsigned char) one;
+        }
+        dst++;
+        if (padTwo) 
+            break;
+        if (writeDestination)
+            *dst = (unsigned char) two;
+        dst++;
+        if (padThree)
+            break;
+        if (writeDestination)
+            *dst = (unsigned char) three;
+        dst++;
+    }
 goHome:
-       fLength = dst - dstStart;
-       return kNoError;
+    fLength = dst - dstStart;
+    return kNoError;
 }
 
-#if defined _WIN32 && _MSC_VER >= 1300 
+#if defined _WIN32 && _MSC_VER >= 1300  
 #pragma warning ( pop )
 #endif
 
 size_t SkBase64::Encode(const void* srcPtr, size_t length, void* dstPtr) {
-       const unsigned char* src = (const unsigned char*) srcPtr;
-       unsigned char* dst = (unsigned char*) dstPtr;
-       if (dst) {
-               size_t remainder = length % 3;
-               const unsigned char* end = &src[length - remainder];
-               while (src < end) {
-                       unsigned a = *src++;
-                       unsigned b = *src++;
-                       unsigned c = *src++;
-                       int              d = c & 0x3F;
-                       c = (c >> 6 | b << 2) & 0x3F; 
-                       b = (b >> 4 | a << 4) & 0x3F;
-                       a = a >> 2;
-                       *dst++ = encode[a];
-                       *dst++ = encode[b];
-                       *dst++ = encode[c];
-                       *dst++ = encode[d];
-               }
-               if (remainder > 0) {
-                       int k1 = 0;
-                       int k2 = EncodePad;
-                       int a = (U8) *src++;
-                       if (remainder == 2)
-                       {
-                               int b = *src++;
-                               k1 = b >> 4;
-                               k2 = (b << 2) & 0x3F;
-                       }
-                       *dst++ = encode[a >> 2];
-                       *dst++ = encode[(k1 | a << 4) & 0x3F];
-                       *dst++ = encode[k2];
-                       *dst++ = encode[EncodePad];
-               }
-       }
-       return (length + 2) / 3 * 4;
+    const unsigned char* src = (const unsigned char*) srcPtr;
+    unsigned char* dst = (unsigned char*) dstPtr;
+    if (dst) {
+        size_t remainder = length % 3;
+        const unsigned char* end = &src[length - remainder];
+        while (src < end) {
+            unsigned a = *src++;
+            unsigned b = *src++;
+            unsigned c = *src++;
+            int      d = c & 0x3F;
+            c = (c >> 6 | b << 2) & 0x3F; 
+            b = (b >> 4 | a << 4) & 0x3F;
+            a = a >> 2;
+            *dst++ = encode[a];
+            *dst++ = encode[b];
+            *dst++ = encode[c];
+            *dst++ = encode[d];
+        }
+        if (remainder > 0) {
+            int k1 = 0;
+            int k2 = EncodePad;
+            int a = (U8) *src++;
+            if (remainder == 2)
+            {
+                int b = *src++;
+                k1 = b >> 4;
+                k2 = (b << 2) & 0x3F;
+            }
+            *dst++ = encode[a >> 2];
+            *dst++ = encode[(k1 | a << 4) & 0x3F];
+            *dst++ = encode[k2];
+            *dst++ = encode[EncodePad];
+        }
+    }
+    return (length + 2) / 3 * 4;
 }
 
 SkBase64::Error SkBase64::decode(const char* src, size_t len) {
-       Error err = decode(src, len, false);
-       SkASSERT(err == kNoError);
-       if (err != kNoError)
-               return err;
-       fData = new char[fLength];      // should use sk_malloc/sk_free
-       decode(src, len, true);
-       return kNoError;
+    Error err = decode(src, len, false);
+    SkASSERT(err == kNoError);
+    if (err != kNoError)
+        return err;
+    fData = new char[fLength];  // should use sk_malloc/sk_free
+    decode(src, len, true);
+    return kNoError;
 }
 
 #ifdef SK_SUPPORT_UNITTEST
 void SkBase64::UnitTest() {
-       signed char all[256];
-       for (int index = 0; index < 256; index++)
-               all[index] = (signed char) (index + 1);
-       for (int offset = 0; offset < 6; offset++) {
-               size_t length = 256 - offset;
-               size_t encodeLength = Encode(all + offset, length, nil);
-               char* src = (char*)sk_malloc_throw(encodeLength + 1);
-               Encode(all + offset, length, src);
-               src[encodeLength] = '\0';
-               SkBase64 tryMe;
-               tryMe.decode(src, encodeLength);
-               SkASSERT(length == tryMe.fLength);
-               SkASSERT(strcmp((const char*) (all + offset), tryMe.fData) == 0);
-               sk_free(src);
-               delete[] tryMe.fData;
-       }
+    signed char all[256];
+    for (int index = 0; index < 256; index++)
+        all[index] = (signed char) (index + 1);
+    for (int offset = 0; offset < 6; offset++) {
+        size_t length = 256 - offset;
+        size_t encodeLength = Encode(all + offset, length, nil);
+        char* src = (char*)sk_malloc_throw(encodeLength + 1);
+        Encode(all + offset, length, src);
+        src[encodeLength] = '\0';
+        SkBase64 tryMe;
+        tryMe.decode(src, encodeLength);
+        SkASSERT(length == tryMe.fLength);
+        SkASSERT(strcmp((const char*) (all + offset), tryMe.fData) == 0);
+        sk_free(src);
+        delete[] tryMe.fData;
+    }
 }
 #endif
 
index 4132dd3..89a179b 100644 (file)
@@ -1,3 +1,20 @@
+/* libs/graphics/animator/SkBase64.h
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #ifndef SkBase64_DEFINED
 #define SkBase64_DEFINED
 
 
 struct SkBase64 {
 public:
-       enum Error {
-               kNoError,
-               kPadError,
-               kBadCharError
-       };
+    enum Error {
+        kNoError,
+        kPadError,
+        kBadCharError
+    };
 
-       SkBase64();
-       Error decode(const char* src, size_t length);
-       char* getData() { return fData; }
-       static size_t Encode(const void* src, size_t length, void* dest);
+    SkBase64();
+    Error decode(const char* src, size_t length);
+    char* getData() { return fData; }
+    static size_t Encode(const void* src, size_t length, void* dest);
 
 #ifdef SK_SUPPORT_UNITTEST
-       static void UnitTest();
+    static void UnitTest();
 #endif
 private:
-       Error decode(const void* srcPtr, size_t length, bool writeDestination);
+    Error decode(const void* srcPtr, size_t length, bool writeDestination);
 
-       size_t fLength;
-       char* fData;
-       friend class SkImage;
+    size_t fLength;
+    char* fData;
+    friend class SkImage;
 };
 
 #endif // SkBase64_DEFINED
index 92c8fd0..9043790 100644 (file)
@@ -1,47 +1,64 @@
+/* libs/graphics/animator/SkBoundable.cpp
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #include "SkBoundable.h"
 #include "SkAnimateMaker.h"
 #include "SkCanvas.h"
 
 SkBoundable::SkBoundable() {
-       clearBounds();
-       fBounds.fTop = 0;
-       fBounds.fRight = 0;
-       fBounds.fBottom = 0;
+    clearBounds();
+    fBounds.fTop = 0;
+    fBounds.fRight = 0;
+    fBounds.fBottom = 0;
 }
 
 void SkBoundable::clearBounder() {
-       fBounds.fLeft = 0x7fff;
+    fBounds.fLeft = 0x7fff;
 }
 
 void SkBoundable::getBounds(SkRect* rect) {
-       SkASSERT(rect);
-       if (fBounds.fLeft == (S16)0x8000U) {
-               INHERITED::getBounds(rect);
-               return;
-       }
-       rect->fLeft = SkIntToScalar(fBounds.fLeft);
-       rect->fTop = SkIntToScalar(fBounds.fTop);
-       rect->fRight = SkIntToScalar(fBounds.fRight);
-       rect->fBottom = SkIntToScalar(fBounds.fBottom);
+    SkASSERT(rect);
+    if (fBounds.fLeft == (S16)0x8000U) {
+        INHERITED::getBounds(rect);
+        return;
+    }
+    rect->fLeft = SkIntToScalar(fBounds.fLeft);
+    rect->fTop = SkIntToScalar(fBounds.fTop);
+    rect->fRight = SkIntToScalar(fBounds.fRight);
+    rect->fBottom = SkIntToScalar(fBounds.fBottom);
 }
 
 void SkBoundable::enableBounder() {
-       fBounds.fLeft = 0;
+    fBounds.fLeft = 0;
 }
 
 
 SkBoundableAuto::SkBoundableAuto(SkBoundable* boundable, 
-               SkAnimateMaker& maker) : fBoundable(boundable), fMaker(maker) {
-       if (fBoundable->hasBounds()) {
-               fMaker.fCanvas->setBounder(&maker.fDisplayList);
-               fMaker.fDisplayList.fBounds.setEmpty();
-       }
+        SkAnimateMaker& maker) : fBoundable(boundable), fMaker(maker) {
+    if (fBoundable->hasBounds()) {
+        fMaker.fCanvas->setBounder(&maker.fDisplayList);
+        fMaker.fDisplayList.fBounds.setEmpty();
+    }
 }
 
 SkBoundableAuto::~SkBoundableAuto() {
-       if (fBoundable->hasBounds() == false)
-               return;
-       fMaker.fCanvas->setBounder(nil);
-       fBoundable->setBounds(fMaker.fDisplayList.fBounds);
+    if (fBoundable->hasBounds() == false)
+        return;
+    fMaker.fCanvas->setBounder(nil);
+    fBoundable->setBounds(fMaker.fDisplayList.fBounds);
 }
 
index d3e3586..dd1b8d3 100644 (file)
@@ -1,3 +1,20 @@
+/* libs/graphics/animator/SkBoundable.h
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #ifndef SkBoundable_DEFINED
 #define SkBoundable_DEFINED
 
 
 class SkBoundable : public SkDrawable {
 public:
-       SkBoundable();
-       virtual void clearBounder();
-       virtual void enableBounder();
-       virtual void getBounds(SkRect* );
-       bool hasBounds() { return fBounds.fLeft != (S16)0x8000U; }
-       void setBounds(SkRect16& bounds) { fBounds = bounds; }
+    SkBoundable();
+    virtual void clearBounder();
+    virtual void enableBounder();
+    virtual void getBounds(SkRect* );
+    bool hasBounds() { return fBounds.fLeft != (S16)0x8000U; }
+    void setBounds(SkRect16& bounds) { fBounds = bounds; }
 protected:
-       void clearBounds() { fBounds.fLeft = (S16) SkToU16(0x8000); }; // mark bounds as unset
-       SkRect16 fBounds;
+    void clearBounds() { fBounds.fLeft = (S16) SkToU16(0x8000); }; // mark bounds as unset
+    SkRect16 fBounds;
 private:
-       typedef SkDrawable INHERITED;
+    typedef SkDrawable INHERITED;
 };
 
 class SkBoundableAuto {
 public:
-       SkBoundableAuto(SkBoundable* boundable, SkAnimateMaker& maker);
-       ~SkBoundableAuto();
+    SkBoundableAuto(SkBoundable* boundable, SkAnimateMaker& maker);
+    ~SkBoundableAuto();
 private:
-       SkBoundable* fBoundable;
-       SkAnimateMaker& fMaker;
-       SkBoundableAuto& operator= (const SkBoundableAuto& );
+    SkBoundable* fBoundable;
+    SkAnimateMaker& fMaker;
+    SkBoundableAuto& operator= (const SkBoundableAuto& );
 };
 
 #endif // SkBoundable_DEFINED
index 6c29499..f51f469 100644 (file)
@@ -1,3 +1,20 @@
+/* libs/graphics/animator/SkBuildCondensedInfo.cpp
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #include "SkTypes.h"
 #if defined SK_BUILD_CONDENSED
 #include "SkMemberInfo.h"
@@ -18,253 +35,253 @@ SkTDMemberInfoArray gUnknowns;
 SkTDIntArray gUnknownsCounts;
 
 static void AddInfo(SkDisplayTypes type, const SkMemberInfo* info, int infoCount) {
-       SkASSERT(gInfos[type] == nil);
-       gInfos[type] = info;
-       gInfosCounts[type] = infoCount;
-       *gInfosTypeIDs.append() = type;
-       size_t allStrs = 0;
-       for (int inner = 0; inner < infoCount; inner++) {
-               SkASSERT(info[inner].fCount < 256);
-               int offset = (int) info[inner].fOffset;
-               SkASSERT(offset < 128 && offset > -129);
-               SkASSERT(allStrs < 256);
-               if (info[inner].fType == SkType_BaseClassInfo) {
-                       const SkMemberInfo* innerInfo = (const SkMemberInfo*) info[inner].fName;
-                       if (gUnknowns.find(innerInfo) == -1) {
-                               *gUnknowns.append() = innerInfo;
-                               *gUnknownsCounts.append() = info[inner].fCount;
-                       }
-               }
-               if (info[inner].fType != SkType_BaseClassInfo && info[inner].fName)
-                       allStrs += strlen(info[inner].fName);
-               allStrs += 1;
-               SkASSERT(info[inner].fType < 256);
-       }
+    SkASSERT(gInfos[type] == nil);
+    gInfos[type] = info;
+    gInfosCounts[type] = infoCount;
+    *gInfosTypeIDs.append() = type;
+    size_t allStrs = 0;
+    for (int inner = 0; inner < infoCount; inner++) {
+        SkASSERT(info[inner].fCount < 256);
+        int offset = (int) info[inner].fOffset;
+        SkASSERT(offset < 128 && offset > -129);
+        SkASSERT(allStrs < 256);
+        if (info[inner].fType == SkType_BaseClassInfo) {
+            const SkMemberInfo* innerInfo = (const SkMemberInfo*) info[inner].fName;
+            if (gUnknowns.find(innerInfo) == -1) {
+                *gUnknowns.append() = innerInfo;
+                *gUnknownsCounts.append() = info[inner].fCount;
+            }
+        }
+        if (info[inner].fType != SkType_BaseClassInfo && info[inner].fName)
+            allStrs += strlen(info[inner].fName);
+        allStrs += 1;
+        SkASSERT(info[inner].fType < 256);
+    }
 }
 
 static void WriteInfo(FILE* condensed, const SkMemberInfo* info, int infoCount,
-                       const char* typeName, bool draw, bool display) {
-       fprintf(condensed, "static const char g%sStrings[] = \n", typeName);
-       int inner;
-       // write strings
-       for (inner = 0; inner < infoCount; inner++) {
-               const char* name = (info[inner].fType != SkType_BaseClassInfo && info[inner].fName) ?
-                       info[inner].fName : "";
-               const char* zero = inner < infoCount - 1 ? "\\0" : "";
-               fprintf(condensed, "\t\"%s%s\"\n", name, zero);
-       }
-       fprintf(condensed, ";\n\nstatic const SkMemberInfo g%s", draw ? "Draw" : display ? "Display" : "");
-       fprintf(condensed, "%sInfo[] = {", typeName);
-       size_t nameOffset = 0;
-       // write info tables
-       for (inner = 0; inner < infoCount; inner++) {
-               size_t offset = info[inner].fOffset;
-               if (info[inner].fType == SkType_BaseClassInfo) {
-                       offset = (size_t) gInfos.find((const SkMemberInfo* ) info[inner].fName);
-                       SkASSERT((int) offset >= 0);
-                       offset = gInfosTypeIDs.find((SkDisplayTypes) offset);
-                       SkASSERT((int) offset >= 0);
-               }
-               fprintf(condensed, "\n\t{%d, %d, %d, %d}", nameOffset, offset,
-                       info[inner].fType, info[inner].fCount);
-               if (inner < infoCount - 1)
-                       putc(',', condensed);
-               if (info[inner].fType != SkType_BaseClassInfo && info[inner].fName)
-                       nameOffset += strlen(info[inner].fName);
-               nameOffset += 1;
-       }
-       fprintf(condensed, "\n};\n\n");
+            const char* typeName, bool draw, bool display) {
+    fprintf(condensed, "static const char g%sStrings[] = \n", typeName);
+    int inner;
+    // write strings
+    for (inner = 0; inner < infoCount; inner++) {
+        const char* name = (info[inner].fType != SkType_BaseClassInfo && info[inner].fName) ?
+            info[inner].fName : "";
+        const char* zero = inner < infoCount - 1 ? "\\0" : "";
+        fprintf(condensed, "\t\"%s%s\"\n", name, zero);
+    }
+    fprintf(condensed, ";\n\nstatic const SkMemberInfo g%s", draw ? "Draw" : display ? "Display" : "");
+    fprintf(condensed, "%sInfo[] = {", typeName);
+    size_t nameOffset = 0;
+    // write info tables
+    for (inner = 0; inner < infoCount; inner++) {
+        size_t offset = info[inner].fOffset;
+        if (info[inner].fType == SkType_BaseClassInfo) {
+            offset = (size_t) gInfos.find((const SkMemberInfo* ) info[inner].fName);
+            SkASSERT((int) offset >= 0);
+            offset = gInfosTypeIDs.find((SkDisplayTypes) offset);
+            SkASSERT((int) offset >= 0);
+        }
+        fprintf(condensed, "\n\t{%d, %d, %d, %d}", nameOffset, offset,
+            info[inner].fType, info[inner].fCount);
+        if (inner < infoCount - 1)
+            putc(',', condensed);
+        if (info[inner].fType != SkType_BaseClassInfo && info[inner].fName)
+            nameOffset += strlen(info[inner].fName);
+        nameOffset += 1;
+    }
+    fprintf(condensed, "\n};\n\n");
 }
 
 static void Get3DName(char* scratch, const char* name) {
-       if (strncmp("skia3d:", name, sizeof("skia3d:") - 1) == 0) {
-               strcpy(scratch, "3D_");
-               scratch[3]= name[7] & ~0x20;
-               strcpy(&scratch[4], &name[8]);
-       } else {
-               scratch[0] = name[0] & ~0x20;
-               strcpy(&scratch[1], &name[1]);
-       }
+    if (strncmp("skia3d:", name, sizeof("skia3d:") - 1) == 0) {
+        strcpy(scratch, "3D_");
+        scratch[3]= name[7] & ~0x20;
+        strcpy(&scratch[4], &name[8]);
+    } else {
+        scratch[0] = name[0] & ~0x20;
+        strcpy(&scratch[1], &name[1]);
+    }
 }
 
 int type_compare(const void* a, const void* b) {
-       SkDisplayTypes first = *(SkDisplayTypes*) a;
-       SkDisplayTypes second = *(SkDisplayTypes*) b;
-       return first < second ? -1 : first == second ? 0 : 1;
+    SkDisplayTypes first = *(SkDisplayTypes*) a;
+    SkDisplayTypes second = *(SkDisplayTypes*) b;
+    return first < second ? -1 : first == second ? 0 : 1;
 }
 
 void SkDisplayType::BuildCondensedInfo(SkAnimateMaker* maker) {
-       gInfos.setCount(kNumberOfTypes);
-       memset(gInfos.begin(), 0, sizeof(gInfos[0]) * kNumberOfTypes);
-       gInfosCounts.setCount(kNumberOfTypes);
-       memset(gInfosCounts.begin(), -1, sizeof(gInfosCounts[0]) * kNumberOfTypes);
-       // check to see if it is condensable
-       int index, infoCount;
-       for (index = 0; index < kTypeNamesSize; index++) {
-               const SkMemberInfo* info = GetMembers(maker, gTypeNames[index].fType, &infoCount);
-               if (info == nil)
-                       continue;
-               AddInfo(gTypeNames[index].fType, info, infoCount);
-       }
-       const SkMemberInfo* extraInfo = 
-               SkDisplayType::GetMembers(maker, SkType_3D_Point, &infoCount);
-       AddInfo(SkType_Point, extraInfo, infoCount);
-       AddInfo(SkType_3D_Point, extraInfo, infoCount);
-//     int baseInfos = gInfos.count();
-       do {
-               SkTDMemberInfoArray oldRefs = gUnknowns;
-               SkTDIntArray oldRefCounts = gUnknownsCounts;
-               gUnknowns.reset();
-               gUnknownsCounts.reset();
-               for (index = 0; index < oldRefs.count(); index++) {
-                       const SkMemberInfo* info = oldRefs[index];
-                       if (gInfos.find(info) == -1) {
-                               int typeIndex = 0;
-                               for (; typeIndex < kNumberOfTypes; typeIndex++) {
-                                       const SkMemberInfo* temp = SkDisplayType::GetMembers(
-                                               maker, (SkDisplayTypes) typeIndex, nil);
-                                       if (temp == info)
-                                               break;
-                               }
-                               SkASSERT(typeIndex < kNumberOfTypes);
-                               AddInfo((SkDisplayTypes) typeIndex, info, oldRefCounts[index]);
-                       }
-               }
-       } while (gUnknowns.count() > 0);
-       qsort(gInfosTypeIDs.begin(), gInfosTypeIDs.count(), sizeof(gInfosTypeIDs[0]), &type_compare);
+    gInfos.setCount(kNumberOfTypes);
+    memset(gInfos.begin(), 0, sizeof(gInfos[0]) * kNumberOfTypes);
+    gInfosCounts.setCount(kNumberOfTypes);
+    memset(gInfosCounts.begin(), -1, sizeof(gInfosCounts[0]) * kNumberOfTypes);
+    // check to see if it is condensable
+    int index, infoCount;
+    for (index = 0; index < kTypeNamesSize; index++) {
+        const SkMemberInfo* info = GetMembers(maker, gTypeNames[index].fType, &infoCount);
+        if (info == nil)
+            continue;
+        AddInfo(gTypeNames[index].fType, info, infoCount);
+    }
+    const SkMemberInfo* extraInfo = 
+        SkDisplayType::GetMembers(maker, SkType_3D_Point, &infoCount);
+    AddInfo(SkType_Point, extraInfo, infoCount);
+    AddInfo(SkType_3D_Point, extraInfo, infoCount);
+//  int baseInfos = gInfos.count();
+    do {
+        SkTDMemberInfoArray oldRefs = gUnknowns;
+        SkTDIntArray oldRefCounts = gUnknownsCounts;
+        gUnknowns.reset();
+        gUnknownsCounts.reset();
+        for (index = 0; index < oldRefs.count(); index++) {
+            const SkMemberInfo* info = oldRefs[index];
+            if (gInfos.find(info) == -1) {
+                int typeIndex = 0;
+                for (; typeIndex < kNumberOfTypes; typeIndex++) {
+                    const SkMemberInfo* temp = SkDisplayType::GetMembers(
+                        maker, (SkDisplayTypes) typeIndex, nil);
+                    if (temp == info)
+                        break;
+                }
+                SkASSERT(typeIndex < kNumberOfTypes);
+                AddInfo((SkDisplayTypes) typeIndex, info, oldRefCounts[index]);
+            }
+        }
+    } while (gUnknowns.count() > 0);
+    qsort(gInfosTypeIDs.begin(), gInfosTypeIDs.count(), sizeof(gInfosTypeIDs[0]), &type_compare);
 #ifdef SK_DEBUG
-       FILE* condensed = fopen("../../src/animator/SkCondensedDebug.cpp", "w+");
-       fprintf(condensed, "#include \"SkTypes.h\"\n");
-       fprintf(condensed, "#ifdef SK_DEBUG\n");
+    FILE* condensed = fopen("../../src/animator/SkCondensedDebug.cpp", "w+");
+    fprintf(condensed, "#include \"SkTypes.h\"\n");
+    fprintf(condensed, "#ifdef SK_DEBUG\n");
 #else
-       FILE* condensed = fopen("../../src/animator/SkCondensedRelease.cpp", "w+");
-       fprintf(condensed, "#include \"SkTypes.h\"\n");
-       fprintf(condensed, "#ifdef SK_RELEASE\n");
+    FILE* condensed = fopen("../../src/animator/SkCondensedRelease.cpp", "w+");
+    fprintf(condensed, "#include \"SkTypes.h\"\n");
+    fprintf(condensed, "#ifdef SK_RELEASE\n");
 #endif
-       // write header
-       fprintf(condensed, "// This file was automatically generated.\n");
-       fprintf(condensed, "// To change it, edit the file with the matching debug info.\n");
-       fprintf(condensed, "// Then execute SkDisplayType::BuildCondensedInfo() to "
-               "regenerate this file.\n\n");
-       // write name of memberInfo
-       int typeNameIndex = 0;
-       int unknown = 1;
-       for (index = 0; index < gInfos.count(); index++) {
-               const SkMemberInfo* info = gInfos[index];
-               if (info == nil)
-                       continue;
-               char scratch[64];
-               bool drawPrefix, displayPrefix;
-               while (gTypeNames[typeNameIndex].fType < index)
-                       typeNameIndex++;
-               if (gTypeNames[typeNameIndex].fType == index) {
-                       Get3DName(scratch, gTypeNames[typeNameIndex].fName);
-                       drawPrefix = gTypeNames[typeNameIndex].fDrawPrefix;
-                       displayPrefix = gTypeNames[typeNameIndex].fDisplayPrefix;
-               } else {
-                       sprintf(scratch, "Unknown%d", unknown++);
-                       drawPrefix = displayPrefix = false;
-               }
-               WriteInfo(condensed, info, gInfosCounts[index], scratch, drawPrefix, displayPrefix);
-       }
-       // write array of table pointers
-//     start here;
-       fprintf(condensed, "static const SkMemberInfo* const gInfoTables[] = {");
-       typeNameIndex = 0;
-       unknown = 1;
-       for (index = 0; index < gInfos.count(); index++) {
-               const SkMemberInfo* info = gInfos[index];
-               if (info == nil)
-                       continue;
-               char scratch[64];
-               bool drawPrefix, displayPrefix;
-               while (gTypeNames[typeNameIndex].fType < index)
-                       typeNameIndex++;
-               if (gTypeNames[typeNameIndex].fType == index) {
-                       Get3DName(scratch, gTypeNames[typeNameIndex].fName);
-                       drawPrefix = gTypeNames[typeNameIndex].fDrawPrefix;
-                       displayPrefix = gTypeNames[typeNameIndex].fDisplayPrefix;
-               } else {
-                       sprintf(scratch, "Unknown%d", unknown++);
-                       drawPrefix = displayPrefix = false;
-               }
-               fprintf(condensed, "\n\tg");
-               if (drawPrefix)
-                       fprintf(condensed, "Draw");
-               if (displayPrefix)
-                       fprintf(condensed, "Display");
-               fprintf(condensed, "%sInfo", scratch);
-               if (index < gInfos.count() - 1)
-                               putc(',', condensed);
-       }
-       fprintf(condensed, "\n};\n\n");
-       // write the array of number of entries in the info table
-       fprintf(condensed, "static const unsigned char gInfoCounts[] = {\n\t");
-       int written = 0;
-       for (index = 0; index < gInfosCounts.count(); index++) {
-               int count = gInfosCounts[index];
-               if (count < 0)
-                       continue;
-               if (written > 0)
-                       putc(',', condensed);
-               if (written % 20 == 19)
-                       fprintf(condensed, "\n\t");
-               fprintf(condensed, "%d",count);
-               written++;
-       }
-       fprintf(condensed, "\n};\n\n");
-       // write array of type ids table entries correspond to
-       fprintf(condensed, "static const unsigned char gTypeIDs[] = {\n\t");
-       int typeIDCount = 0;
-       typeNameIndex = 0;
-       unknown = 1;
-       for (index = 0; index < gInfosCounts.count(); index++) {
-               const SkMemberInfo* info = gInfos[index];
-               if (info == nil)
-                       continue;
-               typeIDCount++;
-               char scratch[64];
-               while (gTypeNames[typeNameIndex].fType < index)
-                       typeNameIndex++;
-               if (gTypeNames[typeNameIndex].fType == index) {
-                       Get3DName(scratch, gTypeNames[typeNameIndex].fName);
-               } else
-                       sprintf(scratch, "Unknown%d", unknown++);
-               fprintf(condensed, "%d%c // %s\n\t", index, 
-                       index < gInfosCounts.count() ? ',' : ' ', scratch);
-       }
-       fprintf(condensed, "\n};\n\n");
-       fprintf(condensed, "static const int kTypeIDs = %d;\n\n", typeIDCount);
-       // write the array of string pointers
-       fprintf(condensed, "static const char* const gInfoNames[] = {");
-       typeNameIndex = 0;
-       unknown = 1;
-       written = 0;
-       for (index = 0; index < gInfosCounts.count(); index++) {
-               const SkMemberInfo* info = gInfos[index];
-               if (info == nil)
-                       continue;
-               if (written > 0)
-                               putc(',', condensed);
-               written++;
-               fprintf(condensed, "\n\tg");
-               char scratch[64];
-               while (gTypeNames[typeNameIndex].fType < index)
-                       typeNameIndex++;
-               if (gTypeNames[typeNameIndex].fType == index) {
-                       Get3DName(scratch, gTypeNames[typeNameIndex].fName);
-               } else
-                       sprintf(scratch, "Unknown%d", unknown++);
-               fprintf(condensed, "%sStrings", scratch);
-       }
-       fprintf(condensed, "\n};\n\n");
-       fprintf(condensed, "#endif\n");
-       fclose(condensed);
-       gInfos.reset();
-       gInfosCounts.reset();
-       gInfosTypeIDs.reset();
-       gUnknowns.reset();
-       gUnknownsCounts.reset();
+    // write header
+    fprintf(condensed, "// This file was automatically generated.\n");
+    fprintf(condensed, "// To change it, edit the file with the matching debug info.\n");
+    fprintf(condensed, "// Then execute SkDisplayType::BuildCondensedInfo() to "
+        "regenerate this file.\n\n");
+    // write name of memberInfo
+    int typeNameIndex = 0;
+    int unknown = 1;
+    for (index = 0; index < gInfos.count(); index++) {
+        const SkMemberInfo* info = gInfos[index];
+        if (info == nil)
+            continue;
+        char scratch[64];
+        bool drawPrefix, displayPrefix;
+        while (gTypeNames[typeNameIndex].fType < index)
+            typeNameIndex++;
+        if (gTypeNames[typeNameIndex].fType == index) {
+            Get3DName(scratch, gTypeNames[typeNameIndex].fName);
+            drawPrefix = gTypeNames[typeNameIndex].fDrawPrefix;
+            displayPrefix = gTypeNames[typeNameIndex].fDisplayPrefix;
+        } else {
+            sprintf(scratch, "Unknown%d", unknown++);
+            drawPrefix = displayPrefix = false;
+        }
+        WriteInfo(condensed, info, gInfosCounts[index], scratch, drawPrefix, displayPrefix);
+    }
+    // write array of table pointers
+//  start here;
+    fprintf(condensed, "static const SkMemberInfo* const gInfoTables[] = {");
+    typeNameIndex = 0;
+    unknown = 1;
+    for (index = 0; index < gInfos.count(); index++) {
+        const SkMemberInfo* info = gInfos[index];
+        if (info == nil)
+            continue;
+        char scratch[64];
+        bool drawPrefix, displayPrefix;
+        while (gTypeNames[typeNameIndex].fType < index)
+            typeNameIndex++;
+        if (gTypeNames[typeNameIndex].fType == index) {
+            Get3DName(scratch, gTypeNames[typeNameIndex].fName);
+            drawPrefix = gTypeNames[typeNameIndex].fDrawPrefix;
+            displayPrefix = gTypeNames[typeNameIndex].fDisplayPrefix;
+        } else {
+            sprintf(scratch, "Unknown%d", unknown++);
+            drawPrefix = displayPrefix = false;
+        }
+        fprintf(condensed, "\n\tg");
+        if (drawPrefix)
+            fprintf(condensed, "Draw");
+        if (displayPrefix)
+            fprintf(condensed, "Display");
+        fprintf(condensed, "%sInfo", scratch);
+        if (index < gInfos.count() - 1)
+                putc(',', condensed);
+    }
+    fprintf(condensed, "\n};\n\n");
+    // write the array of number of entries in the info table
+    fprintf(condensed, "static const unsigned char gInfoCounts[] = {\n\t");
+    int written = 0;
+    for (index = 0; index < gInfosCounts.count(); index++) {
+        int count = gInfosCounts[index];
+        if (count < 0)
+            continue;
+        if (written > 0)
+            putc(',', condensed);
+        if (written % 20 == 19)
+            fprintf(condensed, "\n\t");
+        fprintf(condensed, "%d",count);
+        written++;
+    }
+    fprintf(condensed, "\n};\n\n");
+    // write array of type ids table entries correspond to
+    fprintf(condensed, "static const unsigned char gTypeIDs[] = {\n\t");
+    int typeIDCount = 0;
+    typeNameIndex = 0;
+    unknown = 1;
+    for (index = 0; index < gInfosCounts.count(); index++) {
+        const SkMemberInfo* info = gInfos[index];
+        if (info == nil)
+            continue;
+        typeIDCount++;
+        char scratch[64];
+        while (gTypeNames[typeNameIndex].fType < index)
+            typeNameIndex++;
+        if (gTypeNames[typeNameIndex].fType == index) {
+            Get3DName(scratch, gTypeNames[typeNameIndex].fName);
+        } else
+            sprintf(scratch, "Unknown%d", unknown++);
+        fprintf(condensed, "%d%c // %s\n\t", index, 
+            index < gInfosCounts.count() ? ',' : ' ', scratch);
+    }
+    fprintf(condensed, "\n};\n\n");
+    fprintf(condensed, "static const int kTypeIDs = %d;\n\n", typeIDCount);
+    // write the array of string pointers
+    fprintf(condensed, "static const char* const gInfoNames[] = {");
+    typeNameIndex = 0;
+    unknown = 1;
+    written = 0;
+    for (index = 0; index < gInfosCounts.count(); index++) {
+        const SkMemberInfo* info = gInfos[index];
+        if (info == nil)
+            continue;
+        if (written > 0)
+                putc(',', condensed);
+        written++;
+        fprintf(condensed, "\n\tg");
+        char scratch[64];
+        while (gTypeNames[typeNameIndex].fType < index)
+            typeNameIndex++;
+        if (gTypeNames[typeNameIndex].fType == index) {
+            Get3DName(scratch, gTypeNames[typeNameIndex].fName);
+        } else
+            sprintf(scratch, "Unknown%d", unknown++);
+        fprintf(condensed, "%sStrings", scratch);
+    }
+    fprintf(condensed, "\n};\n\n");
+    fprintf(condensed, "#endif\n");
+    fclose(condensed);
+    gInfos.reset();
+    gInfosCounts.reset();
+    gInfosTypeIDs.reset();
+    gUnknowns.reset();
+    gUnknownsCounts.reset();
 }
 
 #elif defined SK_DEBUG
index f60487b..1d20025 100644 (file)
@@ -1,3 +1,20 @@
+/* libs/graphics/animator/SkCondensedDebug.cpp
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #include "SkTypes.h"
 #ifndef SK_BUILD_FOR_UNIX
 #ifdef SK_DEBUG
 // Then execute SkDisplayType::BuildCondensedInfo() to regenerate this file.
 
 static const char gMathStrings[] = 
-       "E\0"
-       "LN10\0"
-       "LN2\0"
-       "LOG10E\0"
-       "LOG2E\0"
-       "PI\0"
-       "SQRT1_2\0"
-       "SQRT2\0"
-       "abs\0"
-       "acos\0"
-       "asin\0"
-       "atan\0"
-       "atan2\0"
-       "ceil\0"
-       "cos\0"
-       "exp\0"
-       "floor\0"
-       "log\0"
-       "max\0"
-       "min\0"
-       "pow\0"
-       "random\0"
-       "round\0"
-       "sin\0"
-       "sqrt\0"
-       "tan"
+    "E\0"
+    "LN10\0"
+    "LN2\0"
+    "LOG10E\0"
+    "LOG2E\0"
+    "PI\0"
+    "SQRT1_2\0"
+    "SQRT2\0"
+    "abs\0"
+    "acos\0"
+    "asin\0"
+    "atan\0"
+    "atan2\0"
+    "ceil\0"
+    "cos\0"
+    "exp\0"
+    "floor\0"
+    "log\0"
+    "max\0"
+    "min\0"
+    "pow\0"
+    "random\0"
+    "round\0"
+    "sin\0"
+    "sqrt\0"
+    "tan"
 ;
 
 static const SkMemberInfo gMathInfo[] = {
-       {0, -1, 67, 98},
-       {2, -2, 67, 98},
-       {7, -3, 67, 98},
-       {11, -4, 67, 98},
-       {18, -5, 67, 98},
-       {24, -6, 67, 98},
-       {27, -7, 67, 98},
-       {35, -8, 67, 98},
-       {41, -1, 66, 98},
-       {45, -2, 66, 98},
-       {50, -3, 66, 98},
-       {55, -4, 66, 98},
-       {60, -5, 66, 98},
-       {66, -6, 66, 98},
-       {71, -7, 66, 98},
-       {75, -8, 66, 98},
-       {79, -9, 66, 98},
-       {85, -10, 66, 98},
-       {89, -11, 66, 98},
-       {93, -12, 66, 98},
-       {97, -13, 66, 98},
-       {101, -14, 66, 98},
-       {108, -15, 66, 98},
-       {114, -16, 66, 98},
-       {118, -17, 66, 98},
-       {123, -18, 66, 98}
+    {0, -1, 67, 98},
+    {2, -2, 67, 98},
+    {7, -3, 67, 98},
+    {11, -4, 67, 98},
+    {18, -5, 67, 98},
+    {24, -6, 67, 98},
+    {27, -7, 67, 98},
+    {35, -8, 67, 98},
+    {41, -1, 66, 98},
+    {45, -2, 66, 98},
+    {50, -3, 66, 98},
+    {55, -4, 66, 98},
+    {60, -5, 66, 98},
+    {66, -6, 66, 98},
+    {71, -7, 66, 98},
+    {75, -8, 66, 98},
+    {79, -9, 66, 98},
+    {85, -10, 66, 98},
+    {89, -11, 66, 98},
+    {93, -12, 66, 98},
+    {97, -13, 66, 98},
+    {101, -14, 66, 98},
+    {108, -15, 66, 98},
+    {114, -16, 66, 98},
+    {118, -17, 66, 98},
+    {123, -18, 66, 98}
 };
 
 static const char gAddStrings[] = 
-       "inPlace\0"
-       "offset\0"
-       "use\0"
-       "where"
+    "inPlace\0"
+    "offset\0"
+    "use\0"
+    "where"
 ;
 
 static const SkMemberInfo gAddInfo[] = {
-       {0, 16, 26, 1},
-       {8, 20, 96, 1},
-       {15, 24, 37, 1},
-       {19, 28, 37, 1}
+    {0, 16, 26, 1},
+    {8, 20, 96, 1},
+    {15, 24, 37, 1},
+    {19, 28, 37, 1}
 };
 
 static const char gAddCircleStrings[] = 
-       "\0"
-       "radius\0"
-       "x\0"
-       "y"
+    "\0"
+    "radius\0"
+    "x\0"
+    "y"
 ;
 
 static const SkMemberInfo gAddCircleInfo[] = {
-       {0, 3, 18, 1},
-       {1, 24, 98, 1},
-       {8, 28, 98, 1},
-       {10, 32, 98, 1}
+    {0, 3, 18, 1},
+    {1, 24, 98, 1},
+    {8, 28, 98, 1},
+    {10, 32, 98, 1}
 };
 
 static const char gUnknown1Strings[] = 
-       "direction"
+    "direction"
 ;
 
 static const SkMemberInfo gUnknown1Info[] = {
-       {0, 20, 75, 1}
+    {0, 20, 75, 1}
 };
 
 static const char gAddOvalStrings[] = 
-       ""
+    ""
 ;
 
 static const SkMemberInfo gAddOvalInfo[] = {
-       {0, 6, 18, 5}
+    {0, 6, 18, 5}
 };
 
 static const char gAddPathStrings[] = 
-       "matrix\0"
-       "path"
+    "matrix\0"
+    "path"
 ;
 
 static const SkMemberInfo gAddPathInfo[] = {
-       {0, 20, 65, 1},
-       {7, 24, 74, 1}
+    {0, 20, 65, 1},
+    {7, 24, 74, 1}
 };
 
 static const char gAddRectangleStrings[] = 
-       "\0"
-       "bottom\0"
-       "left\0"
-       "right\0"
-       "top"
+    "\0"
+    "bottom\0"
+    "left\0"
+    "right\0"
+    "top"
 ;
 
 static const SkMemberInfo gAddRectangleInfo[] = {
-       {0, 3, 18, 1},
-       {1, 36, 98, 1},
-       {8, 24, 98, 1},
-       {13, 32, 98, 1},
-       {19, 28, 98, 1}
+    {0, 3, 18, 1},
+    {1, 36, 98, 1},
+    {8, 24, 98, 1},
+    {13, 32, 98, 1},
+    {19, 28, 98, 1}
 };
 
 static const char gAddRoundRectStrings[] = 
-       "\0"
-       "rx\0"
-       "ry"
+    "\0"
+    "rx\0"
+    "ry"
 ;
 
 static const SkMemberInfo gAddRoundRectInfo[] = {
-       {0, 6, 18, 5},
-       {1, 40, 98, 1},
-       {4, 44, 98, 1}
+    {0, 6, 18, 5},
+    {1, 40, 98, 1},
+    {4, 44, 98, 1}
 };
 
 static const char gUnknown2Strings[] = 
-       "begin\0"
-       "blend\0"
-       "dur\0"
-       "dynamic\0"
-       "field\0"
-       "formula\0"
-       "from\0"
-       "mirror\0"
-       "repeat\0"
-       "reset\0"
-       "target\0"
-       "to\0"
-       "values"
+    "begin\0"
+    "blend\0"
+    "dur\0"
+    "dynamic\0"
+    "field\0"
+    "formula\0"
+    "from\0"
+    "mirror\0"
+    "repeat\0"
+    "reset\0"
+    "target\0"
+    "to\0"
+    "values"
 ;
 
 static const SkMemberInfo gUnknown2Info[] = {
-       {0, 16, 71, 1},
-       {6, 20, 119, 98},
-       {12, 36, 71, 1},
-       {16, -1, 67, 26},
-       {24, 40, 108, 2},
-       {30, 48, 40, 2},
-       {38, 56, 40, 2},
-       {43, -2, 67, 26},
-       {50, 64, 98, 1},
-       {57, -3, 67, 26},
-       {63, 68, 40, 2},
-       {70, 76, 40, 2},
-       {73, -4, 67, 40}
+    {0, 16, 71, 1},
+    {6, 20, 119, 98},
+    {12, 36, 71, 1},
+    {16, -1, 67, 26},
+    {24, 40, 108, 2},
+    {30, 48, 40, 2},
+    {38, 56, 40, 2},
+    {43, -2, 67, 26},
+    {50, 64, 98, 1},
+    {57, -3, 67, 26},
+    {63, 68, 40, 2},
+    {70, 76, 40, 2},
+    {73, -4, 67, 40}
 };
 
 static const char gAnimateFieldStrings[] = 
-       ""
+    ""
 ;
 
 static const SkMemberInfo gAnimateFieldInfo[] = {
-       {0, 8, 18, 13}
+    {0, 8, 18, 13}
 };
 
 static const char gApplyStrings[] = 
-       "animator\0"
-       "begin\0"
-       "dontDraw\0"
-       "dynamicScope\0"
-       "interval\0"
-       "mode\0"
-       "pickup\0"
-       "restore\0"
-       "scope\0"
-       "step\0"
-       "steps\0"
-       "time\0"
-       "transition"
+    "animator\0"
+    "begin\0"
+    "dontDraw\0"
+    "dynamicScope\0"
+    "interval\0"
+    "mode\0"
+    "pickup\0"
+    "restore\0"
+    "scope\0"
+    "step\0"
+    "steps\0"
+    "time\0"
+    "transition"
 ;
 
 static const SkMemberInfo gApplyInfo[] = {
-       {0, -1, 67, 10},
-       {9, 16, 71, 1},
-       {15, 20, 26, 1},
-       {24, 24, 108, 2},
-       {37, 32, 71, 1},
-       {46, 36, 13, 1},
-       {51, 40, 26, 1},
-       {58, 44, 26, 1},
-       {66, 48, 37, 1},
-       {72, -2, 67, 96},
-       {77, 52, 96, 1},
-       {83, -3, 67, 71},
-       {88, 56, 14, 1}
+    {0, -1, 67, 10},
+    {9, 16, 71, 1},
+    {15, 20, 26, 1},
+    {24, 24, 108, 2},
+    {37, 32, 71, 1},
+    {46, 36, 13, 1},
+    {51, 40, 26, 1},
+    {58, 44, 26, 1},
+    {66, 48, 37, 1},
+    {72, -2, 67, 96},
+    {77, 52, 96, 1},
+    {83, -3, 67, 71},
+    {88, 56, 14, 1}
 };
 
 static const char gUnknown3Strings[] = 
-       "x\0"
-       "y"
+    "x\0"
+    "y"
 ;
 
 static const SkMemberInfo gUnknown3Info[] = {
-       {0, 48, 98, 1},
-       {2, 52, 98, 1}
+    {0, 48, 98, 1},
+    {2, 52, 98, 1}
 };
 
 static const char gBitmapStrings[] = 
-       "\0"
-       "erase\0"
-       "format\0"
-       "height\0"
-       "rowBytes\0"
-       "width"
+    "\0"
+    "erase\0"
+    "format\0"
+    "height\0"
+    "rowBytes\0"
+    "width"
 ;
 
 static const SkMemberInfo gDrawBitmapInfo[] = {
-       {0, 11, 18, 2},
-       {1, -1, 67, 15},
-       {7, 56, 21, 1},
-       {14, 60, 96, 1},
-       {21, 64, 96, 1},
-       {30, 68, 96, 1}
+    {0, 11, 18, 2},
+    {1, -1, 67, 15},
+    {7, 56, 21, 1},
+    {14, 60, 96, 1},
+    {21, 64, 96, 1},
+    {30, 68, 96, 1}
 };
 
 static const char gBitmapShaderStrings[] = 
-       "\0"
-       "filterType\0"
-       "image"
+    "\0"
+    "filterType\0"
+    "image"
 ;
 
 static const SkMemberInfo gDrawBitmapShaderInfo[] = {
-       {0, 67, 18, 2},
-       {1, 28, 47, 1},
-       {12, 32, 17, 1}
+    {0, 67, 18, 2},
+    {1, 28, 47, 1},
+    {12, 32, 17, 1}
 };
 
 static const char gBlurStrings[] = 
-       "blurStyle\0"
-       "radius"
+    "blurStyle\0"
+    "radius"
 ;
 
 static const SkMemberInfo gDrawBlurInfo[] = {
-       {0, 24, 63, 1},
-       {10, 20, 98, 1}
+    {0, 24, 63, 1},
+    {10, 20, 98, 1}
 };
 
 static const char gBoundsStrings[] = 
-       "\0"
-       "inval"
+    "\0"
+    "inval"
 ;
 
 static const SkMemberInfo gDisplayBoundsInfo[] = {
-       {0, 58, 18, 7},
-       {1, 44, 26, 1}
+    {0, 58, 18, 7},
+    {1, 44, 26, 1}
 };
 
 static const char gClipStrings[] = 
-       "path\0"
-       "rectangle"
+    "path\0"
+    "rectangle"
 ;
 
 static const SkMemberInfo gDrawClipInfo[] = {
-       {0, 20, 74, 1},
-       {5, 16, 91, 1}
+    {0, 20, 74, 1},
+    {5, 16, 91, 1}
 };
 
 static const char gColorStrings[] = 
-       "alpha\0"
-       "blue\0"
-       "color\0"
-       "green\0"
-       "hue\0"
-       "red\0"
-       "saturation\0"
-       "value"
+    "alpha\0"
+    "blue\0"
+    "color\0"
+    "green\0"
+    "hue\0"
+    "red\0"
+    "saturation\0"
+    "value"
 ;
 
 static const SkMemberInfo gDrawColorInfo[] = {
-       {0, -1, 67, 98},
-       {6, -2, 67, 98},
-       {11, 20, 15, 1},
-       {17, -3, 67, 98},
-       {23, -4, 67, 98},
-       {27, -5, 67, 98},
-       {31, -6, 67, 98},
-       {42, -7, 67, 98}
+    {0, -1, 67, 98},
+    {6, -2, 67, 98},
+    {11, 20, 15, 1},
+    {17, -3, 67, 98},
+    {23, -4, 67, 98},
+    {27, -5, 67, 98},
+    {31, -6, 67, 98},
+    {42, -7, 67, 98}
 };
 
 static const char gCubicToStrings[] = 
-       "x1\0"
-       "x2\0"
-       "x3\0"
-       "y1\0"
-       "y2\0"
-       "y3"
+    "x1\0"
+    "x2\0"
+    "x3\0"
+    "y1\0"
+    "y2\0"
+    "y3"
 ;
 
 static const SkMemberInfo gCubicToInfo[] = {
-       {0, 20, 98, 1},
-       {3, 28, 98, 1},
-       {6, 36, 98, 1},
-       {9, 24, 98, 1},
-       {12, 32, 98, 1},
-       {15, 40, 98, 1}
+    {0, 20, 98, 1},
+    {3, 28, 98, 1},
+    {6, 36, 98, 1},
+    {9, 24, 98, 1},
+    {12, 32, 98, 1},
+    {15, 40, 98, 1}
 };
 
 static const char gDashStrings[] = 
-       "intervals\0"
-       "phase"
+    "intervals\0"
+    "phase"
 ;
 
 static const SkMemberInfo gDashInfo[] = {
-       {0, 20, 119, 98},
-       {10, 36, 98, 1}
+    {0, 20, 119, 98},
+    {10, 36, 98, 1}
 };
 
 static const char gDataStrings[] = 
-       "\0"
-       "name"
+    "\0"
+    "name"
 ;
 
 static const SkMemberInfo gDataInfo[] = {
-       {0, 33, 18, 3},
-       {1, 32, 108, 2}
+    {0, 33, 18, 3},
+    {1, 32, 108, 2}
 };
 
 static const char gDiscreteStrings[] = 
-       "deviation\0"
-       "segLength"
+    "deviation\0"
+    "segLength"
 ;
 
 static const SkMemberInfo gDiscreteInfo[] = {
-       {0, 20, 98, 1},
-       {10, 24, 98, 1}
+    {0, 20, 98, 1},
+    {10, 24, 98, 1}
 };
 
 static const char gDrawToStrings[] = 
-       "drawOnce\0"
-       "use"
+    "drawOnce\0"
+    "use"
 ;
 
 static const SkMemberInfo gDrawToInfo[] = {
-       {0, 72, 26, 1},
-       {9, 76, 19, 1}
+    {0, 72, 26, 1},
+    {9, 76, 19, 1}
 };
 
 static const char gDumpStrings[] = 
-       "displayList\0"
-       "eventList\0"
-       "events\0"
-       "groups\0"
-       "name\0"
-       "posts"
+    "displayList\0"
+    "eventList\0"
+    "events\0"
+    "groups\0"
+    "name\0"
+    "posts"
 ;
 
 static const SkMemberInfo gDumpInfo[] = {
-       {0, 16, 26, 1},
-       {12, 20, 26, 1},
-       {22, 24, 26, 1},
-       {29, 36, 26, 1},
-       {36, 28, 108, 2},
-       {41, 40, 26, 1}
+    {0, 16, 26, 1},
+    {12, 20, 26, 1},
+    {22, 24, 26, 1},
+    {29, 36, 26, 1},
+    {36, 28, 108, 2},
+    {41, 40, 26, 1}
 };
 
 static const char gEmbossStrings[] = 
-       "ambient\0"
-       "direction\0"
-       "radius\0"
-       "specular"
+    "ambient\0"
+    "direction\0"
+    "radius\0"
+    "specular"
 ;
 
 static const SkMemberInfo gDrawEmbossInfo[] = {
-       {0, -1, 67, 98},
-       {8, 20, 119, 98},
-       {18, 36, 98, 1},
-       {25, -2, 67, 98}
+    {0, -1, 67, 98},
+    {8, 20, 119, 98},
+    {18, 36, 98, 1},
+    {25, -2, 67, 98}
 };
 
 static const char gEventStrings[] = 
-       "code\0"
-       "disable\0"
-       "key\0"
-       "keys\0"
-       "kind\0"
-       "target\0"
-       "x\0"
-       "y"
+    "code\0"
+    "disable\0"
+    "key\0"
+    "keys\0"
+    "kind\0"
+    "target\0"
+    "x\0"
+    "y"
 ;
 
 static const SkMemberInfo gDisplayEventInfo[] = {
-       {0, 16, 43, 1},
-       {5, 20, 26, 1},
-       {13, -1, 67, 108},
-       {17, -2, 67, 108},
-       {22, 24, 44, 1},
-       {27, 28, 108, 2},
-       {34, 36, 98, 1},
-       {36, 40, 98, 1}
+    {0, 16, 43, 1},
+    {5, 20, 26, 1},
+    {13, -1, 67, 108},
+    {17, -2, 67, 108},
+    {22, 24, 44, 1},
+    {27, 28, 108, 2},
+    {34, 36, 98, 1},
+    {36, 40, 98, 1}
 };
 
 static const char gFromPathStrings[] = 
-       "mode\0"
-       "offset\0"
-       "path"
+    "mode\0"
+    "offset\0"
+    "path"
 ;
 
 static const SkMemberInfo gFromPathInfo[] = {
-       {0, 20, 49, 1},
-       {5, 24, 98, 1},
-       {12, 28, 74, 1}
+    {0, 20, 49, 1},
+    {5, 24, 98, 1},
+    {12, 28, 74, 1}
 };
 
 static const char gUnknown4Strings[] = 
-       "\0"
-       "offsets\0"
-       "unitMapper"
+    "\0"
+    "offsets\0"
+    "unitMapper"
 ;
 
 static const SkMemberInfo gUnknown4Info[] = {
-       {0, 67, 18, 2},
-       {1, 28, 119, 98},
-       {9, 44, 108, 2}
+    {0, 67, 18, 2},
+    {1, 28, 119, 98},
+    {9, 44, 108, 2}
 };
 
 static const char gGStrings[] = 
-       "condition\0"
-       "enableCondition"
+    "condition\0"
+    "enableCondition"
 ;
 
 static const SkMemberInfo gGInfo[] = {
-       {0, 16, 40, 2},
-       {10, 24, 40, 2}
+    {0, 16, 40, 2},
+    {10, 24, 40, 2}
 };
 
 static const char gHitClearStrings[] = 
-       "targets"
+    "targets"
 ;
 
 static const SkMemberInfo gHitClearInfo[] = {
-       {0, 16, 119, 36}
+    {0, 16, 119, 36}
 };
 
 static const char gHitTestStrings[] = 
-       "bullets\0"
-       "hits\0"
-       "targets\0"
-       "value"
+    "bullets\0"
+    "hits\0"
+    "targets\0"
+    "value"
 ;
 
 static const SkMemberInfo gHitTestInfo[] = {
-       {0, 16, 119, 36},
-       {8, 32, 119, 96},
-       {13, 48, 119, 36},
-       {21, 64, 26, 1}
+    {0, 16, 119, 36},
+    {8, 32, 119, 96},
+    {13, 48, 119, 36},
+    {21, 64, 26, 1}
 };
 
 static const char gImageStrings[] = 
-       "\0"
-       "base64\0"
-       "src"
+    "\0"
+    "base64\0"
+    "src"
 ;
 
 static const SkMemberInfo gImageInfo[] = {
-       {0, 11, 18, 2},
-       {1, 56, 16, 2},
-       {8, 64, 108, 2}
+    {0, 11, 18, 2},
+    {1, 56, 16, 2},
+    {8, 64, 108, 2}
 };
 
 static const char gIncludeStrings[] = 
-       "src"
+    "src"
 ;
 
 static const SkMemberInfo gIncludeInfo[] = {
-       {0, 16, 108, 2}
+    {0, 16, 108, 2}
 };
 
 static const char gInputStrings[] = 
-       "s32\0"
-       "scalar\0"
-       "string"
+    "s32\0"
+    "scalar\0"
+    "string"
 ;
 
 static const SkMemberInfo gInputInfo[] = {
-       {0, 16, 96, 1},
-       {4, 20, 98, 1},
-       {11, 24, 108, 2}
+    {0, 16, 96, 1},
+    {4, 20, 98, 1},
+    {11, 24, 108, 2}
 };
 
 static const char gLineStrings[] = 
-       "x1\0"
-       "x2\0"
-       "y1\0"
-       "y2"
+    "x1\0"
+    "x2\0"
+    "y1\0"
+    "y2"
 ;
 
 static const SkMemberInfo gLineInfo[] = {
-       {0, 24, 98, 1},
-       {3, 28, 98, 1},
-       {6, 32, 98, 1},
-       {9, 36, 98, 1}
+    {0, 24, 98, 1},
+    {3, 28, 98, 1},
+    {6, 32, 98, 1},
+    {9, 36, 98, 1}
 };
 
 static const char gLineToStrings[] = 
-       "x\0"
-       "y"
+    "x\0"
+    "y"
 ;
 
 static const SkMemberInfo gLineToInfo[] = {
-       {0, 20, 98, 1},
-       {2, 24, 98, 1}
+    {0, 20, 98, 1},
+    {2, 24, 98, 1}
 };
 
 static const char gLinearGradientStrings[] = 
-       "\0"
-       "points"
+    "\0"
+    "points"
 ;
 
 static const SkMemberInfo gLinearGradientInfo[] = {
-       {0, 27, 18, 3},
-       {1, 88, 77, 4}
+    {0, 27, 18, 3},
+    {1, 88, 77, 4}
 };
 
 static const char gMatrixStrings[] = 
-       "matrix\0"
-       "perspectX\0"
-       "perspectY\0"
-       "rotate\0"
-       "scale\0"
-       "scaleX\0"
-       "scaleY\0"
-       "skewX\0"
-       "skewY\0"
-       "translate\0"
-       "translateX\0"
-       "translateY"
+    "matrix\0"
+    "perspectX\0"
+    "perspectY\0"
+    "rotate\0"
+    "scale\0"
+    "scaleX\0"
+    "scaleY\0"
+    "skewX\0"
+    "skewY\0"
+    "translate\0"
+    "translateX\0"
+    "translateY"
 ;
 
 static const SkMemberInfo gDrawMatrixInfo[] = {
-       {0, 16, 119, 98},
-       {7, -1, 67, 98},
-       {17, -2, 67, 98},
-       {27, -3, 67, 98},
-       {34, -4, 67, 98},
-       {40, -5, 67, 98},
-       {47, -6, 67, 98},
-       {54, -7, 67, 98},
-       {60, -8, 67, 98},
-       {66, -9, 67, 77},
-       {76, -10, 67, 98},
-       {87, -11, 67, 98}
+    {0, 16, 119, 98},
+    {7, -1, 67, 98},
+    {17, -2, 67, 98},
+    {27, -3, 67, 98},
+    {34, -4, 67, 98},
+    {40, -5, 67, 98},
+    {47, -6, 67, 98},
+    {54, -7, 67, 98},
+    {60, -8, 67, 98},
+    {66, -9, 67, 77},
+    {76, -10, 67, 98},
+    {87, -11, 67, 98}
 };
 
 static const char gMoveStrings[] = 
-       ""
+    ""
 ;
 
 static const SkMemberInfo gMoveInfo[] = {
-       {0, 1, 18, 4}
+    {0, 1, 18, 4}
 };
 
 static const char gMoveToStrings[] = 
-       "x\0"
-       "y"
+    "x\0"
+    "y"
 ;
 
 static const SkMemberInfo gMoveToInfo[] = {
-       {0, 20, 98, 1},
-       {2, 24, 98, 1}
+    {0, 20, 98, 1},
+    {2, 24, 98, 1}
 };
 
 static const char gMovieStrings[] = 
-       "src"
+    "src"
 ;
 
 static const SkMemberInfo gMovieInfo[] = {
-       {0, 16, 108, 2}
+    {0, 16, 108, 2}
 };
 
 static const char gOvalStrings[] = 
-       ""
+    ""
 ;
 
 static const SkMemberInfo gOvalInfo[] = {
-       {0, 58, 18, 7}
+    {0, 58, 18, 7}
 };
 
 static const char gPaintStrings[] = 
-       "antiAlias\0"
-       "ascent\0"
-       "color\0"
-       "descent\0"
-       "filterType\0"
-       "linearText\0"
-       "maskFilter\0"
-       "measureText\0"
-       "pathEffect\0"
-       "shader\0"
-       "strikeThru\0"
-       "stroke\0"
-       "strokeCap\0"
-       "strokeJoin\0"
-       "strokeMiter\0"
-       "strokeWidth\0"
-       "style\0"
-       "textAlign\0"
-       "textScaleX\0"
-       "textSize\0"
-       "textSkewX\0"
-       "textTracking\0"
-       "typeface\0"
-       "underline\0"
-       "xfermode"
+    "antiAlias\0"
+    "ascent\0"
+    "color\0"
+    "descent\0"
+    "filterType\0"
+    "linearText\0"
+    "maskFilter\0"
+    "measureText\0"
+    "pathEffect\0"
+    "shader\0"
+    "strikeThru\0"
+    "stroke\0"
+    "strokeCap\0"
+    "strokeJoin\0"
+    "strokeMiter\0"
+    "strokeWidth\0"
+    "style\0"
+    "textAlign\0"
+    "textScaleX\0"
+    "textSize\0"
+    "textSkewX\0"
+    "textTracking\0"
+    "typeface\0"
+    "underline\0"
+    "xfermode"
 ;
 
 static const SkMemberInfo gDrawPaintInfo[] = {
-       {0, 16, 26, 1},
-       {10, -1, 67, 98},
-       {17, 20, 31, 1},
-       {23, -2, 67, 98},
-       {31, 24, 47, 1},
-       {42, 28, 26, 1},
-       {53, 32, 62, 1},
-       {64, -1, 66, 98},
-       {76, 36, 76, 1},
-       {87, 40, 102, 1},
-       {94, 44, 26, 1},
-       {105, 48, 26, 1},
-       {112, 52, 27, 1},
-       {122, 56, 58, 1},
-       {133, 60, 98, 1},
-       {145, 64, 98, 1},
-       {157, 68, 109, 1},
-       {163, 72, 9, 1},
-       {173, 76, 98, 1},
-       {184, 80, 98, 1},
-       {193, 84, 98, 1},
-       {203, 88, 98, 1},
-       {216, 92, 120, 1},
-       {225, 96, 26, 1},
-       {235, 100, 121, 1}
+    {0, 16, 26, 1},
+    {10, -1, 67, 98},
+    {17, 20, 31, 1},
+    {23, -2, 67, 98},
+    {31, 24, 47, 1},
+    {42, 28, 26, 1},
+    {53, 32, 62, 1},
+    {64, -1, 66, 98},
+    {76, 36, 76, 1},
+    {87, 40, 102, 1},
+    {94, 44, 26, 1},
+    {105, 48, 26, 1},
+    {112, 52, 27, 1},
+    {122, 56, 58, 1},
+    {133, 60, 98, 1},
+    {145, 64, 98, 1},
+    {157, 68, 109, 1},
+    {163, 72, 9, 1},
+    {173, 76, 98, 1},
+    {184, 80, 98, 1},
+    {193, 84, 98, 1},
+    {203, 88, 98, 1},
+    {216, 92, 120, 1},
+    {225, 96, 26, 1},
+    {235, 100, 121, 1}
 };
 
 static const char gPathStrings[] = 
-       "d\0"
-       "fillType\0"
-       "length"
+    "d\0"
+    "fillType\0"
+    "length"
 ;
 
 static const SkMemberInfo gDrawPathInfo[] = {
-       {0, 52, 108, 2},
-       {2, -1, 67, 46},
-       {11, -2, 67, 98}
+    {0, 52, 108, 2},
+    {2, -1, 67, 46},
+    {11, -2, 67, 98}
 };
 
 static const char gUnknown5Strings[] = 
-       "x\0"
-       "y\0"
-       "z"
+    "x\0"
+    "y\0"
+    "z"
 ;
 
 static const SkMemberInfo gUnknown5Info[] = {
-       {0, 0, 98, 1},
-       {2, 4, 98, 1},
-       {4, 8, 98, 1}
+    {0, 0, 98, 1},
+    {2, 4, 98, 1},
+    {4, 8, 98, 1}
 };
 
 static const char gPointStrings[] = 
-       "x\0"
-       "y"
+    "x\0"
+    "y"
 ;
 
 static const SkMemberInfo gDrawPointInfo[] = {
-       {0, 16, 98, 1},
-       {2, 20, 98, 1}
+    {0, 16, 98, 1},
+    {2, 20, 98, 1}
 };
 
 static const char gPolyToPolyStrings[] = 
-       "destination\0"
-       "source"
+    "destination\0"
+    "source"
 ;
 
 static const SkMemberInfo gPolyToPolyInfo[] = {
-       {0, 24, 80, 1},
-       {12, 20, 80, 1}
+    {0, 24, 80, 1},
+    {12, 20, 80, 1}
 };
 
 static const char gPolygonStrings[] = 
-       ""
+    ""
 ;
 
 static const SkMemberInfo gPolygonInfo[] = {
-       {0, 48, 18, 1}
+    {0, 48, 18, 1}
 };
 
 static const char gPolylineStrings[] = 
-       "points"
+    "points"
 ;
 
 static const SkMemberInfo gPolylineInfo[] = {
-       {0, 88, 119, 98}
+    {0, 88, 119, 98}
 };
 
 static const char gPostStrings[] = 
-       "delay\0"
-       "initialized\0"
-       "mode\0"
-       "sink\0"
-       "target\0"
-       "type"
+    "delay\0"
+    "initialized\0"
+    "mode\0"
+    "sink\0"
+    "target\0"
+    "type"
 ;
 
 static const SkMemberInfo gPostInfo[] = {
-       {0, 16, 71, 1},
-       {6, 20, 26, 1},
-       {18, 24, 45, 1},
-       {23, -1, 67, 108},
-       {28, -2, 67, 108},
-       {35, -3, 67, 108}
+    {0, 16, 71, 1},
+    {6, 20, 26, 1},
+    {18, 24, 45, 1},
+    {23, -1, 67, 108},
+    {28, -2, 67, 108},
+    {35, -3, 67, 108}
 };
 
 static const char gQuadToStrings[] = 
-       "x1\0"
-       "x2\0"
-       "y1\0"
-       "y2"
+    "x1\0"
+    "x2\0"
+    "y1\0"
+    "y2"
 ;
 
 static const SkMemberInfo gQuadToInfo[] = {
-       {0, 20, 98, 1},
-       {3, 28, 98, 1},
-       {6, 24, 98, 1},
-       {9, 32, 98, 1}
+    {0, 20, 98, 1},
+    {3, 28, 98, 1},
+    {6, 24, 98, 1},
+    {9, 32, 98, 1}
 };
 
 static const char gRCubicToStrings[] = 
-       ""
+    ""
 ;
 
 static const SkMemberInfo gRCubicToInfo[] = {
-       {0, 18, 18, 6}
+    {0, 18, 18, 6}
 };
 
 static const char gRLineToStrings[] = 
-       ""
+    ""
 ;
 
 static const SkMemberInfo gRLineToInfo[] = {
-       {0, 35, 18, 2}
+    {0, 35, 18, 2}
 };
 
 static const char gRMoveToStrings[] = 
-       ""
+    ""
 ;
 
 static const SkMemberInfo gRMoveToInfo[] = {
-       {0, 39, 18, 2}
+    {0, 39, 18, 2}
 };
 
 static const char gRQuadToStrings[] = 
-       ""
+    ""
 ;
 
 static const SkMemberInfo gRQuadToInfo[] = {
-       {0, 50, 18, 4}
+    {0, 50, 18, 4}
 };
 
 static const char gRadialGradientStrings[] = 
-       "\0"
-       "center\0"
-       "radius"
+    "\0"
+    "center\0"
+    "radius"
 ;
 
 static const SkMemberInfo gRadialGradientInfo[] = {
-       {0, 27, 18, 3},
-       {1, 88, 77, 2},
-       {8, 96, 98, 1}
+    {0, 27, 18, 3},
+    {1, 88, 77, 2},
+    {8, 96, 98, 1}
 };
 
 static const char gRandomStrings[] = 
-       "blend\0"
-       "max\0"
-       "min\0"
-       "random\0"
-       "seed"
+    "blend\0"
+    "max\0"
+    "min\0"
+    "random\0"
+    "seed"
 ;
 
 static const SkMemberInfo gDisplayRandomInfo[] = {
-       {0, 16, 98, 1},
-       {6, 24, 98, 1},
-       {10, 20, 98, 1},
-       {14, 1, 67, 98},
-       {21, -2, 67, 96}
+    {0, 16, 98, 1},
+    {6, 24, 98, 1},
+    {10, 20, 98, 1},
+    {14, 1, 67, 98},
+    {21, -2, 67, 96}
 };
 
 static const char gRectToRectStrings[] = 
-       "destination\0"
-       "source"
+    "destination\0"
+    "source"
 ;
 
 static const SkMemberInfo gRectToRectInfo[] = {
-       {0, 24, 91, 1},
-       {12, 20, 91, 1}
+    {0, 24, 91, 1},
+    {12, 20, 91, 1}
 };
 
 static const char gRectangleStrings[] = 
-       "bottom\0"
-       "height\0"
-       "left\0"
-       "needsRedraw\0"
-       "right\0"
-       "top\0"
-       "width"
+    "bottom\0"
+    "height\0"
+    "left\0"
+    "needsRedraw\0"
+    "right\0"
+    "top\0"
+    "width"
 ;
 
 static const SkMemberInfo gRectangleInfo[] = {
-       {0, 36, 98, 1},
-       {7, -1, 67, 98},
-       {14, 24, 98, 1},
-       {19, -2, 67, 26},
-       {31, 32, 98, 1},
-       {37, 28, 98, 1},
-       {41, -3, 67, 98}
+    {0, 36, 98, 1},
+    {7, -1, 67, 98},
+    {14, 24, 98, 1},
+    {19, -2, 67, 26},
+    {31, 32, 98, 1},
+    {37, 28, 98, 1},
+    {41, -3, 67, 98}
 };
 
 static const char gRemoveStrings[] = 
-       "offset\0"
-       "where"
+    "offset\0"
+    "where"
 ;
 
 static const SkMemberInfo gRemoveInfo[] = {
-       {0, 20, 96, 1},
-       {7, 28, 37, 1}
+    {0, 20, 96, 1},
+    {7, 28, 37, 1}
 };
 
 static const char gReplaceStrings[] = 
-       ""
+    ""
 ;
 
 static const SkMemberInfo gReplaceInfo[] = {
-       {0, 1, 18, 4}
+    {0, 1, 18, 4}
 };
 
 static const char gRotateStrings[] = 
-       "center\0"
-       "degrees"
+    "center\0"
+    "degrees"
 ;
 
 static const SkMemberInfo gRotateInfo[] = {
-       {0, 24, 77, 2},
-       {7, 20, 98, 1}
+    {0, 24, 77, 2},
+    {7, 20, 98, 1}
 };
 
 static const char gRoundRectStrings[] = 
-       "\0"
-       "rx\0"
-       "ry"
+    "\0"
+    "rx\0"
+    "ry"
 ;
 
 static const SkMemberInfo gRoundRectInfo[] = {
-       {0, 58, 18, 7},
-       {1, 44, 98, 1},
-       {4, 48, 98, 1}
+    {0, 58, 18, 7},
+    {1, 44, 98, 1},
+    {4, 48, 98, 1}
 };
 
 static const char gS32Strings[] = 
-       "value"
+    "value"
 ;
 
 static const SkMemberInfo gS32Info[] = {
-       {0, 16, 96, 1}
+    {0, 16, 96, 1}
 };
 
 static const char gScalarStrings[] = 
-       "value"
+    "value"
 ;
 
 static const SkMemberInfo gScalarInfo[] = {
-       {0, 16, 98, 1}
+    {0, 16, 98, 1}
 };
 
 static const char gScaleStrings[] = 
-       "center\0"
-       "x\0"
-       "y"
+    "center\0"
+    "x\0"
+    "y"
 ;
 
 static const SkMemberInfo gScaleInfo[] = {
-       {0, 28, 77, 2},
-       {7, 20, 98, 1},
-       {9, 24, 98, 1}
+    {0, 28, 77, 2},
+    {7, 20, 98, 1},
+    {9, 24, 98, 1}
 };
 
 static const char gSetStrings[] = 
-       "begin\0"
-       "dur\0"
-       "dynamic\0"
-       "field\0"
-       "formula\0"
-       "reset\0"
-       "target\0"
-       "to"
+    "begin\0"
+    "dur\0"
+    "dynamic\0"
+    "field\0"
+    "formula\0"
+    "reset\0"
+    "target\0"
+    "to"
 ;
 
 static const SkMemberInfo gSetInfo[] = {
-       {0, 16, 71, 1},
-       {6, 36, 71, 1},
-       {10, -1, 67, 26},
-       {18, 40, 108, 2},
-       {24, 48, 40, 2},
-       {32, -3, 67, 26},
-       {38, 68, 40, 2},
-       {45, 76, 40, 2}
+    {0, 16, 71, 1},
+    {6, 36, 71, 1},
+    {10, -1, 67, 26},
+    {18, 40, 108, 2},
+    {24, 48, 40, 2},
+    {32, -3, 67, 26},
+    {38, 68, 40, 2},
+    {45, 76, 40, 2}
 };
 
 static const char gShaderStrings[] = 
-       "matrix\0"
-       "tileMode"
+    "matrix\0"
+    "tileMode"
 ;
 
 static const SkMemberInfo gShaderInfo[] = {
-       {0, 20, 65, 1},
-       {7, 24, 116, 1}
+    {0, 20, 65, 1},
+    {7, 24, 116, 1}
 };
 
 static const char gSkewStrings[] = 
-       "center\0"
-       "x\0"
-       "y"
+    "center\0"
+    "x\0"
+    "y"
 ;
 
 static const SkMemberInfo gSkewInfo[] = {
-       {0, 28, 77, 2},
-       {7, 20, 98, 1},
-       {9, 24, 98, 1}
+    {0, 28, 77, 2},
+    {7, 20, 98, 1},
+    {9, 24, 98, 1}
 };
 
 static const char g3D_CameraStrings[] = 
-       "axis\0"
-       "hackHeight\0"
-       "hackWidth\0"
-       "location\0"
-       "observer\0"
-       "patch\0"
-       "zenith"
+    "axis\0"
+    "hackHeight\0"
+    "hackWidth\0"
+    "location\0"
+    "observer\0"
+    "patch\0"
+    "zenith"
 ;
 
 static const SkMemberInfo g3D_CameraInfo[] = {
-       {0, 36, 106, 3},
-       {5, 20, 98, 1},
-       {16, 16, 98, 1},
-       {26, 24, 106, 3},
-       {35, 60, 106, 3},
-       {44, 108, 105, 1},
-       {50, 48, 106, 3}
+    {0, 36, 106, 3},
+    {5, 20, 98, 1},
+    {16, 16, 98, 1},
+    {26, 24, 106, 3},
+    {35, 60, 106, 3},
+    {44, 108, 105, 1},
+    {50, 48, 106, 3}
 };
 
 static const char g3D_PatchStrings[] = 
-       "origin\0"
-       "rotateDegrees\0"
-       "u\0"
-       "v"
+    "origin\0"
+    "rotateDegrees\0"
+    "u\0"
+    "v"
 ;
 
 static const SkMemberInfo g3D_PatchInfo[] = {
-       {0, 40, 106, 3},
-       {7, -1, 66, 98},
-       {21, 16, 106, 3},
-       {23, 28, 106, 3}
+    {0, 40, 106, 3},
+    {7, -1, 66, 98},
+    {21, 16, 106, 3},
+    {23, 28, 106, 3}
 };
 
 static const char gUnknown6Strings[] = 
-       "x\0"
-       "y\0"
-       "z"
+    "x\0"
+    "y\0"
+    "z"
 ;
 
 static const SkMemberInfo gUnknown6Info[] = {
-       {0, 0, 98, 1},
-       {2, 4, 98, 1},
-       {4, 8, 98, 1}
+    {0, 0, 98, 1},
+    {2, 4, 98, 1},
+    {4, 8, 98, 1}
 };
 
 static const char gSnapshotStrings[] = 
-       "filename\0"
-       "quality\0"
-       "sequence\0"
-       "type"
+    "filename\0"
+    "quality\0"
+    "sequence\0"
+    "type"
 ;
 
 static const SkMemberInfo gSnapshotInfo[] = {
-       {0, 16, 108, 2},
-       {9, 24, 98, 1},
-       {17, 28, 26, 1},
-       {26, 32, 20, 1}
+    {0, 16, 108, 2},
+    {9, 24, 98, 1},
+    {17, 28, 26, 1},
+    {26, 32, 20, 1}
 };
 
 static const char gStringStrings[] = 
-       "length\0"
-       "slice\0"
-       "value"
+    "length\0"
+    "slice\0"
+    "value"
 ;
 
 static const SkMemberInfo gStringInfo[] = {
-       {0, -1, 67, 96},
-       {7, -1, 66, 108},
-       {13, 16, 108, 2}
+    {0, -1, 67, 96},
+    {7, -1, 66, 108},
+    {13, 16, 108, 2}
 };
 
 static const char gTextStrings[] = 
-       "length\0"
-       "text\0"
-       "x\0"
-       "y"
+    "length\0"
+    "text\0"
+    "x\0"
+    "y"
 ;
 
 static const SkMemberInfo gTextInfo[] = {
-       {0, -1, 67, 96},
-       {7, 24, 108, 2},
-       {12, 32, 98, 1},
-       {14, 36, 98, 1}
+    {0, -1, 67, 96},
+    {7, 24, 108, 2},
+    {12, 32, 98, 1},
+    {14, 36, 98, 1}
 };
 
 static const char gTextBoxStrings[] = 
-       "\0"
-       "mode\0"
-       "spacingAdd\0"
-       "spacingAlign\0"
-       "spacingMul\0"
-       "text"
+    "\0"
+    "mode\0"
+    "spacingAdd\0"
+    "spacingAlign\0"
+    "spacingMul\0"
+    "text"
 ;
 
 static const SkMemberInfo gTextBoxInfo[] = {
-       {0, 58, 18, 7},
-       {1, 60, 113, 1},
-       {6, 56, 98, 1},
-       {17, 64, 112, 1},
-       {30, 52, 98, 1},
-       {41, 44, 108, 2}
+    {0, 58, 18, 7},
+    {1, 60, 113, 1},
+    {6, 56, 98, 1},
+    {17, 64, 112, 1},
+    {30, 52, 98, 1},
+    {41, 44, 108, 2}
 };
 
 static const char gTextOnPathStrings[] = 
-       "offset\0"
-       "path\0"
-       "text"
+    "offset\0"
+    "path\0"
+    "text"
 ;
 
 static const SkMemberInfo gTextOnPathInfo[] = {
-       {0, 24, 98, 1},
-       {7, 28, 74, 1},
-       {12, 32, 110, 1}
+    {0, 24, 98, 1},
+    {7, 28, 74, 1},
+    {12, 32, 110, 1}
 };
 
 static const char gTextToPathStrings[] = 
-       "path\0"
-       "text"
+    "path\0"
+    "text"
 ;
 
 static const SkMemberInfo gTextToPathInfo[] = {
-       {0, 16, 74, 1},
-       {5, 20, 110, 1}
+    {0, 16, 74, 1},
+    {5, 20, 110, 1}
 };
 
 static const char gTranslateStrings[] = 
-       "x\0"
-       "y"
+    "x\0"
+    "y"
 ;
 
 static const SkMemberInfo gTranslateInfo[] = {
-       {0, 20, 98, 1},
-       {2, 24, 98, 1}
+    {0, 20, 98, 1},
+    {2, 24, 98, 1}
 };
 
 static const char gTypedArrayStrings[] = 
-       "length\0"
-       "values"
+    "length\0"
+    "values"
 ;
 
 static const SkMemberInfo gTypedArrayInfo[] = {
-       {0, -1, 67, 96},
-       {7, 16, 119, 0}
+    {0, -1, 67, 96},
+    {7, 16, 119, 0}
 };
 
 static const char gTypefaceStrings[] = 
-       "fontName"
+    "fontName"
 ;
 
 static const SkMemberInfo gTypefaceInfo[] = {
-       {0, 20, 108, 2}
+    {0, 20, 108, 2}
 };
 
 static const SkMemberInfo* const gInfoTables[] = {
-       gMathInfo,
-       gAddInfo,
-       gAddCircleInfo,
-       gUnknown1Info,
-       gAddOvalInfo,
-       gAddPathInfo,
-       gAddRectangleInfo,
-       gAddRoundRectInfo,
-       gUnknown2Info,
-       gAnimateFieldInfo,
-       gApplyInfo,
-       gUnknown3Info,
-       gDrawBitmapInfo,
-       gDrawBitmapShaderInfo,
-       gDrawBlurInfo,
-       gDisplayBoundsInfo,
-       gDrawClipInfo,
-       gDrawColorInfo,
-       gCubicToInfo,
-       gDashInfo,
-       gDataInfo,
-       gDiscreteInfo,
-       gDrawToInfo,
-       gDumpInfo,
-       gDrawEmbossInfo,
-       gDisplayEventInfo,
-       gFromPathInfo,
-       gUnknown4Info,
-       gGInfo,
-       gHitClearInfo,
-       gHitTestInfo,
-       gImageInfo,
-       gIncludeInfo,
-       gInputInfo,
-       gLineInfo,
-       gLineToInfo,
-       gLinearGradientInfo,
-       gDrawMatrixInfo,
-       gMoveInfo,
-       gMoveToInfo,
-       gMovieInfo,
-       gOvalInfo,
-       gDrawPaintInfo,
-       gDrawPathInfo,
-       gUnknown5Info,
-       gDrawPointInfo,
-       gPolyToPolyInfo,
-       gPolygonInfo,
-       gPolylineInfo,
-       gPostInfo,
-       gQuadToInfo,
-       gRCubicToInfo,
-       gRLineToInfo,
-       gRMoveToInfo,
-       gRQuadToInfo,
-       gRadialGradientInfo,
-       gDisplayRandomInfo,
-       gRectToRectInfo,
-       gRectangleInfo,
-       gRemoveInfo,
-       gReplaceInfo,
-       gRotateInfo,
-       gRoundRectInfo,
-       gS32Info,
-       gScalarInfo,
-       gScaleInfo,
-       gSetInfo,
-       gShaderInfo,
-       gSkewInfo,
-       g3D_CameraInfo,
-       g3D_PatchInfo,
-       gUnknown6Info,
-       gSnapshotInfo,
-       gStringInfo,
-       gTextInfo,
-       gTextBoxInfo,
-       gTextOnPathInfo,
-       gTextToPathInfo,
-       gTranslateInfo,
-       gTypedArrayInfo,
-       gTypefaceInfo,
+    gMathInfo,
+    gAddInfo,
+    gAddCircleInfo,
+    gUnknown1Info,
+    gAddOvalInfo,
+    gAddPathInfo,
+    gAddRectangleInfo,
+    gAddRoundRectInfo,
+    gUnknown2Info,
+    gAnimateFieldInfo,
+    gApplyInfo,
+    gUnknown3Info,
+    gDrawBitmapInfo,
+    gDrawBitmapShaderInfo,
+    gDrawBlurInfo,
+    gDisplayBoundsInfo,
+    gDrawClipInfo,
+    gDrawColorInfo,
+    gCubicToInfo,
+    gDashInfo,
+    gDataInfo,
+    gDiscreteInfo,
+    gDrawToInfo,
+    gDumpInfo,
+    gDrawEmbossInfo,
+    gDisplayEventInfo,
+    gFromPathInfo,
+    gUnknown4Info,
+    gGInfo,
+    gHitClearInfo,
+    gHitTestInfo,
+    gImageInfo,
+    gIncludeInfo,
+    gInputInfo,
+    gLineInfo,
+    gLineToInfo,
+    gLinearGradientInfo,
+    gDrawMatrixInfo,
+    gMoveInfo,
+    gMoveToInfo,
+    gMovieInfo,
+    gOvalInfo,
+    gDrawPaintInfo,
+    gDrawPathInfo,
+    gUnknown5Info,
+    gDrawPointInfo,
+    gPolyToPolyInfo,
+    gPolygonInfo,
+    gPolylineInfo,
+    gPostInfo,
+    gQuadToInfo,
+    gRCubicToInfo,
+    gRLineToInfo,
+    gRMoveToInfo,
+    gRQuadToInfo,
+    gRadialGradientInfo,
+    gDisplayRandomInfo,
+    gRectToRectInfo,
+    gRectangleInfo,
+    gRemoveInfo,
+    gReplaceInfo,
+    gRotateInfo,
+    gRoundRectInfo,
+    gS32Info,
+    gScalarInfo,
+    gScaleInfo,
+    gSetInfo,
+    gShaderInfo,
+    gSkewInfo,
+    g3D_CameraInfo,
+    g3D_PatchInfo,
+    gUnknown6Info,
+    gSnapshotInfo,
+    gStringInfo,
+    gTextInfo,
+    gTextBoxInfo,
+    gTextOnPathInfo,
+    gTextToPathInfo,
+    gTranslateInfo,
+    gTypedArrayInfo,
+    gTypefaceInfo,
 };
 
 static const unsigned char gInfoCounts[] = {
-       26,4,4,1,1,2,5,3,13,1,13,2,6,3,2,2,2,8,6,
-       2,2,2,2,6,4,8,3,3,2,1,4,3,1,3,4,2,2,12,1,
-       2,1,1,25,3,3,2,2,1,1,6,4,1,1,1,1,3,5,2,7,
-       2,1,2,3,1,1,3,8,2,3,7,4,3,4,3,4,6,3,2,2,
-       2,1
+    26,4,4,1,1,2,5,3,13,1,13,2,6,3,2,2,2,8,6,
+    2,2,2,2,6,4,8,3,3,2,1,4,3,1,3,4,2,2,12,1,
+    2,1,1,25,3,3,2,2,1,1,6,4,1,1,1,1,3,5,2,7,
+    2,1,2,3,1,1,3,8,2,3,7,4,3,4,3,4,6,3,2,2,
+    2,1
 };
 
 static const unsigned char gTypeIDs[] = {
-       1, // Math
-       2, // Add
-       3, // AddCircle
-       4, // Unknown1
-       5, // AddOval
-       6, // AddPath
-       7, // AddRectangle
-       8, // AddRoundRect
-       10, // Unknown2
-       11, // AnimateField
-       12, // Apply
-       17, // Unknown3
-       19, // Bitmap
-       22, // BitmapShader
-       23, // Blur
-       25, // Bounds
-       29, // Clip
-       31, // Color
-       32, // CubicTo
-       33, // Dash
-       34, // Data
-       35, // Discrete
-       38, // DrawTo
-       39, // Dump
-       41, // Emboss
-       42, // Event
-       48, // FromPath
-       51, // Unknown4
-       52, // G
-       53, // HitClear
-       54, // HitTest
-       55, // Image
-       56, // Include
-       57, // Input
-       59, // Line
-       60, // LineTo
-       61, // LinearGradient
-       65, // Matrix
-       68, // Move
-       69, // MoveTo
-       70, // Movie
-       72, // Oval
-       73, // Paint
-       74, // Path
-       77, // Unknown5
-       78, // Point
-       79, // PolyToPoly
-       80, // Polygon
-       81, // Polyline
-       82, // Post
-       83, // QuadTo
-       84, // RCubicTo
-       85, // RLineTo
-       86, // RMoveTo
-       87, // RQuadTo
-       88, // RadialGradient
-       89, // Random
-       90, // RectToRect
-       91, // Rectangle
-       92, // Remove
-       93, // Replace
-       94, // Rotate
-       95, // RoundRect
-       96, // S32
-       98, // Scalar
-       99, // Scale
-       101, // Set
-       102, // Shader
-       103, // Skew
-       104, // 3D_Camera
-       105, // 3D_Patch
-       106, // Unknown6
-       107, // Snapshot
-       108, // String
-       110, // Text
-       111, // TextBox
-       114, // TextOnPath
-       115, // TextToPath
-       117, // Translate
-       119, // TypedArray
-       120, // Typeface
-       
+    1, // Math
+    2, // Add
+    3, // AddCircle
+    4, // Unknown1
+    5, // AddOval
+    6, // AddPath
+    7, // AddRectangle
+    8, // AddRoundRect
+    10, // Unknown2
+    11, // AnimateField
+    12, // Apply
+    17, // Unknown3
+    19, // Bitmap
+    22, // BitmapShader
+    23, // Blur
+    25, // Bounds
+    29, // Clip
+    31, // Color
+    32, // CubicTo
+    33, // Dash
+    34, // Data
+    35, // Discrete
+    38, // DrawTo
+    39, // Dump
+    41, // Emboss
+    42, // Event
+    48, // FromPath
+    51, // Unknown4
+    52, // G
+    53, // HitClear
+    54, // HitTest
+    55, // Image
+    56, // Include
+    57, // Input
+    59, // Line
+    60, // LineTo
+    61, // LinearGradient
+    65, // Matrix
+    68, // Move
+    69, // MoveTo
+    70, // Movie
+    72, // Oval
+    73, // Paint
+    74, // Path
+    77, // Unknown5
+    78, // Point
+    79, // PolyToPoly
+    80, // Polygon
+    81, // Polyline
+    82, // Post
+    83, // QuadTo
+    84, // RCubicTo
+    85, // RLineTo
+    86, // RMoveTo
+    87, // RQuadTo
+    88, // RadialGradient
+    89, // Random
+    90, // RectToRect
+    91, // Rectangle
+    92, // Remove
+    93, // Replace
+    94, // Rotate
+    95, // RoundRect
+    96, // S32
+    98, // Scalar
+    99, // Scale
+    101, // Set
+    102, // Shader
+    103, // Skew
+    104, // 3D_Camera
+    105, // 3D_Patch
+    106, // Unknown6
+    107, // Snapshot
+    108, // String
+    110, // Text
+    111, // TextBox
+    114, // TextOnPath
+    115, // TextToPath
+    117, // Translate
+    119, // TypedArray
+    120, // Typeface
+    
 };
 
 static const int kTypeIDs = 81;
 
 static const char* const gInfoNames[] = {
-       gMathStrings,
-       gAddStrings,
-       gAddCircleStrings,
-       gUnknown1Strings,
-       gAddOvalStrings,
-       gAddPathStrings,
-       gAddRectangleStrings,
-       gAddRoundRectStrings,
-       gUnknown2Strings,
-       gAnimateFieldStrings,
-       gApplyStrings,
-       gUnknown3Strings,
-       gBitmapStrings,
-       gBitmapShaderStrings,
-       gBlurStrings,
-       gBoundsStrings,
-       gClipStrings,
-       gColorStrings,
-       gCubicToStrings,
-       gDashStrings,
-       gDataStrings,
-       gDiscreteStrings,
-       gDrawToStrings,
-       gDumpStrings,
-       gEmbossStrings,
-       gEventStrings,
-       gFromPathStrings,
-       gUnknown4Strings,
-       gGStrings,
-       gHitClearStrings,
-       gHitTestStrings,
-       gImageStrings,
-       gIncludeStrings,
-       gInputStrings,
-       gLineStrings,
-       gLineToStrings,
-       gLinearGradientStrings,
-       gMatrixStrings,
-       gMoveStrings,
-       gMoveToStrings,
-       gMovieStrings,
-       gOvalStrings,
-       gPaintStrings,
-       gPathStrings,
-       gUnknown5Strings,
-       gPointStrings,
-       gPolyToPolyStrings,
-       gPolygonStrings,
-       gPolylineStrings,
-       gPostStrings,
-       gQuadToStrings,
-       gRCubicToStrings,
-       gRLineToStrings,
-       gRMoveToStrings,
-       gRQuadToStrings,
-       gRadialGradientStrings,
-       gRandomStrings,
-       gRectToRectStrings,
-       gRectangleStrings,
-       gRemoveStrings,
-       gReplaceStrings,
-       gRotateStrings,
-       gRoundRectStrings,
-       gS32Strings,
-       gScalarStrings,
-       gScaleStrings,
-       gSetStrings,
-       gShaderStrings,
-       gSkewStrings,
-       g3D_CameraStrings,
-       g3D_PatchStrings,
-       gUnknown6Strings,
-       gSnapshotStrings,
-       gStringStrings,
-       gTextStrings,
-       gTextBoxStrings,
-       gTextOnPathStrings,
-       gTextToPathStrings,
-       gTranslateStrings,
-       gTypedArrayStrings,
-       gTypefaceStrings
+    gMathStrings,
+    gAddStrings,
+    gAddCircleStrings,
+    gUnknown1Strings,
+    gAddOvalStrings,
+    gAddPathStrings,
+    gAddRectangleStrings,
+    gAddRoundRectStrings,
+    gUnknown2Strings,
+    gAnimateFieldStrings,
+    gApplyStrings,
+    gUnknown3Strings,
+    gBitmapStrings,
+    gBitmapShaderStrings,
+    gBlurStrings,
+    gBoundsStrings,
+    gClipStrings,
+    gColorStrings,
+    gCubicToStrings,
+    gDashStrings,
+    gDataStrings,
+    gDiscreteStrings,
+    gDrawToStrings,
+    gDumpStrings,
+    gEmbossStrings,
+    gEventStrings,
+    gFromPathStrings,
+    gUnknown4Strings,
+    gGStrings,
+    gHitClearStrings,
+    gHitTestStrings,
+    gImageStrings,
+    gIncludeStrings,
+    gInputStrings,
+    gLineStrings,
+    gLineToStrings,
+    gLinearGradientStrings,
+    gMatrixStrings,
+    gMoveStrings,
+    gMoveToStrings,
+    gMovieStrings,
+    gOvalStrings,
+    gPaintStrings,
+    gPathStrings,
+    gUnknown5Strings,
+    gPointStrings,
+    gPolyToPolyStrings,
+    gPolygonStrings,
+    gPolylineStrings,
+    gPostStrings,
+    gQuadToStrings,
+    gRCubicToStrings,
+    gRLineToStrings,
+    gRMoveToStrings,
+    gRQuadToStrings,
+    gRadialGradientStrings,
+    gRandomStrings,
+    gRectToRectStrings,
+    gRectangleStrings,
+    gRemoveStrings,
+    gReplaceStrings,
+    gRotateStrings,
+    gRoundRectStrings,
+    gS32Strings,
+    gScalarStrings,
+    gScaleStrings,
+    gSetStrings,
+    gShaderStrings,
+    gSkewStrings,
+    g3D_CameraStrings,
+    g3D_PatchStrings,
+    gUnknown6Strings,
+    gSnapshotStrings,
+    gStringStrings,
+    gTextStrings,
+    gTextBoxStrings,
+    gTextOnPathStrings,
+    gTextToPathStrings,
+    gTranslateStrings,
+    gTypedArrayStrings,
+    gTypefaceStrings
 };
 
 #endif
index 70bb1b4..87d5d7c 100644 (file)
@@ -1,3 +1,20 @@
+/* libs/graphics/animator/SkCondensedRelease.cpp
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #include "SkTypes.h"
 #ifndef SK_BUILD_FOR_UNIX
 #ifdef SK_RELEASE
 // Then execute SkDisplayType::BuildCondensedInfo() to regenerate this file.
 
 static const char gMathStrings[] = 
-       "E\0"
-       "LN10\0"
-       "LN2\0"
-       "LOG10E\0"
-       "LOG2E\0"
-       "PI\0"
-       "SQRT1_2\0"
-       "SQRT2\0"
-       "abs\0"
-       "acos\0"
-       "asin\0"
-       "atan\0"
-       "atan2\0"
-       "ceil\0"
-       "cos\0"
-       "exp\0"
-       "floor\0"
-       "log\0"
-       "max\0"
-       "min\0"
-       "pow\0"
-       "random\0"
-       "round\0"
-       "sin\0"
-       "sqrt\0"
-       "tan"
+    "E\0"
+    "LN10\0"
+    "LN2\0"
+    "LOG10E\0"
+    "LOG2E\0"
+    "PI\0"
+    "SQRT1_2\0"
+    "SQRT2\0"
+    "abs\0"
+    "acos\0"
+    "asin\0"
+    "atan\0"
+    "atan2\0"
+    "ceil\0"
+    "cos\0"
+    "exp\0"
+    "floor\0"
+    "log\0"
+    "max\0"
+    "min\0"
+    "pow\0"
+    "random\0"
+    "round\0"
+    "sin\0"
+    "sqrt\0"
+    "tan"
 ;
 
 static const SkMemberInfo gMathInfo[] = {
-       {0, -1, 67, 98},
-       {2, -2, 67, 98},
-       {7, -3, 67, 98},
-       {11, -4, 67, 98},
-       {18, -5, 67, 98},
-       {24, -6, 67, 98},
-       {27, -7, 67, 98},
-       {35, -8, 67, 98},
-       {41, -1, 66, 98},
-       {45, -2, 66, 98},
-       {50, -3, 66, 98},
-       {55, -4, 66, 98},
-       {60, -5, 66, 98},
-       {66, -6, 66, 98},
-       {71, -7, 66, 98},
-       {75, -8, 66, 98},
-       {79, -9, 66, 98},
-       {85, -10, 66, 98},
-       {89, -11, 66, 98},
-       {93, -12, 66, 98},
-       {97, -13, 66, 98},
-       {101, -14, 66, 98},
-       {108, -15, 66, 98},
-       {114, -16, 66, 98},
-       {118, -17, 66, 98},
-       {123, -18, 66, 98}
+    {0, -1, 67, 98},
+    {2, -2, 67, 98},
+    {7, -3, 67, 98},
+    {11, -4, 67, 98},
+    {18, -5, 67, 98},
+    {24, -6, 67, 98},
+    {27, -7, 67, 98},
+    {35, -8, 67, 98},
+    {41, -1, 66, 98},
+    {45, -2, 66, 98},
+    {50, -3, 66, 98},
+    {55, -4, 66, 98},
+    {60, -5, 66, 98},
+    {66, -6, 66, 98},
+    {71, -7, 66, 98},
+    {75, -8, 66, 98},
+    {79, -9, 66, 98},
+    {85, -10, 66, 98},
+    {89, -11, 66, 98},
+    {93, -12, 66, 98},
+    {97, -13, 66, 98},
+    {101, -14, 66, 98},
+    {108, -15, 66, 98},
+    {114, -16, 66, 98},
+    {118, -17, 66, 98},
+    {123, -18, 66, 98}
 };
 
 static const char gAddStrings[] = 
-       "inPlace\0"
-       "offset\0"
-       "use\0"
-       "where"
+    "inPlace\0"
+    "offset\0"
+    "use\0"
+    "where"
 ;
 
 static const SkMemberInfo gAddInfo[] = {
-       {0, 4, 26, 1},
-       {8, 8, 96, 1},
-       {15, 12, 37, 1},
-       {19, 16, 37, 1}
+    {0, 4, 26, 1},
+    {8, 8, 96, 1},
+    {15, 12, 37, 1},
+    {19, 16, 37, 1}
 };
 
 static const char gAddCircleStrings[] = 
-       "\0"
-       "radius\0"
-       "x\0"
-       "y"
+    "\0"
+    "radius\0"
+    "x\0"
+    "y"
 ;
 
 static const SkMemberInfo gAddCircleInfo[] = {
-       {0, 3, 18, 1},
-       {1, 12, 98, 1},
-       {8, 16, 98, 1},
-       {10, 20, 98, 1}
+    {0, 3, 18, 1},
+    {1, 12, 98, 1},
+    {8, 16, 98, 1},
+    {10, 20, 98, 1}
 };
 
 static const char gUnknown1Strings[] = 
-       "direction"
+    "direction"
 ;
 
 static const SkMemberInfo gUnknown1Info[] = {
-       {0, 8, 75, 1}
+    {0, 8, 75, 1}
 };
 
 static const char gAddOvalStrings[] = 
-       ""
+    ""
 ;
 
 static const SkMemberInfo gAddOvalInfo[] = {
-       {0, 6, 18, 5}
+    {0, 6, 18, 5}
 };
 
 static const char gAddPathStrings[] = 
-       "matrix\0"
-       "path"
+    "matrix\0"
+    "path"
 ;
 
 static const SkMemberInfo gAddPathInfo[] = {
-       {0, 8, 65, 1},
-       {7, 12, 74, 1}
+    {0, 8, 65, 1},
+    {7, 12, 74, 1}
 };
 
 static const char gAddRectangleStrings[] = 
-       "\0"
-       "bottom\0"
-       "left\0"
-       "right\0"
-       "top"
+    "\0"
+    "bottom\0"
+    "left\0"
+    "right\0"
+    "top"
 ;
 
 static const SkMemberInfo gAddRectangleInfo[] = {
-       {0, 3, 18, 1},
-       {1, 24, 98, 1},
-       {8, 12, 98, 1},
-       {13, 20, 98, 1},
-       {19, 16, 98, 1}
+    {0, 3, 18, 1},
+    {1, 24, 98, 1},
+    {8, 12, 98, 1},
+    {13, 20, 98, 1},
+    {19, 16, 98, 1}
 };
 
 static const char gAddRoundRectStrings[] = 
-       "\0"
-       "rx\0"
-       "ry"
+    "\0"
+    "rx\0"
+    "ry"
 ;
 
 static const SkMemberInfo gAddRoundRectInfo[] = {
-       {0, 6, 18, 5},
-       {1, 28, 98, 1},
-       {4, 32, 98, 1}
+    {0, 6, 18, 5},
+    {1, 28, 98, 1},
+    {4, 32, 98, 1}
 };
 
 static const char gUnknown2Strings[] = 
-       "begin\0"
-       "blend\0"
-       "dur\0"
-       "dynamic\0"
-       "field\0"
-       "formula\0"
-       "from\0"
-       "mirror\0"
-       "repeat\0"
-       "reset\0"
-       "target\0"
-       "to\0"
-       "values"
+    "begin\0"
+    "blend\0"
+    "dur\0"
+    "dynamic\0"
+    "field\0"
+    "formula\0"
+    "from\0"
+    "mirror\0"
+    "repeat\0"
+    "reset\0"
+    "target\0"
+    "to\0"
+    "values"
 ;
 
 static const SkMemberInfo gUnknown2Info[] = {
-       {0, 4, 71, 1},
-       {6, 8, 119, 98},
-       {12, 16, 71, 1},
-       {16, -1, 67, 26},
-       {24, 20, 108, 1},
-       {30, 24, 40, 1},
-       {38, 28, 40, 1},
-       {43, -2, 67, 26},
-       {50, 32, 98, 1},
-       {57, -3, 67, 26},
-       {63, 36, 40, 1},
-       {70, 40, 40, 1},
-       {73, -4, 67, 40}
+    {0, 4, 71, 1},
+    {6, 8, 119, 98},
+    {12, 16, 71, 1},
+    {16, -1, 67, 26},
+    {24, 20, 108, 1},
+    {30, 24, 40, 1},
+    {38, 28, 40, 1},
+    {43, -2, 67, 26},
+    {50, 32, 98, 1},
+    {57, -3, 67, 26},
+    {63, 36, 40, 1},
+    {70, 40, 40, 1},
+    {73, -4, 67, 40}
 };
 
 static const char gAnimateFieldStrings[] = 
-       ""
+    ""
 ;
 
 static const SkMemberInfo gAnimateFieldInfo[] = {
-       {0, 8, 18, 13}
+    {0, 8, 18, 13}
 };
 
 static const char gApplyStrings[] = 
-       "animator\0"
-       "begin\0"
-       "dontDraw\0"
-       "dynamicScope\0"
-       "interval\0"
-       "mode\0"
-       "pickup\0"
-       "restore\0"
-       "scope\0"
-       "step\0"
-       "steps\0"
-       "time\0"
-       "transition"
+    "animator\0"
+    "begin\0"
+    "dontDraw\0"
+    "dynamicScope\0"
+    "interval\0"
+    "mode\0"
+    "pickup\0"
+    "restore\0"
+    "scope\0"
+    "step\0"
+    "steps\0"
+    "time\0"
+    "transition"
 ;
 
 static const SkMemberInfo gApplyInfo[] = {
-       {0, -1, 67, 10},
-       {9, 4, 71, 1},
-       {15, 8, 26, 1},
-       {24, 12, 108, 1},
-       {37, 16, 71, 1},
-       {46, 20, 13, 1},
-       {51, 24, 26, 1},
-       {58, 28, 26, 1},
-       {66, 32, 37, 1},
-       {72, -2, 67, 96},
-       {77, 36, 96, 1},
-       {83, -3, 67, 71},
-       {88, 40, 14, 1}
+    {0, -1, 67, 10},
+    {9, 4, 71, 1},
+    {15, 8, 26, 1},
+    {24, 12, 108, 1},
+    {37, 16, 71, 1},
+    {46, 20, 13, 1},
+    {51, 24, 26, 1},
+    {58, 28, 26, 1},
+    {66, 32, 37, 1},
+    {72, -2, 67, 96},
+    {77, 36, 96, 1},
+    {83, -3, 67, 71},
+    {88, 40, 14, 1}
 };
 
 static const char gUnknown3Strings[] = 
-       "x\0"
-       "y"
+    "x\0"
+    "y"
 ;
 
 static const SkMemberInfo gUnknown3Info[] = {
-       {0, 36, 98, 1},
-       {2, 40, 98, 1}
+    {0, 36, 98, 1},
+    {2, 40, 98, 1}
 };
 
 static const char gBitmapStrings[] = 
-       "\0"
-       "erase\0"
-       "format\0"
-       "height\0"
-       "rowBytes\0"
-       "width"
+    "\0"
+    "erase\0"
+    "format\0"
+    "height\0"
+    "rowBytes\0"
+    "width"
 ;
 
 static const SkMemberInfo gDrawBitmapInfo[] = {
-       {0, 11, 18, 2},
-       {1, -1, 67, 15},
-       {7, 44, 21, 1},
-       {14, 48, 96, 1},
-       {21, 52, 96, 1},
-       {30, 56, 96, 1}
+    {0, 11, 18, 2},
+    {1, -1, 67, 15},
+    {7, 44, 21, 1},
+    {14, 48, 96, 1},
+    {21, 52, 96, 1},
+    {30, 56, 96, 1}
 };
 
 static const char gBitmapShaderStrings[] = 
-       "\0"
-       "filterType\0"
-       "image"
+    "\0"
+    "filterType\0"
+    "image"
 ;
 
 static const SkMemberInfo gDrawBitmapShaderInfo[] = {
-       {0, 66, 18, 2},
-       {1, 16, 47, 1},
-       {12, 20, 17, 1}
+    {0, 66, 18, 2},
+    {1, 16, 47, 1},
+    {12, 20, 17, 1}
 };
 
 static const char gBlurStrings[] = 
-       "blurStyle\0"
-       "radius"
+    "blurStyle\0"
+    "radius"
 ;
 
 static const SkMemberInfo gDrawBlurInfo[] = {
-       {0, 12, 63, 1},
-       {10, 8, 98, 1}
+    {0, 12, 63, 1},
+    {10, 8, 98, 1}
 };
 
 static const char gBoundsStrings[] = 
-       "\0"
-       "inval"
+    "\0"
+    "inval"
 ;
 
 static const SkMemberInfo gDisplayBoundsInfo[] = {
-       {0, 57, 18, 7},
-       {1, 32, 26, 1}
+    {0, 57, 18, 7},
+    {1, 32, 26, 1}
 };
 
 static const char gClipStrings[] = 
-       "path\0"
-       "rectangle"
+    "path\0"
+    "rectangle"
 ;
 
 static const SkMemberInfo gDrawClipInfo[] = {
-       {0, 8, 74, 1},
-       {5, 4, 91, 1}
+    {0, 8, 74, 1},
+    {5, 4, 91, 1}
 };
 
 static const char gColorStrings[] = 
-       "alpha\0"
-       "blue\0"
-       "color\0"
-       "green\0"
-       "hue\0"
-       "red\0"
-       "saturation\0"
-       "value"
+    "alpha\0"
+    "blue\0"
+    "color\0"
+    "green\0"
+    "hue\0"
+    "red\0"
+    "saturation\0"
+    "value"
 ;
 
 static const SkMemberInfo gDrawColorInfo[] = {
-       {0, -1, 67, 98},
-       {6, -2, 67, 98},
-       {11, 8, 15, 1},
-       {17, -3, 67, 98},
-       {23, -4, 67, 98},
-       {27, -5, 67, 98},
-       {31, -6, 67, 98},
-       {42, -7, 67, 98}
+    {0, -1, 67, 98},
+    {6, -2, 67, 98},
+    {11, 8, 15, 1},
+    {17, -3, 67, 98},
+    {23, -4, 67, 98},
+    {27, -5, 67, 98},
+    {31, -6, 67, 98},
+    {42, -7, 67, 98}
 };
 
 static const char gCubicToStrings[] = 
-       "x1\0"
-       "x2\0"
-       "x3\0"
-       "y1\0"
-       "y2\0"
-       "y3"
+    "x1\0"
+    "x2\0"
+    "x3\0"
+    "y1\0"
+    "y2\0"
+    "y3"
 ;
 
 static const SkMemberInfo gCubicToInfo[] = {
-       {0, 8, 98, 1},
-       {3, 16, 98, 1},
-       {6, 24, 98, 1},
-       {9, 12, 98, 1},
-       {12, 20, 98, 1},
-       {15, 28, 98, 1}
+    {0, 8, 98, 1},
+    {3, 16, 98, 1},
+    {6, 24, 98, 1},
+    {9, 12, 98, 1},
+    {12, 20, 98, 1},
+    {15, 28, 98, 1}
 };
 
 static const char gDashStrings[] = 
-       "intervals\0"
-       "phase"
+    "intervals\0"
+    "phase"
 ;
 
 static const SkMemberInfo gDashInfo[] = {
-       {0, 8, 119, 98},
-       {10, 16, 98, 1}
+    {0, 8, 119, 98},
+    {10, 16, 98, 1}
 };
 
 static const char gDataStrings[] = 
-       "\0"
-       "name"
+    "\0"
+    "name"
 ;
 
 static const SkMemberInfo gDataInfo[] = {
-       {0, 32, 18, 3},
-       {1, 16, 108, 1}
+    {0, 32, 18, 3},
+    {1, 16, 108, 1}
 };
 
 static const char gDiscreteStrings[] = 
-       "deviation\0"
-       "segLength"
+    "deviation\0"
+    "segLength"
 ;
 
 static const SkMemberInfo gDiscreteInfo[] = {
-       {0, 8, 98, 1},
-       {10, 12, 98, 1}
+    {0, 8, 98, 1},
+    {10, 12, 98, 1}
 };
 
 static const char gDrawToStrings[] = 
-       "drawOnce\0"
-       "use"
+    "drawOnce\0"
+    "use"
 ;
 
 static const SkMemberInfo gDrawToInfo[] = {
-       {0, 36, 26, 1},
-       {9, 40, 19, 1}
+    {0, 36, 26, 1},
+    {9, 40, 19, 1}
 };
 
 static const char gEmbossStrings[] = 
-       "ambient\0"
-       "direction\0"
-       "radius\0"
-       "specular"
+    "ambient\0"
+    "direction\0"
+    "radius\0"
+    "specular"
 ;
 
 static const SkMemberInfo gDrawEmbossInfo[] = {
-       {0, -1, 67, 98},
-       {8, 8, 119, 98},
-       {18, 16, 98, 1},
-       {25, -2, 67, 98}
+    {0, -1, 67, 98},
+    {8, 8, 119, 98},
+    {18, 16, 98, 1},
+    {25, -2, 67, 98}
 };
 
 static const char gEventStrings[] = 
-       "code\0"
-       "disable\0"
-       "key\0"
-       "keys\0"
-       "kind\0"
-       "target\0"
-       "x\0"
-       "y"
+    "code\0"
+    "disable\0"
+    "key\0"
+    "keys\0"
+    "kind\0"
+    "target\0"
+    "x\0"
+    "y"
 ;
 
 static const SkMemberInfo gDisplayEventInfo[] = {
-       {0, 4, 43, 1},
-       {5, 8, 26, 1},
-       {13, -1, 67, 108},
-       {17, -2, 67, 108},
-       {22, 12, 44, 1},
-       {27, 16, 108, 1},
-       {34, 20, 98, 1},
-       {36, 24, 98, 1}
+    {0, 4, 43, 1},
+    {5, 8, 26, 1},
+    {13, -1, 67, 108},
+    {17, -2, 67, 108},
+    {22, 12, 44, 1},
+    {27, 16, 108, 1},
+    {34, 20, 98, 1},
+    {36, 24, 98, 1}
 };
 
 static const char gFromPathStrings[] = 
-       "mode\0"
-       "offset\0"
-       "path"
+    "mode\0"
+    "offset\0"
+    "path"
 ;
 
 static const SkMemberInfo gFromPathInfo[] = {
-       {0, 8, 49, 1},
-       {5, 12, 98, 1},
-       {12, 16, 74, 1}
+    {0, 8, 49, 1},
+    {5, 12, 98, 1},
+    {12, 16, 74, 1}
 };
 
 static const char gUnknown4Strings[] = 
-       "\0"
-       "offsets\0"
-       "unitMapper"
+    "\0"
+    "offsets\0"
+    "unitMapper"
 ;
 
 static const SkMemberInfo gUnknown4Info[] = {
-       {0, 66, 18, 2},
-       {1, 16, 119, 98},
-       {9, 24, 108, 1}
+    {0, 66, 18, 2},
+    {1, 16, 119, 98},
+    {9, 24, 108, 1}
 };
 
 static const char gGStrings[] = 
-       "condition\0"
-       "enableCondition"
+    "condition\0"
+    "enableCondition"
 ;
 
 static const SkMemberInfo gGInfo[] = {
-       {0, 4, 40, 1},
-       {10, 8, 40, 1}
+    {0, 4, 40, 1},
+    {10, 8, 40, 1}
 };
 
 static const char gHitClearStrings[] = 
-       "targets"
+    "targets"
 ;
 
 static const SkMemberInfo gHitClearInfo[] = {
-       {0, 4, 119, 36}
+    {0, 4, 119, 36}
 };
 
 static const char gHitTestStrings[] = 
-       "bullets\0"
-       "hits\0"
-       "targets\0"
-       "value"
+    "bullets\0"
+    "hits\0"
+    "targets\0"
+    "value"
 ;
 
 static const SkMemberInfo gHitTestInfo[] = {
-       {0, 4, 119, 36},
-       {8, 12, 119, 96},
-       {13, 20, 119, 36},
-       {21, 28, 26, 1}
+    {0, 4, 119, 36},
+    {8, 12, 119, 96},
+    {13, 20, 119, 36},
+    {21, 28, 26, 1}
 };
 
 static const char gImageStrings[] = 
-       "\0"
-       "base64\0"
-       "src"
+    "\0"
+    "base64\0"
+    "src"
 ;
 
 static const SkMemberInfo gImageInfo[] = {
-       {0, 11, 18, 2},
-       {1, 44, 16, 2},
-       {8, 52, 108, 1}
+    {0, 11, 18, 2},
+    {1, 44, 16, 2},
+    {8, 52, 108, 1}
 };
 
 static const char gIncludeStrings[] = 
-       "src"
+    "src"
 ;
 
 static const SkMemberInfo gIncludeInfo[] = {
-       {0, 4, 108, 1}
+    {0, 4, 108, 1}
 };
 
 static const char gInputStrings[] = 
-       "s32\0"
-       "scalar\0"
-       "string"
+    "s32\0"
+    "scalar\0"
+    "string"
 ;
 
 static const SkMemberInfo gInputInfo[] = {
-       {0, 4, 96, 1},
-       {4, 8, 98, 1},
-       {11, 12, 108, 1}
+    {0, 4, 96, 1},
+    {4, 8, 98, 1},
+    {11, 12, 108, 1}
 };
 
 static const char gLineStrings[] = 
-       "x1\0"
-       "x2\0"
-       "y1\0"
-       "y2"
+    "x1\0"
+    "x2\0"
+    "y1\0"
+    "y2"
 ;
 
 static const SkMemberInfo gLineInfo[] = {
-       {0, 12, 98, 1},
-       {3, 16, 98, 1},
-       {6, 20, 98, 1},
-       {9, 24, 98, 1}
+    {0, 12, 98, 1},
+    {3, 16, 98, 1},
+    {6, 20, 98, 1},
+    {9, 24, 98, 1}
 };
 
 static const char gLineToStrings[] = 
-       "x\0"
-       "y"
+    "x\0"
+    "y"
 ;
 
 static const SkMemberInfo gLineToInfo[] = {
-       {0, 8, 98, 1},
-       {2, 12, 98, 1}
+    {0, 8, 98, 1},
+    {2, 12, 98, 1}
 };
 
 static const char gLinearGradientStrings[] = 
-       "\0"
-       "points"
+    "\0"
+    "points"
 ;
 
 static const SkMemberInfo gLinearGradientInfo[] = {
-       {0, 26, 18, 3},
-       {1, 48, 77, 4}
+    {0, 26, 18, 3},
+    {1, 48, 77, 4}
 };
 
 static const char gMatrixStrings[] = 
-       "matrix\0"
-       "perspectX\0"
-       "perspectY\0"
-       "rotate\0"
-       "scale\0"
-       "scaleX\0"
-       "scaleY\0"
-       "skewX\0"
-       "skewY\0"
-       "translate\0"
-       "translateX\0"
-       "translateY"
+    "matrix\0"
+    "perspectX\0"
+    "perspectY\0"
+    "rotate\0"
+    "scale\0"
+    "scaleX\0"
+    "scaleY\0"
+    "skewX\0"
+    "skewY\0"
+    "translate\0"
+    "translateX\0"
+    "translateY"
 ;
 
 static const SkMemberInfo gDrawMatrixInfo[] = {
-       {0, 4, 119, 98},
-       {7, -1, 67, 98},
-       {17, -2, 67, 98},
-       {27, -3, 67, 98},
-       {34, -4, 67, 98},
-       {40, -5, 67, 98},
-       {47, -6, 67, 98},
-       {54, -7, 67, 98},
-       {60, -8, 67, 98},
-       {66, -9, 67, 77},
-       {76, -10, 67, 98},
-       {87, -11, 67, 98}
+    {0, 4, 119, 98},
+    {7, -1, 67, 98},
+    {17, -2, 67, 98},
+    {27, -3, 67, 98},
+    {34, -4, 67, 98},
+    {40, -5, 67, 98},
+    {47, -6, 67, 98},
+    {54, -7, 67, 98},
+    {60, -8, 67, 98},
+    {66, -9, 67, 77},
+    {76, -10, 67, 98},
+    {87, -11, 67, 98}
 };
 
 static const char gMoveStrings[] = 
-       ""
+    ""
 ;
 
 static const SkMemberInfo gMoveInfo[] = {
-       {0, 1, 18, 4}
+    {0, 1, 18, 4}
 };
 
 static const char gMoveToStrings[] = 
-       "x\0"
-       "y"
+    "x\0"
+    "y"
 ;
 
 static const SkMemberInfo gMoveToInfo[] = {
-       {0, 8, 98, 1},
-       {2, 12, 98, 1}
+    {0, 8, 98, 1},
+    {2, 12, 98, 1}
 };
 
 static const char gMovieStrings[] = 
-       "src"
+    "src"
 ;
 
 static const SkMemberInfo gMovieInfo[] = {
-       {0, 4, 108, 1}
+    {0, 4, 108, 1}
 };
 
 static const char gOvalStrings[] = 
-       ""
+    ""
 ;
 
 static const SkMemberInfo gOvalInfo[] = {
-       {0, 57, 18, 7}
+    {0, 57, 18, 7}
 };
 
 static const char gPaintStrings[] = 
-       "antiAlias\0"
-       "ascent\0"
-       "color\0"
-       "descent\0"
-       "filterType\0"
-       "linearText\0"
-       "maskFilter\0"
-       "measureText\0"
-       "pathEffect\0"
-       "shader\0"
-       "strikeThru\0"
-       "stroke\0"
-       "strokeCap\0"
-       "strokeJoin\0"
-       "strokeMiter\0"
-       "strokeWidth\0"
-       "style\0"
-       "textAlign\0"
-       "textScaleX\0"
-       "textSize\0"
-       "textSkewX\0"
-       "textTracking\0"
-       "typeface\0"
-       "underline\0"
-       "xfermode"
+    "antiAlias\0"
+    "ascent\0"
+    "color\0"
+    "descent\0"
+    "filterType\0"
+    "linearText\0"
+    "maskFilter\0"
+    "measureText\0"
+    "pathEffect\0"
+    "shader\0"
+    "strikeThru\0"
+    "stroke\0"
+    "strokeCap\0"
+    "strokeJoin\0"
+    "strokeMiter\0"
+    "strokeWidth\0"
+    "style\0"
+    "textAlign\0"
+    "textScaleX\0"
+    "textSize\0"
+    "textSkewX\0"
+    "textTracking\0"
+    "typeface\0"
+    "underline\0"
+    "xfermode"
 ;
 
 static const SkMemberInfo gDrawPaintInfo[] = {
-       {0, 4, 26, 1},
-       {10, -1, 67, 98},
-       {17, 8, 31, 1},
-       {23, -2, 67, 98},
-       {31, 12, 47, 1},
-       {42, 16, 26, 1},
-       {53, 20, 62, 1},
-       {64, -1, 66, 98},
-       {76, 24, 76, 1},
-       {87, 28, 102, 1},
-       {94, 32, 26, 1},
-       {105, 36, 26, 1},
-       {112, 40, 27, 1},
-       {122, 44, 58, 1},
-       {133, 48, 98, 1},
-       {145, 52, 98, 1},
-       {157, 56, 109, 1},
-       {163, 60, 9, 1},
-       {173, 64, 98, 1},
-       {184, 68, 98, 1},
-       {193, 72, 98, 1},
-       {203, 76, 98, 1},
-       {216, 80, 120, 1},
-       {225, 84, 26, 1},
-       {235, 88, 121, 1}
+    {0, 4, 26, 1},
+    {10, -1, 67, 98},
+    {17, 8, 31, 1},
+    {23, -2, 67, 98},
+    {31, 12, 47, 1},
+    {42, 16, 26, 1},
+    {53, 20, 62, 1},
+    {64, -1, 66, 98},
+    {76, 24, 76, 1},
+    {87, 28, 102, 1},
+    {94, 32, 26, 1},
+    {105, 36, 26, 1},
+    {112, 40, 27, 1},
+    {122, 44, 58, 1},
+    {133, 48, 98, 1},
+    {145, 52, 98, 1},
+    {157, 56, 109, 1},
+    {163, 60, 9, 1},
+    {173, 64, 98, 1},
+    {184, 68, 98, 1},
+    {193, 72, 98, 1},
+    {203, 76, 98, 1},
+    {216, 80, 120, 1},
+    {225, 84, 26, 1},
+    {235, 88, 121, 1}
 };
 
 static const char gPathStrings[] = 
-       "d\0"
-       "fillType\0"
-       "length"
+    "d\0"
+    "fillType\0"
+    "length"
 ;
 
 static const SkMemberInfo gDrawPathInfo[] = {
-       {0, 32, 108, 1},
-       {2, -1, 67, 46},
-       {11, -2, 67, 98}
+    {0, 32, 108, 1},
+    {2, -1, 67, 46},
+    {11, -2, 67, 98}
 };
 
 static const char gUnknown5Strings[] = 
-       "x\0"
-       "y\0"
-       "z"
+    "x\0"
+    "y\0"
+    "z"
 ;
 
 static const SkMemberInfo gUnknown5Info[] = {
-       {0, 0, 98, 1},
-       {2, 4, 98, 1},
-       {4, 8, 98, 1}
+    {0, 0, 98, 1},
+    {2, 4, 98, 1},
+    {4, 8, 98, 1}
 };
 
 static const char gPointStrings[] = 
-       "x\0"
-       "y"
+    "x\0"
+    "y"
 ;
 
 static const SkMemberInfo gDrawPointInfo[] = {
-       {0, 4, 98, 1},
-       {2, 8, 98, 1}
+    {0, 4, 98, 1},
+    {2, 8, 98, 1}
 };
 
 static const char gPolyToPolyStrings[] = 
-       "destination\0"
-       "source"
+    "destination\0"
+    "source"
 ;
 
 static const SkMemberInfo gPolyToPolyInfo[] = {
-       {0, 12, 80, 1},
-       {12, 8, 80, 1}
+    {0, 12, 80, 1},
+    {12, 8, 80, 1}
 };
 
 static const char gPolygonStrings[] = 
-       ""
+    ""
 ;
 
 static const SkMemberInfo gPolygonInfo[] = {
-       {0, 47, 18, 1}
+    {0, 47, 18, 1}
 };
 
 static const char gPolylineStrings[] = 
-       "points"
+    "points"
 ;
 
 static const SkMemberInfo gPolylineInfo[] = {
-       {0, 56, 119, 98}
+    {0, 56, 119, 98}
 };
 
 static const char gPostStrings[] = 
-       "delay\0"
-       "initialized\0"
-       "mode\0"
-       "sink\0"
-       "target\0"
-       "type"
+    "delay\0"
+    "initialized\0"
+    "mode\0"
+    "sink\0"
+    "target\0"
+    "type"
 ;
 
 static const SkMemberInfo gPostInfo[] = {
-       {0, 4, 71, 1},
-       {6, 8, 26, 1},
-       {18, 12, 45, 1},
-       {23, -1, 67, 108},
-       {28, -2, 67, 108},
-       {35, -3, 67, 108}
+    {0, 4, 71, 1},
+    {6, 8, 26, 1},
+    {18, 12, 45, 1},
+    {23, -1, 67, 108},
+    {28, -2, 67, 108},
+    {35, -3, 67, 108}
 };
 
 static const char gQuadToStrings[] = 
-       "x1\0"
-       "x2\0"
-       "y1\0"
-       "y2"
+    "x1\0"
+    "x2\0"
+    "y1\0"
+    "y2"
 ;
 
 static const SkMemberInfo gQuadToInfo[] = {
-       {0, 8, 98, 1},
-       {3, 16, 98, 1},
-       {6, 12, 98, 1},
-       {9, 20, 98, 1}
+    {0, 8, 98, 1},
+    {3, 16, 98, 1},
+    {6, 12, 98, 1},
+    {9, 20, 98, 1}
 };
 
 static const char gRCubicToStrings[] = 
-       ""
+    ""
 ;
 
 static const SkMemberInfo gRCubicToInfo[] = {
-       {0, 18, 18, 6}
+    {0, 18, 18, 6}
 };
 
 static const char gRLineToStrings[] = 
-       ""
+    ""
 ;
 
 static const SkMemberInfo gRLineToInfo[] = {
-       {0, 34, 18, 2}
+    {0, 34, 18, 2}
 };
 
 static const char gRMoveToStrings[] = 
-       ""
+    ""
 ;
 
 static const SkMemberInfo gRMoveToInfo[] = {
-       {0, 38, 18, 2}
+    {0, 38, 18, 2}
 };
 
 static const char gRQuadToStrings[] = 
-       ""
+    ""
 ;
 
 static const SkMemberInfo gRQuadToInfo[] = {
-       {0, 49, 18, 4}
+    {0, 49, 18, 4}
 };
 
 static const char gRadialGradientStrings[] = 
-       "\0"
-       "center\0"
-       "radius"
+    "\0"
+    "center\0"
+    "radius"
 ;
 
 static const SkMemberInfo gRadialGradientInfo[] = {
-       {0, 26, 18, 3},
-       {1, 48, 77, 2},
-       {8, 56, 98, 1}
+    {0, 26, 18, 3},
+    {1, 48, 77, 2},
+    {8, 56, 98, 1}
 };
 
 static const char gRandomStrings[] = 
-       "blend\0"
-       "max\0"
-       "min\0"
-       "random\0"
-       "seed"
+    "blend\0"
+    "max\0"
+    "min\0"
+    "random\0"
+    "seed"
 ;
 
 static const SkMemberInfo gDisplayRandomInfo[] = {
-       {0, 4, 98, 1},
-       {6, 12, 98, 1},
-       {10, 8, 98, 1},
-       {14, 1, 67, 98},
-       {21, -2, 67, 96}
+    {0, 4, 98, 1},
+    {6, 12, 98, 1},
+    {10, 8, 98, 1},
+    {14, 1, 67, 98},
+    {21, -2, 67, 96}
 };
 
 static const char gRectToRectStrings[] = 
-       "destination\0"
-       "source"
+    "destination\0"
+    "source"
 ;
 
 static const SkMemberInfo gRectToRectInfo[] = {
-       {0, 12, 91, 1},
-       {12, 8, 91, 1}
+    {0, 12, 91, 1},
+    {12, 8, 91, 1}
 };
 
 static const char gRectangleStrings[] = 
-       "bottom\0"
-       "height\0"
-       "left\0"
-       "needsRedraw\0"
-       "right\0"
-       "top\0"
-       "width"
+    "bottom\0"
+    "height\0"
+    "left\0"
+    "needsRedraw\0"
+    "right\0"
+    "top\0"
+    "width"
 ;
 
 static const SkMemberInfo gRectangleInfo[] = {
-       {0, 24, 98, 1},
-       {7, -1, 67, 98},
-       {14, 12, 98, 1},
-       {19, -2, 67, 26},
-       {31, 20, 98, 1},
-       {37, 16, 98, 1},
-       {41, -3, 67, 98}
+    {0, 24, 98, 1},
+    {7, -1, 67, 98},
+    {14, 12, 98, 1},
+    {19, -2, 67, 26},
+    {31, 20, 98, 1},
+    {37, 16, 98, 1},
+    {41, -3, 67, 98}
 };
 
 static const char gRemoveStrings[] = 
-       "offset\0"
-       "where"
+    "offset\0"
+    "where"
 ;
 
 static const SkMemberInfo gRemoveInfo[] = {
-       {0, 8, 96, 1},
-       {7, 16, 37, 1}
+    {0, 8, 96, 1},
+    {7, 16, 37, 1}
 };
 
 static const char gReplaceStrings[] = 
-       ""
+    ""
 ;
 
 static const SkMemberInfo gReplaceInfo[] = {
-       {0, 1, 18, 4}
+    {0, 1, 18, 4}
 };
 
 static const char gRotateStrings[] = 
-       "center\0"
-       "degrees"
+    "center\0"
+    "degrees"
 ;
 
 static const SkMemberInfo gRotateInfo[] = {
-       {0, 12, 77, 2},
-       {7, 8, 98, 1}
+    {0, 12, 77, 2},
+    {7, 8, 98, 1}
 };
 
 static const char gRoundRectStrings[] = 
-       "\0"
-       "rx\0"
-       "ry"
+    "\0"
+    "rx\0"
+    "ry"
 ;
 
 static const SkMemberInfo gRoundRectInfo[] = {
-       {0, 57, 18, 7},
-       {1, 32, 98, 1},
-       {4, 36, 98, 1}
+    {0, 57, 18, 7},
+    {1, 32, 98, 1},
+    {4, 36, 98, 1}
 };
 
 static const char gS32Strings[] = 
-       "value"
+    "value"
 ;
 
 static const SkMemberInfo gS32Info[] = {
-       {0, 4, 96, 1}
+    {0, 4, 96, 1}
 };
 
 static const char gScalarStrings[] = 
-       "value"
+    "value"
 ;
 
 static const SkMemberInfo gScalarInfo[] = {
-       {0, 4, 98, 1}
+    {0, 4, 98, 1}
 };
 
 static const char gScaleStrings[] = 
-       "center\0"
-       "x\0"
-       "y"
+    "center\0"
+    "x\0"
+    "y"
 ;
 
 static const SkMemberInfo gScaleInfo[] = {
-       {0, 16, 77, 2},
-       {7, 8, 98, 1},
-       {9, 12, 98, 1}
+    {0, 16, 77, 2},
+    {7, 8, 98, 1},
+    {9, 12, 98, 1}
 };
 
 static const char gSetStrings[] = 
-       "begin\0"
-       "dur\0"
-       "dynamic\0"
-       "field\0"
-       "formula\0"
-       "reset\0"
-       "target\0"
-       "to"
+    "begin\0"
+    "dur\0"
+    "dynamic\0"
+    "field\0"
+    "formula\0"
+    "reset\0"
+    "target\0"
+    "to"
 ;
 
 static const SkMemberInfo gSetInfo[] = {
-       {0, 4, 71, 1},
-       {6, 16, 71, 1},
-       {10, -1, 67, 26},
-       {18, 20, 108, 1},
-       {24, 24, 40, 1},
-       {32, -3, 67, 26},
-       {38, 36, 40, 1},
-       {45, 40, 40, 1}
+    {0, 4, 71, 1},
+    {6, 16, 71, 1},
+    {10, -1, 67, 26},
+    {18, 20, 108, 1},
+    {24, 24, 40, 1},
+    {32, -3, 67, 26},
+    {38, 36, 40, 1},
+    {45, 40, 40, 1}
 };
 
 static const char gShaderStrings[] = 
-       "matrix\0"
-       "tileMode"
+    "matrix\0"
+    "tileMode"
 ;
 
 static const SkMemberInfo gShaderInfo[] = {
-       {0, 8, 65, 1},
-       {7, 12, 116, 1}
+    {0, 8, 65, 1},
+    {7, 12, 116, 1}
 };
 
 static const char gSkewStrings[] = 
-       "center\0"
-       "x\0"
-       "y"
+    "center\0"
+    "x\0"
+    "y"
 ;
 
 static const SkMemberInfo gSkewInfo[] = {
-       {0, 16, 77, 2},
-       {7, 8, 98, 1},
-       {9, 12, 98, 1}
+    {0, 16, 77, 2},
+    {7, 8, 98, 1},
+    {9, 12, 98, 1}
 };
 
 static const char g3D_CameraStrings[] = 
-       "axis\0"
-       "hackHeight\0"
-       "hackWidth\0"
-       "location\0"
-       "observer\0"
-       "patch\0"
-       "zenith"
+    "axis\0"
+    "hackHeight\0"
+    "hackWidth\0"
+    "location\0"
+    "observer\0"
+    "patch\0"
+    "zenith"
 ;
 
 static const SkMemberInfo g3D_CameraInfo[] = {
-       {0, 24, 106, 3},
-       {5, 8, 98, 1},
-       {16, 4, 98, 1},
-       {26, 12, 106, 3},
-       {35, 48, 106, 3},
-       {44, 96, 105, 1},
-       {50, 36, 106, 3}
+    {0, 24, 106, 3},
+    {5, 8, 98, 1},
+    {16, 4, 98, 1},
+    {26, 12, 106, 3},
+    {35, 48, 106, 3},
+    {44, 96, 105, 1},
+    {50, 36, 106, 3}
 };
 
 static const char g3D_PatchStrings[] = 
-       "origin\0"
-       "rotateDegrees\0"
-       "u\0"
-       "v"
+    "origin\0"
+    "rotateDegrees\0"
+    "u\0"
+    "v"
 ;
 
 static const SkMemberInfo g3D_PatchInfo[] = {
-       {0, 28, 106, 3},
-       {7, -1, 66, 98},
-       {21, 4, 106, 3},
-       {23, 16, 106, 3}
+    {0, 28, 106, 3},
+    {7, -1, 66, 98},
+    {21, 4, 106, 3},
+    {23, 16, 106, 3}
 };
 
 static const char gUnknown6Strings[] = 
-       "x\0"
-       "y\0"
-       "z"
+    "x\0"
+    "y\0"
+    "z"
 ;
 
 static const SkMemberInfo gUnknown6Info[] = {
-       {0, 0, 98, 1},
-       {2, 4, 98, 1},
-       {4, 8, 98, 1}
+    {0, 0, 98, 1},
+    {2, 4, 98, 1},
+    {4, 8, 98, 1}
 };
 
 static const char gSnapshotStrings[] = 
-       "filename\0"
-       "quality\0"
-       "sequence\0"
-       "type"
+    "filename\0"
+    "quality\0"
+    "sequence\0"
+    "type"
 ;
 
 static const SkMemberInfo gSnapshotInfo[] = {
-       {0, 4, 108, 1},
-       {9, 8, 98, 1},
-       {17, 12, 26, 1},
-       {26, 16, 20, 1}
+    {0, 4, 108, 1},
+    {9, 8, 98, 1},
+    {17, 12, 26, 1},
+    {26, 16, 20, 1}
 };
 
 static const char gStringStrings[] = 
-       "length\0"
-       "slice\0"
-       "value"
+    "length\0"
+    "slice\0"
+    "value"
 ;
 
 static const SkMemberInfo gStringInfo[] = {
-       {0, -1, 67, 96},
-       {7, -1, 66, 108},
-       {13, 4, 108, 1}
+    {0, -1, 67, 96},
+    {7, -1, 66, 108},
+    {13, 4, 108, 1}
 };
 
 static const char gTextStrings[] = 
-       "length\0"
-       "text\0"
-       "x\0"
-       "y"
+    "length\0"
+    "text\0"
+    "x\0"
+    "y"
 ;
 
 static const SkMemberInfo gTextInfo[] = {
-       {0, -1, 67, 96},
-       {7, 12, 108, 1},
-       {12, 16, 98, 1},
-       {14, 20, 98, 1}
+    {0, -1, 67, 96},
+    {7, 12, 108, 1},
+    {12, 16, 98, 1},
+    {14, 20, 98, 1}
 };
 
 static const char gTextBoxStrings[] = 
-       "\0"
-       "mode\0"
-       "spacingAdd\0"
-       "spacingAlign\0"
-       "spacingMul\0"
-       "text"
+    "\0"
+    "mode\0"
+    "spacingAdd\0"
+    "spacingAlign\0"
+    "spacingMul\0"
+    "text"
 ;
 
 static const SkMemberInfo gTextBoxInfo[] = {
-       {0, 57, 18, 7},
-       {1, 44, 113, 1},
-       {6, 40, 98, 1},
-       {17, 48, 112, 1},
-       {30, 36, 98, 1},
-       {41, 32, 108, 1}
+    {0, 57, 18, 7},
+    {1, 44, 113, 1},
+    {6, 40, 98, 1},
+    {17, 48, 112, 1},
+    {30, 36, 98, 1},
+    {41, 32, 108, 1}
 };
 
 static const char gTextOnPathStrings[] = 
-       "offset\0"
-       "path\0"
-       "text"
+    "offset\0"
+    "path\0"
+    "text"
 ;
 
 static const SkMemberInfo gTextOnPathInfo[] = {
-       {0, 12, 98, 1},
-       {7, 16, 74, 1},
-       {12, 20, 110, 1}
+    {0, 12, 98, 1},
+    {7, 16, 74, 1},
+    {12, 20, 110, 1}
 };
 
 static const char gTextToPathStrings[] = 
-       "path\0"
-       "text"
+    "path\0"
+    "text"
 ;
 
 static const SkMemberInfo gTextToPathInfo[] = {
-       {0, 4, 74, 1},
-       {5, 8, 110, 1}
+    {0, 4, 74, 1},
+    {5, 8, 110, 1}
 };
 
 static const char gTranslateStrings[] = 
-       "x\0"
-       "y"
+    "x\0"
+    "y"
 ;
 
 static const SkMemberInfo gTranslateInfo[] = {
-       {0, 8, 98, 1},
-       {2, 12, 98, 1}
+    {0, 8, 98, 1},
+    {2, 12, 98, 1}
 };
 
 static const char gTypedArrayStrings[] = 
-       "length\0"
-       "values"
+    "length\0"
+    "values"
 ;
 
 static const SkMemberInfo gTypedArrayInfo[] = {
-       {0, -1, 67, 96},
-       {7, 4, 119, 0}
+    {0, -1, 67, 96},
+    {7, 4, 119, 0}
 };
 
 static const char gTypefaceStrings[] = 
-       "fontName"
+    "fontName"
 ;
 
 static const SkMemberInfo gTypefaceInfo[] = {
-       {0, 8, 108, 1}
+    {0, 8, 108, 1}
 };
 
 static const SkMemberInfo* const gInfoTables[] = {
-       gMathInfo,
-       gAddInfo,
-       gAddCircleInfo,
-       gUnknown1Info,
-       gAddOvalInfo,
-       gAddPathInfo,
-       gAddRectangleInfo,
-       gAddRoundRectInfo,
-       gUnknown2Info,
-       gAnimateFieldInfo,
-       gApplyInfo,
-       gUnknown3Info,
-       gDrawBitmapInfo,
-       gDrawBitmapShaderInfo,
-       gDrawBlurInfo,
-       gDisplayBoundsInfo,
-       gDrawClipInfo,
-       gDrawColorInfo,
-       gCubicToInfo,
-       gDashInfo,
-       gDataInfo,
-       gDiscreteInfo,
-       gDrawToInfo,
-       gDrawEmbossInfo,
-       gDisplayEventInfo,
-       gFromPathInfo,
-       gUnknown4Info,
-       gGInfo,
-       gHitClearInfo,
-       gHitTestInfo,
-       gImageInfo,
-       gIncludeInfo,
-       gInputInfo,
-       gLineInfo,
-       gLineToInfo,
-       gLinearGradientInfo,
-       gDrawMatrixInfo,
-       gMoveInfo,
-       gMoveToInfo,
-       gMovieInfo,
-       gOvalInfo,
-       gDrawPaintInfo,
-       gDrawPathInfo,
-       gUnknown5Info,
-       gDrawPointInfo,
-       gPolyToPolyInfo,
-       gPolygonInfo,
-       gPolylineInfo,
-       gPostInfo,
-       gQuadToInfo,
-       gRCubicToInfo,
-       gRLineToInfo,
-       gRMoveToInfo,
-       gRQuadToInfo,
-       gRadialGradientInfo,
-       gDisplayRandomInfo,
-       gRectToRectInfo,
-       gRectangleInfo,
-       gRemoveInfo,
-       gReplaceInfo,
-       gRotateInfo,
-       gRoundRectInfo,
-       gS32Info,
-       gScalarInfo,
-       gScaleInfo,
-       gSetInfo,
-       gShaderInfo,
-       gSkewInfo,
-       g3D_CameraInfo,
-       g3D_PatchInfo,
-       gUnknown6Info,
-       gSnapshotInfo,
-       gStringInfo,
-       gTextInfo,
-       gTextBoxInfo,
-       gTextOnPathInfo,
-       gTextToPathInfo,
-       gTranslateInfo,
-       gTypedArrayInfo,
-       gTypefaceInfo,
+    gMathInfo,
+    gAddInfo,
+    gAddCircleInfo,
+    gUnknown1Info,
+    gAddOvalInfo,
+    gAddPathInfo,
+    gAddRectangleInfo,
+    gAddRoundRectInfo,
+    gUnknown2Info,
+    gAnimateFieldInfo,
+    gApplyInfo,
+    gUnknown3Info,
+    gDrawBitmapInfo,
+    gDrawBitmapShaderInfo,
+    gDrawBlurInfo,
+    gDisplayBoundsInfo,
+    gDrawClipInfo,
+    gDrawColorInfo,
+    gCubicToInfo,
+    gDashInfo,
+    gDataInfo,
+    gDiscreteInfo,
+    gDrawToInfo,
+    gDrawEmbossInfo,
+    gDisplayEventInfo,
+    gFromPathInfo,
+    gUnknown4Info,
+    gGInfo,
+    gHitClearInfo,
+    gHitTestInfo,
+    gImageInfo,
+    gIncludeInfo,
+    gInputInfo,
+    gLineInfo,
+    gLineToInfo,
+    gLinearGradientInfo,
+    gDrawMatrixInfo,
+    gMoveInfo,
+    gMoveToInfo,
+    gMovieInfo,
+    gOvalInfo,
+    gDrawPaintInfo,
+    gDrawPathInfo,
+    gUnknown5Info,
+    gDrawPointInfo,
+    gPolyToPolyInfo,
+    gPolygonInfo,
+    gPolylineInfo,
+    gPostInfo,
+    gQuadToInfo,
+    gRCubicToInfo,
+    gRLineToInfo,
+    gRMoveToInfo,
+    gRQuadToInfo,
+    gRadialGradientInfo,
+    gDisplayRandomInfo,
+    gRectToRectInfo,
+    gRectangleInfo,
+    gRemoveInfo,
+    gReplaceInfo,
+    gRotateInfo,
+    gRoundRectInfo,
+    gS32Info,
+    gScalarInfo,
+    gScaleInfo,
+    gSetInfo,
+    gShaderInfo,
+    gSkewInfo,
+    g3D_CameraInfo,
+    g3D_PatchInfo,
+    gUnknown6Info,
+    gSnapshotInfo,
+    gStringInfo,
+    gTextInfo,
+    gTextBoxInfo,
+    gTextOnPathInfo,
+    gTextToPathInfo,
+    gTranslateInfo,
+    gTypedArrayInfo,
+    gTypefaceInfo,
 };
 
 static const unsigned char gInfoCounts[] = {
-       26,4,4,1,1,2,5,3,13,1,13,2,6,3,2,2,2,8,6,
-       2,2,2,2,4,8,3,3,2,1,4,3,1,3,4,2,2,12,1,2,
-       1,1,25,3,3,2,2,1,1,6,4,1,1,1,1,3,5,2,7,2,
-       1,2,3,1,1,3,8,2,3,7,4,3,4,3,4,6,3,2,2,2,
-       1
+    26,4,4,1,1,2,5,3,13,1,13,2,6,3,2,2,2,8,6,
+    2,2,2,2,4,8,3,3,2,1,4,3,1,3,4,2,2,12,1,2,
+    1,1,25,3,3,2,2,1,1,6,4,1,1,1,1,3,5,2,7,2,
+    1,2,3,1,1,3,8,2,3,7,4,3,4,3,4,6,3,2,2,2,
+    1
 };
 
 static const unsigned char gTypeIDs[] = {
-       1, // Math
-       2, // Add
-       3, // AddCircle
-       4, // Unknown1
-       5, // AddOval
-       6, // AddPath
-       7, // AddRectangle
-       8, // AddRoundRect
-       10, // Unknown2
-       11, // AnimateField
-       12, // Apply
-       17, // Unknown3
-       19, // Bitmap
-       22, // BitmapShader
-       23, // Blur
-       25, // Bounds
-       29, // Clip
-       31, // Color
-       32, // CubicTo
-       33, // Dash
-       34, // Data
-       35, // Discrete
-       38, // DrawTo
-       41, // Emboss
-       42, // Event
-       48, // FromPath
-       51, // Unknown4
-       52, // G
-       53, // HitClear
-       54, // HitTest
-       55, // Image
-       56, // Include
-       57, // Input
-       59, // Line
-       60, // LineTo
-       61, // LinearGradient
-       65, // Matrix
-       68, // Move
-       69, // MoveTo
-       70, // Movie
-       72, // Oval
-       73, // Paint
-       74, // Path
-       77, // Unknown5
-       78, // Point
-       79, // PolyToPoly
-       80, // Polygon
-       81, // Polyline
-       82, // Post
-       83, // QuadTo
-       84, // RCubicTo
-       85, // RLineTo
-       86, // RMoveTo
-       87, // RQuadTo
-       88, // RadialGradient
-       89, // Random
-       90, // RectToRect
-       91, // Rectangle
-       92, // Remove
-       93, // Replace
-       94, // Rotate
-       95, // RoundRect
-       96, // S32
-       98, // Scalar
-       99, // Scale
-       101, // Set
-       102, // Shader
-       103, // Skew
-       104, // 3D_Camera
-       105, // 3D_Patch
-       106, // Unknown6
-       107, // Snapshot
-       108, // String
-       110, // Text
-       111, // TextBox
-       114, // TextOnPath
-       115, // TextToPath
-       117, // Translate
-       119, // TypedArray
-       120, // Typeface
-       
+    1, // Math
+    2, // Add
+    3, // AddCircle
+    4, // Unknown1
+    5, // AddOval
+    6, // AddPath
+    7, // AddRectangle
+    8, // AddRoundRect
+    10, // Unknown2
+    11, // AnimateField
+    12, // Apply
+    17, // Unknown3
+    19, // Bitmap
+    22, // BitmapShader
+    23, // Blur
+    25, // Bounds
+    29, // Clip
+    31, // Color
+    32, // CubicTo
+    33, // Dash
+    34, // Data
+    35, // Discrete
+    38, // DrawTo
+    41, // Emboss
+    42, // Event
+    48, // FromPath
+    51, // Unknown4
+    52, // G
+    53, // HitClear
+    54, // HitTest
+    55, // Image
+    56, // Include
+    57, // Input
+    59, // Line
+    60, // LineTo
+    61, // LinearGradient
+    65, // Matrix
+    68, // Move
+    69, // MoveTo
+    70, // Movie
+    72, // Oval
+    73, // Paint
+    74, // Path
+    77, // Unknown5
+    78, // Point
+    79, // PolyToPoly
+    80, // Polygon
+    81, // Polyline
+    82, // Post
+    83, // QuadTo
+    84, // RCubicTo
+    85, // RLineTo
+    86, // RMoveTo
+    87, // RQuadTo
+    88, // RadialGradient
+    89, // Random
+    90, // RectToRect
+    91, // Rectangle
+    92, // Remove
+    93, // Replace
+    94, // Rotate
+    95, // RoundRect
+    96, // S32
+    98, // Scalar
+    99, // Scale
+    101, // Set
+    102, // Shader
+    103, // Skew
+    104, // 3D_Camera
+    105, // 3D_Patch
+    106, // Unknown6
+    107, // Snapshot
+    108, // String
+    110, // Text
+    111, // TextBox
+    114, // TextOnPath
+    115, // TextToPath
+    117, // Translate
+    119, // TypedArray
+    120, // Typeface
+    
 };
 
 static const int kTypeIDs = 80;
 
 static const char* const gInfoNames[] = {
-       gMathStrings,
-       gAddStrings,
-       gAddCircleStrings,
-       gUnknown1Strings,
-       gAddOvalStrings,
-       gAddPathStrings,
-       gAddRectangleStrings,
-       gAddRoundRectStrings,
-       gUnknown2Strings,
-       gAnimateFieldStrings,
-       gApplyStrings,
-       gUnknown3Strings,
-       gBitmapStrings,
-       gBitmapShaderStrings,
-       gBlurStrings,
-       gBoundsStrings,
-       gClipStrings,
-       gColorStrings,
-       gCubicToStrings,
-       gDashStrings,
-       gDataStrings,
-       gDiscreteStrings,
-       gDrawToStrings,
-       gEmbossStrings,
-       gEventStrings,
-       gFromPathStrings,
-       gUnknown4Strings,
-       gGStrings,
-       gHitClearStrings,
-       gHitTestStrings,
-       gImageStrings,
-       gIncludeStrings,
-       gInputStrings,
-       gLineStrings,
-       gLineToStrings,
-       gLinearGradientStrings,
-       gMatrixStrings,
-       gMoveStrings,
-       gMoveToStrings,
-       gMovieStrings,
-       gOvalStrings,
-       gPaintStrings,
-       gPathStrings,
-       gUnknown5Strings,
-       gPointStrings,
-       gPolyToPolyStrings,
-       gPolygonStrings,
-       gPolylineStrings,
-       gPostStrings,
-       gQuadToStrings,
-       gRCubicToStrings,
-       gRLineToStrings,
-       gRMoveToStrings,
-       gRQuadToStrings,
-       gRadialGradientStrings,
-       gRandomStrings,
-       gRectToRectStrings,
-       gRectangleStrings,
-       gRemoveStrings,
-       gReplaceStrings,
-       gRotateStrings,
-       gRoundRectStrings,
-       gS32Strings,
-       gScalarStrings,
-       gScaleStrings,
-       gSetStrings,
-       gShaderStrings,
-       gSkewStrings,
-       g3D_CameraStrings,
-       g3D_PatchStrings,
-       gUnknown6Strings,
-       gSnapshotStrings,
-       gStringStrings,
-       gTextStrings,
-       gTextBoxStrings,
-       gTextOnPathStrings,
-       gTextToPathStrings,
-       gTranslateStrings,
-       gTypedArrayStrings,
-       gTypefaceStrings
+    gMathStrings,
+    gAddStrings,
+    gAddCircleStrings,
+    gUnknown1Strings,
+    gAddOvalStrings,
+    gAddPathStrings,
+    gAddRectangleStrings,
+    gAddRoundRectStrings,
+    gUnknown2Strings,
+    gAnimateFieldStrings,
+    gApplyStrings,
+    gUnknown3Strings,
+    gBitmapStrings,
+    gBitmapShaderStrings,
+    gBlurStrings,
+    gBoundsStrings,
+    gClipStrings,
+    gColorStrings,
+    gCubicToStrings,
+    gDashStrings,
+    gDataStrings,
+    gDiscreteStrings,
+    gDrawToStrings,
+    gEmbossStrings,
+    gEventStrings,
+    gFromPathStrings,
+    gUnknown4Strings,
+    gGStrings,
+    gHitClearStrings,
+    gHitTestStrings,
+    gImageStrings,
+    gIncludeStrings,
+    gInputStrings,
+    gLineStrings,
+    gLineToStrings,
+    gLinearGradientStrings,
+    gMatrixStrings,
+    gMoveStrings,
+    gMoveToStrings,
+    gMovieStrings,
+    gOvalStrings,
+    gPaintStrings,
+    gPathStrings,
+    gUnknown5Strings,
+    gPointStrings,
+    gPolyToPolyStrings,
+    gPolygonStrings,
+    gPolylineStrings,
+    gPostStrings,
+    gQuadToStrings,
+    gRCubicToStrings,
+    gRLineToStrings,
+    gRMoveToStrings,
+    gRQuadToStrings,
+    gRadialGradientStrings,
+    gRandomStrings,
+    gRectToRectStrings,
+    gRectangleStrings,
+    gRemoveStrings,
+    gReplaceStrings,
+    gRotateStrings,
+    gRoundRectStrings,
+    gS32Strings,
+    gScalarStrings,
+    gScaleStrings,
+    gSetStrings,
+    gShaderStrings,
+    gSkewStrings,
+    g3D_CameraStrings,
+    g3D_PatchStrings,
+    gUnknown6Strings,
+    gSnapshotStrings,
+    gStringStrings,
+    gTextStrings,
+    gTextBoxStrings,
+    gTextOnPathStrings,
+    gTextToPathStrings,
+    gTranslateStrings,
+    gTypedArrayStrings,
+    gTypefaceStrings
 };
 #endif
 #endif
index 0264a5f..cec62af 100644 (file)
@@ -1,3 +1,20 @@
+/* libs/graphics/animator/SkDisplayAdd.cpp
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #include "SkDisplayAdd.h"
 #include "SkAnimateMaker.h"
 #include "SkDisplayApply.h"
 #if SK_USE_CONDENSED_INFO == 0
 
 const SkMemberInfo SkAdd::fInfo[] = {
-       SK_MEMBER(mode, AddMode),
-       SK_MEMBER(offset, Int),
-       SK_MEMBER(use, Drawable),
-       SK_MEMBER(where, Drawable)
+    SK_MEMBER(mode, AddMode),
+    SK_MEMBER(offset, Int),
+    SK_MEMBER(use, Drawable),
+    SK_MEMBER(where, Drawable)
 };
 
 #endif
@@ -25,133 +42,133 @@ const SkMemberInfo SkAdd::fInfo[] = {
 DEFINE_GET_MEMBER(SkAdd);
 
 SkAdd::SkAdd() : mode(kMode_indirect), 
-       offset(SK_MaxS32), use(nil), where(nil) {
+    offset(SK_MaxS32), use(nil), where(nil) {
 }
 
 SkDisplayable* SkAdd::deepCopy(SkAnimateMaker* maker) {
-       SkDrawable* saveUse = use;
-       SkDrawable* saveWhere = where;
-       use = nil;
-       where = nil;
-       SkAdd* copy = (SkAdd*) INHERITED::deepCopy(maker);
-       copy->use = use = saveUse;
-       copy->where = where = saveWhere;
-       return copy;
+    SkDrawable* saveUse = use;
+    SkDrawable* saveWhere = where;
+    use = nil;
+    where = nil;
+    SkAdd* copy = (SkAdd*) INHERITED::deepCopy(maker);
+    copy->use = use = saveUse;
+    copy->where = where = saveWhere;
+    return copy;
 }
 
 bool SkAdd::draw(SkAnimateMaker& maker) {
-       SkASSERT(use);
-       SkASSERT(use->isDrawable());
-       if (mode == kMode_indirect)
-               use->draw(maker);
-       return false;
+    SkASSERT(use);
+    SkASSERT(use->isDrawable());
+    if (mode == kMode_indirect)
+        use->draw(maker);
+    return false;
 }
 
 #ifdef SK_DUMP_ENABLED
 void SkAdd::dump(SkAnimateMaker* maker) {
-       dumpBase(maker);
+    dumpBase(maker);
     dumpAttrs(maker);
     if (where)
         SkDebugf("where=\"%s\" ", where->id);
     if (mode == kMode_immediate)
         SkDebugf("mode=\"immediate\" ");
     SkDebugf(">\n");
-       SkDisplayList::fIndent += 4;
-       int save = SkDisplayList::fDumpIndex;
+    SkDisplayList::fIndent += 4;
+    int save = SkDisplayList::fDumpIndex;
     if (use)    //just in case
         use->dump(maker);
-       SkDisplayList::fIndent -= 4;
-       SkDisplayList::fDumpIndex = save;
+    SkDisplayList::fIndent -= 4;
+    SkDisplayList::fDumpIndex = save;
     dumpEnd(maker);
 }
 #endif
 
 bool SkAdd::enable(SkAnimateMaker& maker ) {
-       SkDisplayTypes type = getType();
-       SkDisplayList& displayList = maker.fDisplayList;
-       SkTDDrawableArray* parentList = displayList.getDrawList();
-       if (type == SkType_Add) {
-               if (use == nil) // not set in apply yet
-                       return true;
-       }
-       bool skipAddToParent = true;
-       SkASSERT(type != SkType_Replace || where);
-       SkTDDrawableArray* grandList SK_INIT_TO_AVOID_WARNING;
-       SkGroup* parentGroup = nil;
-       SkGroup* thisGroup = nil;
-       int index = where ? displayList.findGroup(where, &parentList, &parentGroup,
-               &thisGroup, &grandList) : 0;
-       if (index < 0)
-               return true;
-       int max = parentList->count();
-       if (where == nil && type == SkType_Move)
-               index = max;
-       if (offset != SK_MaxS32) {
-               index += offset;
-               if (index > max) {
-                       maker.setErrorCode(SkDisplayXMLParserError::kIndexOutOfRange);
-                       return true;    // caller should not add
-               }
-       }
-       if (offset < 0 && where == nil)
-               index += max + 1;
-       switch (type) {
-               case SkType_Add:
-                       if (offset == SK_MaxS32 && where == nil) {
-                               if (use->isDrawable()) {
-                                       skipAddToParent = mode == kMode_immediate;
-                                       if (skipAddToParent) {
-                                               if (where == nil) {
-                                                       SkTDDrawableArray* useParentList;
-                                                       index = displayList.findGroup(this, &useParentList, &parentGroup,
-                                                               &thisGroup, &grandList);
-                                                       if (index >= 0) {
-                                                               parentGroup->markCopySize(index);
-                                                               parentGroup->markCopySet(index);
-                                                               useParentList->begin()[index] = use;
-                                                               break;
-                                                       }                                                               
-                                               }
-                                               *parentList->append() = use;
-                                       }
-                               }
-                               break;
-                       } else {
-                               if (thisGroup)
-                                       thisGroup->markCopySize(index);
-                               *parentList->insert(index) = use;
-                               if (thisGroup)
-                                       thisGroup->markCopySet(index);
-                               if (use->isApply())
-                                       ((SkApply*) use)->setEmbedded();
-                       }
-                       break;
-               case SkType_Move: {
-                       int priorLocation = parentList->find(use);
-                       if (priorLocation < 0)
-                               break;
-                       *parentList->insert(index) = use;
-                       if (index < priorLocation)
-                               priorLocation++;
-                       parentList->remove(priorLocation);
-                       } break;
-               case SkType_Remove: {
-                       SkDisplayable* old = (*parentList)[index];
-                       if (((SkRemove*)(this))->fDelete) {
-                               delete old;
-                               goto noHelperNeeded;
-                       }
-                       for (int inner = 0; inner < maker.fChildren.count(); inner++) {
-                               SkDisplayable* child = maker.fChildren[inner];
-                               if (child == old || child->contains(old))
-                                       goto noHelperNeeded;
-                       }
-                       if (maker.fHelpers.find(old) < 0)
-                               maker.helperAdd(old);
+    SkDisplayTypes type = getType();
+    SkDisplayList& displayList = maker.fDisplayList;
+    SkTDDrawableArray* parentList = displayList.getDrawList();
+    if (type == SkType_Add) {
+        if (use == nil) // not set in apply yet
+            return true;
+    }
+    bool skipAddToParent = true;
+    SkASSERT(type != SkType_Replace || where);
+    SkTDDrawableArray* grandList SK_INIT_TO_AVOID_WARNING;
+    SkGroup* parentGroup = nil;
+    SkGroup* thisGroup = nil;
+    int index = where ? displayList.findGroup(where, &parentList, &parentGroup,
+        &thisGroup, &grandList) : 0;
+    if (index < 0)
+        return true;
+    int max = parentList->count();
+    if (where == nil && type == SkType_Move)
+        index = max;
+    if (offset != SK_MaxS32) {
+        index += offset;
+        if (index > max) {
+            maker.setErrorCode(SkDisplayXMLParserError::kIndexOutOfRange);
+            return true;    // caller should not add
+        }
+    }
+    if (offset < 0 && where == nil)
+        index += max + 1;
+    switch (type) {
+        case SkType_Add:
+            if (offset == SK_MaxS32 && where == nil) {
+                if (use->isDrawable()) {
+                    skipAddToParent = mode == kMode_immediate;
+                    if (skipAddToParent) {
+                        if (where == nil) {
+                            SkTDDrawableArray* useParentList;
+                            index = displayList.findGroup(this, &useParentList, &parentGroup,
+                                &thisGroup, &grandList);
+                            if (index >= 0) {
+                                parentGroup->markCopySize(index);
+                                parentGroup->markCopySet(index);
+                                useParentList->begin()[index] = use;
+                                break;
+                            }                               
+                        }
+                        *parentList->append() = use;
+                    }
+                }
+                break;
+            } else {
+                if (thisGroup)
+                    thisGroup->markCopySize(index);
+                *parentList->insert(index) = use;
+                if (thisGroup)
+                    thisGroup->markCopySet(index);
+                if (use->isApply())
+                    ((SkApply*) use)->setEmbedded();
+            }
+            break;
+        case SkType_Move: {
+            int priorLocation = parentList->find(use);
+            if (priorLocation < 0)
+                break;
+            *parentList->insert(index) = use;
+            if (index < priorLocation)
+                priorLocation++;
+            parentList->remove(priorLocation);
+            } break;
+        case SkType_Remove: {
+            SkDisplayable* old = (*parentList)[index];
+            if (((SkRemove*)(this))->fDelete) {
+                delete old;
+                goto noHelperNeeded;
+            }
+            for (int inner = 0; inner < maker.fChildren.count(); inner++) {
+                SkDisplayable* child = maker.fChildren[inner];
+                if (child == old || child->contains(old))
+                    goto noHelperNeeded;
+            }
+            if (maker.fHelpers.find(old) < 0)
+                maker.helperAdd(old);
 noHelperNeeded:
-                       parentList->remove(index);
-                       } break;
-               case SkType_Replace:
+            parentList->remove(index);
+            } break;
+        case SkType_Replace:
             if (thisGroup) {
                 thisGroup->markCopySize(index);
                 if (thisGroup->markedForDelete(index)) {
@@ -160,50 +177,50 @@ noHelperNeeded:
                         maker.helperAdd(old);
                 }
             }
-                       (*parentList)[index] = use;
+            (*parentList)[index] = use;
             if (thisGroup)
                 thisGroup->markCopySet(index);
-                       break;
-               default:
-                       SkASSERT(0);
-       }
-       if (type == SkType_Remove)
-               return true;
-       if (use->hasEnable())
-               use->enable(maker);
-       return skipAddToParent; // append if indirect: *parentList->append() = this;
+            break;
+        default:
+            SkASSERT(0);
+    }
+    if (type == SkType_Remove)
+        return true;
+    if (use->hasEnable())
+        use->enable(maker);
+    return skipAddToParent; // append if indirect: *parentList->append() = this;
 }
 
 bool SkAdd::hasEnable() const {
-       return true;
+    return true;
 }
 
 void SkAdd::initialize() {
-       if (use)
-               use->initialize();
+    if (use)
+        use->initialize();
 }
 
 bool SkAdd::isDrawable() const {
-       return getType() == SkType_Add && mode == kMode_indirect && offset == SK_MaxS32 &&
-               where == nil && use != nil && use->isDrawable();
+    return getType() == SkType_Add && mode == kMode_indirect && offset == SK_MaxS32 &&
+        where == nil && use != nil && use->isDrawable();
 }
 
 //SkDisplayable* SkAdd::resolveTarget(SkAnimateMaker& maker) {
-//     return use;
+//  return use;
 //}
 
 
 bool SkClear::enable(SkAnimateMaker& maker ) {
-       SkDisplayList& displayList = maker.fDisplayList;
-       displayList.clear();
-       return true;
+    SkDisplayList& displayList = maker.fDisplayList;
+    displayList.clear();
+    return true;
 }
 
 
 #if SK_USE_CONDENSED_INFO == 0
 
 const SkMemberInfo SkMove::fInfo[] = {
-       SK_MEMBER_INHERITED
+    SK_MEMBER_INHERITED
 };
 
 #endif
@@ -213,9 +230,9 @@ DEFINE_GET_MEMBER(SkMove);
 #if SK_USE_CONDENSED_INFO == 0
 
 const SkMemberInfo SkRemove::fInfo[] = {
-       SK_MEMBER_ALIAS(delete, fDelete, Boolean),      // !!! experimental
-       SK_MEMBER(offset, Int),
-       SK_MEMBER(where, Drawable)
+    SK_MEMBER_ALIAS(delete, fDelete, Boolean),  // !!! experimental
+    SK_MEMBER(offset, Int),
+    SK_MEMBER(where, Drawable)
 };
 
 #endif
@@ -228,7 +245,7 @@ SkRemove::SkRemove() : fDelete(false) {
 #if SK_USE_CONDENSED_INFO == 0
 
 const SkMemberInfo SkReplace::fInfo[] = {
-       SK_MEMBER_INHERITED
+    SK_MEMBER_INHERITED
 };
 
 #endif
index ed72730..e3cc041 100644 (file)
@@ -1,3 +1,20 @@
+/* libs/graphics/animator/SkDisplayAdd.h
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #ifndef SkDisplayAdd_DEFINED
 #define SkDisplayAdd_DEFINED
 
 #include "SkMemberInfo.h"
 
 class SkAdd : public SkDrawable {
-       DECLARE_MEMBER_INFO(Add);
-       SkAdd();
-       
-       enum Mode {
-               kMode_indirect,
-               kMode_immediate
-       };
-       
-       virtual SkDisplayable* deepCopy(SkAnimateMaker* );
-       virtual bool draw(SkAnimateMaker& );
+    DECLARE_MEMBER_INFO(Add);
+    SkAdd();
+    
+    enum Mode {
+        kMode_indirect,
+        kMode_immediate
+    };
+    
+    virtual SkDisplayable* deepCopy(SkAnimateMaker* );
+    virtual bool draw(SkAnimateMaker& );
 #ifdef SK_DUMP_ENABLED
-       virtual void dump(SkAnimateMaker* );
+    virtual void dump(SkAnimateMaker* );
 #endif
-       virtual bool enable(SkAnimateMaker& );
-       virtual bool hasEnable() const;
-       virtual void initialize();
-       virtual bool isDrawable() const;
+    virtual bool enable(SkAnimateMaker& );
+    virtual bool hasEnable() const;
+    virtual void initialize();
+    virtual bool isDrawable() const;
 protected:
-//     struct _A {
-               Mode mode;
-               S32 offset;
-               SkDrawable* use;
-               SkDrawable* where;      // if nil, offset becomes index
-//     } A;
+//  struct _A {
+        Mode mode;
+        S32 offset;
+        SkDrawable* use;
+        SkDrawable* where;  // if nil, offset becomes index
+//  } A;
 private:
-       typedef SkDrawable INHERITED;
+    typedef SkDrawable INHERITED;
 };
 
 class SkClear : public SkDisplayable {
-       virtual bool enable(SkAnimateMaker& );
+    virtual bool enable(SkAnimateMaker& );
 };
 
 class SkMove : public SkAdd {
-       DECLARE_MEMBER_INFO(Move);
+    DECLARE_MEMBER_INFO(Move);
 private:
-       typedef SkAdd INHERITED;
+    typedef SkAdd INHERITED;
 };
 
 class SkRemove : public SkAdd {
-       DECLARE_MEMBER_INFO(Remove);
-       SkRemove();
+    DECLARE_MEMBER_INFO(Remove);
+    SkRemove();
 protected:
-       SkBool fDelete;
+    SkBool fDelete;
 private:
-       friend class SkAdd;
-       typedef SkAdd INHERITED;
+    friend class SkAdd;
+    typedef SkAdd INHERITED;
 };
 
 class SkReplace : public SkAdd {
-       DECLARE_MEMBER_INFO(Replace);
+    DECLARE_MEMBER_INFO(Replace);
 private:
-       typedef SkAdd INHERITED;
+    typedef SkAdd INHERITED;
 };
 
 #endif // SkDisplayAdd_DEFINED
index af88631..fa58903 100644 (file)
@@ -1,3 +1,20 @@
+/* libs/graphics/animator/SkDisplayApply.cpp
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #include "SkDisplayApply.h"
 #include "SkAnimateActive.h"
 #include "SkAnimateMaker.h"
 #include <ctype.h>
 
 enum SkApply_Properties {
-       SK_PROPERTY(animator),
-       SK_PROPERTY(step),
-       SK_PROPERTY(steps),
-       SK_PROPERTY(time)
+    SK_PROPERTY(animator),
+    SK_PROPERTY(step),
+    SK_PROPERTY(steps),
+    SK_PROPERTY(time)
 };
 
 #if SK_USE_CONDENSED_INFO == 0
@@ -25,21 +42,21 @@ enum SkApply_Properties {
 // if no attibutes, enclosed displayable is both scope & target
 // only if both scope & target are specified, or if target and enclosed displayable, are scope and target different
 const SkMemberInfo SkApply::fInfo[] = {
-       SK_MEMBER_PROPERTY(animator, Animate),
-       SK_MEMBER(begin, MSec),
-       SK_MEMBER(dontDraw, Boolean),
-       SK_MEMBER(dynamicScope, String),
-       SK_MEMBER(interval, MSec),      // recommended redraw interval
-       SK_MEMBER(mode, ApplyMode),
+    SK_MEMBER_PROPERTY(animator, Animate),
+    SK_MEMBER(begin, MSec),
+    SK_MEMBER(dontDraw, Boolean),
+    SK_MEMBER(dynamicScope, String),
+    SK_MEMBER(interval, MSec),  // recommended redraw interval
+    SK_MEMBER(mode, ApplyMode),
 #if 0
-       SK_MEMBER(pickup, Boolean),
+    SK_MEMBER(pickup, Boolean),
 #endif
-       SK_MEMBER(restore, Boolean),
-       SK_MEMBER(scope, Drawable),     // thing that scopes animation (unnamed enclosed displayable goes here)
-       SK_MEMBER_PROPERTY(step, Int),
-       SK_MEMBER_PROPERTY(steps, Int),
-       SK_MEMBER_PROPERTY(time, MSec),
-       SK_MEMBER(transition, ApplyTransition)
+    SK_MEMBER(restore, Boolean),
+    SK_MEMBER(scope, Drawable), // thing that scopes animation (unnamed enclosed displayable goes here)
+    SK_MEMBER_PROPERTY(step, Int),
+    SK_MEMBER_PROPERTY(steps, Int),
+    SK_MEMBER_PROPERTY(time, MSec),
+    SK_MEMBER(transition, ApplyTransition)
 };
 
 #endif 
@@ -47,159 +64,159 @@ const SkMemberInfo SkApply::fInfo[] = {
 DEFINE_GET_MEMBER(SkApply);
 
 SkApply::SkApply() : begin(0), dontDraw(false), interval((SkMSec) -1), mode((Mode) -1), /*pickup(false), */
-       restore(false), scope(nil), steps(-1), transition((Transition) -1), fActive(nil), /*fCurrentScope(nil),*/
-       fLastTime(0), fAppended(false), fContainsScope(false), fDeleteScope(false), fEmbedded(false), 
-       fEnabled(false), fEnabling(false) {
+    restore(false), scope(nil), steps(-1), transition((Transition) -1), fActive(nil), /*fCurrentScope(nil),*/
+    fLastTime(0), fAppended(false), fContainsScope(false), fDeleteScope(false), fEmbedded(false), 
+    fEnabled(false), fEnabling(false) {
 }
 
 SkApply::~SkApply() {
-       for (SkDrawable** curPtr = fScopes.begin(); curPtr < fScopes.end(); curPtr++)
-               delete *curPtr;
-       if (fDeleteScope)
-               delete scope;
-       // !!! caller must call maker.removeActive(fActive)
-       delete fActive;
+    for (SkDrawable** curPtr = fScopes.begin(); curPtr < fScopes.end(); curPtr++)
+        delete *curPtr;
+    if (fDeleteScope)
+        delete scope;
+    // !!! caller must call maker.removeActive(fActive)
+    delete fActive;
 }
 
 void SkApply::activate(SkAnimateMaker& maker) {
-       if (fActive != nil) {
-               if (fActive->fDrawIndex == 0 && fActive->fDrawMax == 0)
-                       return; // if only one use, nothing more to do
-               if (restore == false)
-                       return; // all share same state, regardless of instance number
-               bool save = fActive->initializeSave();
-               fActive->fixInterpolator(save);
-       } else {
-               fActive = new SkActive(*this, maker);
-               fActive->init();
-               maker.appendActive(fActive);
-               if (restore) {
-                       fActive->initializeSave();
-                       int animators = fAnimators.count();
-                       for (int index = 0; index < animators; index++)
-                               fActive->saveInterpolatorValues(index);
-               }
-       }
+    if (fActive != nil) {
+        if (fActive->fDrawIndex == 0 && fActive->fDrawMax == 0)
+            return; // if only one use, nothing more to do
+        if (restore == false)
+            return; // all share same state, regardless of instance number
+        bool save = fActive->initializeSave();
+        fActive->fixInterpolator(save);
+    } else {
+        fActive = new SkActive(*this, maker);
+        fActive->init();
+        maker.appendActive(fActive);
+        if (restore) {
+            fActive->initializeSave();
+            int animators = fAnimators.count();
+            for (int index = 0; index < animators; index++)
+                fActive->saveInterpolatorValues(index);
+        }
+    }
 }
 
 void SkApply::append(SkApply* apply) {
-       if (fActive == nil)
-               return;
-       int oldCount = fActive->fAnimators.count();
-       fActive->append(apply);
-       if (restore) {
-               fActive->appendSave(oldCount);
-               int newCount = fActive->fAnimators.count();
-               for (int index = oldCount; index < newCount; index++)
-                       fActive->saveInterpolatorValues(index);
-       }
+    if (fActive == nil)
+        return;
+    int oldCount = fActive->fAnimators.count();
+    fActive->append(apply);
+    if (restore) {
+        fActive->appendSave(oldCount);
+        int newCount = fActive->fAnimators.count();
+        for (int index = oldCount; index < newCount; index++)
+            fActive->saveInterpolatorValues(index);
+    }
 }
 
 void SkApply::applyValues(int animatorIndex, SkOperand* values, int count,
-        SkDisplayTypes valuesType, SkMSec time) 
+     SkDisplayTypes valuesType, SkMSec time) 
 {
-       SkAnimateBase* animator = fActive->fAnimators[animatorIndex];
-       const SkMemberInfo * info = animator->fFieldInfo;
-       SkASSERT(animator);
-       SkASSERT(info != nil);
-       SkDisplayTypes type = (SkDisplayTypes) info->fType;
-       SkDisplayable* target = getTarget(animator);
-       if (animator->hasExecute() || type == SkType_MemberFunction || type == SkType_MemberProperty) {
-               SkDisplayable* executor = animator->hasExecute() ? animator : target;
-               if (type != SkType_MemberProperty) {
-                       SkTDArray<SkScriptValue> typedValues;
-                       for (int index = 0; index < count; index++) {
-                               SkScriptValue temp;
-                               temp.fType = valuesType;
-                               temp.fOperand = values[index];
-                               *typedValues.append() = temp;
-                       }
-                       executor->executeFunction(target, info->functionIndex(), typedValues, info->getType(), nil);
-               } else {
-                       SkScriptValue scriptValue;
-                       scriptValue.fOperand = values[0];
-                       scriptValue.fType = info->getType();
-                       target->setProperty(info->propertyIndex(), scriptValue);
-               }
-       } else {
-               SkTypedArray converted;
-               if (type == SkType_ARGB) {
-                       if (count == 4) {
-                               // !!! assert that it is SkType_Float ?
-                               animator->packARGB(&values->fScalar, count, &converted);
-                               values = converted.begin();
-                               count = converted.count();
-                       } else
-                               SkASSERT(count == 1);
-               }
-//             SkASSERT(type == SkType_ARGB || type == SkType_String ||info->isSettable());
-               if (type == SkType_String || type == SkType_DynamicString)
-                       info->setString(target, values->fString);
-               else if (type == SkType_Drawable || type == SkType_Displayable)
-                       target->setReference(info, values->fDisplayable);
-               else
-                       info->setValue(target, values, count);
-       
+    SkAnimateBase* animator = fActive->fAnimators[animatorIndex];
+    const SkMemberInfo * info = animator->fFieldInfo;
+    SkASSERT(animator);
+    SkASSERT(info != nil);
+    SkDisplayTypes type = (SkDisplayTypes) info->fType;
+    SkDisplayable* target = getTarget(animator);
+    if (animator->hasExecute() || type == SkType_MemberFunction || type == SkType_MemberProperty) {
+        SkDisplayable* executor = animator->hasExecute() ? animator : target;
+        if (type != SkType_MemberProperty) {
+            SkTDArray<SkScriptValue> typedValues;
+            for (int index = 0; index < count; index++) {
+                SkScriptValue temp;
+                temp.fType = valuesType;
+                temp.fOperand = values[index];
+                *typedValues.append() = temp;
+            }
+            executor->executeFunction(target, info->functionIndex(), typedValues, info->getType(), nil);
+        } else {
+            SkScriptValue scriptValue;
+            scriptValue.fOperand = values[0];
+            scriptValue.fType = info->getType();
+            target->setProperty(info->propertyIndex(), scriptValue);
+        }
+    } else {
+        SkTypedArray converted;
+        if (type == SkType_ARGB) {
+            if (count == 4) {
+                // !!! assert that it is SkType_Float ?
+                animator->packARGB(&values->fScalar, count, &converted);
+                values = converted.begin();
+                count = converted.count();
+            } else
+                SkASSERT(count == 1);
+        }
+//      SkASSERT(type == SkType_ARGB || type == SkType_String ||info->isSettable());
+        if (type == SkType_String || type == SkType_DynamicString)
+            info->setString(target, values->fString);
+        else if (type == SkType_Drawable || type == SkType_Displayable)
+            target->setReference(info, values->fDisplayable);
+        else
+            info->setValue(target, values, count);
+    } 
 }
 
 bool SkApply::contains(SkDisplayable* child) {
-       for (SkDrawable** curPtr = fScopes.begin(); curPtr < fScopes.end(); curPtr++) {
-               if (*curPtr == child || (*curPtr)->contains(child))
-                       return true;
-       }
-       return fDeleteScope && scope == child;
+    for (SkDrawable** curPtr = fScopes.begin(); curPtr < fScopes.end(); curPtr++) {
+        if (*curPtr == child || (*curPtr)->contains(child))
+            return true;
+    }
+    return fDeleteScope && scope == child;
 }
 
 SkDisplayable* SkApply::deepCopy(SkAnimateMaker* maker) {
-       SkDrawable* saveScope = scope;
-       scope = nil;
-       SkApply* result = (SkApply*) INHERITED::deepCopy(maker);
-       result->scope = scope = saveScope;
-       SkAnimateBase** end = fAnimators.end();
-       for (SkAnimateBase** animPtr = fAnimators.begin(); animPtr < end; animPtr++) {
-               SkAnimateBase* anim = (SkAnimateBase*) (*animPtr)->deepCopy(maker);
-               *result->fAnimators.append() = anim;
-               maker->helperAdd(anim);
-       }
-       return result;
+    SkDrawable* saveScope = scope;
+    scope = nil;
+    SkApply* result = (SkApply*) INHERITED::deepCopy(maker);
+    result->scope = scope = saveScope;
+    SkAnimateBase** end = fAnimators.end();
+    for (SkAnimateBase** animPtr = fAnimators.begin(); animPtr < end; animPtr++) {
+        SkAnimateBase* anim = (SkAnimateBase*) (*animPtr)->deepCopy(maker);
+        *result->fAnimators.append() = anim;
+        maker->helperAdd(anim);
+    }
+    return result;
 }
 
 void SkApply::disable() {
-       //!!! this is the right thing to do, but has bad side effects because of other problems
-       // currently, if an apply is in a g and scopes a statement in another g, it ends up as members
-       // of both containers. The disabling here incorrectly disables both instances
-       // maybe the fEnabled flag needs to be moved to the fActive data so that both 
-       // instances are not affected.
-//     fEnabled = false;
+    //!!! this is the right thing to do, but has bad side effects because of other problems
+    // currently, if an apply is in a g and scopes a statement in another g, it ends up as members
+    // of both containers. The disabling here incorrectly disables both instances
+    // maybe the fEnabled flag needs to be moved to the fActive data so that both 
+    // instances are not affected.
+//  fEnabled = false;
 }
 
 bool SkApply::draw(SkAnimateMaker& maker) {
-       if (scope ==nil)
-               return false;
-       if (scope->isApply() || scope->isDrawable() == false)
-               return false;
-       if (fEnabled == false)
-               enable(maker);
-       SkASSERT(scope);
-       activate(maker);
-       if (mode == kMode_immediate)
-               return fActive->draw();
-       bool result = interpolate(maker, maker.getInTime());
-       if (dontDraw == false) {
-//             if (scope->isDrawable())
-                       result |= scope->draw(maker);
-       }
-       if (restore) {
-               for (int index = 0; index < fActive->fAnimators.count(); index++)
-                       endSave(index);
-               fActive->advance();
-       }
-       return result;
+    if (scope ==nil)
+        return false;
+    if (scope->isApply() || scope->isDrawable() == false)
+        return false;
+    if (fEnabled == false)
+        enable(maker);
+    SkASSERT(scope);
+    activate(maker);
+    if (mode == kMode_immediate)
+        return fActive->draw();
+    bool result = interpolate(maker, maker.getInTime());
+    if (dontDraw == false) {
+//      if (scope->isDrawable())
+            result |= scope->draw(maker);
+    }
+    if (restore) {
+        for (int index = 0; index < fActive->fAnimators.count(); index++)
+            endSave(index);
+        fActive->advance();
+    }
+    return result;
 }
 
 #ifdef SK_DUMP_ENABLED
 void SkApply::dump(SkAnimateMaker* maker) {
-       dumpBase(maker);
+    dumpBase(maker);
     if (dynamicScope.isEmpty() == false)
         SkDebugf("dynamicScope=\"%s\" ", dynamicScope.c_str());
     if (dontDraw)
@@ -221,8 +238,8 @@ void SkApply::dump(SkAnimateMaker* maker) {
         SkDebugf("mode=\"create\" ");
     }
     bool closedYet = false;
-       SkDisplayList::fIndent += 4;
-       int save = SkDisplayList::fDumpIndex;
+    SkDisplayList::fIndent += 4;
+    int save = SkDisplayList::fDumpIndex;
     if (scope) {
         if (closedYet == false) {
             SkDebugf(">\n");
@@ -230,19 +247,19 @@ void SkApply::dump(SkAnimateMaker* maker) {
         }
         scope->dump(maker);
     }
-       int index;
-//     if (fActive) {
-               for (index = 0; index < fAnimators.count(); index++) {
+    int index;
+//  if (fActive) {
+        for (index = 0; index < fAnimators.count(); index++) {
             if (closedYet == false) {
                 SkDebugf(">\n");
                 closedYet = true;
             }
-                       SkAnimateBase* animator = fAnimators[index];
-                       animator->dump(maker);
-//             }
-       }
-       SkDisplayList::fIndent -= 4;
-       SkDisplayList::fDumpIndex = save;
+            SkAnimateBase* animator = fAnimators[index];
+            animator->dump(maker);
+//      }
+    }
+    SkDisplayList::fIndent -= 4;
+    SkDisplayList::fDumpIndex = save;
     if (closedYet)
         dumpEnd(maker);
     else
@@ -251,279 +268,279 @@ void SkApply::dump(SkAnimateMaker* maker) {
 #endif
 
 bool SkApply::enable(SkAnimateMaker& maker) {
-       fEnabled = true;
-       bool initialized = fActive != nil;
-       if (dynamicScope.size() > 0)
-               enableDynamic(maker);
+    fEnabled = true;
+    bool initialized = fActive != nil;
+    if (dynamicScope.size() > 0)
+        enableDynamic(maker);
     if (maker.fError.hasError()) 
         return false;
-       int animators = fAnimators.count();
-       int index;
-       for (index = 0; index < animators; index++) {
-               SkAnimateBase* animator = fAnimators[index];
-               animator->fStart = maker.fEnableTime;
-               animator->fResetPending = animator->fReset;
-       }
-       if (scope && scope->isApply())
-               ((SkApply*) scope)->setEmbedded();
-/*     if (mode == kMode_once) {
-               if (scope) {
-                       activate(maker);
-                       interpolate(maker, maker.fEnableTime);
-                       inactivate(maker);
-               }
-               return true;
-       }*/
-       if ((mode == kMode_immediate || mode == kMode_create) && scope == nil)
-               return false;   // !!! error?
-       bool enableMe = scope && (scope->hasEnable() || scope->isApply() || scope->isDrawable() == false);
-       if (mode == kMode_immediate && enableMe || mode == kMode_create)
-               activate(maker);        // for non-drawables like post, prime them here
-       if (mode == kMode_immediate && enableMe)
-               fActive->enable();
-       if (mode == kMode_create && scope != nil) {
-               enableCreate(maker);
-               return true;
-       }
-       if (mode == kMode_immediate) {
-               return scope->isApply() || scope->isDrawable() == false;
-       }
-       refresh(maker);
-       SkDisplayList& displayList = maker.fDisplayList;
-       SkDrawable* drawable;
+    int animators = fAnimators.count();
+    int index;
+    for (index = 0; index < animators; index++) {
+        SkAnimateBase* animator = fAnimators[index];
+        animator->fStart = maker.fEnableTime;
+        animator->fResetPending = animator->fReset;
+    }
+    if (scope && scope->isApply())
+        ((SkApply*) scope)->setEmbedded();
+/*  if (mode == kMode_once) {
+        if (scope) {
+            activate(maker);
+            interpolate(maker, maker.fEnableTime);
+            inactivate(maker);
+        }
+        return true;
+    }*/
+    if ((mode == kMode_immediate || mode == kMode_create) && scope == nil)
+        return false;   // !!! error?
+    bool enableMe = scope && (scope->hasEnable() || scope->isApply() || scope->isDrawable() == false);
+    if (mode == kMode_immediate && enableMe || mode == kMode_create)
+        activate(maker);    // for non-drawables like post, prime them here
+    if (mode == kMode_immediate && enableMe)
+        fActive->enable();
+    if (mode == kMode_create && scope != nil) {
+        enableCreate(maker);
+        return true;
+    }
+    if (mode == kMode_immediate) {
+        return scope->isApply() || scope->isDrawable() == false;
+    }
+    refresh(maker);
+    SkDisplayList& displayList = maker.fDisplayList;
+    SkDrawable* drawable;
 #if defined SK_DEBUG && defined SK_DEBUG_ANIMATION_TIMING
-       SkString debugOut;
-       SkMSec time = maker.getAppTime();
-       debugOut.appendS32(time - maker.fDebugTimeBase);
-       debugOut.append(" apply enable id=");
-       debugOut.append(_id);
-       debugOut.append("; start=");
-       debugOut.appendS32(maker.fEnableTime - maker.fDebugTimeBase);
-       SkDebugf("%s\n", debugOut.c_str());
+    SkString debugOut;
+    SkMSec time = maker.getAppTime();
+    debugOut.appendS32(time - maker.fDebugTimeBase);
+    debugOut.append(" apply enable id=");
+    debugOut.append(_id);
+    debugOut.append("; start=");
+    debugOut.appendS32(maker.fEnableTime - maker.fDebugTimeBase);
+    SkDebugf("%s\n", debugOut.c_str());
 #endif
-       if (scope == nil || scope->isApply() || scope->getType() == SkType_Movie || scope->isDrawable() == false) {
-               activate(maker);        // for non-drawables like post, prime them here
-               if (initialized) {
-                       append(this);
-               }
-               fEnabling = true;
-               interpolate(maker, maker.fEnableTime);
-               fEnabling = false;
-               if (scope != nil && dontDraw == false)
-                       scope->enable(maker);
-               return true;
-       } else if (initialized && restore == false)
-               append(this);
+    if (scope == nil || scope->isApply() || scope->getType() == SkType_Movie || scope->isDrawable() == false) {
+        activate(maker);    // for non-drawables like post, prime them here
+        if (initialized) {
+            append(this);
+        }
+        fEnabling = true;
+        interpolate(maker, maker.fEnableTime);
+        fEnabling = false;
+        if (scope != nil && dontDraw == false)
+            scope->enable(maker);
+        return true;
+    } else if (initialized && restore == false)
+        append(this);
 #if 0
-       bool wasActive = inactivate(maker); // start fresh
-       if (wasActive) {
-               activate(maker);
-               interpolate(maker, maker.fEnableTime);
-               return true;
-       }
+    bool wasActive = inactivate(maker); // start fresh
+    if (wasActive) {
+        activate(maker);
+        interpolate(maker, maker.fEnableTime);
+        return true;
+    }
 #endif
-//     start here;
-       // now that one apply might embed another, only the parent apply should replace the scope 
-       // or get appended to the display list
-       // similarly, an apply added by an add immediate has already been located in the display list
-       // and should not get moved or added again here
-       if (fEmbedded) {
-               return false;   // already added to display list by embedder
-       }
-       drawable = (SkDrawable*) scope;
-       SkTDDrawableArray* parentList;
-       SkTDDrawableArray* grandList;
-       SkGroup* parentGroup;
-       SkGroup* thisGroup;
-       int old = displayList.findGroup(drawable, &parentList, &parentGroup, &thisGroup, &grandList);
-       if (old < 0)
-               goto append;
-       else if (fContainsScope) {
-               if ((*parentList)[old] != this || restore == true) {
+//  start here;
+    // now that one apply might embed another, only the parent apply should replace the scope 
+    // or get appended to the display list
+    // similarly, an apply added by an add immediate has already been located in the display list
+    // and should not get moved or added again here
+    if (fEmbedded) {
+        return false;   // already added to display list by embedder
+    }
+    drawable = (SkDrawable*) scope;
+    SkTDDrawableArray* parentList;
+    SkTDDrawableArray* grandList;
+    SkGroup* parentGroup;
+    SkGroup* thisGroup;
+    int old = displayList.findGroup(drawable, &parentList, &parentGroup, &thisGroup, &grandList);
+    if (old < 0)
+        goto append;
+    else if (fContainsScope) {
+        if ((*parentList)[old] != this || restore == true) {
 append:
-                       if (parentGroup)
-                               parentGroup->markCopySize(old);
-                       if (parentList->count() < 10000) {
-                               fAppended = true;
-                               *parentList->append() = this;
-                       } else
-                               maker.setErrorCode(SkDisplayXMLParserError::kDisplayTreeTooDeep);
-                       old = -1;
-               } else
-                       reset();
-       } else {
-               SkASSERT(old < parentList->count());
-               if ((*parentList)[old]->isApply()) {
-                       SkApply* apply = (SkApply*) (*parentList)[old];
-                       if (apply != this && apply->fActive == nil)
-                               apply->activate(maker);
-                       apply->append(this);
-                       parentGroup = nil;
-               } else {
-                       if (parentGroup)
-                               parentGroup->markCopySize(old);
-                       SkDrawable** newApplyLocation = &(*parentList)[old];
-                       SkGroup* pGroup;
-                       int oldApply = displayList.findGroup(this, &parentList, &pGroup, &thisGroup, &grandList);
-                       if (oldApply >= 0) {
-                               (*parentList)[oldApply] = (SkDrawable*) SkDisplayType::CreateInstance(&maker, SkType_Apply);
-                               parentGroup = nil;
-                               fDeleteScope = true;
-                       }
-                       *newApplyLocation = this;
-               }
-       }
-       if (parentGroup) {
-               parentGroup->markCopySet(old);
-               fDeleteScope = dynamicScope.size() == 0;
-       }
-       return true;
+            if (parentGroup)
+                parentGroup->markCopySize(old);
+            if (parentList->count() < 10000) {
+                fAppended = true;
+                *parentList->append() = this;
+            } else
+                maker.setErrorCode(SkDisplayXMLParserError::kDisplayTreeTooDeep);
+            old = -1;
+        } else
+            reset();
+    } else {
+        SkASSERT(old < parentList->count());
+        if ((*parentList)[old]->isApply()) {
+            SkApply* apply = (SkApply*) (*parentList)[old];
+            if (apply != this && apply->fActive == nil)
+                apply->activate(maker);
+            apply->append(this);
+            parentGroup = nil;
+        } else {
+            if (parentGroup)
+                parentGroup->markCopySize(old);
+            SkDrawable** newApplyLocation = &(*parentList)[old];
+            SkGroup* pGroup;
+            int oldApply = displayList.findGroup(this, &parentList, &pGroup, &thisGroup, &grandList);
+            if (oldApply >= 0) {
+                (*parentList)[oldApply] = (SkDrawable*) SkDisplayType::CreateInstance(&maker, SkType_Apply);
+                parentGroup = nil;
+                fDeleteScope = true;
+            }
+            *newApplyLocation = this;
+        }
+    }
+    if (parentGroup) {
+        parentGroup->markCopySet(old);
+        fDeleteScope = dynamicScope.size() == 0;
+    }
+    return true;
 }
 
 void SkApply::enableCreate(SkAnimateMaker& maker) {
-       SkString newID;
-       for (int step = 0; step <= steps; step++) {
-               fLastTime = step * SK_MSec1;
-               bool success = maker.computeID(scope, this, &newID);
-               if (success == false)
-                       return;
-               if (maker.find(newID.c_str(), nil))
-                       continue;
-               SkApply* copy = (SkApply*) deepCopy(&maker); // work on copy of animator state
-               if (mode == kMode_create)
-                       copy->mode = (Mode) -1;
-               SkDrawable* copyScope = copy->scope = (SkDrawable*) scope->deepCopy(&maker);
-               *fScopes.append() = copyScope;
-               if (copyScope->resolveIDs(maker, scope, this)) {
-                       step = steps; // quit
-                       goto next; // resolveIDs failed
-               }
-               if (newID.size() > 0) 
-                       maker.setID(copyScope, newID);
-               if (copy->resolveIDs(maker, this, this)) { // fix up all fields, including target
-                       step = steps; // quit
-                       goto next; // resolveIDs failed
-               }
-               copy->activate(maker);
-               copy->interpolate(maker, step * SK_MSec1);
-               maker.removeActive(copy->fActive);
-       next:
-               delete copy;
-       }
+    SkString newID;
+    for (int step = 0; step <= steps; step++) {
+        fLastTime = step * SK_MSec1;
+        bool success = maker.computeID(scope, this, &newID);
+        if (success == false)
+            return;
+        if (maker.find(newID.c_str(), nil))
+            continue;
+        SkApply* copy = (SkApply*) deepCopy(&maker); // work on copy of animator state
+        if (mode == kMode_create)
+            copy->mode = (Mode) -1;
+        SkDrawable* copyScope = copy->scope = (SkDrawable*) scope->deepCopy(&maker);
+        *fScopes.append() = copyScope;
+        if (copyScope->resolveIDs(maker, scope, this)) {
+            step = steps; // quit
+            goto next; // resolveIDs failed
+        }
+        if (newID.size() > 0) 
+            maker.setID(copyScope, newID);
+        if (copy->resolveIDs(maker, this, this)) { // fix up all fields, including target
+            step = steps; // quit
+            goto next; // resolveIDs failed
+        }
+        copy->activate(maker);
+        copy->interpolate(maker, step * SK_MSec1);
+        maker.removeActive(copy->fActive);
+    next:
+        delete copy;
+    }
 }
 
 void SkApply::enableDynamic(SkAnimateMaker& maker) {
-       SkASSERT(mode != kMode_create); // create + dynamic are not currently compatible
-       SkDisplayable* newScope;
-       bool success = SkAnimatorScript::EvaluateDisplayable(maker, this, dynamicScope.c_str(),
-               &newScope);
-       if (success && scope != newScope) {
-               SkTDDrawableArray* pList, * gList;
-               SkGroup* pGroup = nil, * found = nil;
-               int old = maker.fDisplayList.findGroup(scope, &pList, &pGroup, &found, &gList);
-               if (pList && old >= 0 && (*pList)[old]->isApply() && (*pList)[old] != this) {
-                       if (fAppended == false) {
-                               if (found != nil) {
-                                       SkDisplayable* oldChild = (*pList)[old];
-                                       if (oldChild->isApply() && found->copySet(old)) {
-                                               found->markCopyClear(old);
-       //                                      delete oldChild;
-                                       }
-                               }
-                               (*pList)[old] = scope;
-                       } else
-                               pList->remove(old);
-               }
-               scope = (SkDrawable*) newScope;
-               onEndElement(maker);
-       }
-       maker.removeActive(fActive);
-       delete fActive;
-       fActive = nil;
+    SkASSERT(mode != kMode_create); // create + dynamic are not currently compatible
+    SkDisplayable* newScope;
+    bool success = SkAnimatorScript::EvaluateDisplayable(maker, this, dynamicScope.c_str(),
+        &newScope);
+    if (success && scope != newScope) {
+        SkTDDrawableArray* pList, * gList;
+        SkGroup* pGroup = nil, * found = nil;
+        int old = maker.fDisplayList.findGroup(scope, &pList, &pGroup, &found, &gList);
+        if (pList && old >= 0 && (*pList)[old]->isApply() && (*pList)[old] != this) {
+            if (fAppended == false) {
+                if (found != nil) {
+                    SkDisplayable* oldChild = (*pList)[old];
+                    if (oldChild->isApply() && found->copySet(old)) {
+                        found->markCopyClear(old);
+    //                  delete oldChild;
+                    }
+                }
+                (*pList)[old] = scope;
+            } else
+                pList->remove(old);
+        }
+        scope = (SkDrawable*) newScope;
+        onEndElement(maker);
+    }
+    maker.removeActive(fActive);
+    delete fActive;
+    fActive = nil;
 }
 
 void SkApply::endSave(int index) {
-       SkAnimateBase* animate = fActive->fAnimators[index];
-       const SkMemberInfo* info = animate->fFieldInfo;
-       SkDisplayTypes type = (SkDisplayTypes) info->fType;
-       if (type == SkType_MemberFunction)
-               return;
-       SkDisplayable* target = getTarget(animate);
-       size_t size = info->getSize(target);
-       int count = (int) (size / sizeof(SkScalar));
-       int activeIndex = fActive->fDrawIndex + index;
-       SkOperand* last = new SkOperand[count];
-       SkAutoTDelete<SkOperand> autoLast(last);
-       if (type != SkType_MemberProperty) {
-               info->getValue(target, last, count);
-               SkOperand* saveOperand = fActive->fSaveRestore[activeIndex];
-               if (saveOperand)
-                       info->setValue(target, fActive->fSaveRestore[activeIndex], count);
-       } else {
-               SkScriptValue scriptValue;
-               bool success = target->getProperty(info->propertyIndex(), &scriptValue);
-               SkASSERT(success = true);
-               last[0] = scriptValue.fOperand;
-               scriptValue.fOperand = fActive->fSaveRestore[activeIndex][0];
-               target->setProperty(info->propertyIndex(), scriptValue);
-       }
-       SkOperand* save = fActive->fSaveRestore[activeIndex];
-       if (save)
-               memcpy(save, last, count * sizeof(SkOperand));
+    SkAnimateBase* animate = fActive->fAnimators[index];
+    const SkMemberInfo* info = animate->fFieldInfo;
+    SkDisplayTypes type = (SkDisplayTypes) info->fType;
+    if (type == SkType_MemberFunction)
+        return;
+    SkDisplayable* target = getTarget(animate);
+    size_t size = info->getSize(target);
+    int count = (int) (size / sizeof(SkScalar));
+    int activeIndex = fActive->fDrawIndex + index;
+    SkOperand* last = new SkOperand[count];
+    SkAutoTDelete<SkOperand> autoLast(last);
+    if (type != SkType_MemberProperty) {
+        info->getValue(target, last, count);
+        SkOperand* saveOperand = fActive->fSaveRestore[activeIndex];
+        if (saveOperand)
+            info->setValue(target, fActive->fSaveRestore[activeIndex], count);
+    } else {
+        SkScriptValue scriptValue;
+        bool success = target->getProperty(info->propertyIndex(), &scriptValue);
+        SkASSERT(success = true);
+        last[0] = scriptValue.fOperand;
+        scriptValue.fOperand = fActive->fSaveRestore[activeIndex][0];
+        target->setProperty(info->propertyIndex(), scriptValue);
+    }
+    SkOperand* save = fActive->fSaveRestore[activeIndex];
+    if (save)
+        memcpy(save, last, count * sizeof(SkOperand));
 }
 
 bool SkApply::getProperty(int index, SkScriptValue* value) const {
-       switch (index) {
-               case SK_PROPERTY(step):
-                       value->fType = SkType_Int;
-                       value->fOperand.fS32 = fLastTime / SK_MSec1;
-                       break;
-               case SK_PROPERTY(steps):
-                       value->fType = SkType_Int;
-                       value->fOperand.fS32 = steps;
-                       break;
-               case SK_PROPERTY(time):
-                       value->fType = SkType_MSec;
-                       value->fOperand.fS32 = fLastTime;
-                       break;
-               default:
-       //              SkASSERT(0);
-                       return false;
-       }
-       return true;
+    switch (index) {
+        case SK_PROPERTY(step):
+            value->fType = SkType_Int;
+            value->fOperand.fS32 = fLastTime / SK_MSec1;
+            break;
+        case SK_PROPERTY(steps):
+            value->fType = SkType_Int;
+            value->fOperand.fS32 = steps;
+            break;
+        case SK_PROPERTY(time):
+            value->fType = SkType_MSec;
+            value->fOperand.fS32 = fLastTime;
+            break;
+        default:
+    //      SkASSERT(0);
+            return false;
+    }
+    return true;
 }
 
 void SkApply::getStep(SkScriptValue* value) {
-       getProperty(SK_PROPERTY(step), value);
+    getProperty(SK_PROPERTY(step), value);
 }
 
 SkDrawable* SkApply::getTarget(SkAnimateBase* animate) {
-       if (animate->fTargetIsScope == false || mode != kMode_create)
-               return animate->fTarget;
-       return scope;
+    if (animate->fTargetIsScope == false || mode != kMode_create)
+        return animate->fTarget;
+    return scope;
 }
 
 bool SkApply::hasDelayedAnimator() const {
-       SkAnimateBase** animEnd = fAnimators.end();
-       for (SkAnimateBase** animPtr = fAnimators.begin(); animPtr < animEnd; animPtr++) {
-               SkAnimateBase* animator = *animPtr;
-               if (animator->fDelayed) 
-                       return true;
-       }
-       return false;
+    SkAnimateBase** animEnd = fAnimators.end();
+    for (SkAnimateBase** animPtr = fAnimators.begin(); animPtr < animEnd; animPtr++) {
+        SkAnimateBase* animator = *animPtr;
+        if (animator->fDelayed) 
+            return true;
+    }
+    return false;
 }
 
 bool SkApply::hasEnable() const {
-       return true;
+    return true;
 }
 
 bool SkApply::inactivate(SkAnimateMaker& maker) {
-       if (fActive == nil)
-               return false;
-       maker.removeActive(fActive);
-       delete fActive;
-       fActive = nil;
-       return true;
+    if (fActive == nil)
+        return false;
+    maker.removeActive(fActive);
+    delete fActive;
+    fActive = nil;
+    return true;
 }
 
 #ifdef SK_DEBUG
@@ -531,115 +548,115 @@ SkMSec lastTime = (SkMSec) -1;
 #endif
 
 bool SkApply::interpolate(SkAnimateMaker& maker, SkMSec rawTime) {
-       if (fActive == nil)
-               return false;
-       bool result = false;
+    if (fActive == nil)
+        return false;
+    bool result = false;
 #if defined SK_DEBUG && defined SK_DEBUG_ANIMATION_TIMING
-       SkMSec time = maker.getAppTime();
-       if (lastTime == (SkMSec) -1)
-               lastTime = rawTime - 1;
-       if (fActive != nil && 
-               strcmp(id, "a3") == 0 && rawTime > lastTime) {
-               lastTime += 1000;
-               SkString debugOut;
-               debugOut.appendS32(time - maker.fDebugTimeBase);
-               debugOut.append(" apply id=");
-               debugOut.append(_id);
-               debugOut.append("; ");
-               debugOut.append(fActive->fAnimators[0]->_id);
-               debugOut.append("=");
-               debugOut.appendS32(rawTime - fActive->fState[0].fStartTime);
-               debugOut.append(")");
-               SkDebugf("%s\n", debugOut.c_str());
-       }
+    SkMSec time = maker.getAppTime();
+    if (lastTime == (SkMSec) -1)
+        lastTime = rawTime - 1;
+    if (fActive != nil && 
+        strcmp(id, "a3") == 0 && rawTime > lastTime) {
+        lastTime += 1000;
+        SkString debugOut;
+        debugOut.appendS32(time - maker.fDebugTimeBase);
+        debugOut.append(" apply id=");
+        debugOut.append(_id);
+        debugOut.append("; ");
+        debugOut.append(fActive->fAnimators[0]->_id);
+        debugOut.append("=");
+        debugOut.appendS32(rawTime - fActive->fState[0].fStartTime);
+        debugOut.append(")");
+        SkDebugf("%s\n", debugOut.c_str());
+    }
 #endif
-       fActive->start();
-       if (restore)
-               fActive->initializeSave();
-       int animators = fActive->fAnimators.count();
-       for (int inner = 0; inner < animators; inner++) {
-               SkAnimateBase* animate = fActive->fAnimators[inner];
-               if (animate->fChanged) {
-                       animate->fChanged = false;
-                       animate->fStart = rawTime;
-       //              SkTypedArray values;
-       //              int count = animate->fValues.count();
-       //              values.setCount(count);
-       //              memcpy(values.begin(), animate->fValues.begin(), sizeof(SkOperand) * count);
-                       animate->onEndElement(maker);
-       //              if (memcmp(values.begin(), animate->fValues.begin(), sizeof(SkOperand) * count) != 0) {
-                               fActive->append(this);
-                               fActive->start();
-       //              }
-               }
-               SkMSec time = fActive->getTime(rawTime, inner);
-               SkActive::SkState& state = fActive->fState[inner];
-               if (SkMSec_LT(rawTime, state.fStartTime)) {
-                       if (fEnabling) {
-                               animate->fDelayed = true;
-                               maker.delayEnable(this, state.fStartTime);
-                       }
-                       continue;
-               } else
-                       animate->fDelayed = false;
-               SkMSec innerTime = fLastTime = state.getRelativeTime(time);
-               if (restore) 
-                       fActive->restoreInterpolatorValues(inner);
-               if (animate->fReset) {
-                       if (transition != SkApply::kTransition_reverse) {
-                               if (SkMSec_LT(state.fBegin + state.fDuration, innerTime)) {
-                                       if (animate->fResetPending) {
-                                               innerTime = 0;
-                                               animate->fResetPending = false;
-                                       } else
-                                               continue;
-                               }
-                       } else if (innerTime == 0) {
-                                       if (animate->fResetPending) {
-                                               innerTime = state.fBegin + state.fDuration;
-                                               animate->fResetPending = false;
-                                       } else
-                                               continue;
-                       }
-               }
-               int count = animate->components();
-               SkAutoSTMalloc<16, SkOperand> values(count);
-               SkInterpolatorBase::Result interpResult = fActive->fInterpolators[inner]->timeToValues(
-                       innerTime, values.get());
-               result |= (interpResult != SkInterpolatorBase::kFreezeEnd_Result);
-               if ((transition != SkApply::kTransition_reverse && interpResult == SkInterpolatorBase::kFreezeEnd_Result ||
-                               transition == SkApply::kTransition_reverse && fLastTime == 0) && state.fUnpostedEndEvent) {
-//                     SkDEBUGF(("interpolate: post on end\n"));
-                       state.fUnpostedEndEvent = false;
-                       maker.postOnEnd(animate, state.fBegin + state.fDuration);
-                       maker.fAdjustedStart = 0;        // !!! left over from synchronizing animation days, undoubtably out of date (and broken)
-               }
-               if (animate->formula.size() > 0) {
-                       if (fLastTime > animate->dur)
-                               fLastTime = animate->dur;
-                       SkTypedArray formulaValues;
-                       formulaValues.setCount(count);
-                       bool success = animate->fFieldInfo->setValue(maker, &formulaValues, 0, 0, nil, 
-                               animate->getValuesType(), animate->formula);
-                       SkASSERT(success);
-                       if (restore)
-                               save(inner); // save existing value
-                       applyValues(inner, formulaValues.begin(), count, animate->getValuesType(), innerTime);
-               } else {
-                       if (restore)
-                               save(inner); // save existing value
-                       applyValues(inner, values.get(), count, animate->getValuesType(), innerTime);
-               }
-       }
-       return result;
+    fActive->start();
+    if (restore)
+        fActive->initializeSave();
+    int animators = fActive->fAnimators.count();
+    for (int inner = 0; inner < animators; inner++) {
+        SkAnimateBase* animate = fActive->fAnimators[inner];
+        if (animate->fChanged) {
+            animate->fChanged = false;
+            animate->fStart = rawTime;
+    //      SkTypedArray values;
+    //      int count = animate->fValues.count();
+    //      values.setCount(count);
+    //      memcpy(values.begin(), animate->fValues.begin(), sizeof(SkOperand) * count);
+            animate->onEndElement(maker);
+    //      if (memcmp(values.begin(), animate->fValues.begin(), sizeof(SkOperand) * count) != 0) {
+                fActive->append(this);
+                fActive->start();
+    //      }
+        }
+        SkMSec time = fActive->getTime(rawTime, inner);
+        SkActive::SkState& state = fActive->fState[inner];
+        if (SkMSec_LT(rawTime, state.fStartTime)) {
+            if (fEnabling) {
+                animate->fDelayed = true;
+                maker.delayEnable(this, state.fStartTime);
+            }
+            continue;
+        } else
+            animate->fDelayed = false;
+        SkMSec innerTime = fLastTime = state.getRelativeTime(time);
+        if (restore) 
+            fActive->restoreInterpolatorValues(inner);
+        if (animate->fReset) {
+            if (transition != SkApply::kTransition_reverse) {
+                if (SkMSec_LT(state.fBegin + state.fDuration, innerTime)) {
+                    if (animate->fResetPending) {
+                        innerTime = 0;
+                        animate->fResetPending = false;
+                    } else
+                        continue;
+                }
+            } else if (innerTime == 0) {
+                    if (animate->fResetPending) {
+                        innerTime = state.fBegin + state.fDuration;
+                        animate->fResetPending = false;
+                    } else
+                        continue;
+            }
+        }
+        int count = animate->components();
+        SkAutoSTMalloc<16, SkOperand> values(count);
+        SkInterpolatorBase::Result interpResult = fActive->fInterpolators[inner]->timeToValues(
+            innerTime, values.get());
+        result |= (interpResult != SkInterpolatorBase::kFreezeEnd_Result);
+        if ((transition != SkApply::kTransition_reverse && interpResult == SkInterpolatorBase::kFreezeEnd_Result ||
+                transition == SkApply::kTransition_reverse && fLastTime == 0) && state.fUnpostedEndEvent) {
+//          SkDEBUGF(("interpolate: post on end\n"));
+            state.fUnpostedEndEvent = false;
+            maker.postOnEnd(animate, state.fBegin + state.fDuration);
+            maker.fAdjustedStart = 0;    // !!! left over from synchronizing animation days, undoubtably out of date (and broken)
+        }
+        if (animate->formula.size() > 0) {
+            if (fLastTime > animate->dur)
+                fLastTime = animate->dur;
+            SkTypedArray formulaValues;
+            formulaValues.setCount(count);
+            bool success = animate->fFieldInfo->setValue(maker, &formulaValues, 0, 0, nil, 
+                animate->getValuesType(), animate->formula);
+            SkASSERT(success);
+            if (restore)
+                save(inner); // save existing value
+            applyValues(inner, formulaValues.begin(), count, animate->getValuesType(), innerTime);
+        } else {
+            if (restore)
+                save(inner); // save existing value
+            applyValues(inner, values.get(), count, animate->getValuesType(), innerTime);
+        }
+    }
+    return result;
 }
 
 void SkApply::initialize() {
-       if (scope == nil)
-               return;
-       if (scope->isApply() || scope->isDrawable() == false)
-               return;
-       scope->initialize();
+    if (scope == nil)
+        return;
+    if (scope->isApply() || scope->isDrawable() == false)
+        return;
+    scope->initialize();
 }
 
 void SkApply::onEndElement(SkAnimateMaker& maker) 
@@ -653,143 +670,143 @@ void SkApply::onEndElement(SkAnimateMaker& maker)
         }
         scopePtr = scopedApply->scope;
     }
-       if (mode == kMode_create)
-               return;
-       if (scope != nil && steps >= 0 && scope->isApply() == false && scope->isDrawable())
-               scope->setSteps(steps);
-       for (SkAnimateBase** animPtr = fAnimators.begin(); animPtr < fAnimators.end(); animPtr++) {
-               SkAnimateBase* anim = *animPtr;
+    if (mode == kMode_create)
+        return;
+    if (scope != nil && steps >= 0 && scope->isApply() == false && scope->isDrawable())
+        scope->setSteps(steps);
+    for (SkAnimateBase** animPtr = fAnimators.begin(); animPtr < fAnimators.end(); animPtr++) {
+        SkAnimateBase* anim = *animPtr;
         //for reusing apply statements with dynamic scope
-               if (anim->fTarget == nil || anim->fTargetIsScope) {
-                       anim->fTargetIsScope = true;
-                       if (scope)
-                               anim->fTarget = scope;
-                       else
-                               anim->setTarget(maker);
-                       anim->onEndElement(maker);      // allows animate->fFieldInfo to be set
-               }
-               if (scope != nil && steps >= 0 && anim->fTarget != scope && anim->fTarget->isDrawable())
-                       anim->fTarget->setSteps(steps);
-       }
+        if (anim->fTarget == nil || anim->fTargetIsScope) {
+            anim->fTargetIsScope = true;
+            if (scope)
+                anim->fTarget = scope;
+            else
+                anim->setTarget(maker);
+            anim->onEndElement(maker);  // allows animate->fFieldInfo to be set
+        }
+        if (scope != nil && steps >= 0 && anim->fTarget != scope && anim->fTarget->isDrawable())
+            anim->fTarget->setSteps(steps);
+    }
 }
 
 const SkMemberInfo* SkApply::preferredChild(SkDisplayTypes type) {
-       SkASSERT(SkDisplayType::IsAnimate(type) == false);
-       fContainsScope = true;
-       return getMember("scope"); // !!! cwap! need to refer to member through enum like kScope instead
+    SkASSERT(SkDisplayType::IsAnimate(type) == false);
+    fContainsScope = true;
+    return getMember("scope"); // !!! cwap! need to refer to member through enum like kScope instead
 }
 
 void SkApply::refresh(SkAnimateMaker& maker) {
-       for (SkAnimateBase** animPtr = fAnimators.begin(); animPtr < fAnimators.end(); animPtr++) {
-               SkAnimateBase* animate = *animPtr;
-               animate->onEndElement(maker);
-       }
-       if (fActive)
-               fActive->resetInterpolators();
+    for (SkAnimateBase** animPtr = fAnimators.begin(); animPtr < fAnimators.end(); animPtr++) {
+        SkAnimateBase* animate = *animPtr;
+        animate->onEndElement(maker);
+    }
+    if (fActive)
+        fActive->resetInterpolators();
 }
 
 void SkApply::reset() {
-       if (fActive)
-               fActive->resetState();
-}
-
-bool SkApply::resolveIDs(SkAnimateMaker& maker, SkDisplayable* original, SkApply* apply) { //  replace to/formula strings in animators of the form xxx.step with the step value, if xxx.step is in scope
-       if (resolveField(maker, apply, &dynamicScope) == false)
-               return true;    // failed
-       SkAnimateBase** endPtr = fAnimators.end();
-       SkAnimateBase** origPtr = ((SkApply*) original)->fAnimators.begin();
-       for (SkAnimateBase** animPtr = fAnimators.begin(); animPtr < endPtr; ) {
-               SkAnimateBase* animator = *animPtr++;
-               maker.resolveID(animator, *origPtr++);
-               if (resolveField(maker, this, &animator->target) == false)
-                       return true;
-               if (resolveField(maker, this, &animator->from) == false)
-                       return true;
-               if (resolveField(maker, this, &animator->to) == false)
-                       return true;
-               if (resolveField(maker, this, &animator->formula) == false)
-                       return true;
-       }
-//     setEmbedded();
-       onEndElement(maker);
-       return false; // succeeded
+    if (fActive)
+        fActive->resetState();
+}
+
+bool SkApply::resolveIDs(SkAnimateMaker& maker, SkDisplayable* original, SkApply* apply) { //   replace to/formula strings in animators of the form xxx.step with the step value, if xxx.step is in scope
+    if (resolveField(maker, apply, &dynamicScope) == false)
+        return true;    // failed
+    SkAnimateBase** endPtr = fAnimators.end();
+    SkAnimateBase** origPtr = ((SkApply*) original)->fAnimators.begin();
+    for (SkAnimateBase** animPtr = fAnimators.begin(); animPtr < endPtr; ) {
+        SkAnimateBase* animator = *animPtr++;
+        maker.resolveID(animator, *origPtr++);
+        if (resolveField(maker, this, &animator->target) == false)
+            return true;
+        if (resolveField(maker, this, &animator->from) == false)
+            return true;
+        if (resolveField(maker, this, &animator->to) == false)
+            return true;
+        if (resolveField(maker, this, &animator->formula) == false)
+            return true;
+    }
+//  setEmbedded();
+    onEndElement(maker);
+    return false; // succeeded
 }
 
 bool SkApply::resolveField(SkAnimateMaker& maker, SkDisplayable* parent, SkString* str) {
-       const char* script = str->c_str();
-       if (str->startsWith("#string:") == false)
-               return true;
-       script += sizeof("#string:") - 1;
-       return SkAnimatorScript::EvaluateString(maker, this, parent, script, str);
+    const char* script = str->c_str();
+    if (str->startsWith("#string:") == false)
+        return true;
+    script += sizeof("#string:") - 1;
+    return SkAnimatorScript::EvaluateString(maker, this, parent, script, str);
 }
 
 void SkApply::save(int index) {
-       SkAnimateBase* animate = fActive->fAnimators[index];
-       const SkMemberInfo * info = animate->fFieldInfo;
-       SkDisplayable* target = getTarget(animate);
-//     if (animate->hasExecute())
-//             info = animate->getResolvedInfo();
-       SkDisplayTypes type = (SkDisplayTypes) info->fType;
-       if (type == SkType_MemberFunction)
-               return; // nothing to save
-       size_t size = info->getSize(target);
-       int count = (int) (size / sizeof(SkScalar));
-       bool useLast = true;
+    SkAnimateBase* animate = fActive->fAnimators[index];
+    const SkMemberInfo * info = animate->fFieldInfo;
+    SkDisplayable* target = getTarget(animate);
+//  if (animate->hasExecute())
+//      info = animate->getResolvedInfo();
+    SkDisplayTypes type = (SkDisplayTypes) info->fType;
+    if (type == SkType_MemberFunction)
+        return; // nothing to save
+    size_t size = info->getSize(target);
+    int count = (int) (size / sizeof(SkScalar));
+    bool useLast = true;
 // !!! this all may be unneeded, at least in the dynamic case ??
-       int activeIndex = fActive->fDrawIndex + index;
-       SkTDOperandArray last;
-       if (fActive->fSaveRestore[activeIndex] == nil) {
-               fActive->fSaveRestore[activeIndex] = new SkOperand[count];
-               useLast = false;
-       } else {
-               last.setCount(count);
-               memcpy(last.begin(), fActive->fSaveRestore[activeIndex], count * sizeof(SkOperand));
-       }
-       if (type != SkType_MemberProperty) {
-               info->getValue(target, fActive->fSaveRestore[activeIndex], count);
-               if (useLast)
-                       info->setValue(target, last.begin(), count);
-       } else {
-               SkScriptValue scriptValue;
-               bool success = target->getProperty(info->propertyIndex(), &scriptValue);
-               SkASSERT(success == true);
-               SkASSERT(scriptValue.fType == SkType_Float);
-               fActive->fSaveRestore[activeIndex][0] = scriptValue.fOperand;
-               if (useLast) {
-                       SkScriptValue scriptValue;
-                       scriptValue.fType = type;
-                       scriptValue.fOperand = last[0];
-                       target->setProperty(info->propertyIndex(), scriptValue);
-               }
-       }
+    int activeIndex = fActive->fDrawIndex + index;
+    SkTDOperandArray last;
+    if (fActive->fSaveRestore[activeIndex] == nil) {
+        fActive->fSaveRestore[activeIndex] = new SkOperand[count];
+        useLast = false;
+    } else {
+        last.setCount(count);
+        memcpy(last.begin(), fActive->fSaveRestore[activeIndex], count * sizeof(SkOperand));
+    }
+    if (type != SkType_MemberProperty) {
+        info->getValue(target, fActive->fSaveRestore[activeIndex], count);
+        if (useLast)
+            info->setValue(target, last.begin(), count);
+    } else {
+        SkScriptValue scriptValue;
+        bool success = target->getProperty(info->propertyIndex(), &scriptValue);
+        SkASSERT(success == true);
+        SkASSERT(scriptValue.fType == SkType_Float);
+        fActive->fSaveRestore[activeIndex][0] = scriptValue.fOperand;
+        if (useLast) {
+            SkScriptValue scriptValue;
+            scriptValue.fType = type;
+            scriptValue.fOperand = last[0];
+            target->setProperty(info->propertyIndex(), scriptValue);
+        }
+    }
 // !!!  end of unneeded
 }
 
 bool SkApply::setProperty(int index, SkScriptValue& scriptValue) {
-       switch (index) {
-               case SK_PROPERTY(animator): {
-                       SkAnimateBase* animate = (SkAnimateBase*) scriptValue.fOperand.fDisplayable;
-                       SkASSERT(animate->isAnimate());
-                       *fAnimators.append() = animate;
-                       return true; 
-               }
-               case SK_PROPERTY(steps):
-                       steps = scriptValue.fOperand.fS32;
-                       if (fActive)
-                               fActive->setSteps(steps);
-                       return true;
-       }
-       return false;
+    switch (index) {
+        case SK_PROPERTY(animator): {
+            SkAnimateBase* animate = (SkAnimateBase*) scriptValue.fOperand.fDisplayable;
+            SkASSERT(animate->isAnimate());
+            *fAnimators.append() = animate;
+            return true; 
+        }
+        case SK_PROPERTY(steps):
+            steps = scriptValue.fOperand.fS32;
+            if (fActive)
+                fActive->setSteps(steps);
+            return true;
+    }
+    return false;
 }
 
 void SkApply::setSteps(int _steps) { 
-       steps = _steps; 
+    steps = _steps; 
 }
 
 #ifdef SK_DEBUG
 void SkApply::validate() {
-       if (fActive)
-               fActive->validate();
+    if (fActive)
+        fActive->validate();
 }
 #endif
 
index 883323a..fb4da3c 100644 (file)
@@ -1,3 +1,20 @@
+/* libs/graphics/animator/SkDisplayApply.h
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #ifndef SkDisplayApply_DEFINED
 #define SkDisplayApply_DEFINED
 
 class SkActive;
 
 class SkApply : public SkDrawable {
-       DECLARE_MEMBER_INFO(Apply);
+    DECLARE_MEMBER_INFO(Apply);
 public:
 
-       SkApply();
-       virtual ~SkApply();
+    SkApply();
+    virtual ~SkApply();
 
-       enum Transition {
-               kTransition_normal,
-               kTransition_reverse
-       };
-       
-       enum Mode {
-               kMode_create,
-               kMode_immediate,
-               //kMode_once
-       };
-       void activate(SkAnimateMaker& );
-       void append(SkApply* apply);
-       void appendActive(SkActive* );
-       void applyValues(int animatorIndex, SkOperand* values, int count,
-               SkDisplayTypes , SkMSec time);
-       virtual bool contains(SkDisplayable*);
-//     void createActive(SkAnimateMaker& );
-       virtual SkDisplayable* deepCopy(SkAnimateMaker* );
-       void disable();
-       virtual bool draw(SkAnimateMaker& );
+    enum Transition {
+        kTransition_normal,
+        kTransition_reverse
+    };
+    
+    enum Mode {
+        kMode_create,
+        kMode_immediate,
+        //kMode_once
+    };
+    void activate(SkAnimateMaker& );
+    void append(SkApply* apply);
+    void appendActive(SkActive* );
+    void applyValues(int animatorIndex, SkOperand* values, int count,
+        SkDisplayTypes , SkMSec time);
+    virtual bool contains(SkDisplayable*);
+//  void createActive(SkAnimateMaker& );
+    virtual SkDisplayable* deepCopy(SkAnimateMaker* );
+    void disable();
+    virtual bool draw(SkAnimateMaker& );
 #ifdef SK_DUMP_ENABLED
-       virtual void dump(SkAnimateMaker* );
+    virtual void dump(SkAnimateMaker* );
 #endif
-       virtual bool enable(SkAnimateMaker& );
-       void enableCreate(SkAnimateMaker& );
-       void enableDynamic(SkAnimateMaker& );
-       void endSave(int index);
-       Mode getMode() { return mode; }
-       virtual bool getProperty(int index, SkScriptValue* value) const;
-       SkDrawable* getScope() { return scope; }
-       void getStep(SkScriptValue* );
-       SkDrawable* getTarget(SkAnimateBase* );
-       bool hasDelayedAnimator() const;
-       virtual bool hasEnable() const;
-       bool inactivate(SkAnimateMaker& maker);
-       virtual void initialize(); 
-       bool interpolate(SkAnimateMaker& , SkMSec time);
-       virtual void onEndElement(SkAnimateMaker& );
-       virtual const SkMemberInfo* preferredChild(SkDisplayTypes type);
-       void refresh(SkAnimateMaker& );
-       void reset();
-       virtual bool resolveIDs(SkAnimateMaker& maker, SkDisplayable* original, SkApply* );
-       bool resolveField(SkAnimateMaker& , SkDisplayable* parent, SkString* str);
-       void save(int index);
-       void setEmbedded() { fEmbedded = true; }
-       virtual bool setProperty(int index, SkScriptValue& );
-       virtual void setSteps(int _steps);
-//     virtual void setTime(SkMSec time);
+    virtual bool enable(SkAnimateMaker& );
+    void enableCreate(SkAnimateMaker& );
+    void enableDynamic(SkAnimateMaker& );
+    void endSave(int index);
+    Mode getMode() { return mode; }
+    virtual bool getProperty(int index, SkScriptValue* value) const;
+    SkDrawable* getScope() { return scope; }
+    void getStep(SkScriptValue* );
+    SkDrawable* getTarget(SkAnimateBase* );
+    bool hasDelayedAnimator() const;
+    virtual bool hasEnable() const;
+    bool inactivate(SkAnimateMaker& maker);
+    virtual void initialize(); 
+    bool interpolate(SkAnimateMaker& , SkMSec time);
+    virtual void onEndElement(SkAnimateMaker& );
+    virtual const SkMemberInfo* preferredChild(SkDisplayTypes type);
+    void refresh(SkAnimateMaker& );
+    void reset();
+    virtual bool resolveIDs(SkAnimateMaker& maker, SkDisplayable* original, SkApply* );
+    bool resolveField(SkAnimateMaker& , SkDisplayable* parent, SkString* str);
+    void save(int index);
+    void setEmbedded() { fEmbedded = true; }
+    virtual bool setProperty(int index, SkScriptValue& );
+    virtual void setSteps(int _steps);
+//  virtual void setTime(SkMSec time);
 #ifdef SK_DEBUG
-       virtual void validate();
+    virtual void validate();
 #endif
 private:
-       SkMSec begin;
-       SkBool dontDraw;
-       SkString dynamicScope;
-       SkMSec interval;
-       Mode mode;
+    SkMSec begin;
+    SkBool dontDraw;
+    SkString dynamicScope;
+    SkMSec interval;
+    Mode mode;
 #if 0
-       SkBool pickup;
+    SkBool pickup;
 #endif
-       SkBool restore;
-       SkDrawable* scope;
-       S32 steps;
-       Transition transition;
-       SkActive* fActive;
-       SkTDAnimateArray fAnimators;
-//     SkDrawable* fCurrentScope;
-       SkMSec fLastTime;       // used only to return script property time
-       SkTDDrawableArray fScopes;
-       SkBool fAppended : 1;
-       SkBool fContainsScope : 1;
-       SkBool fDeleteScope : 1;
-       SkBool fEmbedded : 1;
-       SkBool fEnabled : 1;
-       SkBool fEnabling : 1; // set if calling interpolate from enable
-       friend class SkActive;
-       friend class SkDisplayList;
-       typedef SkDrawable INHERITED;
+    SkBool restore;
+    SkDrawable* scope;
+    S32 steps;
+    Transition transition;
+    SkActive* fActive;
+    SkTDAnimateArray fAnimators;
+//  SkDrawable* fCurrentScope;
+    SkMSec fLastTime;   // used only to return script property time
+    SkTDDrawableArray fScopes;
+    SkBool fAppended : 1;
+    SkBool fContainsScope : 1;
+    SkBool fDeleteScope : 1;
+    SkBool fEmbedded : 1;
+    SkBool fEnabled : 1;
+    SkBool fEnabling : 1; // set if calling interpolate from enable
+    friend class SkActive;
+    friend class SkDisplayList;
+    typedef SkDrawable INHERITED;
 };
 
 #endif // SkDisplayApply_DEFINED
index e6abcc3..ba12d8f 100644 (file)
@@ -1,11 +1,28 @@
+/* libs/graphics/animator/SkDisplayBounds.cpp
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #include "SkDisplayBounds.h"
 #include "SkAnimateMaker.h"
 
 #if SK_USE_CONDENSED_INFO == 0
 
 const SkMemberInfo SkDisplayBounds::fInfo[] = {
-       SK_MEMBER_INHERITED,
-       SK_MEMBER(inval, Boolean)
+    SK_MEMBER_INHERITED,
+    SK_MEMBER(inval, Boolean)
 };
 
 #endif
@@ -16,21 +33,21 @@ SkDisplayBounds::SkDisplayBounds() : inval(false) {
 }
 
 bool SkDisplayBounds::draw(SkAnimateMaker& maker) {
-       maker.fDisplayList.fUnionBounds = SkToBool(inval);
-       maker.fDisplayList.fDrawBounds = false;
-       fBounds.setEmpty();
-       bool result = INHERITED::draw(maker);
-       maker.fDisplayList.fUnionBounds = false;
-       maker.fDisplayList.fDrawBounds = true;
-       if (inval && fBounds.isEmpty() == false) {
-               SkRect16& rect = maker.fDisplayList.fInvalBounds;
-               maker.fDisplayList.fHasUnion = true;
-               if (rect.isEmpty())
-                       rect = fBounds;
-               else 
-                       rect.join(fBounds);
-       }
-       return result;
+    maker.fDisplayList.fUnionBounds = SkToBool(inval);
+    maker.fDisplayList.fDrawBounds = false;
+    fBounds.setEmpty();
+    bool result = INHERITED::draw(maker);
+    maker.fDisplayList.fUnionBounds = false;
+    maker.fDisplayList.fDrawBounds = true;
+    if (inval && fBounds.isEmpty() == false) {
+        SkRect16& rect = maker.fDisplayList.fInvalBounds;
+        maker.fDisplayList.fHasUnion = true;
+        if (rect.isEmpty())
+            rect = fBounds;
+        else 
+            rect.join(fBounds);
+    }
+    return result;
 }
 
 
index 077d4cc..fdfb78b 100644 (file)
@@ -1,15 +1,32 @@
+/* libs/graphics/animator/SkDisplayBounds.h
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #ifndef SkDisplayBounds_DEFINED
 #define SkDisplayBounds_DEFINED
 
 #include "SkDrawRectangle.h"
 
 class SkDisplayBounds : public SkDrawRect {
-       DECLARE_DISPLAY_MEMBER_INFO(Bounds);
-       SkDisplayBounds();
-       virtual bool draw(SkAnimateMaker& );
+    DECLARE_DISPLAY_MEMBER_INFO(Bounds);
+    SkDisplayBounds();
+    virtual bool draw(SkAnimateMaker& );
 private:
-       SkBool inval;
-       typedef SkDrawRect INHERITED;
+    SkBool inval;
+    typedef SkDrawRect INHERITED;
 };
 
 #endif // SkDisplayBounds_DEFINED
index 46af81c..469d6fc 100644 (file)
@@ -1,3 +1,20 @@
+/* libs/graphics/animator/SkDisplayEvent.cpp
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #include "SkDisplayEvent.h"
 #include "SkAnimateMaker.h"
 #include "SkDisplayApply.h"
 #include "SkUtils.h"
 
 enum SkDisplayEvent_Properties {
-       SK_PROPERTY(key),
-       SK_PROPERTY(keys)
+    SK_PROPERTY(key),
+    SK_PROPERTY(keys)
 };
 
 #if SK_USE_CONDENSED_INFO == 0
 
 const SkMemberInfo SkDisplayEvent::fInfo[] = {
-       SK_MEMBER(code, EventCode),
-       SK_MEMBER(disable, Boolean),
-       SK_MEMBER_PROPERTY(key, String), // a single key (also last key pressed)
-       SK_MEMBER_PROPERTY(keys, String), // a single key or dash-delimited range of keys
-       SK_MEMBER(kind, EventKind),
-       SK_MEMBER(target, String),
-       SK_MEMBER(x, Float),
-       SK_MEMBER(y, Float)
+    SK_MEMBER(code, EventCode),
+    SK_MEMBER(disable, Boolean),
+    SK_MEMBER_PROPERTY(key, String), // a single key (also last key pressed)
+    SK_MEMBER_PROPERTY(keys, String), // a single key or dash-delimited range of keys
+    SK_MEMBER(kind, EventKind),
+    SK_MEMBER(target, String),
+    SK_MEMBER(x, Float),
+    SK_MEMBER(y, Float)
 };
 
 #endif
@@ -36,40 +53,40 @@ const SkMemberInfo SkDisplayEvent::fInfo[] = {
 DEFINE_GET_MEMBER(SkDisplayEvent);
 
 SkDisplayEvent::SkDisplayEvent() : code((SkKey) -1), disable(false),
-       kind(kUser), x(0), y(0), fLastCode((SkKey) -1), fMax((SkKey) -1), fTarget(nil) {
+    kind(kUser), x(0), y(0), fLastCode((SkKey) -1), fMax((SkKey) -1), fTarget(nil) {
 }
 
 SkDisplayEvent::~SkDisplayEvent() {
-       deleteMembers();
+    deleteMembers();
 }
 
 bool SkDisplayEvent::add(SkAnimateMaker& , SkDisplayable* child) { 
-       *fChildren.append() = child; 
-       return true; 
+    *fChildren.append() = child; 
+    return true; 
 }
 
 bool SkDisplayEvent::contains(SkDisplayable* match) {
-       for (int index = 0; index < fChildren.count(); index++) {
-               if (fChildren[index] == match || fChildren[index]->contains(match))
-                       return true;
-       }
-       return false;
+    for (int index = 0; index < fChildren.count(); index++) {
+        if (fChildren[index] == match || fChildren[index]->contains(match))
+            return true;
+    }
+    return false;
 }
 
 SkDisplayable* SkDisplayEvent::contains(const SkString& match) {
-       for (int index = 0; index < fChildren.count(); index++) {
-               SkDisplayable* child = fChildren[index];
-               if (child->contains(match))
-                       return child;
-       }
-       return nil;
+    for (int index = 0; index < fChildren.count(); index++) {
+        SkDisplayable* child = fChildren[index];
+        if (child->contains(match))
+            return child;
+    }
+    return nil;
 }
 
 void SkDisplayEvent::deleteMembers() {
-       for (int index = 0; index < fChildren.count(); index++) {
-               SkDisplayable* evt = fChildren[index];
-               delete evt;
-       }
+    for (int index = 0; index < fChildren.count(); index++) {
+        SkDisplayable* evt = fChildren[index];
+        delete evt;
+    }
 }
 
 #ifdef SK_DUMP_ENABLED
@@ -109,140 +126,140 @@ void SkDisplayEvent::dumpEvent(SkAnimateMaker* maker) {
 
 bool SkDisplayEvent::enableEvent(SkAnimateMaker& maker) 
 {
-       maker.fActiveEvent = this;
-       if (fChildren.count() == 0)
-               return false;
-       if (disable)
-               return false;
+    maker.fActiveEvent = this;
+    if (fChildren.count() == 0)
+        return false;
+    if (disable)
+        return false;
 #ifdef SK_DUMP_ENABLED
-       if (maker.fDumpEvents) {
-               SkDebugf("enable: ");
-               dumpEvent(&maker);
-       }
+    if (maker.fDumpEvents) {
+        SkDebugf("enable: ");
+        dumpEvent(&maker);
+    }
 #endif
-       SkDisplayList& displayList = maker.fDisplayList;
-       for (int index = 0; index < fChildren.count(); index++) {
-               SkDisplayable* displayable = fChildren[index];
-               if (displayable->isGroup()) {
-                       SkTDDrawableArray* parentList = displayList.getDrawList();
-                       *parentList->append() = (SkDrawable*) displayable;      // make it findable before children are enabled
-               }
-               if (displayable->enable(maker))
-                       continue;
+    SkDisplayList& displayList = maker.fDisplayList;
+    for (int index = 0; index < fChildren.count(); index++) {
+        SkDisplayable* displayable = fChildren[index];
+        if (displayable->isGroup()) {
+            SkTDDrawableArray* parentList = displayList.getDrawList();
+            *parentList->append() = (SkDrawable*) displayable;  // make it findable before children are enabled
+        }
+        if (displayable->enable(maker))
+            continue;
         if (maker.hasError()) 
             return true;
-               if (displayable->isDrawable() == false)
-                       return true;    // error
-               SkDrawable* drawable = (SkDrawable*) displayable;
-               SkTDDrawableArray* parentList = displayList.getDrawList();
-               *parentList->append() = drawable;
-       }
-       return false;
+        if (displayable->isDrawable() == false)
+            return true;    // error
+        SkDrawable* drawable = (SkDrawable*) displayable;
+        SkTDDrawableArray* parentList = displayList.getDrawList();
+        *parentList->append() = drawable;
+    }
+    return false;
 }
 
 bool SkDisplayEvent::getProperty(int index, SkScriptValue* value) const {
-       switch (index) {
-               case SK_PROPERTY(key):
-               case SK_PROPERTY(keys): {
-                       value->fType = SkType_String;
-                       char scratch[8];
-                       SkKey convert = index == SK_PROPERTY(keys) ? code : fLastCode;
-                       size_t size = convert > 0 ? SkUTF8_FromUnichar(convert, scratch) : 0;
+    switch (index) {
+        case SK_PROPERTY(key):
+        case SK_PROPERTY(keys): {
+            value->fType = SkType_String;
+            char scratch[8];
+            SkKey convert = index == SK_PROPERTY(keys) ? code : fLastCode;
+            size_t size = convert > 0 ? SkUTF8_FromUnichar(convert, scratch) : 0;
             fKeyString.set(scratch, size);
-                       value->fOperand.fString = &fKeyString;
-                       if (index != SK_PROPERTY(keys) || fMax == (SkKey) -1 || fMax == code)
-                               break;
-                       value->fOperand.fString->append("-");
-                       size = SkUTF8_FromUnichar(fMax, scratch);
-                       value->fOperand.fString->append(scratch, size);
-                       } break;
-               default:
-                       SkASSERT(0);
-                       return false;
-       }
-       return true;
+            value->fOperand.fString = &fKeyString;
+            if (index != SK_PROPERTY(keys) || fMax == (SkKey) -1 || fMax == code)
+                break;
+            value->fOperand.fString->append("-");
+            size = SkUTF8_FromUnichar(fMax, scratch);
+            value->fOperand.fString->append(scratch, size);
+            } break;
+        default:
+            SkASSERT(0);
+            return false;
+    }
+    return true;
 }
 
 void SkDisplayEvent::onEndElement(SkAnimateMaker& maker)
 {
-       if (kind == kUser)
-               return;
-       maker.fEvents.addEvent(this);
-       if (kind == kOnEnd) {
-               bool found = maker.find(target.c_str(), &fTarget);
-               SkASSERT(found);
-               SkASSERT(fTarget && fTarget->isAnimate());
-               SkAnimateBase* animate = (SkAnimateBase*) fTarget;
-               animate->setHasEndEvent();
-       }
+    if (kind == kUser)
+        return;
+    maker.fEvents.addEvent(this);
+    if (kind == kOnEnd) {
+        bool found = maker.find(target.c_str(), &fTarget);
+        SkASSERT(found);
+        SkASSERT(fTarget && fTarget->isAnimate());
+        SkAnimateBase* animate = (SkAnimateBase*) fTarget;
+        animate->setHasEndEvent();
+    }
 }
 
 void SkDisplayEvent::populateInput(SkAnimateMaker& maker, const SkEvent& fEvent) {
-       const SkMetaData& meta = fEvent.getMetaData();
-       SkMetaData::Iter iter(meta);
-       SkMetaData::Type        type;
-       int number;
-       const char* name;
-       while ((name = iter.next(&type, &number)) != nil) {
-               if (name[0] == '\0')
-                       continue;
-               SkDisplayable* displayable;
-               SkInput* input;
-               for (int index = 0; index < fChildren.count(); index++) {
-                       displayable = fChildren[index];
-                       if (displayable->getType() != SkType_Input)
-                               continue;
-                       input = (SkInput*) displayable;
-                       if (input->name.equals(name))
-                               goto found;
-               }
-               if (!maker.find(name, &displayable) || displayable->getType() != SkType_Input)
-                       continue;
-               input = (SkInput*) displayable;
-       found:
-               switch (type) {
-                       case SkMetaData::kS32_Type:
-                               meta.findS32(name, &input->fInt);
-                               break;
-                       case SkMetaData::kScalar_Type:
-                               meta.findScalar(name, &input->fFloat);
-                               break;
-                       case SkMetaData::kPtr_Type:
-                               SkASSERT(0);
-                               break; // !!! not handled for now
-                       case SkMetaData::kString_Type:
-                               input->string.set(meta.findString(name));
-                               break;
-                       default:
-                               SkASSERT(0);
-               }
-       }
-       // re-evaluate all animators that may have built their values from input strings
-       for (SkDisplayable** childPtr = fChildren.begin(); childPtr < fChildren.end(); childPtr++) {
-               SkDisplayable* displayable = *childPtr;
-               if (displayable->isApply() == false)
-                       continue;
-               SkApply* apply = (SkApply*) displayable;
-               apply->refresh(maker);
-       }
+    const SkMetaData& meta = fEvent.getMetaData();
+    SkMetaData::Iter iter(meta);
+    SkMetaData::Type    type;
+    int number;
+    const char* name;
+    while ((name = iter.next(&type, &number)) != nil) {
+        if (name[0] == '\0')
+            continue;
+        SkDisplayable* displayable;
+        SkInput* input;
+        for (int index = 0; index < fChildren.count(); index++) {
+            displayable = fChildren[index];
+            if (displayable->getType() != SkType_Input)
+                continue;
+            input = (SkInput*) displayable;
+            if (input->name.equals(name))
+                goto found;
+        }
+        if (!maker.find(name, &displayable) || displayable->getType() != SkType_Input)
+            continue;
+        input = (SkInput*) displayable;
+    found:
+        switch (type) {
+            case SkMetaData::kS32_Type:
+                meta.findS32(name, &input->fInt);
+                break;
+            case SkMetaData::kScalar_Type:
+                meta.findScalar(name, &input->fFloat);
+                break;
+            case SkMetaData::kPtr_Type:
+                SkASSERT(0);
+                break; // !!! not handled for now
+            case SkMetaData::kString_Type:
+                input->string.set(meta.findString(name));
+                break;
+            default:
+                SkASSERT(0);
+        }
+    }
+    // re-evaluate all animators that may have built their values from input strings
+    for (SkDisplayable** childPtr = fChildren.begin(); childPtr < fChildren.end(); childPtr++) {
+        SkDisplayable* displayable = *childPtr;
+        if (displayable->isApply() == false)
+            continue;
+        SkApply* apply = (SkApply*) displayable;
+        apply->refresh(maker);
+    }
 }
 
 bool SkDisplayEvent::setProperty(int index, SkScriptValue& value) {
-       SkASSERT(index == SK_PROPERTY(key) || index == SK_PROPERTY(keys));
-       SkASSERT(value.fType == SkType_String);
-       SkString* string = value.fOperand.fString;
-       const char* chars = string->c_str();
-       int count = SkUTF8_CountUnichars(chars);
-       SkASSERT(count >= 1);
-       code = (SkKey) SkUTF8_NextUnichar(&chars);
-       fMax = code;
-       SkASSERT(count == 1 || index == SK_PROPERTY(keys));
-       if (--count > 0) {
-               SkASSERT(*chars == '-');
-               chars++;
-               fMax = (SkKey) SkUTF8_NextUnichar(&chars);
-               SkASSERT(fMax >= code);
-       }
-       return true;
+    SkASSERT(index == SK_PROPERTY(key) || index == SK_PROPERTY(keys));
+    SkASSERT(value.fType == SkType_String);
+    SkString* string = value.fOperand.fString;
+    const char* chars = string->c_str();
+    int count = SkUTF8_CountUnichars(chars);
+    SkASSERT(count >= 1);
+    code = (SkKey) SkUTF8_NextUnichar(&chars);
+    fMax = code;
+    SkASSERT(count == 1 || index == SK_PROPERTY(keys));
+    if (--count > 0) {
+        SkASSERT(*chars == '-');
+        chars++;
+        fMax = (SkKey) SkUTF8_NextUnichar(&chars);
+        SkASSERT(fMax >= code);
+    }
+    return true;
 }
 
index 4d5be02..e1e66df 100644 (file)
@@ -1,3 +1,20 @@
+/* libs/graphics/animator/SkDisplayEvent.h
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #ifndef SkDisplayEvent_DEFINED
 #define SkDisplayEvent_DEFINED
 
 class SkEvent;
 
 class SkDisplayEvent : public SkDisplayable {
-       DECLARE_DISPLAY_MEMBER_INFO(Event);
-       enum Kind {
-               kNo_kind,
-               kKeyChar,
-               kKeyPress,
+    DECLARE_DISPLAY_MEMBER_INFO(Event);
+    enum Kind {
+        kNo_kind,
+        kKeyChar,
+        kKeyPress,
         kKeyPressUp,    //i assume the order here is intended to match with skanimatorscript.cpp
-               kMouseDown,
-               kMouseDrag,
-               kMouseMove,
-               kMouseUp,
-               kOnEnd,
-               kOnload,
-               kUser
-       };
-       SkDisplayEvent();
-       virtual ~SkDisplayEvent();
-       virtual bool add(SkAnimateMaker& , SkDisplayable* child);
-       virtual bool contains(SkDisplayable*);
-       virtual SkDisplayable* contains(const SkString& );
+        kMouseDown,
+        kMouseDrag,
+        kMouseMove,
+        kMouseUp,
+        kOnEnd,
+        kOnload,
+        kUser
+    };
+    SkDisplayEvent();
+    virtual ~SkDisplayEvent();
+    virtual bool add(SkAnimateMaker& , SkDisplayable* child);
+    virtual bool contains(SkDisplayable*);
+    virtual SkDisplayable* contains(const SkString& );
 #ifdef SK_DEBUG
-       void dumpEvent(SkAnimateMaker* );
+    void dumpEvent(SkAnimateMaker* );
 #endif
-       bool enableEvent(SkAnimateMaker& );
-       virtual bool getProperty(int index, SkScriptValue* ) const;
-       virtual void onEndElement(SkAnimateMaker& maker);
-       void populateInput(SkAnimateMaker& , const SkEvent& fEvent);
-       virtual bool setProperty(int index, SkScriptValue& );
+    bool enableEvent(SkAnimateMaker& );
+    virtual bool getProperty(int index, SkScriptValue* ) const;
+    virtual void onEndElement(SkAnimateMaker& maker);
+    void populateInput(SkAnimateMaker& , const SkEvent& fEvent);
+    virtual bool setProperty(int index, SkScriptValue& );
 protected:
-       SkKey code;
-       SkBool disable;
-       Kind kind;
-       SkString target;
-       SkScalar x;
-       SkScalar y;
-       SkTDDisplayableArray fChildren;
+    SkKey code;
+    SkBool disable;
+    Kind kind;
+    SkString target;
+    SkScalar x;
+    SkScalar y;
+    SkTDDisplayableArray fChildren;
     mutable SkString fKeyString;
-       SkKey fLastCode; // last key to trigger this event
-       SkKey fMax; // if the code expresses a range
-       SkDisplayable* fTarget; // used by onEnd
+    SkKey fLastCode; // last key to trigger this event
+    SkKey fMax; // if the code expresses a range
+    SkDisplayable* fTarget; // used by onEnd
 private:
-       void deleteMembers();
-       friend class SkEvents;
-       typedef SkDisplayable INHERITED;
+    void deleteMembers();
+    friend class SkEvents;
+    typedef SkDisplayable INHERITED;
 };
 
 #endif // SkDisplayEvent_DEFINED
index 405e134..8b7729e 100644 (file)
@@ -1,3 +1,20 @@
+/* libs/graphics/animator/SkDisplayEvents.cpp
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #include "SkDisplayEvents.h"
 #include "SkAnimateMaker.h"
 #include "SkAnimator.h"
@@ -19,86 +36,86 @@ SkEvents::~SkEvents() {
 
 bool SkEvents::doEvent(SkAnimateMaker& maker, SkDisplayEvent::Kind kind, SkEventState* state) {
 /*#ifdef SK_DUMP_ENABLED
-       if (maker.fDumpEvents) {
-               SkDebugf("doEvent: ");
-               SkString str;
-               SkDump::GetEnumString(SkType_EventKind, kind, &str);
-               SkDebugf("kind=%s ", str.c_str());
-               if (state && state->fDisplayable)
-                       state->fDisplayable->SkDisplayable::dump(&maker);
-               else
-                       SkDebugf("\n");
-       }
+    if (maker.fDumpEvents) {
+        SkDebugf("doEvent: ");
+        SkString str;
+        SkDump::GetEnumString(SkType_EventKind, kind, &str);
+        SkDebugf("kind=%s ", str.c_str());
+        if (state && state->fDisplayable)
+            state->fDisplayable->SkDisplayable::dump(&maker);
+        else
+            SkDebugf("\n");
+    }
 #endif*/
-       bool handled = false;
-       SkDisplayable** firstMovie = maker.fMovies.begin();
-       SkDisplayable** endMovie = maker.fMovies.end();
-       for (SkDisplayable** ptr = firstMovie; ptr < endMovie; ptr++) {
-               SkDisplayMovie* movie = (SkDisplayMovie*) *ptr;
-               if (kind != SkDisplayEvent::kOnload)
-                       movie->doEvent(kind, state);
-       }
-       SkDisplayable* displayable = state ? state->fDisplayable : nil;
-       int keyCode = state ? state->fCode : 0;
-       int count = fEvents.count();
-       for (int index = 0; index < count; index++) {
-               SkDisplayEvent* evt = fEvents[index];
-               if (evt->disable)
-                       continue;
-               if (evt->kind != kind)
-                       continue;
-               if (evt->code != (SkKey) -1) {
-                       if ((int) evt->code > keyCode || (int) (evt->fMax != (SkKey) -1 ? evt->fMax : evt->code) < keyCode)
-                               continue;
-                       evt->fLastCode = (SkKey) keyCode;
-               }
-               if (evt->fTarget != nil && evt->fTarget != displayable)
-                       continue;
-               if (state == nil || state->fDisable == 0) {
-                       if (kind >= SkDisplayEvent::kMouseDown && kind <= SkDisplayEvent::kMouseUp) {
-                               evt->x = state->fX;
-                               evt->y = state->fY;
-                       }
-                       if (evt->enableEvent(maker))
-                               fError = true;
-               }
-               handled = true;
-       }
-       return handled;
+    bool handled = false;
+    SkDisplayable** firstMovie = maker.fMovies.begin();
+    SkDisplayable** endMovie = maker.fMovies.end();
+    for (SkDisplayable** ptr = firstMovie; ptr < endMovie; ptr++) {
+        SkDisplayMovie* movie = (SkDisplayMovie*) *ptr;
+        if (kind != SkDisplayEvent::kOnload)
+            movie->doEvent(kind, state);
+    }
+    SkDisplayable* displayable = state ? state->fDisplayable : nil;
+    int keyCode = state ? state->fCode : 0;
+    int count = fEvents.count();
+    for (int index = 0; index < count; index++) {
+        SkDisplayEvent* evt = fEvents[index];
+        if (evt->disable)
+            continue;
+        if (evt->kind != kind)
+            continue;
+        if (evt->code != (SkKey) -1) {
+            if ((int) evt->code > keyCode || (int) (evt->fMax != (SkKey) -1 ? evt->fMax : evt->code) < keyCode)
+                continue;
+            evt->fLastCode = (SkKey) keyCode;
+        }
+        if (evt->fTarget != nil && evt->fTarget != displayable)
+            continue;
+        if (state == nil || state->fDisable == 0) {
+            if (kind >= SkDisplayEvent::kMouseDown && kind <= SkDisplayEvent::kMouseUp) {
+                evt->x = state->fX;
+                evt->y = state->fY;
+            }
+            if (evt->enableEvent(maker))
+                fError = true;
+        }
+        handled = true;
+    }
+    return handled;
 }
 
 #ifdef SK_DUMP_ENABLED
 void SkEvents::dump(SkAnimateMaker& maker) {
-       int index;
-       SkTDDrawableArray& drawArray = maker.fDisplayList.fDrawList;
-       int count = drawArray.count();
-       for (index = 0; index < count; index++) {
-               SkDrawable* drawable = drawArray[index];
-               drawable->dumpEvents(); 
-       }
-       count = fEvents.count();
-       for (index = 0; index < count; index++) {
-               SkDisplayEvent* evt = fEvents[index];
-               evt->dumpEvent(&maker);
-       }
+    int index;
+    SkTDDrawableArray& drawArray = maker.fDisplayList.fDrawList;
+    int count = drawArray.count();
+    for (index = 0; index < count; index++) {
+        SkDrawable* drawable = drawArray[index];
+        drawable->dumpEvents(); 
+    }
+    count = fEvents.count();
+    for (index = 0; index < count; index++) {
+        SkDisplayEvent* evt = fEvents[index];
+        evt->dumpEvent(&maker);
+    }
 }
 #endif
 
 // currently this only removes onLoad events
 void SkEvents::removeEvent(SkDisplayEvent::Kind kind, SkEventState* state) {
-       int keyCode = state ? state->fCode : 0;
-       SkDisplayable* displayable = state ? state->fDisplayable : nil;
-       for (SkDisplayEvent** evtPtr = fEvents.begin(); evtPtr < fEvents.end(); evtPtr++) {
-               SkDisplayEvent* evt = *evtPtr;
-               if (evt->kind != kind)
-                       continue;
-               if (evt->code != (SkKey) -1) {
-                       if ((int) evt->code > keyCode || (int) (evt->fMax != (SkKey) -1 ? evt->fMax : evt->code) < keyCode)
-                               continue;
-               }
-               if (evt->fTarget != nil && evt->fTarget != displayable)
-                       continue;
-               int index = fEvents.find(evt);
-               fEvents.remove(index);
-       }
+    int keyCode = state ? state->fCode : 0;
+    SkDisplayable* displayable = state ? state->fDisplayable : nil;
+    for (SkDisplayEvent** evtPtr = fEvents.begin(); evtPtr < fEvents.end(); evtPtr++) {
+        SkDisplayEvent* evt = *evtPtr;
+        if (evt->kind != kind)
+            continue;
+        if (evt->code != (SkKey) -1) {
+            if ((int) evt->code > keyCode || (int) (evt->fMax != (SkKey) -1 ? evt->fMax : evt->code) < keyCode)
+                continue;
+        }
+        if (evt->fTarget != nil && evt->fTarget != displayable)
+            continue;
+        int index = fEvents.find(evt);
+        fEvents.remove(index);
+    }
 }
index 7000b67..e22f5c8 100644 (file)
@@ -1,3 +1,20 @@
+/* libs/graphics/animator/SkDisplayEvents.h
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #ifndef SkDisplayEvents_DEFINED
 #define SkDisplayEvents_DEFINED
 
 #include "SkDisplayEvent.h"
 
 struct SkEventState {
-       SkEventState();
-       int fCode;
-       SkBool fDisable;
-       SkDisplayable* fDisplayable;
-       SkScalar fX;
-       SkScalar fY;
+    SkEventState();
+    int fCode;
+    SkBool fDisable;
+    SkDisplayable* fDisplayable;
+    SkScalar fX;
+    SkScalar fY;
 };
 
 class SkEvents {
 public:
-       SkEvents();
-       ~SkEvents();
-       void addEvent(SkDisplayEvent* evt) { *fEvents.append() = evt; }
-       bool doEvent(SkAnimateMaker& , SkDisplayEvent::Kind , SkEventState* );
+    SkEvents();
+    ~SkEvents();
+    void addEvent(SkDisplayEvent* evt) { *fEvents.append() = evt; }
+    bool doEvent(SkAnimateMaker& , SkDisplayEvent::Kind , SkEventState* );
 #ifdef SK_DUMP_ENABLED
-       void dump(SkAnimateMaker& );
+    void dump(SkAnimateMaker& );
 #endif
-       void reset() { fEvents.reset(); }
-       void removeEvent(SkDisplayEvent::Kind kind, SkEventState* );
+    void reset() { fEvents.reset(); }
+    void removeEvent(SkDisplayEvent::Kind kind, SkEventState* );
 private:
-       SkTDDisplayEventArray fEvents;
-       SkBool fError;
-       friend class SkDisplayXMLParser;
+    SkTDDisplayEventArray fEvents;
+    SkBool fError;
+    friend class SkDisplayXMLParser;
 };
 
 #endif // SkDisplayEvents_DEFINED
index eee5f96..52f2e7c 100644 (file)
@@ -1,3 +1,20 @@
+/* libs/graphics/animator/SkDisplayInclude.cpp
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #include "SkDisplayInclude.h"
 #include "SkAnimateMaker.h"
 #include "SkAnimator.h"
 #if 0
 #undef SK_MEMBER
 #define SK_MEMBER(_member, _type) \
-       { #_member, SK_OFFSETOF(BASE_CLASS::_A, _member), SkType_##_type, \
-       sizeof(((BASE_CLASS::_A*) 0)->_member) / sizeof(SkScalar) }
+    { #_member, SK_OFFSETOF(BASE_CLASS::_A, _member), SkType_##_type, \
+    sizeof(((BASE_CLASS::_A*) 0)->_member) / sizeof(SkScalar) }
 #endif
 
 #if SK_USE_CONDENSED_INFO == 0
 
 const SkMemberInfo SkInclude::fInfo[] = {
-       SK_MEMBER(src, String)
+    SK_MEMBER(src, String)
 };
 
 #endif
@@ -20,31 +37,31 @@ const SkMemberInfo SkInclude::fInfo[] = {
 DEFINE_GET_MEMBER(SkInclude);
 
 //SkInclude::SkInclude() {
-//     src.init();
+//  src.init();
 //}
 
 //SkInclude::~SkInclude() {
-//     src.unref();
+//  src.unref();
 //}
 
 bool SkInclude::enable(SkAnimateMaker & ) {
-       return true;
+    return true;
 }
 
 bool SkInclude::hasEnable() const {
-       return true;
+    return true;
 }
 
 void SkInclude::onEndElement(SkAnimateMaker& maker) {
-       maker.fInInclude = true;
-       if (src.size() == 0 || maker.decodeURI(src.c_str()) == false) {
-               if (maker.getErrorCode() != SkXMLParserError::kNoError || maker.getNativeCode() != -1) {
-                       maker.setInnerError(&maker, src);
-                       maker.setErrorCode(SkDisplayXMLParserError::kInInclude);
-               } else {
-                       maker.setErrorNoun(src);
-                       maker.setErrorCode(SkDisplayXMLParserError::kIncludeNameUnknownOrMissing);
-               }
-       }
-       maker.fInInclude = false;
+    maker.fInInclude = true;
+    if (src.size() == 0 || maker.decodeURI(src.c_str()) == false) {
+        if (maker.getErrorCode() != SkXMLParserError::kNoError || maker.getNativeCode() != -1) {
+            maker.setInnerError(&maker, src);
+            maker.setErrorCode(SkDisplayXMLParserError::kInInclude);
+        } else {
+            maker.setErrorNoun(src);
+            maker.setErrorCode(SkDisplayXMLParserError::kIncludeNameUnknownOrMissing);
+        }
+    }
+    maker.fInInclude = false;
 }
index b842c69..af67942 100644 (file)
@@ -1,3 +1,20 @@
+/* libs/graphics/animator/SkDisplayInclude.h
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #ifndef SkDisplayInclude_DEFINED
 #define SkDisplayInclude_DEFINED
 
 #include "SkMemberInfo.h"
 
 class SkInclude : public SkDisplayable {
-       DECLARE_MEMBER_INFO(Include);
-       virtual void onEndElement(SkAnimateMaker & );
-       virtual bool enable(SkAnimateMaker & );
-       virtual bool hasEnable() const;
+    DECLARE_MEMBER_INFO(Include);
+    virtual void onEndElement(SkAnimateMaker & );
+    virtual bool enable(SkAnimateMaker & );
+    virtual bool hasEnable() const;
 protected:
-       SkString src;
+    SkString src;
 };
 
 #endif // SkDisplayInclude_DEFINED
index 7eec8d3..e616847 100644 (file)
@@ -1,17 +1,34 @@
+/* libs/graphics/animator/SkDisplayInput.cpp
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #include "SkDisplayInput.h"
 
 enum SkInput_Properties {
-       SK_PROPERTY(initialized)
+    SK_PROPERTY(initialized)
 };
 
 #if SK_USE_CONDENSED_INFO == 0
 
 const SkMemberInfo SkInput::fInfo[] = {
-       SK_MEMBER_ALIAS(float, fFloat, Float),
-       SK_MEMBER_PROPERTY(initialized, Boolean),
-       SK_MEMBER_ALIAS(int, fInt, Int),
-       SK_MEMBER(name, String),
-       SK_MEMBER(string, String)
+    SK_MEMBER_ALIAS(float, fFloat, Float),
+    SK_MEMBER_PROPERTY(initialized, Boolean),
+    SK_MEMBER_ALIAS(int, fInt, Int),
+    SK_MEMBER(name, String),
+    SK_MEMBER(string, String)
 };
 
 #endif
@@ -21,26 +38,26 @@ DEFINE_GET_MEMBER(SkInput);
 SkInput::SkInput() : fInt((int) SK_NaN32), fFloat(SK_ScalarNaN) {}
 
 SkDisplayable* SkInput::contains(const SkString& string) {
-       return string.equals(name) ? this : nil;
+    return string.equals(name) ? this : nil;
 }
 
 bool SkInput::enable(SkAnimateMaker & ) {
-       return true;
+    return true;
 }
 
 bool SkInput::getProperty(int index, SkScriptValue* value) const {
-       switch (index) {
-               case SK_PROPERTY(initialized):
-                       value->fType = SkType_Boolean;
-                       value->fOperand.fS32 = fInt != (int) SK_NaN32 ||
-                               SkScalarIsNaN(fFloat) == false || string.size() > 0;
-                       break;
-               default:
-                       return false;
-       }
-       return true;
+    switch (index) {
+        case SK_PROPERTY(initialized):
+            value->fType = SkType_Boolean;
+            value->fOperand.fS32 = fInt != (int) SK_NaN32 ||
+                SkScalarIsNaN(fFloat) == false || string.size() > 0;
+            break;
+        default:
+            return false;
+    }
+    return true;
 }
  
 bool SkInput::hasEnable() const {
-       return true;
+    return true;
 }
index b118b22..4693c36 100644 (file)
@@ -1,3 +1,20 @@
+/* libs/graphics/animator/SkDisplayInput.h
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #ifndef SkDisplayInput_DEFINED
 #define SkDisplayInput_DEFINED
 
 #include "SkMemberInfo.h"
 
 class SkInput : public SkDisplayable {
-       DECLARE_MEMBER_INFO(Input);
-       SkInput();
-       virtual SkDisplayable* contains(const SkString& );
-       virtual bool getProperty(int index, SkScriptValue* value) const;
-       virtual bool enable(SkAnimateMaker & );
-       virtual bool hasEnable() const;
+    DECLARE_MEMBER_INFO(Input);
+    SkInput();
+    virtual SkDisplayable* contains(const SkString& );
+    virtual bool getProperty(int index, SkScriptValue* value) const;
+    virtual bool enable(SkAnimateMaker & );
+    virtual bool hasEnable() const;
 protected:
-       SkString name;
-       int32_t  fInt;
-       SkScalar fFloat;
-       SkString string;
+    SkString name;
+    int32_t  fInt;
+    SkScalar fFloat;
+    SkString string;
 private:
-       friend class SkDisplayEvent;
-       friend class SkPost;
+    friend class SkDisplayEvent;
+    friend class SkPost;
 };
 
 #endif // SkDisplayInput_DEFINED
index 2e4d928..11dcbd8 100644 (file)
@@ -1,3 +1,20 @@
+/* libs/graphics/animator/SkDisplayList.cpp
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #include "SkDisplayList.h"
 #include "SkAnimateActive.h"
 #include "SkAnimateBase.h"
@@ -16,109 +33,109 @@ SkDisplayList::~SkDisplayList() {
 }
 
 void SkDisplayList::append(SkActive* active) {
-       *fActiveList.append() = active;
+    *fActiveList.append() = active;
 }
 
 bool SkDisplayList::draw(SkAnimateMaker& maker, SkMSec inTime) {
-       validate();
-       fInTime = inTime;
-       bool result = false;
-       fInvalBounds.setEmpty();
-       if (fDrawList.count()) {
-               for (SkActive** activePtr = fActiveList.begin(); activePtr < fActiveList.end(); activePtr++) {
-                       SkActive* active = *activePtr;
-                       active->reset();
-               }
-               for (int index = 0; index < fDrawList.count(); index++) {
-                       SkDrawable* draw = fDrawList[index];
-                       draw->initialize(); // allow matrices to reset themselves
-                       SkASSERT(draw->isDrawable());
-                       validate();
-                       result |= draw->draw(maker);
-               }
-       }
-       validate();
-       return result;
+    validate();
+    fInTime = inTime;
+    bool result = false;
+    fInvalBounds.setEmpty();
+    if (fDrawList.count()) {
+        for (SkActive** activePtr = fActiveList.begin(); activePtr < fActiveList.end(); activePtr++) {
+            SkActive* active = *activePtr;
+            active->reset();
+        }
+        for (int index = 0; index < fDrawList.count(); index++) {
+            SkDrawable* draw = fDrawList[index];
+            draw->initialize(); // allow matrices to reset themselves
+            SkASSERT(draw->isDrawable());
+            validate();
+            result |= draw->draw(maker);
+        }
+    }
+    validate();
+    return result;
 }
 
 int SkDisplayList::findGroup(SkDrawable* match, SkTDDrawableArray** list,
-               SkGroup** parent, SkGroup** found, SkTDDrawableArray**grandList) { 
-       *parent = nil;
-       *list = &fDrawList;
-       *grandList = &fDrawList;
-       return SearchForMatch(match, list, parent, found, grandList);
+        SkGroup** parent, SkGroup** found, SkTDDrawableArray**grandList) { 
+    *parent = nil;
+    *list = &fDrawList;
+    *grandList = &fDrawList;
+    return SearchForMatch(match, list, parent, found, grandList);
 }
 
 void SkDisplayList::hardReset() {
-       fDrawList.reset();
-       fActiveList.reset();
+    fDrawList.reset();
+    fActiveList.reset();
 }
 
 bool SkDisplayList::onIRect(const SkRect16& r) {
-       fBounds = r;
-       return fDrawBounds;
+    fBounds = r;
+    return fDrawBounds;
 }
 
 int SkDisplayList::SearchForMatch(SkDrawable* match, SkTDDrawableArray** list,
-               SkGroup** parent, SkGroup** found, SkTDDrawableArray**grandList) { 
-       *found = nil;
-       for (int index = 0; index < (*list)->count(); index++) {
-               SkDrawable* draw = (**list)[index];
-               if (draw == match)
-                       return index;
-               if (draw->isApply()) {
-                       SkApply* apply = (SkApply*) draw;
-                       if (apply->scope == match)
-                               return index;
+        SkGroup** parent, SkGroup** found, SkTDDrawableArray**grandList) { 
+    *found = nil;
+    for (int index = 0; index < (*list)->count(); index++) {
+        SkDrawable* draw = (**list)[index];
+        if (draw == match)
+            return index;
+        if (draw->isApply()) {
+            SkApply* apply = (SkApply*) draw;
+            if (apply->scope == match)
+                return index;
             if (apply->scope->isGroup() && SearchGroupForMatch(apply->scope, match, list, parent, found, grandList, index))
                 return index;
-                       if (apply->mode == SkApply::kMode_create) {
-                               for (SkDrawable** ptr = apply->fScopes.begin(); ptr < apply->fScopes.end(); ptr++) {
-                                       SkDrawable* scope = *ptr;
-                                       if (scope == match)
-                                               return index;
+            if (apply->mode == SkApply::kMode_create) {
+                for (SkDrawable** ptr = apply->fScopes.begin(); ptr < apply->fScopes.end(); ptr++) {
+                    SkDrawable* scope = *ptr;
+                    if (scope == match)
+                        return index;
                     //perhaps should call SearchGroupForMatch here as well (on scope)
-                               }
-                       
-               }
-               if (draw->isGroup() && SearchGroupForMatch(draw, match, list, parent, found, grandList, index)) 
-                       return index;
-               
-       }
-       return -1;
+                }
+            } 
+        }
+        if (draw->isGroup() && SearchGroupForMatch(draw, match, list, parent, found, grandList, index)) 
+            return index;
+        
+    }
+    return -1;
 }
 
 bool SkDisplayList::SearchGroupForMatch(SkDrawable* draw, SkDrawable* match, SkTDDrawableArray** list,
         SkGroup** parent, SkGroup** found, SkTDDrawableArray** grandList, int &index) {
             SkGroup* group = (SkGroup*) draw;
-                       if (group->getOriginal() == match)
-                               return true;
-                       SkTDDrawableArray* saveList = *list;
-                       int groupIndex = group->findGroup(match, list, parent, found, grandList);
-                       if (groupIndex >= 0) {
-                               *found = group;
+            if (group->getOriginal() == match)
+                return true;
+            SkTDDrawableArray* saveList = *list;
+            int groupIndex = group->findGroup(match, list, parent, found, grandList);
+            if (groupIndex >= 0) {
+                *found = group;
                 index = groupIndex;
-                               return true;
-                       }
-                       *list = saveList;
+                return true;
+            }
+            *list = saveList;
             return false;
         }
 
 void SkDisplayList::reset() {
-       for (int index = 0; index < fDrawList.count(); index++) {
-               SkDrawable* draw = fDrawList[index];
-               if (draw->isApply() == false)
-                       continue;
-               SkApply* apply = (SkApply*) draw;
-               apply->reset();
-       }                       
+    for (int index = 0; index < fDrawList.count(); index++) {
+        SkDrawable* draw = fDrawList[index];
+        if (draw->isApply() == false)
+            continue;
+        SkApply* apply = (SkApply*) draw;
+        apply->reset();
+    }           
 }
 
 void SkDisplayList::remove(SkActive* active) {
-       int index = fActiveList.find(active);
-       SkASSERT(index >= 0);
-       fActiveList.remove(index);      // !!! could use shuffle instead
-       SkASSERT(fActiveList.find(active) < 0);
+    int index = fActiveList.find(active);
+    SkASSERT(index >= 0);
+    fActiveList.remove(index);  // !!! could use shuffle instead
+    SkASSERT(fActiveList.find(active) < 0);
 }
 
 #ifdef SK_DUMP_ENABLED
@@ -126,25 +143,25 @@ int SkDisplayList::fDumpIndex;
 int SkDisplayList::fIndent;
 
 void SkDisplayList::dump(SkAnimateMaker* maker) {
-       fIndent = 0;
-       dumpInner(maker);
+    fIndent = 0;
+    dumpInner(maker);
 }
 
 void SkDisplayList::dumpInner(SkAnimateMaker* maker) {
-       for (int index = 0; index < fDrawList.count(); index++) {
-               fDumpIndex = index;
-               fDrawList[fDumpIndex]->dump(maker);
-       }
+    for (int index = 0; index < fDrawList.count(); index++) {
+        fDumpIndex = index;
+        fDrawList[fDumpIndex]->dump(maker);
+    }
 }
 
 #endif
 
 #ifdef SK_DEBUG
 void SkDisplayList::validate() {
-       for (int index = 0; index < fDrawList.count(); index++) {
-               SkDrawable* draw = fDrawList[index];
-               draw->validate();
-       }
+    for (int index = 0; index < fDrawList.count(); index++) {
+        SkDrawable* draw = fDrawList[index];
+        draw->validate();
+    }
 }
 #endif
 
index 30c21a6..6925377 100644 (file)
@@ -1,3 +1,20 @@
+/* libs/graphics/animator/SkDisplayList.h
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #ifndef SkDisplayList_DEFINED
 #define SkDisplayList_DEFINED
 
@@ -14,48 +31,48 @@ class SkGroup;
 
 class SkDisplayList : public SkBounder {
 public:
-       SkDisplayList();
-       virtual ~SkDisplayList();
-       void append(SkActive* );
-       void clear() { fDrawList.reset(); }
-       int count() { return fDrawList.count(); }
-       bool draw(SkAnimateMaker& , SkMSec time);
+    SkDisplayList();
+    virtual ~SkDisplayList();
+    void append(SkActive* );
+    void clear() { fDrawList.reset(); }
+    int count() { return fDrawList.count(); }
+    bool draw(SkAnimateMaker& , SkMSec time);
 #ifdef SK_DUMP_ENABLED
-       void dump(SkAnimateMaker* maker);
-       void dumpInner(SkAnimateMaker* maker);
-       static int fIndent;
-       static int fDumpIndex;
+    void dump(SkAnimateMaker* maker);
+    void dumpInner(SkAnimateMaker* maker);
+    static int fIndent;
+    static int fDumpIndex;
 #endif
-       int findGroup(SkDrawable* match, SkTDDrawableArray** list, 
-               SkGroup** parent, SkGroup** found, SkTDDrawableArray** grandList); 
-       SkDrawable* get(int index) { return fDrawList[index]; }
-       SkMSec getTime() { return fInTime; }
-       SkTDDrawableArray* getDrawList() { return &fDrawList; }
-       void hardReset();
-       virtual bool onIRect(const SkRect16& r);
-       void reset();
-       void remove(SkActive* );
+    int findGroup(SkDrawable* match, SkTDDrawableArray** list, 
+        SkGroup** parent, SkGroup** found, SkTDDrawableArray** grandList); 
+    SkDrawable* get(int index) { return fDrawList[index]; }
+    SkMSec getTime() { return fInTime; }
+    SkTDDrawableArray* getDrawList() { return &fDrawList; }
+    void hardReset();
+    virtual bool onIRect(const SkRect16& r);
+    void reset();
+    void remove(SkActive* );
 #ifdef SK_DEBUG
-       void validate();
+    void validate();
 #else
-       void validate() {}
+    void validate() {}
 #endif
-       static int SearchForMatch(SkDrawable* match, SkTDDrawableArray** list,
-               SkGroup** parent, SkGroup** found, SkTDDrawableArray**grandList);
-       static bool SearchGroupForMatch(SkDrawable* draw, SkDrawable* match, 
-               SkTDDrawableArray** list, SkGroup** parent, SkGroup** found, SkTDDrawableArray** grandList, 
-               int &index);
+    static int SearchForMatch(SkDrawable* match, SkTDDrawableArray** list,
+        SkGroup** parent, SkGroup** found, SkTDDrawableArray**grandList);
+    static bool SearchGroupForMatch(SkDrawable* draw, SkDrawable* match, 
+        SkTDDrawableArray** list, SkGroup** parent, SkGroup** found, SkTDDrawableArray** grandList, 
+        int &index);
 public:
-       SkRect16 fBounds;
-       SkRect16 fInvalBounds;
-       bool fDrawBounds;
-       bool fHasUnion;
-       bool fUnionBounds;
+    SkRect16 fBounds;
+    SkRect16 fInvalBounds;
+    bool fDrawBounds;
+    bool fHasUnion;
+    bool fUnionBounds;
 private:
-       SkTDDrawableArray fDrawList;
-       SkTDActiveArray fActiveList;
-       SkMSec fInTime;
-       friend class SkEvents;
+    SkTDDrawableArray fDrawList;
+    SkTDActiveArray fActiveList;
+    SkMSec fInTime;
+    friend class SkEvents;
 };
 
 #endif // SkDisplayList_DEFINED
index da757a3..e485fa6 100644 (file)
+/* libs/graphics/animator/SkDisplayMath.cpp
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #include "SkDisplayMath.h"
 
 enum SkDisplayMath_Properties {
-       SK_PROPERTY(E),
-       SK_PROPERTY(LN10),
-       SK_PROPERTY(LN2),
-       SK_PROPERTY(LOG10E),
-       SK_PROPERTY(LOG2E),
-       SK_PROPERTY(PI),
-       SK_PROPERTY(SQRT1_2),
-       SK_PROPERTY(SQRT2)
+    SK_PROPERTY(E),
+    SK_PROPERTY(LN10),
+    SK_PROPERTY(LN2),
+    SK_PROPERTY(LOG10E),
+    SK_PROPERTY(LOG2E),
+    SK_PROPERTY(PI),
+    SK_PROPERTY(SQRT1_2),
+    SK_PROPERTY(SQRT2)
 };
 
 const SkScalar SkDisplayMath::gConstants[] = {
 #ifdef SK_SCALAR_IS_FLOAT
-       2.718281828f,   // E
-       2.302585093f,   // LN10
-       0.693147181f,   // LN2
-       0.434294482f,   // LOG10E
-       1.442695041f,   // LOG2E
-       3.141592654f,   // PI
-       0.707106781f,   // SQRT1_2
-       1.414213562f            // SQRT2 
+    2.718281828f,   // E
+    2.302585093f,   // LN10
+    0.693147181f,   // LN2
+    0.434294482f,   // LOG10E
+    1.442695041f,   // LOG2E
+    3.141592654f,   // PI
+    0.707106781f,   // SQRT1_2
+    1.414213562f        // SQRT2 
 #else
-       0x2B7E1,        // E
-       0x24D76,        // LN10
-       0xB172,         // LN2
-       0x6F2E,         // LOG10E
-       0x17154,        // LOG2E
-       0x3243F,        // PI
-       0xB505,         // SQRT1_2
-       0x16A0A // SQRT2
+    0x2B7E1,    // E
+    0x24D76,    // LN10
+    0xB172,     // LN2
+    0x6F2E,     // LOG10E
+    0x17154,    // LOG2E
+    0x3243F,    // PI
+    0xB505,     // SQRT1_2
+    0x16A0A // SQRT2
 #endif
 };
 
 enum SkDisplayMath_Functions {
-       SK_FUNCTION(abs),
-       SK_FUNCTION(acos),
-       SK_FUNCTION(asin),
-       SK_FUNCTION(atan),
-       SK_FUNCTION(atan2),
-       SK_FUNCTION(ceil),
-       SK_FUNCTION(cos),
-       SK_FUNCTION(exp),
-       SK_FUNCTION(floor),
-       SK_FUNCTION(log),
-       SK_FUNCTION(max),
-       SK_FUNCTION(min),
-       SK_FUNCTION(pow),
-       SK_FUNCTION(random),
-       SK_FUNCTION(round),
-       SK_FUNCTION(sin),
-       SK_FUNCTION(sqrt),
-       SK_FUNCTION(tan)
+    SK_FUNCTION(abs),
+    SK_FUNCTION(acos),
+    SK_FUNCTION(asin),
+    SK_FUNCTION(atan),
+    SK_FUNCTION(atan2),
+    SK_FUNCTION(ceil),
+    SK_FUNCTION(cos),
+    SK_FUNCTION(exp),
+    SK_FUNCTION(floor),
+    SK_FUNCTION(log),
+    SK_FUNCTION(max),
+    SK_FUNCTION(min),
+    SK_FUNCTION(pow),
+    SK_FUNCTION(random),
+    SK_FUNCTION(round),
+    SK_FUNCTION(sin),
+    SK_FUNCTION(sqrt),
+    SK_FUNCTION(tan)
 };
 
 const SkFunctionParamType SkDisplayMath::fFunctionParameters[] = {
-       (SkFunctionParamType) SkType_Float,     // abs
-       (SkFunctionParamType) 0,
-       (SkFunctionParamType) SkType_Float,     // acos
-       (SkFunctionParamType) 0,
-       (SkFunctionParamType) SkType_Float,     // asin
-       (SkFunctionParamType) 0,
-       (SkFunctionParamType) SkType_Float,     // atan
-       (SkFunctionParamType) 0,
-       (SkFunctionParamType) SkType_Float,     // atan2
-       (SkFunctionParamType) SkType_Float,
-       (SkFunctionParamType) 0,
-       (SkFunctionParamType) SkType_Float,     // ceil
-       (SkFunctionParamType) 0,
-       (SkFunctionParamType) SkType_Float,     // cos
-       (SkFunctionParamType) 0,
-       (SkFunctionParamType) SkType_Float,     // exp
-       (SkFunctionParamType) 0,
-       (SkFunctionParamType) SkType_Float,     // floor
-       (SkFunctionParamType) 0,
-       (SkFunctionParamType) SkType_Float,     // log
-       (SkFunctionParamType) 0,
-       (SkFunctionParamType) SkType_Array,     // max
-       (SkFunctionParamType) 0,
-       (SkFunctionParamType) SkType_Array,     // min
-       (SkFunctionParamType) 0,
-       (SkFunctionParamType) SkType_Float,     // pow
-       (SkFunctionParamType) SkType_Float,
-       (SkFunctionParamType) 0,
-       (SkFunctionParamType) SkType_Float,     // random
-       (SkFunctionParamType) 0,
-       (SkFunctionParamType) SkType_Float,     // round
-       (SkFunctionParamType) 0,
-       (SkFunctionParamType) SkType_Float,     // sin
-       (SkFunctionParamType) 0,
-       (SkFunctionParamType) SkType_Float,     // sqrt
-       (SkFunctionParamType) 0,
-       (SkFunctionParamType) SkType_Float,     // tan
-       (SkFunctionParamType) 0
+    (SkFunctionParamType) SkType_Float, // abs
+    (SkFunctionParamType) 0,
+    (SkFunctionParamType) SkType_Float, // acos
+    (SkFunctionParamType) 0,
+    (SkFunctionParamType) SkType_Float, // asin
+    (SkFunctionParamType) 0,
+    (SkFunctionParamType) SkType_Float, // atan
+    (SkFunctionParamType) 0,
+    (SkFunctionParamType) SkType_Float, // atan2
+    (SkFunctionParamType) SkType_Float,
+    (SkFunctionParamType) 0,
+    (SkFunctionParamType) SkType_Float, // ceil
+    (SkFunctionParamType) 0,
+    (SkFunctionParamType) SkType_Float, // cos
+    (SkFunctionParamType) 0,
+    (SkFunctionParamType) SkType_Float, // exp
+    (SkFunctionParamType) 0,
+    (SkFunctionParamType) SkType_Float, // floor
+    (SkFunctionParamType) 0,
+    (SkFunctionParamType) SkType_Float, // log
+    (SkFunctionParamType) 0,
+    (SkFunctionParamType) SkType_Array, // max
+    (SkFunctionParamType) 0,
+    (SkFunctionParamType) SkType_Array, // min
+    (SkFunctionParamType) 0,
+    (SkFunctionParamType) SkType_Float, // pow
+    (SkFunctionParamType) SkType_Float,
+    (SkFunctionParamType) 0,
+    (SkFunctionParamType) SkType_Float, // random
+    (SkFunctionParamType) 0,
+    (SkFunctionParamType) SkType_Float, // round
+    (SkFunctionParamType) 0,
+    (SkFunctionParamType) SkType_Float, // sin
+    (SkFunctionParamType) 0,
+    (SkFunctionParamType) SkType_Float, // sqrt
+    (SkFunctionParamType) 0,
+    (SkFunctionParamType) SkType_Float, // tan
+    (SkFunctionParamType) 0
 };
 
 #if SK_USE_CONDENSED_INFO == 0
 
 const SkMemberInfo SkDisplayMath::fInfo[] = {
-       SK_MEMBER_PROPERTY(E, Float),
-       SK_MEMBER_PROPERTY(LN10, Float),
-       SK_MEMBER_PROPERTY(LN2, Float),
-       SK_MEMBER_PROPERTY(LOG10E, Float),
-       SK_MEMBER_PROPERTY(LOG2E, Float),
-       SK_MEMBER_PROPERTY(PI, Float),
-       SK_MEMBER_PROPERTY(SQRT1_2, Float),
-       SK_MEMBER_PROPERTY(SQRT2, Float),
-       SK_MEMBER_FUNCTION(abs, Float),
-       SK_MEMBER_FUNCTION(acos, Float),
-       SK_MEMBER_FUNCTION(asin, Float),
-       SK_MEMBER_FUNCTION(atan, Float),
-       SK_MEMBER_FUNCTION(atan2, Float),
-       SK_MEMBER_FUNCTION(ceil, Float),
-       SK_MEMBER_FUNCTION(cos, Float),
-       SK_MEMBER_FUNCTION(exp, Float),
-       SK_MEMBER_FUNCTION(floor, Float),
-       SK_MEMBER_FUNCTION(log, Float),
-       SK_MEMBER_FUNCTION(max, Float),
-       SK_MEMBER_FUNCTION(min, Float),
-       SK_MEMBER_FUNCTION(pow, Float),
-       SK_MEMBER_FUNCTION(random, Float),
-       SK_MEMBER_FUNCTION(round, Float),
-       SK_MEMBER_FUNCTION(sin, Float),
-       SK_MEMBER_FUNCTION(sqrt, Float),
-       SK_MEMBER_FUNCTION(tan, Float)
+    SK_MEMBER_PROPERTY(E, Float),
+    SK_MEMBER_PROPERTY(LN10, Float),
+    SK_MEMBER_PROPERTY(LN2, Float),
+    SK_MEMBER_PROPERTY(LOG10E, Float),
+    SK_MEMBER_PROPERTY(LOG2E, Float),
+    SK_MEMBER_PROPERTY(PI, Float),
+    SK_MEMBER_PROPERTY(SQRT1_2, Float),
+    SK_MEMBER_PROPERTY(SQRT2, Float),
+    SK_MEMBER_FUNCTION(abs, Float),
+    SK_MEMBER_FUNCTION(acos, Float),
+    SK_MEMBER_FUNCTION(asin, Float),
+    SK_MEMBER_FUNCTION(atan, Float),
+    SK_MEMBER_FUNCTION(atan2, Float),
+    SK_MEMBER_FUNCTION(ceil, Float),
+    SK_MEMBER_FUNCTION(cos, Float),
+    SK_MEMBER_FUNCTION(exp, Float),
+    SK_MEMBER_FUNCTION(floor, Float),
+    SK_MEMBER_FUNCTION(log, Float),
+    SK_MEMBER_FUNCTION(max, Float),
+    SK_MEMBER_FUNCTION(min, Float),
+    SK_MEMBER_FUNCTION(pow, Float),
+    SK_MEMBER_FUNCTION(random, Float),
+    SK_MEMBER_FUNCTION(round, Float),
+    SK_MEMBER_FUNCTION(sin, Float),
+    SK_MEMBER_FUNCTION(sqrt, Float),
+    SK_MEMBER_FUNCTION(tan, Float)
 };
 
 #endif
@@ -131,101 +148,101 @@ const SkMemberInfo SkDisplayMath::fInfo[] = {
 DEFINE_GET_MEMBER(SkDisplayMath);
 
 void SkDisplayMath::executeFunction(SkDisplayable* target, int index, 
-               SkTDArray<SkScriptValue>& parameters, SkDisplayTypes type,
-               SkScriptValue* scriptValue) {
-       if (scriptValue == nil)
-               return;
-       SkASSERT(target == this);
-       SkScriptValue* array = parameters.begin();
-       SkScriptValue* end = parameters.end();
-       SkScalar input = parameters[0].fOperand.fScalar;
-       SkScalar scalarResult;
-       switch (index) {
-               case SK_FUNCTION(abs):
-                       scalarResult = SkScalarAbs(input); 
-                       break;
-               case SK_FUNCTION(acos):
-                       scalarResult = SkScalarACos(input);
-                       break;
-               case SK_FUNCTION(asin):
-                       scalarResult = SkScalarASin(input);
-                       break;
-               case SK_FUNCTION(atan):
-                       scalarResult = SkScalarATan2(input, SK_Scalar1);
-                       break;
-               case SK_FUNCTION(atan2):
-                       scalarResult = SkScalarATan2(input, parameters[1].fOperand.fScalar);
-                       break;
-               case SK_FUNCTION(ceil):
-                       scalarResult = SkIntToScalar(SkScalarCeil(input)); 
-                       break;
-               case SK_FUNCTION(cos):
-                       scalarResult = SkScalarCos(input);
-                       break;
-               case SK_FUNCTION(exp):
-                       scalarResult = SkScalarExp(input);
-                       break;
-               case SK_FUNCTION(floor):
-                       scalarResult = SkIntToScalar(SkScalarFloor(input)); 
-                       break;
-               case SK_FUNCTION(log):
-                       scalarResult = SkScalarLog(input);
-                       break;
-               case SK_FUNCTION(max):
-                       scalarResult = -SK_ScalarMax;
-                       while (array < end) {
-                               scalarResult = SkMaxScalar(scalarResult, array->fOperand.fScalar);
-                               array++;
-                       }
-                       break;
-               case SK_FUNCTION(min):
-                       scalarResult = SK_ScalarMax;
-                       while (array < end) {
-                               scalarResult = SkMinScalar(scalarResult, array->fOperand.fScalar);
-                               array++;
-                       }
-                       break;
-               case SK_FUNCTION(pow):
-                       // not the greatest -- but use x^y = e^(y * ln(x))
-                       scalarResult = SkScalarLog(input);
-                       scalarResult = SkScalarMul(parameters[1].fOperand.fScalar, scalarResult);
-                       scalarResult = SkScalarExp(scalarResult);
-                       break;
-               case SK_FUNCTION(random):
-                       scalarResult = fRandom.nextUScalar1();
-                       break;
-               case SK_FUNCTION(round):
-                       scalarResult = SkIntToScalar(SkScalarRound(input)); 
-                       break;
-               case SK_FUNCTION(sin):
-                       scalarResult = SkScalarSin(input);
-                       break;
-               case SK_FUNCTION(sqrt): {
-                       SkASSERT(parameters.count() == 1);
-                       SkASSERT(type == SkType_Float);
-                       scalarResult = SkScalarSqrt(input); 
-                       } break;
-               case SK_FUNCTION(tan):
-                       scalarResult = SkScalarTan(input);
-                       break;
-               default:
-                       SkASSERT(0);
-                       scalarResult = SK_ScalarNaN;
-       }
-       scriptValue->fOperand.fScalar = scalarResult;
-       scriptValue->fType = SkType_Float;
+        SkTDArray<SkScriptValue>& parameters, SkDisplayTypes type,
+        SkScriptValue* scriptValue) {
+    if (scriptValue == nil)
+        return;
+    SkASSERT(target == this);
+    SkScriptValue* array = parameters.begin();
+    SkScriptValue* end = parameters.end();
+    SkScalar input = parameters[0].fOperand.fScalar;
+    SkScalar scalarResult;
+    switch (index) {
+        case SK_FUNCTION(abs):
+            scalarResult = SkScalarAbs(input); 
+            break;
+        case SK_FUNCTION(acos):
+            scalarResult = SkScalarACos(input);
+            break;
+        case SK_FUNCTION(asin):
+            scalarResult = SkScalarASin(input);
+            break;
+        case SK_FUNCTION(atan):
+            scalarResult = SkScalarATan2(input, SK_Scalar1);
+            break;
+        case SK_FUNCTION(atan2):
+            scalarResult = SkScalarATan2(input, parameters[1].fOperand.fScalar);
+            break;
+        case SK_FUNCTION(ceil):
+            scalarResult = SkIntToScalar(SkScalarCeil(input)); 
+            break;
+        case SK_FUNCTION(cos):
+            scalarResult = SkScalarCos(input);
+            break;
+        case SK_FUNCTION(exp):
+            scalarResult = SkScalarExp(input);
+            break;
+        case SK_FUNCTION(floor):
+            scalarResult = SkIntToScalar(SkScalarFloor(input)); 
+            break;
+        case SK_FUNCTION(log):
+            scalarResult = SkScalarLog(input);
+            break;
+        case SK_FUNCTION(max):
+            scalarResult = -SK_ScalarMax;
+            while (array < end) {
+                scalarResult = SkMaxScalar(scalarResult, array->fOperand.fScalar);
+                array++;
+            }
+            break;
+        case SK_FUNCTION(min):
+            scalarResult = SK_ScalarMax;
+            while (array < end) {
+                scalarResult = SkMinScalar(scalarResult, array->fOperand.fScalar);
+                array++;
+            }
+            break;
+        case SK_FUNCTION(pow):
+            // not the greatest -- but use x^y = e^(y * ln(x))
+            scalarResult = SkScalarLog(input);
+            scalarResult = SkScalarMul(parameters[1].fOperand.fScalar, scalarResult);
+            scalarResult = SkScalarExp(scalarResult);
+            break;
+        case SK_FUNCTION(random):
+            scalarResult = fRandom.nextUScalar1();
+            break;
+        case SK_FUNCTION(round):
+            scalarResult = SkIntToScalar(SkScalarRound(input)); 
+            break;
+        case SK_FUNCTION(sin):
+            scalarResult = SkScalarSin(input);
+            break;
+        case SK_FUNCTION(sqrt): {
+            SkASSERT(parameters.count() == 1);
+            SkASSERT(type == SkType_Float);
+            scalarResult = SkScalarSqrt(input); 
+            } break;
+        case SK_FUNCTION(tan):
+            scalarResult = SkScalarTan(input);
+            break;
+        default:
+            SkASSERT(0);
+            scalarResult = SK_ScalarNaN;
+    }
+    scriptValue->fOperand.fScalar = scalarResult;
+    scriptValue->fType = SkType_Float;
 }
 
 const SkFunctionParamType* SkDisplayMath::getFunctionsParameters() {
-       return fFunctionParameters;
+    return fFunctionParameters;
 }
 
 bool SkDisplayMath::getProperty(int index, SkScriptValue* value) const {
-       if ((unsigned)index < SK_ARRAY_COUNT(gConstants)) {
-               value->fOperand.fScalar = gConstants[index];
-               value->fType = SkType_Float;
-               return true;
-       }
-       SkASSERT(0);
-       return false;
+    if ((unsigned)index < SK_ARRAY_COUNT(gConstants)) {
+        value->fOperand.fScalar = gConstants[index];
+        value->fType = SkType_Float;
+        return true;
+    }
+    SkASSERT(0);
+    return false;
 }
index ced6e42..dc1fb9e 100644 (file)
@@ -1,3 +1,20 @@
+/* libs/graphics/animator/SkDisplayMath.h
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #ifndef SkDisplayMath_DEFINED
 #define SkDisplayMath_DEFINED
 
 #include "SkRandom.h"
 
 class SkDisplayMath : public SkDisplayable {
-       DECLARE_DISPLAY_MEMBER_INFO(Math);
-       virtual void executeFunction(SkDisplayable* , int index, 
-               SkTDArray<SkScriptValue>& parameters, SkDisplayTypes type,
-               SkScriptValue* );
-       virtual const SkFunctionParamType* getFunctionsParameters();
-       virtual bool getProperty(int index, SkScriptValue* value) const;
+    DECLARE_DISPLAY_MEMBER_INFO(Math);
+    virtual void executeFunction(SkDisplayable* , int index, 
+        SkTDArray<SkScriptValue>& parameters, SkDisplayTypes type,
+        SkScriptValue* );
+    virtual const SkFunctionParamType* getFunctionsParameters();
+    virtual bool getProperty(int index, SkScriptValue* value) const;
 private:
-       mutable SkRandom fRandom;
-       static const SkScalar gConstants[];
-       static const SkFunctionParamType fFunctionParameters[];
+    mutable SkRandom fRandom;
+    static const SkScalar gConstants[];
+    static const SkFunctionParamType fFunctionParameters[];
 
 };
-       
+    
 #endif // SkDisplayMath_DEFINED
 
index 3727efe..dbc458c 100644 (file)
@@ -1,3 +1,20 @@
+/* libs/graphics/animator/SkDisplayMovie.cpp
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #include "SkDisplayMovie.h"
 #include "SkAnimateMaker.h"
 #include "SkCanvas.h"
@@ -6,7 +23,7 @@
 #if SK_USE_CONDENSED_INFO == 0
 
 const SkMemberInfo SkDisplayMovie::fInfo[] = {
-       SK_MEMBER(src, String)
+    SK_MEMBER(src, String)
 };
 
 #endif
@@ -14,108 +31,108 @@ const SkMemberInfo SkDisplayMovie::fInfo[] = {
 DEFINE_GET_MEMBER(SkDisplayMovie);
 
 SkDisplayMovie::SkDisplayMovie() : fDecodedSuccessfully(false), fLoaded(false), fMovieBuilt(false) {
-       fMovie.fMaker->fInMovie = true;
+    fMovie.fMaker->fInMovie = true;
 }
 
 SkDisplayMovie::~SkDisplayMovie() {
 }
 
 void SkDisplayMovie::buildMovie() {
-       if (fMovieBuilt)
-               return;
-       SkAnimateMaker* movieMaker = fMovie.fMaker;
-       SkAnimateMaker* parentMaker = movieMaker->fParentMaker;
-       if (src.size() == 0 || parentMaker == nil)
-               return;
-       movieMaker->fPrefix.set(parentMaker->fPrefix);
-       fDecodedSuccessfully = fMovie.fMaker->decodeURI(src.c_str());
-       if (fDecodedSuccessfully == false) {
-
-               if (movieMaker->getErrorCode() != SkXMLParserError::kNoError || movieMaker->getNativeCode() != -1) {
-                       movieMaker->setInnerError(parentMaker, src);
-                       parentMaker->setErrorCode(SkDisplayXMLParserError::kInMovie);
-               } else {
-                       parentMaker->setErrorNoun(src);
-                       parentMaker->setErrorCode(SkDisplayXMLParserError::kMovieNameUnknownOrMissing);
-               }
-       }
-       fMovieBuilt = true;
+    if (fMovieBuilt)
+        return;
+    SkAnimateMaker* movieMaker = fMovie.fMaker;
+    SkAnimateMaker* parentMaker = movieMaker->fParentMaker;
+    if (src.size() == 0 || parentMaker == nil)
+        return;
+    movieMaker->fPrefix.set(parentMaker->fPrefix);
+    fDecodedSuccessfully = fMovie.fMaker->decodeURI(src.c_str());
+    if (fDecodedSuccessfully == false) {
+
+        if (movieMaker->getErrorCode() != SkXMLParserError::kNoError || movieMaker->getNativeCode() != -1) {
+            movieMaker->setInnerError(parentMaker, src);
+            parentMaker->setErrorCode(SkDisplayXMLParserError::kInMovie);
+        } else {
+            parentMaker->setErrorNoun(src);
+            parentMaker->setErrorCode(SkDisplayXMLParserError::kMovieNameUnknownOrMissing);
+        }
+    }
+    fMovieBuilt = true;
 }
 
 SkDisplayable* SkDisplayMovie::deepCopy(SkAnimateMaker* maker) {
-       SkDisplayMovie* copy = (SkDisplayMovie*) INHERITED::deepCopy(maker);
-       copy->fMovie.fMaker->fParentMaker = fMovie.fMaker->fParentMaker;
-       copy->fMovie.fMaker->fHostEventSinkID = fMovie.fMaker->fHostEventSinkID;
-       copy->fMovieBuilt = false;
-       *fMovie.fMaker->fParentMaker->fMovies.append() = copy;
-       return copy;
+    SkDisplayMovie* copy = (SkDisplayMovie*) INHERITED::deepCopy(maker);
+    copy->fMovie.fMaker->fParentMaker = fMovie.fMaker->fParentMaker;
+    copy->fMovie.fMaker->fHostEventSinkID = fMovie.fMaker->fHostEventSinkID;
+    copy->fMovieBuilt = false;
+    *fMovie.fMaker->fParentMaker->fMovies.append() = copy;
+    return copy;
 }
 
 void SkDisplayMovie::dirty() {
-       buildMovie();
+    buildMovie();
 }
 
 bool SkDisplayMovie::doEvent(SkDisplayEvent::Kind kind, SkEventState* state) {
     if (fLoaded == false)
         return false;
-       fMovie.fMaker->fEnableTime = fMovie.fMaker->fParentMaker->fEnableTime;
-       return fMovie.fMaker->fEvents.doEvent(*fMovie.fMaker, kind, state);
+    fMovie.fMaker->fEnableTime = fMovie.fMaker->fParentMaker->fEnableTime;
+    return fMovie.fMaker->fEvents.doEvent(*fMovie.fMaker, kind, state);
 }
 
 bool SkDisplayMovie::draw(SkAnimateMaker& maker) {
-       if (fDecodedSuccessfully == false)
-               return false;
-       if (fLoaded == false)
-               enable(maker);
-       maker.fCanvas->save();
-       SkPaint local = SkPaint(*maker.fPaint);
-       bool result = fMovie.draw(maker.fCanvas, &local, 
-               maker.fDisplayList.getTime()) != SkAnimator::kNotDifferent;
-       maker.fDisplayList.fInvalBounds.join(fMovie.fMaker->fDisplayList.fInvalBounds);
-       maker.fCanvas->restore();
-       return result;
+    if (fDecodedSuccessfully == false)
+        return false;
+    if (fLoaded == false)
+        enable(maker);
+    maker.fCanvas->save();
+    SkPaint local = SkPaint(*maker.fPaint);
+    bool result = fMovie.draw(maker.fCanvas, &local, 
+        maker.fDisplayList.getTime()) != SkAnimator::kNotDifferent;
+    maker.fDisplayList.fInvalBounds.join(fMovie.fMaker->fDisplayList.fInvalBounds);
+    maker.fCanvas->restore();
+    return result;
 }
 
 #ifdef SK_DUMP_ENABLED
 void SkDisplayMovie::dump(SkAnimateMaker* maker) {
-       dumpBase(maker);
-       SkDebugf("src=\"%s\"/>\n",  src.c_str());
-       SkAnimateMaker* movieMaker = fMovie.fMaker;
-       SkDisplayList::fIndent += 4;
-       movieMaker->fDisplayList.dumpInner(movieMaker);
-       SkDisplayList::fIndent -= 4;
+    dumpBase(maker);
+    SkDebugf("src=\"%s\"/>\n",  src.c_str());
+    SkAnimateMaker* movieMaker = fMovie.fMaker;
+    SkDisplayList::fIndent += 4;
+    movieMaker->fDisplayList.dumpInner(movieMaker);
+    SkDisplayList::fIndent -= 4;
     dumpEnd(maker);
 }
 
 void SkDisplayMovie::dumpEvents() {
-       fMovie.fMaker->fEvents.dump(*fMovie.fMaker);
+    fMovie.fMaker->fEvents.dump(*fMovie.fMaker);
 }
 #endif
 
 bool SkDisplayMovie::enable(SkAnimateMaker& maker) {
-       if (fDecodedSuccessfully == false)
-               return false;
-       SkAnimateMaker* movieMaker = fMovie.fMaker;
-       movieMaker->fEvents.doEvent(*movieMaker, SkDisplayEvent::kOnload, nil);
-       movieMaker->fEvents.removeEvent(SkDisplayEvent::kOnload, nil);
-       fLoaded = true;
+    if (fDecodedSuccessfully == false)
+        return false;
+    SkAnimateMaker* movieMaker = fMovie.fMaker;
+    movieMaker->fEvents.doEvent(*movieMaker, SkDisplayEvent::kOnload, nil);
+    movieMaker->fEvents.removeEvent(SkDisplayEvent::kOnload, nil);
+    fLoaded = true;
     movieMaker->fLoaded = true;
-       return false;
+    return false;
 }
 
 bool SkDisplayMovie::hasEnable() const {
-       return true;
+    return true;
 }
 
 void SkDisplayMovie::onEndElement(SkAnimateMaker& maker) {
 #if defined SK_DEBUG && defined SK_DEBUG_ANIMATION_TIMING
-       fMovie.fMaker->fDebugTimeBase = maker.fDebugTimeBase;
+    fMovie.fMaker->fDebugTimeBase = maker.fDebugTimeBase;
 #endif
-       fMovie.fMaker->fPrefix.set(maker.fPrefix);
-       fMovie.fMaker->fHostEventSinkID = maker.fHostEventSinkID;
-       fMovie.fMaker->fParentMaker = &maker;
-       buildMovie();
-       *maker.fMovies.append() = this;
+    fMovie.fMaker->fPrefix.set(maker.fPrefix);
+    fMovie.fMaker->fHostEventSinkID = maker.fHostEventSinkID;
+    fMovie.fMaker->fParentMaker = &maker;
+    buildMovie();
+    *maker.fMovies.append() = this;
 }
 
 
index f81a740..9441343 100644 (file)
@@ -1,3 +1,20 @@
+/* libs/graphics/animator/SkDisplayMovie.h
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #ifndef SkDisplayMovie_DEFINED
 #define SkDisplayMovie_DEFINED
 
 struct SkEventState;
 
 class SkDisplayMovie : public SkDrawable {
-       DECLARE_DISPLAY_MEMBER_INFO(Movie);
-       SkDisplayMovie();
-       virtual ~SkDisplayMovie();
-       void buildMovie();
-       virtual SkDisplayable* deepCopy(SkAnimateMaker* );
-       virtual void dirty();
-       bool doEvent(const SkEvent& evt) {
-               return fLoaded && fMovie.doEvent(evt);
-       }
-       virtual bool doEvent(SkDisplayEvent::Kind , SkEventState* state );
-       virtual bool draw(SkAnimateMaker& );
+    DECLARE_DISPLAY_MEMBER_INFO(Movie);
+    SkDisplayMovie();
+    virtual ~SkDisplayMovie();
+    void buildMovie();
+    virtual SkDisplayable* deepCopy(SkAnimateMaker* );
+    virtual void dirty();
+    bool doEvent(const SkEvent& evt) {
+        return fLoaded && fMovie.doEvent(evt);
+    }
+    virtual bool doEvent(SkDisplayEvent::Kind , SkEventState* state );
+    virtual bool draw(SkAnimateMaker& );
 #ifdef SK_DUMP_ENABLED
-       virtual void dump(SkAnimateMaker* );
-       virtual void dumpEvents();
+    virtual void dump(SkAnimateMaker* );
+    virtual void dumpEvents();
 #endif
-       virtual bool enable(SkAnimateMaker& );
-       const SkAnimator* getAnimator() const { return &fMovie; }
-       virtual bool hasEnable() const;
-       virtual void onEndElement(SkAnimateMaker& );
+    virtual bool enable(SkAnimateMaker& );
+    const SkAnimator* getAnimator() const { return &fMovie; }
+    virtual bool hasEnable() const;
+    virtual void onEndElement(SkAnimateMaker& );
 protected:
-       SkString src;
-       SkAnimator fMovie;
-       SkBool8 fDecodedSuccessfully;
-       SkBool8 fLoaded;
-       SkBool8 fMovieBuilt;
-       friend class SkAnimateMaker;
-       friend class SkPost;
+    SkString src;
+    SkAnimator fMovie;
+    SkBool8 fDecodedSuccessfully;
+    SkBool8 fLoaded;
+    SkBool8 fMovieBuilt;
+    friend class SkAnimateMaker;
+    friend class SkPost;
 private:
-       typedef SkDrawable INHERITED;
+    typedef SkDrawable INHERITED;
 };
 
 #endif // SkDisplayMovie_DEFINED
index 03de65c..062fd4a 100644 (file)
@@ -1,21 +1,38 @@
+/* libs/graphics/animator/SkDisplayNumber.cpp
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #include "SkDisplayNumber.h"
 
 enum SkDisplayNumber_Properties {
-       SK_PROPERTY(MAX_VALUE),
-       SK_PROPERTY(MIN_VALUE),
-       SK_PROPERTY(NEGATIVE_INFINITY),
-       SK_PROPERTY(NaN),
-       SK_PROPERTY(POSITIVE_INFINITY)
+    SK_PROPERTY(MAX_VALUE),
+    SK_PROPERTY(MIN_VALUE),
+    SK_PROPERTY(NEGATIVE_INFINITY),
+    SK_PROPERTY(NaN),
+    SK_PROPERTY(POSITIVE_INFINITY)
 };
 
 #if SK_USE_CONDENSED_INFO == 0
 
 const SkMemberInfo SkDisplayNumber::fInfo[] = {
-       SK_MEMBER_PROPERTY(MAX_VALUE, Float),
-       SK_MEMBER_PROPERTY(MIN_VALUE, Float),
-       SK_MEMBER_PROPERTY(NEGATIVE_INFINITY, Float),
-       SK_MEMBER_PROPERTY(NaN, Float),
-       SK_MEMBER_PROPERTY(POSITIVE_INFINITY, Float)
+    SK_MEMBER_PROPERTY(MAX_VALUE, Float),
+    SK_MEMBER_PROPERTY(MIN_VALUE, Float),
+    SK_MEMBER_PROPERTY(NEGATIVE_INFINITY, Float),
+    SK_MEMBER_PROPERTY(NaN, Float),
+    SK_MEMBER_PROPERTY(POSITIVE_INFINITY, Float)
 };
 
 #endif
@@ -23,28 +40,28 @@ const SkMemberInfo SkDisplayNumber::fInfo[] = {
 DEFINE_GET_MEMBER(SkDisplayNumber);
 
 bool SkDisplayNumber::getProperty(int index, SkScriptValue* value) const {
-       SkScalar constant;
-       switch (index) {
-               case SK_PROPERTY(MAX_VALUE):
-                       constant = SK_ScalarMax;
-               break;
-               case SK_PROPERTY(MIN_VALUE):
-                       constant = SK_ScalarMin;
-               break;
-               case SK_PROPERTY(NEGATIVE_INFINITY):
-                       constant = -SK_ScalarInfinity;
-               break;
-               case SK_PROPERTY(NaN):
-                       constant = SK_ScalarNaN;
-               break;
-               case SK_PROPERTY(POSITIVE_INFINITY):
-                       constant = SK_ScalarInfinity;
-               break;
-               default:
-                       SkASSERT(0);
-                       return false;
-       }
-       value->fOperand.fScalar = constant;
-       value->fType = SkType_Float;
-       return true;
+    SkScalar constant;
+    switch (index) {
+        case SK_PROPERTY(MAX_VALUE):
+            constant = SK_ScalarMax;
+        break;
+        case SK_PROPERTY(MIN_VALUE):
+            constant = SK_ScalarMin;
+        break;
+        case SK_PROPERTY(NEGATIVE_INFINITY):
+            constant = -SK_ScalarInfinity;
+        break;
+        case SK_PROPERTY(NaN):
+            constant = SK_ScalarNaN;
+        break;
+        case SK_PROPERTY(POSITIVE_INFINITY):
+            constant = SK_ScalarInfinity;
+        break;
+        default:
+            SkASSERT(0);
+            return false;
+    }
+    value->fOperand.fScalar = constant;
+    value->fType = SkType_Float;
+    return true;
 }
index 7b2ea58..5429aaf 100644 (file)
@@ -1,3 +1,20 @@
+/* libs/graphics/animator/SkDisplayNumber.h
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #ifndef SkDisplayNumber_DEFINED
 #define SkDisplayNumber_DEFINED
 
@@ -5,9 +22,9 @@
 #include "SkMemberInfo.h"
 
 class SkDisplayNumber : public SkDisplayable {
-       DECLARE_DISPLAY_MEMBER_INFO(Number);
-       virtual bool getProperty(int index, SkScriptValue* value) const;
+    DECLARE_DISPLAY_MEMBER_INFO(Number);
+    virtual bool getProperty(int index, SkScriptValue* value) const;
 private:
 };
-       
+    
 #endif // SkDisplayNumber_DEFINED
index fad3aee..4c927a3 100644 (file)
@@ -1,3 +1,20 @@
+/* libs/graphics/animator/SkDisplayPost.cpp
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #include "SkDisplayPost.h"
 #include "SkAnimateMaker.h"
 #include "SkAnimator.h"
 #endif
 
 enum SkPost_Properties {
-       SK_PROPERTY(target),
-       SK_PROPERTY(type)
+    SK_PROPERTY(target),
+    SK_PROPERTY(type)
 };
 
 #if SK_USE_CONDENSED_INFO == 0
 
 const SkMemberInfo SkPost::fInfo[] = {
-       SK_MEMBER(delay, MSec),
-//     SK_MEMBER(initialized, Boolean),
-       SK_MEMBER(mode, EventMode),
-       SK_MEMBER(sink, String),
-       SK_MEMBER_PROPERTY(target, String),
-       SK_MEMBER_PROPERTY(type, String)
+    SK_MEMBER(delay, MSec),
+//  SK_MEMBER(initialized, Boolean),
+    SK_MEMBER(mode, EventMode),
+    SK_MEMBER(sink, String),
+    SK_MEMBER_PROPERTY(target, String),
+    SK_MEMBER_PROPERTY(type, String)
 };
 
 #endif
@@ -30,32 +47,32 @@ const SkMemberInfo SkPost::fInfo[] = {
 DEFINE_GET_MEMBER(SkPost);
 
 SkPost::SkPost() : delay(0), /*initialized(SkBool(-1)), */ mode(kImmediate), fMaker(nil),
-       fSinkID(0), fTargetMaker(nil), fChildHasID(false), fDirty(false) {
+    fSinkID(0), fTargetMaker(nil), fChildHasID(false), fDirty(false) {
 }
 
 SkPost::~SkPost() {
-       for (SkData** part = fParts.begin(); part < fParts.end();  part++)
-               delete *part;
+    for (SkData** part = fParts.begin(); part < fParts.end();  part++)
+        delete *part;
 }
 
 bool SkPost::add(SkAnimateMaker& , SkDisplayable* child) {
-       SkASSERT(child && child->isData());
-       SkData* part = (SkData*) child;
-       *fParts.append() = part;
-       return true;
+    SkASSERT(child && child->isData());
+    SkData* part = (SkData*) child;
+    *fParts.append() = part;
+    return true;
 }
 
 bool SkPost::childrenNeedDisposing() const { 
-       return false; 
+    return false; 
 }
 
 void SkPost::dirty() { 
-       fDirty = true; 
+    fDirty = true; 
 }
 
 #ifdef SK_DUMP_ENABLED
 void SkPost::dump(SkAnimateMaker* maker) {
-       dumpBase(maker);
+    dumpBase(maker);
     SkString* eventType = new SkString();
     fEvent.getType(eventType);
     if (eventType->equals("user")) {
@@ -66,30 +83,30 @@ void SkPost::dump(SkAnimateMaker* maker) {
         SkDebugf("type=\"%s\" ", eventType->c_str());
     delete eventType;
     
-       if (delay > 0) {
+    if (delay > 0) {
 #ifdef SK_CAN_USE_FLOAT
-               SkDebugf("delay=\"%g\" ", SkScalarToFloat(SkScalarDiv(delay, 1000)));
+        SkDebugf("delay=\"%g\" ", SkScalarToFloat(SkScalarDiv(delay, 1000)));
 #else
-               SkDebugf("delay=\"%x\" ", SkScalarDiv(delay, 1000));
+        SkDebugf("delay=\"%x\" ", SkScalarDiv(delay, 1000));
 #endif
     }
-//     if (initialized == false)
-//             SkDebugf("(uninitialized) ");
-       SkString string;
-       SkDump::GetEnumString(SkType_EventMode, mode, &string);
+//  if (initialized == false)
+//      SkDebugf("(uninitialized) ");
+    SkString string;
+    SkDump::GetEnumString(SkType_EventMode, mode, &string);
     if (!string.equals("immediate"))
         SkDebugf("mode=\"%s\" ", string.c_str());
-       // !!! could enhance this to search through make hierarchy to show name of sink
-       if (sink.size() > 0) {
-               SkDebugf("sink=\"%s\" sinkID=\"%d\" ", sink.c_str(), fSinkID);
-       } else if (fSinkID != maker->getAnimator()->getSinkID() && fSinkID != 0) {
-               SkDebugf("sinkID=\"%d\" ", fSinkID);
-       }
-       const SkMetaData& meta = fEvent.getMetaData();
-       SkMetaData::Iter iter(meta);
-       SkMetaData::Type        type;
-       int number;
-       const char* name;
+    // !!! could enhance this to search through make hierarchy to show name of sink
+    if (sink.size() > 0) {
+        SkDebugf("sink=\"%s\" sinkID=\"%d\" ", sink.c_str(), fSinkID);
+    } else if (fSinkID != maker->getAnimator()->getSinkID() && fSinkID != 0) {
+        SkDebugf("sinkID=\"%d\" ", fSinkID);
+    }
+    const SkMetaData& meta = fEvent.getMetaData();
+    SkMetaData::Iter iter(meta);
+    SkMetaData::Type    type;
+    int number;
+    const char* name;
     bool closedYet = false;
     SkDisplayList::fIndent += 4;
     //this seems to work, but kinda hacky
@@ -99,7 +116,7 @@ void SkPost::dump(SkAnimateMaker* maker) {
     //SkData** ptr = fParts.end();
     //SkData* data;
     //const char* ID;
-       while ((name = iter.next(&type, &number)) != nil) {
+    while ((name = iter.next(&type, &number)) != nil) {
         //ptr--;
         if (strcmp(name, "id") == 0)
             continue;
@@ -112,47 +129,47 @@ void SkPost::dump(SkAnimateMaker* maker) {
         //    ID = data->id;
         //else
         //    ID = "";
-               SkDebugf("%*s<data name=\"%s\" ", SkDisplayList::fIndent, "", name);
-               switch (type) {
-                       case SkMetaData::kS32_Type: {
-                               int32_t s32;
-                               meta.findS32(name, &s32);
-                               SkDebugf("int=\"%d\" ", s32);
-                               } break;
-                       case SkMetaData::kScalar_Type: {
-                               SkScalar scalar;
-                               meta.findScalar(name, &scalar);
+        SkDebugf("%*s<data name=\"%s\" ", SkDisplayList::fIndent, "", name);
+        switch (type) {
+            case SkMetaData::kS32_Type: {
+                int32_t s32;
+                meta.findS32(name, &s32);
+                SkDebugf("int=\"%d\" ", s32);
+                } break;
+            case SkMetaData::kScalar_Type: {
+                SkScalar scalar;
+                meta.findScalar(name, &scalar);
 #ifdef SK_CAN_USE_FLOAT
-                               SkDebugf("float=\"%g\" ", SkScalarToFloat(scalar));
+                SkDebugf("float=\"%g\" ", SkScalarToFloat(scalar));
 #else
-                               SkDebugf("float=\"%x\" ", scalar);
+                SkDebugf("float=\"%x\" ", scalar);
 #endif
-                               } break;
-                       case SkMetaData::kString_Type:
-                               SkDebugf("string=\"%s\" ", meta.findString(name));
-                               break;
-                       case SkMetaData::kPtr_Type: {//when do we have a pointer
-                                       void* ptr;
-                                       meta.findPtr(name, &ptr);
-                                       SkDebugf("0x%08x ", ptr);
-                               } break;
-                       case SkMetaData::kBool_Type: {
-                               bool boolean;
-                               meta.findBool(name, &boolean);
-                               SkDebugf("boolean=\"%s\" ", boolean ? "true " : "false ");
-                               } break;
+                } break;
+            case SkMetaData::kString_Type:
+                SkDebugf("string=\"%s\" ", meta.findString(name));
+                break;
+            case SkMetaData::kPtr_Type: {//when do we have a pointer
+                    void* ptr;
+                    meta.findPtr(name, &ptr);
+                    SkDebugf("0x%08x ", ptr);
+                } break;
+            case SkMetaData::kBool_Type: {
+                bool boolean;
+                meta.findBool(name, &boolean);
+                SkDebugf("boolean=\"%s\" ", boolean ? "true " : "false ");
+                } break;
             default:
                 break;
-               }
+        }
         SkDebugf("/>\n");
         //ptr++;
 /*      perhaps this should only be done in the case of a pointer?
-               SkDisplayable* displayable;
-               if (maker->find(name, &displayable))
-                       displayable->dump(maker);
-               else
-                       SkDebugf("\n");*/
-       }
+        SkDisplayable* displayable;
+        if (maker->find(name, &displayable))
+            displayable->dump(maker);
+        else
+            SkDebugf("\n");*/
+    }
     SkDisplayList::fIndent -= 4;
     if (closedYet)
         dumpEnd(maker);
@@ -163,136 +180,136 @@ void SkPost::dump(SkAnimateMaker* maker) {
 #endif
 
 bool SkPost::enable(SkAnimateMaker& maker ) {
-       if (maker.hasError())
-               return true;
-       if (fDirty) {
-               if (sink.size() > 0)
-                       findSinkID();
-               if (fChildHasID) {
-                       SkString preserveID(fEvent.findString("id"));
-                       fEvent.getMetaData().reset();
-                       if (preserveID.size() > 0)
-                               fEvent.setString("id", preserveID);
-                       for (SkData** part = fParts.begin(); part < fParts.end();  part++) {
-                               if ((*part)->add())
-                                       maker.setErrorCode(SkDisplayXMLParserError::kErrorAddingDataToPost);
-                       }
-               }
-               fDirty = false;
-       }
+    if (maker.hasError())
+        return true;
+    if (fDirty) {
+        if (sink.size() > 0)
+            findSinkID();
+        if (fChildHasID) {
+            SkString preserveID(fEvent.findString("id"));
+            fEvent.getMetaData().reset();
+            if (preserveID.size() > 0)
+                fEvent.setString("id", preserveID);
+            for (SkData** part = fParts.begin(); part < fParts.end();  part++) {
+                if ((*part)->add())
+                    maker.setErrorCode(SkDisplayXMLParserError::kErrorAddingDataToPost);
+            }
+        }
+        fDirty = false;
+    }
 #ifdef SK_DUMP_ENABLED
-       if (maker.fDumpPosts) {
-               SkDebugf("post enable: ");
-               dump(&maker);
-       }
+    if (maker.fDumpPosts) {
+        SkDebugf("post enable: ");
+        dump(&maker);
+    }
 #if defined SK_DEBUG_ANIMATION_TIMING
-       SkString debugOut;
-       SkMSec time = maker.getAppTime();
-       debugOut.appendS32(time - maker.fDebugTimeBase);
-       debugOut.append(" post id=");
-       debugOut.append(_id);
-       debugOut.append(" enable=");
-       debugOut.appendS32(maker.fEnableTime - maker.fDebugTimeBase);
-       debugOut.append(" delay=");
-       debugOut.appendS32(delay);
+    SkString debugOut;
+    SkMSec time = maker.getAppTime();
+    debugOut.appendS32(time - maker.fDebugTimeBase);
+    debugOut.append(" post id=");
+    debugOut.append(_id);
+    debugOut.append(" enable=");
+    debugOut.appendS32(maker.fEnableTime - maker.fDebugTimeBase);
+    debugOut.append(" delay=");
+    debugOut.appendS32(delay);
 #endif
 #endif
-//     SkMSec adjustedDelay = maker.adjustDelay(maker.fEnableTime, delay);
-       SkMSec futureTime = maker.fEnableTime + delay;
-       fEvent.setFast32(futureTime);
+//  SkMSec adjustedDelay = maker.adjustDelay(maker.fEnableTime, delay);
+    SkMSec futureTime = maker.fEnableTime + delay;
+    fEvent.setFast32(futureTime);
 #if defined SK_DEBUG && defined SK_DEBUG_ANIMATION_TIMING
-       debugOut.append(" future=");
-       debugOut.appendS32(futureTime - maker.fDebugTimeBase);
-       SkDebugf("%s\n", debugOut.c_str());
+    debugOut.append(" future=");
+    debugOut.appendS32(futureTime - maker.fDebugTimeBase);
+    SkDebugf("%s\n", debugOut.c_str());
 #endif
-       SkEventSinkID targetID = fSinkID;
-       bool isAnimatorEvent = true;
-       SkAnimator* anim = maker.getAnimator();
-       if (targetID == 0) {
-               isAnimatorEvent = fEvent.findString("id") != nil;
-               if (isAnimatorEvent) 
-                       targetID = anim->getSinkID();
-               else if (maker.fHostEventSinkID)
-                       targetID = maker.fHostEventSinkID;
-               else
-                       return true;
-       } else
-               anim = fTargetMaker->getAnimator();
-       if (delay == 0) {
-               if (isAnimatorEvent && mode == kImmediate)
-                       fTargetMaker->doEvent(fEvent);
-               else
-                       anim->onEventPost(new SkEvent(fEvent), targetID);
-       } else
-               anim->onEventPostTime(new SkEvent(fEvent), targetID, futureTime);
-       return true;
+    SkEventSinkID targetID = fSinkID;
+    bool isAnimatorEvent = true;
+    SkAnimator* anim = maker.getAnimator();
+    if (targetID == 0) {
+        isAnimatorEvent = fEvent.findString("id") != nil;
+        if (isAnimatorEvent) 
+            targetID = anim->getSinkID();
+        else if (maker.fHostEventSinkID)
+            targetID = maker.fHostEventSinkID;
+        else
+            return true;
+    } else
+        anim = fTargetMaker->getAnimator();
+    if (delay == 0) {
+        if (isAnimatorEvent && mode == kImmediate)
+            fTargetMaker->doEvent(fEvent);
+        else
+            anim->onEventPost(new SkEvent(fEvent), targetID);
+    } else
+        anim->onEventPostTime(new SkEvent(fEvent), targetID, futureTime);
+    return true;
 }
 
 void SkPost::findSinkID() {
-       // get the next delimiter '.' if any
-       fTargetMaker = fMaker;
-       const char* ch = sink.c_str();
-       do {
-               const char* end = strchr(ch, '.');
-               size_t len = end ? end - ch : strlen(ch);
-               SkDisplayable* displayable = nil;
-               if (SK_LITERAL_STR_EQUAL("parent", ch, len)) {
-                       if (fTargetMaker->fParentMaker)
-                               fTargetMaker = fTargetMaker->fParentMaker;
-                       else {
-                               fTargetMaker->setErrorCode(SkDisplayXMLParserError::kNoParentAvailable);
-                               return;
-                       }
-               } else {
-                       fTargetMaker->find(ch, len, &displayable);
-                       if (displayable == nil || displayable->getType() != SkType_Movie) {
-                               fTargetMaker->setErrorCode(SkDisplayXMLParserError::kExpectedMovie);
-                               return;
-                       }
-                       SkDisplayMovie* movie = (SkDisplayMovie*) displayable;
-                       fTargetMaker = movie->fMovie.fMaker;
-               }
-               if (end == nil)
-                       break;
-               ch = ++end;
-       } while (true);
-       SkAnimator* anim = fTargetMaker->getAnimator();
-       fSinkID = anim->getSinkID();
+    // get the next delimiter '.' if any
+    fTargetMaker = fMaker;
+    const char* ch = sink.c_str();
+    do {
+        const char* end = strchr(ch, '.');
+        size_t len = end ? end - ch : strlen(ch);
+        SkDisplayable* displayable = nil;
+        if (SK_LITERAL_STR_EQUAL("parent", ch, len)) {
+            if (fTargetMaker->fParentMaker)
+                fTargetMaker = fTargetMaker->fParentMaker;
+            else {
+                fTargetMaker->setErrorCode(SkDisplayXMLParserError::kNoParentAvailable);
+                return;
+            }
+        } else {
+            fTargetMaker->find(ch, len, &displayable);
+            if (displayable == nil || displayable->getType() != SkType_Movie) {
+                fTargetMaker->setErrorCode(SkDisplayXMLParserError::kExpectedMovie);
+                return;
+            }
+            SkDisplayMovie* movie = (SkDisplayMovie*) displayable;
+            fTargetMaker = movie->fMovie.fMaker;
+        }
+        if (end == nil)
+            break;
+        ch = ++end;
+    } while (true);
+    SkAnimator* anim = fTargetMaker->getAnimator();
+    fSinkID = anim->getSinkID();
 }
  
 bool SkPost::hasEnable() const {
-       return true;
+    return true;
 }
 
 void SkPost::onEndElement(SkAnimateMaker& maker) {
-       fTargetMaker = fMaker = &maker;
-       if (fChildHasID == false) {
-               for (SkData** part = fParts.begin(); part < fParts.end();  part++)
-                       delete *part;
-               fParts.reset();
-       }
+    fTargetMaker = fMaker = &maker;
+    if (fChildHasID == false) {
+        for (SkData** part = fParts.begin(); part < fParts.end();  part++)
+            delete *part;
+        fParts.reset();
+    }
 }
 
 void SkPost::setChildHasID() { 
-       fChildHasID = true; 
+    fChildHasID = true; 
 }
 
 bool SkPost::setProperty(int index, SkScriptValue& value) {
-       SkASSERT(value.fType == SkType_String);
-       SkString* string = value.fOperand.fString;
-       switch(index) {
-               case SK_PROPERTY(target): {
-                       fEvent.setType("user");
-                       fEvent.setString("id", *string);
-                       mode = kImmediate;
-                       } break;
-               case SK_PROPERTY(type):
-                       fEvent.setType(*string);
-                       break;
-               default:
-                       SkASSERT(0);
-                       return false;
-       }
-       return true;
+    SkASSERT(value.fType == SkType_String);
+    SkString* string = value.fOperand.fString;
+    switch(index) {
+        case SK_PROPERTY(target): {
+            fEvent.setType("user");
+            fEvent.setString("id", *string);
+            mode = kImmediate;
+            } break;
+        case SK_PROPERTY(type):
+            fEvent.setType(*string);
+            break;
+        default:
+            SkASSERT(0);
+            return false;
+    }
+    return true;
 }
 
index cfc2fab..ab4ad60 100644 (file)
@@ -1,3 +1,20 @@
+/* libs/graphics/animator/SkDisplayPost.h
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #ifndef SkDisplayPost_DEFINED
 #define SkDisplayPost_DEFINED
 
@@ -11,40 +28,40 @@ class SkData;
 class SkAnimateMaker;
 
 class SkPost : public SkDisplayable {
-       DECLARE_MEMBER_INFO(Post);
-       enum Mode {
-               kDeferred,
-               kImmediate
-       };
-       SkPost();
-       virtual ~SkPost();
-       virtual bool add(SkAnimateMaker& , SkDisplayable* child);
-       virtual bool childrenNeedDisposing() const;
-       virtual void dirty();
+    DECLARE_MEMBER_INFO(Post);
+    enum Mode {
+        kDeferred,
+        kImmediate
+    };
+    SkPost();
+    virtual ~SkPost();
+    virtual bool add(SkAnimateMaker& , SkDisplayable* child);
+    virtual bool childrenNeedDisposing() const;
+    virtual void dirty();
 #ifdef SK_DUMP_ENABLED
-       virtual void dump(SkAnimateMaker* );
+    virtual void dump(SkAnimateMaker* );
 #endif
-       virtual bool enable(SkAnimateMaker& );
-       virtual bool hasEnable() const;
-       virtual void onEndElement(SkAnimateMaker& );
-       virtual void setChildHasID();
-       virtual bool setProperty(int index, SkScriptValue& );
+    virtual bool enable(SkAnimateMaker& );
+    virtual bool hasEnable() const;
+    virtual void onEndElement(SkAnimateMaker& );
+    virtual void setChildHasID();
+    virtual bool setProperty(int index, SkScriptValue& );
 protected:
-       SkMSec delay;
-       SkString sink;
-//     SkBool initialized;
-       Mode mode;
-       SkEvent fEvent;
-       SkAnimateMaker* fMaker;
-       SkTDDataArray fParts;
-       SkEventSinkID fSinkID;
-       SkAnimateMaker* fTargetMaker;
-       SkBool8 fChildHasID;
-       SkBool8 fDirty;
+    SkMSec delay;
+    SkString sink;
+//  SkBool initialized;
+    Mode mode;
+    SkEvent fEvent;
+    SkAnimateMaker* fMaker;
+    SkTDDataArray fParts;
+    SkEventSinkID fSinkID;
+    SkAnimateMaker* fTargetMaker;
+    SkBool8 fChildHasID;
+    SkBool8 fDirty;
 private:
-       void findSinkID();
-       friend class SkData;
-       typedef SkDisplayable INHERITED;
+    void findSinkID();
+    friend class SkData;
+    typedef SkDisplayable INHERITED;
 };
 
 #endif //SkDisplayPost_DEFINED
index 53775d3..dcdfdaf 100644 (file)
@@ -1,19 +1,36 @@
+/* libs/graphics/animator/SkDisplayRandom.cpp
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #include "SkDisplayRandom.h"
 #include "SkInterpolator.h"
 
 enum SkDisplayRandom_Properties {
-       SK_PROPERTY(random),
-       SK_PROPERTY(seed)
+    SK_PROPERTY(random),
+    SK_PROPERTY(seed)
 };
 
 #if SK_USE_CONDENSED_INFO == 0
 
 const SkMemberInfo SkDisplayRandom::fInfo[] = {
-       SK_MEMBER(blend, Float),
-       SK_MEMBER(max, Float),
-       SK_MEMBER(min, Float),
-       SK_MEMBER_DYNAMIC_PROPERTY(random, Float),
-       SK_MEMBER_PROPERTY(seed, Int)
+    SK_MEMBER(blend, Float),
+    SK_MEMBER(max, Float),
+    SK_MEMBER(min, Float),
+    SK_MEMBER_DYNAMIC_PROPERTY(random, Float),
+    SK_MEMBER_PROPERTY(seed, Int)
 };
 
 #endif
@@ -40,24 +57,24 @@ void SkDisplayRandom::dump(SkAnimateMaker* maker) {
 #endif
 
 bool SkDisplayRandom::getProperty(int index, SkScriptValue* value) const {
-       switch(index) {
-               case SK_PROPERTY(random): {
-                       SkScalar random = fRandom.nextUScalar1();
-                       SkScalar relativeT = SkInterpolatorBase::Blend(random, blend);
-                       value->fOperand.fScalar = min + SkScalarMul(max - min, relativeT);
-                       value->fType = SkType_Float;
-                       return true;
-               }
-               default:
-                       SkASSERT(0);
-       }
-       return false;
+    switch(index) {
+        case SK_PROPERTY(random): {
+            SkScalar random = fRandom.nextUScalar1();
+            SkScalar relativeT = SkUnitCubicInterp(random, SK_Scalar1 - blend, 0, 0, SK_Scalar1 - blend);
+            value->fOperand.fScalar = min + SkScalarMul(max - min, relativeT);
+            value->fType = SkType_Float;
+            return true;
+        }
+        default:
+            SkASSERT(0);
+    }
+    return false;
 }
 
 bool SkDisplayRandom::setProperty(int index, SkScriptValue& value) {
-       SkASSERT(index == SK_PROPERTY(seed));
-       SkASSERT(value.fType == SkType_Int);
-       fRandom.setSeed(value.fOperand.fS32);
-       return true;
+    SkASSERT(index == SK_PROPERTY(seed));
+    SkASSERT(value.fType == SkType_Int);
+    fRandom.setSeed(value.fOperand.fS32);
+    return true;
 }
 
index bcfc945..73f490b 100644 (file)
@@ -1,3 +1,20 @@
+/* libs/graphics/animator/SkDisplayRandom.h
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #ifndef SkDisplayRandom_DEFINED
 #define SkDisplayRandom_DEFINED
 
 #endif
 
 class SkDisplayRandom : public SkDisplayable {
-       DECLARE_DISPLAY_MEMBER_INFO(Random);
-       SkDisplayRandom();
+    DECLARE_DISPLAY_MEMBER_INFO(Random);
+    SkDisplayRandom();
 #ifdef SK_DUMP_ENABLED
     virtual void dump(SkAnimateMaker* );
 #endif
-       virtual bool getProperty(int index, SkScriptValue* value) const;
-       virtual bool setProperty(int index, SkScriptValue& );
+    virtual bool getProperty(int index, SkScriptValue* value) const;
+    virtual bool setProperty(int index, SkScriptValue& );
 private:
-       SkScalar blend;
-       SkScalar min;
-       SkScalar max;
-       mutable SkRandom fRandom;
+    SkScalar blend;
+    SkScalar min;
+    SkScalar max;
+    mutable SkRandom fRandom;
 };
 
 #endif // SkDisplayRandom_DEFINED
index 44c7a89..7591a13 100644 (file)
@@ -1,9 +1,26 @@
+/* libs/graphics/animator/SkDisplayScreenplay.cpp
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #include "SkDisplayScreenplay.h"
 
 #if SK_USE_CONDENSED_INFO == 0
 
 const SkMemberInfo SkDisplayScreenplay::fInfo[] = {
-       SK_MEMBER(time, MSec)
+    SK_MEMBER(time, MSec)
 };
 
 #endif
index 6d11f7a..3a7200d 100644 (file)
@@ -1,3 +1,20 @@
+/* libs/graphics/animator/SkDisplayScreenplay.h
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #ifndef SkDisplayScreenplay_DEFINED
 #define SkDisplayScreenplay_DEFINED
 
@@ -5,8 +22,8 @@
 #include "SkMemberInfo.h"
 
 class SkDisplayScreenplay : public SkDisplayable {
-       DECLARE_DISPLAY_MEMBER_INFO(Screenplay);
-       SkMSec time;
+    DECLARE_DISPLAY_MEMBER_INFO(Screenplay);
+    SkMSec time;
 };
 
 #endif // SkDisplayScreenplay_DEFINED
index dfb536f..0ecbfb4 100644 (file)
@@ -1,3 +1,20 @@
+/* libs/graphics/animator/SkDisplayType.cpp
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #include "SkDisplayType.h"
 #include "SkAnimateMaker.h"
 #include "SkAnimateSet.h"
 #include "SkTSearch.h"
 
 #define CASE_NEW(_class) \
-       case SkType_##_class: result = new Sk##_class(); break
+    case SkType_##_class: result = new Sk##_class(); break
 #define CASE_DRAW_NEW(_class) \
-       case SkType_##_class: result = new SkDraw##_class(); break
+    case SkType_##_class: result = new SkDraw##_class(); break
 #define CASE_DISPLAY_NEW(_class) \
-       case SkType_##_class: result = new SkDisplay##_class(); break
+    case SkType_##_class: result = new SkDisplay##_class(); break
 #ifdef SK_DEBUG
-       #define CASE_DEBUG_RETURN_NIL(_class) \
-               case SkType_##_class: return NULL
+    #define CASE_DEBUG_RETURN_NIL(_class) \
+        case SkType_##_class: return NULL
 #else
-       #define CASE_DEBUG_RETURN_NIL(_class)
+    #define CASE_DEBUG_RETURN_NIL(_class)
 #endif
-       
+    
 
 SkDisplayTypes SkDisplayType::gNewTypes = kNumberOfTypes;
 
 SkDisplayable* SkDisplayType::CreateInstance(SkAnimateMaker* maker, SkDisplayTypes type) {
-       SkDisplayable* result = NULL;
-       switch (type) {
-               // unknown
-               CASE_DISPLAY_NEW(Math);
-               CASE_DISPLAY_NEW(Number);
-               CASE_NEW(Add);
-               CASE_NEW(AddCircle);
-               // addgeom
-               CASE_DEBUG_RETURN_NIL(AddMode);
-               CASE_NEW(AddOval);
-               CASE_NEW(AddPath);
-               CASE_NEW(AddRect);
-               CASE_NEW(AddRoundRect);
-               CASE_DEBUG_RETURN_NIL(Align);
-               CASE_NEW(Animate);
-               // animatebase
-               CASE_NEW(Apply);
-               CASE_DEBUG_RETURN_NIL(ApplyMode);
-               CASE_DEBUG_RETURN_NIL(ApplyTransition);
-               CASE_DISPLAY_NEW(Array);
-               // argb
-               // base64
-               // basebitmap
-               // baseclassinfo
-               CASE_DRAW_NEW(Bitmap);
-               // bitmapencoding
-               // bitmapformat
-               CASE_DRAW_NEW(BitmapShader);
-               CASE_DRAW_NEW(Blur);
-               CASE_DISPLAY_NEW(Boolean);
-               // boundable
-               CASE_DISPLAY_NEW(Bounds);
-               CASE_DEBUG_RETURN_NIL(Cap);
-               CASE_NEW(Clear);
-               CASE_DRAW_NEW(Clip);
-               CASE_NEW(Close);
-               CASE_DRAW_NEW(Color);
-               CASE_NEW(CubicTo);
-               CASE_NEW(Dash);
-               CASE_NEW(Data);
-               CASE_NEW(Discrete);
-               // displayable
-               // drawable
-               CASE_NEW(DrawTo);
-               CASE_NEW(Dump);
-               // dynamicstring
-               CASE_DRAW_NEW(Emboss);
-               CASE_DISPLAY_NEW(Event);
-               CASE_DEBUG_RETURN_NIL(EventCode);
-               CASE_DEBUG_RETURN_NIL(EventKind);
-               CASE_DEBUG_RETURN_NIL(EventMode);
-               // filltype
-               // filtertype
-               CASE_DISPLAY_NEW(Float);
-               CASE_NEW(FromPath);
-               CASE_DEBUG_RETURN_NIL(FromPathMode);
-               CASE_NEW(Full);
-               // gradient
-               CASE_NEW(Group);
-               CASE_NEW(HitClear);
-               CASE_NEW(HitTest);
-               CASE_NEW(Image);
-               CASE_NEW(Include);
-               CASE_NEW(Input);
-               CASE_DISPLAY_NEW(Int);
-               CASE_DEBUG_RETURN_NIL(Join);
-               CASE_NEW(Line);
-               CASE_NEW(LineTo);
-               CASE_NEW(LinearGradient);
-               CASE_DRAW_NEW(MaskFilter);
-               CASE_DEBUG_RETURN_NIL(MaskFilterBlurStyle);
-               // maskfilterlight
-               CASE_DRAW_NEW(Matrix);
-               // memberfunction
-               // memberproperty
-               CASE_NEW(Move);
-               CASE_NEW(MoveTo);
-               CASE_DISPLAY_NEW(Movie);
-               // msec
-               CASE_NEW(Oval);
-               CASE_DRAW_NEW(Paint);
-               CASE_DRAW_NEW(Path);
-               // pathdirection
-               CASE_DRAW_NEW(PathEffect);
-               // point
-               CASE_NEW(DrawPoint);
-               CASE_NEW(PolyToPoly);
-               CASE_NEW(Polygon);
-               CASE_NEW(Polyline);
-               CASE_NEW(Post);
-               CASE_NEW(QuadTo);
-               CASE_NEW(RCubicTo);
-               CASE_NEW(RLineTo);
-               CASE_NEW(RMoveTo);
-               CASE_NEW(RQuadTo);
-               CASE_NEW(RadialGradient);
-               CASE_DISPLAY_NEW(Random);
-               CASE_DRAW_NEW(Rect);
-               CASE_NEW(RectToRect);
-               CASE_NEW(Remove);
-               CASE_NEW(Replace);
-               CASE_NEW(Rotate);
-               CASE_NEW(RoundRect);
-               CASE_NEW(Save);
+    SkDisplayable* result = NULL;
+    switch (type) {
+        // unknown
+        CASE_DISPLAY_NEW(Math);
+        CASE_DISPLAY_NEW(Number);
+        CASE_NEW(Add);
+        CASE_NEW(AddCircle);
+        // addgeom
+        CASE_DEBUG_RETURN_NIL(AddMode);
+        CASE_NEW(AddOval);
+        CASE_NEW(AddPath);
+        CASE_NEW(AddRect);
+        CASE_NEW(AddRoundRect);
+        CASE_DEBUG_RETURN_NIL(Align);
+        CASE_NEW(Animate);
+        // animatebase
+        CASE_NEW(Apply);
+        CASE_DEBUG_RETURN_NIL(ApplyMode);
+        CASE_DEBUG_RETURN_NIL(ApplyTransition);
+        CASE_DISPLAY_NEW(Array);
+        // argb
+        // base64
+        // basebitmap
+        // baseclassinfo
+        CASE_DRAW_NEW(Bitmap);
+        // bitmapencoding
+        // bitmapformat
+        CASE_DRAW_NEW(BitmapShader);
+        CASE_DRAW_NEW(Blur);
+        CASE_DISPLAY_NEW(Boolean);
+        // boundable
+        CASE_DISPLAY_NEW(Bounds);
+        CASE_DEBUG_RETURN_NIL(Cap);
+        CASE_NEW(Clear);
+        CASE_DRAW_NEW(Clip);
+        CASE_NEW(Close);
+        CASE_DRAW_NEW(Color);
+        CASE_NEW(CubicTo);
+        CASE_NEW(Dash);
+        CASE_NEW(Data);
+        CASE_NEW(Discrete);
+        // displayable
+        // drawable
+        CASE_NEW(DrawTo);
+        CASE_NEW(Dump);
+        // dynamicstring
+        CASE_DRAW_NEW(Emboss);
+        CASE_DISPLAY_NEW(Event);
+        CASE_DEBUG_RETURN_NIL(EventCode);
+        CASE_DEBUG_RETURN_NIL(EventKind);
+        CASE_DEBUG_RETURN_NIL(EventMode);
+        // filltype
+        // filtertype
+        CASE_DISPLAY_NEW(Float);
+        CASE_NEW(FromPath);
+        CASE_DEBUG_RETURN_NIL(FromPathMode);
+        CASE_NEW(Full);
+        // gradient
+        CASE_NEW(Group);
+        CASE_NEW(HitClear);
+        CASE_NEW(HitTest);
+        CASE_NEW(Image);
+        CASE_NEW(Include);
+        CASE_NEW(Input);
+        CASE_DISPLAY_NEW(Int);
+        CASE_DEBUG_RETURN_NIL(Join);
+        CASE_NEW(Line);
+        CASE_NEW(LineTo);
+        CASE_NEW(LinearGradient);
+        CASE_DRAW_NEW(MaskFilter);
+        CASE_DEBUG_RETURN_NIL(MaskFilterBlurStyle);
+        // maskfilterlight
+        CASE_DRAW_NEW(Matrix);
+        // memberfunction
+        // memberproperty
+        CASE_NEW(Move);
+        CASE_NEW(MoveTo);
+        CASE_DISPLAY_NEW(Movie);
+        // msec
+        CASE_NEW(Oval);
+        CASE_DRAW_NEW(Paint);
+        CASE_DRAW_NEW(Path);
+        // pathdirection
+        CASE_DRAW_NEW(PathEffect);
+        // point
+        CASE_NEW(DrawPoint);
+        CASE_NEW(PolyToPoly);
+        CASE_NEW(Polygon);
+        CASE_NEW(Polyline);
+        CASE_NEW(Post);
+        CASE_NEW(QuadTo);
+        CASE_NEW(RCubicTo);
+        CASE_NEW(RLineTo);
+        CASE_NEW(RMoveTo);
+        CASE_NEW(RQuadTo);
+        CASE_NEW(RadialGradient);
+        CASE_DISPLAY_NEW(Random);
+        CASE_DRAW_NEW(Rect);
+        CASE_NEW(RectToRect);
+        CASE_NEW(Remove);
+        CASE_NEW(Replace);
+        CASE_NEW(Rotate);
+        CASE_NEW(RoundRect);
+        CASE_NEW(Save);
         CASE_NEW(SaveLayer);
-               CASE_NEW(Scale);
-               // screenplay
-               CASE_NEW(Set);
-               CASE_DRAW_NEW(Shader);
-               CASE_NEW(Skew);
-               CASE_NEW(3D_Camera);
-               CASE_NEW(3D_Patch);
-               // 3dpoint
-               CASE_NEW(Snapshot);
-               CASE_DISPLAY_NEW(String);
-               // style
-               CASE_NEW(Text);
-               CASE_DRAW_NEW(TextBox);
-               // textboxalign
-               // textboxmode
-               CASE_NEW(TextOnPath);
-               CASE_NEW(TextToPath);
-               CASE_DEBUG_RETURN_NIL(TileMode);
-               CASE_NEW(Translate);
-               CASE_DRAW_NEW(TransparentShader);
-               CASE_DRAW_NEW(Typeface);
-               CASE_DEBUG_RETURN_NIL(Xfermode);
-               default:
-                       SkExtras** end = maker->fExtras.end();
-                       for (SkExtras** extraPtr = maker->fExtras.begin(); extraPtr < end; extraPtr++) {
-                               if ((result = (*extraPtr)->createInstance(type)) != NULL)
-                                       return result;
-                       }
-                       SkASSERT(0);
-       }
-       return result;
+        CASE_NEW(Scale);
+        // screenplay
+        CASE_NEW(Set);
+        CASE_DRAW_NEW(Shader);
+        CASE_NEW(Skew);
+        CASE_NEW(3D_Camera);
+        CASE_NEW(3D_Patch);
+        // 3dpoint
+        CASE_NEW(Snapshot);
+        CASE_DISPLAY_NEW(String);
+        // style
+        CASE_NEW(Text);
+        CASE_DRAW_NEW(TextBox);
+        // textboxalign
+        // textboxmode
+        CASE_NEW(TextOnPath);
+        CASE_NEW(TextToPath);
+        CASE_DEBUG_RETURN_NIL(TileMode);
+        CASE_NEW(Translate);
+        CASE_DRAW_NEW(TransparentShader);
+        CASE_DRAW_NEW(Typeface);
+        CASE_DEBUG_RETURN_NIL(Xfermode);
+        default:
+            SkExtras** end = maker->fExtras.end();
+            for (SkExtras** extraPtr = maker->fExtras.begin(); extraPtr < end; extraPtr++) {
+                if ((result = (*extraPtr)->createInstance(type)) != NULL)
+                    return result;
+            }
+            SkASSERT(0);
+    }
+    return result;
 }
 
 #undef CASE_NEW
@@ -208,166 +225,166 @@ SkDisplayable* SkDisplayType::CreateInstance(SkAnimateMaker* maker, SkDisplayTyp
 #if SK_USE_CONDENSED_INFO == 0
 
 #define CASE_GET_INFO(_class) case SkType_##_class: \
-       info = Sk##_class::fInfo; infoCount = Sk##_class::fInfoCount; break
+    info = Sk##_class::fInfo; infoCount = Sk##_class::fInfoCount; break
 #define CASE_GET_DRAW_INFO(_class) case SkType_##_class: \
-       info = SkDraw##_class::fInfo; infoCount = SkDraw##_class::fInfoCount; break
+    info = SkDraw##_class::fInfo; infoCount = SkDraw##_class::fInfoCount; break
 #define CASE_GET_DISPLAY_INFO(_class) case SkType_##_class: \
-       info = SkDisplay##_class::fInfo; infoCount = SkDisplay##_class::fInfoCount; \
-       break
+    info = SkDisplay##_class::fInfo; infoCount = SkDisplay##_class::fInfoCount; \
+    break
 
 const SkMemberInfo* SkDisplayType::GetMembers(SkAnimateMaker* maker, 
-               SkDisplayTypes type, int* infoCountPtr) {
-       const SkMemberInfo* info = NULL;
-       int infoCount = 0;
-       switch (type) {
-               // unknown
-               CASE_GET_DISPLAY_INFO(Math);
-               CASE_GET_DISPLAY_INFO(Number);
-               CASE_GET_INFO(Add);
-               CASE_GET_INFO(AddCircle);
-               CASE_GET_INFO(AddGeom);
-               // addmode
-               CASE_GET_INFO(AddOval);
-               CASE_GET_INFO(AddPath);
-               CASE_GET_INFO(AddRect);
-               CASE_GET_INFO(AddRoundRect);
-               // align
-               CASE_GET_INFO(Animate);
-               CASE_GET_INFO(AnimateBase);
-               CASE_GET_INFO(Apply);
-               // applymode
-               // applytransition
-               CASE_GET_DISPLAY_INFO(Array);
-               // argb
-               // base64
-               CASE_GET_INFO(BaseBitmap);
-               // baseclassinfo
-               CASE_GET_DRAW_INFO(Bitmap);
-               // bitmapencoding
-               // bitmapformat
-               CASE_GET_DRAW_INFO(BitmapShader);
-               CASE_GET_DRAW_INFO(Blur);
-               CASE_GET_DISPLAY_INFO(Boolean);
-               // boundable
-               CASE_GET_DISPLAY_INFO(Bounds);
-               // cap
-               // clear
-               CASE_GET_DRAW_INFO(Clip);
-               // close
-               CASE_GET_DRAW_INFO(Color);
-               CASE_GET_INFO(CubicTo);
-               CASE_GET_INFO(Dash);
-               CASE_GET_INFO(Data);
-               CASE_GET_INFO(Discrete);
-               // displayable
-               // drawable
-               CASE_GET_INFO(DrawTo);
-               CASE_GET_INFO(Dump);
-               // dynamicstring
-               CASE_GET_DRAW_INFO(Emboss);
-               CASE_GET_DISPLAY_INFO(Event);
-               // eventcode
-               // eventkind
-               // eventmode
-               // filltype
-               // filtertype
-               CASE_GET_DISPLAY_INFO(Float);
-               CASE_GET_INFO(FromPath);
-               // frompathmode
-               // full
-               CASE_GET_INFO(Gradient);
-               CASE_GET_INFO(Group);
-               CASE_GET_INFO(HitClear);
-               CASE_GET_INFO(HitTest);
-               CASE_GET_INFO(Image);
-               CASE_GET_INFO(Include);
-               CASE_GET_INFO(Input);
-               CASE_GET_DISPLAY_INFO(Int);
-               // join
-               CASE_GET_INFO(Line);
-               CASE_GET_INFO(LineTo);
-               CASE_GET_INFO(LinearGradient);
-               // maskfilter
-               // maskfilterblurstyle
-               // maskfilterlight
-               CASE_GET_DRAW_INFO(Matrix);
-               // memberfunction
-               // memberproperty
-               CASE_GET_INFO(Move);
-               CASE_GET_INFO(MoveTo);
-               CASE_GET_DISPLAY_INFO(Movie);
-               // msec
-               CASE_GET_INFO(Oval);
-               CASE_GET_DRAW_INFO(Path);
-               CASE_GET_DRAW_INFO(Paint);
-               // pathdirection
-               // patheffect
-               case SkType_Point: info = Sk_Point::fInfo; infoCount = Sk_Point::fInfoCount; break; // no virtual flavor
-               CASE_GET_INFO(DrawPoint); // virtual flavor
-               CASE_GET_INFO(PolyToPoly);
-               CASE_GET_INFO(Polygon);
-               CASE_GET_INFO(Polyline);
-               CASE_GET_INFO(Post);
-               CASE_GET_INFO(QuadTo);
-               CASE_GET_INFO(RCubicTo);
-               CASE_GET_INFO(RLineTo);
-               CASE_GET_INFO(RMoveTo);
-               CASE_GET_INFO(RQuadTo);
-               CASE_GET_INFO(RadialGradient);
-               CASE_GET_DISPLAY_INFO(Random);
-               CASE_GET_DRAW_INFO(Rect);
-               CASE_GET_INFO(RectToRect);
-               CASE_GET_INFO(Remove);
-               CASE_GET_INFO(Replace);
-               CASE_GET_INFO(Rotate);
-               CASE_GET_INFO(RoundRect);
-               CASE_GET_INFO(Save);
+        SkDisplayTypes type, int* infoCountPtr) {
+    const SkMemberInfo* info = NULL;
+    int infoCount = 0;
+    switch (type) {
+        // unknown
+        CASE_GET_DISPLAY_INFO(Math);
+        CASE_GET_DISPLAY_INFO(Number);
+        CASE_GET_INFO(Add);
+        CASE_GET_INFO(AddCircle);
+        CASE_GET_INFO(AddGeom);
+        // addmode
+        CASE_GET_INFO(AddOval);
+        CASE_GET_INFO(AddPath);
+        CASE_GET_INFO(AddRect);
+        CASE_GET_INFO(AddRoundRect);
+        // align
+        CASE_GET_INFO(Animate);
+        CASE_GET_INFO(AnimateBase);
+        CASE_GET_INFO(Apply);
+        // applymode
+        // applytransition
+        CASE_GET_DISPLAY_INFO(Array);
+        // argb
+        // base64
+        CASE_GET_INFO(BaseBitmap);
+        // baseclassinfo
+        CASE_GET_DRAW_INFO(Bitmap);
+        // bitmapencoding
+        // bitmapformat
+        CASE_GET_DRAW_INFO(BitmapShader);
+        CASE_GET_DRAW_INFO(Blur);
+        CASE_GET_DISPLAY_INFO(Boolean);
+        // boundable
+        CASE_GET_DISPLAY_INFO(Bounds);
+        // cap
+        // clear
+        CASE_GET_DRAW_INFO(Clip);
+        // close
+        CASE_GET_DRAW_INFO(Color);
+        CASE_GET_INFO(CubicTo);
+        CASE_GET_INFO(Dash);
+        CASE_GET_INFO(Data);
+        CASE_GET_INFO(Discrete);
+        // displayable
+        // drawable
+        CASE_GET_INFO(DrawTo);
+        CASE_GET_INFO(Dump);
+        // dynamicstring
+        CASE_GET_DRAW_INFO(Emboss);
+        CASE_GET_DISPLAY_INFO(Event);
+        // eventcode
+        // eventkind
+        // eventmode
+        // filltype
+        // filtertype
+        CASE_GET_DISPLAY_INFO(Float);
+        CASE_GET_INFO(FromPath);
+        // frompathmode
+        // full
+        CASE_GET_INFO(Gradient);
+        CASE_GET_INFO(Group);
+        CASE_GET_INFO(HitClear);
+        CASE_GET_INFO(HitTest);
+        CASE_GET_INFO(Image);
+        CASE_GET_INFO(Include);
+        CASE_GET_INFO(Input);
+        CASE_GET_DISPLAY_INFO(Int);
+        // join
+        CASE_GET_INFO(Line);
+        CASE_GET_INFO(LineTo);
+        CASE_GET_INFO(LinearGradient);
+        // maskfilter
+        // maskfilterblurstyle
+        // maskfilterlight
+        CASE_GET_DRAW_INFO(Matrix);
+        // memberfunction
+        // memberproperty
+        CASE_GET_INFO(Move);
+        CASE_GET_INFO(MoveTo);
+        CASE_GET_DISPLAY_INFO(Movie);
+        // msec
+        CASE_GET_INFO(Oval);
+        CASE_GET_DRAW_INFO(Path);
+        CASE_GET_DRAW_INFO(Paint);
+        // pathdirection
+        // patheffect
+        case SkType_Point: info = Sk_Point::fInfo; infoCount = Sk_Point::fInfoCount; break; // no virtual flavor
+        CASE_GET_INFO(DrawPoint); // virtual flavor
+        CASE_GET_INFO(PolyToPoly);
+        CASE_GET_INFO(Polygon);
+        CASE_GET_INFO(Polyline);
+        CASE_GET_INFO(Post);
+        CASE_GET_INFO(QuadTo);
+        CASE_GET_INFO(RCubicTo);
+        CASE_GET_INFO(RLineTo);
+        CASE_GET_INFO(RMoveTo);
+        CASE_GET_INFO(RQuadTo);
+        CASE_GET_INFO(RadialGradient);
+        CASE_GET_DISPLAY_INFO(Random);
+        CASE_GET_DRAW_INFO(Rect);
+        CASE_GET_INFO(RectToRect);
+        CASE_GET_INFO(Remove);
+        CASE_GET_INFO(Replace);
+        CASE_GET_INFO(Rotate);
+        CASE_GET_INFO(RoundRect);
+        CASE_GET_INFO(Save);
         CASE_GET_INFO(SaveLayer);
-               CASE_GET_INFO(Scale);
-               // screenplay
-               CASE_GET_INFO(Set);
-               CASE_GET_DRAW_INFO(Shader);
-               CASE_GET_INFO(Skew);
-               CASE_GET_INFO(3D_Camera);
-               CASE_GET_INFO(3D_Patch);
-               CASE_GET_INFO(3D_Point);
-               CASE_GET_INFO(Snapshot);
-               CASE_GET_DISPLAY_INFO(String);
-               // style
-               CASE_GET_INFO(Text);
-               CASE_GET_DRAW_INFO(TextBox);
-               // textboxalign
-               // textboxmode
-               CASE_GET_INFO(TextOnPath);
-               CASE_GET_INFO(TextToPath);
-               // tilemode
-               CASE_GET_INFO(Translate);
-               // transparentshader
-               CASE_GET_DRAW_INFO(Typeface);
-               // xfermode
-               // knumberoftypes
-               default: 
-                       if (maker) {
-                               SkExtras** end = maker->fExtras.end();
-                               for (SkExtras** extraPtr = maker->fExtras.begin(); extraPtr < end; extraPtr++) {
-                                       if ((info = (*extraPtr)->getMembers(type, infoCountPtr)) != NULL)
-                                               return info;
-                               }
-                       }
-                       return NULL;
-       }
-       if (infoCountPtr)
-               *infoCountPtr = infoCount;
-       return info;
+        CASE_GET_INFO(Scale);
+        // screenplay
+        CASE_GET_INFO(Set);
+        CASE_GET_DRAW_INFO(Shader);
+        CASE_GET_INFO(Skew);
+        CASE_GET_INFO(3D_Camera);
+        CASE_GET_INFO(3D_Patch);
+        CASE_GET_INFO(3D_Point);
+        CASE_GET_INFO(Snapshot);
+        CASE_GET_DISPLAY_INFO(String);
+        // style
+        CASE_GET_INFO(Text);
+        CASE_GET_DRAW_INFO(TextBox);
+        // textboxalign
+        // textboxmode
+        CASE_GET_INFO(TextOnPath);
+        CASE_GET_INFO(TextToPath);
+        // tilemode
+        CASE_GET_INFO(Translate);
+        // transparentshader
+        CASE_GET_DRAW_INFO(Typeface);
+        // xfermode
+        // knumberoftypes
+        default: 
+            if (maker) {
+                SkExtras** end = maker->fExtras.end();
+                for (SkExtras** extraPtr = maker->fExtras.begin(); extraPtr < end; extraPtr++) {
+                    if ((info = (*extraPtr)->getMembers(type, infoCountPtr)) != NULL)
+                        return info;
+                }
+            }
+            return NULL;
+    }
+    if (infoCountPtr)
+        *infoCountPtr = infoCount;
+    return info;
 }
 
 const SkMemberInfo* SkDisplayType::GetMember(SkAnimateMaker* maker, 
-               SkDisplayTypes type, const char** matchPtr ) {
-       int infoCount;
-       const SkMemberInfo* info = GetMembers(maker, type, &infoCount);
-       info = SkMemberInfo::Find(info, infoCount, matchPtr);
-//     SkASSERT(info);
-       return info;
+        SkDisplayTypes type, const char** matchPtr ) {
+    int infoCount;
+    const SkMemberInfo* info = GetMembers(maker, type, &infoCount);
+    info = SkMemberInfo::Find(info, infoCount, matchPtr);
+//  SkASSERT(info);
+    return info;
 }
 
 #undef CASE_GET_INFO
@@ -377,381 +394,381 @@ const SkMemberInfo* SkDisplayType::GetMember(SkAnimateMaker* maker,
 #endif // SK_USE_CONDENSED_INFO == 0
 
 #if defined SK_DEBUG || defined SK_BUILD_CONDENSED
-       #define DRAW_NAME(_name, _type) {_name, _type, true, false }
-       #define DISPLAY_NAME(_name, _type) {_name, _type, false, true }
+    #define DRAW_NAME(_name, _type) {_name, _type, true, false }
+    #define DISPLAY_NAME(_name, _type) {_name, _type, false, true }
     #define INIT_BOOL_FIELDS    , false, false
 #else
-       #define DRAW_NAME(_name, _type) {_name, _type }
-       #define DISPLAY_NAME(_name, _type) {_name, _type }
+    #define DRAW_NAME(_name, _type) {_name, _type }
+    #define DISPLAY_NAME(_name, _type) {_name, _type }
     #define INIT_BOOL_FIELDS
 #endif
 
 const TypeNames gTypeNames[] = {
-       // unknown
-       { "Math", SkType_Math                       INIT_BOOL_FIELDS },
-       { "Number", SkType_Number                   INIT_BOOL_FIELDS },
-       { "add", SkType_Add                         INIT_BOOL_FIELDS },
-       { "addCircle", SkType_AddCircle             INIT_BOOL_FIELDS },
-       // addgeom
-       // addmode
-       { "addOval", SkType_AddOval                 INIT_BOOL_FIELDS },
-       { "addPath", SkType_AddPath                 INIT_BOOL_FIELDS },
-       { "addRect", SkType_AddRect                 INIT_BOOL_FIELDS },
-       { "addRoundRect", SkType_AddRoundRect       INIT_BOOL_FIELDS },
-       // align
-       { "animate", SkType_Animate                 INIT_BOOL_FIELDS },
-       // animateBase
-       { "apply", SkType_Apply                     INIT_BOOL_FIELDS },
-       // applymode
-       // applytransition
-       { "array", SkType_Array                     INIT_BOOL_FIELDS },
-       // argb
-       // base64
-       // basebitmap
-       // baseclassinfo
-       DRAW_NAME("bitmap", SkType_Bitmap),
-       // bitmapencoding
-       // bitmapformat
-       DRAW_NAME("bitmapShader", SkType_BitmapShader),
-       DRAW_NAME("blur", SkType_Blur),
-       { "boolean", SkType_Boolean                 INIT_BOOL_FIELDS },
-       // boundable
-       DISPLAY_NAME("bounds", SkType_Bounds),
-       // cap
-       { "clear", SkType_Clear                     INIT_BOOL_FIELDS },
-       DRAW_NAME("clip", SkType_Clip),
-       { "close", SkType_Close                     INIT_BOOL_FIELDS },
-       DRAW_NAME("color", SkType_Color),
-       { "cubicTo", SkType_CubicTo                 INIT_BOOL_FIELDS },
-       { "dash", SkType_Dash                       INIT_BOOL_FIELDS },
-       { "data", SkType_Data                       INIT_BOOL_FIELDS },
-       { "discrete", SkType_Discrete               INIT_BOOL_FIELDS },
-       // displayable
-       // drawable
-       { "drawTo", SkType_DrawTo                   INIT_BOOL_FIELDS },
-       { "dump", SkType_Dump                       INIT_BOOL_FIELDS },
-       // dynamicstring
-       DRAW_NAME("emboss", SkType_Emboss),
-       DISPLAY_NAME("event", SkType_Event),
-       // eventcode
-       // eventkind
-       // eventmode
-       // filltype
-       // filtertype
-       { "float", SkType_Float                     INIT_BOOL_FIELDS },
-       { "fromPath", SkType_FromPath               INIT_BOOL_FIELDS },
-       // frompathmode
-       { "full", SkType_Full                       INIT_BOOL_FIELDS },
-       // gradient
-       { "group", SkType_Group                     INIT_BOOL_FIELDS },
-       { "hitClear", SkType_HitClear               INIT_BOOL_FIELDS },
-       { "hitTest", SkType_HitTest                 INIT_BOOL_FIELDS },
-       { "image", SkType_Image                     INIT_BOOL_FIELDS },
-       { "include", SkType_Include                 INIT_BOOL_FIELDS },
-       { "input", SkType_Input                     INIT_BOOL_FIELDS },
-       { "int", SkType_Int                         INIT_BOOL_FIELDS },
-       // join
-       { "line", SkType_Line                       INIT_BOOL_FIELDS },
-       { "lineTo", SkType_LineTo                   INIT_BOOL_FIELDS },
-       { "linearGradient", SkType_LinearGradient   INIT_BOOL_FIELDS },
-       { "maskFilter", SkType_MaskFilter           INIT_BOOL_FIELDS },
-       // maskfilterblurstyle
-       // maskfilterlight
-       DRAW_NAME("matrix", SkType_Matrix),
-       // memberfunction
-       // memberproperty
-       { "move", SkType_Move                       INIT_BOOL_FIELDS },
-       { "moveTo", SkType_MoveTo                   INIT_BOOL_FIELDS },
-       { "movie", SkType_Movie                     INIT_BOOL_FIELDS },
-       // msec
-       { "oval", SkType_Oval                       INIT_BOOL_FIELDS },
-       DRAW_NAME("paint", SkType_Paint),
-       DRAW_NAME("path", SkType_Path),
-       // pathdirection
-       { "pathEffect", SkType_PathEffect           INIT_BOOL_FIELDS },
-       // point
-       DRAW_NAME("point", SkType_DrawPoint),
-       { "polyToPoly", SkType_PolyToPoly           INIT_BOOL_FIELDS },
-       { "polygon", SkType_Polygon                 INIT_BOOL_FIELDS },
-       { "polyline", SkType_Polyline               INIT_BOOL_FIELDS },
-       { "post", SkType_Post                       INIT_BOOL_FIELDS },
-       { "quadTo", SkType_QuadTo                   INIT_BOOL_FIELDS },
-       { "rCubicTo", SkType_RCubicTo               INIT_BOOL_FIELDS },
-       { "rLineTo", SkType_RLineTo                 INIT_BOOL_FIELDS },
-       { "rMoveTo", SkType_RMoveTo                 INIT_BOOL_FIELDS },
-       { "rQuadTo", SkType_RQuadTo                 INIT_BOOL_FIELDS },
-       { "radialGradient", SkType_RadialGradient   INIT_BOOL_FIELDS },
-       DISPLAY_NAME("random", SkType_Random),
-       { "rect", SkType_Rect                       INIT_BOOL_FIELDS },
-       { "rectToRect", SkType_RectToRect           INIT_BOOL_FIELDS },
-       { "remove", SkType_Remove                   INIT_BOOL_FIELDS },
-       { "replace", SkType_Replace                 INIT_BOOL_FIELDS },
-       { "rotate", SkType_Rotate                   INIT_BOOL_FIELDS },
-       { "roundRect", SkType_RoundRect             INIT_BOOL_FIELDS },
-       { "save", SkType_Save                       INIT_BOOL_FIELDS },
+    // unknown
+    { "Math", SkType_Math                       INIT_BOOL_FIELDS },
+    { "Number", SkType_Number                   INIT_BOOL_FIELDS },
+    { "add", SkType_Add                         INIT_BOOL_FIELDS },
+    { "addCircle", SkType_AddCircle             INIT_BOOL_FIELDS },
+    // addgeom
+    // addmode
+    { "addOval", SkType_AddOval                 INIT_BOOL_FIELDS },
+    { "addPath", SkType_AddPath                 INIT_BOOL_FIELDS },
+    { "addRect", SkType_AddRect                 INIT_BOOL_FIELDS },
+    { "addRoundRect", SkType_AddRoundRect       INIT_BOOL_FIELDS },
+    // align
+    { "animate", SkType_Animate                 INIT_BOOL_FIELDS },
+    // animateBase
+    { "apply", SkType_Apply                     INIT_BOOL_FIELDS },
+    // applymode
+    // applytransition
+    { "array", SkType_Array                     INIT_BOOL_FIELDS },
+    // argb
+    // base64
+    // basebitmap
+    // baseclassinfo
+    DRAW_NAME("bitmap", SkType_Bitmap),
+    // bitmapencoding
+    // bitmapformat
+    DRAW_NAME("bitmapShader", SkType_BitmapShader),
+    DRAW_NAME("blur", SkType_Blur),
+    { "boolean", SkType_Boolean                 INIT_BOOL_FIELDS },
+    // boundable
+    DISPLAY_NAME("bounds", SkType_Bounds),
+    // cap
+    { "clear", SkType_Clear                     INIT_BOOL_FIELDS },
+    DRAW_NAME("clip", SkType_Clip),
+    { "close", SkType_Close                     INIT_BOOL_FIELDS },
+    DRAW_NAME("color", SkType_Color),
+    { "cubicTo", SkType_CubicTo                 INIT_BOOL_FIELDS },
+    { "dash", SkType_Dash                       INIT_BOOL_FIELDS },
+    { "data", SkType_Data                       INIT_BOOL_FIELDS },
+    { "discrete", SkType_Discrete               INIT_BOOL_FIELDS },
+    // displayable
+    // drawable
+    { "drawTo", SkType_DrawTo                   INIT_BOOL_FIELDS },
+    { "dump", SkType_Dump                       INIT_BOOL_FIELDS },
+    // dynamicstring
+    DRAW_NAME("emboss", SkType_Emboss),
+    DISPLAY_NAME("event", SkType_Event),
+    // eventcode
+    // eventkind
+    // eventmode
+    // filltype
+    // filtertype
+    { "float", SkType_Float                     INIT_BOOL_FIELDS },
+    { "fromPath", SkType_FromPath               INIT_BOOL_FIELDS },
+    // frompathmode
+    { "full", SkType_Full                       INIT_BOOL_FIELDS },
+    // gradient
+    { "group", SkType_Group                     INIT_BOOL_FIELDS },
+    { "hitClear", SkType_HitClear               INIT_BOOL_FIELDS },
+    { "hitTest", SkType_HitTest                 INIT_BOOL_FIELDS },
+    { "image", SkType_Image                     INIT_BOOL_FIELDS },
+    { "include", SkType_Include                 INIT_BOOL_FIELDS },
+    { "input", SkType_Input                     INIT_BOOL_FIELDS },
+    { "int", SkType_Int                         INIT_BOOL_FIELDS },
+    // join
+    { "line", SkType_Line                       INIT_BOOL_FIELDS },
+    { "lineTo", SkType_LineTo                   INIT_BOOL_FIELDS },
+    { "linearGradient", SkType_LinearGradient   INIT_BOOL_FIELDS },
+    { "maskFilter", SkType_MaskFilter           INIT_BOOL_FIELDS },
+    // maskfilterblurstyle
+    // maskfilterlight
+    DRAW_NAME("matrix", SkType_Matrix),
+    // memberfunction
+    // memberproperty
+    { "move", SkType_Move                       INIT_BOOL_FIELDS },
+    { "moveTo", SkType_MoveTo                   INIT_BOOL_FIELDS },
+    { "movie", SkType_Movie                     INIT_BOOL_FIELDS },
+    // msec
+    { "oval", SkType_Oval                       INIT_BOOL_FIELDS },
+    DRAW_NAME("paint", SkType_Paint),
+    DRAW_NAME("path", SkType_Path),
+    // pathdirection
+    { "pathEffect", SkType_PathEffect           INIT_BOOL_FIELDS },
+    // point
+    DRAW_NAME("point", SkType_DrawPoint),
+    { "polyToPoly", SkType_PolyToPoly           INIT_BOOL_FIELDS },
+    { "polygon", SkType_Polygon                 INIT_BOOL_FIELDS },
+    { "polyline", SkType_Polyline               INIT_BOOL_FIELDS },
+    { "post", SkType_Post                       INIT_BOOL_FIELDS },
+    { "quadTo", SkType_QuadTo                   INIT_BOOL_FIELDS },
+    { "rCubicTo", SkType_RCubicTo               INIT_BOOL_FIELDS },
+    { "rLineTo", SkType_RLineTo                 INIT_BOOL_FIELDS },
+    { "rMoveTo", SkType_RMoveTo                 INIT_BOOL_FIELDS },
+    { "rQuadTo", SkType_RQuadTo                 INIT_BOOL_FIELDS },
+    { "radialGradient", SkType_RadialGradient   INIT_BOOL_FIELDS },
+    DISPLAY_NAME("random", SkType_Random),
+    { "rect", SkType_Rect                       INIT_BOOL_FIELDS },
+    { "rectToRect", SkType_RectToRect           INIT_BOOL_FIELDS },
+    { "remove", SkType_Remove                   INIT_BOOL_FIELDS },
+    { "replace", SkType_Replace                 INIT_BOOL_FIELDS },
+    { "rotate", SkType_Rotate                   INIT_BOOL_FIELDS },
+    { "roundRect", SkType_RoundRect             INIT_BOOL_FIELDS },
+    { "save", SkType_Save                       INIT_BOOL_FIELDS },
     { "saveLayer", SkType_SaveLayer             INIT_BOOL_FIELDS },
-       { "scale", SkType_Scale                     INIT_BOOL_FIELDS },
-       // screenplay
-       { "set", SkType_Set                         INIT_BOOL_FIELDS },
-       { "shader", SkType_Shader                   INIT_BOOL_FIELDS },
-       { "skew", SkType_Skew                       INIT_BOOL_FIELDS },
-       { "skia3d:camera", SkType_3D_Camera         INIT_BOOL_FIELDS },
-       { "skia3d:patch", SkType_3D_Patch           INIT_BOOL_FIELDS },
-       // point
-       { "snapshot", SkType_Snapshot               INIT_BOOL_FIELDS },
-       { "string", SkType_String                   INIT_BOOL_FIELDS },
-       // style
-       { "text", SkType_Text                       INIT_BOOL_FIELDS },
-       { "textBox", SkType_TextBox                 INIT_BOOL_FIELDS },
-       // textboxalign
-       // textboxmode
-       { "textOnPath", SkType_TextOnPath           INIT_BOOL_FIELDS },
-       { "textToPath", SkType_TextToPath           INIT_BOOL_FIELDS },
-       // tilemode
-       { "translate", SkType_Translate             INIT_BOOL_FIELDS },
-       DRAW_NAME("transparentShader", SkType_TransparentShader),
-       { "typeface", SkType_Typeface               INIT_BOOL_FIELDS }
-       // xfermode
-       // knumberoftypes
+    { "scale", SkType_Scale                     INIT_BOOL_FIELDS },
+    // screenplay
+    { "set", SkType_Set                         INIT_BOOL_FIELDS },
+    { "shader", SkType_Shader                   INIT_BOOL_FIELDS },
+    { "skew", SkType_Skew                       INIT_BOOL_FIELDS },
+    { "skia3d:camera", SkType_3D_Camera         INIT_BOOL_FIELDS },
+    { "skia3d:patch", SkType_3D_Patch           INIT_BOOL_FIELDS },
+    // point
+    { "snapshot", SkType_Snapshot               INIT_BOOL_FIELDS },
+    { "string", SkType_String                   INIT_BOOL_FIELDS },
+    // style
+    { "text", SkType_Text                       INIT_BOOL_FIELDS },
+    { "textBox", SkType_TextBox                 INIT_BOOL_FIELDS },
+    // textboxalign
+    // textboxmode
+    { "textOnPath", SkType_TextOnPath           INIT_BOOL_FIELDS },
+    { "textToPath", SkType_TextToPath           INIT_BOOL_FIELDS },
+    // tilemode
+    { "translate", SkType_Translate             INIT_BOOL_FIELDS },
+    DRAW_NAME("transparentShader", SkType_TransparentShader),
+    { "typeface", SkType_Typeface               INIT_BOOL_FIELDS }
+    // xfermode
+    // knumberoftypes
 };
 
 const int kTypeNamesSize = SK_ARRAY_COUNT(gTypeNames);
 
 SkDisplayTypes SkDisplayType::Find(SkAnimateMaker* maker, const SkMemberInfo* match) {
-       for (int index = 0; index < kTypeNamesSize; index++) {
-               SkDisplayTypes type = gTypeNames[index].fType;
-               const SkMemberInfo* info = SkDisplayType::GetMembers(maker, type, NULL);
-               if (info == match)
-                       return type;
-       }
-       return (SkDisplayTypes) -1;
+    for (int index = 0; index < kTypeNamesSize; index++) {
+        SkDisplayTypes type = gTypeNames[index].fType;
+        const SkMemberInfo* info = SkDisplayType::GetMembers(maker, type, NULL);
+        if (info == match)
+            return type;
+    }
+    return (SkDisplayTypes) -1;
 }
 
 // !!! optimize this by replacing function with a byte-sized lookup table
 SkDisplayTypes SkDisplayType::GetParent(SkAnimateMaker* maker, SkDisplayTypes base) {
-       if (base == SkType_Group || base == SkType_Save || base == SkType_SaveLayer)            //!!! cheat a little until we have a lookup table
-               return SkType_Displayable;
-       if (base == SkType_Set)
-               return SkType_Animate;  // another cheat until we have a lookup table
-       const SkMemberInfo* info = GetMembers(maker, base, NULL); // get info for this type
-       SkASSERT(info);
-       if (info->fType != SkType_BaseClassInfo)
-               return SkType_Unknown; // if no base, done
-       // !!! could change SK_MEMBER_INHERITED macro to take type, stuff in offset, so that 
-       // this (and table builder) could know type without the following steps:
-       const SkMemberInfo* inherited = info->getInherited();
-       SkDisplayTypes result = (SkDisplayTypes) (SkType_Unknown + 1);
-       for (; result <= SkType_Xfermode; result = (SkDisplayTypes) (result + 1)) {
-               const SkMemberInfo* match = GetMembers(maker, result, NULL);
-               if (match == inherited)
-                       break;
-       }
-       SkASSERT(result <= SkType_Xfermode);
-       return result;
+    if (base == SkType_Group || base == SkType_Save || base == SkType_SaveLayer)        //!!! cheat a little until we have a lookup table
+        return SkType_Displayable;
+    if (base == SkType_Set)
+        return SkType_Animate;  // another cheat until we have a lookup table
+    const SkMemberInfo* info = GetMembers(maker, base, NULL); // get info for this type
+    SkASSERT(info);
+    if (info->fType != SkType_BaseClassInfo)
+        return SkType_Unknown; // if no base, done
+    // !!! could change SK_MEMBER_INHERITED macro to take type, stuff in offset, so that 
+    // this (and table builder) could know type without the following steps:
+    const SkMemberInfo* inherited = info->getInherited();
+    SkDisplayTypes result = (SkDisplayTypes) (SkType_Unknown + 1);
+    for (; result <= SkType_Xfermode; result = (SkDisplayTypes) (result + 1)) {
+        const SkMemberInfo* match = GetMembers(maker, result, NULL);
+        if (match == inherited)
+            break;
+    }
+    SkASSERT(result <= SkType_Xfermode);
+    return result;
 }
 
 SkDisplayTypes SkDisplayType::GetType(SkAnimateMaker* maker, const char match[], size_t len ) {
-       int index = SkStrSearch(&gTypeNames[0].fName, kTypeNamesSize, match, 
-               len, sizeof(gTypeNames[0]));
-       if (index >= 0 && index < kTypeNamesSize)
-               return gTypeNames[index].fType;
-       SkExtras** end = maker->fExtras.end();
-       for (SkExtras** extraPtr = maker->fExtras.begin(); extraPtr < end; extraPtr++) {
-               SkDisplayTypes result = (*extraPtr)->getType(match, len);
-               if (result != SkType_Unknown)
-                       return result;
-       }
-       return (SkDisplayTypes) -1;
+    int index = SkStrSearch(&gTypeNames[0].fName, kTypeNamesSize, match, 
+        len, sizeof(gTypeNames[0]));
+    if (index >= 0 && index < kTypeNamesSize)
+        return gTypeNames[index].fType;
+    SkExtras** end = maker->fExtras.end();
+    for (SkExtras** extraPtr = maker->fExtras.begin(); extraPtr < end; extraPtr++) {
+        SkDisplayTypes result = (*extraPtr)->getType(match, len);
+        if (result != SkType_Unknown)
+            return result;
+    }
+    return (SkDisplayTypes) -1;
 }
 
 bool SkDisplayType::IsEnum(SkAnimateMaker* , SkDisplayTypes type) {
-       switch (type) {
-               case SkType_AddMode:
-               case SkType_Align:
-               case SkType_ApplyMode:
-               case SkType_ApplyTransition:
-               case SkType_BitmapEncoding:
-               case SkType_BitmapFormat:
-               case SkType_Boolean:
-               case SkType_Cap:
-               case SkType_EventCode:
-               case SkType_EventKind:
-               case SkType_EventMode:
-               case SkType_FillType:
-               case SkType_FilterType:
+    switch (type) {
+        case SkType_AddMode:
+        case SkType_Align:
+        case SkType_ApplyMode:
+        case SkType_ApplyTransition:
+        case SkType_BitmapEncoding:
+        case SkType_BitmapFormat:
+        case SkType_Boolean:
+        case SkType_Cap:
+        case SkType_EventCode:
+        case SkType_EventKind:
+        case SkType_EventMode:
+        case SkType_FillType:
+        case SkType_FilterType:
         case SkType_FontStyle:
-               case SkType_FromPathMode:
-               case SkType_Join:
-               case SkType_MaskFilterBlurStyle:
-               case SkType_PathDirection:
-               case SkType_Style:
-               case SkType_TextBoxAlign:
-               case SkType_TextBoxMode:
-               case SkType_TileMode:
-               case SkType_Xfermode:
-                       return true;
-               default:        // to avoid warnings
-                       break;
-       }
-       return false;
+        case SkType_FromPathMode:
+        case SkType_Join:
+        case SkType_MaskFilterBlurStyle:
+        case SkType_PathDirection:
+        case SkType_Style:
+        case SkType_TextBoxAlign:
+        case SkType_TextBoxMode:
+        case SkType_TileMode:
+        case SkType_Xfermode:
+            return true;
+        default:    // to avoid warnings
+            break;
+    }
+    return false;
 }
 
 bool SkDisplayType::IsDisplayable(SkAnimateMaker* , SkDisplayTypes type) {
-       switch (type) {
-               case SkType_Add:
-               case SkType_AddCircle:
-               case SkType_AddOval:
-               case SkType_AddPath:
-               case SkType_AddRect:
-               case SkType_AddRoundRect:
-               case SkType_Animate:
-               case SkType_AnimateBase:
-               case SkType_Apply:
-               case SkType_BaseBitmap:
-               case SkType_Bitmap:
-               case SkType_BitmapShader:
-               case SkType_Blur:
-               case SkType_Clear:
-               case SkType_Clip:
-               case SkType_Close:
-               case SkType_Color:
-               case SkType_CubicTo:
-               case SkType_Dash:
-               case SkType_Data:
-               case SkType_Discrete:
-               case SkType_Displayable:
-               case SkType_Drawable:
-               case SkType_DrawTo:
-               case SkType_Emboss:
-               case SkType_Event:
-               case SkType_FromPath:
-               case SkType_Full:
-               case SkType_Group:
-               case SkType_Image:
-               case SkType_Input:
-               case SkType_Line:
-               case SkType_LineTo:
-               case SkType_LinearGradient:
-               case SkType_Matrix:
-               case SkType_Move:
-               case SkType_MoveTo:
-               case SkType_Movie:
-               case SkType_Oval:
-               case SkType_Paint:
-               case SkType_Path:
-               case SkType_PolyToPoly:
-               case SkType_Polygon:
-               case SkType_Polyline:
-               case SkType_Post:
-               case SkType_QuadTo:
-               case SkType_RCubicTo:
-               case SkType_RLineTo:
-               case SkType_RMoveTo:
-               case SkType_RQuadTo:
-               case SkType_RadialGradient:
-               case SkType_Random:
-               case SkType_Rect:
-               case SkType_RectToRect:
-               case SkType_Remove:
-               case SkType_Replace:
-               case SkType_Rotate:
-               case SkType_RoundRect:
-               case SkType_Save:
+    switch (type) {
+        case SkType_Add:
+        case SkType_AddCircle:
+        case SkType_AddOval:
+        case SkType_AddPath:
+        case SkType_AddRect:
+        case SkType_AddRoundRect:
+        case SkType_Animate:
+        case SkType_AnimateBase:
+        case SkType_Apply:
+        case SkType_BaseBitmap:
+        case SkType_Bitmap:
+        case SkType_BitmapShader:
+        case SkType_Blur:
+        case SkType_Clear:
+        case SkType_Clip:
+        case SkType_Close:
+        case SkType_Color:
+        case SkType_CubicTo:
+        case SkType_Dash:
+        case SkType_Data:
+        case SkType_Discrete:
+        case SkType_Displayable:
+        case SkType_Drawable:
+        case SkType_DrawTo:
+        case SkType_Emboss:
+        case SkType_Event:
+        case SkType_FromPath:
+        case SkType_Full:
+        case SkType_Group:
+        case SkType_Image:
+        case SkType_Input:
+        case SkType_Line:
+        case SkType_LineTo:
+        case SkType_LinearGradient:
+        case SkType_Matrix:
+        case SkType_Move:
+        case SkType_MoveTo:
+        case SkType_Movie:
+        case SkType_Oval:
+        case SkType_Paint:
+        case SkType_Path:
+        case SkType_PolyToPoly:
+        case SkType_Polygon:
+        case SkType_Polyline:
+        case SkType_Post:
+        case SkType_QuadTo:
+        case SkType_RCubicTo:
+        case SkType_RLineTo:
+        case SkType_RMoveTo:
+        case SkType_RQuadTo:
+        case SkType_RadialGradient:
+        case SkType_Random:
+        case SkType_Rect:
+        case SkType_RectToRect:
+        case SkType_Remove:
+        case SkType_Replace:
+        case SkType_Rotate:
+        case SkType_RoundRect:
+        case SkType_Save:
         case SkType_SaveLayer:
-               case SkType_Scale:
-               case SkType_Set:
-               case SkType_Shader:
-               case SkType_Skew:
-               case SkType_3D_Camera:
-               case SkType_3D_Patch:
-               case SkType_Snapshot:
-               case SkType_Text:
-               case SkType_TextBox:
-               case SkType_TextOnPath:
-               case SkType_TextToPath:
-               case SkType_Translate:
-               case SkType_TransparentShader:
-                       return true;
-               default:        // to avoid warnings
-                       break;
-       }
-       return false;
+        case SkType_Scale:
+        case SkType_Set:
+        case SkType_Shader:
+        case SkType_Skew:
+        case SkType_3D_Camera:
+        case SkType_3D_Patch:
+        case SkType_Snapshot:
+        case SkType_Text:
+        case SkType_TextBox:
+        case SkType_TextOnPath:
+        case SkType_TextToPath:
+        case SkType_Translate:
+        case SkType_TransparentShader:
+            return true;
+        default:    // to avoid warnings
+            break;
+    }
+    return false;
 }
 
 bool SkDisplayType::IsStruct(SkAnimateMaker* , SkDisplayTypes type) {
-       switch (type) {
-               case SkType_Point:
-               case SkType_3D_Point:
-                       return true;
-               default:        // to avoid warnings
-                       break;
-       }
-       return false;
+    switch (type) {
+        case SkType_Point:
+        case SkType_3D_Point:
+            return true;
+        default:    // to avoid warnings
+            break;
+    }
+    return false;
 }
 
 
 SkDisplayTypes SkDisplayType::RegisterNewType() {
-       gNewTypes = (SkDisplayTypes) (gNewTypes + 1);
-       return gNewTypes;
+    gNewTypes = (SkDisplayTypes) (gNewTypes + 1);
+    return gNewTypes;
 }
 
 
 
 #ifdef SK_DEBUG
 const char* SkDisplayType::GetName(SkAnimateMaker* maker, SkDisplayTypes type) {
-       for (int index = 0; index < kTypeNamesSize - 1; index++) {
-               if (gTypeNames[index].fType == type)
-                       return gTypeNames[index].fName;
-       }
-       SkExtras** end = maker->fExtras.end();
-       for (SkExtras** extraPtr = maker->fExtras.begin(); extraPtr < end; extraPtr++) {
-               const char* result = (*extraPtr)->getName(type);
-               if (result != NULL)
-                       return result;
-       }
-       return NULL;
+    for (int index = 0; index < kTypeNamesSize - 1; index++) {
+        if (gTypeNames[index].fType == type)
+            return gTypeNames[index].fName;
+    }
+    SkExtras** end = maker->fExtras.end();
+    for (SkExtras** extraPtr = maker->fExtras.begin(); extraPtr < end; extraPtr++) {
+        const char* result = (*extraPtr)->getName(type);
+        if (result != NULL)
+            return result;
+    }
+    return NULL;
 }
 #endif
 
 #ifdef SK_SUPPORT_UNITTEST
 void SkDisplayType::UnitTest() {
-       SkAnimator animator;
-       SkAnimateMaker* maker = animator.fMaker;
-       int index;
-       for (index = 0; index < kTypeNamesSize - 1; index++) {
-               SkASSERT(strcmp(gTypeNames[index].fName, gTypeNames[index + 1].fName) < 0);
-               SkASSERT(gTypeNames[index].fType < gTypeNames[index + 1].fType);
-       }
-       for (index = 0; index < kTypeNamesSize; index++) {
-               SkDisplayable* test = CreateInstance(maker, gTypeNames[index].fType);
-               if (test == NULL)
-                       continue;
-#if defined _WIN32 && _MSC_VER >= 1300 && defined _INC_CRTDBG // only on windows, only if using "crtdbg.h"
-       // we know that crtdbg puts 0xfdfdfdfd at the end of the block
-       // look for unitialized memory, signature 0xcdcdcdcd prior to that
-               int* start = (int*) test;
-               while (*start != 0xfdfdfdfd) {
-                       SkASSERT(*start != 0xcdcdcdcd);
-                       start++;
-               }
+    SkAnimator animator;
+    SkAnimateMaker* maker = animator.fMaker;
+    int index;
+    for (index = 0; index < kTypeNamesSize - 1; index++) {
+        SkASSERT(strcmp(gTypeNames[index].fName, gTypeNames[index + 1].fName) < 0);
+        SkASSERT(gTypeNames[index].fType < gTypeNames[index + 1].fType);
+    }
+    for (index = 0; index < kTypeNamesSize; index++) {
+        SkDisplayable* test = CreateInstance(maker, gTypeNames[index].fType);
+        if (test == NULL)
+            continue;
+#if defined _WIN32 && _MSC_VER >= 1300  && defined _INC_CRTDBG // only on windows, only if using "crtdbg.h"
+    // we know that crtdbg puts 0xfdfdfdfd at the end of the block
+    // look for unitialized memory, signature 0xcdcdcdcd prior to that
+        int* start = (int*) test;
+        while (*start != 0xfdfdfdfd) {
+            SkASSERT(*start != 0xcdcdcdcd);
+            start++;
+        }
 #endif
-               delete test;
-       }
-       for (index = 0; index < kTypeNamesSize; index++) {
-               int infoCount;
-               const SkMemberInfo* info = GetMembers(maker, gTypeNames[index].fType, &infoCount);
-               if (info == NULL)
-                       continue;
+        delete test;
+    }
+    for (index = 0; index < kTypeNamesSize; index++) {
+        int infoCount;
+        const SkMemberInfo* info = GetMembers(maker, gTypeNames[index].fType, &infoCount);
+        if (info == NULL)
+            continue;
 #if SK_USE_CONDENSED_INFO == 0
-               for (int inner = 0; inner < infoCount - 1; inner++) {
-                       if (info[inner].fType == SkType_BaseClassInfo)
-                               continue;
-                       SkASSERT(strcmp(info[inner].fName, info[inner + 1].fName) < 0);
-               }
+        for (int inner = 0; inner < infoCount - 1; inner++) {
+            if (info[inner].fType == SkType_BaseClassInfo)
+                continue;
+            SkASSERT(strcmp(info[inner].fName, info[inner + 1].fName) < 0);
+        }
 #endif
-       }
+    }
 #if defined SK_DEBUG || defined SK_BUILD_CONDENSED
-       BuildCondensedInfo(maker);
+    BuildCondensedInfo(maker);
 #endif
 }
 #endif
index d6c4a93..c6c0de9 100644 (file)
@@ -1,3 +1,20 @@
+/* libs/graphics/animator/SkDisplayType.h
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #ifndef SkDisplayType_DEFINED
 #define SkDisplayType_DEFINED
 
 #endif
 
 #define SK_LITERAL_STR_EQUAL(str, token, len) (sizeof(str) - 1 == len \
-       && strncmp(str, token, sizeof(str) - 1) == 0)
+    && strncmp(str, token, sizeof(str) - 1) == 0)
 
 class SkAnimateMaker;
 class SkDisplayable;
 struct SkMemberInfo;
 
 enum SkDisplayTypes {
-       SkType_Unknown,
-       SkType_Math, // for ecmascript compatible Math functions and constants
-       SkType_Number,  // for for ecmascript compatible Number functions and constants
-       SkType_Add,
-       SkType_AddCircle,
-       SkType_AddGeom,
-       SkType_AddMode,
-       SkType_AddOval,
-       SkType_AddPath,
-       SkType_AddRect, // path part
-       SkType_AddRoundRect,
-       SkType_Align,
-       SkType_Animate,
-       SkType_AnimateBase,     // base type for animate, set
-       SkType_Apply,
-       SkType_ApplyMode,
-       SkType_ApplyTransition,
-       SkType_Array,
-       SkType_ARGB,
-       SkType_Base64,
-       SkType_BaseBitmap,
-       SkType_BaseClassInfo,
-       SkType_Bitmap,
-       SkType_BitmapEncoding,
-       SkType_BitmapFormat,
-       SkType_BitmapShader,
-       SkType_Blur,
-       SkType_Boolean, // can have values -1 (uninitialized), 0, 1
-       SkType_Boundable,
-       SkType_Bounds,
-       SkType_Cap,
-       SkType_Clear,
-       SkType_Clip,
-       SkType_Close,
-       SkType_Color,
-       SkType_CubicTo,
-       SkType_Dash,
-       SkType_Data,
-       SkType_Discrete,
-       SkType_Displayable,
-       SkType_Drawable,
-       SkType_DrawTo,
-       SkType_Dump,
-       SkType_DynamicString,   // evaluate at draw time
-       SkType_Emboss,
-       SkType_Event,
-       SkType_EventCode,
-       SkType_EventKind,
-       SkType_EventMode,
-       SkType_FillType,
-       SkType_FilterType,
-       SkType_Float,
+    SkType_Unknown,
+    SkType_Math, // for ecmascript compatible Math functions and constants
+    SkType_Number,  // for for ecmascript compatible Number functions and constants
+    SkType_Add,
+    SkType_AddCircle,
+    SkType_AddGeom,
+    SkType_AddMode,
+    SkType_AddOval,
+    SkType_AddPath,
+    SkType_AddRect, // path part
+    SkType_AddRoundRect,
+    SkType_Align,
+    SkType_Animate,
+    SkType_AnimateBase, // base type for animate, set
+    SkType_Apply,
+    SkType_ApplyMode,
+    SkType_ApplyTransition,
+    SkType_Array,
+    SkType_ARGB,
+    SkType_Base64,
+    SkType_BaseBitmap,
+    SkType_BaseClassInfo,
+    SkType_Bitmap,
+    SkType_BitmapEncoding,
+    SkType_BitmapFormat,
+    SkType_BitmapShader,
+    SkType_Blur,
+    SkType_Boolean, // can have values -1 (uninitialized), 0, 1
+    SkType_Boundable,
+    SkType_Bounds,
+    SkType_Cap,
+    SkType_Clear,
+    SkType_Clip,
+    SkType_Close,
+    SkType_Color,
+    SkType_CubicTo,
+    SkType_Dash,
+    SkType_Data,
+    SkType_Discrete,
+    SkType_Displayable,
+    SkType_Drawable,
+    SkType_DrawTo,
+    SkType_Dump,
+    SkType_DynamicString,   // evaluate at draw time
+    SkType_Emboss,
+    SkType_Event,
+    SkType_EventCode,
+    SkType_EventKind,
+    SkType_EventMode,
+    SkType_FillType,
+    SkType_FilterType,
+    SkType_Float,
     SkType_FontStyle,
-       SkType_FromPath,
-       SkType_FromPathMode,
-       SkType_Full,
-       SkType_Gradient,
-       SkType_Group,
-       SkType_HitClear,
-       SkType_HitTest,
-       SkType_Image,
-       SkType_Include,
-       SkType_Input,
-       SkType_Int,
-       SkType_Join,
-       SkType_Line, // simple line primitive
-       SkType_LineTo, // used as part of path construction
-       SkType_LinearGradient,
-       SkType_MaskFilter,
-       SkType_MaskFilterBlurStyle,
-       SkType_MaskFilterLight,
-       SkType_Matrix,
-       SkType_MemberFunction,
-       SkType_MemberProperty,
-       SkType_Move,
-       SkType_MoveTo,
-       SkType_Movie,
-       SkType_MSec,
-       SkType_Oval,
-       SkType_Paint,
-       SkType_Path,
-       SkType_PathDirection,
-       SkType_PathEffect,
-       SkType_Point,   // used inside other structures, no vtable
-       SkType_DrawPoint, // used to draw points, has a vtable
-       SkType_PolyToPoly,
-       SkType_Polygon,
-       SkType_Polyline,
-       SkType_Post,
-       SkType_QuadTo,
-       SkType_RCubicTo,
-       SkType_RLineTo,
-       SkType_RMoveTo,
-       SkType_RQuadTo,
-       SkType_RadialGradient,
-       SkType_Random,
-       SkType_Rect,
-       SkType_RectToRect,
-       SkType_Remove,
-       SkType_Replace,
-       SkType_Rotate,
-       SkType_RoundRect,
-       SkType_Save,
+    SkType_FromPath,
+    SkType_FromPathMode,
+    SkType_Full,
+    SkType_Gradient,
+    SkType_Group,
+    SkType_HitClear,
+    SkType_HitTest,
+    SkType_Image,
+    SkType_Include,
+    SkType_Input,
+    SkType_Int,
+    SkType_Join,
+    SkType_Line, // simple line primitive
+    SkType_LineTo, // used as part of path construction
+    SkType_LinearGradient,
+    SkType_MaskFilter,
+    SkType_MaskFilterBlurStyle,
+    SkType_MaskFilterLight,
+    SkType_Matrix,
+    SkType_MemberFunction,
+    SkType_MemberProperty,
+    SkType_Move,
+    SkType_MoveTo,
+    SkType_Movie,
+    SkType_MSec,
+    SkType_Oval,
+    SkType_Paint,
+    SkType_Path,
+    SkType_PathDirection,
+    SkType_PathEffect,
+    SkType_Point,   // used inside other structures, no vtable
+    SkType_DrawPoint, // used to draw points, has a vtable
+    SkType_PolyToPoly,
+    SkType_Polygon,
+    SkType_Polyline,
+    SkType_Post,
+    SkType_QuadTo,
+    SkType_RCubicTo,
+    SkType_RLineTo,
+    SkType_RMoveTo,
+    SkType_RQuadTo,
+    SkType_RadialGradient,
+    SkType_Random,
+    SkType_Rect,
+    SkType_RectToRect,
+    SkType_Remove,
+    SkType_Replace,
+    SkType_Rotate,
+    SkType_RoundRect,
+    SkType_Save,
     SkType_SaveLayer,
-       SkType_Scale,
-       SkType_Screenplay,
-       SkType_Set,
-       SkType_Shader,
-       SkType_Skew,
-       SkType_3D_Camera,
-       SkType_3D_Patch,
-       SkType_3D_Point,
-       SkType_Snapshot,
-       SkType_String,  // pointer to SkString
-       SkType_Style,
-       SkType_Text,
-       SkType_TextBox,
-       SkType_TextBoxAlign,
-       SkType_TextBoxMode,
-       SkType_TextOnPath,
-       SkType_TextToPath,
-       SkType_TileMode,
-       SkType_Translate,
-       SkType_TransparentShader,
-       SkType_Typeface,
-       SkType_Xfermode,
-       kNumberOfTypes
+    SkType_Scale,
+    SkType_Screenplay,
+    SkType_Set,
+    SkType_Shader,
+    SkType_Skew,
+    SkType_3D_Camera,
+    SkType_3D_Patch,
+    SkType_3D_Point,
+    SkType_Snapshot,
+    SkType_String,  // pointer to SkString
+    SkType_Style,
+    SkType_Text,
+    SkType_TextBox,
+    SkType_TextBoxAlign,
+    SkType_TextBoxMode,
+    SkType_TextOnPath,
+    SkType_TextToPath,
+    SkType_TileMode,
+    SkType_Translate,
+    SkType_TransparentShader,
+    SkType_Typeface,
+    SkType_Xfermode,
+    kNumberOfTypes
 };
 
 struct TypeNames {
-       const char* fName;
-       SkDisplayTypes fType;
+    const char* fName;
+    SkDisplayTypes fType;
 #if defined SK_DEBUG || defined SK_BUILD_CONDENSED
-       bool fDrawPrefix;
-       bool fDisplayPrefix;
+    bool fDrawPrefix;
+    bool fDisplayPrefix;
 #endif
 };
 
@@ -169,30 +186,30 @@ extern const int kTypeNamesSize;
 
 class SkDisplayType {
 public:
-       static SkDisplayTypes Find(SkAnimateMaker* , const SkMemberInfo* );
-       static const SkMemberInfo* GetMember(SkAnimateMaker* , SkDisplayTypes , const char** );
-       static const SkMemberInfo* GetMembers(SkAnimateMaker* , SkDisplayTypes , int* infoCountPtr);
-       static SkDisplayTypes GetParent(SkAnimateMaker* , SkDisplayTypes );
-       static bool IsDisplayable(SkAnimateMaker* , SkDisplayTypes );
-       static bool IsEnum(SkAnimateMaker* , SkDisplayTypes );
-       static bool IsStruct(SkAnimateMaker* , SkDisplayTypes );
-       static SkDisplayTypes RegisterNewType();
-       static SkDisplayTypes Resolve(const char[] , const SkMemberInfo** );
+    static SkDisplayTypes Find(SkAnimateMaker* , const SkMemberInfo* );
+    static const SkMemberInfo* GetMember(SkAnimateMaker* , SkDisplayTypes , const char** );
+    static const SkMemberInfo* GetMembers(SkAnimateMaker* , SkDisplayTypes , int* infoCountPtr);
+    static SkDisplayTypes GetParent(SkAnimateMaker* , SkDisplayTypes );
+    static bool IsDisplayable(SkAnimateMaker* , SkDisplayTypes );
+    static bool IsEnum(SkAnimateMaker* , SkDisplayTypes );
+    static bool IsStruct(SkAnimateMaker* , SkDisplayTypes );
+    static SkDisplayTypes RegisterNewType();
+    static SkDisplayTypes Resolve(const char[] , const SkMemberInfo** );
 #ifdef SK_DEBUG
-       static bool IsAnimate(SkDisplayTypes type ) { return type == SkType_Animate || 
-               type == SkType_Set; }
-       static const char* GetName(SkAnimateMaker* , SkDisplayTypes );
+    static bool IsAnimate(SkDisplayTypes type ) { return type == SkType_Animate || 
+        type == SkType_Set; }
+    static const char* GetName(SkAnimateMaker* , SkDisplayTypes );
 #endif
 #ifdef SK_SUPPORT_UNITTEST
-       static void UnitTest();
+    static void UnitTest();
 #endif
 #if defined SK_DEBUG || defined SK_BUILD_CONDENSED
-       static void BuildCondensedInfo(SkAnimateMaker* );
+    static void BuildCondensedInfo(SkAnimateMaker* );
 #endif
-       static SkDisplayTypes GetType(SkAnimateMaker* , const char[] , size_t len);
-       static SkDisplayable* CreateInstance(SkAnimateMaker* , SkDisplayTypes );
+    static SkDisplayTypes GetType(SkAnimateMaker* , const char[] , size_t len);
+    static SkDisplayable* CreateInstance(SkAnimateMaker* , SkDisplayTypes );
 private:
-       static SkDisplayTypes gNewTypes;
+    static SkDisplayTypes gNewTypes;
 };
 
 #endif // SkDisplayType_DEFINED
index b38a04c..bd29445 100644 (file)
@@ -1,23 +1,40 @@
+/* libs/graphics/animator/SkDisplayTypes.cpp
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #include "SkDisplayTypes.h"
 #include "SkAnimateBase.h"
 
 bool SkDisplayDepend::canContainDependents() const {
-       return true; 
+    return true; 
 }
 
 void SkDisplayDepend::dirty() {
-       SkDisplayable** last = fDependents.end();
-       for (SkDisplayable** depPtr = fDependents.begin(); depPtr < last; depPtr++) {
-               SkAnimateBase* animate = (SkAnimateBase* ) *depPtr;
-               animate->setChanged(true);
-       }
+    SkDisplayable** last = fDependents.end();
+    for (SkDisplayable** depPtr = fDependents.begin(); depPtr < last; depPtr++) {
+        SkAnimateBase* animate = (SkAnimateBase* ) *depPtr;
+        animate->setChanged(true);
+    }
 }
 
 // Boolean
 #if SK_USE_CONDENSED_INFO == 0
 
 const SkMemberInfo SkDisplayBoolean::fInfo[] = {
-       SK_MEMBER(value, Boolean)
+    SK_MEMBER(value, Boolean)
 };
 
 #endif
@@ -29,8 +46,8 @@ SkDisplayBoolean::SkDisplayBoolean() : value(false) {
 
 #ifdef SK_DUMP_ENABLED
 void SkDisplayBoolean::dump(SkAnimateMaker* maker){
-       dumpBase(maker);
-       SkDebugf("value=\"%s\" />\n", value ? "true" : "false");
+    dumpBase(maker);
+    SkDebugf("value=\"%s\" />\n", value ? "true" : "false");
 }
 #endif
 
@@ -38,7 +55,7 @@ void SkDisplayBoolean::dump(SkAnimateMaker* maker){
 #if SK_USE_CONDENSED_INFO == 0
 
 const SkMemberInfo SkDisplayInt::fInfo[] = {
-       SK_MEMBER(value, Int)
+    SK_MEMBER(value, Int)
 };
 
 #endif
@@ -50,8 +67,8 @@ SkDisplayInt::SkDisplayInt() : value(0) {
 
 #ifdef SK_DUMP_ENABLED
 void SkDisplayInt::dump(SkAnimateMaker* maker){
-       dumpBase(maker);
-       SkDebugf("value=\"%d\" />\n", value);
+    dumpBase(maker);
+    SkDebugf("value=\"%d\" />\n", value);
 }
 #endif
 
@@ -59,7 +76,7 @@ void SkDisplayInt::dump(SkAnimateMaker* maker){
 #if SK_USE_CONDENSED_INFO == 0
 
 const SkMemberInfo SkDisplayFloat::fInfo[] = {
-       SK_MEMBER(value, Float)
+    SK_MEMBER(value, Float)
 };
 
 #endif
@@ -71,36 +88,36 @@ SkDisplayFloat::SkDisplayFloat() : value(0) {
 
 #ifdef SK_DUMP_ENABLED
 void SkDisplayFloat::dump(SkAnimateMaker* maker) {
-       dumpBase(maker);
+    dumpBase(maker);
 #ifdef SK_CAN_USE_FLOAT
-       SkDebugf("value=\"%g\" />\n", SkScalarToFloat(value));
+    SkDebugf("value=\"%g\" />\n", SkScalarToFloat(value));
 #else
-       SkDebugf("value=\"%x\" />\n", value);
+    SkDebugf("value=\"%x\" />\n", value);
 #endif
 }
 #endif
 
 // SkString
 enum SkDisplayString_Functions {
-       SK_FUNCTION(slice)
+    SK_FUNCTION(slice)
 };
 
 enum SkDisplayString_Properties {
-       SK_PROPERTY(length)
+    SK_PROPERTY(length)
 };
 
 const SkFunctionParamType SkDisplayString::fFunctionParameters[] = {
-       (SkFunctionParamType) SkType_Int,       // slice
-       (SkFunctionParamType) SkType_Int,
-       (SkFunctionParamType) 0
+    (SkFunctionParamType) SkType_Int,   // slice
+    (SkFunctionParamType) SkType_Int,
+    (SkFunctionParamType) 0
 };
 
 #if SK_USE_CONDENSED_INFO == 0
 
 const SkMemberInfo SkDisplayString::fInfo[] = {
-       SK_MEMBER_PROPERTY(length, Int),
-       SK_MEMBER_FUNCTION(slice, String),
-       SK_MEMBER(value, String)
+    SK_MEMBER_PROPERTY(length, Int),
+    SK_MEMBER_FUNCTION(slice, String),
+    SK_MEMBER(value, String)
 };
 
 #endif
@@ -114,62 +131,62 @@ SkDisplayString::SkDisplayString(SkString& copyFrom) : value(copyFrom) {
 }
 
 void SkDisplayString::executeFunction(SkDisplayable* target, int index, 
-               SkTDArray<SkScriptValue>& parameters, SkDisplayTypes type,
-               SkScriptValue* scriptValue) {
-       if (scriptValue == nil)
-               return;
-       SkASSERT(target == this);
-       switch (index) {
-               case SK_FUNCTION(slice):
-                       scriptValue->fType = SkType_String;
-                       SkASSERT(parameters[0].fType == SkType_Int);
-                       int start =  parameters[0].fOperand.fS32;
-                       if (start < 0)
-                               start = (int) (value.size() - start);
-                       int end = (int) value.size();
-                       if (parameters.count() > 1) {
-                               SkASSERT(parameters[1].fType == SkType_Int);
-                               end = parameters[1].fOperand.fS32;
-                       }
-                       //if (end >= 0 && end < (int) value.size())
-                       if (end >= 0 && end <= (int) value.size())
-                               scriptValue->fOperand.fString = new SkString(&value.c_str()[start], end - start);
-                       else
-                               scriptValue->fOperand.fString = new SkString(value);
-               break;
-       }
+        SkTDArray<SkScriptValue>& parameters, SkDisplayTypes type,
+        SkScriptValue* scriptValue) {
+    if (scriptValue == nil)
+        return;
+    SkASSERT(target == this);
+    switch (index) {
+        case SK_FUNCTION(slice):
+            scriptValue->fType = SkType_String;
+            SkASSERT(parameters[0].fType == SkType_Int);
+            int start =  parameters[0].fOperand.fS32;
+            if (start < 0)
+                start = (int) (value.size() - start);
+            int end = (int) value.size();
+            if (parameters.count() > 1) {
+                SkASSERT(parameters[1].fType == SkType_Int);
+                end = parameters[1].fOperand.fS32;
+            }
+            //if (end >= 0 && end < (int) value.size())
+            if (end >= 0 && end <= (int) value.size())
+                scriptValue->fOperand.fString = new SkString(&value.c_str()[start], end - start);
+            else
+                scriptValue->fOperand.fString = new SkString(value);
+        break;
+    }
 }
 
 const SkFunctionParamType* SkDisplayString::getFunctionsParameters() {
-       return fFunctionParameters;
+    return fFunctionParameters;
 }
 
 bool SkDisplayString::getProperty(int index, SkScriptValue* scriptValue) const {
-       switch (index) { 
-               case SK_PROPERTY(length):
-                       scriptValue->fType = SkType_Int;
-                       scriptValue->fOperand.fS32 = (S32) value.size();
-                       break;
-               default:
-                       SkASSERT(0);
-                       return false;
-       }
-       return true;
+    switch (index) { 
+        case SK_PROPERTY(length):
+            scriptValue->fType = SkType_Int;
+            scriptValue->fOperand.fS32 = (S32) value.size();
+            break;
+        default:
+            SkASSERT(0);
+            return false;
+    }
+    return true;
 }
 
 
 // SkArray
-#if 0  // !!! reason enough to qualify enum with class name or move typedArray into its own file
+#if 0   // !!! reason enough to qualify enum with class name or move typedArray into its own file
 enum SkDisplayArray_Properties {
-       SK_PROPERTY(length)
+    SK_PROPERTY(length)
 };
 #endif
 
 #if SK_USE_CONDENSED_INFO == 0
 
 const SkMemberInfo SkDisplayArray::fInfo[] = {
-       SK_MEMBER_PROPERTY(length, Int),
-       SK_MEMBER_ARRAY(values, Unknown)
+    SK_MEMBER_PROPERTY(length, Int),
+    SK_MEMBER_ARRAY(values, Unknown)
 };
 
 #endif
@@ -184,28 +201,28 @@ SkDisplayArray::SkDisplayArray(SkTypedArray& copyFrom) : values(copyFrom) {
 }
 
 SkDisplayArray::~SkDisplayArray() {
-       if (values.getType() == SkType_String) {
-               for (int index = 0; index < values.count(); index++)
-                       delete values[index].fString;
-               return;
-       }
-       if (values.getType() == SkType_Array) {
-               for (int index = 0; index < values.count(); index++)
-                       delete values[index].fArray;
-       }
+    if (values.getType() == SkType_String) {
+        for (int index = 0; index < values.count(); index++)
+            delete values[index].fString;
+        return;
+    }
+    if (values.getType() == SkType_Array) {
+        for (int index = 0; index < values.count(); index++)
+            delete values[index].fArray;
+    }
 }
 
 bool SkDisplayArray::getProperty(int index, SkScriptValue* value) const {
-       switch (index) { 
-               case SK_PROPERTY(length):
-                       value->fType = SkType_Int;
-                       value->fOperand.fS32 = values.count();
-                       break;
-               default:
-                       SkASSERT(0);
-                       return false;
-       }
-       return true;
+    switch (index) { 
+        case SK_PROPERTY(length):
+            value->fType = SkType_Int;
+            value->fOperand.fS32 = values.count();
+            break;
+        default:
+            SkASSERT(0);
+            return false;
+    }
+    return true;
 }
 
 
index ce654ab..ce16e48 100644 (file)
@@ -1,3 +1,20 @@
+/* libs/graphics/animator/SkDisplayTypes.h
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #ifndef SkDisplayTypes_DEFINED
 #define SkDisplayTypes_DEFINED
 
@@ -10,88 +27,88 @@ class SkOpArray; // compiled script experiment
 
 class SkDisplayDepend : public SkDisplayable {
 public:
-       virtual bool canContainDependents() const;
-       void addDependent(SkDisplayable* displayable) {
-               if (fDependents.find(displayable) < 0)
-                       *fDependents.append() = displayable;
-       }
-       virtual void dirty();
+    virtual bool canContainDependents() const;
+    void addDependent(SkDisplayable* displayable) {
+        if (fDependents.find(displayable) < 0)
+            *fDependents.append() = displayable;
+    }
+    virtual void dirty();
 private:
-       SkTDDisplayableArray fDependents;
-       typedef SkDisplayable INHERITED;
+    SkTDDisplayableArray fDependents;
+    typedef SkDisplayable INHERITED;
 };
 
 class SkDisplayBoolean : public SkDisplayDepend {
-       DECLARE_DISPLAY_MEMBER_INFO(Boolean);
-       SkDisplayBoolean();
+    DECLARE_DISPLAY_MEMBER_INFO(Boolean);
+    SkDisplayBoolean();
 #ifdef SK_DUMP_ENABLED
-       virtual void dump(SkAnimateMaker* );
+    virtual void dump(SkAnimateMaker* );
 #endif
-       SkBool value;
-       friend class SkAnimatorScript;
-       friend class SkAnimatorScript_Box;
-       friend class SkAnimatorScript_Unbox;
-       typedef SkDisplayDepend INHERITED;
+    SkBool value;
+    friend class SkAnimatorScript;
+    friend class SkAnimatorScript_Box;
+    friend class SkAnimatorScript_Unbox;
+    typedef SkDisplayDepend INHERITED;
 };
 
 class SkDisplayInt : public SkDisplayDepend {
-       DECLARE_DISPLAY_MEMBER_INFO(Int);
-       SkDisplayInt();
+    DECLARE_DISPLAY_MEMBER_INFO(Int);
+    SkDisplayInt();
 #ifdef SK_DUMP_ENABLED
-       virtual void dump(SkAnimateMaker* );
+    virtual void dump(SkAnimateMaker* );
 #endif
 private:
-       S32 value;
-       friend class SkAnimatorScript;
-       friend class SkAnimatorScript_Box;
-       friend class SkAnimatorScript_Unbox;
-       typedef SkDisplayDepend INHERITED;
+    S32 value;
+    friend class SkAnimatorScript;
+    friend class SkAnimatorScript_Box;
+    friend class SkAnimatorScript_Unbox;
+    typedef SkDisplayDepend INHERITED;
 };
 
 class SkDisplayFloat : public SkDisplayDepend {
-       DECLARE_DISPLAY_MEMBER_INFO(Float);
-       SkDisplayFloat();
+    DECLARE_DISPLAY_MEMBER_INFO(Float);
+    SkDisplayFloat();
 #ifdef SK_DUMP_ENABLED
-       virtual void dump(SkAnimateMaker* );
+    virtual void dump(SkAnimateMaker* );
 #endif
 private:
-       SkScalar value;
-       friend class SkAnimatorScript;
-       friend class SkAnimatorScript_Box;
-       friend class SkAnimatorScript_Unbox;
-       typedef SkDisplayDepend INHERITED;
+    SkScalar value;
+    friend class SkAnimatorScript;
+    friend class SkAnimatorScript_Box;
+    friend class SkAnimatorScript_Unbox;
+    typedef SkDisplayDepend INHERITED;
 };
 
 class SkDisplayString : public SkDisplayDepend {
-       DECLARE_DISPLAY_MEMBER_INFO(String);
-       SkDisplayString();
-       SkDisplayString(SkString& );
-       virtual void executeFunction(SkDisplayable* , int index, 
-               SkTDArray<SkScriptValue>& parameters, SkDisplayTypes type,
-               SkScriptValue* );
-       virtual const SkFunctionParamType* getFunctionsParameters();
-       virtual bool getProperty(int index, SkScriptValue* ) const;
-       SkString value;
+    DECLARE_DISPLAY_MEMBER_INFO(String);
+    SkDisplayString();
+    SkDisplayString(SkString& );
+    virtual void executeFunction(SkDisplayable* , int index, 
+        SkTDArray<SkScriptValue>& parameters, SkDisplayTypes type,
+        SkScriptValue* );
+    virtual const SkFunctionParamType* getFunctionsParameters();
+    virtual bool getProperty(int index, SkScriptValue* ) const;
+    SkString value;
 private:
-       static const SkFunctionParamType fFunctionParameters[];
+    static const SkFunctionParamType fFunctionParameters[];
 };
 
 class SkDisplayArray : public SkDisplayDepend {
-       DECLARE_DISPLAY_MEMBER_INFO(Array);
-       SkDisplayArray();
-       SkDisplayArray(SkTypedArray& );
-       SkDisplayArray(SkOpArray& ); // compiled script experiment
-       virtual ~SkDisplayArray();
-       virtual bool getProperty(int index, SkScriptValue* ) const;
+    DECLARE_DISPLAY_MEMBER_INFO(Array);
+    SkDisplayArray();
+    SkDisplayArray(SkTypedArray& );
+    SkDisplayArray(SkOpArray& ); // compiled script experiment
+    virtual ~SkDisplayArray();
+    virtual bool getProperty(int index, SkScriptValue* ) const;
 private:
-       SkTypedArray values;
+    SkTypedArray values;
     friend class SkAnimator;
-       friend class SkAnimatorScript;
-       friend class SkAnimatorScript2;
-       friend class SkAnimatorScript_Unbox;
-       friend class SkDisplayable;
-       friend struct SkMemberInfo;
-       friend class SkScriptEngine;
+    friend class SkAnimatorScript;
+    friend class SkAnimatorScript2;
+    friend class SkAnimatorScript_Unbox;
+    friend class SkDisplayable;
+    friend struct SkMemberInfo;
+    friend class SkScriptEngine;
 };
 
 #endif // SkDisplayTypes_DEFINED
index fd4840a..8d7f75e 100644 (file)
@@ -1,3 +1,20 @@
+/* libs/graphics/animator/SkDisplayXMLParser.cpp
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #include "SkDisplayXMLParser.h"
 #include "SkAnimateMaker.h"
 #include "SkDisplayApply.h"
 #endif
 
 static char const* const gErrorStrings[] = {
-       "unknown error ",
+    "unknown error ",
     "apply scopes itself",
-       "display tree too deep (circular reference?) ",
-       "element missing parent ",
-       "element type not allowed in parent ",
-       "error adding <data> to <post> ",
-       "error adding to <matrix> ",
-       "error adding to <paint> ",
-       "error adding to <path> ",
-       "error in attribute value ",
-       "error in script ",
-       "expected movie in sink attribute ",
-       "field not in target ",
+    "display tree too deep (circular reference?) ",
+    "element missing parent ",
+    "element type not allowed in parent ",
+    "error adding <data> to <post> ",
+    "error adding to <matrix> ",
+    "error adding to <paint> ",
+    "error adding to <path> ",
+    "error in attribute value ",
+    "error in script ",
+    "expected movie in sink attribute ",
+    "field not in target ",
     "number of offsets in gradient must match number of colors",
     "no offset in gradient may be greater than one",
     "last offset in gradient must be one",
     "offsets in gradient must be increasing",
     "first offset in gradient must be zero",
     "gradient attribute \"points\" must have length of four", 
-       "in include ",
-       "in movie ",
-       "include name unknown or missing ",
-       "index out of range ",
-       "movie name unknown or missing ",
-       "no parent available to resolve sink attribute ",
-       "parent element can't contain ",
+    "in include ",
+    "in movie ",
+    "include name unknown or missing ",
+    "index out of range ",
+    "movie name unknown or missing ",
+    "no parent available to resolve sink attribute ",
+    "parent element can't contain ",
     "saveLayer must specify a bounds",
-       "target id not found ",
-       "unexpected type "
+    "target id not found ",
+    "unexpected type "
 };
 
 SkDisplayXMLParserError::~SkDisplayXMLParserError() {
 }
 
 void SkDisplayXMLParserError::getErrorString(SkString* str) const {
-       if (fCode > kUnknownError)
-               str->set(gErrorStrings[fCode - kUnknownError]);
-       else
-               str->reset();
-       INHERITED::getErrorString(str);
+    if (fCode > kUnknownError)
+        str->set(gErrorStrings[fCode - kUnknownError]);
+    else
+        str->reset();
+    INHERITED::getErrorString(str);
 }
 
 void SkDisplayXMLParserError::setInnerError(SkAnimateMaker* parent, const SkString& src) {
-       SkString inner;
-       getErrorString(&inner);
-       inner.prepend(": ");
-       inner.prependS32(getLineNumber());
-       inner.prepend(", line ");
-       inner.prepend(src);
-       parent->setErrorNoun(inner);
+    SkString inner;
+    getErrorString(&inner);
+    inner.prepend(": ");
+    inner.prependS32(getLineNumber());
+    inner.prepend(", line ");
+    inner.prepend(src);
+    parent->setErrorNoun(inner);
 }
 
 
 SkDisplayXMLParser::SkDisplayXMLParser(SkAnimateMaker& maker)
-       : INHERITED(&maker.fError), fMaker(maker), fInInclude(maker.fInInclude), 
-               fInSkia(maker.fInInclude), fCurrDisplayable(nil)
+    : INHERITED(&maker.fError), fMaker(maker), fInInclude(maker.fInInclude), 
+        fInSkia(maker.fInInclude), fCurrDisplayable(nil)
 {
 }
 
 SkDisplayXMLParser::~SkDisplayXMLParser() {
-       if (fCurrDisplayable && fMaker.fChildren.find(fCurrDisplayable) < 0)
-               delete fCurrDisplayable;
-       for (Parent* parPtr = fParents.begin() + 1; parPtr < fParents.end(); parPtr++) {
-               SkDisplayable* displayable = parPtr->fDisplayable;
-               if (displayable == fCurrDisplayable)
-                       continue;
-               SkASSERT(fMaker.fChildren.find(displayable) < 0);
-               if (fMaker.fHelpers.find(displayable) < 0)
-                       delete displayable;
-       }
+    if (fCurrDisplayable && fMaker.fChildren.find(fCurrDisplayable) < 0)
+        delete fCurrDisplayable;
+    for (Parent* parPtr = fParents.begin() + 1; parPtr < fParents.end(); parPtr++) {
+        SkDisplayable* displayable = parPtr->fDisplayable;
+        if (displayable == fCurrDisplayable)
+            continue;
+        SkASSERT(fMaker.fChildren.find(displayable) < 0);
+        if (fMaker.fHelpers.find(displayable) < 0)
+            delete displayable;
+    }
 }
 
 
 
 bool SkDisplayXMLParser::onAddAttribute(const char name[], const char value[]) {
-       return onAddAttributeLen(name, value, strlen(value));
+    return onAddAttributeLen(name, value, strlen(value));
 }
 
 bool SkDisplayXMLParser::onAddAttributeLen(const char attrName[], const char attrValue[], 
-                                                                               size_t attrValueLen)
+                                        size_t attrValueLen)
 {
-       if (fCurrDisplayable == nil)    // this signals we should ignore attributes for this element
-               return strncmp(attrName, "xmlns", sizeof("xmlns") - 1) != 0;
-       SkDisplayable*  displayable = fCurrDisplayable;
-       SkDisplayTypes  type = fCurrType;
+    if (fCurrDisplayable == nil)    // this signals we should ignore attributes for this element
+        return strncmp(attrName, "xmlns", sizeof("xmlns") - 1) != 0;
+    SkDisplayable*  displayable = fCurrDisplayable;
+    SkDisplayTypes  type = fCurrType;
 
-       if (strcmp(attrName, "id") == 0) {
-               if (fMaker.find(attrValue, attrValueLen, nil)) {
-                       fError->setNoun(attrValue, attrValueLen);
-                       fError->setCode(SkXMLParserError::kDuplicateIDs);
-                       return true;
-               }
+    if (strcmp(attrName, "id") == 0) {
+        if (fMaker.find(attrValue, attrValueLen, nil)) {
+            fError->setNoun(attrValue, attrValueLen);
+            fError->setCode(SkXMLParserError::kDuplicateIDs);
+            return true;
+        }
 #ifdef SK_DEBUG
-               displayable->_id.set(attrValue, attrValueLen);
-               displayable->id = displayable->_id.c_str();
+        displayable->_id.set(attrValue, attrValueLen);
+        displayable->id = displayable->_id.c_str();
 #endif
-               fMaker.idsSet(attrValue, attrValueLen, displayable);
-               int parentIndex = fParents.count() - 1;
-               if (parentIndex > 0) {
-                       SkDisplayable* parent = fParents[parentIndex - 1].fDisplayable;
-                       parent->setChildHasID();
-               }
-               return false;
-       }
-       const char* name = attrName;
-       const SkMemberInfo* info = SkDisplayType::GetMember(&fMaker, type, &name);
-       if (info == nil) {
-               fError->setNoun(name);
-               fError->setCode(SkXMLParserError::kUnknownAttributeName);
-               return true;
-       }
-       if (info->setValue(fMaker, nil, 0, info->getCount(), displayable, info->getType(), attrValue,
-                       attrValueLen))
-               return false;
-       if (fMaker.fError.hasError()) {
-               fError->setNoun(attrValue, attrValueLen);
-               return true;
-       }
-       SkDisplayable* ref = nil;
-       if (fMaker.find(attrValue, attrValueLen, &ref) == false) {
-               ref = fMaker.createInstance(attrValue, attrValueLen);
-               if (ref == nil) {
-                       fError->setNoun(attrValue, attrValueLen);
-                       fError->setCode(SkXMLParserError::kErrorInAttributeValue);
-                       return true;
-               } else
-                       fMaker.helperAdd(ref);
-       }
-       if (info->fType != SkType_MemberProperty) {
-               fError->setNoun(name);
-               fError->setCode(SkXMLParserError::kUnknownAttributeName);
-               return true;
-       }
-       SkScriptValue scriptValue;
-       scriptValue.fOperand.fDisplayable = ref;
-       scriptValue.fType = ref->getType();
-       displayable->setProperty(info->propertyIndex(), scriptValue);
-       return false;
+        fMaker.idsSet(attrValue, attrValueLen, displayable);
+        int parentIndex = fParents.count() - 1;
+        if (parentIndex > 0) {
+            SkDisplayable* parent = fParents[parentIndex - 1].fDisplayable;
+            parent->setChildHasID();
+        }
+        return false;
+    }
+    const char* name = attrName;
+    const SkMemberInfo* info = SkDisplayType::GetMember(&fMaker, type, &name);
+    if (info == nil) {
+        fError->setNoun(name);
+        fError->setCode(SkXMLParserError::kUnknownAttributeName);
+        return true;
+    }
+    if (info->setValue(fMaker, nil, 0, info->getCount(), displayable, info->getType(), attrValue,
+            attrValueLen))
+        return false;
+    if (fMaker.fError.hasError()) {
+        fError->setNoun(attrValue, attrValueLen);
+        return true;
+    }
+    SkDisplayable* ref = nil;
+    if (fMaker.find(attrValue, attrValueLen, &ref) == false) {
+        ref = fMaker.createInstance(attrValue, attrValueLen);
+        if (ref == nil) {
+            fError->setNoun(attrValue, attrValueLen);
+            fError->setCode(SkXMLParserError::kErrorInAttributeValue);
+            return true;
+        } else
+            fMaker.helperAdd(ref);
+    }
+    if (info->fType != SkType_MemberProperty) {
+        fError->setNoun(name);
+        fError->setCode(SkXMLParserError::kUnknownAttributeName);
+        return true;
+    }
+    SkScriptValue scriptValue;
+    scriptValue.fOperand.fDisplayable = ref;
+    scriptValue.fType = ref->getType();
+    displayable->setProperty(info->propertyIndex(), scriptValue);
+    return false;
 }
 
 bool SkDisplayXMLParser::onEndElement(const char elem[])
 {
-       int parentIndex = fParents.count() - 1;
-       if (parentIndex >= 0) {
-               Parent& container = fParents[parentIndex];
-               SkDisplayable* displayable = container.fDisplayable;
-               fMaker.fEndDepth = parentIndex;
-               displayable->onEndElement(fMaker);
-               if (fMaker.fError.hasError()) 
-                       return true;
-               if (parentIndex > 0) {
-                       SkDisplayable* parent = fParents[parentIndex - 1].fDisplayable;
-                       bool result = parent->add(fMaker, displayable);
-                       if (fMaker.hasError()) 
-                               return true;
-                       if (result == false) {
-                               int infoCount;
-                               const SkMemberInfo* info = 
-                                       SkDisplayType::GetMembers(&fMaker, fParents[parentIndex - 1].fType, &infoCount);
-                               const SkMemberInfo* foundInfo;
-                               if ((foundInfo = searchContainer(info, infoCount)) != nil) {
-                                       parent->setReference(foundInfo, displayable);
-               //                      if (displayable->isHelper() == false)
-                                               fMaker.helperAdd(displayable);
-                               } else {
-                                       fMaker.setErrorCode(SkDisplayXMLParserError::kElementTypeNotAllowedInParent);
-                                       return true;
-                               }
-                       }
-                       if (parent->childrenNeedDisposing())
-                               delete displayable;
-               }
-               fParents.remove(parentIndex);
-       }
-       fCurrDisplayable = nil;
-       if (fInInclude == false && strcasecmp(elem, "screenplay") == 0) {
-               if (fMaker.fInMovie == false) {
-                       fMaker.fEnableTime = fMaker.getAppTime();
+    int parentIndex = fParents.count() - 1;
+    if (parentIndex >= 0) {
+        Parent& container = fParents[parentIndex];
+        SkDisplayable* displayable = container.fDisplayable;
+        fMaker.fEndDepth = parentIndex;
+        displayable->onEndElement(fMaker);
+        if (fMaker.fError.hasError()) 
+            return true;
+        if (parentIndex > 0) {
+            SkDisplayable* parent = fParents[parentIndex - 1].fDisplayable;
+            bool result = parent->add(fMaker, displayable);
+            if (fMaker.hasError()) 
+                return true;
+            if (result == false) {
+                int infoCount;
+                const SkMemberInfo* info = 
+                    SkDisplayType::GetMembers(&fMaker, fParents[parentIndex - 1].fType, &infoCount);
+                const SkMemberInfo* foundInfo;
+                if ((foundInfo = searchContainer(info, infoCount)) != nil) {
+                    parent->setReference(foundInfo, displayable);
+        //          if (displayable->isHelper() == false)
+                        fMaker.helperAdd(displayable);
+                } else {
+                    fMaker.setErrorCode(SkDisplayXMLParserError::kElementTypeNotAllowedInParent);
+                    return true;
+                }
+            }
+            if (parent->childrenNeedDisposing())
+                delete displayable;
+        }
+        fParents.remove(parentIndex);
+    }
+    fCurrDisplayable = nil;
+    if (fInInclude == false && strcasecmp(elem, "screenplay") == 0) {
+        if (fMaker.fInMovie == false) {
+            fMaker.fEnableTime = fMaker.getAppTime();
 #if defined SK_DEBUG && defined SK_DEBUG_ANIMATION_TIMING
-                       if (fMaker.fDebugTimeBase == (SkMSec) -1)
-                               fMaker.fDebugTimeBase = fMaker.fEnableTime;
-                       SkString debugOut;
-                       SkMSec time = fMaker.getAppTime();
-                       debugOut.appendS32(time - fMaker.fDebugTimeBase);
-                       debugOut.append(" onLoad enable=");
-                       debugOut.appendS32(fMaker.fEnableTime - fMaker.fDebugTimeBase);
-                       SkDebugf("%s\n", debugOut.c_str());
+            if (fMaker.fDebugTimeBase == (SkMSec) -1)
+                fMaker.fDebugTimeBase = fMaker.fEnableTime;
+            SkString debugOut;
+            SkMSec time = fMaker.getAppTime();
+            debugOut.appendS32(time - fMaker.fDebugTimeBase);
+            debugOut.append(" onLoad enable=");
+            debugOut.appendS32(fMaker.fEnableTime - fMaker.fDebugTimeBase);
+            SkDebugf("%s\n", debugOut.c_str());
 #endif
-                       fMaker.fEvents.doEvent(fMaker, SkDisplayEvent::kOnload, nil);
-                       if (fMaker.fError.hasError()) 
-                               return true;
-                       fMaker.fEvents.removeEvent(SkDisplayEvent::kOnload, nil);
+            fMaker.fEvents.doEvent(fMaker, SkDisplayEvent::kOnload, nil);
+            if (fMaker.fError.hasError()) 
+                return true;
+            fMaker.fEvents.removeEvent(SkDisplayEvent::kOnload, nil);
 
-               }
-               fInSkia = false;
-       }
-       return false;
+        }
+        fInSkia = false;
+    }
+    return false;
 }
 
 bool SkDisplayXMLParser::onStartElement(const char name[])
 {
-       return onStartElementLen(name, strlen(name));
+    return onStartElementLen(name, strlen(name));
 }
 
 bool SkDisplayXMLParser::onStartElementLen(const char name[], size_t len) {
-       fCurrDisplayable = nil; // init so we'll ignore attributes if we exit early
+    fCurrDisplayable = nil; // init so we'll ignore attributes if we exit early
 
-       if (strncasecmp(name, "screenplay", len) == 0) {
-               fInSkia = true;
-               if (fInInclude == false)
-                       fMaker.idsSet(name, len, &fMaker.fScreenplay);
-               return false;
-       }
-       if (fInSkia == false)
-               return false;
+    if (strncasecmp(name, "screenplay", len) == 0) {
+        fInSkia = true;
+        if (fInInclude == false)
+            fMaker.idsSet(name, len, &fMaker.fScreenplay);
+        return false;
+    }
+    if (fInSkia == false)
+        return false;
 
-       SkDisplayable* displayable = fMaker.createInstance(name, len);
-       if (displayable == nil) {
-               fError->setNoun(name, len);
-               fError->setCode(SkXMLParserError::kUnknownElement);
-               return true;
-       }
-       SkDisplayTypes type = displayable->getType();
-       Parent record = { displayable, type };
-       *fParents.append() = record;
-       if (fParents.count() == 1)
-               fMaker.childrenAdd(displayable);
-       else {
-               Parent* parent = fParents.end() - 2;
-               if (displayable->setParent(parent->fDisplayable)) {
-                       fError->setNoun(name, len);
-                       getError()->setCode(SkDisplayXMLParserError::kParentElementCantContain);
-                       return true;
-               }
-       }
+    SkDisplayable* displayable = fMaker.createInstance(name, len);
+    if (displayable == nil) {
+        fError->setNoun(name, len);
+        fError->setCode(SkXMLParserError::kUnknownElement);
+        return true;
+    }
+    SkDisplayTypes type = displayable->getType();
+    Parent record = { displayable, type };
+    *fParents.append() = record;
+    if (fParents.count() == 1)
+        fMaker.childrenAdd(displayable);
+    else {
+        Parent* parent = fParents.end() - 2;
+        if (displayable->setParent(parent->fDisplayable)) {
+            fError->setNoun(name, len);
+            getError()->setCode(SkDisplayXMLParserError::kParentElementCantContain);
+            return true;
+        }
+    }
 
-       // set these for subsequent calls to addAttribute()
-       fCurrDisplayable = displayable;
-       fCurrType = type;
-       return false;
+    // set these for subsequent calls to addAttribute()
+    fCurrDisplayable = displayable;
+    fCurrType = type;
+    return false;
 }
 
 const SkMemberInfo* SkDisplayXMLParser::searchContainer(const SkMemberInfo* infoBase,
-                                                                                                                int infoCount) {
-       const SkMemberInfo* bestDisplayable = nil;
-       const SkMemberInfo* lastResort = nil;
-       for (int index = 0; index < infoCount; index++) {
-               const SkMemberInfo* info = &infoBase[index];
-               if (info->fType == SkType_BaseClassInfo) {
-                       const SkMemberInfo* inherited = info->getInherited();
-                       const SkMemberInfo* result = searchContainer(inherited, info->fCount);
-                       if (result != nil)
-                               return result;
-                       continue;
-               }
-               Parent* container = fParents.end() - 1;
-               SkDisplayTypes type = (SkDisplayTypes) info->fType;
-               if (type == SkType_MemberProperty) 
-                       type = info->propertyType();
-               SkDisplayTypes containerType = container->fType;
-               if (type == containerType && (type == SkType_Rect || type == SkType_Polygon ||
-                       type == SkType_Array || type == SkType_Int || type == SkType_Bitmap))
-                       goto rectNext;
-               while (type != containerType) {
-                       if (containerType == SkType_Displayable)
-                               goto next;
-                       containerType = SkDisplayType::GetParent(&fMaker, containerType);
-                       if (containerType == SkType_Unknown)
-                               goto next;
-               }
-               return info;
+                                                         int infoCount) {
+    const SkMemberInfo* bestDisplayable = nil;
+    const SkMemberInfo* lastResort = nil;
+    for (int index = 0; index < infoCount; index++) {
+        const SkMemberInfo* info = &infoBase[index];
+        if (info->fType == SkType_BaseClassInfo) {
+            const SkMemberInfo* inherited = info->getInherited();
+            const SkMemberInfo* result = searchContainer(inherited, info->fCount);
+            if (result != nil)
+                return result;
+            continue;
+        }
+        Parent* container = fParents.end() - 1;
+        SkDisplayTypes type = (SkDisplayTypes) info->fType;
+        if (type == SkType_MemberProperty) 
+            type = info->propertyType();
+        SkDisplayTypes containerType = container->fType;
+        if (type == containerType && (type == SkType_Rect || type == SkType_Polygon ||
+            type == SkType_Array || type == SkType_Int || type == SkType_Bitmap))
+            goto rectNext;
+        while (type != containerType) {
+            if (containerType == SkType_Displayable)
+                goto next;
+            containerType = SkDisplayType::GetParent(&fMaker, containerType);
+            if (containerType == SkType_Unknown)
+                goto next;
+        }
+        return info;
 next:
-               if (type == SkType_Drawable || type == SkType_Displayable && 
-                       container->fDisplayable->isDrawable()) {
+        if (type == SkType_Drawable || type == SkType_Displayable && 
+            container->fDisplayable->isDrawable()) {
 rectNext:
-                       if (fParents.count() > 1) {
-                               Parent* parent = fParents.end() - 2;
-                               if (info == parent->fDisplayable->preferredChild(type))
-                                       bestDisplayable = info;
-                               else
-                                       lastResort = info;
-                       }
-               }
-       }
-       if (bestDisplayable)
-               return bestDisplayable;
-       if (lastResort)
-               return lastResort;
-       return nil;
+            if (fParents.count() > 1) {
+                Parent* parent = fParents.end() - 2;
+                if (info == parent->fDisplayable->preferredChild(type))
+                    bestDisplayable = info;
+                else
+                    lastResort = info;
+            }
+        }
+    }
+    if (bestDisplayable)
+        return bestDisplayable;
+    if (lastResort)
+        return lastResort;
+    return nil;
 }
 
 
index 3aa42cf..bddc809 100644 (file)
@@ -1,3 +1,20 @@
+/* libs/graphics/animator/SkDisplayXMLParser.h
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #ifndef SkDisplayXMLParser_DEFINED
 #define SkDisplayXMLParser_DEFINED
 
@@ -11,72 +28,72 @@ class SkDisplayable;
 
 class SkDisplayXMLParserError : public SkXMLParserError {
 public:
-       enum ErrorCode {
+    enum ErrorCode {
         kApplyScopesItself = kUnknownError + 1,
-               kDisplayTreeTooDeep,
-               kElementMissingParent,
-               kElementTypeNotAllowedInParent,
-               kErrorAddingDataToPost,
-               kErrorAddingToMatrix,
-               kErrorAddingToPaint,
-               kErrorAddingToPath,
-               kErrorInAttributeValue,
-               kErrorInScript,
-               kExpectedMovie,
-               kFieldNotInTarget,
+        kDisplayTreeTooDeep,
+        kElementMissingParent,
+        kElementTypeNotAllowedInParent,
+        kErrorAddingDataToPost,
+        kErrorAddingToMatrix,
+        kErrorAddingToPaint,
+        kErrorAddingToPath,
+        kErrorInAttributeValue,
+        kErrorInScript,
+        kExpectedMovie,
+        kFieldNotInTarget,
         kGradientOffsetsDontMatchColors,
         kGradientOffsetsMustBeNoMoreThanOne,
         kGradientOffsetsMustEndWithOne,
         kGradientOffsetsMustIncrease,
         kGradientOffsetsMustStartWithZero,
         kGradientPointsLengthMustBeFour,
-               kInInclude,
-               kInMovie,
-               kIncludeNameUnknownOrMissing,
-               kIndexOutOfRange,
-               kMovieNameUnknownOrMissing,
-               kNoParentAvailable,
-               kParentElementCantContain,
+        kInInclude,
+        kInMovie,
+        kIncludeNameUnknownOrMissing,
+        kIndexOutOfRange,
+        kMovieNameUnknownOrMissing,
+        kNoParentAvailable,
+        kParentElementCantContain,
         kSaveLayerNeedsBounds,
-               kTargetIDNotFound,
-               kUnexpectedType
-       };
-       virtual ~SkDisplayXMLParserError();
-       virtual void getErrorString(SkString* str) const;
-       void setCode(ErrorCode code) { INHERITED::setCode((INHERITED::ErrorCode) code); }
-       void setInnerError(SkAnimateMaker* maker, const SkString& str);
-       typedef SkXMLParserError INHERITED;
-       friend class SkDisplayXMLParser;
+        kTargetIDNotFound,
+        kUnexpectedType
+    };
+    virtual ~SkDisplayXMLParserError();
+    virtual void getErrorString(SkString* str) const;
+    void setCode(ErrorCode code) { INHERITED::setCode((INHERITED::ErrorCode) code); }
+    void setInnerError(SkAnimateMaker* maker, const SkString& str);
+    typedef SkXMLParserError INHERITED;
+    friend class SkDisplayXMLParser;
 };
 
 class SkDisplayXMLParser : public SkXMLParser {
 public:
-       SkDisplayXMLParser(SkAnimateMaker& maker);
-       virtual ~SkDisplayXMLParser();
+    SkDisplayXMLParser(SkAnimateMaker& maker);
+    virtual ~SkDisplayXMLParser();
 protected:
-       virtual bool onAddAttribute(const char name[], const char value[]);
-       bool onAddAttributeLen(const char name[], const char value[], size_t len);
-       virtual bool onEndElement(const char elem[]);
-       virtual bool onStartElement(const char elem[]);
-       bool onStartElementLen(const char elem[], size_t len);
+    virtual bool onAddAttribute(const char name[], const char value[]);
+    bool onAddAttributeLen(const char name[], const char value[], size_t len);
+    virtual bool onEndElement(const char elem[]);
+    virtual bool onStartElement(const char elem[]);
+    bool onStartElementLen(const char elem[], size_t len);
 private:
-       struct Parent {
-               SkDisplayable* fDisplayable;
-               SkDisplayTypes fType;
-       };
-       SkTDArray<Parent> fParents;
-       SkDisplayXMLParser& operator= (const SkDisplayXMLParser& );
-       SkDisplayXMLParserError* getError() { return (SkDisplayXMLParserError*) fError; }
-       const SkMemberInfo* searchContainer(const SkMemberInfo* ,
-               int infoCount);
-       SkAnimateMaker& fMaker;
-       SkBool fInInclude;
-       SkBool fInSkia;
-       // local state between onStartElement and onAddAttribute
-       SkDisplayable*  fCurrDisplayable;
-       SkDisplayTypes  fCurrType;
-       friend class SkXMLAnimatorWriter;
-       typedef SkXMLParser INHERITED;
+    struct Parent {
+        SkDisplayable* fDisplayable;
+        SkDisplayTypes fType;
+    };
+    SkTDArray<Parent> fParents;
+    SkDisplayXMLParser& operator= (const SkDisplayXMLParser& );
+    SkDisplayXMLParserError* getError() { return (SkDisplayXMLParserError*) fError; }
+    const SkMemberInfo* searchContainer(const SkMemberInfo* ,
+        int infoCount);
+    SkAnimateMaker& fMaker;
+    SkBool fInInclude;
+    SkBool fInSkia;
+    // local state between onStartElement and onAddAttribute
+    SkDisplayable*  fCurrDisplayable;
+    SkDisplayTypes  fCurrType;
+    friend class SkXMLAnimatorWriter;
+    typedef SkXMLParser INHERITED;
 };
 
 #endif // SkDisplayXMLParser_DEFINED
index 41c4b47..ba347c0 100644 (file)
@@ -1,3 +1,20 @@
+/* libs/graphics/animator/SkDisplayable.cpp
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #include "SkDisplayable.h"
 #include "SkDisplayApply.h"
 #include "SkParse.h"
@@ -13,112 +30,112 @@ SkTDDisplayableArray SkDisplayable::fAllocations;
 
 #ifdef SK_DEBUG
 SkDisplayable::SkDisplayable() { 
-       id = _id.c_str();
+    id = _id.c_str();
 #ifdef SK_FIND_LEAKS
-       // fAllocationCount++;
-       *fAllocations.append() = this;
+    // fAllocationCount++;
+    *fAllocations.append() = this;
 #endif
 }
 #endif
 
 SkDisplayable::~SkDisplayable() {
 #ifdef SK_FIND_LEAKS
-    // fAllocationCount--;
-       int index = fAllocations.find(this);
-       SkASSERT(index >= 0);
-       fAllocations.remove(index);
+    //  fAllocationCount--;
+    int index = fAllocations.find(this);
+    SkASSERT(index >= 0);
+    fAllocations.remove(index);
 #endif
 }
 
 bool SkDisplayable::add(SkAnimateMaker& , SkDisplayable* child) {
-       return false; 
+    return false; 
 }
 
 //void SkDisplayable::apply(SkAnimateMaker& , const SkMemberInfo* , 
-//             SkDisplayable* , SkScalar [], int count) { 
-//     SkASSERT(0); 
+//      SkDisplayable* , SkScalar [], int count) { 
+//  SkASSERT(0); 
 //}
 
 bool SkDisplayable::canContainDependents() const {
-       return false; 
+    return false; 
 }
  
 bool SkDisplayable::childrenNeedDisposing() const { 
-       return false; 
+    return false; 
 }
 
 void SkDisplayable::clearBounder() {
 }
 
 bool SkDisplayable::contains(SkDisplayable* ) {
-       return false;
+    return false;
 }
 
 SkDisplayable* SkDisplayable::contains(const SkString& ) {
-       return nil;
+    return nil;
 }
 
 SkDisplayable* SkDisplayable::deepCopy(SkAnimateMaker* maker) {
-       SkDisplayTypes type = getType();
-       if (type == SkType_Unknown) {
-               SkASSERT(0);
-               return nil;
-       }
-       SkDisplayable* copy = SkDisplayType::CreateInstance(maker, type);
-       int index = -1;
-       int propIndex = 0;
-       const SkMemberInfo* info;
-       do {
-               info = copy->getMember(++index);
-               if (info == nil)
-                       break;
-               if (info->fType == SkType_MemberProperty) {
-                       SkScriptValue value;
-                       if (getProperty(propIndex, &value))
-                               copy->setProperty(propIndex, value);
-                       propIndex++;
-                       continue;
-               }
-               if (info->fType == SkType_MemberFunction)
-                       continue;
-               if (info->fType == SkType_Array) {
-                       SkTDOperandArray* array = (SkTDOperandArray*) info->memberData(this);
-                       int arrayCount;
-                       if (array == nil || (arrayCount = array->count()) == 0)
-                               continue;
-                       SkTDOperandArray* copyArray = (SkTDOperandArray*) info->memberData(copy);
-                       copyArray->setCount(arrayCount);
-                       SkDisplayTypes elementType;
-                       if (type == SkType_Array) {
-                               SkDisplayArray* dispArray = (SkDisplayArray*) this;
-                               elementType = dispArray->values.getType();
-                       } else
-                               elementType = info->arrayType();
-                       size_t elementSize = SkMemberInfo::GetSize(elementType);
-                       size_t byteSize = elementSize * arrayCount;
-                       memcpy(copyArray->begin(), array->begin(), byteSize);
-                       continue;
-               }
-               if (SkDisplayType::IsDisplayable(maker, info->fType)) {
-                       SkDisplayable** displayable = (SkDisplayable**) info->memberData(this);
-                       if (*displayable == nil || *displayable == (SkDisplayable*) -1)
-                               continue;
-                       SkDisplayable* deeper = (*displayable)->deepCopy(maker);
-                       info->setMemberData(copy, deeper, sizeof(deeper));
-                       continue;
-               }
-               if (info->fType == SkType_String || info->fType == SkType_DynamicString) {
-                       SkString* string;
-                       info->getString(this, &string);
-                       info->setString(copy, string);
-                       continue;
-               }
-               void* data = info->memberData(this);
-               size_t size = SkMemberInfo::GetSize(info->fType);
-               info->setMemberData(copy, data, size);
-       } while (true);
-       copy->dirty();
-       return copy;
+    SkDisplayTypes type = getType();
+    if (type == SkType_Unknown) {
+        SkASSERT(0);
+        return nil;
+    }
+    SkDisplayable* copy = SkDisplayType::CreateInstance(maker, type);
+    int index = -1;
+    int propIndex = 0;
+    const SkMemberInfo* info;
+    do {
+        info = copy->getMember(++index);
+        if (info == nil)
+            break;
+        if (info->fType == SkType_MemberProperty) {
+            SkScriptValue value;
+            if (getProperty(propIndex, &value))
+                copy->setProperty(propIndex, value);
+            propIndex++;
+            continue;
+        }
+        if (info->fType == SkType_MemberFunction)
+            continue;
+        if (info->fType == SkType_Array) {
+            SkTDOperandArray* array = (SkTDOperandArray*) info->memberData(this);
+            int arrayCount;
+            if (array == nil || (arrayCount = array->count()) == 0)
+                continue;
+            SkTDOperandArray* copyArray = (SkTDOperandArray*) info->memberData(copy);
+            copyArray->setCount(arrayCount);
+            SkDisplayTypes elementType;
+            if (type == SkType_Array) {
+                SkDisplayArray* dispArray = (SkDisplayArray*) this;
+                elementType = dispArray->values.getType();
+            } else
+                elementType = info->arrayType();
+            size_t elementSize = SkMemberInfo::GetSize(elementType);
+            size_t byteSize = elementSize * arrayCount;
+            memcpy(copyArray->begin(), array->begin(), byteSize);
+            continue;
+        }
+        if (SkDisplayType::IsDisplayable(maker, info->fType)) {
+            SkDisplayable** displayable = (SkDisplayable**) info->memberData(this);
+            if (*displayable == nil || *displayable == (SkDisplayable*) -1)
+                continue;
+            SkDisplayable* deeper = (*displayable)->deepCopy(maker);
+            info->setMemberData(copy, deeper, sizeof(deeper));
+            continue;
+        }
+        if (info->fType == SkType_String || info->fType == SkType_DynamicString) {
+            SkString* string;
+            info->getString(this, &string);
+            info->setString(copy, string);
+            continue;
+        }
+        void* data = info->memberData(this);
+        size_t size = SkMemberInfo::GetSize(info->fType);
+        info->setMemberData(copy, data, size);
+    } while (true);
+    copy->dirty();
+    return copy;
 }
 
 void SkDisplayable::dirty() {
@@ -126,7 +143,7 @@ void SkDisplayable::dirty() {
 
 #ifdef SK_DUMP_ENABLED
 void SkDisplayable::dump(SkAnimateMaker* maker) {
-       dumpBase(maker);
+    dumpBase(maker);
 #if SK_USE_CONDENSED_INFO == 0
     this->dumpAttrs(maker);
     this->dumpChildren(maker);
@@ -135,11 +152,11 @@ void SkDisplayable::dump(SkAnimateMaker* maker) {
 
 void SkDisplayable::dumpAttrs(SkAnimateMaker* maker) {
     SkDisplayTypes type = getType();
-       if (type == SkType_Unknown) {
-               //SkDebugf("/>\n");
-               return;
-       }
-       SkDisplayable* blankCopy = SkDisplayType::CreateInstance(maker, type);
+    if (type == SkType_Unknown) {
+        //SkDebugf("/>\n");
+        return;
+    }
+    SkDisplayable* blankCopy = SkDisplayType::CreateInstance(maker, type);
 
     int index = -1;
     int propIndex = 0;
@@ -175,15 +192,15 @@ void SkDisplayable::dumpAttrs(SkAnimateMaker* maker) {
             
         if (info->fType == SkType_Array) {
             SkTDOperandArray* array = (SkTDOperandArray*) info->memberData(this);
-                       int arrayCount;
-                       if (array == nil || (arrayCount = array->count()) == 0)
-                               continue;
-                       SkDisplayTypes elementType;
-                       if (type == SkType_Array) {
-                               SkDisplayArray* dispArray = (SkDisplayArray*) this;
-                               elementType = dispArray->values.getType();
-                       } else
-                               elementType = info->arrayType();
+            int arrayCount;
+            if (array == nil || (arrayCount = array->count()) == 0)
+                continue;
+            SkDisplayTypes elementType;
+            if (type == SkType_Array) {
+                SkDisplayArray* dispArray = (SkDisplayArray*) this;
+                elementType = dispArray->values.getType();
+            } else
+                elementType = info->arrayType();
             bool firstElem = true;
             SkDebugf("%s=\"[", info->fName);
             for (SkOperand* op = array->begin(); op < array->end(); op++) {
@@ -235,13 +252,13 @@ void SkDisplayable::dumpAttrs(SkAnimateMaker* maker) {
 
 void SkDisplayable::dumpBase(SkAnimateMaker* maker) {
     SkDisplayTypes type = getType();
-       const char* elementName = "(unknown)";
-       if (type != SkType_Unknown && type != SkType_Screenplay)
-               elementName = SkDisplayType::GetName(maker, type);
-       SkDebugf("%*s", SkDisplayList::fIndent, "");
-       if (SkDisplayList::fDumpIndex != 0 && SkDisplayList::fIndent == 0)
-               SkDebugf("%d: ", SkDisplayList::fDumpIndex);
-       SkDebugf("<%s ", elementName);
+    const char* elementName = "(unknown)";
+    if (type != SkType_Unknown && type != SkType_Screenplay)
+        elementName = SkDisplayType::GetName(maker, type);
+    SkDebugf("%*s", SkDisplayList::fIndent, "");
+    if (SkDisplayList::fDumpIndex != 0 && SkDisplayList::fIndent == 0)
+        SkDebugf("%d: ", SkDisplayList::fDumpIndex);
+    SkDebugf("<%s ", elementName);
     if (strcmp(id,"") != 0)
         SkDebugf("id=\"%s\" ", id);
 }
@@ -277,11 +294,11 @@ void SkDisplayable::dumpChildren(SkAnimateMaker* maker, bool closedAngle) {
 
 void SkDisplayable::dumpEnd(SkAnimateMaker* maker) {
     SkDisplayTypes type = getType();
-       const char* elementName = "(unknown)";
-       if (type != SkType_Unknown && type != SkType_Screenplay)
-               elementName = SkDisplayType::GetName(maker, type);
-       SkDebugf("%*s", SkDisplayList::fIndent, "");
-       SkDebugf("</%s>\n", elementName);
+    const char* elementName = "(unknown)";
+    if (type != SkType_Unknown && type != SkType_Screenplay)
+        elementName = SkDisplayType::GetName(maker, type);
+    SkDebugf("%*s", SkDisplayList::fIndent, "");
+    SkDebugf("</%s>\n", elementName);
 }
 
 void SkDisplayable::dumpEvents() {
@@ -394,151 +411,151 @@ void SkDisplayable::dumpValues(const SkMemberInfo* info, SkDisplayTypes type, Sk
 #endif
 
 bool SkDisplayable::enable( SkAnimateMaker& ) { 
-       return false;
+    return false;
 }
 
 void SkDisplayable::enableBounder() {
 }
 
 void SkDisplayable::executeFunction(SkDisplayable* , int index, 
-               SkTDArray<SkScriptValue>& , SkDisplayTypes, SkScriptValue*  ) {
-       SkASSERT(0); 
+        SkTDArray<SkScriptValue>& , SkDisplayTypes, SkScriptValue*  ) {
+    SkASSERT(0); 
 }
 
 void SkDisplayable::executeFunction(SkDisplayable* target, 
-               const SkMemberInfo* info, SkTypedArray* values, SkScriptValue* value) {
-       SkTDArray<SkScriptValue> typedValues;
-       for (SkOperand* op = values->begin(); op < values->end(); op++) {
-               SkScriptValue temp;
-               temp.fType = values->getType();
-               temp.fOperand = *op;
-               *typedValues.append() = temp;
-       }
-       executeFunction(target, info->functionIndex(), typedValues, info->getType(), value);
+        const SkMemberInfo* info, SkTypedArray* values, SkScriptValue* value) {
+    SkTDArray<SkScriptValue> typedValues;
+    for (SkOperand* op = values->begin(); op < values->end(); op++) {
+        SkScriptValue temp;
+        temp.fType = values->getType();
+        temp.fOperand = *op;
+        *typedValues.append() = temp;
+    }
+    executeFunction(target, info->functionIndex(), typedValues, info->getType(), value);
 }
 
 void SkDisplayable::executeFunction2(SkDisplayable* , int index, 
-               SkOpArray* params, SkDisplayTypes, SkOperand2*  ) {
-       SkASSERT(0); 
+        SkOpArray* params, SkDisplayTypes, SkOperand2*  ) {
+    SkASSERT(0); 
 }
 
 void SkDisplayable::getBounds(SkRect* rect) {
-       SkASSERT(rect);
-       rect->fLeft = rect->fTop = SK_ScalarMax;
-       rect->fRight= rect->fBottom = -SK_ScalarMax;
+    SkASSERT(rect);
+    rect->fLeft = rect->fTop = SK_ScalarMax;
+    rect->fRight= rect->fBottom = -SK_ScalarMax;
 }
 
 const SkFunctionParamType* SkDisplayable::getFunctionsParameters() {
-       return nil;
+    return nil;
 }
 
 const SkMemberInfo* SkDisplayable::getMember(int index) { 
-       return nil; 
+    return nil; 
 }
 
 const SkMemberInfo* SkDisplayable::getMember(const char name[]) { 
-       return nil; 
+    return nil; 
 }
 
 const SkFunctionParamType* SkDisplayable::getParameters(const SkMemberInfo* info, 
-               int* paramCount) {
-       const SkFunctionParamType* params = getFunctionsParameters();
-       SkASSERT(params != nil);
-       int funcIndex = info->functionIndex();
-       // !!! eventually break traversing params into an external function (maybe this whole function)
-       int index = funcIndex;
-       int offset = 0;
-       while (--index >= 0) {
-               while (params[offset] != 0)
-                       offset++;
-               offset++;
-       }
-       int count = 0;
-       while (params[offset] != 0) {
-               count++;
-               offset++;
-       }
-       *paramCount = count;
-       return &params[offset - count];
+        int* paramCount) {
+    const SkFunctionParamType* params = getFunctionsParameters();
+    SkASSERT(params != nil);
+    int funcIndex = info->functionIndex();
+    // !!! eventually break traversing params into an external function (maybe this whole function)
+    int index = funcIndex;
+    int offset = 0;
+    while (--index >= 0) {
+        while (params[offset] != 0)
+            offset++;
+        offset++;
+    }
+    int count = 0;
+    while (params[offset] != 0) {
+        count++;
+        offset++;
+    }
+    *paramCount = count;
+    return &params[offset - count];
 }
 
 SkDisplayable* SkDisplayable::getParent() const {
-       return nil;
+    return nil;
 }
 
 bool SkDisplayable::getProperty(int index, SkScriptValue* ) const {
-//     SkASSERT(0); 
-       return false; 
+//  SkASSERT(0); 
+    return false; 
 }
 
 bool SkDisplayable::getProperty2(int index, SkOperand2* value) const {
-       SkASSERT(0); 
-       return false; 
+    SkASSERT(0); 
+    return false; 
 }
 
 SkDisplayTypes SkDisplayable::getType() const { 
-       return SkType_Unknown; 
+    return SkType_Unknown; 
 }
 
 bool SkDisplayable::hasEnable() const {
-       return false;
+    return false;
 }
 
 bool SkDisplayable::isDrawable() const {
-       return false; 
+    return false; 
 }
 
 void SkDisplayable::onEndElement(SkAnimateMaker& ) {}
 
 const SkMemberInfo* SkDisplayable::preferredChild(SkDisplayTypes type) {
-       return nil;
+    return nil;
 }
 
 bool SkDisplayable::resolveIDs(SkAnimateMaker& maker, SkDisplayable* original, SkApply* apply) {
-       return false;
+    return false;
 }
 
 //SkDisplayable* SkDisplayable::resolveTarget(SkAnimateMaker& ) { 
-//     return this; 
+//  return this; 
 //}
 
 void SkDisplayable::setChildHasID() {
 }
 
 bool SkDisplayable::setParent(SkDisplayable* ) {
-       return false;
+    return false;
 }
 
 bool SkDisplayable::setProperty(int index, SkScriptValue& ) {
-       //SkASSERT(0); 
-       return false; 
+    //SkASSERT(0); 
+    return false; 
 }
 
 void SkDisplayable::setReference(const SkMemberInfo* info, SkDisplayable* displayable) {
-       if (info->fType == SkType_MemberProperty) {
-               SkScriptValue scriptValue;
-               scriptValue.fOperand.fDisplayable = displayable;
-               scriptValue.fType = displayable->getType();
-               setProperty(info->propertyIndex(), scriptValue);
-       } else if (info->fType == SkType_Array) {
-               SkASSERT(displayable->getType() == SkType_Array);
-               SkDisplayArray* dispArray = (SkDisplayArray*) displayable;
-               SkTDScalarArray* array = (SkTDScalarArray* ) info->memberData(this);
-               array->setCount(dispArray->values.count());
-               memcpy(array->begin(), dispArray->values.begin(), dispArray->values.count() * sizeof(int));
-               //
-
-               // !!! need a way for interpreter engine to own array
-               // !!! probably need to replace all scriptable arrays with single bigger array
-               // that has operand and type on every element -- or
-               // when array is dirtied, need to get parent to reparse to local array
-       } else {
-               void* storage = info->memberData(this);
-               memcpy(storage, &displayable, sizeof(SkDisplayable*));
-       }
+    if (info->fType == SkType_MemberProperty) {
+        SkScriptValue scriptValue;
+        scriptValue.fOperand.fDisplayable = displayable;
+        scriptValue.fType = displayable->getType();
+        setProperty(info->propertyIndex(), scriptValue);
+    } else if (info->fType == SkType_Array) {
+        SkASSERT(displayable->getType() == SkType_Array);
+        SkDisplayArray* dispArray = (SkDisplayArray*) displayable;
+        SkTDScalarArray* array = (SkTDScalarArray* ) info->memberData(this);
+        array->setCount(dispArray->values.count());
+        memcpy(array->begin(), dispArray->values.begin(), dispArray->values.count() * sizeof(int));
+        //
+
+        // !!! need a way for interpreter engine to own array
+        // !!! probably need to replace all scriptable arrays with single bigger array
+        // that has operand and type on every element -- or
+        // when array is dirtied, need to get parent to reparse to local array
+    } else {
+        void* storage = info->memberData(this);
+        memcpy(storage, &displayable, sizeof(SkDisplayable*));
+    }
 // !!! unclear why displayable is dirtied here
 // if this is called, this breaks fromPath.xml
-//     displayable->dirty();
+//  displayable->dirty();
 }
 
 #ifdef SK_DEBUG
index aea64b5..0c35d10 100644 (file)
@@ -1,3 +1,20 @@
+/* libs/graphics/animator/SkDisplayable.h
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #ifndef SkDisplayable_DEFINED
 #define SkDisplayable_DEFINED
 
@@ -20,78 +37,78 @@ union SkOperand2; // compiled scripting experiment
 class SkDisplayable {
 public:
 #ifdef SK_DEBUG
-       SkDisplayable();
+    SkDisplayable();
 #endif
-       virtual ~SkDisplayable();
-       virtual bool add(SkAnimateMaker& , SkDisplayable* child);
-       virtual bool canContainDependents() const;
-       virtual bool childrenNeedDisposing() const;
-       virtual void clearBounder();
-       virtual bool contains(SkDisplayable* );
-       virtual SkDisplayable* contains(const SkString& );
-       virtual SkDisplayable* deepCopy(SkAnimateMaker* );
-       virtual void dirty();
+    virtual ~SkDisplayable();
+    virtual bool add(SkAnimateMaker& , SkDisplayable* child);
+    virtual bool canContainDependents() const;
+    virtual bool childrenNeedDisposing() const;
+    virtual void clearBounder();
+    virtual bool contains(SkDisplayable* );
+    virtual SkDisplayable* contains(const SkString& );
+    virtual SkDisplayable* deepCopy(SkAnimateMaker* );
+    virtual void dirty();
 #ifdef SK_DUMP_ENABLED
-       virtual void dump(SkAnimateMaker* );
+    virtual void dump(SkAnimateMaker* );
     void dumpAttrs(SkAnimateMaker* );
     void dumpBase(SkAnimateMaker* );
     void dumpChildren(SkAnimateMaker* maker, bool closedAngle = false );
     void dumpEnd(SkAnimateMaker* );
-       virtual void dumpEvents();
+    virtual void dumpEvents();
 #endif
-       virtual bool enable( SkAnimateMaker& );
-       virtual void enableBounder();
-       virtual void executeFunction(SkDisplayable* , int functionIndex, 
-               SkTDArray<SkScriptValue>& , SkDisplayTypes , SkScriptValue* ); 
-       void executeFunction(SkDisplayable* , const SkMemberInfo* , 
-               SkTypedArray* , SkScriptValue* ); 
-       virtual void executeFunction2(SkDisplayable* , int functionIndex, 
-               SkOpArray* params , SkDisplayTypes , SkOperand2* ); // compiled scripting experiment
-       virtual void getBounds(SkRect* );
-       virtual const SkFunctionParamType* getFunctionsParameters();
-       virtual const SkMemberInfo* getMember(int index);
-       virtual const SkMemberInfo* getMember(const char name[]);
-       const SkFunctionParamType* getParameters(const SkMemberInfo* info, 
-               int* paramCount);
-       virtual SkDisplayable* getParent() const;
-       virtual bool getProperty(int index, SkScriptValue* value) const;
-       virtual bool getProperty2(int index, SkOperand2* value) const;    // compiled scripting experiment
-       virtual SkDisplayTypes getType() const;
-       virtual bool hasEnable() const;
-       bool isAnimate() const { 
-               SkDisplayTypes type = getType(); 
-               return type == SkType_Animate || type == SkType_Set; }
-       bool isApply() const { return getType() == SkType_Apply; }
-       bool isColor() const { return getType() == SkType_Color; }
-       virtual bool isDrawable() const;
-       bool isGroup() const { return getType() == SkType_Group || 
-               getType() == SkType_Save || getType() == SkType_DrawTo ||
+    virtual bool enable( SkAnimateMaker& );
+    virtual void enableBounder();
+    virtual void executeFunction(SkDisplayable* , int functionIndex, 
+        SkTDArray<SkScriptValue>& , SkDisplayTypes , SkScriptValue* ); 
+    void executeFunction(SkDisplayable* , const SkMemberInfo* , 
+        SkTypedArray* , SkScriptValue* ); 
+    virtual void executeFunction2(SkDisplayable* , int functionIndex, 
+        SkOpArray* params , SkDisplayTypes , SkOperand2* ); // compiled scripting experiment
+    virtual void getBounds(SkRect* );
+    virtual const SkFunctionParamType* getFunctionsParameters();
+    virtual const SkMemberInfo* getMember(int index);
+    virtual const SkMemberInfo* getMember(const char name[]);
+    const SkFunctionParamType* getParameters(const SkMemberInfo* info, 
+        int* paramCount);
+    virtual SkDisplayable* getParent() const;
+    virtual bool getProperty(int index, SkScriptValue* value) const;
+    virtual bool getProperty2(int index, SkOperand2* value) const;    // compiled scripting experiment
+    virtual SkDisplayTypes getType() const;
+    virtual bool hasEnable() const;
+    bool isAnimate() const { 
+        SkDisplayTypes type = getType(); 
+        return type == SkType_Animate || type == SkType_Set; }
+    bool isApply() const { return getType() == SkType_Apply; }
+    bool isColor() const { return getType() == SkType_Color; }
+    virtual bool isDrawable() const;
+    bool isGroup() const { return getType() == SkType_Group || 
+        getType() == SkType_Save || getType() == SkType_DrawTo ||
         getType() == SkType_SaveLayer; }
-       bool isMatrix() const { return getType() == SkType_Matrix; }
-       virtual bool isPaint() const { return getType() == SkType_Paint; }
-       virtual bool isPath() const { return false; }
-       bool isPost() const { return getType() == SkType_Post; }
-       virtual void onEndElement(SkAnimateMaker& );
-       virtual const SkMemberInfo* preferredChild(SkDisplayTypes type);
-       virtual bool resolveIDs(SkAnimateMaker& maker, SkDisplayable* original, SkApply* );
-       virtual void setChildHasID();
-       virtual bool setParent(SkDisplayable* );
-       virtual bool setProperty(int index, SkScriptValue& );
-       void setReference(const SkMemberInfo* info, SkDisplayable* ref);
+    bool isMatrix() const { return getType() == SkType_Matrix; }
+    virtual bool isPaint() const { return getType() == SkType_Paint; }
+    virtual bool isPath() const { return false; }
+    bool isPost() const { return getType() == SkType_Post; }
+    virtual void onEndElement(SkAnimateMaker& );
+    virtual const SkMemberInfo* preferredChild(SkDisplayTypes type);
+    virtual bool resolveIDs(SkAnimateMaker& maker, SkDisplayable* original, SkApply* );
+    virtual void setChildHasID();
+    virtual bool setParent(SkDisplayable* );
+    virtual bool setProperty(int index, SkScriptValue& );
+    void setReference(const SkMemberInfo* info, SkDisplayable* ref);
 #ifdef SK_DEBUG
-       bool isData() const { return getType() == SkType_Data; };
-       bool isEvent() const { return getType() == SkType_Event; }
-       virtual bool isMatrixPart() const { return false; }
-       bool isPatch() const { return getType() == SkType_3D_Patch; }
-       virtual bool isPaintPart() const { return false; }
-       virtual bool isPathPart() const { return false; }
-       virtual void validate();
-       SkString _id;
-       const char* id;
-//     static int fAllocationCount;
-       static SkTDDisplayableArray fAllocations;
+    bool isData() const { return getType() == SkType_Data; };
+    bool isEvent() const { return getType() == SkType_Event; }
+    virtual bool isMatrixPart() const { return false; }
+    bool isPatch() const { return getType() == SkType_3D_Patch; }
+    virtual bool isPaintPart() const { return false; }
+    virtual bool isPathPart() const { return false; }
+    virtual void validate();
+    SkString _id;
+    const char* id;
+//  static int fAllocationCount;
+    static SkTDDisplayableArray fAllocations;
 #else
-       void validate() {}
+    void validate() {}
 #endif
 #ifdef SK_DUMP_ENABLED
 private:
index 8a69445..8d003a9 100644 (file)
@@ -1,3 +1,20 @@
+/* libs/graphics/animator/SkDraw3D.cpp
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #include "SkDraw3D.h"
 #include "SkAnimateMaker.h"
 #include "SkCanvas.h"
@@ -6,9 +23,9 @@
 #if SK_USE_CONDENSED_INFO == 0
 
 const SkMemberInfo Sk3D_Point::fInfo[] = {
-       SK_MEMBER_ALIAS(x, fPoint.fX, Float),
-       SK_MEMBER_ALIAS(y, fPoint.fY, Float),
-       SK_MEMBER_ALIAS(z, fPoint.fZ, Float)
+    SK_MEMBER_ALIAS(x, fPoint.fX, Float),
+    SK_MEMBER_ALIAS(y, fPoint.fY, Float),
+    SK_MEMBER_ALIAS(z, fPoint.fZ, Float)
 };
 
 #endif
@@ -16,19 +33,19 @@ const SkMemberInfo Sk3D_Point::fInfo[] = {
 DEFINE_NO_VIRTUALS_GET_MEMBER(Sk3D_Point);
 
 Sk3D_Point::Sk3D_Point() {
-       fPoint.set(0, 0, 0);    
+    fPoint.set(0, 0, 0);    
 }
 
 #if SK_USE_CONDENSED_INFO == 0
 
 const SkMemberInfo Sk3D_Camera::fInfo[] = {
-       SK_MEMBER_ALIAS(axis, fCamera.fAxis, 3D_Point),
-       SK_MEMBER(hackHeight, Float),
-       SK_MEMBER(hackWidth, Float),
-       SK_MEMBER_ALIAS(location, fCamera.fLocation, 3D_Point),
-       SK_MEMBER_ALIAS(observer, fCamera.fObserver, 3D_Point),
-       SK_MEMBER(patch, 3D_Patch),
-       SK_MEMBER_ALIAS(zenith, fCamera.fZenith, 3D_Point),
+    SK_MEMBER_ALIAS(axis, fCamera.fAxis, 3D_Point),
+    SK_MEMBER(hackHeight, Float),
+    SK_MEMBER(hackWidth, Float),
+    SK_MEMBER_ALIAS(location, fCamera.fLocation, 3D_Point),
+    SK_MEMBER_ALIAS(observer, fCamera.fObserver, 3D_Point),
+    SK_MEMBER(patch, 3D_Patch),
+    SK_MEMBER_ALIAS(zenith, fCamera.fZenith, 3D_Point),
 };
 
 #endif
@@ -42,34 +59,34 @@ Sk3D_Camera::~Sk3D_Camera() {
 }
 
 bool Sk3D_Camera::draw(SkAnimateMaker& maker) {
-       fCamera.update();
-       SkMatrix matrix;
-       fCamera.computeMatrix(patch->fPatch, &matrix);
-       matrix.preTranslate(hackWidth / 2, -hackHeight / 2);
-       matrix.postTranslate(hackWidth / 2, hackHeight / 2);
-       maker.fCanvas->concat(matrix);
-       return false;
+    fCamera.update();
+    SkMatrix matrix;
+    fCamera.patchToMatrix(patch->fPatch, &matrix);
+    matrix.preTranslate(hackWidth / 2, -hackHeight / 2);
+    matrix.postTranslate(hackWidth / 2, hackHeight / 2);
+    maker.fCanvas->concat(matrix);
+    return false;
 }
 
 
 enum Sk3D_Patch_Functions {
-       SK_FUNCTION(rotateDegrees)
+    SK_FUNCTION(rotateDegrees)
 };
 
 const SkFunctionParamType Sk3D_Patch::fFunctionParameters[] = {
-       (SkFunctionParamType) SkType_Float,
-       (SkFunctionParamType) SkType_Float,
-       (SkFunctionParamType) SkType_Float,
-       (SkFunctionParamType) 0 // terminator for parameter list (there may be multiple parameter lists)
+    (SkFunctionParamType) SkType_Float,
+    (SkFunctionParamType) SkType_Float,
+    (SkFunctionParamType) SkType_Float,
+    (SkFunctionParamType) 0 // terminator for parameter list (there may be multiple parameter lists)
 };
 
 #if SK_USE_CONDENSED_INFO == 0
 
 const SkMemberInfo Sk3D_Patch::fInfo[] = {
-       SK_MEMBER_ALIAS(origin, fPatch.fOrigin, 3D_Point),
-       SK_MEMBER_FUNCTION(rotateDegrees, Float),
-       SK_MEMBER_ALIAS(u, fPatch.fU, 3D_Point),
-       SK_MEMBER_ALIAS(v, fPatch.fV, 3D_Point)
+    SK_MEMBER_ALIAS(origin, fPatch.fOrigin, 3D_Point),
+    SK_MEMBER_FUNCTION(rotateDegrees, Float),
+    SK_MEMBER_ALIAS(u, fPatch.fU, 3D_Point),
+    SK_MEMBER_ALIAS(v, fPatch.fV, 3D_Point)
 };
 
 #endif
@@ -77,23 +94,23 @@ const SkMemberInfo Sk3D_Patch::fInfo[] = {
 DEFINE_GET_MEMBER(Sk3D_Patch);
 
 void Sk3D_Patch::executeFunction(SkDisplayable* target, int index, 
-               SkTDArray<SkScriptValue>& parameters, SkDisplayTypes type,
-               SkScriptValue* ) {
-       SkASSERT(target == this);
-       switch (index) {
-               case SK_FUNCTION(rotateDegrees):
-                       SkASSERT(parameters.count() == 3);
-                       SkASSERT(type == SkType_Float);
-                       fPatch.rotateDegrees(parameters[0].fOperand.fScalar, 
-                               parameters[1].fOperand.fScalar, parameters[2].fOperand.fScalar);
-                       break;
-               default:
-                       SkASSERT(0);
-       }
+        SkTDArray<SkScriptValue>& parameters, SkDisplayTypes type,
+        SkScriptValue* ) {
+    SkASSERT(target == this);
+    switch (index) {
+        case SK_FUNCTION(rotateDegrees):
+            SkASSERT(parameters.count() == 3);
+            SkASSERT(type == SkType_Float);
+            fPatch.rotateDegrees(parameters[0].fOperand.fScalar, 
+                parameters[1].fOperand.fScalar, parameters[2].fOperand.fScalar);
+            break;
+        default:
+            SkASSERT(0);
+    }
 }
 
 const SkFunctionParamType* Sk3D_Patch::getFunctionsParameters() {
-       return fFunctionParameters;
+    return fFunctionParameters;
 }
 
 
index 55f7664..b9be37e 100644 (file)
@@ -1,3 +1,20 @@
+/* libs/graphics/animator/SkDraw3D.h
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #ifndef SkDraw3D_DEFINED
 #define SkDraw3D_DEFINED
 
 class Sk3D_Patch;
 
 struct Sk3D_Point {
-       DECLARE_NO_VIRTUALS_MEMBER_INFO(3D_Point);
-       Sk3D_Point();
+    DECLARE_NO_VIRTUALS_MEMBER_INFO(3D_Point);
+    Sk3D_Point();
 private:
-       SkPoint3D fPoint;
+    SkPoint3D fPoint;
 };
 
 class Sk3D_Camera : public SkDrawable {
-       DECLARE_MEMBER_INFO(3D_Camera);
-       Sk3D_Camera();
-       virtual ~Sk3D_Camera();
-       virtual bool draw(SkAnimateMaker& );
+    DECLARE_MEMBER_INFO(3D_Camera);
+    Sk3D_Camera();
+    virtual ~Sk3D_Camera();
+    virtual bool draw(SkAnimateMaker& );
 private:
-       SkScalar hackWidth;
-       SkScalar hackHeight;
-       SkCamera3D fCamera;
-       Sk3D_Patch* patch;
+    SkScalar hackWidth;
+    SkScalar hackHeight;
+    SkCamera3D fCamera;
+    Sk3D_Patch* patch;
 };
 
 class Sk3D_Patch : public SkDisplayable {
-       DECLARE_MEMBER_INFO(3D_Patch);
+    DECLARE_MEMBER_INFO(3D_Patch);
 private:
-       virtual void executeFunction(SkDisplayable* , int index, 
-               SkTDArray<SkScriptValue>& parameters, SkDisplayTypes type,
-               SkScriptValue* );
-       virtual const SkFunctionParamType* getFunctionsParameters();
-       SkPatch3D  fPatch;
-       static const SkFunctionParamType fFunctionParameters[];
-       friend class Sk3D_Camera;
+    virtual void executeFunction(SkDisplayable* , int index, 
+        SkTDArray<SkScriptValue>& parameters, SkDisplayTypes type,
+        SkScriptValue* );
+    virtual const SkFunctionParamType* getFunctionsParameters();
+    SkPatch3D  fPatch;
+    static const SkFunctionParamType fFunctionParameters[];
+    friend class Sk3D_Camera;
 };
 
 #endif // SkDraw3D_DEFINED
index 3ad4e00..47d5736 100644 (file)
@@ -1,3 +1,20 @@
+/* libs/graphics/animator/SkDrawBitmap.cpp
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #include "SkDrawBitmap.h"
 #include "SkAnimateMaker.h"
 #include "SkCanvas.h"
@@ -8,8 +25,8 @@
 #if SK_USE_CONDENSED_INFO == 0
 
 const SkMemberInfo SkBaseBitmap::fInfo[] = {
-       SK_MEMBER(x, Float),
-       SK_MEMBER(y, Float)
+    SK_MEMBER(x, Float),
+    SK_MEMBER(y, Float)
 };
 
 #endif
@@ -23,24 +40,24 @@ SkBaseBitmap::~SkBaseBitmap() {
 }
 
 bool SkBaseBitmap::draw(SkAnimateMaker& maker) {
-       SkBoundableAuto boundable(this, maker);
-       maker.fCanvas->drawBitmap(fBitmap, x, y, *maker.fPaint);
-       return false;
+    SkBoundableAuto boundable(this, maker);
+    maker.fCanvas->drawBitmap(fBitmap, x, y, *maker.fPaint);
+    return false;
 }
 
 enum SkDrawBitmap_Properties {
-       SK_PROPERTY(erase)
+    SK_PROPERTY(erase)
 };
 
 #if SK_USE_CONDENSED_INFO == 0
 
 const SkMemberInfo SkDrawBitmap::fInfo[] = {
-       SK_MEMBER_INHERITED,
-       SK_MEMBER_PROPERTY(erase, ARGB),
-       SK_MEMBER(format, BitmapFormat),
-       SK_MEMBER(height, Int),
-       SK_MEMBER(rowBytes, Int),
-       SK_MEMBER(width, Int),
+    SK_MEMBER_INHERITED,
+    SK_MEMBER_PROPERTY(erase, ARGB),
+    SK_MEMBER(format, BitmapFormat),
+    SK_MEMBER(height, Int),
+    SK_MEMBER(rowBytes, Int),
+    SK_MEMBER(width, Int),
 };
 
 #endif
@@ -48,7 +65,7 @@ const SkMemberInfo SkDrawBitmap::fInfo[] = {
 DEFINE_GET_MEMBER(SkDrawBitmap);
 
 SkDrawBitmap::SkDrawBitmap() : format((SkBitmap::Config) -1), height(-1), 
-       rowBytes(0),    width(-1), fColor(0), fColorSet(false) {
+    rowBytes(0),    width(-1), fColor(0), fColorSet(false) {
 }
 
 SkDrawBitmap::~SkDrawBitmap() {
@@ -77,45 +94,45 @@ void SkDrawBitmap::dump(SkAnimateMaker* maker) {
 #endif
 
 void SkDrawBitmap::onEndElement(SkAnimateMaker& maker) {
-       SkASSERT(format != (SkBitmap::Config) -1);
-       SkASSERT(width != -1);
-       SkASSERT(height != -1);
-       SkASSERT(rowBytes >= 0);
-       fBitmap.setConfig((SkBitmap::Config) format, width, height, rowBytes);
-       fBitmap.allocPixels();
-       if (fColorSet)
-               fBitmap.eraseColor(fColor);
+    SkASSERT(format != (SkBitmap::Config) -1);
+    SkASSERT(width != -1);
+    SkASSERT(height != -1);
+    SkASSERT(rowBytes >= 0);
+    fBitmap.setConfig((SkBitmap::Config) format, width, height, rowBytes);
+    fBitmap.allocPixels();
+    if (fColorSet)
+        fBitmap.eraseColor(fColor);
 }
 
 bool SkDrawBitmap::setProperty(int index, SkScriptValue& value)
 {
-       switch (index) {
-               case SK_PROPERTY(erase):
-                       SkASSERT(value.fType == SkType_ARGB);
-                       fColor = value.fOperand.fS32;
-                       fColorSet = true;
-                       break;
-               default:
-                       SkASSERT(0);
-                       return false;
-       }
-       return true;
+    switch (index) {
+        case SK_PROPERTY(erase):
+            SkASSERT(value.fType == SkType_ARGB);
+            fColor = value.fOperand.fS32;
+            fColorSet = true;
+            break;
+        default:
+            SkASSERT(0);
+            return false;
+    }
+    return true;
 }
 
 
 enum SkImage_Properties {
-       SK_PROPERTY(height),
-       SK_PROPERTY(width)
+    SK_PROPERTY(height),
+    SK_PROPERTY(width)
 };
 
 #if SK_USE_CONDENSED_INFO == 0
 
 const SkMemberInfo SkImage::fInfo[] = {
-       SK_MEMBER_INHERITED,
-       SK_MEMBER(base64, Base64),
-       SK_MEMBER_PROPERTY(height, Int),
-       SK_MEMBER(src, String),
-       SK_MEMBER_PROPERTY(width, Int)
+    SK_MEMBER_INHERITED,
+    SK_MEMBER(base64, Base64),
+    SK_MEMBER_PROPERTY(height, Int),
+    SK_MEMBER(src, String),
+    SK_MEMBER_PROPERTY(width, Int)
 };
 
 #endif
@@ -123,12 +140,12 @@ const SkMemberInfo SkImage::fInfo[] = {
 DEFINE_GET_MEMBER(SkImage);
 
 SkImage::SkImage() : fDirty(true), fUriBase(nil) {
-       base64.fData = nil;
-       base64.fLength = 0;
+    base64.fData = nil;
+    base64.fLength = 0;
 }
 
 SkImage::~SkImage() {
-       delete[] base64.fData; 
+    delete[] base64.fData; 
 }
 
 SkDisplayable* SkImage::deepCopy(SkAnimateMaker* maker) {
@@ -138,49 +155,49 @@ SkDisplayable* SkImage::deepCopy(SkAnimateMaker* maker) {
 }
 
 void SkImage::dirty() {
-       fDirty = true;
+    fDirty = true;
 }
 
 bool SkImage::draw(SkAnimateMaker& maker) {
-       if (fDirty) 
-               resolve();
-       return INHERITED::draw(maker);
+    if (fDirty) 
+        resolve();
+    return INHERITED::draw(maker);
 }
 
 bool SkImage::getProperty(int index, SkScriptValue* value) const {
-       if (fDirty) 
-               resolve();
-       switch (index) {
-               case SK_PROPERTY(height):
-                       value->fOperand.fS32 = fBitmap.height();
-                       break;
-               case SK_PROPERTY(width):
-                       value->fOperand.fS32 = fBitmap.width();
-                       break;
-       default:
-               SkASSERT(0);
-               return false;
-       }
-       value->fType = SkType_Int;
-       return true;
+    if (fDirty) 
+        resolve();
+    switch (index) {
+        case SK_PROPERTY(height):
+            value->fOperand.fS32 = fBitmap.height();
+            break;
+        case SK_PROPERTY(width):
+            value->fOperand.fS32 = fBitmap.width();
+            break;
+    default:
+        SkASSERT(0);
+        return false;
+    }
+    value->fType = SkType_Int;
+    return true;
 }
 
 void SkImage::onEndElement(SkAnimateMaker& maker) {
-       fUriBase = maker.fPrefix.c_str();
+    fUriBase = maker.fPrefix.c_str();
 }
 
 void SkImage::resolve() {
-       fDirty = false;
-       if (base64.fData) {
-               fBitmap.reset();
-               SkImageDecoder::DecodeMemory(base64.fData, base64.fLength, &fBitmap);
-       } else if (src.size()) {
-               if (fLast.equals(src))
-                       return;
-               fLast.set(src);
-               fBitmap.reset();
-               SkStream* stream = SkStream::GetURIStream(fUriBase, src.c_str());
-               SkAutoTDelete<SkStream> autoDel(stream);
-               SkImageDecoder::DecodeStream(stream, &fBitmap);
-       }       
+    fDirty = false;
+    if (base64.fData) {
+        fBitmap.reset();
+        SkImageDecoder::DecodeMemory(base64.fData, base64.fLength, &fBitmap);
+    } else if (src.size()) {
+        if (fLast.equals(src))
+            return;
+        fLast.set(src);
+        fBitmap.reset();
+        SkStream* stream = SkStream::GetURIStream(fUriBase, src.c_str());
+        SkAutoTDelete<SkStream> autoDel(stream);
+        SkImageDecoder::DecodeStream(stream, &fBitmap);
+    }   
 }
index f5ef330..6a064f0 100644 (file)
@@ -1,3 +1,20 @@
+/* libs/graphics/animator/SkDrawBitmap.h
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #ifndef SkDrawBitmap_DEFINED
 #define SkDrawBitmap_DEFINED
 
 #include "SkMemberInfo.h"
 
 class SkBaseBitmap : public SkBoundable {
-       DECLARE_MEMBER_INFO(BaseBitmap);
-       SkBaseBitmap();
-       virtual ~SkBaseBitmap();
-       virtual bool draw(SkAnimateMaker& );
+    DECLARE_MEMBER_INFO(BaseBitmap);
+    SkBaseBitmap();
+    virtual ~SkBaseBitmap();
+    virtual bool draw(SkAnimateMaker& );
 protected:
-       SkBitmap fBitmap;
-       SkScalar x;
-       SkScalar y;
+    SkBitmap fBitmap;
+    SkScalar x;
+    SkScalar y;
 private:
-       friend class SkDrawTo;
-       friend class SkDrawBitmapShader;
-       typedef SkBoundable INHERITED;
+    friend class SkDrawTo;
+    friend class SkDrawBitmapShader;
+    typedef SkBoundable INHERITED;
 };
 
 class SkDrawBitmap : public SkBaseBitmap {
-       DECLARE_DRAW_MEMBER_INFO(Bitmap);
-       SkDrawBitmap();
-       virtual ~SkDrawBitmap();
+    DECLARE_DRAW_MEMBER_INFO(Bitmap);
+    SkDrawBitmap();
+    virtual ~SkDrawBitmap();
 #ifdef SK_DUMP_ENABLED
     virtual void dump(SkAnimateMaker* );
 #endif
-       virtual void onEndElement(SkAnimateMaker& );
-       virtual bool setProperty(int index, SkScriptValue& value);
+    virtual void onEndElement(SkAnimateMaker& );
+    virtual bool setProperty(int index, SkScriptValue& value);
 protected:
-       int /*SkBitmap::Config*/ format;
-       S32 height;
-       S32 rowBytes;
-       S32 width;
-       SkColor fColor;
-       SkBool fColorSet;
-       typedef SkBaseBitmap INHERITED;
+    int /*SkBitmap::Config*/ format;
+    S32 height;
+    S32 rowBytes;
+    S32 width;
+    SkColor fColor;
+    SkBool fColorSet;
+    typedef SkBaseBitmap INHERITED;
 };
 
 class SkImage : public SkBaseBitmap {
-       DECLARE_MEMBER_INFO(Image);
-       SkImage();
-       virtual ~SkImage();
+    DECLARE_MEMBER_INFO(Image);
+    SkImage();
+    virtual ~SkImage();
     virtual SkDisplayable* deepCopy(SkAnimateMaker* );
-       virtual void dirty();
-       virtual bool draw(SkAnimateMaker& );
-       virtual bool getProperty(int index, SkScriptValue* value) const;
-       virtual void onEndElement(SkAnimateMaker& maker);
+    virtual void dirty();
+    virtual bool draw(SkAnimateMaker& );
+    virtual bool getProperty(int index, SkScriptValue* value) const;
+    virtual void onEndElement(SkAnimateMaker& maker);
 private:
-       void resolve() const { (const_cast<SkImage*>(this))->resolve(); }
-       void resolve();
+    void resolve() const { (const_cast<SkImage*>(this))->resolve(); }
+    void resolve();
 protected:
-       SkBase64 base64;
-       SkString src;
-       SkString fLast; // cache of src so that stream isn't unnecessarily decoded 
-       SkBool fDirty;
-       const char* fUriBase;
-       typedef SkBaseBitmap INHERITED;
+    SkBase64 base64;
+    SkString src;
+    SkString fLast; // cache of src so that stream isn't unnecessarily decoded 
+    SkBool fDirty;
+    const char* fUriBase;
+    typedef SkBaseBitmap INHERITED;
 };
 
 #endif // SkDrawBitmap_DEFINED
index 170a770..23ef8c7 100644 (file)
@@ -1,10 +1,27 @@
+/* libs/graphics/animator/SkDrawBlur.cpp
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #include "SkDrawBlur.h"
 
 #if SK_USE_CONDENSED_INFO == 0
 
 const SkMemberInfo SkDrawBlur::fInfo[] = {
-       SK_MEMBER(blurStyle, MaskFilterBlurStyle),
-       SK_MEMBER(radius, Float)
+    SK_MEMBER(blurStyle, MaskFilterBlurStyle),
+    SK_MEMBER(radius, Float)
 };
 
 #endif
@@ -12,12 +29,12 @@ const SkMemberInfo SkDrawBlur::fInfo[] = {
 DEFINE_GET_MEMBER(SkDrawBlur);
 
 SkDrawBlur::SkDrawBlur() : radius(-1), 
-       blurStyle(SkBlurMaskFilter::kNormal_BlurStyle) {
+    blurStyle(SkBlurMaskFilter::kNormal_BlurStyle) {
 }
 
 SkMaskFilter* SkDrawBlur::getMaskFilter() {
-       if (radius < 0)
-               return nil;
-       return SkBlurMaskFilter::Create(radius, (SkBlurMaskFilter::BlurStyle) blurStyle);
+    if (radius < 0)
+        return nil;
+    return SkBlurMaskFilter::Create(radius, (SkBlurMaskFilter::BlurStyle) blurStyle);
 }
 
index 4bfb268..5a6e8b3 100644 (file)
@@ -1,3 +1,20 @@
+/* libs/graphics/animator/SkDrawBlur.h
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #ifndef SkDrawBlur_DEFINED
 #define SkDrawBlur_DEFINED
 
 #include "SkBlurMaskFilter.h"
 
 class SkDrawBlur : public SkDrawMaskFilter {
-       DECLARE_DRAW_MEMBER_INFO(Blur);
-       SkDrawBlur();
-       virtual SkMaskFilter* getMaskFilter();
+    DECLARE_DRAW_MEMBER_INFO(Blur);
+    SkDrawBlur();
+    virtual SkMaskFilter* getMaskFilter();
 protected:
-       SkScalar radius;
-       int /*SkBlurMaskFilter::BlurStyle*/ blurStyle;
+    SkScalar radius;
+    int /*SkBlurMaskFilter::BlurStyle*/ blurStyle;
 };
 
 #endif // SkDrawBlur_DEFINED
index 4717501..15fb372 100644 (file)
@@ -1,3 +1,20 @@
+/* libs/graphics/animator/SkDrawClip.cpp
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #include "SkDrawClip.h"
 #include "SkAnimateMaker.h"
 #include "SkCanvas.h"
@@ -8,8 +25,8 @@
 #if SK_USE_CONDENSED_INFO == 0
 
 const SkMemberInfo SkDrawClip::fInfo[] = {
-       SK_MEMBER(path, Path),
-       SK_MEMBER(rect, Rect)
+    SK_MEMBER(path, Path),
+    SK_MEMBER(rect, Rect)
 };
 
 #endif
@@ -20,12 +37,12 @@ SkDrawClip::SkDrawClip() : rect(nil), path(nil) {
 }
 
 bool SkDrawClip::draw(SkAnimateMaker& maker ) {
-       if (rect != nil)
-               maker.fCanvas->clipRect(rect->fRect);
-       else {
-               SkASSERT(path != nil);
-               maker.fCanvas->clipPath(path->fPath);
-       }
-       return false;
+    if (rect != nil)
+        maker.fCanvas->clipRect(rect->fRect);
+    else {
+        SkASSERT(path != nil);
+        maker.fCanvas->clipPath(path->fPath);
+    }
+    return false;
 }
 
index 6c89666..c19694b 100644 (file)
@@ -1,3 +1,20 @@
+/* libs/graphics/animator/SkDrawClip.h
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #ifndef SkDrawClip_DEFINED
 #define SkDrawClip_DEFINED
 
@@ -9,12 +26,12 @@ class SkDrawPath;
 class SkDrawRect;
 
 class SkDrawClip : public SkDrawable {
-       DECLARE_DRAW_MEMBER_INFO(Clip);
-       SkDrawClip();
-       virtual bool draw(SkAnimateMaker& );
+    DECLARE_DRAW_MEMBER_INFO(Clip);
+    SkDrawClip();
+    virtual bool draw(SkAnimateMaker& );
 private:
-       SkDrawRect* rect;
-       SkDrawPath* path;
+    SkDrawRect* rect;
+    SkDrawPath* path;
 };
 
 #endif // SkDrawClip_DEFINED
index a21bde4..c7baf4f 100644 (file)
@@ -1,3 +1,20 @@
+/* libs/graphics/animator/SkDrawColor.cpp
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #include "SkDrawColor.h"
 #ifdef SK_DEBUG
 #include "SkDisplayList.h"
 #include "SkScript.h"
 
 enum HSV_Choice {
-       kGetHue,
-       kGetSaturation,
-       kGetValue
+    kGetHue,
+    kGetSaturation,
+    kGetValue
 };
 
 static SkScalar RGB_to_HSV(SkColor color, HSV_Choice choice) {
-       SkScalar red = SkIntToScalar(SkColorGetR(color));
-       SkScalar green = SkIntToScalar(SkColorGetG(color));
-       SkScalar blue = SkIntToScalar(SkColorGetB(color));
-       SkScalar min = SkMinScalar(SkMinScalar(red, green), blue);
-       SkScalar value = SkMaxScalar(SkMaxScalar(red, green), blue);
-       if (choice == kGetValue)
-               return value/255;
-       SkScalar delta = value - min;
-       SkScalar saturation = value == 0 ? 0 : SkScalarDiv(delta, value);
-       if (choice == kGetSaturation)
-               return saturation;
-       SkScalar hue;
-       if (saturation == 0)
-               hue = 0;
-       else {
-               SkScalar part60 = SkScalarDiv(60 * SK_Scalar1, delta);
-               if (red == value) {
-                       hue = SkScalarMul(green - blue, part60);
-                       if (hue < 0)
-                               hue += 360 * SK_Scalar1;
-               }
-               else if (green == value)
-                       hue = 120 * SK_Scalar1 + SkScalarMul(blue - red, part60);
-               else  // blue == value
-                       hue = 240 * SK_Scalar1 + SkScalarMul(red - green, part60);
-       }
-       SkASSERT(choice == kGetHue);
-       return hue;
+    SkScalar red = SkIntToScalar(SkColorGetR(color));
+    SkScalar green = SkIntToScalar(SkColorGetG(color));
+    SkScalar blue = SkIntToScalar(SkColorGetB(color));
+    SkScalar min = SkMinScalar(SkMinScalar(red, green), blue);
+    SkScalar value = SkMaxScalar(SkMaxScalar(red, green), blue);
+    if (choice == kGetValue)
+        return value/255;
+    SkScalar delta = value - min;
+    SkScalar saturation = value == 0 ? 0 : SkScalarDiv(delta, value);
+    if (choice == kGetSaturation)
+        return saturation;
+    SkScalar hue;
+    if (saturation == 0)
+        hue = 0;
+    else {
+        SkScalar part60 = SkScalarDiv(60 * SK_Scalar1, delta);
+        if (red == value) {
+            hue = SkScalarMul(green - blue, part60);
+            if (hue < 0)
+                hue += 360 * SK_Scalar1;
+        }
+        else if (green == value)
+            hue = 120 * SK_Scalar1 + SkScalarMul(blue - red, part60);
+        else  // blue == value
+            hue = 240 * SK_Scalar1 + SkScalarMul(red - green, part60);
+    }
+    SkASSERT(choice == kGetHue);
+    return hue;
 }
 
-#if defined _WIN32 && _MSC_VER >= 1300 // disable 'red', etc. may be used without having been initialized
+#if defined _WIN32 && _MSC_VER >= 1300  // disable 'red', etc. may be used without having been initialized
 #pragma warning ( push )
 #pragma warning ( disable : 4701 )
 #endif
 
 static SkColor HSV_to_RGB(SkColor color, HSV_Choice choice, SkScalar hsv) {
-       SkScalar hue = choice == kGetHue ? hsv : RGB_to_HSV(color, kGetHue);
-       SkScalar saturation = choice == kGetSaturation ? hsv : RGB_to_HSV(color, kGetSaturation);
-       SkScalar value = choice == kGetValue ? hsv : RGB_to_HSV(color, kGetValue);
-       value *= 255;
-       SkScalar red SK_INIT_TO_AVOID_WARNING;
-       SkScalar green SK_INIT_TO_AVOID_WARNING;
-       SkScalar blue SK_INIT_TO_AVOID_WARNING;
-       if (saturation == 0)    // color is on black-and-white center line
-               red = green = blue = value;
-       else {
-               //SkScalar fraction = SkScalarMod(hue, 60 * SK_Scalar1);
-               int sextant = SkScalarFloor(hue / 60);
-               SkScalar fraction = hue / 60 - SkIntToScalar(sextant);
-               SkScalar p = SkScalarMul(value , SK_Scalar1 - saturation);
-               SkScalar q = SkScalarMul(value, SK_Scalar1 - SkScalarMul(saturation, fraction));
-               SkScalar t = SkScalarMul(value, SK_Scalar1 - 
-                       SkScalarMul(saturation, SK_Scalar1 - fraction));
-               switch (sextant % 6) {
-                       case 0: red = value; green = t; blue = p; break;
-                       case 1: red = q; green = value; blue = p; break;
-                       case 2: red = p; green = value; blue = t; break;
-                       case 3: red = p; green = q; blue = value; break;
-                       case 4: red = t;  green = p; blue = value; break;
-                       case 5: red = value; green = p; blue = q; break;
-               }
-       }
-       //used to say SkToU8((U8CPU) red) etc
-       return SkColorSetARGB(SkColorGetA(color), SkScalarRound(red), 
-               SkScalarRound(green), SkScalarRound(blue));
+    SkScalar hue = choice == kGetHue ? hsv : RGB_to_HSV(color, kGetHue);
+    SkScalar saturation = choice == kGetSaturation ? hsv : RGB_to_HSV(color, kGetSaturation);
+    SkScalar value = choice == kGetValue ? hsv : RGB_to_HSV(color, kGetValue);
+    value *= 255;
+    SkScalar red SK_INIT_TO_AVOID_WARNING;
+    SkScalar green SK_INIT_TO_AVOID_WARNING;
+    SkScalar blue SK_INIT_TO_AVOID_WARNING;
+    if (saturation == 0)    // color is on black-and-white center line
+        red = green = blue = value;
+    else {
+        //SkScalar fraction = SkScalarMod(hue, 60 * SK_Scalar1);
+        int sextant = SkScalarFloor(hue / 60);
+        SkScalar fraction = hue / 60 - SkIntToScalar(sextant);
+        SkScalar p = SkScalarMul(value , SK_Scalar1 - saturation);
+        SkScalar q = SkScalarMul(value, SK_Scalar1 - SkScalarMul(saturation, fraction));
+        SkScalar t = SkScalarMul(value, SK_Scalar1 - 
+            SkScalarMul(saturation, SK_Scalar1 - fraction));
+        switch (sextant % 6) {
+            case 0: red = value; green = t; blue = p; break;
+            case 1: red = q; green = value; blue = p; break;
+            case 2: red = p; green = value; blue = t; break;
+            case 3: red = p; green = q; blue = value; break;
+            case 4: red = t;  green = p; blue = value; break;
+            case 5: red = value; green = p; blue = q; break;
+        }
+    }
+    //used to say SkToU8((U8CPU) red) etc
+    return SkColorSetARGB(SkColorGetA(color), SkScalarRound(red), 
+        SkScalarRound(green), SkScalarRound(blue));
 }
 
-#if defined _WIN32 && _MSC_VER >= 1300 
+#if defined _WIN32 && _MSC_VER >= 1300  
 #pragma warning ( pop )
 #endif
 
 enum SkDrawColor_Properties {
-       SK_PROPERTY(alpha),
-       SK_PROPERTY(blue),
-       SK_PROPERTY(green),
-       SK_PROPERTY(hue),
-       SK_PROPERTY(red),
-       SK_PROPERTY(saturation),
-       SK_PROPERTY(value)
+    SK_PROPERTY(alpha),
+    SK_PROPERTY(blue),
+    SK_PROPERTY(green),
+    SK_PROPERTY(hue),
+    SK_PROPERTY(red),
+    SK_PROPERTY(saturation),
+    SK_PROPERTY(value)
 };
 
 #if SK_USE_CONDENSED_INFO == 0
 
 const SkMemberInfo SkDrawColor::fInfo[] = {
-       SK_MEMBER_PROPERTY(alpha, Float),
-       SK_MEMBER_PROPERTY(blue, Float),
-       SK_MEMBER(color, ARGB),
-       SK_MEMBER_PROPERTY(green, Float),
-       SK_MEMBER_PROPERTY(hue, Float),
-       SK_MEMBER_PROPERTY(red, Float),
-       SK_MEMBER_PROPERTY(saturation, Float),
-       SK_MEMBER_PROPERTY(value, Float),
+    SK_MEMBER_PROPERTY(alpha, Float),
+    SK_MEMBER_PROPERTY(blue, Float),
+    SK_MEMBER(color, ARGB),
+    SK_MEMBER_PROPERTY(green, Float),
+    SK_MEMBER_PROPERTY(hue, Float),
+    SK_MEMBER_PROPERTY(red, Float),
+    SK_MEMBER_PROPERTY(saturation, Float),
+    SK_MEMBER_PROPERTY(value, Float),
 };
 
 #endif
@@ -112,150 +129,150 @@ const SkMemberInfo SkDrawColor::fInfo[] = {
 DEFINE_GET_MEMBER(SkDrawColor);
 
 SkDrawColor::SkDrawColor() : fDirty(false) { 
-       color = SK_ColorBLACK; 
-       fHue = fSaturation = fValue = SK_ScalarNaN;
+    color = SK_ColorBLACK; 
+    fHue = fSaturation = fValue = SK_ScalarNaN;
 }
 
 bool SkDrawColor::add() {
-       if (fPaint->color != nil)
-               return true; // error (probably color in paint as attribute as well)
-       fPaint->color = this;
-       fPaint->fOwnsColor = true;
-       return false;
+    if (fPaint->color != nil)
+        return true; // error (probably color in paint as attribute as well)
+    fPaint->color = this;
+    fPaint->fOwnsColor = true;
+    return false;
 }
 
 SkDisplayable* SkDrawColor::deepCopy(SkAnimateMaker* maker) {
-       SkDrawColor* copy = new SkDrawColor();
-       copy->color = color;
-       copy->fHue = fHue;
-       copy->fSaturation = fSaturation;
-       copy->fValue = fValue;
-       copy->fDirty = fDirty;
-       return copy;
+    SkDrawColor* copy = new SkDrawColor();
+    copy->color = color;
+    copy->fHue = fHue;
+    copy->fSaturation = fSaturation;
+    copy->fValue = fValue;
+    copy->fDirty = fDirty;
+    return copy;
 }
 
 void SkDrawColor::dirty(){
-       fDirty = true;
+    fDirty = true;
 }
 
 #ifdef SK_DUMP_ENABLED
 void SkDrawColor::dump(SkAnimateMaker* maker) {
-       dumpBase(maker);
-       SkDebugf("alpha=\"%d\" red=\"%d\" green=\"%d\" blue=\"%d\" />\n",  
-               SkColorGetA(color)/255, SkColorGetR(color),
-               SkColorGetG(color), SkColorGetB(color));
+    dumpBase(maker);
+    SkDebugf("alpha=\"%d\" red=\"%d\" green=\"%d\" blue=\"%d\" />\n",  
+        SkColorGetA(color)/255, SkColorGetR(color),
+        SkColorGetG(color), SkColorGetB(color));
 }
 #endif
 
 SkColor SkDrawColor::getColor() { 
-       if (fDirty) {
-               if (SkScalarIsNaN(fValue) == false)
-                       color = HSV_to_RGB(color, kGetValue, fValue);
-               if (SkScalarIsNaN(fSaturation) == false)
-                       color = HSV_to_RGB(color, kGetSaturation, fSaturation);
-               if (SkScalarIsNaN(fHue) == false)
-                       color = HSV_to_RGB(color, kGetHue, fHue);
-               fDirty = false;
-       }
-       return color; 
+    if (fDirty) {
+        if (SkScalarIsNaN(fValue) == false)
+            color = HSV_to_RGB(color, kGetValue, fValue);
+        if (SkScalarIsNaN(fSaturation) == false)
+            color = HSV_to_RGB(color, kGetSaturation, fSaturation);
+        if (SkScalarIsNaN(fHue) == false)
+            color = HSV_to_RGB(color, kGetHue, fHue);
+        fDirty = false;
+    }
+    return color; 
 }
 
 SkDisplayable* SkDrawColor::getParent() const {
-       return fPaint;
+    return fPaint;
 }
 
 bool SkDrawColor::getProperty(int index, SkScriptValue* value) const {
-       value->fType = SkType_Float;
-       SkScalar result;
-       switch(index) {
-               case SK_PROPERTY(alpha):
-                       result = SkIntToScalar(SkColorGetA(color)) / 255;
-                       break;
-               case SK_PROPERTY(blue):
-                       result = SkIntToScalar(SkColorGetB(color));
-                       break;
-               case SK_PROPERTY(green):
-                       result = SkIntToScalar(SkColorGetG(color));
-                       break;
-               case SK_PROPERTY(hue):
-                       result = RGB_to_HSV(color, kGetHue);
-                       break;
-               case SK_PROPERTY(red):
-                       result = SkIntToScalar(SkColorGetR(color));
-                       break;
-               case SK_PROPERTY(saturation):
-                       result = RGB_to_HSV(color, kGetSaturation);
-                       break;
-               case SK_PROPERTY(value):
-                       result = RGB_to_HSV(color, kGetValue);
-                       break;
-               default:
-                       SkASSERT(0);
-                       return false;
-       }
-       value->fOperand.fScalar = result;
-       return true;
+    value->fType = SkType_Float;
+    SkScalar result;
+    switch(index) {
+        case SK_PROPERTY(alpha):
+            result = SkIntToScalar(SkColorGetA(color)) / 255;
+            break;
+        case SK_PROPERTY(blue):
+            result = SkIntToScalar(SkColorGetB(color));
+            break;
+        case SK_PROPERTY(green):
+            result = SkIntToScalar(SkColorGetG(color));
+            break;
+        case SK_PROPERTY(hue):
+            result = RGB_to_HSV(color, kGetHue);
+            break;
+        case SK_PROPERTY(red):
+            result = SkIntToScalar(SkColorGetR(color));
+            break;
+        case SK_PROPERTY(saturation):
+            result = RGB_to_HSV(color, kGetSaturation);
+            break;
+        case SK_PROPERTY(value):
+            result = RGB_to_HSV(color, kGetValue);
+            break;
+        default:
+            SkASSERT(0);
+            return false;
+    }
+    value->fOperand.fScalar = result;
+    return true;
 }
 
 void SkDrawColor::onEndElement(SkAnimateMaker& maker){
-       fDirty = true;
+    fDirty = true;
 }
 
 bool SkDrawColor::setParent(SkDisplayable* parent) {
-       SkASSERT(parent != nil);
-       if (parent->getType() == SkType_LinearGradient || parent->getType() == SkType_RadialGradient)
-               return false;
-       if (parent->isPaint() == false)
-               return true;
-       fPaint = (SkDrawPaint*) parent;
-       return false;
+    SkASSERT(parent != nil);
+    if (parent->getType() == SkType_LinearGradient || parent->getType() == SkType_RadialGradient)
+        return false;
+    if (parent->isPaint() == false)
+        return true;
+    fPaint = (SkDrawPaint*) parent;
+    return false;
 }
 
 bool SkDrawColor::setProperty(int index, SkScriptValue& value) {
-       SkASSERT(value.fType == SkType_Float);
-       SkScalar scalar = value.fOperand.fScalar;
-       switch (index) {
-               case SK_PROPERTY(alpha):
-                       U8 alpha;
-               #ifdef SK_SCALAR_IS_FLOAT
-                       alpha = scalar == SK_Scalar1 ? 255 : SkToU8((U8CPU) (scalar * 256));
-               #else
-                       alpha = SkToU8((scalar - (scalar >= SK_ScalarHalf)) >> 8);
-               #endif
-                       color = SkColorSetARGB(alpha, SkColorGetR(color), 
-                               SkColorGetG(color), SkColorGetB(color));
-                       break;
-               case SK_PROPERTY(blue):
-                       scalar = SkScalarClampMax(scalar, 255 * SK_Scalar1);
-                       color = SkColorSetARGB(SkColorGetA(color), SkColorGetR(color), 
-                               SkColorGetG(color), SkToU8((U8CPU) scalar));
-                       break;
-               case SK_PROPERTY(green):
-                       scalar = SkScalarClampMax(scalar, 255 * SK_Scalar1);
-                       color = SkColorSetARGB(SkColorGetA(color), SkColorGetR(color), 
-                               SkToU8((U8CPU) scalar), SkColorGetB(color));
-                       break;
-               case SK_PROPERTY(hue):
-                       fHue = scalar;//RGB_to_HSV(color, kGetHue);
-                       fDirty = true;
-                       break;
-               case SK_PROPERTY(red):
-                       scalar = SkScalarClampMax(scalar, 255 * SK_Scalar1);
-                       color = SkColorSetARGB(SkColorGetA(color), SkToU8((U8CPU) scalar), 
-                               SkColorGetG(color), SkColorGetB(color));
-               break;
-               case SK_PROPERTY(saturation):
-                       fSaturation = scalar;//RGB_to_HSV(color, kGetSaturation);
-                       fDirty = true;
-                       break;
-               case SK_PROPERTY(value):
-                       fValue = scalar;//RGB_to_HSV(color, kGetValue);
-                       fDirty = true;
-                       break;
-               default:
-                       SkASSERT(0);
-                       return false;
-       }
-       return true;
+    SkASSERT(value.fType == SkType_Float);
+    SkScalar scalar = value.fOperand.fScalar;
+    switch (index) {
+        case SK_PROPERTY(alpha):
+            U8 alpha;
+        #ifdef SK_SCALAR_IS_FLOAT
+            alpha = scalar == SK_Scalar1 ? 255 : SkToU8((U8CPU) (scalar * 256));
+        #else
+            alpha = SkToU8((scalar - (scalar >= SK_ScalarHalf)) >> 8);
+        #endif
+            color = SkColorSetARGB(alpha, SkColorGetR(color), 
+                SkColorGetG(color), SkColorGetB(color));
+            break;
+        case SK_PROPERTY(blue):
+            scalar = SkScalarClampMax(scalar, 255 * SK_Scalar1);
+            color = SkColorSetARGB(SkColorGetA(color), SkColorGetR(color), 
+                SkColorGetG(color), SkToU8((U8CPU) scalar));
+            break;
+        case SK_PROPERTY(green):
+            scalar = SkScalarClampMax(scalar, 255 * SK_Scalar1);
+            color = SkColorSetARGB(SkColorGetA(color), SkColorGetR(color), 
+                SkToU8((U8CPU) scalar), SkColorGetB(color));
+            break;
+        case SK_PROPERTY(hue):
+            fHue = scalar;//RGB_to_HSV(color, kGetHue);
+            fDirty = true;
+            break;
+        case SK_PROPERTY(red):
+            scalar = SkScalarClampMax(scalar, 255 * SK_Scalar1);
+            color = SkColorSetARGB(SkColorGetA(color), SkToU8((U8CPU) scalar), 
+                SkColorGetG(color), SkColorGetB(color));
+        break;
+        case SK_PROPERTY(saturation):
+            fSaturation = scalar;//RGB_to_HSV(color, kGetSaturation);
+            fDirty = true;
+            break;
+        case SK_PROPERTY(value):
+            fValue = scalar;//RGB_to_HSV(color, kGetValue);
+            fDirty = true;
+            break;
+        default:
+            SkASSERT(0);
+            return false;
+    }
+    return true;
 }
 
index ad7c3f8..f1e6d2b 100644 (file)
@@ -1,3 +1,20 @@
+/* libs/graphics/animator/SkDrawColor.h
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #ifndef SkDrawColor_DEFINED
 #define SkDrawColor_DEFINED
 
 #include "SkColor.h"
 
 class SkDrawColor : public SkPaintPart {
-       DECLARE_DRAW_MEMBER_INFO(Color);
-       SkDrawColor();
-       virtual bool add();
-       virtual void dirty();
+    DECLARE_DRAW_MEMBER_INFO(Color);
+    SkDrawColor();
+    virtual bool add();
+    virtual void dirty();
 #ifdef SK_DUMP_ENABLED
-       virtual void dump(SkAnimateMaker* );
+    virtual void dump(SkAnimateMaker* );
 #endif
-       SkColor getColor();
-       virtual SkDisplayable* deepCopy(SkAnimateMaker* );
-       virtual SkDisplayable* getParent() const;
-       virtual bool getProperty(int index, SkScriptValue* value) const;
-       virtual void onEndElement(SkAnimateMaker& );
-       virtual bool setParent(SkDisplayable* parent);
-       virtual bool setProperty(int index, SkScriptValue&);
+    SkColor getColor();
+    virtual SkDisplayable* deepCopy(SkAnimateMaker* );
+    virtual SkDisplayable* getParent() const;
+    virtual bool getProperty(int index, SkScriptValue* value) const;
+    virtual void onEndElement(SkAnimateMaker& );
+    virtual bool setParent(SkDisplayable* parent);
+    virtual bool setProperty(int index, SkScriptValue&);
 protected:
-       SkColor color;
-       SkScalar fHue;
-       SkScalar fSaturation;
-       SkScalar fValue;
-       SkBool fDirty;
+    SkColor color;
+    SkScalar fHue;
+    SkScalar fSaturation;
+    SkScalar fValue;
+    SkBool fDirty;
 private:
-       friend class SkGradient;
-       typedef SkPaintPart INHERITED;
+    friend class SkGradient;
+    typedef SkPaintPart INHERITED;
 };
 
 #endif // SkDrawColor_DEFINED
index 78e2d66..c7e296c 100644 (file)
@@ -1,11 +1,28 @@
+/* libs/graphics/animator/SkDrawDash.cpp
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #include "SkDrawDash.h"
 #include "SkDashPathEffect.h"
 
 #if SK_USE_CONDENSED_INFO == 0
 
 const SkMemberInfo SkDash::fInfo[] = {
-       SK_MEMBER_ARRAY(intervals, Float),
-       SK_MEMBER(phase, Float)
+    SK_MEMBER_ARRAY(intervals, Float),
+    SK_MEMBER(phase, Float)
 };
 
 #endif
@@ -19,9 +36,9 @@ SkDash::~SkDash() {
 }
 
 SkPathEffect* SkDash::getPathEffect() {
-       int count = intervals.count();
-       if (count == 0)
-               return nil;
-       return new SkDashPathEffect(intervals.begin(), count, phase);
+    int count = intervals.count();
+    if (count == 0)
+        return nil;
+    return new SkDashPathEffect(intervals.begin(), count, phase);
 }
 
index ff89f50..39a13ea 100644 (file)
@@ -1,3 +1,20 @@
+/* libs/graphics/animator/SkDrawDash.h
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #ifndef SkDrawDash_DEFINED
 #define SkDrawDash_DEFINED
 
 #include "SkIntArray.h"
 
 class SkDash : public SkDrawPathEffect {
-       DECLARE_MEMBER_INFO(Dash);
-       SkDash();
-       virtual ~SkDash();
-       virtual SkPathEffect* getPathEffect();
+    DECLARE_MEMBER_INFO(Dash);
+    SkDash();
+    virtual ~SkDash();
+    virtual SkPathEffect* getPathEffect();
 private:
-       SkTDScalarArray intervals;
-       SkScalar phase;
+    SkTDScalarArray intervals;
+    SkScalar phase;
 };
 
 #endif // SkDrawDash_DEFINED
index 9e32772..d40d269 100644 (file)
@@ -1,3 +1,20 @@
+/* libs/graphics/animator/SkDrawDiscrete.cpp
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #include "SkDrawDiscrete.h"
 #include "SkAnimateMaker.h"
 #include "SkPaint.h"
@@ -6,8 +23,8 @@
 #if SK_USE_CONDENSED_INFO == 0
 
 const SkMemberInfo SkDiscrete::fInfo[] = {
-       SK_MEMBER(deviation, Float),
-       SK_MEMBER(segLength, Float)
+    SK_MEMBER(deviation, Float),
+    SK_MEMBER(segLength, Float)
 };
 
 #endif
@@ -18,9 +35,9 @@ SkDiscrete::SkDiscrete() : deviation(0), segLength(0) {
 }
 
 SkPathEffect* SkDiscrete::getPathEffect() {
-       if (deviation <= 0 || segLength <= 0)
-               return nil;
-       else
-               return new SkDiscretePathEffect(segLength, deviation);
+    if (deviation <= 0 || segLength <= 0)
+        return nil;
+    else
+        return new SkDiscretePathEffect(segLength, deviation);
 }
 
index 61aeac0..9652766 100644 (file)
@@ -1,15 +1,32 @@
+/* libs/graphics/animator/SkDrawDiscrete.h
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #ifndef SkDrawDiscrete_DEFINED
 #define SkDrawDiscrete_DEFINED
 
 #include "SkPaintParts.h"
 
 class SkDiscrete : public SkDrawPathEffect {
-       DECLARE_MEMBER_INFO(Discrete);
-       SkDiscrete();
-       virtual SkPathEffect* getPathEffect();
+    DECLARE_MEMBER_INFO(Discrete);
+    SkDiscrete();
+    virtual SkPathEffect* getPathEffect();
 private:
-       SkScalar deviation;
-       SkScalar segLength;
+    SkScalar deviation;
+    SkScalar segLength;
 };
 
 #endif //SkDrawDiscrete_DEFINED
index f0aee87..59810ab 100644 (file)
@@ -1,12 +1,29 @@
+/* libs/graphics/animator/SkDrawEmboss.cpp
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #include "SkDrawEmboss.h"
 
 #if SK_USE_CONDENSED_INFO == 0
 
 const SkMemberInfo SkDrawEmboss::fInfo[] = {
-       SK_MEMBER(ambient, Float),
-       SK_MEMBER_ARRAY(direction, Float),
-       SK_MEMBER(radius, Float),
-       SK_MEMBER(specular, Float)
+    SK_MEMBER(ambient, Float),
+    SK_MEMBER_ARRAY(direction, Float),
+    SK_MEMBER(radius, Float),
+    SK_MEMBER(specular, Float)
 };
 
 #endif
@@ -14,12 +31,12 @@ const SkMemberInfo SkDrawEmboss::fInfo[] = {
 DEFINE_GET_MEMBER(SkDrawEmboss);
 
 SkDrawEmboss::SkDrawEmboss() : radius(-1) { 
-       direction.setCount(3);
+    direction.setCount(3);
 }
 
 SkMaskFilter* SkDrawEmboss::getMaskFilter() {
-       if (radius < 0 || direction.count() !=3)
-               return nil;
+    if (radius < 0 || direction.count() !=3)
+        return nil;
     return SkBlurMaskFilter::CreateEmboss(direction.begin(), ambient, specular, radius);
 }
 
index 8014f45..51c60a1 100644 (file)
@@ -1,15 +1,32 @@
+/* libs/graphics/animator/SkDrawEmboss.h
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #ifndef SkDrawEmboss_DEFINED
 #define SkDrawEmboss_DEFINED
 
 #include "SkDrawBlur.h"
 
 class SkDrawEmboss : public SkDrawMaskFilter {
-       DECLARE_DRAW_MEMBER_INFO(Emboss);
-       SkDrawEmboss();
-       virtual SkMaskFilter* getMaskFilter();
+    DECLARE_DRAW_MEMBER_INFO(Emboss);
+    SkDrawEmboss();
+    virtual SkMaskFilter* getMaskFilter();
 protected:
-       SkTDScalarArray direction;
-       SkScalar radius, ambient, specular;
+    SkTDScalarArray direction;
+    SkScalar radius, ambient, specular;
 };
 
 #endif // SkDrawEmboss_DEFINED
index b008643..1431fd3 100644 (file)
@@ -1,3 +1,20 @@
+/* libs/graphics/animator/SkDrawExtraPathEffect.cpp
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #include "SkDrawExtraPathEffect.h"
 #include "SkDrawPath.h"
 #include "Sk1DPathEffect.h"
 #include "SkDashPathEffect.h"
 
 class SkDrawShapePathEffect : public SkDrawPathEffect {
-       DECLARE_PRIVATE_MEMBER_INFO(DrawShapePathEffect);
-       SkDrawShapePathEffect();
-       virtual ~SkDrawShapePathEffect();
-       virtual bool add(SkAnimateMaker& , SkDisplayable* );
-       virtual SkPathEffect* getPathEffect();
+    DECLARE_PRIVATE_MEMBER_INFO(DrawShapePathEffect);
+    SkDrawShapePathEffect();
+    virtual ~SkDrawShapePathEffect();
+    virtual bool add(SkAnimateMaker& , SkDisplayable* );
+    virtual SkPathEffect* getPathEffect();
 protected:
-       SkDrawable* addPath;
-       SkDrawable* addMatrix;
-       SkDrawPath* path;
-       SkPathEffect* fPathEffect;
-       friend class SkShape1DPathEffect;
-       friend class SkShape2DPathEffect;
+    SkDrawable* addPath;
+    SkDrawable* addMatrix;
+    SkDrawPath* path;
+    SkPathEffect* fPathEffect;
+    friend class SkShape1DPathEffect;
+    friend class SkShape2DPathEffect;
 };
 
 class SkDrawShape1DPathEffect : public SkDrawShapePathEffect {
-       DECLARE_EXTRAS_MEMBER_INFO(SkDrawShape1DPathEffect);
-       SkDrawShape1DPathEffect(SkDisplayTypes );
-       virtual ~SkDrawShape1DPathEffect();
-       virtual void onEndElement(SkAnimateMaker& );
+    DECLARE_EXTRAS_MEMBER_INFO(SkDrawShape1DPathEffect);
+    SkDrawShape1DPathEffect(SkDisplayTypes );
+    virtual ~SkDrawShape1DPathEffect();
+    virtual void onEndElement(SkAnimateMaker& );
 private:
-       SkString phase;
-       SkString spacing;
-       friend class SkShape1DPathEffect;
-       typedef SkDrawShapePathEffect INHERITED;
+    SkString phase;
+    SkString spacing;
+    friend class SkShape1DPathEffect;
+    typedef SkDrawShapePathEffect INHERITED;
 };
 
 class SkDrawShape2DPathEffect : public SkDrawShapePathEffect {
-       DECLARE_EXTRAS_MEMBER_INFO(SkDrawShape2DPathEffect);
-       SkDrawShape2DPathEffect(SkDisplayTypes );
-       virtual ~SkDrawShape2DPathEffect();
-       virtual void onEndElement(SkAnimateMaker& );
+    DECLARE_EXTRAS_MEMBER_INFO(SkDrawShape2DPathEffect);
+    SkDrawShape2DPathEffect(SkDisplayTypes );
+    virtual ~SkDrawShape2DPathEffect();
+    virtual void onEndElement(SkAnimateMaker& );
 private:
-       SkDrawMatrix* matrix;
-       friend class SkShape2DPathEffect;
-       typedef SkDrawShapePathEffect INHERITED;
+    SkDrawMatrix* matrix;
+    friend class SkShape2DPathEffect;
+    typedef SkDrawShapePathEffect INHERITED;
 };
 
 class SkDrawComposePathEffect : public SkDrawPathEffect {
-       DECLARE_EXTRAS_MEMBER_INFO(SkDrawComposePathEffect);
-       SkDrawComposePathEffect(SkDisplayTypes );
-       virtual ~SkDrawComposePathEffect();
-       virtual bool add(SkAnimateMaker& , SkDisplayable* );
-       virtual SkPathEffect* getPathEffect();
-       virtual bool isPaint() const; 
+    DECLARE_EXTRAS_MEMBER_INFO(SkDrawComposePathEffect);
+    SkDrawComposePathEffect(SkDisplayTypes );
+    virtual ~SkDrawComposePathEffect();
+    virtual bool add(SkAnimateMaker& , SkDisplayable* );
+    virtual SkPathEffect* getPathEffect();
+    virtual bool isPaint() const; 
 private:
-       SkDrawPathEffect* effect1;
-       SkDrawPathEffect* effect2;
+    SkDrawPathEffect* effect1;
+    SkDrawPathEffect* effect2;
 };
 
 class SkDrawCornerPathEffect : public SkDrawPathEffect {
@@ -78,77 +95,77 @@ private:
 
 class SkShape1DPathEffect : public Sk1DPathEffect {
 public:
-       SkShape1DPathEffect(SkDrawShape1DPathEffect* draw, SkAnimateMaker* maker) :
-               fDraw(draw), fMaker(maker) {
-       }
+    SkShape1DPathEffect(SkDrawShape1DPathEffect* draw, SkAnimateMaker* maker) :
+        fDraw(draw), fMaker(maker) {
+    }
 
 protected:
-       virtual SkScalar begin(SkScalar contourLength)
-       {
-               SkScriptValue value;
-               SkAnimatorScript engine(*fMaker, nil, SkType_Float);
-               engine.propertyCallBack(GetContourLength, &contourLength);
-               value.fOperand.fScalar = 0;
-               engine.evaluate(fDraw->phase.c_str(), &value, SkType_Float);
-               return value.fOperand.fScalar;
-       }
-
-       virtual SkScalar next(SkScalar distance, const SkMatrix& mat, SkPath* dst)
-       {
-               fMaker->setExtraPropertyCallBack(fDraw->fType, GetDistance, &distance);
-               SkDrawPath* drawPath = nil;
-               if (fDraw->addPath->isPath()) {
-                       drawPath = (SkDrawPath*) fDraw->addPath;
-               } else {
-                       SkApply* apply = (SkApply*) fDraw->addPath;
-                       apply->refresh(*fMaker);
-                       apply->activate(*fMaker);
-                       apply->interpolate(*fMaker, SkScalarMulRound(distance, 1000));
-                       drawPath = (SkDrawPath*) apply->getScope();
-               }
-               SkMatrix m(mat);
-               if (fDraw->addMatrix) {
-                       SkDrawMatrix* matrix;
-                       if (fDraw->addMatrix->getType() == SkType_Matrix) 
-                               matrix = (SkDrawMatrix*) fDraw->addMatrix;
-                       else {
-                               SkApply* apply = (SkApply*) fDraw->addMatrix;
-                               apply->refresh(*fMaker);
-                               apply->activate(*fMaker);
-                               apply->interpolate(*fMaker, SkScalarMulRound(distance, 1000));
-                               matrix = (SkDrawMatrix*) apply->getScope();
-                       }
-               }
-               SkScalar result = 0;
-               SkAnimatorScript::EvaluateFloat(*fMaker, nil, fDraw->spacing.c_str(), &result);
-               if (drawPath)
-                       dst->addPath(drawPath->getPath(), m);
-               fMaker->clearExtraPropertyCallBack(fDraw->fType);
-               return result;
-       }
+    virtual SkScalar begin(SkScalar contourLength)
+    {
+        SkScriptValue value;
+        SkAnimatorScript engine(*fMaker, nil, SkType_Float);
+        engine.propertyCallBack(GetContourLength, &contourLength);
+        value.fOperand.fScalar = 0;
+        engine.evaluate(fDraw->phase.c_str(), &value, SkType_Float);
+        return value.fOperand.fScalar;
+    }
+
+    virtual SkScalar next(SkScalar distance, const SkMatrix& mat, SkPath* dst)
+    {
+        fMaker->setExtraPropertyCallBack(fDraw->fType, GetDistance, &distance);
+        SkDrawPath* drawPath = nil;
+        if (fDraw->addPath->isPath()) {
+            drawPath = (SkDrawPath*) fDraw->addPath;
+        } else {
+            SkApply* apply = (SkApply*) fDraw->addPath;
+            apply->refresh(*fMaker);
+            apply->activate(*fMaker);
+            apply->interpolate(*fMaker, SkScalarMulRound(distance, 1000));
+            drawPath = (SkDrawPath*) apply->getScope();
+        }
+        SkMatrix m(mat);
+        if (fDraw->addMatrix) {
+            SkDrawMatrix* matrix;
+            if (fDraw->addMatrix->getType() == SkType_Matrix) 
+                matrix = (SkDrawMatrix*) fDraw->addMatrix;
+            else {
+                SkApply* apply = (SkApply*) fDraw->addMatrix;
+                apply->refresh(*fMaker);
+                apply->activate(*fMaker);
+                apply->interpolate(*fMaker, SkScalarMulRound(distance, 1000));
+                matrix = (SkDrawMatrix*) apply->getScope();
+            }
+        }
+        SkScalar result = 0;
+        SkAnimatorScript::EvaluateFloat(*fMaker, nil, fDraw->spacing.c_str(), &result);
+        if (drawPath)
+            dst->addPath(drawPath->getPath(), m);
+        fMaker->clearExtraPropertyCallBack(fDraw->fType);
+        return result;
+    }
 
 private:
 
-       static bool GetContourLength(const char* token, size_t len, void* clen, SkScriptValue* value) {
-               if (SK_LITERAL_STR_EQUAL("contourLength", token, len)) {
-                       value->fOperand.fScalar = *(SkScalar*) clen;
-                       value->fType = SkType_Float;
-                       return true;
-               }
-               return false;
-       }
-
-       static bool GetDistance(const char* token, size_t len, void* dist, SkScriptValue* value) {
-               if (SK_LITERAL_STR_EQUAL("distance", token, len)) {
-                       value->fOperand.fScalar = *(SkScalar*) dist;
-                       value->fType = SkType_Float;
-                       return true;
-               }
-               return false;
-       }
-
-       SkDrawShape1DPathEffect* fDraw;
-       SkAnimateMaker* fMaker;
+    static bool GetContourLength(const char* token, size_t len, void* clen, SkScriptValue* value) {
+        if (SK_LITERAL_STR_EQUAL("contourLength", token, len)) {
+            value->fOperand.fScalar = *(SkScalar*) clen;
+            value->fType = SkType_Float;
+            return true;
+        }
+        return false;
+    }
+
+    static bool GetDistance(const char* token, size_t len, void* dist, SkScriptValue* value) {
+        if (SK_LITERAL_STR_EQUAL("distance", token, len)) {
+            value->fOperand.fScalar = *(SkScalar*) dist;
+            value->fType = SkType_Float;
+            return true;
+        }
+        return false;
+    }
+
+    SkDrawShape1DPathEffect* fDraw;
+    SkAnimateMaker* fMaker;
 };
 
 //////////// SkDrawShapePathEffect
@@ -156,9 +173,9 @@ private:
 #if SK_USE_CONDENSED_INFO == 0
 
 const SkMemberInfo SkDrawShapePathEffect::fInfo[] = {
-       SK_MEMBER(addMatrix, Drawable), // either matrix or apply
-       SK_MEMBER(addPath, Drawable),   // either path or apply
-       SK_MEMBER(path, Path),
+    SK_MEMBER(addMatrix, Drawable), // either matrix or apply
+    SK_MEMBER(addPath, Drawable),   // either path or apply
+    SK_MEMBER(path, Path),
 };
 
 #endif
@@ -166,21 +183,21 @@ const SkMemberInfo SkDrawShapePathEffect::fInfo[] = {
 DEFINE_GET_MEMBER(SkDrawShapePathEffect);
 
 SkDrawShapePathEffect::SkDrawShapePathEffect() : 
-       addPath(nil), addMatrix(nil), path(nil), fPathEffect(nil) {
+    addPath(nil), addMatrix(nil), path(nil), fPathEffect(nil) {
 }
 
 SkDrawShapePathEffect::~SkDrawShapePathEffect() {
-       fPathEffect->safeUnref();
+    fPathEffect->safeUnref();
 }
 
 bool SkDrawShapePathEffect::add(SkAnimateMaker& , SkDisplayable* child) {
-       path = (SkDrawPath*) child;
-       return true;
+    path = (SkDrawPath*) child;
+    return true;
 }
 
 SkPathEffect* SkDrawShapePathEffect::getPathEffect() {
-       fPathEffect->ref();
-       return fPathEffect;
+    fPathEffect->ref();
+    return fPathEffect;
 }
 
 //////////// SkDrawShape1DPathEffect
@@ -188,9 +205,9 @@ SkPathEffect* SkDrawShapePathEffect::getPathEffect() {
 #if SK_USE_CONDENSED_INFO == 0
 
 const SkMemberInfo SkDrawShape1DPathEffect::fInfo[] = {
-       SK_MEMBER_INHERITED,
-       SK_MEMBER(phase, String),
-       SK_MEMBER(spacing, String),
+    SK_MEMBER_INHERITED,
+    SK_MEMBER(phase, String),
+    SK_MEMBER(spacing, String),
 };
 
 #endif
@@ -204,94 +221,94 @@ SkDrawShape1DPathEffect::~SkDrawShape1DPathEffect() {
 }
 
 void SkDrawShape1DPathEffect::onEndElement(SkAnimateMaker& maker) {
-       if (addPath == nil || (addPath->isPath() == false && addPath->isApply() == false))
-               maker.setErrorCode(SkDisplayXMLParserError::kUnknownError); // !!! add error
-       else
-               fPathEffect = new SkShape1DPathEffect(this, &maker);
+    if (addPath == nil || (addPath->isPath() == false && addPath->isApply() == false))
+        maker.setErrorCode(SkDisplayXMLParserError::kUnknownError); // !!! add error
+    else
+        fPathEffect = new SkShape1DPathEffect(this, &maker);
 }
 
 ////////// SkShape2DPathEffect
 
 class SkShape2DPathEffect : public Sk2DPathEffect {
 public:
-       SkShape2DPathEffect(SkDrawShape2DPathEffect* draw, SkAnimateMaker* maker, 
-               const SkMatrix& matrix) : Sk2DPathEffect(matrix), fDraw(draw), fMaker(maker) {
-       }
+    SkShape2DPathEffect(SkDrawShape2DPathEffect* draw, SkAnimateMaker* maker, 
+        const SkMatrix& matrix) : Sk2DPathEffect(matrix), fDraw(draw), fMaker(maker) {
+    }
 
 protected:
-       virtual void begin(const SkRect16& uvBounds, SkPath* )
-       {
-               fUVBounds.set(SkIntToScalar(uvBounds.fLeft), SkIntToScalar(uvBounds.fTop),
-                       SkIntToScalar(uvBounds.fRight), SkIntToScalar(uvBounds.fBottom));
-       }
-
-       virtual void next(const SkPoint& loc, int u, int v, SkPath* dst)
-       {
-               fLoc = loc;
-               fU = u;
-               fV = v;
-               SkDrawPath* drawPath;
-               fMaker->setExtraPropertyCallBack(fDraw->fType, Get2D, this);
-               if (fDraw->addPath->isPath()) {
-                       drawPath = (SkDrawPath*) fDraw->addPath;
-               } else {
-                       SkApply* apply = (SkApply*) fDraw->addPath;
-                       apply->refresh(*fMaker);
-                       apply->activate(*fMaker);
-                       apply->interpolate(*fMaker, v);
-                       drawPath = (SkDrawPath*) apply->getScope();
-               }
-               if (drawPath == nil)
-                       goto clearCallBack;
-               if (fDraw->matrix) {
-                       SkDrawMatrix* matrix;
-                       if (fDraw->matrix->getType() == SkType_Matrix) 
-                               matrix = (SkDrawMatrix*) fDraw->matrix;
-                       else {
-                               SkApply* apply = (SkApply*) fDraw->matrix;
-                               apply->activate(*fMaker);
-                               apply->interpolate(*fMaker, v);
-                               matrix = (SkDrawMatrix*) apply->getScope();
-                       }
-                       if (matrix) {
-                               dst->addPath(drawPath->getPath(), matrix->getMatrix());
-                               goto clearCallBack;
-                       }
-               }
-               dst->addPath(drawPath->getPath());
+    virtual void begin(const SkRect16& uvBounds, SkPath* )
+    {
+        fUVBounds.set(SkIntToScalar(uvBounds.fLeft), SkIntToScalar(uvBounds.fTop),
+            SkIntToScalar(uvBounds.fRight), SkIntToScalar(uvBounds.fBottom));
+    }
+
+    virtual void next(const SkPoint& loc, int u, int v, SkPath* dst)
+    {
+        fLoc = loc;
+        fU = u;
+        fV = v;
+        SkDrawPath* drawPath;
+        fMaker->setExtraPropertyCallBack(fDraw->fType, Get2D, this);
+        if (fDraw->addPath->isPath()) {
+            drawPath = (SkDrawPath*) fDraw->addPath;
+        } else {
+            SkApply* apply = (SkApply*) fDraw->addPath;
+            apply->refresh(*fMaker);
+            apply->activate(*fMaker);
+            apply->interpolate(*fMaker, v);
+            drawPath = (SkDrawPath*) apply->getScope();
+        }
+        if (drawPath == nil)
+            goto clearCallBack;
+        if (fDraw->matrix) {
+            SkDrawMatrix* matrix;
+            if (fDraw->matrix->getType() == SkType_Matrix) 
+                matrix = (SkDrawMatrix*) fDraw->matrix;
+            else {
+                SkApply* apply = (SkApply*) fDraw->matrix;
+                apply->activate(*fMaker);
+                apply->interpolate(*fMaker, v);
+                matrix = (SkDrawMatrix*) apply->getScope();
+            }
+            if (matrix) {
+                dst->addPath(drawPath->getPath(), matrix->getMatrix());
+                goto clearCallBack;
+            }
+        }
+        dst->addPath(drawPath->getPath());
 clearCallBack:
-               fMaker->clearExtraPropertyCallBack(fDraw->fType);
-       }
+        fMaker->clearExtraPropertyCallBack(fDraw->fType);
+    }
 
 private:
 
-       static bool Get2D(const char* token, size_t len, void* s2D, SkScriptValue* value) {
-               static const char match[] = "locX|locY|left|top|right|bottom|u|v" ;
-               SkShape2DPathEffect* shape2D = (SkShape2DPathEffect*) s2D;
-               int index;
-               if (SkAnimatorScript::MapEnums(match, token, len, &index) == false)
-                       return false;
-               SkASSERT((sizeof(SkPoint) +     sizeof(SkRect)) / sizeof(SkScalar) == 6);
-               if (index < 6) {
-                       value->fType = SkType_Float;
-                       value->fOperand.fScalar = (&shape2D->fLoc.fX)[index];
-               } else {
-                       value->fType = SkType_Int;
-                       value->fOperand.fS32 = (&shape2D->fU)[index - 6];
-               }
-               return true;
-       }
-       
-       SkPoint fLoc;
-       SkRect fUVBounds;
-       S32 fU;
-       S32 fV;
-       SkDrawShape2DPathEffect* fDraw;
-       SkAnimateMaker* fMaker;
-
-       // illegal
-       SkShape2DPathEffect(const SkShape2DPathEffect&);
-       SkShape2DPathEffect& operator=(const SkShape2DPathEffect&);
+    static bool Get2D(const char* token, size_t len, void* s2D, SkScriptValue* value) {
+        static const char match[] = "locX|locY|left|top|right|bottom|u|v" ;
+        SkShape2DPathEffect* shape2D = (SkShape2DPathEffect*) s2D;
+        int index;
+        if (SkAnimatorScript::MapEnums(match, token, len, &index) == false)
+            return false;
+        SkASSERT((sizeof(SkPoint) +     sizeof(SkRect)) / sizeof(SkScalar) == 6);
+        if (index < 6) {
+            value->fType = SkType_Float;
+            value->fOperand.fScalar = (&shape2D->fLoc.fX)[index];
+        } else {
+            value->fType = SkType_Int;
+            value->fOperand.fS32 = (&shape2D->fU)[index - 6];
+        }
+        return true;
+    }
+    
+    SkPoint fLoc;
+    SkRect fUVBounds;
+    S32 fU;
+    S32 fV;
+    SkDrawShape2DPathEffect* fDraw;
+    SkAnimateMaker* fMaker;
+
+    // illegal
+    SkShape2DPathEffect(const SkShape2DPathEffect&);
+    SkShape2DPathEffect& operator=(const SkShape2DPathEffect&);
 };
 
 ////////// SkDrawShape2DPathEffect
@@ -299,8 +316,8 @@ private:
 #if SK_USE_CONDENSED_INFO == 0
 
 const SkMemberInfo SkDrawShape2DPathEffect::fInfo[] = {
-       SK_MEMBER_INHERITED,
-       SK_MEMBER(matrix, Matrix)
+    SK_MEMBER_INHERITED,
+    SK_MEMBER(matrix, Matrix)
 };
 
 #endif
@@ -314,11 +331,11 @@ SkDrawShape2DPathEffect::~SkDrawShape2DPathEffect() {
 }
 
 void SkDrawShape2DPathEffect::onEndElement(SkAnimateMaker& maker) {
-       if (addPath == nil || (addPath->isPath() == false && addPath->isApply() == false) ||
-                       matrix == nil)
-               maker.setErrorCode(SkDisplayXMLParserError::kUnknownError); // !!! add error
-       else
-               fPathEffect = new SkShape2DPathEffect(this, &maker, matrix->getMatrix());
+    if (addPath == nil || (addPath->isPath() == false && addPath->isApply() == false) ||
+            matrix == nil)
+        maker.setErrorCode(SkDisplayXMLParserError::kUnknownError); // !!! add error
+    else
+        fPathEffect = new SkShape2DPathEffect(this, &maker, matrix->getMatrix());
 }
 
 ////////// SkDrawComposePathEffect
@@ -326,8 +343,8 @@ void SkDrawShape2DPathEffect::onEndElement(SkAnimateMaker& maker) {
 #if SK_USE_CONDENSED_INFO == 0
 
 const SkMemberInfo SkDrawComposePathEffect::fInfo[] = {
-       SK_MEMBER(effect1, PathEffect),
-       SK_MEMBER(effect2, PathEffect)
+    SK_MEMBER(effect1, PathEffect),
+    SK_MEMBER(effect2, PathEffect)
 };
 
 #endif
@@ -335,33 +352,33 @@ const SkMemberInfo SkDrawComposePathEffect::fInfo[] = {
 DEFINE_GET_MEMBER(SkDrawComposePathEffect);
 
 SkDrawComposePathEffect::SkDrawComposePathEffect(SkDisplayTypes type) : fType(type),
-       effect1(nil), effect2(nil) {
+    effect1(nil), effect2(nil) {
 }
 
 SkDrawComposePathEffect::~SkDrawComposePathEffect() {
-       delete effect1;
-       delete effect2;
+    delete effect1;
+    delete effect2;
 }
 
 bool SkDrawComposePathEffect::add(SkAnimateMaker& , SkDisplayable* child) {
-       if (effect1 == nil)
-               effect1 = (SkDrawPathEffect*) child;
-       else
-               effect2 = (SkDrawPathEffect*) child;
-       return true;
+    if (effect1 == nil)
+        effect1 = (SkDrawPathEffect*) child;
+    else
+        effect2 = (SkDrawPathEffect*) child;
+    return true;
 }
 
 SkPathEffect* SkDrawComposePathEffect::getPathEffect() {
-       SkPathEffect* e1 = effect1->getPathEffect();
-       SkPathEffect* e2 = effect2->getPathEffect();
-       SkPathEffect* composite = new SkComposePathEffect(e1, e2);
-       e1->unref();
-       e2->unref();
-       return composite;
+    SkPathEffect* e1 = effect1->getPathEffect();
+    SkPathEffect* e2 = effect2->getPathEffect();
+    SkPathEffect* composite = new SkComposePathEffect(e1, e2);
+    e1->unref();
+    e2->unref();
+    return composite;
 }
 
 bool SkDrawComposePathEffect::isPaint() const {
-       return true;
+    return true;
 }
 
 //////////// SkDrawCornerPathEffect
@@ -398,98 +415,98 @@ const char kDrawCornerPathEffectName[]  = "pathEffect:corner";
 
 class SkExtraPathEffects : public SkExtras {
 public:
-       SkExtraPathEffects(SkAnimator* animator) : 
-                       skDrawShape1DPathEffectType(SkType_Unknown),
-                       skDrawShape2DPathEffectType(SkType_Unknown),
-                       skDrawComposePathEffectType(SkType_Unknown),
+    SkExtraPathEffects(SkAnimator* animator) : 
+            skDrawShape1DPathEffectType(SkType_Unknown),
+            skDrawShape2DPathEffectType(SkType_Unknown),
+            skDrawComposePathEffectType(SkType_Unknown),
             skDrawCornerPathEffectType(SkType_Unknown) {
-       }
-       
-       virtual SkDisplayable* createInstance(SkDisplayTypes type) {
-               SkDisplayable* result = nil;
-               if (skDrawShape1DPathEffectType == type)
-                       result = new SkDrawShape1DPathEffect(type);
-               else if (skDrawShape2DPathEffectType == type)
-                       result = new SkDrawShape2DPathEffect(type);
-               else if (skDrawComposePathEffectType == type)
-                       result = new SkDrawComposePathEffect(type);
+    }
+    
+    virtual SkDisplayable* createInstance(SkDisplayTypes type) {
+        SkDisplayable* result = nil;
+        if (skDrawShape1DPathEffectType == type)
+            result = new SkDrawShape1DPathEffect(type);
+        else if (skDrawShape2DPathEffectType == type)
+            result = new SkDrawShape2DPathEffect(type);
+        else if (skDrawComposePathEffectType == type)
+            result = new SkDrawComposePathEffect(type);
         else if (skDrawCornerPathEffectType == type)
             result = new SkDrawCornerPathEffect(type);
-               return result;
-       }
+        return result;
+    }
 
-       virtual bool definesType(SkDisplayTypes type) {
-               return type == skDrawShape1DPathEffectType || 
-                       type == skDrawShape2DPathEffectType || 
-                       type == skDrawComposePathEffectType ||
+    virtual bool definesType(SkDisplayTypes type) {
+        return type == skDrawShape1DPathEffectType || 
+            type == skDrawShape2DPathEffectType || 
+            type == skDrawComposePathEffectType ||
             type == skDrawCornerPathEffectType;
-       }
+    }
 
 #if SK_USE_CONDENSED_INFO == 0
-       virtual const SkMemberInfo* getMembers(SkDisplayTypes type, int* infoCountPtr) {
-               const SkMemberInfo* info = nil;
-               int infoCount = 0;
-               if (skDrawShape1DPathEffectType == type) {
-                       info = SkDrawShape1DPathEffect::fInfo;
-                       infoCount = SkDrawShape1DPathEffect::fInfoCount;
-               } else if (skDrawShape2DPathEffectType == type) {
-                       info = SkDrawShape2DPathEffect::fInfo;
-                       infoCount = SkDrawShape2DPathEffect::fInfoCount;
-               } else if (skDrawComposePathEffectType == type) {
-                       info = SkDrawComposePathEffect::fInfo;
-                       infoCount = SkDrawShape1DPathEffect::fInfoCount;
-               } else if (skDrawCornerPathEffectType == type) {
+    virtual const SkMemberInfo* getMembers(SkDisplayTypes type, int* infoCountPtr) {
+        const SkMemberInfo* info = nil;
+        int infoCount = 0;
+        if (skDrawShape1DPathEffectType == type) {
+            info = SkDrawShape1DPathEffect::fInfo;
+            infoCount = SkDrawShape1DPathEffect::fInfoCount;
+        } else if (skDrawShape2DPathEffectType == type) {
+            info = SkDrawShape2DPathEffect::fInfo;
+            infoCount = SkDrawShape2DPathEffect::fInfoCount;
+        } else if (skDrawComposePathEffectType == type) {
+            info = SkDrawComposePathEffect::fInfo;
+            infoCount = SkDrawShape1DPathEffect::fInfoCount;
+        } else if (skDrawCornerPathEffectType == type) {
             info = SkDrawCornerPathEffect::fInfo;
             infoCount = SkDrawCornerPathEffect::fInfoCount;
         }
-               if (infoCountPtr)
-                       *infoCountPtr = infoCount;
-               return info;
-       }
+        if (infoCountPtr)
+            *infoCountPtr = infoCount;
+        return info;
+    }
 #endif
 
 #ifdef SK_DEBUG
-       virtual const char* getName(SkDisplayTypes type) {
+    virtual const char* getName(SkDisplayTypes type) {
         if (skDrawShape1DPathEffectType == type)
-                       return kDrawShape1DPathEffectName;
-               else if (skDrawShape2DPathEffectType == type)
-                       return kDrawShape2DPathEffectName;
-               else if (skDrawComposePathEffectType == type)
-                       return kDrawComposePathEffectName;
+            return kDrawShape1DPathEffectName;
+        else if (skDrawShape2DPathEffectType == type)
+            return kDrawShape2DPathEffectName;
+        else if (skDrawComposePathEffectType == type)
+            return kDrawComposePathEffectName;
         else if (skDrawCornerPathEffectType == type)
             return kDrawCornerPathEffectName;
         return NULL;
-       }
+    }
 #endif
 
-       virtual SkDisplayTypes getType(const char name[], size_t len ) {
-               SkDisplayTypes* type = nil;
-               if (SK_LITERAL_STR_EQUAL(kDrawShape1DPathEffectName, name, len))
-                       type = &skDrawShape1DPathEffectType;
-               else if (SK_LITERAL_STR_EQUAL(kDrawShape2DPathEffectName, name, len))
-                       type = &skDrawShape2DPathEffectType;
-               else if (SK_LITERAL_STR_EQUAL(kDrawComposePathEffectName, name, len))
-                       type = &skDrawComposePathEffectType;
+    virtual SkDisplayTypes getType(const char name[], size_t len ) {
+        SkDisplayTypes* type = nil;
+        if (SK_LITERAL_STR_EQUAL(kDrawShape1DPathEffectName, name, len))
+            type = &skDrawShape1DPathEffectType;
+        else if (SK_LITERAL_STR_EQUAL(kDrawShape2DPathEffectName, name, len))
+            type = &skDrawShape2DPathEffectType;
+        else if (SK_LITERAL_STR_EQUAL(kDrawComposePathEffectName, name, len))
+            type = &skDrawComposePathEffectType;
         else if (SK_LITERAL_STR_EQUAL(kDrawCornerPathEffectName, name, len))
             type = &skDrawCornerPathEffectType;
-               if (type) {
-                       if (*type == SkType_Unknown)
-                               *type = SkDisplayType::RegisterNewType();
-                       return *type;
-               }
-               return SkType_Unknown;
-       }
+        if (type) {
+            if (*type == SkType_Unknown)
+                *type = SkDisplayType::RegisterNewType();
+            return *type;
+        }
+        return SkType_Unknown;
+    }
 
 private:
-       SkDisplayTypes skDrawShape1DPathEffectType;
-       SkDisplayTypes skDrawShape2DPathEffectType;
-       SkDisplayTypes skDrawComposePathEffectType;
+    SkDisplayTypes skDrawShape1DPathEffectType;
+    SkDisplayTypes skDrawShape2DPathEffectType;
+    SkDisplayTypes skDrawComposePathEffectType;
     SkDisplayTypes skDrawCornerPathEffectType;
 };
 
 
 void InitializeSkExtraPathEffects(SkAnimator* animator) {
-       animator->addExtras(new SkExtraPathEffects(animator));
+    animator->addExtras(new SkExtraPathEffects(animator));
 }
 
 ////////////////
index 3bf27d9..9c964eb 100644 (file)
@@ -1,10 +1,27 @@
+/* libs/graphics/animator/SkDrawFull.cpp
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #include "SkDrawFull.h"
 #include "SkAnimateMaker.h"
 #include "SkCanvas.h"
 
 bool SkFull::draw(SkAnimateMaker& maker) {
-       SkBoundableAuto boundable(this, maker);
-       maker.fCanvas->drawPaint(*maker.fPaint);
-       return false;
+    SkBoundableAuto boundable(this, maker);
+    maker.fCanvas->drawPaint(*maker.fPaint);
+    return false;
 }
 
index 8822b02..68fe130 100644 (file)
@@ -1,13 +1,30 @@
+/* libs/graphics/animator/SkDrawFull.h
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #ifndef SkDrawFull_DEFINED
 #define SkDrawFull_DEFINED
 
 #include "SkBoundable.h"
 
 class SkFull : public SkBoundable {
-       DECLARE_EMPTY_MEMBER_INFO(Full);
-       virtual bool draw(SkAnimateMaker& );
+    DECLARE_EMPTY_MEMBER_INFO(Full);
+    virtual bool draw(SkAnimateMaker& );
 private:
-       typedef SkBoundable INHERITED;
+    typedef SkBoundable INHERITED;
 };
 
 #endif // SkDrawFull_DEFINED
index ae40728..8b96c69 100644 (file)
@@ -1,3 +1,20 @@
+/* libs/graphics/animator/SkDrawGradient.cpp
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #include "SkDrawGradient.h"
 #include "SkAnimateMaker.h"
 #include "SkAnimatorScript.h"
 
 SkScalar SkUnitToScalar(U16CPU x) {
 #ifdef SK_SCALAR_IS_FLOAT
-       return x / 65535.0f;
+    return x / 65535.0f;
 #else
-       return x + (x >> 8);
+    return x + (x >> 8);
 #endif
 }
 
 U16CPU SkScalarToUnit(SkScalar x) {
-       SkScalar pin =  SkScalarPin(x, 0, SK_Scalar1);
+    SkScalar pin =  SkScalarPin(x, 0, SK_Scalar1);
 #ifdef SK_SCALAR_IS_FLOAT
-       return (int) (pin * 65535.0f);
+    return (int) (pin * 65535.0f);
 #else
-       return pin - (pin >= 32768);
+    return pin - (pin >= 32768);
 #endif
 }
 
 class SkGradientUnitMapper : public SkUnitMapper {
 public:
-       SkGradientUnitMapper(SkAnimateMaker* maker, const char* script) : fMaker(maker), fScript(script) {
-       }
+    SkGradientUnitMapper(SkAnimateMaker* maker, const char* script) : fMaker(maker), fScript(script) {
+    }
 protected:
-       virtual U16CPU mapUnit16(U16CPU x) {
-               fUnit = SkUnitToScalar(x);
-               SkScriptValue value;
-               SkAnimatorScript engine(*fMaker, nil, SkType_Float);
-               engine.propertyCallBack(GetUnitValue, &fUnit);
-               if (engine.evaluate(fScript, &value, SkType_Float)) 
-                       x = SkScalarToUnit(value.fOperand.fScalar);
-               return x;
-       }
-
-       static bool GetUnitValue(const char* token, size_t len, void* unitPtr, SkScriptValue* value) {
-               if (SK_LITERAL_STR_EQUAL("unit", token, len)) {
-                       value->fOperand.fScalar = *(SkScalar*) unitPtr;
-                       value->fType = SkType_Float;
-                       return true;
-               }
-               return false;
-       }
-
-       SkAnimateMaker* fMaker;
-       const char* fScript;
-       SkScalar fUnit;
+    virtual U16CPU mapUnit16(U16CPU x) {
+        fUnit = SkUnitToScalar(x);
+        SkScriptValue value;
+        SkAnimatorScript engine(*fMaker, nil, SkType_Float);
+        engine.propertyCallBack(GetUnitValue, &fUnit);
+        if (engine.evaluate(fScript, &value, SkType_Float)) 
+            x = SkScalarToUnit(value.fOperand.fScalar);
+        return x;
+    }
+
+    static bool GetUnitValue(const char* token, size_t len, void* unitPtr, SkScriptValue* value) {
+        if (SK_LITERAL_STR_EQUAL("unit", token, len)) {
+            value->fOperand.fScalar = *(SkScalar*) unitPtr;
+            value->fType = SkType_Float;
+            return true;
+        }
+        return false;
+    }
+
+    SkAnimateMaker* fMaker;
+    const char* fScript;
+    SkScalar fUnit;
 };
 
 
 #if SK_USE_CONDENSED_INFO == 0
 
 const SkMemberInfo SkGradient::fInfo[] = {
-       SK_MEMBER_INHERITED,
-       SK_MEMBER_ARRAY(offsets, Float),
-       SK_MEMBER(unitMapper, String)
+    SK_MEMBER_INHERITED,
+    SK_MEMBER_ARRAY(offsets, Float),
+    SK_MEMBER(unitMapper, String)
 };
 
 #endif
@@ -67,27 +84,27 @@ SkGradient::SkGradient() : fUnitMapper(nil) {
 }
 
 SkGradient::~SkGradient() {
-       for (int index = 0; index < fDrawColors.count(); index++) 
-               delete fDrawColors[index];
-       delete fUnitMapper;
+    for (int index = 0; index < fDrawColors.count(); index++) 
+        delete fDrawColors[index];
+    delete fUnitMapper;
 }
 
 bool SkGradient::add(SkAnimateMaker& , SkDisplayable* child) {
-       SkASSERT(child);
-       if (child->isColor()) {
-               SkDrawColor* color = (SkDrawColor*) child;
-               *fDrawColors.append() = color;
-               return true;
-       }
-       return false;
+    SkASSERT(child);
+    if (child->isColor()) {
+        SkDrawColor* color = (SkDrawColor*) child;
+        *fDrawColors.append() = color;
+        return true;
+    }
+    return false;
 }
 
 int SkGradient::addPrelude() {
-       int count = fDrawColors.count();
-       fColors.setCount(count);
-       for (int index = 0; index < count; index++) 
-               fColors[index] = fDrawColors[index]->color;
-       return count;
+    int count = fDrawColors.count();
+    fColors.setCount(count);
+    for (int index = 0; index < count; index++) 
+        fColors[index] = fDrawColors[index]->color;
+    return count;
 }
 
 #ifdef SK_DUMP_ENABLED
@@ -134,15 +151,15 @@ void SkGradient::onEndElement(SkAnimateMaker& maker) {
             }
         }
     }
-       if (unitMapper.size() > 0) 
-               fUnitMapper = new SkGradientUnitMapper(&maker, unitMapper.c_str());
-       INHERITED::onEndElement(maker);
+    if (unitMapper.size() > 0) 
+        fUnitMapper = new SkGradientUnitMapper(&maker, unitMapper.c_str());
+    INHERITED::onEndElement(maker);
 }
 
 #if SK_USE_CONDENSED_INFO == 0
 
 const SkMemberInfo SkLinearGradient::fInfo[] = {
-       SK_MEMBER_INHERITED,
+    SK_MEMBER_INHERITED,
     SK_MEMBER_ARRAY(points, Float),
 };
 
@@ -168,23 +185,23 @@ void SkLinearGradient::dump(SkAnimateMaker* maker) {
 #endif
 
 SkShader* SkLinearGradient::getShader() {
-       if (addPrelude() == 0 || points.count() != 4)
-               return nil;
-       SkShader* shader = SkGradientShader::CreateLinear((SkPoint*)points.begin(),
-               fColors.begin(), offsets.begin(), fColors.count(), (SkShader::TileMode) tileMode, fUnitMapper);
-       SkAutoTDelete<SkShader> autoDel(shader);
-       addPostlude(shader);
-       (void)autoDel.detach();
-       return shader;
+    if (addPrelude() == 0 || points.count() != 4)
+        return nil;
+    SkShader* shader = SkGradientShader::CreateLinear((SkPoint*)points.begin(),
+        fColors.begin(), offsets.begin(), fColors.count(), (SkShader::TileMode) tileMode, fUnitMapper);
+    SkAutoTDelete<SkShader> autoDel(shader);
+    addPostlude(shader);
+    (void)autoDel.detach();
+    return shader;
 }
 
 
 #if SK_USE_CONDENSED_INFO == 0
 
 const SkMemberInfo SkRadialGradient::fInfo[] = {
-       SK_MEMBER_INHERITED,
-       SK_MEMBER(center, Point),
-       SK_MEMBER(radius, Float)
+    SK_MEMBER_INHERITED,
+    SK_MEMBER(center, Point),
+    SK_MEMBER(radius, Float)
 };
 
 #endif
@@ -192,7 +209,7 @@ const SkMemberInfo SkRadialGradient::fInfo[] = {
 DEFINE_GET_MEMBER(SkRadialGradient);
 
 SkRadialGradient::SkRadialGradient() : radius(0) { 
-       center.set(0, 0); 
+    center.set(0, 0); 
 }
 
 #ifdef SK_DUMP_ENABLED
@@ -203,12 +220,12 @@ void SkRadialGradient::dump(SkAnimateMaker* maker) {
 #endif
 
 SkShader* SkRadialGradient::getShader() {
-       if (addPrelude() == 0)
-               return nil;
-       SkShader* shader = SkGradientShader::CreateRadial(center,
-               radius, fColors.begin(), offsets.begin(), fColors.count(), (SkShader::TileMode) tileMode, fUnitMapper);
-       SkAutoTDelete<SkShader> autoDel(shader);
-       addPostlude(shader);
-       (void)autoDel.detach();
-       return shader;
+    if (addPrelude() == 0)
+        return nil;
+    SkShader* shader = SkGradientShader::CreateRadial(center,
+        radius, fColors.begin(), offsets.begin(), fColors.count(), (SkShader::TileMode) tileMode, fUnitMapper);
+    SkAutoTDelete<SkShader> autoDel(shader);
+    addPostlude(shader);
+    (void)autoDel.detach();
+    return shader;
 }
index 2940b76..4b4a3cd 100644 (file)
@@ -1,3 +1,20 @@
+/* libs/graphics/animator/SkDrawGradient.h
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #ifndef SkDrawGradient_DEFINED
 #define SkDrawGradient_DEFINED
 
 class SkUnitMapper;
 
 class SkGradient : public SkDrawShader {
-       DECLARE_PRIVATE_MEMBER_INFO(Gradient);
-       SkGradient();
-       virtual ~SkGradient();
-       virtual bool add(SkAnimateMaker& , SkDisplayable* child);
+    DECLARE_PRIVATE_MEMBER_INFO(Gradient);
+    SkGradient();
+    virtual ~SkGradient();
+    virtual bool add(SkAnimateMaker& , SkDisplayable* child);
 #ifdef SK_DUMP_ENABLED
     virtual void dumpRest(SkAnimateMaker*);
 #endif    
-       virtual void onEndElement(SkAnimateMaker& );
+    virtual void onEndElement(SkAnimateMaker& );
 protected:
-       SkTDScalarArray offsets;
-       SkString unitMapper;
-       SkTDColorArray fColors;
-       SkTDDrawColorArray fDrawColors;
-       SkUnitMapper* fUnitMapper;
-       int addPrelude();
+    SkTDScalarArray offsets;
+    SkString unitMapper;
+    SkTDColorArray fColors;
+    SkTDDrawColorArray fDrawColors;
+    SkUnitMapper* fUnitMapper;
+    int addPrelude();
 private:
-       typedef SkDrawShader INHERITED;
+    typedef SkDrawShader INHERITED;
 };
 
 class SkLinearGradient : public SkGradient {
-       DECLARE_MEMBER_INFO(LinearGradient);
-       SkLinearGradient();
+    DECLARE_MEMBER_INFO(LinearGradient);
+    SkLinearGradient();
     virtual void onEndElement(SkAnimateMaker& );
 #ifdef SK_DUMP_ENABLED
     virtual void dump(SkAnimateMaker*);
 #endif
-       virtual SkShader* getShader();
+    virtual SkShader* getShader();
 protected:
     SkTDScalarArray points;
 private:
-       typedef SkGradient INHERITED;
+    typedef SkGradient INHERITED;
 };
 
 class SkRadialGradient : public SkGradient {
-       DECLARE_MEMBER_INFO(RadialGradient);
-       SkRadialGradient();
+    DECLARE_MEMBER_INFO(RadialGradient);
+    SkRadialGradient();
 #ifdef SK_DUMP_ENABLED
     virtual void dump(SkAnimateMaker*);
 #endif    
-       virtual SkShader* getShader();
+    virtual SkShader* getShader();
 protected:
-       SkPoint center;
-       SkScalar radius;
+    SkPoint center;
+    SkScalar radius;
 private:
-       typedef SkGradient INHERITED;
+    typedef SkGradient INHERITED;
 };
 
 #endif // SkDrawGradient_DEFINED
index 89232dd..6d3d491 100644 (file)
@@ -1,3 +1,20 @@
+/* libs/graphics/animator/SkDrawGroup.cpp
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #include "SkDrawGroup.h"
 #include "SkAnimateMaker.h"
 #include "SkAnimatorScript.h"
@@ -11,8 +28,8 @@
 #if SK_USE_CONDENSED_INFO == 0
 
 const SkMemberInfo SkGroup::fInfo[] = {
-       SK_MEMBER(condition, String),
-       SK_MEMBER(enableCondition, String)
+    SK_MEMBER(condition, String),
+    SK_MEMBER(enableCondition, String)
 };
 
 #endif
@@ -23,53 +40,53 @@ SkGroup::SkGroup() : fParentList(nil), fOriginal(nil) {
 }
 
 SkGroup::~SkGroup() {
-       if (fOriginal)  // has been copied
-               return;
-       int index = 0;
-       int max = fCopies.count() << 5;
-       for (SkDrawable** ptr = fChildren.begin(); ptr < fChildren.end(); ptr++) {
-               if (index >= max || markedForDelete(index))
-                       delete *ptr;
-//             else {
-//                     SkApply* apply = (SkApply*) *ptr;
-//                     SkASSERT(apply->isApply());
-//                     SkASSERT(apply->getScope());
-//                     delete apply->getScope();
-//             }
-               index++;
-       }
+    if (fOriginal)  // has been copied
+        return;
+    int index = 0;
+    int max = fCopies.count() << 5;
+    for (SkDrawable** ptr = fChildren.begin(); ptr < fChildren.end(); ptr++) {
+        if (index >= max || markedForDelete(index))
+            delete *ptr;
+//      else {
+//          SkApply* apply = (SkApply*) *ptr;
+//          SkASSERT(apply->isApply());
+//          SkASSERT(apply->getScope());
+//          delete apply->getScope();
+//      }
+        index++;
+    }
 }
 
 bool SkGroup::add(SkAnimateMaker& , SkDisplayable* child) {
-       SkASSERT(child); 
-//     SkASSERT(child->isDrawable());
-       *fChildren.append() = (SkDrawable*) child;
-       if (child->isGroup()) {
-               SkGroup* groupie = (SkGroup*) child;
-               SkASSERT(groupie->fParentList == nil);
-               groupie->fParentList = &fChildren;
-       }
-       return true;
+    SkASSERT(child); 
+//  SkASSERT(child->isDrawable());
+    *fChildren.append() = (SkDrawable*) child;
+    if (child->isGroup()) {
+        SkGroup* groupie = (SkGroup*) child;
+        SkASSERT(groupie->fParentList == nil);
+        groupie->fParentList = &fChildren;
+    }
+    return true;
 }
 
 bool SkGroup::contains(SkDisplayable* match) {
-       for (SkDrawable** ptr = fChildren.begin(); ptr < fChildren.end(); ptr++) {
-               SkDrawable* drawable = *ptr;
-               if (drawable == match || drawable->contains(match))
-                       return true;
-       }
-       return false;
+    for (SkDrawable** ptr = fChildren.begin(); ptr < fChildren.end(); ptr++) {
+        SkDrawable* drawable = *ptr;
+        if (drawable == match || drawable->contains(match))
+            return true;
+    }
+    return false;
 }
 
 SkGroup* SkGroup::copy() {
-       SkGroup* result = new SkGroup();
-       result->fOriginal = this;
-       result->fChildren = fChildren;
-       return result;
+    SkGroup* result = new SkGroup();
+    result->fOriginal = this;
+    result->fChildren = fChildren;
+    return result;
 }
 
 SkBool SkGroup::copySet(int index) {
-       return (fCopies[index >> 5] & 1 << (index & 0x1f)) != 0;
+    return (fCopies[index >> 5] & 1 << (index & 0x1f)) != 0;
 }
 
 SkDisplayable* SkGroup::deepCopy(SkAnimateMaker* maker) {
@@ -83,61 +100,61 @@ SkDisplayable* SkGroup::deepCopy(SkAnimateMaker* maker) {
 }
 
 bool SkGroup::doEvent(SkDisplayEvent::Kind kind, SkEventState* state) {
-       bool handled = false;
-       for (SkDrawable** ptr = fChildren.begin(); ptr < fChildren.end(); ptr++) {
-               SkDrawable* drawable = *ptr;
-               if (drawable->isDrawable() == false)
-                       continue;
-               handled |= drawable->doEvent(kind, state);
-       }
-       return handled;
+    bool handled = false;
+    for (SkDrawable** ptr = fChildren.begin(); ptr < fChildren.end(); ptr++) {
+        SkDrawable* drawable = *ptr;
+        if (drawable->isDrawable() == false)
+            continue;
+        handled |= drawable->doEvent(kind, state);
+    }
+    return handled;
 }
 
 bool SkGroup::draw(SkAnimateMaker& maker) {
-       bool conditionTrue = ifCondition(maker, this, condition);
-       bool result = false;
-       for (SkDrawable** ptr = fChildren.begin(); ptr < fChildren.end(); ptr++) {
-               SkDrawable* drawable = *ptr;
-               if (drawable->isDrawable() == false)
-                       continue;
-               if (conditionTrue == false) {
-                       if (drawable->isApply())
-                               ((SkApply*) drawable)->disable();
-                       continue;
-               }
-               maker.validate();
-               result |= drawable->draw(maker);
-               maker.validate();
-       }
-       return result;
+    bool conditionTrue = ifCondition(maker, this, condition);
+    bool result = false;
+    for (SkDrawable** ptr = fChildren.begin(); ptr < fChildren.end(); ptr++) {
+        SkDrawable* drawable = *ptr;
+        if (drawable->isDrawable() == false)
+            continue;
+        if (conditionTrue == false) {
+            if (drawable->isApply())
+                ((SkApply*) drawable)->disable();
+            continue;
+        }
+        maker.validate();
+        result |= drawable->draw(maker);
+        maker.validate();
+    }
+    return result;
 }
 
 #ifdef SK_DUMP_ENABLED
 void SkGroup::dump(SkAnimateMaker* maker) {
-       dumpBase(maker);
-       if (condition.size() > 0)
-               SkDebugf("condition=\"%s\" ", condition.c_str());
+    dumpBase(maker);
+    if (condition.size() > 0)
+        SkDebugf("condition=\"%s\" ", condition.c_str());
     if (enableCondition.size() > 0)
-               SkDebugf("enableCondition=\"%s\" ", enableCondition.c_str());
+        SkDebugf("enableCondition=\"%s\" ", enableCondition.c_str());
     dumpDrawables(maker);
 }
 
 void SkGroup::dumpDrawables(SkAnimateMaker* maker) {
     SkDisplayList::fIndent += 4;
-       int save = SkDisplayList::fDumpIndex;
-       SkDisplayList::fDumpIndex = 0;
+    int save = SkDisplayList::fDumpIndex;
+    SkDisplayList::fDumpIndex = 0;
     bool closedYet = false;
-       for (SkDrawable** ptr = fChildren.begin(); ptr < fChildren.end(); ptr++) {
+    for (SkDrawable** ptr = fChildren.begin(); ptr < fChildren.end(); ptr++) {
         if (closedYet == false) {
             closedYet = true;
             SkDebugf(">\n");
         }
-               SkDrawable* drawable = *ptr;
-               drawable->dump(maker);
-               SkDisplayList::fDumpIndex++;
-       }
-       SkDisplayList::fIndent -= 4;
-       SkDisplayList::fDumpIndex = save;
+        SkDrawable* drawable = *ptr;
+        drawable->dump(maker);
+        SkDisplayList::fDumpIndex++;
+    }
+    SkDisplayList::fIndent -= 4;
+    SkDisplayList::fDumpIndex = save;
     if (closedYet) //we had children, now it's time to close the group
         dumpEnd(maker);
     else    //no children
@@ -145,155 +162,155 @@ void SkGroup::dumpDrawables(SkAnimateMaker* maker) {
 }
 
 void SkGroup::dumpEvents() {
-       for (SkDrawable** ptr = fChildren.begin(); ptr < fChildren.end(); ptr++) {
-               SkDrawable* drawable = *ptr;
-               drawable->dumpEvents();
-       }
+    for (SkDrawable** ptr = fChildren.begin(); ptr < fChildren.end(); ptr++) {
+        SkDrawable* drawable = *ptr;
+        drawable->dumpEvents();
+    }
 }
 #endif
 
 bool SkGroup::enable(SkAnimateMaker& maker ) {
-       reset();
-       for (SkDrawable** ptr = fChildren.begin(); ptr < fChildren.end(); ptr++) {
-               SkDrawable* drawable = *ptr;
-               if (ifCondition(maker, drawable, enableCondition) == false)
-                       continue;
-               drawable->enable(maker);
-       }
-       return true;    // skip add; already added so that scope is findable by children
+    reset();
+    for (SkDrawable** ptr = fChildren.begin(); ptr < fChildren.end(); ptr++) {
+        SkDrawable* drawable = *ptr;
+        if (ifCondition(maker, drawable, enableCondition) == false)
+            continue;
+        drawable->enable(maker);
+    }
+    return true;    // skip add; already added so that scope is findable by children
 }
 
 int SkGroup::findGroup(SkDrawable* match,  SkTDDrawableArray** list,
-                                SkGroup** parent, SkGroup** found, SkTDDrawableArray** grandList) {
-       *list = &fChildren;
-       for (SkDrawable** ptr = fChildren.begin(); ptr < fChildren.end(); ptr++) {
-               SkDrawable* drawable = *ptr;
-               if (drawable->isGroup()) {
-                       SkGroup* childGroup = (SkGroup*) drawable;
-                       if (childGroup->fOriginal == match)
-                               goto foundMatch;
-               }
-               if (drawable == match) {
+                 SkGroup** parent, SkGroup** found, SkTDDrawableArray** grandList) {
+    *list = &fChildren;
+    for (SkDrawable** ptr = fChildren.begin(); ptr < fChildren.end(); ptr++) {
+        SkDrawable* drawable = *ptr;
+        if (drawable->isGroup()) {
+            SkGroup* childGroup = (SkGroup*) drawable;
+            if (childGroup->fOriginal == match)
+                goto foundMatch;
+        }
+        if (drawable == match) {
 foundMatch:
-                       *parent = this;
-                       return (int) (ptr - fChildren.begin());
-               }
-       }
-       *grandList = &fChildren;
-       return SkDisplayList::SearchForMatch(match, list, parent, found, grandList);
+            *parent = this;
+            return (int) (ptr - fChildren.begin());
+        }
+    }
+    *grandList = &fChildren;
+    return SkDisplayList::SearchForMatch(match, list, parent, found, grandList);
 }
 
 bool SkGroup::hasEnable() const {
-       return true;
+    return true;
 }
 
 bool SkGroup::ifCondition(SkAnimateMaker& maker, SkDrawable* drawable,
-               SkString& conditionString) {
-       if (conditionString.size() == 0)
-               return true;
-       int32_t result;
-       bool success = SkAnimatorScript::EvaluateInt(maker, this, conditionString.c_str(), &result);
+        SkString& conditionString) {
+    if (conditionString.size() == 0)
+        return true;
+    int32_t result;
+    bool success = SkAnimatorScript::EvaluateInt(maker, this, conditionString.c_str(), &result);
 #ifdef SK_DUMP_ENABLED
-       if (maker.fDumpGConditions) {
-               SkDebugf("group: ");
-               dumpBase(&maker);
-               SkDebugf("condition=%s ", conditionString.c_str());
-               if (success == false)
-                       SkDebugf("(script failed)\n");
-               else
-                       SkDebugf("success=%s\n", result != 0 ? "true" : "false");
-       }
+    if (maker.fDumpGConditions) {
+        SkDebugf("group: ");
+        dumpBase(&maker);
+        SkDebugf("condition=%s ", conditionString.c_str());
+        if (success == false)
+            SkDebugf("(script failed)\n");
+        else
+            SkDebugf("success=%s\n", result != 0 ? "true" : "false");
+    }
 #endif
-       return success && result != 0;
+    return success && result != 0;
 }
 
 void SkGroup::initialize() {
-       for (SkDrawable** ptr = fChildren.begin(); ptr < fChildren.end(); ptr++) {
-               SkDrawable* drawable = *ptr;
-               if (drawable->isDrawable() == false)
-                       continue;
-               drawable->initialize();
-       }
+    for (SkDrawable** ptr = fChildren.begin(); ptr < fChildren.end(); ptr++) {
+        SkDrawable* drawable = *ptr;
+        if (drawable->isDrawable() == false)
+            continue;
+        drawable->initialize();
+    }
 }
 
 void SkGroup::markCopyClear(int index) {
-       if (index < 0)
-               index = fChildren.count();
-       fCopies[index >> 5] &= ~(1 << (index & 0x1f));
+    if (index < 0)
+        index = fChildren.count();
+    fCopies[index >> 5] &= ~(1 << (index & 0x1f));
 }
 
 void SkGroup::markCopySet(int index) {
-       if (index < 0)
-               index = fChildren.count();
-       fCopies[index >> 5] |= 1 << (index & 0x1f);
+    if (index < 0)
+        index = fChildren.count();
+    fCopies[index >> 5] |= 1 << (index & 0x1f);
 }
 
 void SkGroup::markCopySize(int index) {
-       if (index < 0)
-               index = fChildren.count() + 1;
-       int oldLongs = fCopies.count();
-       int newLongs = (index >> 5) + 1;
-       if (oldLongs < newLongs) {
-               fCopies.setCount(newLongs);
-               memset(&fCopies[oldLongs], 0, (newLongs - oldLongs) << 2);
-       }
+    if (index < 0)
+        index = fChildren.count() + 1;
+    int oldLongs = fCopies.count();
+    int newLongs = (index >> 5) + 1;
+    if (oldLongs < newLongs) {
+        fCopies.setCount(newLongs);
+        memset(&fCopies[oldLongs], 0, (newLongs - oldLongs) << 2);
+    }
 }
 
 void SkGroup::reset() {
-       if (fOriginal)  // has been copied
-               return;
-       int index = 0;
-       int max = fCopies.count() << 5;
-       for (SkDrawable** ptr = fChildren.begin(); ptr < fChildren.end(); ptr++) {
-               if (index >= max || copySet(index) == false)
-                       continue;
-               SkApply* apply = (SkApply*) *ptr;
-               SkASSERT(apply->isApply());
-               SkASSERT(apply->getScope());
-               *ptr = apply->getScope();
-               markCopyClear(index);
-               index++;
-       }
+    if (fOriginal)  // has been copied
+        return;
+    int index = 0;
+    int max = fCopies.count() << 5;
+    for (SkDrawable** ptr = fChildren.begin(); ptr < fChildren.end(); ptr++) {
+        if (index >= max || copySet(index) == false)
+            continue;
+        SkApply* apply = (SkApply*) *ptr;
+        SkASSERT(apply->isApply());
+        SkASSERT(apply->getScope());
+        *ptr = apply->getScope();
+        markCopyClear(index);
+        index++;
+    }
 }
 
 bool SkGroup::resolveIDs(SkAnimateMaker& maker, SkDisplayable* orig, SkApply* apply) {
-       SkGroup* original = (SkGroup*) orig;
-       SkTDDrawableArray& originalChildren = original->fChildren;
-       SkDrawable** originalPtr = originalChildren.begin();
-       SkDrawable** ptr = fChildren.begin();
-       SkDrawable** end = fChildren.end();
-       SkDrawable** origChild = ((SkGroup*) orig)->fChildren.begin();
-       while (ptr < end) {
-               SkDrawable* drawable = *ptr++;
-               maker.resolveID(drawable, *origChild++);
-               if (drawable->resolveIDs(maker, *originalPtr++, apply) == true)
-                       return true; // failed
-       }
-       return false;
+    SkGroup* original = (SkGroup*) orig;
+    SkTDDrawableArray& originalChildren = original->fChildren;
+    SkDrawable** originalPtr = originalChildren.begin();
+    SkDrawable** ptr = fChildren.begin();
+    SkDrawable** end = fChildren.end();
+    SkDrawable** origChild = ((SkGroup*) orig)->fChildren.begin();
+    while (ptr < end) {
+        SkDrawable* drawable = *ptr++;
+        maker.resolveID(drawable, *origChild++);
+        if (drawable->resolveIDs(maker, *originalPtr++, apply) == true)
+            return true; // failed
+    }
+    return false;
 }
 
 void SkGroup::setSteps(int steps) {
-       for (SkDrawable** ptr = fChildren.begin(); ptr < fChildren.end(); ptr++) {
-               SkDrawable* drawable = *ptr;
-               if (drawable->isDrawable() == false)
-                       continue;
-               drawable->setSteps(steps);
-       }
+    for (SkDrawable** ptr = fChildren.begin(); ptr < fChildren.end(); ptr++) {
+        SkDrawable* drawable = *ptr;
+        if (drawable->isDrawable() == false)
+            continue;
+        drawable->setSteps(steps);
+    }
 }
 
 #ifdef SK_DEBUG
 void SkGroup::validate() {
-       for (SkDrawable** ptr = fChildren.begin(); ptr < fChildren.end(); ptr++) {
-               SkDrawable* drawable = *ptr;
-               drawable->validate();
-       }
+    for (SkDrawable** ptr = fChildren.begin(); ptr < fChildren.end(); ptr++) {
+        SkDrawable* drawable = *ptr;
+        drawable->validate();
+    }
 }
 #endif
 
 #if SK_USE_CONDENSED_INFO == 0
 
 const SkMemberInfo SkSave::fInfo[] = {
-       SK_MEMBER_INHERITED
+    SK_MEMBER_INHERITED
 };
 
 #endif
@@ -301,14 +318,14 @@ const SkMemberInfo SkSave::fInfo[] = {
 DEFINE_GET_MEMBER(SkSave);
 
 bool SkSave::draw(SkAnimateMaker& maker) {
-       maker.fCanvas->save();
-       SkPaint* save = maker.fPaint;
-       SkPaint local = SkPaint(*maker.fPaint);
-       maker.fPaint = &local;
-       bool result = INHERITED::draw(maker);
-       maker.fPaint = save;
-       maker.fCanvas->restore();
-       return result;
+    maker.fCanvas->save();
+    SkPaint* save = maker.fPaint;
+    SkPaint local = SkPaint(*maker.fPaint);
+    maker.fPaint = &local;
+    bool result = INHERITED::draw(maker);
+    maker.fPaint = save;
+    maker.fCanvas->restore();
+    return result;
 }
 
 
index 45e3a43..2a49b82 100644 (file)
@@ -1,3 +1,20 @@
+/* libs/graphics/animator/SkDrawGroup.h
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #ifndef SkDrawGroup_DEFINED
 #define SkDrawGroup_DEFINED
 
 #include "SkIntArray.h"
 #include "SkMemberInfo.h"
 
-class SkGroup : public SkDrawable {    //interface for schema element <g>
+class SkGroup : public SkDrawable { //interface for schema element <g>
 public:
-       DECLARE_MEMBER_INFO(Group);
-       SkGroup();
-       virtual ~SkGroup();
-       virtual bool add(SkAnimateMaker& , SkDisplayable* child);
-       virtual bool contains(SkDisplayable* );
-       SkGroup* copy();
-       SkBool copySet(int index);
+    DECLARE_MEMBER_INFO(Group);
+    SkGroup();
+    virtual ~SkGroup();
+    virtual bool add(SkAnimateMaker& , SkDisplayable* child);
+    virtual bool contains(SkDisplayable* );
+    SkGroup* copy();
+    SkBool copySet(int index);
     virtual SkDisplayable* deepCopy(SkAnimateMaker* );
-       virtual bool doEvent(SkDisplayEvent::Kind , SkEventState* state );
-       virtual bool draw(SkAnimateMaker& );
+    virtual bool doEvent(SkDisplayEvent::Kind , SkEventState* state );
+    virtual bool draw(SkAnimateMaker& );
 #ifdef SK_DUMP_ENABLED
-       virtual void dump(SkAnimateMaker* );
+    virtual void dump(SkAnimateMaker* );
     virtual void dumpDrawables(SkAnimateMaker* );
-       virtual void dumpEvents();
+    virtual void dumpEvents();
 #endif
-       int findGroup(SkDrawable* drawable,  SkTDDrawableArray** list,
-               SkGroup** parent, SkGroup** found, SkTDDrawableArray** grandList);
-       virtual bool enable(SkAnimateMaker& );
-       SkTDDrawableArray* getChildren() { return &fChildren; }
-       SkGroup* getOriginal() { return fOriginal; }
-       virtual bool hasEnable() const;
-       virtual void initialize();
-       SkBool isACopy() { return fOriginal != nil; }
-       void markCopyClear(int index);
-       void markCopySet(int index);
-       void markCopySize(int index);
+    int findGroup(SkDrawable* drawable,  SkTDDrawableArray** list,
+        SkGroup** parent, SkGroup** found, SkTDDrawableArray** grandList);
+    virtual bool enable(SkAnimateMaker& );
+    SkTDDrawableArray* getChildren() { return &fChildren; }
+    SkGroup* getOriginal() { return fOriginal; }
+    virtual bool hasEnable() const;
+    virtual void initialize();
+    SkBool isACopy() { return fOriginal != nil; }
+    void markCopyClear(int index);
+    void markCopySet(int index);
+    void markCopySize(int index);
     bool markedForDelete(int index) const { return (fCopies[index >> 5] & 1 << (index & 0x1f)) == 0; }
-       void reset();
-       bool resolveIDs(SkAnimateMaker& maker, SkDisplayable* original, SkApply* );
-       virtual void setSteps(int steps);
+    void reset();
+    bool resolveIDs(SkAnimateMaker& maker, SkDisplayable* original, SkApply* );
+    virtual void setSteps(int steps);
 #ifdef SK_DEBUG
-       virtual void validate();
+    virtual void validate();
 #endif
 protected:
-       bool ifCondition(SkAnimateMaker& maker, SkDrawable* drawable,
-               SkString& conditionString);
-       SkString condition;
-       SkString enableCondition;
-       SkTDDrawableArray fChildren;
-       SkTDDrawableArray* fParentList;
-       SkTDIntArray fCopies;
-       SkGroup* fOriginal;
+    bool ifCondition(SkAnimateMaker& maker, SkDrawable* drawable,
+        SkString& conditionString);
+    SkString condition;
+    SkString enableCondition;
+    SkTDDrawableArray fChildren;
+    SkTDDrawableArray* fParentList;
+    SkTDIntArray fCopies;
+    SkGroup* fOriginal;
 private:
-       typedef SkDrawable INHERITED;
+    typedef SkDrawable INHERITED;
 };
 
 class SkSave: public SkGroup {
-       DECLARE_MEMBER_INFO(Save);
-       virtual bool draw(SkAnimateMaker& );
+    DECLARE_MEMBER_INFO(Save);
+    virtual bool draw(SkAnimateMaker& );
 private:
-       typedef SkGroup INHERITED;
+    typedef SkGroup INHERITED;
 };
 
 #endif // SkDrawGroup_DEFINED
index 3c38fbe..ad8e3c7 100644 (file)
@@ -1,3 +1,20 @@
+/* libs/graphics/animator/SkDrawLine.cpp
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #include "SkDrawLine.h"
 #include "SkAnimateMaker.h"
 #include "SkCanvas.h"
 #if SK_USE_CONDENSED_INFO == 0
 
 const SkMemberInfo SkLine::fInfo[] = {
-       SK_MEMBER(x1, Float),
-       SK_MEMBER(x2, Float),
-       SK_MEMBER(y1, Float),
-       SK_MEMBER(y2, Float)
+    SK_MEMBER(x1, Float),
+    SK_MEMBER(x2, Float),
+    SK_MEMBER(y1, Float),
+    SK_MEMBER(y2, Float)
 };
 
 #endif
@@ -20,9 +37,9 @@ SkLine::SkLine() : x1(0), x2(0), y1(0), y2(0) {
 }
 
 bool SkLine::draw(SkAnimateMaker& maker) {
-       SkPoint start = {x1, y1};
-       SkPoint stop = {x2, y2};
-       SkBoundableAuto boundable(this, maker);
-       maker.fCanvas->drawLine(start, stop, *maker.fPaint);
-       return false;
+    SkPoint start = {x1, y1};
+    SkPoint stop = {x2, y2};
+    SkBoundableAuto boundable(this, maker);
+    maker.fCanvas->drawLine(start, stop, *maker.fPaint);
+    return false;
 }
index 682c7ee..80451e3 100644 (file)
@@ -1,3 +1,20 @@
+/* libs/graphics/animator/SkDrawLine.h
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #ifndef SkDrawLine_DEFINED
 #define SkDrawLine_DEFINED
 
 #include "SkMemberInfo.h"
 
 class SkLine : public SkBoundable {
-       DECLARE_MEMBER_INFO(Line);
-       SkLine();
-       virtual bool draw(SkAnimateMaker& );
+    DECLARE_MEMBER_INFO(Line);
+    SkLine();
+    virtual bool draw(SkAnimateMaker& );
 private:
-       SkScalar x1;
-       SkScalar x2;
-       SkScalar y1;
-       SkScalar y2;
-       typedef SkBoundable INHERITED;
+    SkScalar x1;
+    SkScalar x2;
+    SkScalar y1;
+    SkScalar y2;
+    typedef SkBoundable INHERITED;
 };
 
 #endif // SkDrawLine_DEFINED
index 18b30e6..b8337cb 100644 (file)
@@ -1,3 +1,20 @@
+/* libs/graphics/animator/SkDrawMatrix.cpp
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #include "SkDrawMatrix.h"
 #include "SkAnimateMaker.h"
 #include "SkCanvas.h"
 #include "SkTypedArray.h"
 
 enum SkDrawMatrix_Properties {
-       SK_PROPERTY(perspectX),
-       SK_PROPERTY(perspectY),
-       SK_PROPERTY(rotate),
-       SK_PROPERTY(scale),
-       SK_PROPERTY(scaleX),
-       SK_PROPERTY(scaleY),
-       SK_PROPERTY(skewX),
-       SK_PROPERTY(skewY),
-       SK_PROPERTY(translate),
-       SK_PROPERTY(translateX),
-       SK_PROPERTY(translateY)
+    SK_PROPERTY(perspectX),
+    SK_PROPERTY(perspectY),
+    SK_PROPERTY(rotate),
+    SK_PROPERTY(scale),
+    SK_PROPERTY(scaleX),
+    SK_PROPERTY(scaleY),
+    SK_PROPERTY(skewX),
+    SK_PROPERTY(skewY),
+    SK_PROPERTY(translate),
+    SK_PROPERTY(translateX),
+    SK_PROPERTY(translateY)
 };
 
 #if SK_USE_CONDENSED_INFO == 0
 
 const SkMemberInfo SkDrawMatrix::fInfo[] = {
-       SK_MEMBER_ARRAY(matrix, Float),
-       SK_MEMBER_PROPERTY(perspectX, Float),
-       SK_MEMBER_PROPERTY(perspectY, Float),
-       SK_MEMBER_PROPERTY(rotate, Float),
-       SK_MEMBER_PROPERTY(scale, Float),
-       SK_MEMBER_PROPERTY(scaleX, Float),
-       SK_MEMBER_PROPERTY(scaleY, Float),
-       SK_MEMBER_PROPERTY(skewX, Float),
-       SK_MEMBER_PROPERTY(skewY, Float),
-       SK_MEMBER_PROPERTY(translate, Point),
-       SK_MEMBER_PROPERTY(translateX, Float),
-       SK_MEMBER_PROPERTY(translateY, Float)
+    SK_MEMBER_ARRAY(matrix, Float),
+    SK_MEMBER_PROPERTY(perspectX, Float),
+    SK_MEMBER_PROPERTY(perspectY, Float),
+    SK_MEMBER_PROPERTY(rotate, Float),
+    SK_MEMBER_PROPERTY(scale, Float),
+    SK_MEMBER_PROPERTY(scaleX, Float),
+    SK_MEMBER_PROPERTY(scaleY, Float),
+    SK_MEMBER_PROPERTY(skewX, Float),
+    SK_MEMBER_PROPERTY(skewY, Float),
+    SK_MEMBER_PROPERTY(translate, Point),
+    SK_MEMBER_PROPERTY(translateX, Float),
+    SK_MEMBER_PROPERTY(translateY, Float)
 };
 
 #endif
@@ -43,231 +60,231 @@ const SkMemberInfo SkDrawMatrix::fInfo[] = {
 DEFINE_GET_MEMBER(SkDrawMatrix);
 
 SkDrawMatrix::SkDrawMatrix() : fChildHasID(false), fDirty(false) { 
-       fConcat.reset();
-       fMatrix.reset(); 
+    fConcat.reset();
+    fMatrix.reset(); 
 }
 
 SkDrawMatrix::~SkDrawMatrix() {
-       for (SkMatrixPart** part = fParts.begin(); part < fParts.end();  part++)
-               delete *part;
+    for (SkMatrixPart** part = fParts.begin(); part < fParts.end();  part++)
+        delete *part;
 }
 
 bool SkDrawMatrix::add(SkAnimateMaker& maker, SkDisplayable* child) {
-       SkASSERT(child && child->isMatrixPart());
-       SkMatrixPart* part = (SkMatrixPart*) child;
-       *fParts.append() = part;
-       if (part->add())
-               maker.setErrorCode(SkDisplayXMLParserError::kErrorAddingToMatrix); 
-       return true;
+    SkASSERT(child && child->isMatrixPart());
+    SkMatrixPart* part = (SkMatrixPart*) child;
+    *fParts.append() = part;
+    if (part->add())
+        maker.setErrorCode(SkDisplayXMLParserError::kErrorAddingToMatrix); 
+    return true;
 }
 
 bool SkDrawMatrix::childrenNeedDisposing() const { 
-       return false;
+    return false;
 }
 
 SkDisplayable* SkDrawMatrix::deepCopy(SkAnimateMaker* maker) {
-       SkDrawMatrix* copy = (SkDrawMatrix*)
-               SkDisplayType::CreateInstance(maker, SkType_Matrix);
-       SkASSERT(fParts.count() == 0);
-       copy->fMatrix = fMatrix;
-       copy->fConcat = fConcat;
-       return copy;
+    SkDrawMatrix* copy = (SkDrawMatrix*)
+        SkDisplayType::CreateInstance(maker, SkType_Matrix);
+    SkASSERT(fParts.count() == 0);
+    copy->fMatrix = fMatrix;
+    copy->fConcat = fConcat;
+    return copy;
 }
 
 void SkDrawMatrix::dirty() { 
-       fDirty = true; 
+    fDirty = true; 
 }
 
 bool SkDrawMatrix::draw(SkAnimateMaker& maker) {
-       SkMatrix& concat = getMatrix();
-       maker.fCanvas->concat(concat);
-       return false;
+    SkMatrix& concat = getMatrix();
+    maker.fCanvas->concat(concat);
+    return false;
 }
 
 #ifdef SK_DUMP_ENABLED
 void SkDrawMatrix::dump(SkAnimateMaker* maker) {
-       dumpBase(maker);
-       if (fMatrix.isIdentity()) {
-               SkDebugf("matrix=\"identity\"/>\n");
-               return;
-       }
-       SkScalar result;
-       result = fMatrix.getScaleX();
-       if (result != SK_Scalar1)
-               SkDebugf("sx=\"%g\" ", SkScalarToFloat(result));
-       result = fMatrix.getScaleY();
-       if (result != SK_Scalar1)
-               SkDebugf("sy=\"%g\" ", SkScalarToFloat(result));
-       result = fMatrix.getSkewX();
-       if (result)
-               SkDebugf("skew-x=\"%g\" ", SkScalarToFloat(result));
-       result = fMatrix.getSkewY();
-       if (result)
-               SkDebugf("skew-y=\"%g\" ", SkScalarToFloat(result));
-       result = fMatrix.getTranslateX();
-       if (result)
-               SkDebugf("tx=\"%g\" ", SkScalarToFloat(result));
-       result = fMatrix.getTranslateY();
-       if (result)
-               SkDebugf("ty=\"%g\" ", SkScalarToFloat(result));
-       result = fMatrix.getPerspX();
-       if (result)
-               SkDebugf("perspect-x=\"%g\" ", SkScalarToFloat(result));
-       result = fMatrix.getPerspY();
-       if (result)
-               SkDebugf("perspect-y=\"%g\" ", SkScalarToFloat(result));
-       SkDebugf("/>\n");
+    dumpBase(maker);
+    if (fMatrix.isIdentity()) {
+        SkDebugf("matrix=\"identity\"/>\n");
+        return;
+    }
+    SkScalar result;
+    result = fMatrix.getScaleX();
+    if (result != SK_Scalar1)
+        SkDebugf("sx=\"%g\" ", SkScalarToFloat(result));
+    result = fMatrix.getScaleY();
+    if (result != SK_Scalar1)
+        SkDebugf("sy=\"%g\" ", SkScalarToFloat(result));
+    result = fMatrix.getSkewX();
+    if (result)
+        SkDebugf("skew-x=\"%g\" ", SkScalarToFloat(result));
+    result = fMatrix.getSkewY();
+    if (result)
+        SkDebugf("skew-y=\"%g\" ", SkScalarToFloat(result));
+    result = fMatrix.getTranslateX();
+    if (result)
+        SkDebugf("tx=\"%g\" ", SkScalarToFloat(result));
+    result = fMatrix.getTranslateY();
+    if (result)
+        SkDebugf("ty=\"%g\" ", SkScalarToFloat(result));
+    result = fMatrix.getPerspX();
+    if (result)
+        SkDebugf("perspect-x=\"%g\" ", SkScalarToFloat(result));
+    result = fMatrix.getPerspY();
+    if (result)
+        SkDebugf("perspect-y=\"%g\" ", SkScalarToFloat(result));
+    SkDebugf("/>\n");
 }
 #endif
 
 SkMatrix& SkDrawMatrix::getMatrix() {
-       if (fDirty == false)
-               return fConcat;
-       fMatrix.reset();
-       for (SkMatrixPart** part = fParts.begin(); part < fParts.end();  part++) {
-               (*part)->add();
-               fConcat = fMatrix;
-       }
-       fDirty = false;
-       return fConcat;
+    if (fDirty == false)
+        return fConcat;
+    fMatrix.reset();
+    for (SkMatrixPart** part = fParts.begin(); part < fParts.end();  part++) {
+        (*part)->add();
+        fConcat = fMatrix;
+    }
+    fDirty = false;
+    return fConcat;
 }
 
 bool SkDrawMatrix::getProperty(int index, SkScriptValue* value) const {
-       value->fType = SkType_Float;
-       SkScalar result;
-       switch (index) {
-               case SK_PROPERTY(perspectX):
-                       result = fMatrix.getPerspX();
-                       break;
-               case SK_PROPERTY(perspectY):
-                       result = fMatrix.getPerspY();
-                       break;
-               case SK_PROPERTY(scaleX):
-                       result = fMatrix.getScaleX();
-                       break;
-               case SK_PROPERTY(scaleY):
-                       result = fMatrix.getScaleY();
-                       break;
-               case SK_PROPERTY(skewX):
-                       result = fMatrix.getSkewX();
-                       break;
-               case SK_PROPERTY(skewY):
-                       result = fMatrix.getSkewY();
-                       break;
-               case SK_PROPERTY(translateX):
-                       result = fMatrix.getTranslateX();
-                       break;
-               case SK_PROPERTY(translateY):
-                       result = fMatrix.getTranslateY();
-                       break;
-               default:
-//                     SkASSERT(0);
-                       return false;
-       }
-       value->fOperand.fScalar = result;
-       return true;
+    value->fType = SkType_Float;
+    SkScalar result;
+    switch (index) {
+        case SK_PROPERTY(perspectX):
+            result = fMatrix.getPerspX();
+            break;
+        case SK_PROPERTY(perspectY):
+            result = fMatrix.getPerspY();
+            break;
+        case SK_PROPERTY(scaleX):
+            result = fMatrix.getScaleX();
+            break;
+        case SK_PROPERTY(scaleY):
+            result = fMatrix.getScaleY();
+            break;
+        case SK_PROPERTY(skewX):
+            result = fMatrix.getSkewX();
+            break;
+        case SK_PROPERTY(skewY):
+            result = fMatrix.getSkewY();
+            break;
+        case SK_PROPERTY(translateX):
+            result = fMatrix.getTranslateX();
+            break;
+        case SK_PROPERTY(translateY):
+            result = fMatrix.getTranslateY();
+            break;
+        default:
+//          SkASSERT(0);
+            return false;
+    }
+    value->fOperand.fScalar = result;
+    return true;
 }
 
 void SkDrawMatrix::initialize() {
-       fConcat = fMatrix;
+    fConcat = fMatrix;
 }
 
 void SkDrawMatrix::onEndElement(SkAnimateMaker& ) {
-       if (matrix.count() > 0) {
-               SkScalar* vals = matrix.begin();
-               fMatrix.setScaleX(vals[0]);
-               fMatrix.setSkewX(vals[1]);
-               fMatrix.setTranslateX(vals[2]);
-               fMatrix.setSkewY(vals[3]);
-               fMatrix.setScaleY(vals[4]);
-               fMatrix.setTranslateY(vals[5]);
+    if (matrix.count() > 0) {
+        SkScalar* vals = matrix.begin();
+        fMatrix.setScaleX(vals[0]);
+        fMatrix.setSkewX(vals[1]);
+        fMatrix.setTranslateX(vals[2]);
+        fMatrix.setSkewY(vals[3]);
+        fMatrix.setScaleY(vals[4]);
+        fMatrix.setTranslateY(vals[5]);
 #ifdef SK_SCALAR_IS_FIXED
-               fMatrix.setPerspX(SkFixedToFract(vals[6]));
-               fMatrix.setPerspY(SkFixedToFract(vals[7]));
+        fMatrix.setPerspX(SkFixedToFract(vals[6]));
+        fMatrix.setPerspY(SkFixedToFract(vals[7]));
 #else
-               fMatrix.setPerspX(vals[6]);
-               fMatrix.setPerspY(vals[7]);
+        fMatrix.setPerspX(vals[6]);
+        fMatrix.setPerspY(vals[7]);
 #endif
-//             fMatrix.setPerspW(vals[8]);
-               goto setConcat;
-       }
-       if (fChildHasID == false) {
-               {
-                       for (SkMatrixPart** part = fParts.begin(); part < fParts.end();  part++)
-                               delete *part;
-               }
-               fParts.reset();
+//      fMatrix.setPerspW(vals[8]);
+        goto setConcat;
+    }
+    if (fChildHasID == false) {
+        {
+            for (SkMatrixPart** part = fParts.begin(); part < fParts.end();  part++)
+                delete *part;
+        }
+        fParts.reset();
 setConcat:
-               fConcat = fMatrix;
-               fDirty = false;
-       }
+        fConcat = fMatrix;
+        fDirty = false;
+    }
 }
 
 void SkDrawMatrix::setChildHasID() { 
-       fChildHasID = true; 
+    fChildHasID = true; 
 }
 
 bool SkDrawMatrix::setProperty(int index, SkScriptValue& scriptValue) {
-       SkScalar number = scriptValue.fOperand.fScalar;
-       switch (index) {
-               case SK_PROPERTY(translate):
-       //              SkScalar xy[2];
-                       SkASSERT(scriptValue.fType == SkType_Array);
-                       SkASSERT(scriptValue.fOperand.fArray->getType() == SkType_Float);
-                       SkASSERT(scriptValue.fOperand.fArray->count() == 2);
-       //              SkParse::FindScalars(scriptValue.fOperand.fString->c_str(), xy, 2);
-                       fMatrix.setTranslateX((*scriptValue.fOperand.fArray)[0].fScalar);
-                       fMatrix.setTranslateY((*scriptValue.fOperand.fArray)[1].fScalar);
-                       return true;
-               case SK_PROPERTY(perspectX):
+    SkScalar number = scriptValue.fOperand.fScalar;
+    switch (index) {
+        case SK_PROPERTY(translate):
+    //      SkScalar xy[2];
+            SkASSERT(scriptValue.fType == SkType_Array);
+            SkASSERT(scriptValue.fOperand.fArray->getType() == SkType_Float);
+            SkASSERT(scriptValue.fOperand.fArray->count() == 2);
+    //      SkParse::FindScalars(scriptValue.fOperand.fString->c_str(), xy, 2);
+            fMatrix.setTranslateX((*scriptValue.fOperand.fArray)[0].fScalar);
+            fMatrix.setTranslateY((*scriptValue.fOperand.fArray)[1].fScalar);
+            return true;
+        case SK_PROPERTY(perspectX):
 #ifdef SK_SCALAR_IS_FIXED
-                       fMatrix.setPerspX(SkFixedToFract(number));
+            fMatrix.setPerspX(SkFixedToFract(number));
 #else
-                       fMatrix.setPerspX(number);
-#endif 
-                       break;
-               case SK_PROPERTY(perspectY):
+            fMatrix.setPerspX(number);
+#endif  
+            break;
+        case SK_PROPERTY(perspectY):
 #ifdef SK_SCALAR_IS_FIXED
-                       fMatrix.setPerspY(SkFixedToFract(number));
+            fMatrix.setPerspY(SkFixedToFract(number));
 #else
-                       fMatrix.setPerspY(number);
-#endif 
-                       break;
-               case SK_PROPERTY(rotate): {
-                       SkMatrix temp;
-                       temp.setRotate(number, 0, 0);
-                       fMatrix.setScaleX(temp.getScaleX());
-                       fMatrix.setScaleY(temp.getScaleY());
-                       fMatrix.setSkewX(temp.getSkewX());
-                       fMatrix.setSkewY(temp.getSkewY());
-                       } break;
-               case SK_PROPERTY(scale):
-                       fMatrix.setScaleX(number);
-                       fMatrix.setScaleY(number);
-                       break;
-               case SK_PROPERTY(scaleX):
-                       fMatrix.setScaleX(number);
-                       break;
-               case SK_PROPERTY(scaleY):
-                       fMatrix.setScaleY(number);
-                       break;
-               case SK_PROPERTY(skewX):
-                       fMatrix.setSkewX(number);
-                       break;
-               case SK_PROPERTY(skewY):
-                       fMatrix.setSkewY(number);
-                       break;
-               case SK_PROPERTY(translateX):
-                       fMatrix.setTranslateX(number);
-                       break;
-               case SK_PROPERTY(translateY):
-                       fMatrix.setTranslateY(number);
-                       break;
-               default:
-                       SkASSERT(0);
-                       return false;
-       }
-       fConcat = fMatrix;
-       return true;
+            fMatrix.setPerspY(number);
+#endif  
+            break;
+        case SK_PROPERTY(rotate): {
+            SkMatrix temp;
+            temp.setRotate(number, 0, 0);
+            fMatrix.setScaleX(temp.getScaleX());
+            fMatrix.setScaleY(temp.getScaleY());
+            fMatrix.setSkewX(temp.getSkewX());
+            fMatrix.setSkewY(temp.getSkewY());
+            } break;
+        case SK_PROPERTY(scale):
+            fMatrix.setScaleX(number);
+            fMatrix.setScaleY(number);
+            break;
+        case SK_PROPERTY(scaleX):
+            fMatrix.setScaleX(number);
+            break;
+        case SK_PROPERTY(scaleY):
+            fMatrix.setScaleY(number);
+            break;
+        case SK_PROPERTY(skewX):
+            fMatrix.setSkewX(number);
+            break;
+        case SK_PROPERTY(skewY):
+            fMatrix.setSkewY(number);
+            break;
+        case SK_PROPERTY(translateX):
+            fMatrix.setTranslateX(number);
+            break;
+        case SK_PROPERTY(translateY):
+            fMatrix.setTranslateY(number);
+            break;
+        default:
+            SkASSERT(0);
+            return false;
+    }
+    fConcat = fMatrix;
+    return true;
 }
 
index df55292..1cf00ff 100644 (file)
@@ -1,3 +1,20 @@
+/* libs/graphics/animator/SkDrawMatrix.h
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #ifndef SkDrawMatrix_DEFINED
 #define SkDrawMatrix_DEFINED
 
 class SkMatrixPart;
 
 class SkDrawMatrix : public SkDrawable {
-       DECLARE_DRAW_MEMBER_INFO(Matrix);
-       SkDrawMatrix();
-       virtual ~SkDrawMatrix();
-       virtual bool add(SkAnimateMaker& , SkDisplayable* child);
-       virtual bool childrenNeedDisposing() const;
-       virtual void dirty();
-       virtual bool draw(SkAnimateMaker& );
+    DECLARE_DRAW_MEMBER_INFO(Matrix);
+    SkDrawMatrix();
+    virtual ~SkDrawMatrix();
+    virtual bool add(SkAnimateMaker& , SkDisplayable* child);
+    virtual bool childrenNeedDisposing() const;
+    virtual void dirty();
+    virtual bool draw(SkAnimateMaker& );
 #ifdef SK_DUMP_ENABLED
-       virtual void dump(SkAnimateMaker* );
+    virtual void dump(SkAnimateMaker* );
 #endif
-       SkMatrix& getMatrix();
-       virtual bool getProperty(int index, SkScriptValue* value) const;
-       virtual void initialize();
-       virtual void onEndElement(SkAnimateMaker& );
-       virtual void setChildHasID();
-       virtual bool setProperty(int index, SkScriptValue& );
+    SkMatrix& getMatrix();
+    virtual bool getProperty(int index, SkScriptValue* value) const;
+    virtual void initialize();
+    virtual void onEndElement(SkAnimateMaker& );
+    virtual void setChildHasID();
+    virtual bool setProperty(int index, SkScriptValue& );
 
-       void concat(SkMatrix& inMatrix) {
-               fConcat.preConcat(inMatrix);
-       }
+    void concat(SkMatrix& inMatrix) {
+        fConcat.preConcat(inMatrix);
+    }
 
-       virtual SkDisplayable* deepCopy(SkAnimateMaker* );
+    virtual SkDisplayable* deepCopy(SkAnimateMaker* );
 
 
-       void rotate(SkScalar degrees, SkPoint& center) {
-               fMatrix.preRotate(degrees, center.fX, center.fY);
-       }
+    void rotate(SkScalar degrees, SkPoint& center) {
+        fMatrix.preRotate(degrees, center.fX, center.fY);
+    }
 
-       void set(SkMatrix& src) {
-               fMatrix.preConcat(src);
-       }
+    void set(SkMatrix& src) {
+        fMatrix.preConcat(src);
+    }
 
-       void scale(SkScalar scaleX, SkScalar scaleY, SkPoint& center) {
-               fMatrix.preScale(scaleX, scaleY, center.fX, center.fY);
-       }
+    void scale(SkScalar scaleX, SkScalar scaleY, SkPoint& center) {
+        fMatrix.preScale(scaleX, scaleY, center.fX, center.fY);
+    }
 
-       void skew(SkScalar skewX, SkScalar skewY, SkPoint& center) {
-               fMatrix.preSkew(skewX, skewY, center.fX, center.fY);
-       }
+    void skew(SkScalar skewX, SkScalar skewY, SkPoint& center) {
+        fMatrix.preSkew(skewX, skewY, center.fX, center.fY);
+    }
 
-       void translate(SkScalar x, SkScalar y) {
-               fMatrix.preTranslate(x, y);
-       }
+    void translate(SkScalar x, SkScalar y) {
+        fMatrix.preTranslate(x, y);
+    }
 private:
-       SkTDScalarArray matrix;
-       SkMatrix fConcat;
-       SkMatrix fMatrix;
-       SkTDMatrixPartArray fParts;
-       SkBool8 fChildHasID;
-       SkBool8 fDirty;
-       typedef SkDrawable INHERITED;
+    SkTDScalarArray matrix;
+    SkMatrix fConcat;
+    SkMatrix fMatrix;
+    SkTDMatrixPartArray fParts;
+    SkBool8 fChildHasID;
+    SkBool8 fDirty;
+    typedef SkDrawable INHERITED;
 };
 
 #endif // SkDrawMatrix_DEFINED
index 11614eb..734bcad 100644 (file)
@@ -1,3 +1,20 @@
+/* libs/graphics/animator/SkDrawOval.cpp
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #include "SkDrawOval.h"
 #include "SkAnimateMaker.h"
 #include "SkCanvas.h"
@@ -5,7 +22,7 @@
 #if SK_USE_CONDENSED_INFO == 0
 
 const SkMemberInfo SkOval::fInfo[] = {
-       SK_MEMBER_INHERITED,
+    SK_MEMBER_INHERITED,
 };
 
 #endif
@@ -13,8 +30,8 @@ const SkMemberInfo SkOval::fInfo[] = {
 DEFINE_GET_MEMBER(SkOval);
 
 bool SkOval::draw(SkAnimateMaker& maker) {
-       SkBoundableAuto boundable(this, maker);
-       maker.fCanvas->drawOval(fRect, *maker.fPaint);
-       return false;
+    SkBoundableAuto boundable(this, maker);
+    maker.fCanvas->drawOval(fRect, *maker.fPaint);
+    return false;
 }
 
index e91576a..2bfec9d 100644 (file)
@@ -1,13 +1,30 @@
+/* libs/graphics/animator/SkDrawOval.h
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #ifndef SkDrawOval_DEFINED
 #define SkDrawOval_DEFINED
 
 #include "SkDrawRectangle.h"
 
 class SkOval : public SkDrawRect {
-       DECLARE_MEMBER_INFO(Oval);
-       virtual bool draw(SkAnimateMaker& );
+    DECLARE_MEMBER_INFO(Oval);
+    virtual bool draw(SkAnimateMaker& );
 private:
-       typedef SkDrawRect INHERITED;
+    typedef SkDrawRect INHERITED;
 };
 
 #endif // SkDrawOval_DEFINED
index 1f13091..004e358 100644 (file)
@@ -1,3 +1,20 @@
+/* libs/graphics/animator/SkDrawPaint.cpp
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #include "SkDrawPaint.h"
 #include "SkAnimateMaker.h"
 #include "SkDrawColor.h"
 #include "SkPathEffect.h"
 
 enum SkPaint_Functions {
-       SK_FUNCTION(measureText)
+    SK_FUNCTION(measureText)
 };
 
 enum SkPaint_Properties {
-       SK_PROPERTY(ascent),
-       SK_PROPERTY(descent)
+    SK_PROPERTY(ascent),
+    SK_PROPERTY(descent)
 };
 
 // !!! in the future, this could be compiled by build-condensed-info into an array of parameters
 // with a lookup table to find the first parameter -- for now, it is iteratively searched through
 const SkFunctionParamType SkDrawPaint::fFunctionParameters[] = {
-       (SkFunctionParamType) SkType_String,
-       (SkFunctionParamType) 0 // terminator for parameter list (there may be multiple parameter lists)
+    (SkFunctionParamType) SkType_String,
+    (SkFunctionParamType) 0 // terminator for parameter list (there may be multiple parameter lists)
 };
 
 
 #if SK_USE_CONDENSED_INFO == 0
 
 const SkMemberInfo SkDrawPaint::fInfo[] = {
-       SK_MEMBER(antiAlias, Boolean),
-       SK_MEMBER_PROPERTY(ascent, Float),
-       SK_MEMBER(color, Color),
-       SK_MEMBER_PROPERTY(descent, Float),
-       SK_MEMBER(fakeBold, Boolean),
-       SK_MEMBER(filterType, FilterType),
-       SK_MEMBER(linearText, Boolean),
-       SK_MEMBER(maskFilter, MaskFilter),
-       SK_MEMBER_FUNCTION(measureText, Float),
-       SK_MEMBER(pathEffect, PathEffect),
-       SK_MEMBER(shader, Shader),
-       SK_MEMBER(strikeThru, Boolean),
-       SK_MEMBER(stroke, Boolean),
-       SK_MEMBER(strokeCap, Cap),
-       SK_MEMBER(strokeJoin, Join),
-       SK_MEMBER(strokeMiter, Float),
-       SK_MEMBER(strokeWidth, Float),
-       SK_MEMBER(style, Style),
-       SK_MEMBER(textAlign, Align),
-       SK_MEMBER(textScaleX, Float),
-       SK_MEMBER(textSize, Float),
-       SK_MEMBER(textSkewX, Float),
-       SK_MEMBER(typeface, Typeface),
-       SK_MEMBER(underline, Boolean),
-       SK_MEMBER(xfermode, Xfermode)
+    SK_MEMBER(antiAlias, Boolean),
+    SK_MEMBER_PROPERTY(ascent, Float),
+    SK_MEMBER(color, Color),
+    SK_MEMBER_PROPERTY(descent, Float),
+    SK_MEMBER(fakeBold, Boolean),
+    SK_MEMBER(filterType, FilterType),
+    SK_MEMBER(linearText, Boolean),
+    SK_MEMBER(maskFilter, MaskFilter),
+    SK_MEMBER_FUNCTION(measureText, Float),
+    SK_MEMBER(pathEffect, PathEffect),
+    SK_MEMBER(shader, Shader),
+    SK_MEMBER(strikeThru, Boolean),
+    SK_MEMBER(stroke, Boolean),
+    SK_MEMBER(strokeCap, Cap),
+    SK_MEMBER(strokeJoin, Join),
+    SK_MEMBER(strokeMiter, Float),
+    SK_MEMBER(strokeWidth, Float),
+    SK_MEMBER(style, Style),
+    SK_MEMBER(textAlign, Align),
+    SK_MEMBER(textScaleX, Float),
+    SK_MEMBER(textSize, Float),
+    SK_MEMBER(textSkewX, Float),
+    SK_MEMBER(typeface, Typeface),
+    SK_MEMBER(underline, Boolean),
+    SK_MEMBER(xfermode, Xfermode)
 };
 
 #endif
@@ -58,58 +75,58 @@ const SkMemberInfo SkDrawPaint::fInfo[] = {
 DEFINE_GET_MEMBER(SkDrawPaint);
 
 SkDrawPaint::SkDrawPaint() : antiAlias(-1), color(NULL), fakeBold(-1), filterType((SkPaint::FilterType) -1),
-       linearText(-1), maskFilter((SkDrawMaskFilter*) -1), pathEffect((SkDrawPathEffect*) -1),
-       shader((SkDrawShader*) -1), strikeThru(-1), stroke(-1),
-       strokeCap((SkPaint::Cap) -1), strokeJoin((SkPaint::Join) -1), strokeMiter(SK_ScalarNaN), 
-       strokeWidth(SK_ScalarNaN), style((SkPaint::Style) -1),
-       textAlign((SkPaint::Align) -1), textScaleX(SK_ScalarNaN), textSize(SK_ScalarNaN), 
-       textSkewX(SK_ScalarNaN), typeface((SkDrawTypeface*) -1),
-       underline(-1), xfermode((SkPorterDuff::Mode) -1), fOwnsColor(false), fOwnsMaskFilter(false), 
-       fOwnsPathEffect(false), fOwnsShader(false), fOwnsTypeface(false) {
+    linearText(-1), maskFilter((SkDrawMaskFilter*) -1), pathEffect((SkDrawPathEffect*) -1),
+    shader((SkDrawShader*) -1), strikeThru(-1), stroke(-1),
+    strokeCap((SkPaint::Cap) -1), strokeJoin((SkPaint::Join) -1), strokeMiter(SK_ScalarNaN), 
+    strokeWidth(SK_ScalarNaN), style((SkPaint::Style) -1),
+    textAlign((SkPaint::Align) -1), textScaleX(SK_ScalarNaN), textSize(SK_ScalarNaN), 
+    textSkewX(SK_ScalarNaN), typeface((SkDrawTypeface*) -1),
+    underline(-1), xfermode((SkPorterDuff::Mode) -1), fOwnsColor(false), fOwnsMaskFilter(false), 
+    fOwnsPathEffect(false), fOwnsShader(false), fOwnsTypeface(false) {
 }
 
 SkDrawPaint::~SkDrawPaint() {
-       if (fOwnsColor)
-               delete color;
-       if (fOwnsMaskFilter)
-               delete maskFilter;
-       if (fOwnsPathEffect)
-               delete pathEffect;
-       if (fOwnsShader)
-               delete shader;
-       if (fOwnsTypeface)
-               delete typeface;
+    if (fOwnsColor)
+        delete color;
+    if (fOwnsMaskFilter)
+        delete maskFilter;
+    if (fOwnsPathEffect)
+        delete pathEffect;
+    if (fOwnsShader)
+        delete shader;
+    if (fOwnsTypeface)
+        delete typeface;
 }
 
 bool SkDrawPaint::add(SkAnimateMaker& maker, SkDisplayable* child) {
-       SkASSERT(child && child->isPaintPart());
-       SkPaintPart* part = (SkPaintPart*) child;
-       if (part->add())
-               maker.setErrorCode(SkDisplayXMLParserError::kErrorAddingToPaint); 
-       return true;
+    SkASSERT(child && child->isPaintPart());
+    SkPaintPart* part = (SkPaintPart*) child;
+    if (part->add())
+        maker.setErrorCode(SkDisplayXMLParserError::kErrorAddingToPaint); 
+    return true;
 }
 
 SkDisplayable* SkDrawPaint::deepCopy(SkAnimateMaker* maker) {
-       SkDrawColor* tempColor = color;
-       color = NULL;
-       SkDrawPaint* copy = (SkDrawPaint*) INHERITED::deepCopy(maker);
-       color = tempColor;
-       tempColor = (SkDrawColor*) color->deepCopy(maker);
-       tempColor->setParent(copy);
-       tempColor->add();
-       copy->fOwnsColor = true;
-       return copy;
+    SkDrawColor* tempColor = color;
+    color = NULL;
+    SkDrawPaint* copy = (SkDrawPaint*) INHERITED::deepCopy(maker);
+    color = tempColor;
+    tempColor = (SkDrawColor*) color->deepCopy(maker);
+    tempColor->setParent(copy);
+    tempColor->add();
+    copy->fOwnsColor = true;
+    return copy;
 }
 
 bool SkDrawPaint::draw(SkAnimateMaker& maker) {
-       SkPaint* paint = maker.fPaint;
-       setupPaint(paint);
-       return false;
+    SkPaint* paint = maker.fPaint;
+    setupPaint(paint);
+    return false;
 }
 
 #ifdef SK_DUMP_ENABLED
 void SkDrawPaint::dump(SkAnimateMaker* maker) {
-       dumpBase(maker);
+    dumpBase(maker);
     dumpAttrs(maker);
     bool closedYet = false;
     SkDisplayList::fIndent +=4;
@@ -139,122 +156,122 @@ void SkDrawPaint::dump(SkAnimateMaker* maker) {
 #endif
     
 void SkDrawPaint::executeFunction(SkDisplayable* target, int index, 
-               SkTDArray<SkScriptValue>& parameters, SkDisplayTypes type,
-               SkScriptValue* scriptValue) {
-               if (scriptValue == NULL)
-                       return;
-       SkASSERT(target == this);
-       switch (index) {
-               case SK_FUNCTION(measureText): {
-                       SkASSERT(parameters.count() == 1);
-                       SkASSERT(type == SkType_Float);
-                       SkPaint paint;
-                       setupPaint(&paint);
-                       scriptValue->fType = SkType_Float;
-                       SkASSERT(parameters[0].fType == SkType_String);
-                       scriptValue->fOperand.fScalar = paint.measureText(parameters[0].fOperand.fString->c_str(), 
-                               parameters[0].fOperand.fString->size()); 
-//                     SkDebugf("measureText: %s = %g\n", parameters[0].fOperand.fString->c_str(), 
-//                             scriptValue->fOperand.fScalar / 65536.0f);
-                       } break;
-               default:
-                       SkASSERT(0);
-       }
+        SkTDArray<SkScriptValue>& parameters, SkDisplayTypes type,
+        SkScriptValue* scriptValue) {
+        if (scriptValue == NULL)
+            return;
+    SkASSERT(target == this);
+    switch (index) {
+        case SK_FUNCTION(measureText): {
+            SkASSERT(parameters.count() == 1);
+            SkASSERT(type == SkType_Float);
+            SkPaint paint;
+            setupPaint(&paint);
+            scriptValue->fType = SkType_Float;
+            SkASSERT(parameters[0].fType == SkType_String);
+            scriptValue->fOperand.fScalar = paint.measureText(parameters[0].fOperand.fString->c_str(), 
+                parameters[0].fOperand.fString->size()); 
+//          SkDebugf("measureText: %s = %g\n", parameters[0].fOperand.fString->c_str(), 
+//              scriptValue->fOperand.fScalar / 65536.0f);
+            } break;
+        default:
+            SkASSERT(0);
+    }
 }
 
 const SkFunctionParamType* SkDrawPaint::getFunctionsParameters() {
-       return fFunctionParameters;
+    return fFunctionParameters;
 }
 
 bool SkDrawPaint::getProperty(int index, SkScriptValue* value) const {
-       SkScalar above, below;
-       SkPaint paint;
-       setupPaint(&paint);
-       paint.measureText("", 0, &above, &below);
-       switch (index) {
-               case SK_PROPERTY(ascent):
-                       value->fOperand.fScalar = above;
-                       break;
-               case SK_PROPERTY(descent):
-                       value->fOperand.fScalar = below;
-                       break;
-               default:
-                       SkASSERT(0);
-                       return false;
-       }
-       value->fType = SkType_Float;
-       return true;
+    SkScalar above, below;
+    SkPaint paint;
+    setupPaint(&paint);
+    paint.measureText("", 0, &above, &below);
+    switch (index) {
+        case SK_PROPERTY(ascent):
+            value->fOperand.fScalar = above;
+            break;
+        case SK_PROPERTY(descent):
+            value->fOperand.fScalar = below;
+            break;
+        default:
+            SkASSERT(0);
+            return false;
+    }
+    value->fType = SkType_Float;
+    return true;
 }
 
 bool SkDrawPaint::resolveIDs(SkAnimateMaker& maker, SkDisplayable* origDisp, SkApply* ) {
-       SkASSERT(origDisp->isPaint());
-       SkDrawPaint* original = (SkDrawPaint*) origDisp;
-       if (fOwnsColor && maker.resolveID(color, original->color) == false)
-               return true;
-       if (fOwnsMaskFilter && maker.resolveID(maskFilter, original->maskFilter) == false)
-               return true;
-       if (fOwnsPathEffect && maker.resolveID(pathEffect, original->pathEffect) == false)
-               return true;
-       if (fOwnsShader && maker.resolveID(shader, original->shader) == false)
-               return true;
-       if (fOwnsTypeface && maker.resolveID(typeface, original->typeface) == false)
-               return true;
-       return false; // succeeded 
+    SkASSERT(origDisp->isPaint());
+    SkDrawPaint* original = (SkDrawPaint*) origDisp;
+    if (fOwnsColor && maker.resolveID(color, original->color) == false)
+        return true;
+    if (fOwnsMaskFilter && maker.resolveID(maskFilter, original->maskFilter) == false)
+        return true;
+    if (fOwnsPathEffect && maker.resolveID(pathEffect, original->pathEffect) == false)
+        return true;
+    if (fOwnsShader && maker.resolveID(shader, original->shader) == false)
+        return true;
+    if (fOwnsTypeface && maker.resolveID(typeface, original->typeface) == false)
+        return true;
+    return false; // succeeded 
 }
 
 void SkDrawPaint::setupPaint(SkPaint* paint) const {
-       if (antiAlias != -1)
-               paint->setAntiAliasOn(SkToBool(antiAlias));
-       if (color != NULL)
-               paint->setColor(color->getColor());
-       if (fakeBold != -1)
-               paint->setFakeBoldTextOn(SkToBool(fakeBold));
-       if (filterType != (SkPaint::FilterType) -1)
-               paint->setFilterType((SkPaint::FilterType) filterType);
-       //      stroke is legacy; style setting if present overrides stroke
-       if (stroke != -1)
-               paint->setStyle(SkToBool(stroke) ? SkPaint::kStroke_Style : SkPaint::kFill_Style);
-       if (style != (SkPaint::Style) -1)
-               paint->setStyle((SkPaint::Style) style);
-       if (linearText != -1)
-               paint->setLinearTextOn(SkToBool(linearText));
-       if (maskFilter == NULL)
-               paint->setMaskFilter(NULL);
-       else if (maskFilter != (SkDrawMaskFilter*) -1)
-               paint->setMaskFilter(maskFilter->getMaskFilter())->safeUnref();
-       if (pathEffect == NULL)
-               paint->setPathEffect(NULL);
-       else if (pathEffect != (SkDrawPathEffect*) -1)
-               paint->setPathEffect(pathEffect->getPathEffect())->safeUnref();
-       if (shader == NULL)
-               paint->setShader(NULL);
-       else if (shader != (SkDrawShader*) -1)
-               paint->setShader(shader->getShader())->safeUnref();
-       if (strikeThru != -1)
-               paint->setStrikeThruTextOn(SkToBool(strikeThru));
-       if (strokeCap != (SkPaint::Cap) -1)
-               paint->setStrokeCap((SkPaint::Cap) strokeCap);
-       if (strokeJoin != (SkPaint::Join) -1)
-               paint->setStrokeJoin((SkPaint::Join) strokeJoin);
-       if (SkScalarIsNaN(strokeMiter) == false)
-               paint->setStrokeMiter(strokeMiter);
-       if (SkScalarIsNaN(strokeWidth) == false)
-               paint->setStrokeWidth(strokeWidth);
-       if (textAlign != (SkPaint::Align) -1)
-               paint->setTextAlign((SkPaint::Align) textAlign);
-       if (SkScalarIsNaN(textScaleX) == false)
-               paint->setTextScaleX(textScaleX);
-       if (SkScalarIsNaN(textSize) == false)
-               paint->setTextSize(textSize);
-       if (SkScalarIsNaN(textSkewX) == false)
-               paint->setTextSkewX(textSkewX);
-       if (typeface == NULL)
-               paint->setTypeface(NULL);
-       else if (typeface != (SkDrawTypeface*) -1)
-               paint->setTypeface(typeface->getTypeface())->safeUnref();
-       if (underline != -1)
-               paint->setUnderlineTextOn(SkToBool(underline));
-       if (xfermode != (SkPorterDuff::Mode) -1) 
-               paint->setPorterDuffXfermode((SkPorterDuff::Mode) xfermode);
+    if (antiAlias != -1)
+        paint->setAntiAliasOn(SkToBool(antiAlias));
+    if (color != NULL)
+        paint->setColor(color->getColor());
+    if (fakeBold != -1)
+        paint->setFakeBoldTextOn(SkToBool(fakeBold));
+    if (filterType != (SkPaint::FilterType) -1)
+        paint->setFilterType((SkPaint::FilterType) filterType);
+    //  stroke is legacy; style setting if present overrides stroke
+    if (stroke != -1)
+        paint->setStyle(SkToBool(stroke) ? SkPaint::kStroke_Style : SkPaint::kFill_Style);
+    if (style != (SkPaint::Style) -1)
+        paint->setStyle((SkPaint::Style) style);
+    if (linearText != -1)
+        paint->setLinearTextOn(SkToBool(linearText));
+    if (maskFilter == NULL)
+        paint->setMaskFilter(NULL);
+    else if (maskFilter != (SkDrawMaskFilter*) -1)
+        paint->setMaskFilter(maskFilter->getMaskFilter())->safeUnref();
+    if (pathEffect == NULL)
+        paint->setPathEffect(NULL);
+    else if (pathEffect != (SkDrawPathEffect*) -1)
+        paint->setPathEffect(pathEffect->getPathEffect())->safeUnref();
+    if (shader == NULL)
+        paint->setShader(NULL);
+    else if (shader != (SkDrawShader*) -1)
+        paint->setShader(shader->getShader())->safeUnref();
+    if (strikeThru != -1)
+        paint->setStrikeThruTextOn(SkToBool(strikeThru));
+    if (strokeCap != (SkPaint::Cap) -1)
+        paint->setStrokeCap((SkPaint::Cap) strokeCap);
+    if (strokeJoin != (SkPaint::Join) -1)
+        paint->setStrokeJoin((SkPaint::Join) strokeJoin);
+    if (SkScalarIsNaN(strokeMiter) == false)
+        paint->setStrokeMiter(strokeMiter);
+    if (SkScalarIsNaN(strokeWidth) == false)
+        paint->setStrokeWidth(strokeWidth);
+    if (textAlign != (SkPaint::Align) -1)
+        paint->setTextAlign((SkPaint::Align) textAlign);
+    if (SkScalarIsNaN(textScaleX) == false)
+        paint->setTextScaleX(textScaleX);
+    if (SkScalarIsNaN(textSize) == false)
+        paint->setTextSize(textSize);
+    if (SkScalarIsNaN(textSkewX) == false)
+        paint->setTextSkewX(textSkewX);
+    if (typeface == NULL)
+        paint->setTypeface(NULL);
+    else if (typeface != (SkDrawTypeface*) -1)
+        paint->setTypeface(typeface->getTypeface())->safeUnref();
+    if (underline != -1)
+        paint->setUnderlineTextOn(SkToBool(underline));
+    if (xfermode != (SkPorterDuff::Mode) -1) 
+        paint->setPorterDuffXfermode((SkPorterDuff::Mode) xfermode);
 }
 
index 3ae0ffa..444c278 100644 (file)
@@ -1,3 +1,20 @@
+/* libs/graphics/animator/SkDrawPaint.h
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #ifndef SkDrawPaint_DEFINED
 #define SkDrawPaint_DEFINED
 
@@ -14,56 +31,56 @@ class SkTransferMode;
 class SkDrawTypeface;
 
 class SkDrawPaint : public SkDrawable {
-       DECLARE_DRAW_MEMBER_INFO(Paint);
-       SkDrawPaint();
-       virtual ~SkDrawPaint();
-       virtual bool add(SkAnimateMaker& , SkDisplayable* child);
-       virtual SkDisplayable* deepCopy(SkAnimateMaker* );
-       virtual bool draw(SkAnimateMaker& );
+    DECLARE_DRAW_MEMBER_INFO(Paint);
+    SkDrawPaint();
+    virtual ~SkDrawPaint();
+    virtual bool add(SkAnimateMaker& , SkDisplayable* child);
+    virtual SkDisplayable* deepCopy(SkAnimateMaker* );
+    virtual bool draw(SkAnimateMaker& );
 #ifdef SK_DUMP_ENABLED
-       virtual void dump(SkAnimateMaker* );
+    virtual void dump(SkAnimateMaker* );
 #endif
-       virtual void executeFunction(SkDisplayable* target, int index, 
-               SkTDArray<SkScriptValue>& parameters, SkDisplayTypes type,
-               SkScriptValue* );
-       virtual const SkFunctionParamType* getFunctionsParameters();
-       virtual bool getProperty(int index, SkScriptValue* value) const;
-       virtual bool resolveIDs(SkAnimateMaker& maker, SkDisplayable* original, SkApply* apply);
+    virtual void executeFunction(SkDisplayable* target, int index, 
+        SkTDArray<SkScriptValue>& parameters, SkDisplayTypes type,
+        SkScriptValue* );
+    virtual const SkFunctionParamType* getFunctionsParameters();
+    virtual bool getProperty(int index, SkScriptValue* value) const;
+    virtual bool resolveIDs(SkAnimateMaker& maker, SkDisplayable* original, SkApply* apply);
 protected:
-       static const SkFunctionParamType fFunctionParameters[];
-       void setupPaint(SkPaint* paint) const;
+    static const SkFunctionParamType fFunctionParameters[];
+    void setupPaint(SkPaint* paint) const;
 public:
-       SkBool antiAlias;
-       SkDrawColor* color;
+    SkBool antiAlias;
+    SkDrawColor* color;
     SkBool fakeBold;
-       int /*SkPaint::FilterType*/ filterType;
-       SkBool linearText;
-       SkDrawMaskFilter* maskFilter;
-       SkDrawPathEffect* pathEffect;
-       SkDrawShader* shader;
-       SkBool strikeThru;
-       SkBool stroke;
-       int /*SkPaint::Cap*/ strokeCap;
-       int /*SkPaint::Join */ strokeJoin;
-       SkScalar strokeMiter;
-       SkScalar strokeWidth;
-       int /* SkPaint::Style */ style;
-       int /* SkPaint::Align */ textAlign;
-       SkScalar textScaleX;
-       SkScalar textSize;
-       SkScalar textSkewX;
-       SkDrawTypeface* typeface;
-       SkBool underline;
-       int /*SkXfermode::Modes*/ xfermode;
-       SkBool8 fOwnsColor;
-       SkBool8 fOwnsMaskFilter;
-       SkBool8 fOwnsPathEffect;
-       SkBool8 fOwnsShader;
-       SkBool8 fOwnsTransferMode;
-       SkBool8 fOwnsTypeface;
+    int /*SkPaint::FilterType*/ filterType;
+    SkBool linearText;
+    SkDrawMaskFilter* maskFilter;
+    SkDrawPathEffect* pathEffect;
+    SkDrawShader* shader;
+    SkBool strikeThru;
+    SkBool stroke;
+    int /*SkPaint::Cap*/ strokeCap;
+    int /*SkPaint::Join */ strokeJoin;
+    SkScalar strokeMiter;
+    SkScalar strokeWidth;
+    int /* SkPaint::Style */ style;
+    int /* SkPaint::Align */ textAlign;
+    SkScalar textScaleX;
+    SkScalar textSize;
+    SkScalar textSkewX;
+    SkDrawTypeface* typeface;
+    SkBool underline;
+    int /*SkXfermode::Modes*/ xfermode;
+    SkBool8 fOwnsColor;
+    SkBool8 fOwnsMaskFilter;
+    SkBool8 fOwnsPathEffect;
+    SkBool8 fOwnsShader;
+    SkBool8 fOwnsTransferMode;
+    SkBool8 fOwnsTypeface;
 private:
-       typedef SkDrawable INHERITED;
-       friend class SkTextToPath;
+    typedef SkDrawable INHERITED;
+    friend class SkTextToPath;
     friend class SkSaveLayer;
 };
 
index 3024600..5f13cb9 100644 (file)
@@ -1,3 +1,20 @@
+/* libs/graphics/animator/SkDrawPath.cpp
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #include "SkDrawPath.h"
 #include "SkAnimateMaker.h"
 #include "SkCanvas.h"
 #include "SkPathParts.h"
 
 enum SkPath_Properties {
-       SK_PROPERTY(fillType),
-       SK_PROPERTY(length)
+    SK_PROPERTY(fillType),
+    SK_PROPERTY(length)
 };
 
 #if SK_USE_CONDENSED_INFO == 0
 
 const SkMemberInfo SkDrawPath::fInfo[] = {
-       SK_MEMBER(d, String),
-       SK_MEMBER_PROPERTY(fillType, FillType),
-       SK_MEMBER_PROPERTY(length, Float)
+    SK_MEMBER(d, String),
+    SK_MEMBER_PROPERTY(fillType, FillType),
+    SK_MEMBER_PROPERTY(length, Float)
 };
 
 #endif
@@ -25,47 +42,47 @@ DEFINE_GET_MEMBER(SkDrawPath);
 
 SkDrawPath::SkDrawPath()
 {
-       fParent = nil;
-       fLength = SK_ScalarNaN;
-       fChildHasID = false;
-       fDirty = false;
+    fParent = nil;
+    fLength = SK_ScalarNaN;
+    fChildHasID = false;
+    fDirty = false;
 }
 
 SkDrawPath::~SkDrawPath() {
-       for (SkPathPart** part = fParts.begin(); part < fParts.end();  part++)
-               delete *part;
+    for (SkPathPart** part = fParts.begin(); part < fParts.end();  part++)
+        delete *part;
 }
 
 bool SkDrawPath::add(SkAnimateMaker& maker, SkDisplayable* child) {
-       SkASSERT(child && child->isPathPart());
-       SkPathPart* part = (SkPathPart*) child;
-       *fParts.append() = part;
-       if (part->add())
-               maker.setErrorCode(SkDisplayXMLParserError::kErrorAddingToPath); 
-       fDirty = false;
-       return true;
+    SkASSERT(child && child->isPathPart());
+    SkPathPart* part = (SkPathPart*) child;
+    *fParts.append() = part;
+    if (part->add())
+        maker.setErrorCode(SkDisplayXMLParserError::kErrorAddingToPath); 
+    fDirty = false;
+    return true;
 }
 
 bool SkDrawPath::childrenNeedDisposing() const { 
-       return false; 
+    return false; 
 }
 
 void SkDrawPath::dirty() { 
-       fDirty = true; 
-       fLength = SK_ScalarNaN;
-       if (fParent)
-               fParent->dirty();
+    fDirty = true; 
+    fLength = SK_ScalarNaN;
+    if (fParent)
+        fParent->dirty();
 }
 
 bool SkDrawPath::draw(SkAnimateMaker& maker) {
-       SkPath& path = getPath();
-       SkBoundableAuto boundable(this, maker);
-       maker.fCanvas->drawPath(path, *maker.fPaint);
-       return false;
+    SkPath& path = getPath();
+    SkBoundableAuto boundable(this, maker);
+    maker.fCanvas->drawPath(path, *maker.fPaint);
+    return false;
 }
 
 SkDisplayable* SkDrawPath::getParent() const {
-       return fParent;
+    return fParent;
 }
 
 #ifdef SK_DUMP_ENABLED
@@ -90,8 +107,8 @@ void SkDrawPath::dump(SkAnimateMaker* maker) {
 #endif
 
 SkPath& SkDrawPath::getPath() {
-       if (fDirty == false)
-               return fPath;
+    if (fDirty == false)
+        return fPath;
     if (d.size() > 0)
     {
         parseSVG();
@@ -103,76 +120,76 @@ SkPath& SkDrawPath::getPath() {
         for (SkPathPart** part = fParts.begin(); part < fParts.end();  part++)
             (*part)->add();
     }
-       fDirty = false;
-       return fPath;
+    fDirty = false;
+    return fPath;
 }
-       
+    
 void SkDrawPath::onEndElement(SkAnimateMaker& ) {
-       if (d.size() > 0) {
-               parseSVG();
-               d.reset();
+    if (d.size() > 0) {
+        parseSVG();
+        d.reset();
         fDirty = false;
         return;
-       }
-       if (fChildHasID == false) {
-               for (SkPathPart** part = fParts.begin(); part < fParts.end();  part++)
-                       delete *part;
-               fParts.reset();
-               fDirty = false;
-       }
+    }
+    if (fChildHasID == false) {
+        for (SkPathPart** part = fParts.begin(); part < fParts.end();  part++)
+            delete *part;
+        fParts.reset();
+        fDirty = false;
+    }
 }
 
 bool SkDrawPath::getProperty(int index, SkScriptValue* value) const {
-       switch (index) {
-               case SK_PROPERTY(length):
-                       if (SkScalarIsNaN(fLength)) {
-                               const SkPath& path = ((SkDrawPath*) this)->getPath();
-                               SkPathMeasure pathMeasure(path, false);
-                               fLength = pathMeasure.getLength();
-                       }
-                       value->fType = SkType_Float;
-                       value->fOperand.fScalar = fLength;
-                       break;
+    switch (index) {
+        case SK_PROPERTY(length):
+            if (SkScalarIsNaN(fLength)) {
+                const SkPath& path = ((SkDrawPath*) this)->getPath();
+                SkPathMeasure pathMeasure(path, false);
+                fLength = pathMeasure.getLength();
+            }
+            value->fType = SkType_Float;
+            value->fOperand.fScalar = fLength;
+            break;
         case SK_PROPERTY(fillType):
             value->fType = SkType_FillType;
             value->fOperand.fS32 = (int) fPath.getFillType();
             break;
-               default:
-                       SkASSERT(0);
-                       return false;
-       }
-       return true;
+        default:
+            SkASSERT(0);
+            return false;
+    }
+    return true;
 }
 
 void SkDrawPath::setChildHasID() { 
-       fChildHasID = true; 
+    fChildHasID = true; 
 }
 
 bool SkDrawPath::setParent(SkDisplayable* parent) {
-       fParent = parent;
-       return false;
+    fParent = parent;
+    return false;
 }
 
 bool SkDrawPath::setProperty(int index, SkScriptValue& value)
 {
-       switch (index) {
-               case SK_PROPERTY(fillType):
-                       SkASSERT(value.fType == SkType_FillType);
-                       SkASSERT(value.fOperand.fS32 >= SkPath::kWinding_FillType &&
-                               value.fOperand.fS32 <= SkPath::kEvenOdd_FillType);
-                       fPath.setFillType((SkPath::FillType) value.fOperand.fS32);
-                       break;
-               default:
-                       SkASSERT(0);
-                       return false;
-       }
-       return true;
+    switch (index) {
+        case SK_PROPERTY(fillType):
+            SkASSERT(value.fType == SkType_FillType);
+            SkASSERT(value.fOperand.fS32 >= SkPath::kWinding_FillType &&
+                value.fOperand.fS32 <= SkPath::kEvenOdd_FillType);
+            fPath.setFillType((SkPath::FillType) value.fOperand.fS32);
+            break;
+        default:
+            SkASSERT(0);
+            return false;
+    }
+    return true;
 }
 
 #if SK_USE_CONDENSED_INFO == 0
 
 const SkMemberInfo SkPolyline::fInfo[] = {
-       SK_MEMBER_ARRAY(points, Float)
+    SK_MEMBER_ARRAY(points, Float)
 };
 
 #endif
@@ -180,25 +197,25 @@ const SkMemberInfo SkPolyline::fInfo[] = {
 DEFINE_GET_MEMBER(SkPolyline);
 
 bool SkPolyline::add(SkAnimateMaker& , SkDisplayable*) const {
-       return false; 
+    return false; 
 }
 
 void SkPolyline::onEndElement(SkAnimateMaker& maker) {
-       INHERITED::onEndElement(maker);
-       if (points.count() <= 0)
-               return;
-       fPath.reset();
-       fPath.moveTo(points[0], points[1]);
-       int count = points.count();
-       for (int index = 2; index < count; index += 2)
-               fPath.lineTo(points[index], points[index+1]);
+    INHERITED::onEndElement(maker);
+    if (points.count() <= 0)
+        return;
+    fPath.reset();
+    fPath.moveTo(points[0], points[1]);
+    int count = points.count();
+    for (int index = 2; index < count; index += 2)
+        fPath.lineTo(points[index], points[index+1]);
 }
 
 
 #if SK_USE_CONDENSED_INFO == 0
 
 const SkMemberInfo SkPolygon::fInfo[] = {
-       SK_MEMBER_INHERITED
+    SK_MEMBER_INHERITED
 };
 
 #endif
@@ -206,7 +223,7 @@ const SkMemberInfo SkPolygon::fInfo[] = {
 DEFINE_GET_MEMBER(SkPolygon);
 
 void SkPolygon::onEndElement(SkAnimateMaker& maker) {
-       INHERITED::onEndElement(maker);
-       fPath.close();
+    INHERITED::onEndElement(maker);
+    fPath.close();
 }
 
index 3c005a5..719b346 100644 (file)
@@ -1,3 +1,20 @@
+/* libs/graphics/animator/SkDrawPath.h
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #ifndef SkDrawPath_DEFINED
 #define SkDrawPath_DEFINED
 
 #include "SkPath.h"
 
 class SkDrawPath : public SkBoundable {
-       DECLARE_DRAW_MEMBER_INFO(Path);
-       SkDrawPath();
-       virtual ~SkDrawPath();
-       virtual bool add(SkAnimateMaker& , SkDisplayable* child);
-       bool childHasID() { return SkToBool(fChildHasID); }
-       virtual bool childrenNeedDisposing() const;
-       virtual void dirty();
-       virtual bool draw(SkAnimateMaker& );
-       virtual SkDisplayable* getParent() const;
+    DECLARE_DRAW_MEMBER_INFO(Path);
+    SkDrawPath();
+    virtual ~SkDrawPath();
+    virtual bool add(SkAnimateMaker& , SkDisplayable* child);
+    bool childHasID() { return SkToBool(fChildHasID); }
+    virtual bool childrenNeedDisposing() const;
+    virtual void dirty();
+    virtual bool draw(SkAnimateMaker& );
+    virtual SkDisplayable* getParent() const;
 #ifdef SK_DUMP_ENABLED
     virtual void dump(SkAnimateMaker* );
 #endif
-       SkPath& getPath();
-       virtual bool getProperty(int index, SkScriptValue* value) const;
-       virtual bool setProperty(int index, SkScriptValue& value);
-       virtual void onEndElement(SkAnimateMaker& );
-       virtual void setChildHasID();
-       virtual bool setParent(SkDisplayable* parent);
-       virtual bool isPath() const { return true; }
+    SkPath& getPath();
+    virtual bool getProperty(int index, SkScriptValue* value) const;
+    virtual bool setProperty(int index, SkScriptValue& value);
+    virtual void onEndElement(SkAnimateMaker& );
+    virtual void setChildHasID();
+    virtual bool setParent(SkDisplayable* parent);
+    virtual bool isPath() const { return true; }
 public:
-       SkPath fPath;
+    SkPath fPath;
 protected:
-       void parseSVG();
-       SkString d;
-       SkTDPathPartArray fParts;
-       mutable SkScalar fLength;
-       SkDisplayable* fParent; // SkPolyToPoly or SkFromPath, for instance
-       SkBool8 fChildHasID;
-       SkBool8 fDirty;
+    void parseSVG();
+    SkString d;
+    SkTDPathPartArray fParts;
+    mutable SkScalar fLength;
+    SkDisplayable* fParent; // SkPolyToPoly or SkFromPath, for instance
+    SkBool8 fChildHasID;
+    SkBool8 fDirty;
 private:
-       typedef SkBoundable INHERITED;
+    typedef SkBoundable INHERITED;
 };
 
 class SkPolyline : public SkDrawPath {
-       DECLARE_MEMBER_INFO(Polyline);
-       virtual bool add(SkAnimateMaker& , SkDisplayable*) const;
-       virtual void onEndElement(SkAnimateMaker& );
+    DECLARE_MEMBER_INFO(Polyline);
+    virtual bool add(SkAnimateMaker& , SkDisplayable*) const;
+    virtual void onEndElement(SkAnimateMaker& );
 protected:
-       SkTDScalarArray points;
+    SkTDScalarArray points;
 private:
-       typedef SkDrawPath INHERITED;
+    typedef SkDrawPath INHERITED;
 };
 
 class SkPolygon : public SkPolyline {
-       DECLARE_MEMBER_INFO(Polygon);
-       virtual void onEndElement(SkAnimateMaker& );
+    DECLARE_MEMBER_INFO(Polygon);
+    virtual void onEndElement(SkAnimateMaker& );
 private:
-       typedef SkPolyline INHERITED;
+    typedef SkPolyline INHERITED;
 };
 
 #endif // SkDrawPath_DEFINED
index 4bbd006..8654e9a 100644 (file)
@@ -1,3 +1,20 @@
+/* libs/graphics/animator/SkDrawPoint.cpp
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #include "SkDrawPoint.h"
 #include "SkAnimateMaker.h"
 #include "SkCanvas.h"
@@ -6,8 +23,8 @@
 #if SK_USE_CONDENSED_INFO == 0
 
 const SkMemberInfo Sk_Point::fInfo[] = {
-       SK_MEMBER_ALIAS(x, fPoint.fX, Float),
-       SK_MEMBER_ALIAS(y, fPoint.fY, Float)
+    SK_MEMBER_ALIAS(x, fPoint.fX, Float),
+    SK_MEMBER_ALIAS(y, fPoint.fY, Float)
 };
 
 #endif
@@ -17,8 +34,8 @@ DEFINE_NO_VIRTUALS_GET_MEMBER(Sk_Point);
 #if SK_USE_CONDENSED_INFO == 0
 
 const SkMemberInfo SkDrawPoint::fInfo[] = {
-       SK_MEMBER_ALIAS(x, fPoint.fX, Float),
-       SK_MEMBER_ALIAS(y, fPoint.fY, Float)
+    SK_MEMBER_ALIAS(x, fPoint.fX, Float),
+    SK_MEMBER_ALIAS(y, fPoint.fY, Float)
 };
 
 #endif
@@ -26,12 +43,12 @@ const SkMemberInfo SkDrawPoint::fInfo[] = {
 DEFINE_GET_MEMBER(SkDrawPoint);
 
 SkDrawPoint::SkDrawPoint() { 
-       fPoint.set(0, 0);       
+    fPoint.set(0, 0);   
 }
 
 void SkDrawPoint::getBounds(SkRect* rect ) {
-       rect->fLeft = rect->fRight = fPoint.fX;
-       rect->fTop = rect->fBottom = fPoint.fY;
+    rect->fLeft = rect->fRight = fPoint.fX;
+    rect->fTop = rect->fBottom = fPoint.fY;
 }
 
 
index c59c78a..30fd243 100644 (file)
@@ -1,3 +1,20 @@
+/* libs/graphics/animator/SkDrawPoint.h
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #ifndef SkDrawPoint_DEFINED
 #define SkDrawPoint_DEFINED
 
 #include "SkPoint.h"
 
 struct Sk_Point {
-       DECLARE_NO_VIRTUALS_MEMBER_INFO(_Point);
-       Sk_Point();
+    DECLARE_NO_VIRTUALS_MEMBER_INFO(_Point);
+    Sk_Point();
 private:
-       SkPoint fPoint;
+    SkPoint fPoint;
 };
 
 class SkDrawPoint : public SkDisplayable {
-       DECLARE_MEMBER_INFO(DrawPoint);
-       SkDrawPoint();
-       virtual void getBounds(SkRect*  );
+    DECLARE_MEMBER_INFO(DrawPoint);
+    SkDrawPoint();
+    virtual void getBounds(SkRect*  );
 private:
-       SkPoint fPoint;
-       typedef SkDisplayable INHERITED;
+    SkPoint fPoint;
+    typedef SkDisplayable INHERITED;
 };
 
 #endif // SkDrawPoint_DEFINED
index 3ccb347..4ba11f3 100644 (file)
@@ -1,3 +1,20 @@
+/* libs/graphics/animator/SkDrawRectangle.cpp
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #include "SkDrawRectangle.h"
 #include "SkAnimateMaker.h"
 #include "SkCanvas.h"
 #include "SkScript.h"
 
 enum SkRectangle_Properties {
-       SK_PROPERTY(height),
-       SK_PROPERTY(needsRedraw),
-       SK_PROPERTY(width)
+    SK_PROPERTY(height),
+    SK_PROPERTY(needsRedraw),
+    SK_PROPERTY(width)
 };
 
 #if SK_USE_CONDENSED_INFO == 0
 
 const SkMemberInfo SkDrawRect::fInfo[] = {
-       SK_MEMBER_ALIAS(bottom, fRect.fBottom, Float),
-       SK_MEMBER_PROPERTY(height, Float),
-       SK_MEMBER_ALIAS(left, fRect.fLeft, Float),
-       SK_MEMBER_PROPERTY(needsRedraw, Boolean),
-       SK_MEMBER_ALIAS(right, fRect.fRight, Float),
-       SK_MEMBER_ALIAS(top, fRect.fTop, Float),
-       SK_MEMBER_PROPERTY(width, Float)
+    SK_MEMBER_ALIAS(bottom, fRect.fBottom, Float),
+    SK_MEMBER_PROPERTY(height, Float),
+    SK_MEMBER_ALIAS(left, fRect.fLeft, Float),
+    SK_MEMBER_PROPERTY(needsRedraw, Boolean),
+    SK_MEMBER_ALIAS(right, fRect.fRight, Float),
+    SK_MEMBER_ALIAS(top, fRect.fTop, Float),
+    SK_MEMBER_PROPERTY(width, Float)
 };
 
 #endif
@@ -28,18 +45,18 @@ const SkMemberInfo SkDrawRect::fInfo[] = {
 DEFINE_GET_MEMBER(SkDrawRect);
 
 SkDrawRect::SkDrawRect() : fParent(nil) { 
-       fRect.setEmpty(); 
+    fRect.setEmpty(); 
 }
 
 void SkDrawRect::dirty() {
-       if (fParent)
-               fParent->dirty();
+    if (fParent)
+        fParent->dirty();
 }
 
 bool SkDrawRect::draw(SkAnimateMaker& maker) {
-       SkBoundableAuto boundable(this, maker);
-       maker.fCanvas->drawRect(fRect, *maker.fPaint);
-       return false;
+    SkBoundableAuto boundable(this, maker);
+    maker.fCanvas->drawRect(fRect, *maker.fPaint);
+    return false;
 }
 
 #ifdef SK_DUMP_ENABLED
@@ -52,62 +69,62 @@ void SkDrawRect::dump(SkAnimateMaker* maker) {
 #endif
 
 SkDisplayable* SkDrawRect::getParent() const {
-       return fParent;
+    return fParent;
 }
 
 bool SkDrawRect::getProperty(int index, SkScriptValue* value) const {
-       SkScalar result;
-       switch (index) {
-               case SK_PROPERTY(height):
-                       result = fRect.height();
-                       break;
-               case SK_PROPERTY(needsRedraw):
-                       value->fType = SkType_Boolean;
-                       value->fOperand.fS32 = fBounds.isEmpty() == false;
-                       return true;
-               case SK_PROPERTY(width):
-                       result = fRect.width();
-                       break;
-               default:
-                       SkASSERT(0);
-                       return false;
-       }
-       value->fType = SkType_Float;
-       value->fOperand.fScalar = result;
-       return true;
+    SkScalar result;
+    switch (index) {
+        case SK_PROPERTY(height):
+            result = fRect.height();
+            break;
+        case SK_PROPERTY(needsRedraw):
+            value->fType = SkType_Boolean;
+            value->fOperand.fS32 = fBounds.isEmpty() == false;
+            return true;
+        case SK_PROPERTY(width):
+            result = fRect.width();
+            break;
+        default:
+            SkASSERT(0);
+            return false;
+    }
+    value->fType = SkType_Float;
+    value->fOperand.fScalar = result;
+    return true;
 }
 
 
 bool SkDrawRect::setParent(SkDisplayable* parent) {
-       fParent = parent;
-       return false;
+    fParent = parent;
+    return false;
 }
 
 bool SkDrawRect::setProperty(int index, SkScriptValue& value) {
-       SkScalar scalar = value.fOperand.fScalar;
-       switch (index) {
-               case SK_PROPERTY(height):
-               SkASSERT(value.fType == SkType_Float);
-                       fRect.fBottom = scalar + fRect.fTop;
-                       return true;
+    SkScalar scalar = value.fOperand.fScalar;
+    switch (index) {
+        case SK_PROPERTY(height):
+            SkASSERT(value.fType == SkType_Float);
+            fRect.fBottom = scalar + fRect.fTop;
+            return true;
         case SK_PROPERTY(needsRedraw):
             return false;
-               case SK_PROPERTY(width):
-               SkASSERT(value.fType == SkType_Float);
-                       fRect.fRight = scalar + fRect.fLeft;
-                       return true;
-               default:
-                       SkASSERT(0);
-       }
-       return false;
+        case SK_PROPERTY(width):
+            SkASSERT(value.fType == SkType_Float);
+            fRect.fRight = scalar + fRect.fLeft;
+            return true;
+        default:
+            SkASSERT(0);
+    }
+    return false;
 }
 
 #if SK_USE_CONDENSED_INFO == 0
 
 const SkMemberInfo SkRoundRect::fInfo[] = {
-       SK_MEMBER_INHERITED,
-       SK_MEMBER(rx, Float),
-       SK_MEMBER(ry, Float),
+    SK_MEMBER_INHERITED,
+    SK_MEMBER(rx, Float),
+    SK_MEMBER(ry, Float),
 };
 
 #endif
@@ -118,9 +135,9 @@ SkRoundRect::SkRoundRect() : rx(0), ry(0) {
 }
 
 bool SkRoundRect::draw(SkAnimateMaker& maker) {
-       SkBoundableAuto boundable(this, maker);
-       maker.fCanvas->drawRoundRect(fRect, rx, ry, *maker.fPaint);
-       return false;
+    SkBoundableAuto boundable(this, maker);
+    maker.fCanvas->drawRoundRect(fRect, rx, ry, *maker.fPaint);
+    return false;
 }
 
 #ifdef SK_DUMP_ENABLED
index 6abb6e4..51edcc5 100644 (file)
@@ -1,3 +1,20 @@
+/* libs/graphics/animator/SkDrawRectangle.h
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #ifndef SkDrawRectangle_DEFINED
 #define SkDrawRectangle_DEFINED
 
 class SkRectToRect;
 
 class SkDrawRect : public SkBoundable {
-       DECLARE_DRAW_MEMBER_INFO(Rect);
-       SkDrawRect();
-       virtual void dirty();
-       virtual bool draw(SkAnimateMaker& );
+    DECLARE_DRAW_MEMBER_INFO(Rect);
+    SkDrawRect();
+    virtual void dirty();
+    virtual bool draw(SkAnimateMaker& );
 #ifdef SK_DUMP_ENABLED
     virtual void dump(SkAnimateMaker* );
 #endif
-       virtual SkDisplayable* getParent() const;
-       virtual bool getProperty(int index, SkScriptValue* value) const;
-       virtual bool setParent(SkDisplayable* parent);
-       virtual bool setProperty(int index, SkScriptValue& );
+    virtual SkDisplayable* getParent() const;
+    virtual bool getProperty(int index, SkScriptValue* value) const;
+    virtual bool setParent(SkDisplayable* parent);
+    virtual bool setProperty(int index, SkScriptValue& );
 protected:
-       SkRect fRect;
-       SkDisplayable* fParent;
+    SkRect fRect;
+    SkDisplayable* fParent;
 private:
-       friend class SkDrawClip;
-       friend class SkRectToRect;
+    friend class SkDrawClip;
+    friend class SkRectToRect;
     friend class SkSaveLayer;
-       typedef SkBoundable INHERITED;
+    typedef SkBoundable INHERITED;
 };
 
 class SkRoundRect : public SkDrawRect {
-       DECLARE_MEMBER_INFO(RoundRect);
-       SkRoundRect();
-       virtual bool draw(SkAnimateMaker& );
+    DECLARE_MEMBER_INFO(RoundRect);
+    SkRoundRect();
+    virtual bool draw(SkAnimateMaker& );
 #ifdef SK_DUMP_ENABLED
     virtual void dump(SkAnimateMaker* );
 #endif    
 protected:
-       SkScalar rx;
-       SkScalar ry;
+    SkScalar rx;
+    SkScalar ry;
 private:
-       typedef SkDrawRect INHERITED;
+    typedef SkDrawRect INHERITED;
 };
 
 #endif // SkDrawRectangle_DEFINED
index c6addb8..a6d15de 100644 (file)
@@ -1,3 +1,20 @@
+/* libs/graphics/animator/SkDrawSaveLayer.cpp
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #include "SkDrawSaveLayer.h"
 #include "SkAnimateMaker.h"
 #include "SkCanvas.h"
@@ -64,4 +81,6 @@ void SkSaveLayer::onEndElement(SkAnimateMaker& maker)
     if (!bounds)
         maker.setErrorCode(SkDisplayXMLParserError::kSaveLayerNeedsBounds);
     INHERITED::onEndElement(maker);
-}
\ No newline at end of file
+}
+
+
index 9644457..c247219 100644 (file)
@@ -1,3 +1,20 @@
+/* libs/graphics/animator/SkDrawSaveLayer.h
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #ifndef SkDrawSaveLayer_DEFINED
 #define SkDrawSaveLayer_DEFINED
 
index 4b071a1..4c25ed8 100644 (file)
@@ -1,3 +1,20 @@
+/* libs/graphics/animator/SkDrawShader.cpp
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #include "SkDrawShader.h"
 #include "SkDrawBitmap.h"
 #include "SkDrawMatrix.h"
@@ -7,8 +24,8 @@
 #if SK_USE_CONDENSED_INFO == 0
 
 const SkMemberInfo SkDrawShader::fInfo[] = {
-       SK_MEMBER(matrix, Matrix),
-       SK_MEMBER(tileMode, TileMode)
+    SK_MEMBER(matrix, Matrix),
+    SK_MEMBER(tileMode, TileMode)
 };
 
 #endif
@@ -16,28 +33,28 @@ const SkMemberInfo SkDrawShader::fInfo[] = {
 DEFINE_GET_MEMBER(SkDrawShader);
 
 SkDrawShader::SkDrawShader() : matrix(nil), 
-       tileMode(SkShader::kClamp_TileMode) {
+    tileMode(SkShader::kClamp_TileMode) {
 }
 
 bool SkDrawShader::add() {
-       if (fPaint->shader != (SkDrawShader*) -1)
-               return true;
-       fPaint->shader = this;
-       fPaint->fOwnsShader = true;
-       return false;
+    if (fPaint->shader != (SkDrawShader*) -1)
+        return true;
+    fPaint->shader = this;
+    fPaint->fOwnsShader = true;
+    return false;
 }
 
 void SkDrawShader::addPostlude(SkShader* shader) {
-       if (matrix)
-               shader->setLocalMatrix(matrix->getMatrix());
+    if (matrix)
+        shader->setLocalMatrix(matrix->getMatrix());
 }
 
 #if SK_USE_CONDENSED_INFO == 0
 
 const SkMemberInfo SkDrawBitmapShader::fInfo[] = {
-       SK_MEMBER_INHERITED,
-       SK_MEMBER(filterType, FilterType),
-       SK_MEMBER(image, BaseBitmap)
+    SK_MEMBER_INHERITED,
+    SK_MEMBER(filterType, FilterType),
+    SK_MEMBER(image, BaseBitmap)
 };
 
 #endif
@@ -47,28 +64,28 @@ DEFINE_GET_MEMBER(SkDrawBitmapShader);
 SkDrawBitmapShader::SkDrawBitmapShader() : filterType(SkPaint::kNo_FilterType), image(nil) {}
 
 bool SkDrawBitmapShader::add() {
-       if (fPaint->shader != (SkDrawShader*) -1)
-               return true;
-       fPaint->shader = this;
-       fPaint->fOwnsShader = true;
-       return false;
+    if (fPaint->shader != (SkDrawShader*) -1)
+        return true;
+    fPaint->shader = this;
+    fPaint->fOwnsShader = true;
+    return false;
 }
 
 SkShader* SkDrawBitmapShader::getShader() {
-       if (image == NULL)
-               return NULL;
+    if (image == NULL)
+        return NULL;
     
     // note: bitmap shader now supports independent tile modes for X and Y
     // we pass the same to both, but later we should extend this flexibility
     // to the xml (e.g. tileModeX="repeat" tileModeY="clmap")
     // <reed>
-       SkShader* shader  = SkShader::CreateBitmapShader(image->fBitmap, false, 
+    SkShader* shader  = SkShader::CreateBitmapShader(image->fBitmap, false, 
                                                     (SkPaint::FilterType) filterType,
                                                     (SkShader::TileMode) tileMode,
                                                     (SkShader::TileMode) tileMode);
-       SkAutoTDelete<SkShader> autoDel(shader);
-       addPostlude(shader);
-       (void)autoDel.detach();
-       return shader;
+    SkAutoTDelete<SkShader> autoDel(shader);
+    addPostlude(shader);
+    (void)autoDel.detach();
+    return shader;
 }
 
index 8601405..932e166 100644 (file)
@@ -1,3 +1,20 @@
+/* libs/graphics/animator/SkDrawShader.h
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #ifndef SkDrawShader_DEFINED
 #define SkDrawShader_DEFINED
 
 class SkBaseBitmap;
 
 class SkDrawBitmapShader : public SkDrawShader {
-       DECLARE_DRAW_MEMBER_INFO(BitmapShader);
-       SkDrawBitmapShader();
-       virtual bool add();
-       virtual SkShader* getShader();
+    DECLARE_DRAW_MEMBER_INFO(BitmapShader);
+    SkDrawBitmapShader();
+    virtual bool add();
+    virtual SkShader* getShader();
 protected:
-       int /*SkPaint::FilterType*/ filterType;
-       SkBaseBitmap* image;
+    int /*SkPaint::FilterType*/ filterType;
+    SkBaseBitmap* image;
 private:
-       typedef SkDrawShader INHERITED;
+    typedef SkDrawShader INHERITED;
 };
 
 #endif // SkDrawShader_DEFINED
index 093e7e4..1bd0440 100644 (file)
@@ -1,19 +1,36 @@
+/* libs/graphics/animator/SkDrawText.cpp
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #include "SkDrawText.h"
 #include "SkAnimateMaker.h"
 #include "SkCanvas.h"
 #include "SkPaint.h"
 
 enum SkText_Properties {
-       SK_PROPERTY(length)
+    SK_PROPERTY(length)
 };
 
 #if SK_USE_CONDENSED_INFO == 0
 
 const SkMemberInfo SkText::fInfo[] = {
-       SK_MEMBER_PROPERTY(length, Int),
-       SK_MEMBER(text, String),
-       SK_MEMBER(x, Float),
-       SK_MEMBER(y, Float)
+    SK_MEMBER_PROPERTY(length, Int),
+    SK_MEMBER(text, String),
+    SK_MEMBER(x, Float),
+    SK_MEMBER(y, Float)
 };
 
 #endif
@@ -27,21 +44,21 @@ SkText::~SkText() {
 }
 
 bool SkText::draw(SkAnimateMaker& maker) {
-       SkBoundableAuto boundable(this, maker);
-       maker.fCanvas->drawText(text.c_str(), text.size(), x, y, *maker.fPaint);
-       return false;
+    SkBoundableAuto boundable(this, maker);
+    maker.fCanvas->drawText(text.c_str(), text.size(), x, y, *maker.fPaint);
+    return false;
 }
 
 #ifdef SK_DUMP_ENABLED
 void SkText::dump(SkAnimateMaker* maker) {
-       INHERITED::dump(maker);
+    INHERITED::dump(maker);
 }
 #endif
 
 bool SkText::getProperty(int index, SkScriptValue* value) const {
-       SkASSERT(index == SK_PROPERTY(length));
-       value->fType = SkType_Int;
-       value->fOperand.fS32 = (S32) text.size();
-       return true;
+    SkASSERT(index == SK_PROPERTY(length));
+    value->fType = SkType_Int;
+    value->fOperand.fS32 = (S32) text.size();
+    return true;
 }
 
index 2cc8c86..cc5ce80 100644 (file)
@@ -1,3 +1,20 @@
+/* libs/graphics/animator/SkDrawText.h
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #ifndef SkDrawText_DEFINED
 #define SkDrawText_DEFINED
 
 #include "SkMemberInfo.h"
 
 class SkText : public SkBoundable {
-       DECLARE_MEMBER_INFO(Text);
-       SkText();
-       virtual ~SkText();
-       virtual bool draw(SkAnimateMaker& );
+    DECLARE_MEMBER_INFO(Text);
+    SkText();
+    virtual ~SkText();
+    virtual bool draw(SkAnimateMaker& );
 #ifdef SK_DUMP_ENABLED
-       virtual void dump(SkAnimateMaker* );
+    virtual void dump(SkAnimateMaker* );
 #endif
-       virtual bool getProperty(int index, SkScriptValue* value) const ; 
-       const char* getText() { return text.c_str(); }
-       size_t getSize() { return text.size(); }
+    virtual bool getProperty(int index, SkScriptValue* value) const ; 
+    const char* getText() { return text.c_str(); }
+    size_t getSize() { return text.size(); }
 protected:
-       SkString text;
-       SkScalar x;
-       SkScalar y;
+    SkString text;
+    SkScalar x;
+    SkScalar y;
 private:
-       friend class SkTextToPath;
-       typedef SkBoundable INHERITED;
+    friend class SkTextToPath;
+    typedef SkBoundable INHERITED;
 };
 
 #endif // SkDrawText_DEFINED
index 204d398..2c3108f 100644 (file)
@@ -1,24 +1,41 @@
+/* libs/graphics/animator/SkDrawTextBox.cpp
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #include "SkDrawTextBox.h"
 #include "SkAnimateMaker.h"
 #include "SkCanvas.h"
 #include "SkPaint.h"
 
 enum SkDrawTextBox_Properties {
-       foo = 100,
-       SK_PROPERTY(spacingAlign),
-       SK_PROPERTY(mode)
+    foo = 100,
+    SK_PROPERTY(spacingAlign),
+    SK_PROPERTY(mode)
 };
 
 
 #if SK_USE_CONDENSED_INFO == 0
 
 const SkMemberInfo SkDrawTextBox::fInfo[] = {
-       SK_MEMBER_INHERITED,
-       SK_MEMBER(mode, TextBoxMode),
-       SK_MEMBER_ALIAS(spacingAdd, fSpacingAdd, Float),
-       SK_MEMBER(spacingAlign, TextBoxAlign),
-       SK_MEMBER_ALIAS(spacingMul, fSpacingMul, Float),
-       SK_MEMBER_ALIAS(text, fText, String)
+    SK_MEMBER_INHERITED,
+    SK_MEMBER(mode, TextBoxMode),
+    SK_MEMBER_ALIAS(spacingAdd, fSpacingAdd, Float),
+    SK_MEMBER(spacingAlign, TextBoxAlign),
+    SK_MEMBER_ALIAS(spacingMul, fSpacingMul, Float),
+    SK_MEMBER_ALIAS(text, fText, String)
 };
 
 #endif
@@ -27,10 +44,10 @@ DEFINE_GET_MEMBER(SkDrawTextBox);
 
 SkDrawTextBox::SkDrawTextBox()
 {
-       fSpacingMul             = SK_Scalar1;
-       fSpacingAdd             = 0;
-       spacingAlign    = SkTextBox::kStart_SpacingAlign;
-       mode                    = SkTextBox::kLineBreak_Mode;
+    fSpacingMul     = SK_Scalar1;
+    fSpacingAdd     = 0;
+    spacingAlign    = SkTextBox::kStart_SpacingAlign;
+    mode            = SkTextBox::kLineBreak_Mode;
 }
 
 #ifdef SK_DUMP_ENABLED
@@ -50,24 +67,24 @@ void SkDrawTextBox::dump(SkAnimateMaker* maker)
 
 bool SkDrawTextBox::getProperty(int index, SkScriptValue* value) const
 {
-       return this->INHERITED::getProperty(index, value);
+    return this->INHERITED::getProperty(index, value);
 }
 
 bool SkDrawTextBox::setProperty(int index, SkScriptValue& scriptValue)
 {
-       return this->INHERITED::setProperty(index, scriptValue);
+    return this->INHERITED::setProperty(index, scriptValue);
 }
 
 bool SkDrawTextBox::draw(SkAnimateMaker& maker)
 {
-       SkTextBox       box;
-       box.setMode((SkTextBox::Mode) mode);
-       box.setSpacingAlign((SkTextBox::SpacingAlign) spacingAlign);
-       box.setBox(fRect);
-       box.setSpacing(fSpacingMul, fSpacingAdd);
-       SkBoundableAuto boundable(this, maker);
-       box.draw(maker.fCanvas, fText.c_str(), fText.size(), *maker.fPaint);
-       return false;
+    SkTextBox   box;
+    box.setMode((SkTextBox::Mode) mode);
+    box.setSpacingAlign((SkTextBox::SpacingAlign) spacingAlign);
+    box.setBox(fRect);
+    box.setSpacing(fSpacingMul, fSpacingAdd);
+    SkBoundableAuto boundable(this, maker);
+    box.draw(maker.fCanvas, fText.c_str(), fText.size(), *maker.fPaint);
+    return false;
 }
 
 
index 20bb14c..6396eac 100644 (file)
@@ -1,3 +1,20 @@
+/* libs/graphics/animator/SkDrawTextBox.h
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #ifndef SkDrawTextBox_DEFINED
 #define SkDrawTextBox_DEFINED
 
 #include "SkTextBox.h"
 
 class SkDrawTextBox : public SkDrawRect {
-       DECLARE_DRAW_MEMBER_INFO(TextBox);
-       SkDrawTextBox();
+    DECLARE_DRAW_MEMBER_INFO(TextBox);
+    SkDrawTextBox();
 
-       // overrides
-       virtual bool draw(SkAnimateMaker& );
+    // overrides
+    virtual bool draw(SkAnimateMaker& );
 #ifdef SK_DUMP_ENABLED
     virtual void dump(SkAnimateMaker* );
 #endif
-       virtual bool getProperty(int index, SkScriptValue* value) const;
-       virtual bool setProperty(int index, SkScriptValue& );
+    virtual bool getProperty(int index, SkScriptValue* value) const;
+    virtual bool setProperty(int index, SkScriptValue& );
 
 private:
-       SkString fText;
-       SkScalar fSpacingMul;
-       SkScalar fSpacingAdd;
-       int /*SkTextBox::Mode*/  mode;
-       int /*SkTextBox::SpacingAlign*/ spacingAlign;
+    SkString fText;
+    SkScalar fSpacingMul;
+    SkScalar fSpacingAdd;
+    int /*SkTextBox::Mode*/  mode;
+    int /*SkTextBox::SpacingAlign*/ spacingAlign;
 
-       typedef SkDrawRect INHERITED;
+    typedef SkDrawRect INHERITED;
 };
 
 #endif // SkDrawTextBox_DEFINED
index 2019c4b..32cfaf6 100644 (file)
@@ -1,3 +1,20 @@
+/* libs/graphics/animator/SkDrawTo.cpp
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #include "SkDrawTo.h"
 #include "SkAnimateMaker.h"
 #include "SkCanvas.h"
@@ -6,8 +23,8 @@
 #if SK_USE_CONDENSED_INFO == 0
 
 const SkMemberInfo SkDrawTo::fInfo[] = {
-       SK_MEMBER(drawOnce, Boolean),
-       SK_MEMBER(use, Bitmap)
+    SK_MEMBER(drawOnce, Boolean),
+    SK_MEMBER(use, Bitmap)
 };
 
 #endif
@@ -19,20 +36,20 @@ SkDrawTo::SkDrawTo() : drawOnce(false), use(nil), fDrawnOnce(false) {
 
 #if 0
 SkDrawTo::~SkDrawTo() {
-       SkASSERT(0);
+    SkASSERT(0);
 }
 #endif
 
 bool SkDrawTo::draw(SkAnimateMaker& maker) {
-       if (fDrawnOnce)
-               return false;
-       SkCanvas canvas(use->fBitmap);
-       SkCanvas* save = maker.fCanvas;
-       maker.fCanvas = &canvas;
-       INHERITED::draw(maker);
-       maker.fCanvas = save;
-       fDrawnOnce = drawOnce;
-       return false;
+    if (fDrawnOnce)
+        return false;
+    SkCanvas canvas(use->fBitmap);
+    SkCanvas* save = maker.fCanvas;
+    maker.fCanvas = &canvas;
+    INHERITED::draw(maker);
+    maker.fCanvas = save;
+    fDrawnOnce = drawOnce;
+    return false;
 }
 
 #ifdef SK_DUMP_ENABLED
index 403ced6..c9268ae 100644 (file)
@@ -1,3 +1,20 @@
+/* libs/graphics/animator/SkDrawTo.h
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #ifndef SkDrawTo_DEFINED
 #define SkDrawTo_DEFINED
 
 class SkDrawBitmap;
 
 class SkDrawTo : public SkGroup {
-       DECLARE_MEMBER_INFO(DrawTo);
-       SkDrawTo();
-//     virtual ~SkDrawTo();
-       virtual bool draw(SkAnimateMaker& );
+    DECLARE_MEMBER_INFO(DrawTo);
+    SkDrawTo();
+//  virtual ~SkDrawTo();
+    virtual bool draw(SkAnimateMaker& );
 #ifdef SK_DUMP_ENABLED
     virtual void dump(SkAnimateMaker* );
 #endif
 protected:
-       SkBool drawOnce;
-       SkDrawBitmap* use;
+    SkBool drawOnce;
+    SkDrawBitmap* use;
 private:
-       typedef SkGroup INHERITED;
-       SkBool fDrawnOnce;
+    typedef SkGroup INHERITED;
+    SkBool fDrawnOnce;
 };
 
 #endif // SkDrawTo_DEFINED
index c71fb37..8282248 100644 (file)
@@ -1,7 +1,24 @@
+/* libs/graphics/animator/SkDrawTransparentShader.cpp
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #include "SkDrawTransparentShader.h"
 #include "SkTransparentShader.h"
 
 SkShader* SkDrawTransparentShader::getShader() {
-       return new SkTransparentShader();
+    return new SkTransparentShader();
 }
 
index 0659937..8c0c49e 100644 (file)
@@ -1,11 +1,28 @@
+/* libs/graphics/animator/SkDrawTransparentShader.h
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #ifndef SkDrawTransparentShader_DEFINED
 #define SkDrawTransparentShader_DEFINED
 
 #include "SkPaintParts.h"
 
 class SkDrawTransparentShader : public SkDrawShader {
-       DECLARE_EMPTY_MEMBER_INFO(TransparentShader);
-       virtual SkShader* getShader();
+    DECLARE_EMPTY_MEMBER_INFO(TransparentShader);
+    virtual SkShader* getShader();
 };
 
 #endif // SkDrawTransparentShader_DEFINED
index e3e3662..631ebb1 100644 (file)
@@ -1,11 +1,28 @@
+/* libs/graphics/animator/SkDrawable.cpp
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #include "SkDrawable.h"
 
 bool SkDrawable::doEvent(SkDisplayEvent::Kind , SkEventState* ) {
-       return false;
+    return false;
 }
 
 bool SkDrawable::isDrawable() const { 
-       return true; 
+    return true; 
 }
 
 void SkDrawable::initialize() {
index 6c62b15..1f932ad 100644 (file)
@@ -1,3 +1,20 @@
+/* libs/graphics/animator/SkDrawable.h
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #ifndef SkDrawable_DEFINED
 #define SkDrawable_DEFINED
 
@@ -9,11 +26,11 @@ struct SkEventState;
 
 class SkDrawable :  public SkDisplayable {
 public:
-       virtual bool doEvent(SkDisplayEvent::Kind , SkEventState* state );
-       virtual bool draw(SkAnimateMaker& ) = 0; 
-       virtual void initialize();
-       virtual bool isDrawable() const;
-       virtual void setSteps(int steps);
+    virtual bool doEvent(SkDisplayEvent::Kind , SkEventState* state );
+    virtual bool draw(SkAnimateMaker& ) = 0; 
+    virtual void initialize();
+    virtual bool isDrawable() const;
+    virtual void setSteps(int steps);
 };
 
 #endif // SkDrawable_DEFINED
index cd7dcf0..aaf83ba 100644 (file)
@@ -1,3 +1,20 @@
+/* libs/graphics/animator/SkDump.cpp
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #include "SkDump.h"
 
 #ifdef SK_DUMP_ENABLED
 #if SK_USE_CONDENSED_INFO == 0
 
 const SkMemberInfo SkDump::fInfo[] = {
-       SK_MEMBER(displayList, Boolean),
-       SK_MEMBER(eventList, Boolean),
-       SK_MEMBER(events, Boolean),
-       SK_MEMBER(groups, Boolean),
-       SK_MEMBER(name, String),
-       SK_MEMBER(posts, Boolean),
+    SK_MEMBER(displayList, Boolean),
+    SK_MEMBER(eventList, Boolean),
+    SK_MEMBER(events, Boolean),
+    SK_MEMBER(groups, Boolean),
+    SK_MEMBER(name, String),
+    SK_MEMBER(posts, Boolean),
     SK_MEMBER(script, String)
 };
 
@@ -28,22 +45,22 @@ SkDump::SkDump() : displayList(-1), eventList(-1), events(-1), groups(-1), posts
 }
 
 bool SkDump::enable(SkAnimateMaker& maker ) {
-       if (script.size() > 0)
+    if (script.size() > 0)
         return evaluate(maker);
-       bool hasAttr = false;
-       if (events > 0)
-               hasAttr |= maker.fDumpEvents = true;
-       if (posts > 0)
-               hasAttr |= maker.fDumpPosts = true;
-       if (groups > 0)
-               hasAttr |= maker.fDumpGConditions = true;
-       if ((hasAttr |= (eventList > 0)) == true)
-               maker.fEvents.dump(maker);
-       if ((hasAttr |= (name.size() > 0)) == true)
-               maker.dump(name.c_str());
+    bool hasAttr = false;
+    if (events > 0)
+        hasAttr |= maker.fDumpEvents = true;
+    if (posts > 0)
+        hasAttr |= maker.fDumpPosts = true;
+    if (groups > 0)
+        hasAttr |= maker.fDumpGConditions = true;
+    if ((hasAttr |= (eventList > 0)) == true)
+        maker.fEvents.dump(maker);
+    if ((hasAttr |= (name.size() > 0)) == true)
+        maker.dump(name.c_str());
     if (displayList > 0 || displayList != 0 && hasAttr == false)
-               maker.fDisplayList.dump(&maker);
-       return true;
+        maker.fDisplayList.dump(&maker);
+    return true;
 }
 
 bool SkDump::evaluate(SkAnimateMaker &maker) {
@@ -73,15 +90,15 @@ bool SkDump::evaluate(SkAnimateMaker &maker) {
 }
 
 bool SkDump::hasEnable() const {
-       return true;
+    return true;
 }
 
 void SkDump::GetEnumString(SkDisplayTypes type, int index, SkString* result) {
     int badEnum = index;
-       const SkDisplayEnumMap& map = SkAnimatorScript::GetEnumValues(type);
-       const char* str  = map.fValues;
-       while (--index >= 0) {
-               str = strchr(str, '|');
+    const SkDisplayEnumMap& map = SkAnimatorScript::GetEnumValues(type);
+    const char* str  = map.fValues;
+    while (--index >= 0) {
+        str = strchr(str, '|');
         if (str == nil) {
             result->reset();
             result->appendS32(badEnum);
@@ -89,10 +106,10 @@ void SkDump::GetEnumString(SkDisplayTypes type, int index, SkString* result) {
         }
         str += 1;
     }
-       const char* end = strchr(str, '|');
-       if (end == nil)
-               end = str + strlen(str);
-       result->set(str, end - str);
+    const char* end = strchr(str, '|');
+    if (end == nil)
+        end = str + strlen(str);
+    result->set(str, end - str);
 }
 
 #else
@@ -103,22 +120,22 @@ void SkDump::GetEnumString(SkDisplayTypes type, int index, SkString* result) {
 #if SK_USE_CONDENSED_INFO == 0
 
 enum SkDump_Properties {
-       SK_PROPERTY(displayList),
-       SK_PROPERTY(eventList),
-       SK_PROPERTY(events),
-       SK_PROPERTY(groups),
-       SK_PROPERTY(name),
-       SK_PROPERTY(posts),
+    SK_PROPERTY(displayList),
+    SK_PROPERTY(eventList),
+    SK_PROPERTY(events),
+    SK_PROPERTY(groups),
+    SK_PROPERTY(name),
+    SK_PROPERTY(posts),
     SK_PROPERTY(script)
 };
 
 const SkMemberInfo SkDump::fInfo[] = {
-       SK_MEMBER_PROPERTY(displayList, Boolean),
-       SK_MEMBER_PROPERTY(eventList, Boolean),
-       SK_MEMBER_PROPERTY(events, Boolean),
-       SK_MEMBER_PROPERTY(groups, Boolean),
-       SK_MEMBER_PROPERTY(name, String),
-       SK_MEMBER_PROPERTY(posts, Boolean),
+    SK_MEMBER_PROPERTY(displayList, Boolean),
+    SK_MEMBER_PROPERTY(eventList, Boolean),
+    SK_MEMBER_PROPERTY(events, Boolean),
+    SK_MEMBER_PROPERTY(groups, Boolean),
+    SK_MEMBER_PROPERTY(name, String),
+    SK_MEMBER_PROPERTY(posts, Boolean),
     SK_MEMBER_PROPERTY(script, String)
 };
 
@@ -127,15 +144,15 @@ const SkMemberInfo SkDump::fInfo[] = {
 DEFINE_GET_MEMBER(SkDump);
 
 bool SkDump::enable(SkAnimateMaker& maker ) {
-       return true;
+    return true;
 }
 
 bool SkDump::hasEnable() const {
-       return true;
+    return true;
 }
 
 bool SkDump::setProperty(int index, SkScriptValue& ) {
-       return index <= SK_PROPERTY(posts); 
+    return index <= SK_PROPERTY(posts); 
 }
 
 #endif
index 2d9c99f..8b38f35 100644 (file)
@@ -1,3 +1,20 @@
+/* libs/graphics/animator/SkDump.h
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #ifndef SkDump_DEFINED
 #define SkDump_DEFINED
 
@@ -8,24 +25,24 @@ class SkAnimateMaker;
 class SkString;
 
 class SkDump : public SkDisplayable {
-       DECLARE_MEMBER_INFO(Dump);
+    DECLARE_MEMBER_INFO(Dump);
 #ifdef SK_DUMP_ENABLED
-       SkDump();
-       virtual bool enable(SkAnimateMaker & );
+    SkDump();
+    virtual bool enable(SkAnimateMaker & );
     bool evaluate(SkAnimateMaker &);
-       virtual bool hasEnable() const;
-       static void GetEnumString(SkDisplayTypes , int index, SkString* result);
-       SkBool displayList;
-       SkBool eventList;
-       SkBool events;
-       SkString name;
-       SkBool groups;
-       SkBool posts;
+    virtual bool hasEnable() const;
+    static void GetEnumString(SkDisplayTypes , int index, SkString* result);
+    SkBool displayList;
+    SkBool eventList;
+    SkBool events;
+    SkString name;
+    SkBool groups;
+    SkBool posts;
     SkString script;
 #else
-       virtual bool enable(SkAnimateMaker & );
-       virtual bool hasEnable() const;
-       virtual bool setProperty(int index, SkScriptValue& );
+    virtual bool enable(SkAnimateMaker & );
+    virtual bool hasEnable() const;
+    virtual bool setProperty(int index, SkScriptValue& );
 #endif
 };
 
index f8af4c5..b792758 100644 (file)
@@ -1,3 +1,20 @@
+/* libs/graphics/animator/SkExtras.h
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #ifndef SkExtras_DEFINED
 #define SkExtras_DEFINED
 
@@ -8,18 +25,18 @@ public:
             SkExtras();
     virtual ~SkExtras() {}
 
-       virtual SkDisplayable* createInstance(SkDisplayTypes type) = 0;
-       virtual bool definesType(SkDisplayTypes type) = 0;
+    virtual SkDisplayable* createInstance(SkDisplayTypes type) = 0;
+    virtual bool definesType(SkDisplayTypes type) = 0;
 #if SK_USE_CONDENSED_INFO == 0
-       virtual const SkMemberInfo* getMembers(SkDisplayTypes type, int* infoCountPtr) = 0;
+    virtual const SkMemberInfo* getMembers(SkDisplayTypes type, int* infoCountPtr) = 0;
 #endif
 #ifdef SK_DEBUG
-       virtual const char* getName(SkDisplayTypes type) = 0;
+    virtual const char* getName(SkDisplayTypes type) = 0;
 #endif
-       virtual SkDisplayTypes getType(const char match[], size_t len ) = 0;
+    virtual SkDisplayTypes getType(const char match[], size_t len ) = 0;
 
-       SkScriptEngine::_propertyCallBack fExtraCallBack;
-       void* fExtraStorage;
+    SkScriptEngine::_propertyCallBack fExtraCallBack;
+    void* fExtraStorage;
 };
 
 #endif // SkExtras_DEFINED
index 28290fd..53e3e46 100644 (file)
@@ -1,3 +1,20 @@
+/* libs/graphics/animator/SkGetCondensedInfo.cpp
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #include "SkMemberInfo.h"
 
 #if SK_USE_CONDENSED_INFO == 1
 #endif
 
 static int _searchByName(const unsigned char* lengths, int count, const char* strings, const char target[]) {
-       int     lo = 0;
-       int     hi = count - 1;
-       while (lo < hi) {
-               int mid = (hi + lo) >> 1;
-               if (strcmp(&strings[lengths[mid << 2]], target) < 0)
-                       lo = mid + 1;
-               else 
-                       hi = mid;
-       }
-       if (strcmp(&strings[lengths[hi << 2]], target) != 0)
-               return -1;
-       return hi;
+    int lo = 0;
+    int hi = count - 1;
+    while (lo < hi) {
+        int mid = (hi + lo) >> 1;
+        if (strcmp(&strings[lengths[mid << 2]], target) < 0)
+            lo = mid + 1;
+        else 
+            hi = mid;
+    }
+    if (strcmp(&strings[lengths[hi << 2]], target) != 0)
+        return -1;
+    return hi;
 }
 
 static int _searchByType(SkDisplayTypes type) {
-       unsigned char match = (unsigned char) type;
-       int     lo = 0;
-       int     hi = kTypeIDs - 1;
-       while (lo < hi) {
-               int mid = (hi + lo) >> 1;
-               if (gTypeIDs[mid] < match)
-                       lo = mid + 1;
-               else
-                       hi = mid;
-       }
-       if (gTypeIDs[hi] != type)
-               return -1;
-       return hi;
+    unsigned char match = (unsigned char) type;
+    int lo = 0;
+    int hi = kTypeIDs - 1;
+    while (lo < hi) {
+        int mid = (hi + lo) >> 1;
+        if (gTypeIDs[mid] < match)
+            lo = mid + 1;
+        else
+            hi = mid;
+    }
+    if (gTypeIDs[hi] != type)
+        return -1;
+    return hi;
 }
 
 const SkMemberInfo* SkDisplayType::GetMembers(SkAnimateMaker* , SkDisplayTypes type, int* infoCountPtr) {
-       int lookup = _searchByType(type);
-       if (lookup < 0)
-               return nil;
-       if (infoCountPtr)
-               *infoCountPtr = gInfoCounts[lookup];
-       return gInfoTables[lookup];
+    int lookup = _searchByType(type);
+    if (lookup < 0)
+        return nil;
+    if (infoCountPtr)
+        *infoCountPtr = gInfoCounts[lookup];
+    return gInfoTables[lookup];
 }
 
 // !!! replace with inline
 const SkMemberInfo* SkDisplayType::GetMember(SkAnimateMaker* , SkDisplayTypes type, const char** matchPtr ) {
-       const SkMemberInfo* info = SkMemberInfo::Find(type, matchPtr);
-       SkASSERT(info);
-       return info;
+    const SkMemberInfo* info = SkMemberInfo::Find(type, matchPtr);
+    SkASSERT(info);
+    return info;
 }
 
 static const SkMemberInfo* _lookup(int lookup, const char** matchPtr) {
-       int count = gInfoCounts[lookup];
-       const SkMemberInfo* info = gInfoTables[lookup];
-       if (info->fType == SkType_BaseClassInfo) {
-               int baseTypeLookup = info->fOffset;
-               const SkMemberInfo* result = _lookup(baseTypeLookup, matchPtr);
-               if (result != nil)
-                       return result;
-               if (--count == 0)
-                       return nil;
-               info++;
-       }
-       SkASSERT(info->fType != SkType_BaseClassInfo);
-       const char* match = *matchPtr;
-       const char* strings = gInfoNames[lookup];
-       int index = _searchByName(&info->fName, count, strings, match);
-       if (index < 0)
-               return nil;
-       return &info[index];
+    int count = gInfoCounts[lookup];
+    const SkMemberInfo* info = gInfoTables[lookup];
+    if (info->fType == SkType_BaseClassInfo) {
+        int baseTypeLookup = info->fOffset;
+        const SkMemberInfo* result = _lookup(baseTypeLookup, matchPtr);
+        if (result != nil)
+            return result;
+        if (--count == 0)
+            return nil;
+        info++;
+    }
+    SkASSERT(info->fType != SkType_BaseClassInfo);
+    const char* match = *matchPtr;
+    const char* strings = gInfoNames[lookup];
+    int index = _searchByName(&info->fName, count, strings, match);
+    if (index < 0)
+        return nil;
+    return &info[index];
 }
 
 const SkMemberInfo* SkMemberInfo::Find(SkDisplayTypes type, int* index) {
-       int count = gInfoCounts[lookup];
-       const SkMemberInfo* info = gInfoTables[lookup];
-       if (info->fType == SkType_BaseClassInfo) {
-               int baseTypeLookup = info->fOffset;
-               const SkMemberInfo* result = Find(baseTypeLookup, index);
-               if (result != nil)
-                       return result;
-               if (--count == 0)
-                       return nil;
-               info++;
-       }
-       SkASSERT(info->fType != SkType_BaseClassInfo);
-       if (*index >= count) {
-               *index -= count;
-               return nil;
-       }
-       return &info[index];
+    int count = gInfoCounts[lookup];
+    const SkMemberInfo* info = gInfoTables[lookup];
+    if (info->fType == SkType_BaseClassInfo) {
+        int baseTypeLookup = info->fOffset;
+        const SkMemberInfo* result = Find(baseTypeLookup, index);
+        if (result != nil)
+            return result;
+        if (--count == 0)
+            return nil;
+        info++;
+    }
+    SkASSERT(info->fType != SkType_BaseClassInfo);
+    if (*index >= count) {
+        *index -= count;
+        return nil;
+    }
+    return &info[index];
 }
 
 const SkMemberInfo* SkMemberInfo::Find(SkDisplayTypes type, const char** matchPtr) {
-       int lookup = _searchByType(type);
-       SkASSERT(lookup >= 0);
-       return _lookup(lookup, matchPtr);
+    int lookup = _searchByType(type);
+    SkASSERT(lookup >= 0);
+    return _lookup(lookup, matchPtr);
 }
 
 const SkMemberInfo* SkMemberInfo::getInherited() const {
-       int baseTypeLookup = fOffset;
-       return gInfoTables[baseTypeLookup];
+    int baseTypeLookup = fOffset;
+    return gInfoTables[baseTypeLookup];
 }
 
 #endif
index 6d90a5a..e88ab92 100644 (file)
@@ -1,9 +1,26 @@
+/* libs/graphics/animator/SkHitClear.cpp
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #include "SkHitClear.h"
 
 #if SK_USE_CONDENSED_INFO == 0
 
 const SkMemberInfo SkHitClear::fInfo[] = {
-       SK_MEMBER_ARRAY(targets, Displayable)
+    SK_MEMBER_ARRAY(targets, Displayable)
 };
 
 #endif
@@ -11,14 +28,14 @@ const SkMemberInfo SkHitClear::fInfo[] = {
 DEFINE_GET_MEMBER(SkHitClear);
 
 bool SkHitClear::enable(SkAnimateMaker& maker) {
-       for (int tIndex = 0; tIndex < targets.count(); tIndex++) {
-               SkDisplayable* target = targets[tIndex];
-               target->clearBounder();
-       }
-       return true;
+    for (int tIndex = 0; tIndex < targets.count(); tIndex++) {
+        SkDisplayable* target = targets[tIndex];
+        target->clearBounder();
+    }
+    return true;
 }
 
 bool SkHitClear::hasEnable() const {
-       return true;
+    return true;
 }
 
index 57bc6b5..8a41e0c 100644 (file)
@@ -1,3 +1,20 @@
+/* libs/graphics/animator/SkHitClear.h
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #ifndef SkHitClear_DEFINED
 #define SkHitClear_DEFINED
 
 #include "SkTypedArray.h"
 
 class SkHitClear : public SkDisplayable {
-       DECLARE_MEMBER_INFO(HitClear);
-       virtual bool enable(SkAnimateMaker& );
-       virtual bool hasEnable() const;
+    DECLARE_MEMBER_INFO(HitClear);
+    virtual bool enable(SkAnimateMaker& );
+    virtual bool hasEnable() const;
 private:
-       SkTDDisplayableArray targets;
+    SkTDDisplayableArray targets;
 };
 
 #endif // SkHitClear_DEFINED
index 7e48adb..1c3c08c 100644 (file)
@@ -1,12 +1,29 @@
+/* libs/graphics/animator/SkHitTest.cpp
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #include "SkHitTest.h"
 
 #if SK_USE_CONDENSED_INFO == 0
 
 const SkMemberInfo SkHitTest::fInfo[] = {
-       SK_MEMBER_ARRAY(bullets, Displayable),
-       SK_MEMBER_ARRAY(hits, Int),
-       SK_MEMBER_ARRAY(targets, Displayable),
-       SK_MEMBER(value, Boolean)
+    SK_MEMBER_ARRAY(bullets, Displayable),
+    SK_MEMBER_ARRAY(hits, Int),
+    SK_MEMBER_ARRAY(targets, Displayable),
+    SK_MEMBER(value, Boolean)
 };
 
 #endif
@@ -17,50 +34,50 @@ SkHitTest::SkHitTest() : value(false) {
 }
 
 bool SkHitTest::draw(SkAnimateMaker& maker) {
-       hits.setCount(bullets.count());
-       value = false;
-       int bulletCount = bullets.count();
-       int targetCount = targets.count();
-       for (int bIndex = 0; bIndex < bulletCount; bIndex++) {
-               SkDisplayable* bullet = bullets[bIndex];
-               SkRect bBounds;
-               bullet->getBounds(&bBounds);
-               hits[bIndex] = -1;
-               if (bBounds.fLeft == (S16)0x8000U)
-                       continue;
-               for (int tIndex = 0; tIndex < targetCount; tIndex++) {
-                       SkDisplayable* target = targets[tIndex];
-                       SkRect tBounds;
-                       target->getBounds(&tBounds);
-                       if (bBounds.intersect(tBounds)) {
-                               hits[bIndex] = tIndex;
-                               value = true;
-                               break;
-                       }
-               }
-       }
-       return false;
+    hits.setCount(bullets.count());
+    value = false;
+    int bulletCount = bullets.count();
+    int targetCount = targets.count();
+    for (int bIndex = 0; bIndex < bulletCount; bIndex++) {
+        SkDisplayable* bullet = bullets[bIndex];
+        SkRect bBounds;
+        bullet->getBounds(&bBounds);
+        hits[bIndex] = -1;
+        if (bBounds.fLeft == (S16)0x8000U)
+            continue;
+        for (int tIndex = 0; tIndex < targetCount; tIndex++) {
+            SkDisplayable* target = targets[tIndex];
+            SkRect tBounds;
+            target->getBounds(&tBounds);
+            if (bBounds.intersect(tBounds)) {
+                hits[bIndex] = tIndex;
+                value = true;
+                break;
+            }
+        }
+    }
+    return false;
 }
 
 bool SkHitTest::enable(SkAnimateMaker& maker) {
-       for (int bIndex = 0; bIndex < bullets.count(); bIndex++) {
-               SkDisplayable* bullet = bullets[bIndex];
-               bullet->enableBounder();
-       }
-       for (int tIndex = 0; tIndex < targets.count(); tIndex++) {
-               SkDisplayable* target = targets[tIndex];
-               target->enableBounder();
-       }
-       return false;
+    for (int bIndex = 0; bIndex < bullets.count(); bIndex++) {
+        SkDisplayable* bullet = bullets[bIndex];
+        bullet->enableBounder();
+    }
+    for (int tIndex = 0; tIndex < targets.count(); tIndex++) {
+        SkDisplayable* target = targets[tIndex];
+        target->enableBounder();
+    }
+    return false;
 }
 
 bool SkHitTest::hasEnable() const {
-       return true;
+    return true;
 }
 
 const SkMemberInfo* SkHitTest::preferredChild(SkDisplayTypes type) {
-       if (bullets.count() == 0)
-               return getMember("bullets");
-       return getMember("targets"); // !!! cwap! need to refer to member through enum like kScope instead
+    if (bullets.count() == 0)
+        return getMember("bullets");
+    return getMember("targets"); // !!! cwap! need to refer to member through enum like kScope instead
 }
 
index a8c9fa4..a786cb2 100644 (file)
@@ -1,3 +1,20 @@
+/* libs/graphics/animator/SkHitTest.h
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #ifndef SkHitTest_DEFINED
 #define SkHitTest_DEFINED
 
 #include "SkTypedArray.h"
 
 class SkHitTest : public SkDrawable {
-       DECLARE_MEMBER_INFO(HitTest);
-       SkHitTest();
-       virtual bool draw(SkAnimateMaker& );
-       virtual bool enable(SkAnimateMaker& );
-       virtual bool hasEnable() const;
-       virtual const SkMemberInfo* preferredChild(SkDisplayTypes type);
+    DECLARE_MEMBER_INFO(HitTest);
+    SkHitTest();
+    virtual bool draw(SkAnimateMaker& );
+    virtual bool enable(SkAnimateMaker& );
+    virtual bool hasEnable() const;
+    virtual const SkMemberInfo* preferredChild(SkDisplayTypes type);
 private:
-       SkTDDisplayableArray bullets;
-       SkTDIntArray hits;
-       SkTDDisplayableArray targets;
-       SkBool value;
+    SkTDDisplayableArray bullets;
+    SkTDIntArray hits;
+    SkTDDisplayableArray targets;
+    SkBool value;
 };
 
 #endif // SkHitTest_DEFINED
index f1824a1..bb58541 100644 (file)
@@ -1,3 +1,20 @@
+/* libs/graphics/animator/SkIntArray.h
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #ifndef SkIntArray_DEFINED
 #define SkIntArray_DEFINED
 
diff --git a/libs/graphics/animator/SkInterpolator.cpp b/libs/graphics/animator/SkInterpolator.cpp
deleted file mode 100644 (file)
index f151bd4..0000000
+++ /dev/null
@@ -1,252 +0,0 @@
-#include "SkInterpolator.h"
-#include "SkTSearch.h"
-
-SkInterpolatorBase::SkInterpolatorBase()
-{
-       fStorage        = nil;
-       fTimes          = nil;
-       SkDEBUGCODE(fTimesArray = nil;)
-}
-
-SkInterpolatorBase::~SkInterpolatorBase()
-{
-       if (fStorage)
-               sk_free(fStorage);
-}
-
-void SkInterpolatorBase::reset(int elemCount, int frameCount)
-{
-       fFlags = 0;
-       fElemCount = SkToU8(elemCount);
-       fFrameCount = SkToS16(frameCount);
-       fRepeat = SK_Scalar1;
-       if (fStorage) {
-               sk_free(fStorage);
-               fStorage = nil;
-               fTimes = nil;
-               SkDEBUGCODE(fTimesArray = nil);
-       }
-}
-
-/*     Each value[] run is formated as:
-               <time (in msec)>
-               <blend>
-               <data[fElemCount]>
-
-       Totaling fElemCount+2 entries per keyframe
-*/
-
-bool SkInterpolatorBase::getDuration(SkMSec* startTime, SkMSec* endTime) const
-{
-       if (fFrameCount == 0)
-               return false;
-
-       if (startTime)
-               *startTime = fTimes[0].fTime;
-       if (endTime)
-               *endTime = fTimes[fFrameCount - 1].fTime;
-       return true;
-}
-
-SkScalar SkInterpolatorBase::ComputeRelativeT(SkMSec time, SkMSec prevTime, SkMSec nextTime, SkScalar blend)
-{
-       SkASSERT(time > prevTime && time < nextTime);
-       SkASSERT(blend >= 0);
-
-       SkScalar        t = SkScalarDiv((SkScalar)(time - prevTime), (SkScalar)(nextTime - prevTime));
-       return Blend(t, blend);
-}
-
-SkScalar SkInterpolatorBase::Blend(SkScalar t, SkScalar blend)
-{
-       // f(t) = -2(1-blend)t^3 + 3(1 - blend)t^2 + blend*t
-       return SkScalarMul(SkScalarMul(SkScalarMul(-2*(SK_Scalar1 - blend), t) + 3*(SK_Scalar1 - blend), t) + blend, t);
-}
-
-SkInterpolatorBase::Result SkInterpolatorBase::timeToT(SkMSec time, SkScalar* T, int* indexPtr, SkBool* exactPtr) const
-{
-       SkASSERT(fFrameCount > 0);
-       Result  result = kNormal_Result;
-       if (fRepeat != SK_Scalar1)
-       {
-               SkMSec startTime, endTime;
-               this->getDuration(&startTime, &endTime);
-               SkMSec totalTime = endTime - startTime;
-               SkMSec offsetTime = time - startTime;
-               endTime = SkScalarMulFloor(fRepeat, totalTime);
-               if (offsetTime >= endTime)
-               {
-                       SkScalar fraction = SkScalarFraction(fRepeat);
-                       offsetTime = fraction == 0 && fRepeat > 0 ? totalTime :
-                               SkScalarMulFloor(fraction, totalTime);
-                       result = kFreezeEnd_Result;
-               }
-               else
-               {
-                       int mirror = fFlags & kMirror;
-                       offsetTime = offsetTime % (totalTime << mirror);
-                       if (offsetTime > totalTime)     // can only be true if fMirror is true
-                               offsetTime = (totalTime << 1) - offsetTime;
-               }
-               time = offsetTime + startTime;
-       }
-
-       int index = SkTSearch<SkMSec>(&fTimes[0].fTime, fFrameCount, time, sizeof(SkTimeCode));
-
-       bool    exact = true;
-
-       if (index < 0)
-       {
-               index = ~index;
-               if (index == 0)
-                       result = kFreezeStart_Result;
-               else if (index == fFrameCount)
-               {
-                       if (fFlags & kReset)
-                               index = 0;
-                       else
-                               index -= 1;
-                       result = kFreezeEnd_Result;
-               }
-               else
-                       exact = false;
-       }
-       SkASSERT(index < fFrameCount);
-       const SkTimeCode* nextTime = &fTimes[index];
-       SkMSec   nextT = nextTime[0].fTime;
-       if (exact)
-               *T = 0;
-       else {
-               SkMSec prevT = nextTime[-1].fTime;
-               *T = ComputeRelativeT(time, prevT, nextT, nextTime[-1].fBlend);
-       }
-       *indexPtr = index;
-       *exactPtr = exact;
-       return result;
-}
-
-
-SkInterpolator::SkInterpolator() {
-       INHERITED::reset(0, 0);
-       fValues = nil;
-       SkDEBUGCODE(fScalarsArray = nil;)
-}
-
-SkInterpolator::SkInterpolator(int elemCount, int frameCount)
-{
-       SkASSERT(elemCount > 0);
-       this->reset(elemCount, frameCount);
-}
-
-void SkInterpolator::reset(int elemCount, int frameCount) {
-       INHERITED::reset(elemCount, frameCount);
-       fStorage = sk_malloc_throw((sizeof(SkScalar) * elemCount + sizeof(SkTimeCode)) * frameCount);
-       fTimes = (SkTimeCode*) fStorage;
-       fValues = (SkScalar*) ((char*) fStorage + sizeof(SkTimeCode) * frameCount);
-#ifdef SK_DEBUG
-       fTimesArray = (SkTimeCode(*)[10]) fTimes;
-       fScalarsArray = (SkScalar(*)[10]) fValues;
-#endif
-}
-
-bool SkInterpolator::setKeyFrame(int index, SkMSec time, const SkScalar values[], SkScalar blend)
-{
-       SkASSERT(values != nil);
-       blend = SkScalarPin(blend, 0, SK_Scalar1);
-
-       bool success = ~index == SkTSearch<SkMSec>(&fTimes->fTime, index, time, sizeof(SkTimeCode));
-       SkASSERT(success);
-       if (success) {
-               SkTimeCode* timeCode = &fTimes[index];
-               timeCode->fTime = time;
-               timeCode->fBlend = blend;
-               SkScalar* dst = &fValues[fElemCount * index];
-               memcpy(dst, values, fElemCount * sizeof(SkScalar));
-       }
-       return success;
-}
-
-SkInterpolator::Result SkInterpolator::timeToValues(SkMSec time, SkScalar values[]) const
-{
-       SkScalar T;
-       int index;
-       SkBool exact;
-       Result result = timeToT(time, &T, &index, &exact);
-       if (values)
-       {
-               const SkScalar* nextSrc = &fValues[index * fElemCount];
-
-               if (exact)
-                       memcpy(values, nextSrc, fElemCount * sizeof(SkScalar));
-               else
-               {
-                       SkASSERT(index > 0);
-
-                       const SkScalar* prevSrc = nextSrc - fElemCount;
-
-                       for (int i = fElemCount - 1; i >= 0; --i)
-                               values[i] = SkScalarInterp(prevSrc[i], nextSrc[i], T);
-               }
-       }
-       return result;
-}
-
-
-///////////////////////////////////////////////////////////////////////////////////////
-///////////////////////////////////////////////////////////////////////////////////////
-
-#ifdef SK_DEBUG
-
-#ifdef SK_SUPPORT_UNITTEST
-       static SkScalar* iset(SkScalar array[3], int a, int b, int c)
-       {
-               array[0] = SkIntToScalar(a);
-               array[1] = SkIntToScalar(b);
-               array[2] = SkIntToScalar(c);
-               return array;
-       }
-#endif
-
-void SkInterpolator::UnitTest()
-{
-#ifdef SK_SUPPORT_UNITTEST
-       SkInterpolator  inter(3, 2);
-       SkScalar                v1[3], v2[3], v[3], vv[3];
-       Result                  result;
-
-       inter.setKeyFrame(0, 100, iset(v1, 10, 20, 30), 0);
-       inter.setKeyFrame(1, 200, iset(v2, 110, 220, 330));
-
-       result = inter.timeToValues(0, v);
-       SkASSERT(result == kFreezeStart_Result);
-       SkASSERT(memcmp(v, v1, sizeof(v)) == 0);
-
-       result = inter.timeToValues(99, v);
-       SkASSERT(result == kFreezeStart_Result);
-       SkASSERT(memcmp(v, v1, sizeof(v)) == 0);
-
-       result = inter.timeToValues(100, v);
-       SkASSERT(result == kNormal_Result);
-       SkASSERT(memcmp(v, v1, sizeof(v)) == 0);
-
-       result = inter.timeToValues(200, v);
-       SkASSERT(result == kNormal_Result);
-       SkASSERT(memcmp(v, v2, sizeof(v)) == 0);
-
-       result = inter.timeToValues(201, v);
-       SkASSERT(result == kFreezeEnd_Result);
-       SkASSERT(memcmp(v, v2, sizeof(v)) == 0);
-
-       result = inter.timeToValues(150, v);
-       SkASSERT(result == kNormal_Result);
-       SkASSERT(memcmp(v, iset(vv, 60, 120, 180), sizeof(v)) == 0);
-
-       result = inter.timeToValues(125, v);
-       SkASSERT(result == kNormal_Result);
-       result = inter.timeToValues(175, v);
-       SkASSERT(result == kNormal_Result);
-#endif
-}
-
-#endif
-
index b9a0633..b4b9277 100644 (file)
@@ -1,3 +1,20 @@
+/* libs/graphics/animator/SkMatrixParts.cpp
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #include "SkMatrixParts.h"
 #include "SkAnimateMaker.h"
 #include "SkDrawMatrix.h"
@@ -8,27 +25,27 @@ SkMatrixPart::SkMatrixPart() : fMatrix(nil) {
 }
 
 void SkMatrixPart::dirty() { 
-       fMatrix->dirty(); 
+    fMatrix->dirty(); 
 }
 
 SkDisplayable* SkMatrixPart::getParent() const {
-       return fMatrix;
+    return fMatrix;
 }
 
 bool SkMatrixPart::setParent(SkDisplayable* parent) {
-       SkASSERT(parent != nil);
-       if (parent->isMatrix() == false)
-               return true;
-       fMatrix = (SkDrawMatrix*) parent;
-       return false;
+    SkASSERT(parent != nil);
+    if (parent->isMatrix() == false)
+        return true;
+    fMatrix = (SkDrawMatrix*) parent;
+    return false;
 }
 
 
 #if SK_USE_CONDENSED_INFO == 0
 
 const SkMemberInfo SkRotate::fInfo[] = {
-       SK_MEMBER(center, Point),
-       SK_MEMBER(degrees, Float)
+    SK_MEMBER(center, Point),
+    SK_MEMBER(degrees, Float)
 };
 
 #endif
@@ -36,21 +53,21 @@ const SkMemberInfo SkRotate::fInfo[] = {
 DEFINE_GET_MEMBER(SkRotate);
 
 SkRotate::SkRotate() : degrees(0) { 
-       center.fX = center.fY = 0; 
+    center.fX = center.fY = 0; 
 }
 
 bool SkRotate::add() {
-       fMatrix->rotate(degrees, center);
-       return false;
+    fMatrix->rotate(degrees, center);
+    return false;
 }
 
 
 #if SK_USE_CONDENSED_INFO == 0
 
 const SkMemberInfo SkScale::fInfo[] = {
-       SK_MEMBER(center, Point),
-       SK_MEMBER(x, Float),
-       SK_MEMBER(y, Float)
+    SK_MEMBER(center, Point),
+    SK_MEMBER(x, Float),
+    SK_MEMBER(y, Float)
 };
 
 #endif
@@ -58,21 +75,21 @@ const SkMemberInfo SkScale::fInfo[] = {
 DEFINE_GET_MEMBER(SkScale);
 
 SkScale::SkScale() : x(SK_Scalar1), y(SK_Scalar1) { 
-       center.fX = center.fY = 0; 
+    center.fX = center.fY = 0; 
 }
 
 bool SkScale::add() {
-       fMatrix->scale(x, y, center);   
-       return false;
+    fMatrix->scale(x, y, center);   
+    return false;
 }
 
 
 #if SK_USE_CONDENSED_INFO == 0
 
 const SkMemberInfo SkSkew::fInfo[] = {
-       SK_MEMBER(center, Point),
-       SK_MEMBER(x, Float),
-       SK_MEMBER(y, Float)
+    SK_MEMBER(center, Point),
+    SK_MEMBER(x, Float),
+    SK_MEMBER(y, Float)
 };
 
 #endif
@@ -80,20 +97,20 @@ const SkMemberInfo SkSkew::fInfo[] = {
 DEFINE_GET_MEMBER(SkSkew);
 
 SkSkew::SkSkew() : x(0), y(0) { 
-       center.fX = center.fY = 0; 
+    center.fX = center.fY = 0; 
 }
 
 bool SkSkew::add() {
-       fMatrix->skew(x, y, center);    
-       return false;
+    fMatrix->skew(x, y, center);    
+    return false;
 }
 
 
 #if SK_USE_CONDENSED_INFO == 0
 
 const SkMemberInfo SkTranslate::fInfo[] = {
-       SK_MEMBER(x, Float),
-       SK_MEMBER(y, Float)
+    SK_MEMBER(x, Float),
+    SK_MEMBER(y, Float)
 };
 
 #endif
@@ -104,17 +121,17 @@ SkTranslate::SkTranslate() : x(0), y(0) {
 }
 
 bool SkTranslate::add() {
-       fMatrix->translate(x, y);       
-       return false;
+    fMatrix->translate(x, y);   
+    return false;
 }
 
 
 #if SK_USE_CONDENSED_INFO == 0
 
 const SkMemberInfo SkFromPath::fInfo[] = {
-       SK_MEMBER(mode, FromPathMode),
-       SK_MEMBER(offset, Float),
-       SK_MEMBER(path, Path)
+    SK_MEMBER(mode, FromPathMode),
+    SK_MEMBER(offset, Float),
+    SK_MEMBER(path, Path)
 };
 
 #endif
@@ -122,35 +139,35 @@ const SkMemberInfo SkFromPath::fInfo[] = {
 DEFINE_GET_MEMBER(SkFromPath);
 
 SkFromPath::SkFromPath() : 
-       mode(0), offset(0), path(nil) {
+    mode(0), offset(0), path(nil) {
 }
 
 SkFromPath::~SkFromPath() {
 }
 
 bool SkFromPath::add() {
-       if (path == nil)
-               return true;
-       static const U8 gFlags[] = {
-               SkPathMeasure::kGetPosAndTan_MatrixFlag,        // normal
-               SkPathMeasure::kGetTangent_MatrixFlag,          // angle
-               SkPathMeasure::kGetPosition_MatrixFlag          // position
-       };
-       if ((unsigned)mode >= SK_ARRAY_COUNT(gFlags))
-               return true;
-       SkMatrix result;
-       fPathMeasure.setPath(&path->getPath(), false);
-       if (fPathMeasure.getMatrix(offset, &result, (SkPathMeasure::MatrixFlags)gFlags[mode]))
-               fMatrix->set(result);
-       return false;
+    if (path == nil)
+        return true;
+    static const U8 gFlags[] = {
+        SkPathMeasure::kGetPosAndTan_MatrixFlag,    // normal
+        SkPathMeasure::kGetTangent_MatrixFlag,      // angle
+        SkPathMeasure::kGetPosition_MatrixFlag      // position
+    };
+    if ((unsigned)mode >= SK_ARRAY_COUNT(gFlags))
+        return true;
+    SkMatrix result;
+    fPathMeasure.setPath(&path->getPath(), false);
+    if (fPathMeasure.getMatrix(offset, &result, (SkPathMeasure::MatrixFlags)gFlags[mode]))
+        fMatrix->set(result);
+    return false;
 }
 
 
 #if SK_USE_CONDENSED_INFO == 0
 
 const SkMemberInfo SkRectToRect::fInfo[] = {
-       SK_MEMBER(destination, Rect),
-       SK_MEMBER(source, Rect)
+    SK_MEMBER(destination, Rect),
+    SK_MEMBER(source, Rect)
 };
 
 #endif
@@ -158,19 +175,19 @@ const SkMemberInfo SkRectToRect::fInfo[] = {
 DEFINE_GET_MEMBER(SkRectToRect);
 
 SkRectToRect::SkRectToRect() : 
-       source(nil), destination(nil) {
+    source(nil), destination(nil) {
 }
 
 SkRectToRect::~SkRectToRect() {
 }
 
 bool SkRectToRect::add() {
-       if (source == nil || destination == nil)
-               return true;
-       SkMatrix temp;
-       temp.setRectToRect(source->fRect, destination->fRect);
-       fMatrix->set(temp);
-       return false;
+    if (source == nil || destination == nil)
+        return true;
+    SkMatrix temp;
+    temp.setRectToRect(source->fRect, destination->fRect);
+    fMatrix->set(temp);
+    return false;
 }
 
 #ifdef SK_DUMP_ENABLED
@@ -198,20 +215,20 @@ void SkRectToRect::dump(SkAnimateMaker* maker) {
 #endif
 
 const SkMemberInfo* SkRectToRect::preferredChild(SkDisplayTypes ) {
-       if (source == nil)
-               return getMember("source"); // !!! cwap! need to refer to member through enum like kScope instead
-       else {
-               SkASSERT(destination == nil);
-               return getMember("destination");
-       }
+    if (source == nil)
+        return getMember("source"); // !!! cwap! need to refer to member through enum like kScope instead
+    else {
+        SkASSERT(destination == nil);
+        return getMember("destination");
+    }
 }
 
 
 #if SK_USE_CONDENSED_INFO == 0
 
 const SkMemberInfo SkPolyToPoly::fInfo[] = {
-       SK_MEMBER(destination, Polygon),
-       SK_MEMBER(source, Polygon)
+    SK_MEMBER(destination, Polygon),
+    SK_MEMBER(source, Polygon)
 };
 
 #endif
@@ -225,20 +242,20 @@ SkPolyToPoly::~SkPolyToPoly() {
 }
 
 bool SkPolyToPoly::add() {
-       SkASSERT(source);
-       SkASSERT(destination);
-       SkPoint src[4];
-       SkPoint dst[4];
-       SkPath& sourcePath = source->getPath();
-       int srcPts = sourcePath.getPoints(src, 4);
-       SkPath& destPath = destination->getPath();
-       int dstPts = destPath.getPoints(dst, 4);
-       if (srcPts != dstPts)
-               return true;
-       SkMatrix temp;
-       temp.setPolyToPoly(dst, src, srcPts);
-       fMatrix->set(temp);
-       return false;
+    SkASSERT(source);
+    SkASSERT(destination);
+    SkPoint src[4];
+    SkPoint dst[4];
+    SkPath& sourcePath = source->getPath();
+    int srcPts = sourcePath.getPoints(src, 4);
+    SkPath& destPath = destination->getPath();
+    int dstPts = destPath.getPoints(dst, 4);
+    if (srcPts != dstPts)
+        return true;
+    SkMatrix temp;
+    temp.setPolyToPoly(dst, src, srcPts);
+    fMatrix->set(temp);
+    return false;
 }
 
 #ifdef SK_DUMP_ENABLED
@@ -266,19 +283,19 @@ void SkPolyToPoly::dump(SkAnimateMaker* maker) {
 #endif
 
 void SkPolyToPoly::onEndElement(SkAnimateMaker& ) {
-       SkASSERT(source);
-       SkASSERT(destination);
-       if (source->childHasID() || destination->childHasID())
-               fMatrix->setChildHasID();
+    SkASSERT(source);
+    SkASSERT(destination);
+    if (source->childHasID() || destination->childHasID())
+        fMatrix->setChildHasID();
 }
 
 const SkMemberInfo* SkPolyToPoly::preferredChild(SkDisplayTypes ) {
-       if (source == nil)
-               return getMember("source"); // !!! cwap! need to refer to member through enum like kScope instead
-       else {
-               SkASSERT(destination == nil);
-               return getMember("destination");
-       }
+    if (source == nil)
+        return getMember("source"); // !!! cwap! need to refer to member through enum like kScope instead
+    else {
+        SkASSERT(destination == nil);
+        return getMember("destination");
+    }
 }
 
 
index 9535355..f1fae76 100644 (file)
@@ -1,3 +1,20 @@
+/* libs/graphics/animator/SkMatrixParts.h
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #ifndef SkMatrixParts_DEFINED
 #define SkMatrixParts_DEFINED
 
@@ -14,95 +31,95 @@ class SkDrawMatrix;
 
 class SkMatrixPart : public SkDisplayable {
 public:
-       SkMatrixPart();
-       virtual bool add() = 0;
-       virtual void dirty();
-       virtual SkDisplayable* getParent() const;
-       virtual bool setParent(SkDisplayable* parent);
+    SkMatrixPart();
+    virtual bool add() = 0;
+    virtual void dirty();
+    virtual SkDisplayable* getParent() const;
+    virtual bool setParent(SkDisplayable* parent);
 #ifdef SK_DEBUG
-       virtual bool isMatrixPart() const { return true; }
+    virtual bool isMatrixPart() const { return true; }
 #endif
 protected:
-       SkDrawMatrix* fMatrix;
+    SkDrawMatrix* fMatrix;
 };
 
 class SkRotate : public SkMatrixPart {
-       DECLARE_MEMBER_INFO(Rotate);
-       SkRotate();
+    DECLARE_MEMBER_INFO(Rotate);
+    SkRotate();
 protected:
-       virtual bool add();
-       SkScalar degrees;
-       SkPoint center;
+    virtual bool add();
+    SkScalar degrees;
+    SkPoint center;
 };
 
 class SkScale : public SkMatrixPart {
-       DECLARE_MEMBER_INFO(Scale);
-       SkScale();
+    DECLARE_MEMBER_INFO(Scale);
+    SkScale();
 protected:
-       virtual bool add();
-       SkScalar x;
-       SkScalar y;
-       SkPoint center;
+    virtual bool add();
+    SkScalar x;
+    SkScalar y;
+    SkPoint center;
 };
 
 class SkSkew : public SkMatrixPart {
-       DECLARE_MEMBER_INFO(Skew);
-       SkSkew();
+    DECLARE_MEMBER_INFO(Skew);
+    SkSkew();
 protected:
-       virtual bool add();
-       SkScalar x;
-       SkScalar y;
-       SkPoint center;
+    virtual bool add();
+    SkScalar x;
+    SkScalar y;
+    SkPoint center;
 };
 
 class SkTranslate : public SkMatrixPart {
-       DECLARE_MEMBER_INFO(Translate);
-       SkTranslate();
+    DECLARE_MEMBER_INFO(Translate);
+    SkTranslate();
 protected:
-       virtual bool add();
-       SkScalar x;
-       SkScalar y;
+    virtual bool add();
+    SkScalar x;
+    SkScalar y;
 };
 
 class SkFromPath : public SkMatrixPart {
-       DECLARE_MEMBER_INFO(FromPath);
-       SkFromPath();
-       virtual ~SkFromPath();
+    DECLARE_MEMBER_INFO(FromPath);
+    SkFromPath();
+    virtual ~SkFromPath();
 protected:
-       virtual bool add();
-       S32 mode;
-       SkScalar offset;
-       SkDrawPath* path;
-       SkPathMeasure fPathMeasure;
+    virtual bool add();
+    S32 mode;
+    SkScalar offset;
+    SkDrawPath* path;
+    SkPathMeasure fPathMeasure;
 };
 
 class SkRectToRect : public SkMatrixPart {
-       DECLARE_MEMBER_INFO(RectToRect);
-       SkRectToRect();
-       virtual ~SkRectToRect();
+    DECLARE_MEMBER_INFO(RectToRect);
+    SkRectToRect();
+    virtual ~SkRectToRect();
 #ifdef SK_DUMP_ENABLED
     virtual void dump(SkAnimateMaker* );
 #endif
-       virtual const SkMemberInfo* preferredChild(SkDisplayTypes type);
+    virtual const SkMemberInfo* preferredChild(SkDisplayTypes type);
 protected:
-       virtual bool add();
-       SkDrawRect* source;
-       SkDrawRect* destination;
+    virtual bool add();
+    SkDrawRect* source;
+    SkDrawRect* destination;
 };
 
 class SkPolyToPoly : public SkMatrixPart {
-       DECLARE_MEMBER_INFO(PolyToPoly);
-       SkPolyToPoly();
-       virtual ~SkPolyToPoly();
+    DECLARE_MEMBER_INFO(PolyToPoly);
+    SkPolyToPoly();
+    virtual ~SkPolyToPoly();
 #ifdef SK_DUMP_ENABLED
     virtual void dump(SkAnimateMaker* );
 #endif
-       virtual void onEndElement(SkAnimateMaker& );
-       virtual const SkMemberInfo* preferredChild(SkDisplayTypes type);
+    virtual void onEndElement(SkAnimateMaker& );
+    virtual const SkMemberInfo* preferredChild(SkDisplayTypes type);
 protected:
-       virtual bool add();
-       SkPolygon* source;
-       SkPolygon* destination;
+    virtual bool add();
+    SkPolygon* source;
+    SkPolygon* destination;
 };
 
 // !!! add concat matrix ? 
index 9ad26d6..149392b 100644 (file)
@@ -1,3 +1,20 @@
+/* libs/graphics/animator/SkMemberInfo.cpp
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #include "SkMemberInfo.h"
 #include "SkAnimateMaker.h"
 #include "SkAnimatorScript.h"
 #include "SkTSearch.h"
 #include "SkTypedArray.h"
 
-size_t SkMemberInfo::GetSize(SkDisplayTypes type) {    // size of simple types only
-       size_t byteSize;
-       switch (type) {
-               case SkType_ARGB:
-                       byteSize = sizeof(SkColor);
-                       break;
-               case SkType_AddMode:
-               case SkType_Align:
-               case SkType_ApplyMode:
-               case SkType_ApplyTransition:
-               case SkType_BitmapEncoding:
-               case SkType_Boolean:
-               case SkType_Cap:
-               case SkType_EventCode:
-               case SkType_EventKind:
-               case SkType_EventMode:
-               case SkType_FilterType:
+size_t SkMemberInfo::GetSize(SkDisplayTypes type) { // size of simple types only
+    size_t byteSize;
+    switch (type) {
+        case SkType_ARGB:
+            byteSize = sizeof(SkColor);
+            break;
+        case SkType_AddMode:
+        case SkType_Align:
+        case SkType_ApplyMode:
+        case SkType_ApplyTransition:
+        case SkType_BitmapEncoding:
+        case SkType_Boolean:
+        case SkType_Cap:
+        case SkType_EventCode:
+        case SkType_EventKind:
+        case SkType_EventMode:
+        case SkType_FilterType:
         case SkType_FontStyle:
-               case SkType_FromPathMode:
-               case SkType_Join:
-               case SkType_MaskFilterBlurStyle:
-               case SkType_PathDirection:
-               case SkType_Style:
-               case SkType_TileMode:
-               case SkType_Xfermode:
-                       byteSize = sizeof(int);
-                       break;
-               case SkType_Base64: // assume base64 data is always const, copied by ref
-               case SkType_Displayable:
-               case SkType_Drawable:
-               case SkType_Matrix:
-                       byteSize = sizeof(void*); 
-                       break;
-               case SkType_MSec:
-                       byteSize = sizeof(SkMSec);
-                       break;
-               case SkType_Point:
-                       byteSize = sizeof(SkPoint);
-                       break;
-               case SkType_3D_Point:
-                       byteSize = sizeof(Sk3D_Point);
-                       break;
-               case SkType_Int:
-                       byteSize = sizeof(S32);
-                       break;
-               case SkType_Float:
-                       byteSize = sizeof(SkScalar);
-                       break;
-               case SkType_DynamicString:
-               case SkType_String:
-                       byteSize = sizeof(SkString);    // assume we'll copy by reference, not value
-                       break;
-               default:
-//                     SkASSERT(0);
-                       byteSize = 0;
-       }
-       return byteSize;
+        case SkType_FromPathMode:
+        case SkType_Join:
+        case SkType_MaskFilterBlurStyle:
+        case SkType_PathDirection:
+        case SkType_Style:
+        case SkType_TileMode:
+        case SkType_Xfermode:
+            byteSize = sizeof(int);
+            break;
+        case SkType_Base64: // assume base64 data is always const, copied by ref
+        case SkType_Displayable:
+        case SkType_Drawable:
+        case SkType_Matrix:
+            byteSize = sizeof(void*); 
+            break;
+        case SkType_MSec:
+            byteSize = sizeof(SkMSec);
+            break;
+        case SkType_Point:
+            byteSize = sizeof(SkPoint);
+            break;
+        case SkType_3D_Point:
+            byteSize = sizeof(Sk3D_Point);
+            break;
+        case SkType_Int:
+            byteSize = sizeof(S32);
+            break;
+        case SkType_Float:
+            byteSize = sizeof(SkScalar);
+            break;
+        case SkType_DynamicString:
+        case SkType_String:
+            byteSize = sizeof(SkString);    // assume we'll copy by reference, not value
+            break;
+        default:
+//          SkASSERT(0);
+            byteSize = 0;
+    }
+    return byteSize;
 }
 
 bool SkMemberInfo::getArrayValue(const SkDisplayable* displayable, int index, SkOperand* value) const {
-       SkASSERT(fType != SkType_String && fType != SkType_MemberProperty);
-       char* valuePtr = (char*) *(SkOperand**) memberData(displayable);
-       SkDisplayTypes type = (SkDisplayTypes) 0;
-       if (displayable->getType() == SkType_Array) {
-               SkDisplayArray* dispArray = (SkDisplayArray*) displayable;
-               if (dispArray->values.count() <= index)
-                       return false;
-               type = dispArray->values.getType();
-       } else
-               SkASSERT(0); // incomplete
-       size_t byteSize = GetSize(type);
-       memcpy(value, valuePtr + index * byteSize, byteSize);
-       return true;
+    SkASSERT(fType != SkType_String && fType != SkType_MemberProperty);
+    char* valuePtr = (char*) *(SkOperand**) memberData(displayable);
+    SkDisplayTypes type = (SkDisplayTypes) 0;
+    if (displayable->getType() == SkType_Array) {
+        SkDisplayArray* dispArray = (SkDisplayArray*) displayable;
+        if (dispArray->values.count() <= index)
+            return false;
+        type = dispArray->values.getType();
+    } else
+        SkASSERT(0); // incomplete
+    size_t byteSize = GetSize(type);
+    memcpy(value, valuePtr + index * byteSize, byteSize);
+    return true;
 }
 
 size_t SkMemberInfo::getSize(const SkDisplayable* displayable) const {
-       size_t byteSize;
-       switch (fType) {
-               case SkType_MemberProperty:
-                       byteSize = GetSize(propertyType());
-                       break;
-               case SkType_Array: {
-                       SkDisplayTypes type;
-                       if (displayable == nil)
-                               return sizeof(int);
-                       if (displayable->getType() == SkType_Array) {
-                               SkDisplayArray* dispArray = (SkDisplayArray*) displayable;
-                               type = dispArray->values.getType();
-                       } else
-                               type = propertyType();
-                       SkTDOperandArray* array = (SkTDOperandArray*) memberData(displayable);
-                       byteSize = GetSize(type) * array->count();
-                       } break;
-               default:
-                       byteSize = GetSize((SkDisplayTypes) fType);
-       }
-       return byteSize;
+    size_t byteSize;
+    switch (fType) {
+        case SkType_MemberProperty:
+            byteSize = GetSize(propertyType());
+            break;
+        case SkType_Array: {
+            SkDisplayTypes type;
+            if (displayable == nil)
+                return sizeof(int);
+            if (displayable->getType() == SkType_Array) {
+                SkDisplayArray* dispArray = (SkDisplayArray*) displayable;
+                type = dispArray->values.getType();
+            } else
+                type = propertyType();
+            SkTDOperandArray* array = (SkTDOperandArray*) memberData(displayable);
+            byteSize = GetSize(type) * array->count();
+            } break;
+        default:
+            byteSize = GetSize((SkDisplayTypes) fType);
+    }
+    return byteSize;
 }
 
 void SkMemberInfo::getString(const SkDisplayable* displayable, SkString** string) const {
-       if (fType == SkType_MemberProperty) {
-               SkScriptValue value;
-               displayable->getProperty(propertyIndex(), &value);
-               SkASSERT(value.fType == SkType_String);
-               *string = value.fOperand.fString;
-               return;
-       }
-       SkASSERT(fCount == sizeof(SkString) / sizeof(SkScalar));
-       SkASSERT(fType == SkType_String || fType == SkType_DynamicString);
-       void* valuePtr = memberData(displayable);
-       *string = (SkString*) valuePtr;
+    if (fType == SkType_MemberProperty) {
+        SkScriptValue value;
+        displayable->getProperty(propertyIndex(), &value);
+        SkASSERT(value.fType == SkType_String);
+        *string = value.fOperand.fString;
+        return;
+    }
+    SkASSERT(fCount == sizeof(SkString) / sizeof(SkScalar));
+    SkASSERT(fType == SkType_String || fType == SkType_DynamicString);
+    void* valuePtr = memberData(displayable);
+    *string = (SkString*) valuePtr;
 }
 
 void SkMemberInfo::getValue(const SkDisplayable* displayable, SkOperand value[], int count) const {
-       SkASSERT(fType != SkType_String && fType != SkType_MemberProperty);
-       SkASSERT(count == fCount);      
-       void* valuePtr = memberData(displayable);
-       size_t byteSize = getSize(displayable);
-       SkASSERT(sizeof(value[0].fScalar) == sizeof(value[0])); // no support for 64 bit pointers, yet
-       memcpy(value, valuePtr, byteSize);
+    SkASSERT(fType != SkType_String && fType != SkType_MemberProperty);
+    SkASSERT(count == fCount);  
+    void* valuePtr = memberData(displayable);
+    size_t byteSize = getSize(displayable);
+    SkASSERT(sizeof(value[0].fScalar) == sizeof(value[0])); // no support for 64 bit pointers, yet
+    memcpy(value, valuePtr, byteSize);
 }
 
 void SkMemberInfo::setString(SkDisplayable* displayable, SkString* value) const {
-       SkString* string = (SkString*) memberData(displayable);
-       string->set(*value);
-       displayable->dirty();
+    SkString* string = (SkString*) memberData(displayable);
+    string->set(*value);
+    displayable->dirty();
 }
 
 void SkMemberInfo::setValue(SkDisplayable* displayable, const SkOperand values[], 
-                                                       int count) const {
-       SkASSERT(sizeof(values[0].fScalar) == sizeof(values[0]));       // no support for 64 bit pointers, yet
-       char* dst = (char*) memberData(displayable);
-       if (fType == SkType_Array) {
-               SkTDScalarArray* array = (SkTDScalarArray* ) dst;
-               array->setCount(count);
-               dst = (char*) array->begin();
-       }
-       memcpy(dst, values, count * sizeof(SkOperand));
-       displayable->dirty();
+                            int count) const {
+    SkASSERT(sizeof(values[0].fScalar) == sizeof(values[0]));   // no support for 64 bit pointers, yet
+    char* dst = (char*) memberData(displayable);
+    if (fType == SkType_Array) {
+        SkTDScalarArray* array = (SkTDScalarArray* ) dst;
+        array->setCount(count);
+        dst = (char*) array->begin();
+    }
+    memcpy(dst, values, count * sizeof(SkOperand));
+    displayable->dirty();
 }
 
-                                                       
+                            
 static inline bool is_between(int c, int min, int max)
 {
-       return (unsigned)(c - min) <= (unsigned)(max - min);
+    return (unsigned)(c - min) <= (unsigned)(max - min);
 }
 
 static inline bool is_hex(int c)
 {
-       if (is_between(c, '0', '9'))
-               return true;
-       c |= 0x20;      // make us lower-case
-       if (is_between(c, 'a', 'f'))
-               return true;
-       return false;
+    if (is_between(c, '0', '9'))
+        return true;
+    c |= 0x20;  // make us lower-case
+    if (is_between(c, 'a', 'f'))
+        return true;
+    return false;
 }
 
 
 bool SkMemberInfo::setValue(SkAnimateMaker& maker, SkTDOperandArray* arrayStorage, 
-       int storageOffset, int maxStorage, SkDisplayable* displayable, SkDisplayTypes outType,
-       const char rawValue[], size_t rawValueLen) const 
+    int storageOffset, int maxStorage, SkDisplayable* displayable, SkDisplayTypes outType,
+    const char rawValue[], size_t rawValueLen) const 
 {
-       SkString valueStr(rawValue, rawValueLen);
-       SkScriptValue scriptValue;
-       scriptValue.fType = SkType_Unknown;
-       scriptValue.fOperand.fS32 = 0;
-       SkDisplayTypes type = getType();
-       SkAnimatorScript engine(maker, displayable, type);
-       if (arrayStorage)
-               displayable = nil;
-       bool success = true;
-       void* untypedStorage = nil;
-       if (displayable && fType != SkType_MemberProperty && fType != SkType_MemberFunction)
-               untypedStorage = (SkTDOperandArray*) memberData(displayable);
+    SkString valueStr(rawValue, rawValueLen);
+    SkScriptValue scriptValue;
+    scriptValue.fType = SkType_Unknown;
+    scriptValue.fOperand.fS32 = 0;
+    SkDisplayTypes type = getType();
+    SkAnimatorScript engine(maker, displayable, type);
+    if (arrayStorage)
+        displayable = nil;
+    bool success = true;
+    void* untypedStorage = nil;
+    if (displayable && fType != SkType_MemberProperty && fType != SkType_MemberFunction)
+        untypedStorage = (SkTDOperandArray*) memberData(displayable);
 
-       if (type == SkType_ARGB) {
-               // for both SpiderMonkey and SkiaScript, substitute any #xyz or #xxyyzz first
-                       // it's enough to expand the colors into 0xFFxxyyzz
-               const char* poundPos;
-               while ((poundPos = strchr(valueStr.c_str(), '#')) != nil) {
-                       size_t offset = poundPos - valueStr.c_str();
-                       if (valueStr.size() - offset < 4)
-                               break;
-                       char r = poundPos[1];
-                       char g = poundPos[2];
-                       char b = poundPos[3];
-                       if (is_hex(r) == false || is_hex(g) == false || is_hex(b) == false)
-                               break;
-                       char hex = poundPos[4];
-                       if (is_hex(hex) == false) {
-                               valueStr.insertUnichar(offset + 1, r);
-                               valueStr.insertUnichar(offset + 3, g);
-                               valueStr.insertUnichar(offset + 5, b);
-                       }
-                       *(char*) poundPos = '0'; // overwrite '#'
-                       valueStr.insert(offset + 1, "xFF");
-               
-       }
-       if (SkDisplayType::IsDisplayable(&maker, type) || SkDisplayType::IsEnum(&maker, type) || type == SkType_ARGB)
-               goto scriptCommon;
-       switch (type) {
-               case SkType_String:
+    if (type == SkType_ARGB) {
+        // for both SpiderMonkey and SkiaScript, substitute any #xyz or #xxyyzz first
+            // it's enough to expand the colors into 0xFFxxyyzz
+        const char* poundPos;
+        while ((poundPos = strchr(valueStr.c_str(), '#')) != nil) {
+            size_t offset = poundPos - valueStr.c_str();
+            if (valueStr.size() - offset < 4)
+                break;
+            char r = poundPos[1];
+            char g = poundPos[2];
+            char b = poundPos[3];
+            if (is_hex(r) == false || is_hex(g) == false || is_hex(b) == false)
+                break;
+            char hex = poundPos[4];
+            if (is_hex(hex) == false) {
+                valueStr.insertUnichar(offset + 1, r);
+                valueStr.insertUnichar(offset + 3, g);
+                valueStr.insertUnichar(offset + 5, b);
+            }
+            *(char*) poundPos = '0'; // overwrite '#'
+            valueStr.insert(offset + 1, "xFF");
+        } 
+    }
+    if (SkDisplayType::IsDisplayable(&maker, type) || SkDisplayType::IsEnum(&maker, type) || type == SkType_ARGB)
+        goto scriptCommon;
+    switch (type) {
+        case SkType_String:
 #if 0
-                       if (displayable && displayable->isAnimate()) {
-                               
-                               goto noScriptString;
-                       
-                       if (strncmp(rawValue, "#string:", sizeof("#string:") - 1) == 0) {
-                               SkASSERT(sizeof("string") == sizeof("script"));
-                               char* stringHeader = valueStr.writable_str();
-                               memcpy(&stringHeader[1], "script", sizeof("script") - 1);
-                               rawValue = valueStr.c_str();
-                               goto noScriptString;
-                       } else 
+            if (displayable && displayable->isAnimate()) {
+                
+                goto noScriptString;
+            } 
+            if (strncmp(rawValue, "#string:", sizeof("#string:") - 1) == 0) {
+                SkASSERT(sizeof("string") == sizeof("script"));
+                char* stringHeader = valueStr.writable_str();
+                memcpy(&stringHeader[1], "script", sizeof("script") - 1);
+                rawValue = valueStr.c_str();
+                goto noScriptString;
+            } else 
 #endif
-                       if (strncmp(rawValue, "#script:", sizeof("#script:") - 1) != 0)
-                               goto noScriptString;
-                       valueStr.remove(0, 8);
-               case SkType_Unknown:
-               case SkType_Int: 
-               case SkType_MSec:  // for the purposes of script, MSec is treated as a Scalar
-               case SkType_Point:
-               case SkType_3D_Point:
-               case SkType_Float:
-               case SkType_Array:
+            if (strncmp(rawValue, "#script:", sizeof("#script:") - 1) != 0)
+                goto noScriptString;
+            valueStr.remove(0, 8);
+        case SkType_Unknown:
+        case SkType_Int: 
+        case SkType_MSec:  // for the purposes of script, MSec is treated as a Scalar
+        case SkType_Point:
+        case SkType_3D_Point:
+        case SkType_Float:
+        case SkType_Array:
 scriptCommon: {
-                               const char* script = valueStr.c_str();
-                               success = engine.evaluateScript(&script, &scriptValue);
-                               if (success == false) {
-                                       maker.setScriptError(engine);
-                                       return false;
-                               }
-                       }
-                       SkASSERT(success);
-                       if (scriptValue.fType == SkType_Displayable) {
-                               if (type == SkType_String) {
-                                       const char* charPtr;
-                                       maker.findKey(scriptValue.fOperand.fDisplayable, &charPtr);
-                                       scriptValue.fOperand.fString = new SkString(charPtr);
-                                       scriptValue.fType = SkType_String;
-                                       engine.SkScriptEngine::track(scriptValue.fOperand.fString);
-                                       break;
-                               }
-                               SkASSERT(SkDisplayType::IsDisplayable(&maker, type));
-                               if (displayable)
-                                       displayable->setReference(this, scriptValue.fOperand.fDisplayable);
-                               else
-                                       arrayStorage->begin()[0].fDisplayable = scriptValue.fOperand.fDisplayable;
-                               return true;
-                       }
-                       if (type != scriptValue.fType) {
-                               if (scriptValue.fType == SkType_Array) {
-                                       engine.forget(scriptValue.getArray());
-                                       goto writeStruct; // real structs have already been written by script
-                               }
-                               switch (type) {
-                                       case SkType_String:
-                                               success = engine.convertTo(SkType_String, &scriptValue);
-                                               break;
-                                       case SkType_MSec:
-                                       case SkType_Float:
-                                               success = engine.convertTo(SkType_Float, &scriptValue);
-                                               break;
-                                       case SkType_Int:
-                                               success = engine.convertTo(SkType_Int, &scriptValue);
-                                               break;
-                                       case SkType_Array:
-                                               success = engine.convertTo(arrayType(), &scriptValue);
-                                               // !!! incomplete; create array of appropriate type and add scriptValue to it
-                                               SkASSERT(0);
-                                               break;
-                                       case SkType_Displayable:
-                                       case SkType_Drawable:
-                                               return false;   // no way to convert other types to this
-                                       default:        // to avoid warnings
-                                               break;
-                               }
-                               if (success == false)
-                                       return false;
-                       }
-                       if (type == SkType_MSec)
-                               scriptValue.fOperand.fMSec = SkScalarMulRound(scriptValue.fOperand.fScalar, 1000);
-                       scriptValue.fType = type;
-               break;
-               noScriptString:
-               case SkType_DynamicString:
-                       if (fType == SkType_MemberProperty && displayable) {
-                               SkString string(rawValue, rawValueLen);
-                               SkScriptValue scriptValue;
-                               scriptValue.fOperand.fString = &string;
-                               scriptValue.fType = SkType_String;
-                               displayable->setProperty(propertyIndex(), scriptValue);
-                       } else if (displayable) {
-                               SkString* string = (SkString*) memberData(displayable);
-                               string->set(rawValue, rawValueLen);
-                       } else {
-                               SkASSERT(arrayStorage->count() == 1);
-                               arrayStorage->begin()->fString->set(rawValue, rawValueLen);
-                       }
-                       goto dirty;
-               case SkType_Base64: {
-                       SkBase64 base64;
-                       base64.decode(rawValue, rawValueLen);
-                       *(SkBase64* ) untypedStorage = base64;
-                       } goto dirty;
-               default:
-                       SkASSERT(0);
-                       break;
-       }
-//     if (SkDisplayType::IsStruct(type) == false) 
-       {
+                const char* script = valueStr.c_str();
+                success = engine.evaluateScript(&script, &scriptValue);
+                if (success == false) {
+                    maker.setScriptError(engine);
+                    return false;
+                }
+            }
+            SkASSERT(success);
+            if (scriptValue.fType == SkType_Displayable) {
+                if (type == SkType_String) {
+                    const char* charPtr;
+                    maker.findKey(scriptValue.fOperand.fDisplayable, &charPtr);
+                    scriptValue.fOperand.fString = new SkString(charPtr);
+                    scriptValue.fType = SkType_String;
+                    engine.SkScriptEngine::track(scriptValue.fOperand.fString);
+                    break;
+                }
+                SkASSERT(SkDisplayType::IsDisplayable(&maker, type));
+                if (displayable)
+                    displayable->setReference(this, scriptValue.fOperand.fDisplayable);
+                else
+                    arrayStorage->begin()[0].fDisplayable = scriptValue.fOperand.fDisplayable;
+                return true;
+            }
+            if (type != scriptValue.fType) {
+                if (scriptValue.fType == SkType_Array) {
+                    engine.forget(scriptValue.getArray());
+                    goto writeStruct; // real structs have already been written by script
+                }
+                switch (type) {
+                    case SkType_String:
+                        success = engine.convertTo(SkType_String, &scriptValue);
+                        break;
+                    case SkType_MSec:
+                    case SkType_Float:
+                        success = engine.convertTo(SkType_Float, &scriptValue);
+                        break;
+                    case SkType_Int:
+                        success = engine.convertTo(SkType_Int, &scriptValue);
+                        break;
+                    case SkType_Array:
+                        success = engine.convertTo(arrayType(), &scriptValue);
+                        // !!! incomplete; create array of appropriate type and add scriptValue to it
+                        SkASSERT(0);
+                        break;
+                    case SkType_Displayable:
+                    case SkType_Drawable:
+                        return false;   // no way to convert other types to this
+                    default:    // to avoid warnings
+                        break;
+                }
+                if (success == false)
+                    return false;
+            }
+            if (type == SkType_MSec)
+                scriptValue.fOperand.fMSec = SkScalarMulRound(scriptValue.fOperand.fScalar, 1000);
+            scriptValue.fType = type;
+        break;
+        noScriptString:
+        case SkType_DynamicString:
+            if (fType == SkType_MemberProperty && displayable) {
+                SkString string(rawValue, rawValueLen);
+                SkScriptValue scriptValue;
+                scriptValue.fOperand.fString = &string;
+                scriptValue.fType = SkType_String;
+                displayable->setProperty(propertyIndex(), scriptValue);
+            } else if (displayable) {
+                SkString* string = (SkString*) memberData(displayable);
+                string->set(rawValue, rawValueLen);
+            } else {
+                SkASSERT(arrayStorage->count() == 1);
+                arrayStorage->begin()->fString->set(rawValue, rawValueLen);
+            }
+            goto dirty;
+        case SkType_Base64: {
+            SkBase64 base64;
+            base64.decode(rawValue, rawValueLen);
+            *(SkBase64* ) untypedStorage = base64;
+            } goto dirty;
+        default:
+            SkASSERT(0);
+            break;
+    }
+//  if (SkDisplayType::IsStruct(type) == false) 
+    {
 writeStruct:
-               if (writeValue(displayable, arrayStorage, storageOffset, maxStorage, 
-                               untypedStorage, outType, scriptValue)) {
-                                       maker.setErrorCode(SkDisplayXMLParserError::kUnexpectedType);
-                       return false;
-               }
-       }
+        if (writeValue(displayable, arrayStorage, storageOffset, maxStorage, 
+                untypedStorage, outType, scriptValue)) {
+                    maker.setErrorCode(SkDisplayXMLParserError::kUnexpectedType);
+            return false;
+        }
+    }
 dirty:
-       if (displayable)
-               displayable->dirty();
-       return true;
+    if (displayable)
+        displayable->dirty();
+    return true;
 }
 
 bool SkMemberInfo::setValue(SkAnimateMaker& maker, SkTDOperandArray* arrayStorage, 
-               int storageOffset, int maxStorage, SkDisplayable* displayable, SkDisplayTypes outType,
-               SkString& raw) const {
-       return setValue(maker, arrayStorage, storageOffset, maxStorage, displayable, outType, raw.c_str(),
-               raw.size());
+        int storageOffset, int maxStorage, SkDisplayable* displayable, SkDisplayTypes outType,
+        SkString& raw) const {
+    return setValue(maker, arrayStorage, storageOffset, maxStorage, displayable, outType, raw.c_str(),
+        raw.size());
 }
 
 bool SkMemberInfo::writeValue(SkDisplayable* displayable, SkTDOperandArray* arrayStorage, 
-       int storageOffset, int maxStorage, void* untypedStorage, SkDisplayTypes outType, 
-       SkScriptValue& scriptValue) const
+    int storageOffset, int maxStorage, void* untypedStorage, SkDisplayTypes outType, 
+    SkScriptValue& scriptValue) const
 {
-       SkOperand* storage = untypedStorage ? (SkOperand*) untypedStorage : arrayStorage ? 
-               arrayStorage->begin() : nil;
-       if (storage)
-               storage += storageOffset;
-       SkDisplayTypes type = getType();
-       if (fType == SkType_MemberProperty) {
-               if(displayable)
-                       displayable->setProperty(propertyIndex(), scriptValue);
-               else {
-                       SkASSERT(storageOffset < arrayStorage->count());
-                       switch (scriptValue.fType) {
-                               case SkType_Boolean:
-                               case SkType_Float:
-                               case SkType_Int:
-                                       memcpy(&storage->fScalar, &scriptValue.fOperand.fScalar, sizeof(SkScalar));
-                                       break;
-                               case SkType_Array:
-                                       memcpy(&storage->fScalar, scriptValue.fOperand.fArray->begin(), scriptValue.fOperand.fArray->count() * sizeof(SkScalar));
-                                       break;
-                               case SkType_String:
-                                       storage->fString->set(*scriptValue.fOperand.fString);
-                                       break;
-                               default:
-                                       SkASSERT(0);    // type isn't handled yet
-                       }
-               }
-       } else if (fType == SkType_MemberFunction) {
-               SkASSERT(scriptValue.fType == SkType_Array);
-               if (displayable)
-                       displayable->executeFunction(displayable, this, scriptValue.fOperand.fArray, nil);
-               else {
-                       int count = scriptValue.fOperand.fArray->count();
-       //              SkASSERT(maxStorage == 0 || count == maxStorage);
-                       if (arrayStorage->count() == 2)
-                               arrayStorage->setCount(2 * count);
-                       else {
-                               storageOffset *= count;
-                               SkASSERT(count + storageOffset <= arrayStorage->count());
-                       }
-                       memcpy(&(*arrayStorage)[storageOffset], scriptValue.fOperand.fArray->begin(), count * sizeof(SkOperand));
-               }
+    SkOperand* storage = untypedStorage ? (SkOperand*) untypedStorage : arrayStorage ? 
+        arrayStorage->begin() : nil;
+    if (storage)
+        storage += storageOffset;
+    SkDisplayTypes type = getType();
+    if (fType == SkType_MemberProperty) {
+        if(displayable)
+            displayable->setProperty(propertyIndex(), scriptValue);
+        else {
+            SkASSERT(storageOffset < arrayStorage->count());
+            switch (scriptValue.fType) {
+                case SkType_Boolean:
+                case SkType_Float:
+                case SkType_Int:
+                    memcpy(&storage->fScalar, &scriptValue.fOperand.fScalar, sizeof(SkScalar));
+                    break;
+                case SkType_Array:
+                    memcpy(&storage->fScalar, scriptValue.fOperand.fArray->begin(), scriptValue.fOperand.fArray->count() * sizeof(SkScalar));
+                    break;
+                case SkType_String:
+                    storage->fString->set(*scriptValue.fOperand.fString);
+                    break;
+                default:
+                    SkASSERT(0);    // type isn't handled yet
+            }
+        }
+    } else if (fType == SkType_MemberFunction) {
+        SkASSERT(scriptValue.fType == SkType_Array);
+        if (displayable)
+            displayable->executeFunction(displayable, this, scriptValue.fOperand.fArray, nil);
+        else {
+            int count = scriptValue.fOperand.fArray->count();
+    //      SkASSERT(maxStorage == 0 || count == maxStorage);
+            if (arrayStorage->count() == 2)
+                arrayStorage->setCount(2 * count);
+            else {
+                storageOffset *= count;
+                SkASSERT(count + storageOffset <= arrayStorage->count());
+            }
+            memcpy(&(*arrayStorage)[storageOffset], scriptValue.fOperand.fArray->begin(), count * sizeof(SkOperand));
+        }
 
-       } else if (fType == SkType_Array) {
-               SkTypedArray* destArray = (SkTypedArray*) (untypedStorage ? untypedStorage : arrayStorage);
-               SkASSERT(destArray);
-       //      destArray->setCount(0);
-               if (scriptValue.fType != SkType_Array) {
-                       SkASSERT(type == scriptValue.fType);
-       //              SkASSERT(storageOffset + 1 <= maxStorage);
-                       destArray->setCount(storageOffset + 1);
-                       (*destArray)[storageOffset] = scriptValue.fOperand;
-               } else {
-                       if (type == SkType_Unknown) {
-                               type = scriptValue.fOperand.fArray->getType();
-                               destArray->setType(type);
-                       }
-                       SkASSERT(type == scriptValue.fOperand.fArray->getType());
-                       int count = scriptValue.fOperand.fArray->count();
-       //              SkASSERT(storageOffset + count <= maxStorage);
-                       destArray->setCount(storageOffset + count);
-                       memcpy(destArray->begin() + storageOffset, scriptValue.fOperand.fArray->begin(), sizeof(SkOperand) * count);
-               }
-       } else if (type == SkType_String) {
-               SkString* string = untypedStorage ? (SkString*) untypedStorage : (*arrayStorage)[storageOffset].fString;
-               string->set(*scriptValue.fOperand.fString);
-       } else if (type == SkType_ARGB && outType == SkType_Float) {
-               SkTypedArray* array = scriptValue.fOperand.fArray;
-               SkASSERT(scriptValue.fType == SkType_Int || scriptValue.fType == SkType_ARGB || 
-                       scriptValue.fType == SkType_Array);
-               SkASSERT(scriptValue.fType != SkType_Array || (array != nil &&
-                       array->getType() == SkType_Int));
-               int numberOfColors = scriptValue.fType == SkType_Array ? array->count() : 1;
-               int numberOfComponents = numberOfColors * 4;
-       //      SkASSERT(maxStorage == 0 || maxStorage == numberOfComponents);
-               if (maxStorage == 0)
-                       arrayStorage->setCount(numberOfComponents);
-               for (int index = 0; index < numberOfColors; index++) {
-                       SkColor color = scriptValue.fType == SkType_Array ? 
-                               (SkColor) array->begin()[index].fS32 : (SkColor) scriptValue.fOperand.fS32;
-                       storage[0].fScalar = SkIntToScalar(SkColorGetA(color));
-                       storage[1].fScalar = SkIntToScalar(SkColorGetR(color));
-                       storage[2].fScalar = SkIntToScalar(SkColorGetG(color));
-                       storage[3].fScalar = SkIntToScalar(SkColorGetB(color));
-                       storage += 4;
-               }
-       } else if (SkDisplayType::IsStruct(nil /* !!! maker*/, type)) {
-               if (scriptValue.fType != SkType_Array)
-                       return true;    // error
-               SkASSERT(sizeof(SkScalar) == sizeof(SkOperand)); // !!! no 64 bit pointer support yet
-               int count = scriptValue.fOperand.fArray->count();
-               if (count > 0) {
-                       SkASSERT(fCount == count);
-                       memcpy(storage, scriptValue.fOperand.fArray->begin(), count * sizeof(SkOperand));
-               }
-       } else if (scriptValue.fType == SkType_Array) {
-               SkASSERT(scriptValue.fOperand.fArray->getType() == type);
-               SkASSERT(scriptValue.fOperand.fArray->count() == getCount());
-               memcpy(storage, scriptValue.fOperand.fArray->begin(), getCount() * sizeof(SkOperand));
-       } else {
-               memcpy(storage, &scriptValue.fOperand, sizeof(SkOperand));
-       }
-       return false;
+    } else if (fType == SkType_Array) {
+        SkTypedArray* destArray = (SkTypedArray*) (untypedStorage ? untypedStorage : arrayStorage);
+        SkASSERT(destArray);
+    //  destArray->setCount(0);
+        if (scriptValue.fType != SkType_Array) {
+            SkASSERT(type == scriptValue.fType);
+    //      SkASSERT(storageOffset + 1 <= maxStorage);
+            destArray->setCount(storageOffset + 1);
+            (*destArray)[storageOffset] = scriptValue.fOperand;
+        } else {
+            if (type == SkType_Unknown) {
+                type = scriptValue.fOperand.fArray->getType();
+                destArray->setType(type);
+            }
+            SkASSERT(type == scriptValue.fOperand.fArray->getType());
+            int count = scriptValue.fOperand.fArray->count();
+    //      SkASSERT(storageOffset + count <= maxStorage);
+            destArray->setCount(storageOffset + count);
+            memcpy(destArray->begin() + storageOffset, scriptValue.fOperand.fArray->begin(), sizeof(SkOperand) * count);
+        }
+    } else if (type == SkType_String) {
+        SkString* string = untypedStorage ? (SkString*) untypedStorage : (*arrayStorage)[storageOffset].fString;
+        string->set(*scriptValue.fOperand.fString);
+    } else if (type == SkType_ARGB && outType == SkType_Float) {
+        SkTypedArray* array = scriptValue.fOperand.fArray;
+        SkASSERT(scriptValue.fType == SkType_Int || scriptValue.fType == SkType_ARGB || 
+            scriptValue.fType == SkType_Array);
+        SkASSERT(scriptValue.fType != SkType_Array || (array != nil &&
+            array->getType() == SkType_Int));
+        int numberOfColors = scriptValue.fType == SkType_Array ? array->count() : 1;
+        int numberOfComponents = numberOfColors * 4;
+    //  SkASSERT(maxStorage == 0 || maxStorage == numberOfComponents);
+        if (maxStorage == 0)
+            arrayStorage->setCount(numberOfComponents);
+        for (int index = 0; index < numberOfColors; index++) {
+            SkColor color = scriptValue.fType == SkType_Array ? 
+                (SkColor) array->begin()[index].fS32 : (SkColor) scriptValue.fOperand.fS32;
+            storage[0].fScalar = SkIntToScalar(SkColorGetA(color));
+            storage[1].fScalar = SkIntToScalar(SkColorGetR(color));
+            storage[2].fScalar = SkIntToScalar(SkColorGetG(color));
+            storage[3].fScalar = SkIntToScalar(SkColorGetB(color));
+            storage += 4;
+        }
+    } else if (SkDisplayType::IsStruct(nil /* !!! maker*/, type)) {
+        if (scriptValue.fType != SkType_Array)
+            return true;    // error
+        SkASSERT(sizeof(SkScalar) == sizeof(SkOperand)); // !!! no 64 bit pointer support yet
+        int count = scriptValue.fOperand.fArray->count();
+        if (count > 0) {
+            SkASSERT(fCount == count);
+            memcpy(storage, scriptValue.fOperand.fArray->begin(), count * sizeof(SkOperand));
+        }
+    } else if (scriptValue.fType == SkType_Array) {
+        SkASSERT(scriptValue.fOperand.fArray->getType() == type);
+        SkASSERT(scriptValue.fOperand.fArray->count() == getCount());
+        memcpy(storage, scriptValue.fOperand.fArray->begin(), getCount() * sizeof(SkOperand));
+    } else {
+        memcpy(storage, &scriptValue.fOperand, sizeof(SkOperand));
+    }
+    return false;
 }
 
 
 //void SkMemberInfo::setValue(SkDisplayable* displayable, const char value[], const char name[]) const {
-//     void* valuePtr = (void*) ((char*) displayable + fOffset);
-//     switch (fType) {
-//             case SkType_Point3D: {
-//                     static const char xyz[] = "x|y|z";
-//                     int index = find_one(xyz, name);
-//                     SkASSERT(index >= 0);
-//                     valuePtr = (void*) ((char*) valuePtr + index * sizeof(SkScalar));
-//                     } break;
-//             default:
-//                     SkASSERT(0);
-//     }
-//     SkParse::FindScalar(value, (SkScalar*) valuePtr);
-//     displayable->dirty();
+//  void* valuePtr = (void*) ((char*) displayable + fOffset);
+//  switch (fType) {
+//      case SkType_Point3D: {
+//          static const char xyz[] = "x|y|z";
+//          int index = find_one(xyz, name);
+//          SkASSERT(index >= 0);
+//          valuePtr = (void*) ((char*) valuePtr + index * sizeof(SkScalar));
+//          } break;
+//      default:
+//          SkASSERT(0);
+//  }
+//  SkParse::FindScalar(value, (SkScalar*) valuePtr);
+//  displayable->dirty();
 //}
 
 #if SK_USE_CONDENSED_INFO == 0
 
 // Find Nth memberInfo
 const SkMemberInfo* SkMemberInfo::Find(const SkMemberInfo info[], int count, int* index) {
-       SkASSERT(*index >= 0);
-       if (info->fType == SkType_BaseClassInfo) {
-               const SkMemberInfo* inherited = (SkMemberInfo*) info->fName;
-               const SkMemberInfo* result = SkMemberInfo::Find(inherited, info->fCount, index);
-               if (result != nil)
-                       return result;
-               if (--count == 0)
-                       return nil;
-               info++;
-       }
-       SkASSERT(info->fName);
-       SkASSERT(info->fType != SkType_BaseClassInfo);
-       if (*index >= count) {
-               *index -= count;
-               return nil;
-       }
-       return &info[*index];
+    SkASSERT(*index >= 0);
+    if (info->fType == SkType_BaseClassInfo) {
+        const SkMemberInfo* inherited = (SkMemberInfo*) info->fName;
+        const SkMemberInfo* result = SkMemberInfo::Find(inherited, info->fCount, index);
+        if (result != nil)
+            return result;
+        if (--count == 0)
+            return nil;
+        info++;
+    }
+    SkASSERT(info->fName);
+    SkASSERT(info->fType != SkType_BaseClassInfo);
+    if (*index >= count) {
+        *index -= count;
+        return nil;
+    }
+    return &info[*index];
 }
 
 // Find named memberinfo
 const SkMemberInfo* SkMemberInfo::Find(const SkMemberInfo info[], int count, const char** matchPtr) {
-       const char* match = *matchPtr;
-       if (info->fType == SkType_BaseClassInfo) {
-               const SkMemberInfo* inherited = (SkMemberInfo*) info->fName;
-               const SkMemberInfo* result = SkMemberInfo::Find(inherited, info->fCount, matchPtr);
-               if (result != nil)
-                       return result;
-               if (--count == 0)
-                       return nil;
-               info++;
-       }
-       SkASSERT(info->fName);
-       SkASSERT(info->fType != SkType_BaseClassInfo);
-       int index = SkStrSearch(&info->fName, count, match, sizeof(*info));
-       if (index < 0 || index >= count)
-               return nil;
-       return &info[index];
+    const char* match = *matchPtr;
+    if (info->fType == SkType_BaseClassInfo) {
+        const SkMemberInfo* inherited = (SkMemberInfo*) info->fName;
+        const SkMemberInfo* result = SkMemberInfo::Find(inherited, info->fCount, matchPtr);
+        if (result != nil)
+            return result;
+        if (--count == 0)
+            return nil;
+        info++;
+    }
+    SkASSERT(info->fName);
+    SkASSERT(info->fType != SkType_BaseClassInfo);
+    int index = SkStrSearch(&info->fName, count, match, sizeof(*info));
+    if (index < 0 || index >= count)
+        return nil;
+    return &info[index];
 }
 
 const SkMemberInfo* SkMemberInfo::getInherited() const {
-       return (SkMemberInfo*) fName;
+    return (SkMemberInfo*) fName;
 }
 
 #endif // SK_USE_CONDENSED_INFO == 0
 
 #if 0
 bool SkMemberInfo::SetValue(void* valuePtr, const char value[], SkDisplayTypes type, 
-                                                       int count) {
-       switch (type) {
-               case SkType_Animate:
-               case SkType_BaseBitmap: 
-               case SkType_Bitmap:
-               case SkType_Dash:
-               case SkType_Displayable:
-               case SkType_Drawable:
-               case SkType_Matrix:
-               case SkType_Path:
-               case SkType_Text:
-               case SkType_3D_Patch:
-                       return false; // ref to object; caller must resolve
-               case SkType_MSec: {
-                       SkParse::FindMSec(value, (SkMSec*) valuePtr);
-                       } break;
-               case SkType_3D_Point:
-               case SkType_Point:
-       //      case SkType_PointArray:
-               case SkType_ScalarArray: 
-                       SkParse::FindScalars(value, (SkScalar*) valuePtr, count);
-                       break;
-               default:
-                       SkASSERT(0);
-       }
-       return true;
+                            int count) {
+    switch (type) {
+        case SkType_Animate:
+        case SkType_BaseBitmap: 
+        case SkType_Bitmap:
+        case SkType_Dash:
+        case SkType_Displayable:
+        case SkType_Drawable:
+        case SkType_Matrix:
+        case SkType_Path:
+        case SkType_Text:
+        case SkType_3D_Patch:
+            return false; // ref to object; caller must resolve
+        case SkType_MSec: {
+            SkParse::FindMSec(value, (SkMSec*) valuePtr);
+            } break;
+        case SkType_3D_Point:
+        case SkType_Point:
+    //  case SkType_PointArray:
+        case SkType_ScalarArray: 
+            SkParse::FindScalars(value, (SkScalar*) valuePtr, count);
+            break;
+        default:
+            SkASSERT(0);
+    }
+    return true;
 }
 #endif
 
index ec66846..8ea97af 100644 (file)
@@ -1,12 +1,29 @@
+/* libs/graphics/animator/SkMemberInfo.h
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #ifndef SkMemberInfo_DEFINED
 #define SkMemberInfo_DEFINED
 
 #if defined SK_BUILD_CONDENSED
-       #define SK_USE_CONDENSED_INFO 0
+    #define SK_USE_CONDENSED_INFO 0
 #elif defined  SK_BUILD_FOR_BREW
-       #define SK_USE_CONDENSED_INFO 1 /* required by BREW to handle its lack of writable globals */
+    #define SK_USE_CONDENSED_INFO 1 /* required by BREW to handle its lack of writable globals */
 #else
-       #define SK_USE_CONDENSED_INFO 0 /* optional, but usually 1 unless Cary is testing something */
+    #define SK_USE_CONDENSED_INFO 0 /* optional, but usually 1 unless Cary is testing something */
 #endif
 
 #include "SkDisplayType.h"
@@ -23,239 +40,239 @@ class SkScriptEngine;
 #define SkInt SkS32
 
 struct SkMemberInfo {
-       //!!! alternative:
-       // if fCount == 0, record is member property
-       // then fType can be type, so caller doesn't have to check
+    //!!! alternative:
+    // if fCount == 0, record is member property
+    // then fType can be type, so caller doesn't have to check
 #if SK_USE_CONDENSED_INFO == 0
-       const char* fName;      // may be nil for anonymous functions
-       size_t fOffset; // if negative, is index into member pointer table (for properties and functions)
-       SkDisplayTypes fType;
-       int fCount;                     // for properties, actual type (count is always assumed to be 1)
+    const char* fName;  // may be nil for anonymous functions
+    size_t fOffset; // if negative, is index into member pointer table (for properties and functions)
+    SkDisplayTypes fType;
+    int fCount;         // for properties, actual type (count is always assumed to be 1)
 #else
-       unsigned char fName;
-       signed char fOffset;
-       unsigned char fType;
-       signed char fCount;
+    unsigned char fName;
+    signed char fOffset;
+    unsigned char fType;
+    signed char fCount;
 #endif
-       SkDisplayTypes arrayType() const {
-               SkASSERT(fType == SkType_Array);
-               return (SkDisplayTypes) fCount;  // hack, but worth it?
-       }
-       int functionIndex() const {
-               SkASSERT(fType == SkType_MemberFunction);
-               return (signed) fOffset > 0 ? -1 + (int) fOffset : -1 - (int) fOffset;
-       }
-       bool getArrayValue(const SkDisplayable* displayable, int index, SkOperand* value) const;
-       int getCount() const {
-               return fType == SkType_MemberProperty || fType == SkType_Array ||
-                       fType == SkType_MemberFunction ? 1 : fCount;
-       }
-       const SkMemberInfo* getInherited() const;
-       size_t getSize(const SkDisplayable* ) const;
-       void getString(const SkDisplayable* , SkString** string) const;
-       SkDisplayTypes getType() const {
-               return fType == SkType_MemberProperty || fType == SkType_Array ||
-                       fType == SkType_MemberFunction ? (SkDisplayTypes) fCount : (SkDisplayTypes) fType;
-       }
-       void getValue(const SkDisplayable* , SkOperand values[], int count) const;
-       bool isEnum() const;
-       const char* mapEnums(const char* match, int* value) const;
-       void* memberData(const SkDisplayable* displayable) const {
-               SkASSERT(fType != SkType_MemberProperty &&      fType != SkType_MemberFunction);
-               return (void*) ((const char*) displayable + fOffset);
-       }
-       int propertyIndex() const {
-               SkASSERT(fType == SkType_MemberProperty);
-               return (signed) fOffset > 0 ? -1 + (int) fOffset : -1 - (int) fOffset;
-       }
-       SkDisplayTypes propertyType() const {
-               SkASSERT(fType == SkType_MemberProperty || fType == SkType_Array);
-               return (SkDisplayTypes) fCount;  // hack, but worth it?
-       }
-       void setMemberData(SkDisplayable* displayable, const void* child, size_t size) const {
-               SkASSERT(fType != SkType_MemberProperty &&      fType != SkType_MemberFunction);
-               memcpy((char*) displayable + fOffset, child, size);
-       }
-       void setString(SkDisplayable* , SkString* ) const;
-       void setValue(SkDisplayable* , const SkOperand values[], int count) const;
-       bool setValue(SkAnimateMaker& , SkTDOperandArray* storage, 
-               int storageOffset, int maxStorage, SkDisplayable* , 
-               SkDisplayTypes outType, const char value[], size_t len) const;
-       bool setValue(SkAnimateMaker& , SkTDOperandArray* storage, 
-               int storageOffset, int maxStorage, SkDisplayable* , 
-               SkDisplayTypes outType, SkString& str) const;
-//     void setValue(SkDisplayable* , const char value[], const char name[]) const;
-       bool writeValue(SkDisplayable* displayable, SkTDOperandArray* arrayStorage, 
-               int storageOffset, int maxStorage, void* untypedStorage, SkDisplayTypes outType, 
-               SkScriptValue& scriptValue) const;
+    SkDisplayTypes arrayType() const {
+        SkASSERT(fType == SkType_Array);
+        return (SkDisplayTypes) fCount;  // hack, but worth it?
+    }
+    int functionIndex() const {
+        SkASSERT(fType == SkType_MemberFunction);
+        return (signed) fOffset > 0 ? -1 + (int) fOffset : -1 - (int) fOffset;
+    }
+    bool getArrayValue(const SkDisplayable* displayable, int index, SkOperand* value) const;
+    int getCount() const {
+        return fType == SkType_MemberProperty || fType == SkType_Array ||
+            fType == SkType_MemberFunction ? 1 : fCount;
+    }
+    const SkMemberInfo* getInherited() const;
+    size_t getSize(const SkDisplayable* ) const;
+    void getString(const SkDisplayable* , SkString** string) const;
+    SkDisplayTypes getType() const {
+        return fType == SkType_MemberProperty || fType == SkType_Array ||
+            fType == SkType_MemberFunction ? (SkDisplayTypes) fCount : (SkDisplayTypes) fType;
+    }
+    void getValue(const SkDisplayable* , SkOperand values[], int count) const;
+    bool isEnum() const;
+    const char* mapEnums(const char* match, int* value) const;
+    void* memberData(const SkDisplayable* displayable) const {
+        SkASSERT(fType != SkType_MemberProperty &&  fType != SkType_MemberFunction);
+        return (void*) ((const char*) displayable + fOffset);
+    }
+    int propertyIndex() const {
+        SkASSERT(fType == SkType_MemberProperty);
+        return (signed) fOffset > 0 ? -1 + (int) fOffset : -1 - (int) fOffset;
+    }
+    SkDisplayTypes propertyType() const {
+        SkASSERT(fType == SkType_MemberProperty || fType == SkType_Array);
+        return (SkDisplayTypes) fCount;  // hack, but worth it?
+    }
+    void setMemberData(SkDisplayable* displayable, const void* child, size_t size) const {
+        SkASSERT(fType != SkType_MemberProperty &&  fType != SkType_MemberFunction);
+        memcpy((char*) displayable + fOffset, child, size);
+    }
+    void setString(SkDisplayable* , SkString* ) const;
+    void setValue(SkDisplayable* , const SkOperand values[], int count) const;
+    bool setValue(SkAnimateMaker& , SkTDOperandArray* storage, 
+        int storageOffset, int maxStorage, SkDisplayable* , 
+        SkDisplayTypes outType, const char value[], size_t len) const;
+    bool setValue(SkAnimateMaker& , SkTDOperandArray* storage, 
+        int storageOffset, int maxStorage, SkDisplayable* , 
+        SkDisplayTypes outType, SkString& str) const;
+//  void setValue(SkDisplayable* , const char value[], const char name[]) const;
+    bool writeValue(SkDisplayable* displayable, SkTDOperandArray* arrayStorage, 
+        int storageOffset, int maxStorage, void* untypedStorage, SkDisplayTypes outType, 
+        SkScriptValue& scriptValue) const;
 #if SK_USE_CONDENSED_INFO == 0
-       static const SkMemberInfo* Find(const SkMemberInfo [], int count, int* index);
-       static const SkMemberInfo* Find(const SkMemberInfo [], int count, const char** name);
+    static const SkMemberInfo* Find(const SkMemberInfo [], int count, int* index);
+    static const SkMemberInfo* Find(const SkMemberInfo [], int count, const char** name);
 #else
-       static const SkMemberInfo* Find(SkDisplayTypes type, int* index);
-       static const SkMemberInfo* Find(SkDisplayTypes type, const char** name);
+    static const SkMemberInfo* Find(SkDisplayTypes type, int* index);
+    static const SkMemberInfo* Find(SkDisplayTypes type, const char** name);
 #endif
-       static size_t GetSize(SkDisplayTypes type);     // size of simple types only
-//     static bool SetValue(void* value, const char* name, SkDisplayTypes , int count);
+    static size_t GetSize(SkDisplayTypes type); // size of simple types only
+//  static bool SetValue(void* value, const char* name, SkDisplayTypes , int count);
 };
 
 #define SK_MEMBER(_member, _type) \
-       { #_member, SK_OFFSETOF(BASE_CLASS, _member), SkType_##_type, \
-       sizeof(((BASE_CLASS*) 1)->_member) / sizeof(SkScalar) }
+    { #_member, SK_OFFSETOF(BASE_CLASS, _member), SkType_##_type, \
+    sizeof(((BASE_CLASS*) 1)->_member) / sizeof(SkScalar) }
 
 #define SK_MEMBER_ALIAS(_member, _alias, _type) \
-       { #_member, SK_OFFSETOF(BASE_CLASS, _alias), SkType_##_type, \
-       sizeof(((BASE_CLASS*) 1)->_alias) / sizeof(SkScalar) }
+    { #_member, SK_OFFSETOF(BASE_CLASS, _alias), SkType_##_type, \
+    sizeof(((BASE_CLASS*) 1)->_alias) / sizeof(SkScalar) }
 
 #define SK_MEMBER_ARRAY(_member, _type) \
-       { #_member, SK_OFFSETOF(BASE_CLASS, _member), SkType_Array, \
-       (int) SkType_##_type }
+    { #_member, SK_OFFSETOF(BASE_CLASS, _member), SkType_Array, \
+    (int) SkType_##_type }
 
 #define SK_MEMBER_INHERITED \
-       { (const char*) INHERITED::fInfo, 0, SkType_BaseClassInfo, INHERITED::fInfoCount }
+    { (const char*) INHERITED::fInfo, 0, SkType_BaseClassInfo, INHERITED::fInfoCount }
 
 // #define SK_MEMBER_KEY_TYPE(_member, _type) 
-//     {#_member, (size_t) -1, SkType_##_type, 0}
+//  {#_member, (size_t) -1, SkType_##_type, 0}
 
 #define SK_FUNCTION(_member) \
-       k_##_member##Function
+    k_##_member##Function
 
 #define SK_PROPERTY(_member) \
-       k_##_member##Property
+    k_##_member##Property
 
 #define SK_MEMBER_DYNAMIC_FUNCTION(_member, _type) \
-       {#_member, (size_t) (+1 + SK_FUNCTION(_member)), SkType_MemberFunction, \
-       (int) SkType_##_type }
+    {#_member, (size_t) (+1 + SK_FUNCTION(_member)), SkType_MemberFunction, \
+    (int) SkType_##_type }
 
 #define SK_MEMBER_DYNAMIC_PROPERTY(_member, _type) \
-       {#_member, (size_t) (1 + SK_PROPERTY(_member)), SkType_MemberProperty, \
-       (int) SkType_##_type }
+    {#_member, (size_t) (1 + SK_PROPERTY(_member)), SkType_MemberProperty, \
+    (int) SkType_##_type }
 
 #define SK_MEMBER_FUNCTION(_member, _type) \
-       {#_member, (size_t) (-1 - SK_FUNCTION(_member)), SkType_MemberFunction, \
-       (int) SkType_##_type }
+    {#_member, (size_t) (-1 - SK_FUNCTION(_member)), SkType_MemberFunction, \
+    (int) SkType_##_type }
 
 #define SK_MEMBER_PROPERTY(_member, _type) \
-       {#_member, (size_t) (-1 - SK_PROPERTY(_member)), SkType_MemberProperty, \
-       (int) SkType_##_type }
+    {#_member, (size_t) (-1 - SK_PROPERTY(_member)), SkType_MemberProperty, \
+    (int) SkType_##_type }
 
 #if SK_USE_CONDENSED_INFO == 0
 
 #define DECLARE_PRIVATE_MEMBER_INFO(_type) \
 public: \
-       static const SkMemberInfo fInfo[]; \
-       static const int fInfoCount; \
-       virtual const SkMemberInfo* getMember(int index); \
-       virtual const SkMemberInfo* getMember(const char name[]); \
-       typedef Sk##_type BASE_CLASS
+    static const SkMemberInfo fInfo[]; \
+    static const int fInfoCount; \
+    virtual const SkMemberInfo* getMember(int index); \
+    virtual const SkMemberInfo* getMember(const char name[]); \
+    typedef Sk##_type BASE_CLASS
 
 #define DECLARE_MEMBER_INFO(_type) \
 public: \
-       static const SkMemberInfo fInfo[]; \
-       static const int fInfoCount; \
-       virtual const SkMemberInfo* getMember(int index); \
-       virtual const SkMemberInfo* getMember(const char name[]); \
-       virtual SkDisplayTypes getType() const { return SkType_##_type; } \
-       typedef Sk##_type BASE_CLASS
+    static const SkMemberInfo fInfo[]; \
+    static const int fInfoCount; \
+    virtual const SkMemberInfo* getMember(int index); \
+    virtual const SkMemberInfo* getMember(const char name[]); \
+    virtual SkDisplayTypes getType() const { return SkType_##_type; } \
+    typedef Sk##_type BASE_CLASS
 
 #define DECLARE_DRAW_MEMBER_INFO(_type) \
 public: \
-       static const SkMemberInfo fInfo[]; \
-       static const int fInfoCount; \
-       virtual const SkMemberInfo* getMember(int index); \
-       virtual const SkMemberInfo* getMember(const char name[]); \
-       virtual SkDisplayTypes getType() const { return SkType_##_type; } \
-       typedef SkDraw##_type BASE_CLASS
+    static const SkMemberInfo fInfo[]; \
+    static const int fInfoCount; \
+    virtual const SkMemberInfo* getMember(int index); \
+    virtual const SkMemberInfo* getMember(const char name[]); \
+    virtual SkDisplayTypes getType() const { return SkType_##_type; } \
+    typedef SkDraw##_type BASE_CLASS
 
 #define DECLARE_DISPLAY_MEMBER_INFO(_type) \
 public: \
-       static const SkMemberInfo fInfo[]; \
-       static const int fInfoCount; \
-       virtual const SkMemberInfo* getMember(int index); \
-       virtual const SkMemberInfo* getMember(const char name[]); \
-       virtual SkDisplayTypes getType() const { return SkType_##_type; } \
-       typedef SkDisplay##_type BASE_CLASS
+    static const SkMemberInfo fInfo[]; \
+    static const int fInfoCount; \
+    virtual const SkMemberInfo* getMember(int index); \
+    virtual const SkMemberInfo* getMember(const char name[]); \
+    virtual SkDisplayTypes getType() const { return SkType_##_type; } \
+    typedef SkDisplay##_type BASE_CLASS
 
 #define DECLARE_EMPTY_MEMBER_INFO(_type) \
 public: \
-       virtual SkDisplayTypes getType() const { return SkType_##_type; }
-       
+    virtual SkDisplayTypes getType() const { return SkType_##_type; }
+    
 #define DECLARE_EXTRAS_MEMBER_INFO(_type) \
 public: \
-       static const SkMemberInfo fInfo[]; \
-       static const int fInfoCount; \
-       virtual const SkMemberInfo* getMember(int index); \
-       virtual const SkMemberInfo* getMember(const char name[]); \
-       SkDisplayTypes fType; \
-       virtual SkDisplayTypes getType() const { return fType; } \
-       typedef _type BASE_CLASS
+    static const SkMemberInfo fInfo[]; \
+    static const int fInfoCount; \
+    virtual const SkMemberInfo* getMember(int index); \
+    virtual const SkMemberInfo* getMember(const char name[]); \
+    SkDisplayTypes fType; \
+    virtual SkDisplayTypes getType() const { return fType; } \
+    typedef _type BASE_CLASS
 
 #define DECLARE_NO_VIRTUALS_MEMBER_INFO(_type) \
 public: \
-       static const SkMemberInfo fInfo[]; \
-       static const int fInfoCount; \
-       typedef Sk##_type BASE_CLASS
+    static const SkMemberInfo fInfo[]; \
+    static const int fInfoCount; \
+    typedef Sk##_type BASE_CLASS
 
 #define DEFINE_GET_MEMBER(_class) \
-       const SkMemberInfo* _class::getMember(int index) { \
-               const SkMemberInfo* result = SkMemberInfo::Find(fInfo, SK_ARRAY_COUNT(fInfo), &index); \
-               return result; \
-       } \
-       const SkMemberInfo* _class::getMember(const char name[]) { \
-               const SkMemberInfo* result = SkMemberInfo::Find(fInfo, SK_ARRAY_COUNT(fInfo), &name); \
-               return result; \
-       } \
-       const int _class::fInfoCount = SK_ARRAY_COUNT(fInfo)
+    const SkMemberInfo* _class::getMember(int index) { \
+        const SkMemberInfo* result = SkMemberInfo::Find(fInfo, SK_ARRAY_COUNT(fInfo), &index); \
+        return result; \
+    } \
+    const SkMemberInfo* _class::getMember(const char name[]) { \
+        const SkMemberInfo* result = SkMemberInfo::Find(fInfo, SK_ARRAY_COUNT(fInfo), &name); \
+        return result; \
+    } \
+    const int _class::fInfoCount = SK_ARRAY_COUNT(fInfo)
 
 #define DEFINE_NO_VIRTUALS_GET_MEMBER(_class) \
-       const int _class::fInfoCount = SK_ARRAY_COUNT(fInfo)
+    const int _class::fInfoCount = SK_ARRAY_COUNT(fInfo)
 
 #else
 
 #define DECLARE_PRIVATE_MEMBER_INFO(_type) \
 public: \
-       typedef Sk##_type BASE_CLASS
+    typedef Sk##_type BASE_CLASS
 
 #define DECLARE_MEMBER_INFO(_type) \
 public: \
-       virtual const SkMemberInfo* getMember(int index) { \
-               return SkDisplayType::GetMember(nil, SkType_##_type, &index); } \
-       virtual const SkMemberInfo* getMember(const char name[]) { \
-               return SkDisplayType::GetMember(nil, SkType_##_type, &name); } \
-       virtual SkDisplayTypes getType() const { return SkType_##_type; } \
-       typedef Sk##_type BASE_CLASS
+    virtual const SkMemberInfo* getMember(int index) { \
+        return SkDisplayType::GetMember(nil, SkType_##_type, &index); } \
+    virtual const SkMemberInfo* getMember(const char name[]) { \
+        return SkDisplayType::GetMember(nil, SkType_##_type, &name); } \
+    virtual SkDisplayTypes getType() const { return SkType_##_type; } \
+    typedef Sk##_type BASE_CLASS
 
 #define DECLARE_DRAW_MEMBER_INFO(_type) \
 public: \
-       virtual const SkMemberInfo* getMember(int index) { \
-               return SkDisplayType::GetMember(nil, SkType_##_type, &index); } \
-       virtual const SkMemberInfo* getMember(const char name[]) { \
-               return SkDisplayType::GetMember(nil, SkType_##_type, &name); } \
-       virtual SkDisplayTypes getType() const { return SkType_##_type; } \
-       typedef SkDraw##_type BASE_CLASS
+    virtual const SkMemberInfo* getMember(int index) { \
+        return SkDisplayType::GetMember(nil, SkType_##_type, &index); } \
+    virtual const SkMemberInfo* getMember(const char name[]) { \
+        return SkDisplayType::GetMember(nil, SkType_##_type, &name); } \
+    virtual SkDisplayTypes getType() const { return SkType_##_type; } \
+    typedef SkDraw##_type BASE_CLASS
 
 #define DECLARE_DISPLAY_MEMBER_INFO(_type) \
 public: \
-       virtual const SkMemberInfo* getMember(int index) { \
-               return SkDisplayType::GetMember(nil, SkType_##_type, &index); } \
-       virtual const SkMemberInfo* getMember(const char name[]) { \
-               return SkDisplayType::GetMember(nil, SkType_##_type, &name); } \
-       virtual SkDisplayTypes getType() const { return SkType_##_type; } \
-       typedef SkDisplay##_type BASE_CLASS
+    virtual const SkMemberInfo* getMember(int index) { \
+        return SkDisplayType::GetMember(nil, SkType_##_type, &index); } \
+    virtual const SkMemberInfo* getMember(const char name[]) { \
+        return SkDisplayType::GetMember(nil, SkType_##_type, &name); } \
+    virtual SkDisplayTypes getType() const { return SkType_##_type; } \
+    typedef SkDisplay##_type BASE_CLASS
 
 #define DECLARE_EXTRAS_MEMBER_INFO(_type) \
 public: \
-       virtual const SkMemberInfo* getMember(int index) { \
-               return SkDisplayType::GetMember(nil, SkType_##_type, &index); } \
-       virtual const SkMemberInfo* getMember(const char name[]) { \
-               return SkDisplayType::GetMember(nil, fType, &name); } \
-       SkDisplayTypes fType; \
-       virtual SkDisplayTypes getType() const { return fType; } \
-       typedef _type BASE_CLASS
+    virtual const SkMemberInfo* getMember(int index) { \
+        return SkDisplayType::GetMember(nil, SkType_##_type, &index); } \
+    virtual const SkMemberInfo* getMember(const char name[]) { \
+        return SkDisplayType::GetMember(nil, fType, &name); } \
+    SkDisplayTypes fType; \
+    virtual SkDisplayTypes getType() const { return fType; } \
+    typedef _type BASE_CLASS
 
 #define DECLARE_NO_VIRTUALS_MEMBER_INFO(_type) \
 public: \
-       typedef Sk##_type BASE_CLASS
+    typedef Sk##_type BASE_CLASS
 
 #define DEFINE_GET_MEMBER(_class)
 #define DEFINE_NO_VIRTUALS_GET_MEMBER(_class)
index 547cdbd..65ee592 100644 (file)
@@ -1,3 +1,20 @@
+/* libs/graphics/animator/SkOperand.h
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #ifndef SkOperand_DEFINED
 #define SkOperand_DEFINED
 
@@ -9,29 +26,29 @@ class SkDrawable;
 class SkString;
 
 union SkOperand {
-//     SkOperand() {}
-//     SkOperand(SkScalar scalar) : fScalar(scalar) {}
-       SkTypedArray* fArray;
-       SkDisplayable* fDisplayable;
-       SkDrawable* fDrawable;
-       void* fObject;
-       int32_t fS32;
-       SkMSec fMSec;
-       SkScalar fScalar;
-       SkString* fString;
+//  SkOperand() {}
+//  SkOperand(SkScalar scalar) : fScalar(scalar) {}
+    SkTypedArray* fArray;
+    SkDisplayable* fDisplayable;
+    SkDrawable* fDrawable;
+    void* fObject;
+    int32_t fS32;
+    SkMSec fMSec;
+    SkScalar fScalar;
+    SkString* fString;
 };
 
 struct SkScriptValue {
-       SkOperand fOperand;
-       SkDisplayTypes fType;
-       SkTypedArray* getArray() { SkASSERT(fType == SkType_Array); return fOperand.fArray; }
-       SkDisplayable* getDisplayable() { SkASSERT(fType == SkType_Displayable); return fOperand.fDisplayable; }
-       SkDrawable* getDrawable() { SkASSERT(fType == SkType_Drawable); return fOperand.fDrawable; }
-       int32_t getS32(SkAnimateMaker* maker) { SkASSERT(fType == SkType_Int || fType == SkType_Boolean ||
-               SkDisplayType::IsEnum(maker, fType)); return fOperand.fS32; }
-       SkMSec getMSec() { SkASSERT(fType == SkType_MSec); return fOperand.fMSec; }
-       SkScalar getScalar() { SkASSERT(fType == SkType_Float); return fOperand.fScalar; }
-       SkString* getString() { SkASSERT(fType == SkType_String); return fOperand.fString; }
+    SkOperand fOperand;
+    SkDisplayTypes fType;
+    SkTypedArray* getArray() { SkASSERT(fType == SkType_Array); return fOperand.fArray; }
+    SkDisplayable* getDisplayable() { SkASSERT(fType == SkType_Displayable); return fOperand.fDisplayable; }
+    SkDrawable* getDrawable() { SkASSERT(fType == SkType_Drawable); return fOperand.fDrawable; }
+    int32_t getS32(SkAnimateMaker* maker) { SkASSERT(fType == SkType_Int || fType == SkType_Boolean ||
+        SkDisplayType::IsEnum(maker, fType)); return fOperand.fS32; }
+    SkMSec getMSec() { SkASSERT(fType == SkType_MSec); return fOperand.fMSec; }
+    SkScalar getScalar() { SkASSERT(fType == SkType_Float); return fOperand.fScalar; }
+    SkString* getString() { SkASSERT(fType == SkType_String); return fOperand.fString; }
 };
 
 #endif // SkOperand_DEFINED
index c6e38c2..d623475 100644 (file)
@@ -1,3 +1,20 @@
+/* libs/graphics/animator/SkOperandInterpolator.h
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #ifndef SkOperandInterpolator_DEFINED
 #define SkOperandInterpolator_DEFINED
 
 
 class SkOperandInterpolator : public SkInterpolatorBase {
 public:
-       SkOperandInterpolator();
-       SkOperandInterpolator(int elemCount, int frameCount, SkDisplayTypes type);
-       SkOperand* getValues() { return fValues; }
-       int getValuesCount() { return fFrameCount * fElemCount; }
-       void    reset(int elemCount, int frameCount, SkDisplayTypes type);
+    SkOperandInterpolator();
+    SkOperandInterpolator(int elemCount, int frameCount, SkDisplayTypes type);
+    SkOperand* getValues() { return fValues; }
+    int getValuesCount() { return fFrameCount * fElemCount; }
+    void    reset(int elemCount, int frameCount, SkDisplayTypes type);
 
-       /**     Add or replace a key frame, copying the values[] data into the interpolator.
-               @param index    The index of this frame (frames must be ordered by time)
-               @param time     The millisecond time for this frame
-               @param values   The array of values [elemCount] for this frame. The data is copied
-                                               into the interpolator.
-               @param blend    A positive scalar specifying how to blend between this and the next key frame.
-                                               [0...1) is a cubic lag/log/lag blend (slow to change at the beginning and end)
-                                               1 is a linear blend (default)
-                                               (1...inf) is a cubic log/lag/log blend (fast to change at the beginning and end)
-       */
-       bool    setKeyFrame(int index, SkMSec time, const SkOperand values[], SkScalar blend = SK_Scalar1);
-       Result timeToValues(SkMSec time, SkOperand values[]) const;
-       SkDEBUGCODE(static void UnitTest();)
+    /** Add or replace a key frame, copying the values[] data into the interpolator.
+        @param index    The index of this frame (frames must be ordered by time)
+        @param time The millisecond time for this frame
+        @param values   The array of values [elemCount] for this frame. The data is copied
+                        into the interpolator.
+        @param blend    A positive scalar specifying how to blend between this and the next key frame.
+                        [0...1) is a cubic lag/log/lag blend (slow to change at the beginning and end)
+                        1 is a linear blend (default)
+                        (1...inf) is a cubic log/lag/log blend (fast to change at the beginning and end)
+    */
+    bool    setKeyFrame(int index, SkMSec time, const SkOperand values[], SkScalar blend = SK_Scalar1);
+    Result timeToValues(SkMSec time, SkOperand values[]) const;
+    SkDEBUGCODE(static void UnitTest();)
 private:
-       SkDisplayTypes fType;
-       SkOperand* fValues;     // pointer into fStorage
+    SkDisplayTypes fType;
+    SkOperand* fValues;     // pointer into fStorage
 #ifdef SK_DEBUG
-       SkOperand(* fValuesArray)[10];
+    SkOperand(* fValuesArray)[10];
 #endif
-       typedef SkInterpolatorBase INHERITED;
+    typedef SkInterpolatorBase INHERITED;
 };
 
 #endif // SkOperandInterpolator_DEFINED
index 8d9f449..7d8825e 100644 (file)
+/* libs/graphics/animator/SkOperandIterpolator.cpp
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #include "SkOperandInterpolator.h"
 #include "SkScript.h"
 
 SkOperandInterpolator::SkOperandInterpolator() {
-       INHERITED::reset(0, 0);
-       fType = SkType_Unknown;
+    INHERITED::reset(0, 0);
+    fType = SkType_Unknown;
 }
 
 SkOperandInterpolator::SkOperandInterpolator(int elemCount, int frameCount, 
-                                                                                        SkDisplayTypes type)
+                                             SkDisplayTypes type)
 {
-       this->reset(elemCount, frameCount, type);
+    this->reset(elemCount, frameCount, type);
 }
 
 void SkOperandInterpolator::reset(int elemCount, int frameCount, SkDisplayTypes type)
 {
-//     SkASSERT(type == SkType_String || type == SkType_Float || type == SkType_Int ||
-//             type == SkType_Displayable || type == SkType_Drawable);
-       INHERITED::reset(elemCount, frameCount);
-       fType = type;
-       fStorage = sk_malloc_throw((sizeof(SkOperand) * elemCount + sizeof(SkTimeCode)) * frameCount);
-       fTimes = (SkTimeCode*) fStorage;
-       fValues = (SkOperand*) ((char*) fStorage + sizeof(SkTimeCode) * frameCount);
+//  SkASSERT(type == SkType_String || type == SkType_Float || type == SkType_Int ||
+//      type == SkType_Displayable || type == SkType_Drawable);
+    INHERITED::reset(elemCount, frameCount);
+    fType = type;
+    fStorage = sk_malloc_throw((sizeof(SkOperand) * elemCount + sizeof(SkTimeCode)) * frameCount);
+    fTimes = (SkTimeCode*) fStorage;
+    fValues = (SkOperand*) ((char*) fStorage + sizeof(SkTimeCode) * frameCount);
 #ifdef SK_DEBUG
-       fTimesArray = (SkTimeCode(*)[10]) fTimes;
-       fValuesArray = (SkOperand(*)[10]) fValues;
+    fTimesArray = (SkTimeCode(*)[10]) fTimes;
+    fValuesArray = (SkOperand(*)[10]) fValues;
 #endif
 }
 
 bool SkOperandInterpolator::setKeyFrame(int index, SkMSec time, const SkOperand values[], SkScalar blend)
 {
-       SkASSERT(values != nil);
-       blend = SkScalarPin(blend, 0, SK_Scalar1);
-
-       bool success = ~index == SkTSearch<SkMSec>(&fTimes->fTime, index, time, sizeof(SkTimeCode));
-       SkASSERT(success);
-       if (success) {
-               SkTimeCode* timeCode = &fTimes[index];
-               timeCode->fTime = time;
-               timeCode->fBlend = blend;
-               SkOperand* dst = &fValues[fElemCount * index];
-               memcpy(dst, values, fElemCount * sizeof(SkOperand));
-       }
-       return success;
+    SkASSERT(values != nil);
+    blend = SkScalarPin(blend, 0, SK_Scalar1);
+
+    bool success = ~index == SkTSearch<SkMSec>(&fTimes->fTime, index, time, sizeof(SkTimeCode));
+    SkASSERT(success);
+    if (success) {
+        SkTimeCode* timeCode = &fTimes[index];
+        timeCode->fTime = time;
+        timeCode->fBlend[0] = SK_Scalar1 - blend;
+        timeCode->fBlend[1] = 0;
+        timeCode->fBlend[2] = 0;
+        timeCode->fBlend[3] = SK_Scalar1 - blend;
+        SkOperand* dst = &fValues[fElemCount * index];
+        memcpy(dst, values, fElemCount * sizeof(SkOperand));
+    }
+    return success;
 }
 
 SkInterpolatorBase::Result SkOperandInterpolator::timeToValues(SkMSec time, SkOperand values[]) const
 {
-       SkScalar T;
-       int index;
-       SkBool exact;
-       Result result = timeToT(time, &T, &index, &exact);
-       if (values)
-       {
-               const SkOperand* nextSrc = &fValues[index * fElemCount];
-
-               if (exact)
-                       memcpy(values, nextSrc, fElemCount * sizeof(SkScalar));
-               else
-               {
-                       SkASSERT(index > 0);
-
-                       const SkOperand* prevSrc = nextSrc - fElemCount;
-
-                       if (fType == SkType_Float || fType == SkType_3D_Point) {
-                               for (int i = fElemCount - 1; i >= 0; --i)
-                                       values[i].fScalar = SkScalarInterp(prevSrc[i].fScalar, nextSrc[i].fScalar, T);
-                       } else if (fType == SkType_Int || fType == SkType_MSec) {
-                               for (int i = fElemCount - 1; i >= 0; --i) {
-                                       S32 a = prevSrc[i].fS32;
-                                       S32 b = nextSrc[i].fS32;
-                                       values[i].fS32 = a + SkScalarRound((b - a) * T);
-                               }
-                       } else
-                               memcpy(values, prevSrc, sizeof(SkOperand) * fElemCount);
-               }
-       }
-       return result;
+    SkScalar T;
+    int index;
+    SkBool exact;
+    Result result = timeToT(time, &T, &index, &exact);
+    if (values)
+    {
+        const SkOperand* nextSrc = &fValues[index * fElemCount];
+
+        if (exact)
+            memcpy(values, nextSrc, fElemCount * sizeof(SkScalar));
+        else
+        {
+            SkASSERT(index > 0);
+
+            const SkOperand* prevSrc = nextSrc - fElemCount;
+
+            if (fType == SkType_Float || fType == SkType_3D_Point) {
+                for (int i = fElemCount - 1; i >= 0; --i)
+                    values[i].fScalar = SkScalarInterp(prevSrc[i].fScalar, nextSrc[i].fScalar, T);
+            } else if (fType == SkType_Int || fType == SkType_MSec) {
+                for (int i = fElemCount - 1; i >= 0; --i) {
+                    S32 a = prevSrc[i].fS32;
+                    S32 b = nextSrc[i].fS32;
+                    values[i].fS32 = a + SkScalarRound((b - a) * T);
+                }
+            } else
+                memcpy(values, prevSrc, sizeof(SkOperand) * fElemCount);
+        }
+    }
+    return result;
 }
 
 ///////////////////////////////////////////////////////////////////////////////////////
@@ -84,53 +104,53 @@ SkInterpolatorBase::Result SkOperandInterpolator::timeToValues(SkMSec time, SkOp
 #ifdef SK_DEBUG
 
 #ifdef SK_SUPPORT_UNITTEST
-       static SkOperand* iset(SkOperand array[3], int a, int b, int c)
-       {
-               array[0].fScalar = SkIntToScalar(a);
-               array[1].fScalar = SkIntToScalar(b);
-               array[2].fScalar = SkIntToScalar(c);
-               return array;
-       }
+    static SkOperand* iset(SkOperand array[3], int a, int b, int c)
+    {
+        array[0].fScalar = SkIntToScalar(a);
+        array[1].fScalar = SkIntToScalar(b);
+        array[2].fScalar = SkIntToScalar(c);
+        return array;
+    }
 #endif
 
 void SkOperandInterpolator::UnitTest()
 {
 #ifdef SK_SUPPORT_UNITTEST
-       SkOperandInterpolator   inter(3, 2, SkType_Float);
-       SkOperand               v1[3], v2[3], v[3], vv[3];
-       Result                  result;
+    SkOperandInterpolator   inter(3, 2, SkType_Float);
+    SkOperand       v1[3], v2[3], v[3], vv[3];
+    Result          result;
 
-       inter.setKeyFrame(0, 100, iset(v1, 10, 20, 30), 0);
-       inter.setKeyFrame(1, 200, iset(v2, 110, 220, 330));
+    inter.setKeyFrame(0, 100, iset(v1, 10, 20, 30), 0);
+    inter.setKeyFrame(1, 200, iset(v2, 110, 220, 330));
 
-       result = inter.timeToValues(0, v);
-       SkASSERT(result == kFreezeStart_Result);
-       SkASSERT(memcmp(v, v1, sizeof(v)) == 0);
+    result = inter.timeToValues(0, v);
+    SkASSERT(result == kFreezeStart_Result);
+    SkASSERT(memcmp(v, v1, sizeof(v)) == 0);
 
-       result = inter.timeToValues(99, v);
-       SkASSERT(result == kFreezeStart_Result);
-       SkASSERT(memcmp(v, v1, sizeof(v)) == 0);
+    result = inter.timeToValues(99, v);
+    SkASSERT(result == kFreezeStart_Result);
+    SkASSERT(memcmp(v, v1, sizeof(v)) == 0);
 
-       result = inter.timeToValues(100, v);
-       SkASSERT(result == kNormal_Result);
-       SkASSERT(memcmp(v, v1, sizeof(v)) == 0);
+    result = inter.timeToValues(100, v);
+    SkASSERT(result == kNormal_Result);
+    SkASSERT(memcmp(v, v1, sizeof(v)) == 0);
 
-       result = inter.timeToValues(200, v);
-       SkASSERT(result == kNormal_Result);
-       SkASSERT(memcmp(v, v2, sizeof(v)) == 0);
+    result = inter.timeToValues(200, v);
+    SkASSERT(result == kNormal_Result);
+    SkASSERT(memcmp(v, v2, sizeof(v)) == 0);
 
-       result = inter.timeToValues(201, v);
-       SkASSERT(result == kFreezeEnd_Result);
-       SkASSERT(memcmp(v, v2, sizeof(v)) == 0);
+    result = inter.timeToValues(201, v);
+    SkASSERT(result == kFreezeEnd_Result);
+    SkASSERT(memcmp(v, v2, sizeof(v)) == 0);
 
-       result = inter.timeToValues(150, v);
-       SkASSERT(result == kNormal_Result);
-       SkASSERT(memcmp(v, iset(vv, 60, 120, 180), sizeof(v)) == 0);
+    result = inter.timeToValues(150, v);
+    SkASSERT(result == kNormal_Result);
+    SkASSERT(memcmp(v, iset(vv, 60, 120, 180), sizeof(v)) == 0);
 
-       result = inter.timeToValues(125, v);
-       SkASSERT(result == kNormal_Result);
-       result = inter.timeToValues(175, v);
-       SkASSERT(result == kNormal_Result);
+    result = inter.timeToValues(125, v);
+    SkASSERT(result == kNormal_Result);
+    result = inter.timeToValues(175, v);
+    SkASSERT(result == kNormal_Result);
 #endif
 }
 
index b45a125..80e00d8 100644 (file)
@@ -1,3 +1,20 @@
+/* libs/graphics/animator/SkPaintParts.cpp
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #include "SkPaintParts.h"
 #include "SkDrawPaint.h"
 #ifdef SK_DUMP_ENABLED
@@ -9,53 +26,53 @@ SkPaintPart::SkPaintPart() : fPaint(nil) {
 }
 
 SkDisplayable* SkPaintPart::getParent() const {
-       return fPaint;
+    return fPaint;
 }
 
 bool SkPaintPart::setParent(SkDisplayable* parent) {
-       SkASSERT(parent != nil);
-       if (parent->isPaint() == false)
-               return true;
-       fPaint = (SkDrawPaint*) parent;
-       return false;
+    SkASSERT(parent != nil);
+    if (parent->isPaint() == false)
+        return true;
+    fPaint = (SkDrawPaint*) parent;
+    return false;
 }
 
 
 // SkDrawMaskFilter
 bool SkDrawMaskFilter::add() {
-       if (fPaint->maskFilter != (SkDrawMaskFilter*) -1)
-               return true;
-       fPaint->maskFilter = this;
-       fPaint->fOwnsMaskFilter = true;
-       return false;
+    if (fPaint->maskFilter != (SkDrawMaskFilter*) -1)
+        return true;
+    fPaint->maskFilter = this;
+    fPaint->fOwnsMaskFilter = true;
+    return false;
 }
 
 SkMaskFilter* SkDrawMaskFilter::getMaskFilter() {
-       return nil;
+    return nil;
 }
 
 
 // SkDrawPathEffect
 bool SkDrawPathEffect::add() {
-       if (fPaint->isPaint()) {
-               if (fPaint->pathEffect != (SkDrawPathEffect*) -1)
-                       return true;
-               fPaint->pathEffect = this;
-               fPaint->fOwnsPathEffect = true;
-               return false;
-       }
-       fPaint->add(*(SkAnimateMaker*) nil, this);
-       return false;
+    if (fPaint->isPaint()) {
+        if (fPaint->pathEffect != (SkDrawPathEffect*) -1)
+            return true;
+        fPaint->pathEffect = this;
+        fPaint->fOwnsPathEffect = true;
+        return false;
+    }
+    fPaint->add(*(SkAnimateMaker*) nil, this);
+    return false;
 }
 
 SkPathEffect* SkDrawPathEffect::getPathEffect() {
-       return nil;
+    return nil;
 }
 
 
 // SkDrawShader
 SkShader* SkDrawShader::getShader() {
-       return nil;
+    return nil;
 }
 
 
@@ -63,7 +80,7 @@ SkShader* SkDrawShader::getShader() {
 #if SK_USE_CONDENSED_INFO == 0
 
 const SkMemberInfo SkDrawTypeface::fInfo[] = {
-       SK_MEMBER(fontName, String),
+    SK_MEMBER(fontName, String),
     SK_MEMBER(style, FontStyle)
 };
 
@@ -75,11 +92,11 @@ SkDrawTypeface::SkDrawTypeface() : style (SkTypeface::kNormal){
 }
 
 bool SkDrawTypeface::add() {
-       if (fPaint->typeface != (SkDrawTypeface*) -1)
-               return true;
-       fPaint->typeface = this;
-       fPaint->fOwnsTypeface = true;
-       return false;
+    if (fPaint->typeface != (SkDrawTypeface*) -1)
+        return true;
+    fPaint->typeface = this;
+    fPaint->fOwnsTypeface = true;
+    return false;
 }
 
 #ifdef SK_DUMP_ENABLED
index c0f84da..615a028 100644 (file)
@@ -1,3 +1,20 @@
+/* libs/graphics/animator/SkPaintParts.h
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #ifndef SkPaintParts_DEFINED
 #define SkPaintParts_DEFINED
 
@@ -13,53 +30,53 @@ class SkDrawMatrix;
 
 class SkPaintPart : public SkDisplayable {
 public:
-       SkPaintPart();
-       virtual bool add() = 0;
-       virtual SkDisplayable* getParent() const;
-       virtual bool setParent(SkDisplayable* parent);
+    SkPaintPart();
+    virtual bool add() = 0;
+    virtual SkDisplayable* getParent() const;
+    virtual bool setParent(SkDisplayable* parent);
 #ifdef SK_DEBUG
-       virtual bool isPaintPart() const { return true; }
+    virtual bool isPaintPart() const { return true; }
 #endif
 protected:
-       SkDrawPaint* fPaint;
+    SkDrawPaint* fPaint;
 };
 
 class SkDrawMaskFilter : public SkPaintPart {
-       DECLARE_EMPTY_MEMBER_INFO(MaskFilter);
-       virtual SkMaskFilter* getMaskFilter();
+    DECLARE_EMPTY_MEMBER_INFO(MaskFilter);
+    virtual SkMaskFilter* getMaskFilter();
 protected:
-       virtual bool add();
+    virtual bool add();
 };
 
 class SkDrawPathEffect : public SkPaintPart {
-       DECLARE_EMPTY_MEMBER_INFO(PathEffect);
-       virtual SkPathEffect* getPathEffect();
+    DECLARE_EMPTY_MEMBER_INFO(PathEffect);
+    virtual SkPathEffect* getPathEffect();
 protected:
-       virtual bool add();
+    virtual bool add();
 };
 
 class SkDrawShader : public SkPaintPart {
-       DECLARE_DRAW_MEMBER_INFO(Shader);
-       SkDrawShader();
-       virtual SkShader* getShader();
+    DECLARE_DRAW_MEMBER_INFO(Shader);
+    SkDrawShader();
+    virtual SkShader* getShader();
 protected:
-       virtual bool add();
-       void addPostlude(SkShader* shader);
-       SkDrawMatrix* matrix;
-       int /*SkShader::TileMode*/ tileMode;
+    virtual bool add();
+    void addPostlude(SkShader* shader);
+    SkDrawMatrix* matrix;
+    int /*SkShader::TileMode*/ tileMode;
 };
 
 class SkDrawTypeface  : public SkPaintPart {
-       DECLARE_DRAW_MEMBER_INFO(Typeface);
-       SkDrawTypeface();
+    DECLARE_DRAW_MEMBER_INFO(Typeface);
+    SkDrawTypeface();
 #ifdef SK_DUMP_ENABLED
     virtual void dump(SkAnimateMaker *);
 #endif
-       SkTypeface* getTypeface() {
-               return SkTypeface::Create(fontName.c_str(), style); }
+    SkTypeface* getTypeface() {
+        return SkTypeface::Create(fontName.c_str(), style); }
 protected:
-       virtual bool add();
-       SkString fontName;
+    virtual bool add();
+    SkString fontName;
     SkTypeface::Style style;
 };
 
index 537a32d..64d3c95 100644 (file)
@@ -1,3 +1,20 @@
+/* libs/graphics/animator/SkPathParts.cpp
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #include "SkPathParts.h"
 #include "SkAnimateMaker.h"
 #include "SkDrawMatrix.h"
@@ -8,27 +25,27 @@ SkPathPart::SkPathPart() : fPath(nil) {
 }
 
 void SkPathPart::dirty() { 
-       fPath->dirty(); 
+    fPath->dirty(); 
 }
 
 SkDisplayable* SkPathPart::getParent() const {
-       return fPath;
+    return fPath;
 }
 
 bool SkPathPart::setParent(SkDisplayable* parent) {
-       SkASSERT(parent != nil);
-       if (parent->isPath() == false)
-               return true;
-       fPath = (SkDrawPath*) parent;
-       return false;
+    SkASSERT(parent != nil);
+    if (parent->isPath() == false)
+        return true;
+    fPath = (SkDrawPath*) parent;
+    return false;
 }
 
 // MoveTo
 #if SK_USE_CONDENSED_INFO == 0
 
 const SkMemberInfo SkMoveTo::fInfo[] = {
-       SK_MEMBER(x, Float),
-       SK_MEMBER(y, Float)
+    SK_MEMBER(x, Float),
+    SK_MEMBER(y, Float)
 };
 
 #endif
@@ -39,8 +56,8 @@ SkMoveTo::SkMoveTo() : x(0), y(0) {
 }
 
 bool SkMoveTo::add() {
-       fPath->fPath.moveTo(x, y);
-       return false;
+    fPath->fPath.moveTo(x, y);
+    return false;
 }
 
 
@@ -48,7 +65,7 @@ bool SkMoveTo::add() {
 #if SK_USE_CONDENSED_INFO == 0
 
 const SkMemberInfo SkRMoveTo::fInfo[] = {
-       SK_MEMBER_INHERITED
+    SK_MEMBER_INHERITED
 };
 
 #endif
@@ -56,8 +73,8 @@ const SkMemberInfo SkRMoveTo::fInfo[] = {
 DEFINE_GET_MEMBER(SkRMoveTo);
 
 bool SkRMoveTo::add() {
-       fPath->fPath.rMoveTo(x, y);
-       return false;
+    fPath->fPath.rMoveTo(x, y);
+    return false;
 }
 
 
@@ -65,8 +82,8 @@ bool SkRMoveTo::add() {
 #if SK_USE_CONDENSED_INFO == 0
 
 const SkMemberInfo SkLineTo::fInfo[] = {
-       SK_MEMBER(x, Float),
-       SK_MEMBER(y, Float)
+    SK_MEMBER(x, Float),
+    SK_MEMBER(y, Float)
 };
 
 #endif
@@ -77,8 +94,8 @@ SkLineTo::SkLineTo() : x(0), y(0) {
 }
 
 bool SkLineTo::add() {
-       fPath->fPath.lineTo(x, y);      
-       return false;
+    fPath->fPath.lineTo(x, y);  
+    return false;
 }
 
 
@@ -86,7 +103,7 @@ bool SkLineTo::add() {
 #if SK_USE_CONDENSED_INFO == 0
 
 const SkMemberInfo SkRLineTo::fInfo[] = {
-       SK_MEMBER_INHERITED
+    SK_MEMBER_INHERITED
 };
 
 #endif
@@ -94,8 +111,8 @@ const SkMemberInfo SkRLineTo::fInfo[] = {
 DEFINE_GET_MEMBER(SkRLineTo);
 
 bool SkRLineTo::add() {
-       fPath->fPath.rLineTo(x, y);     
-       return false;
+    fPath->fPath.rLineTo(x, y); 
+    return false;
 }
 
 
@@ -103,10 +120,10 @@ bool SkRLineTo::add() {
 #if SK_USE_CONDENSED_INFO == 0
 
 const SkMemberInfo SkQuadTo::fInfo[] = {
-       SK_MEMBER(x1, Float),
-       SK_MEMBER(x2, Float),
-       SK_MEMBER(y1, Float),
-       SK_MEMBER(y2, Float)
+    SK_MEMBER(x1, Float),
+    SK_MEMBER(x2, Float),
+    SK_MEMBER(y1, Float),
+    SK_MEMBER(y2, Float)
 };
 
 #endif
@@ -117,8 +134,8 @@ SkQuadTo::SkQuadTo() : x1(0), y1(0), x2(0), y2(0) {
 }
 
 bool SkQuadTo::add() {
-       fPath->fPath.quadTo(x1, y1, x2, y2);
-       return false;
+    fPath->fPath.quadTo(x1, y1, x2, y2);
+    return false;
 }
 
 
@@ -126,7 +143,7 @@ bool SkQuadTo::add() {
 #if SK_USE_CONDENSED_INFO == 0
 
 const SkMemberInfo SkRQuadTo::fInfo[] = {
-       SK_MEMBER_INHERITED
+    SK_MEMBER_INHERITED
 };
 
 #endif
@@ -134,8 +151,8 @@ const SkMemberInfo SkRQuadTo::fInfo[] = {
 DEFINE_GET_MEMBER(SkRQuadTo);
 
 bool SkRQuadTo::add() {
-       fPath->fPath.rQuadTo(x1, y1, x2, y2);
-       return false;
+    fPath->fPath.rQuadTo(x1, y1, x2, y2);
+    return false;
 }
 
 
@@ -143,12 +160,12 @@ bool SkRQuadTo::add() {
 #if SK_USE_CONDENSED_INFO == 0
 
 const SkMemberInfo SkCubicTo::fInfo[] = {
-       SK_MEMBER(x1, Float),
-       SK_MEMBER(x2, Float),
-       SK_MEMBER(x3, Float),
-       SK_MEMBER(y1, Float),
-       SK_MEMBER(y2, Float),
-       SK_MEMBER(y3, Float)
+    SK_MEMBER(x1, Float),
+    SK_MEMBER(x2, Float),
+    SK_MEMBER(x3, Float),
+    SK_MEMBER(y1, Float),
+    SK_MEMBER(y2, Float),
+    SK_MEMBER(y3, Float)
 };
 
 #endif
@@ -159,8 +176,8 @@ SkCubicTo::SkCubicTo() : x1(0), y1(0), x2(0), y2(0), x3(0), y3(0) {
 }
 
 bool SkCubicTo::add() {
-       fPath->fPath.cubicTo(x1, y1, x2, y2, x3, y3);
-       return false;
+    fPath->fPath.cubicTo(x1, y1, x2, y2, x3, y3);
+    return false;
 }
 
 
@@ -168,7 +185,7 @@ bool SkCubicTo::add() {
 #if SK_USE_CONDENSED_INFO == 0
 
 const SkMemberInfo SkRCubicTo::fInfo[] = {
-       SK_MEMBER_INHERITED
+    SK_MEMBER_INHERITED
 };
 
 #endif
@@ -176,15 +193,15 @@ const SkMemberInfo SkRCubicTo::fInfo[] = {
 DEFINE_GET_MEMBER(SkRCubicTo);
 
 bool SkRCubicTo::add() {
-       fPath->fPath.rCubicTo(x1, y1, x2, y2, x3, y3);
-       return false;
+    fPath->fPath.rCubicTo(x1, y1, x2, y2, x3, y3);
+    return false;
 }
 
 
 // SkClose
 bool SkClose::add() {
-       fPath->fPath.close();
-       return false;
+    fPath->fPath.close();
+    return false;
 }
 
 
@@ -192,7 +209,7 @@ bool SkClose::add() {
 #if SK_USE_CONDENSED_INFO == 0
 
 const SkMemberInfo SkAddGeom::fInfo[] = {
-       SK_MEMBER(direction, PathDirection)
+    SK_MEMBER(direction, PathDirection)
 };
 
 #endif
@@ -205,11 +222,11 @@ SkAddGeom::SkAddGeom() : direction(SkPath::kCCW_Direction) {
 #if SK_USE_CONDENSED_INFO == 0
 
 const SkMemberInfo SkAddRect::fInfo[] = {
-       SK_MEMBER_INHERITED,
-       SK_MEMBER_ALIAS(bottom, fRect.fBottom, Float),
-       SK_MEMBER_ALIAS(left, fRect.fLeft, Float),
-       SK_MEMBER_ALIAS(right, fRect.fRight, Float),
-       SK_MEMBER_ALIAS(top, fRect.fTop, Float)
+    SK_MEMBER_INHERITED,
+    SK_MEMBER_ALIAS(bottom, fRect.fBottom, Float),
+    SK_MEMBER_ALIAS(left, fRect.fLeft, Float),
+    SK_MEMBER_ALIAS(right, fRect.fRight, Float),
+    SK_MEMBER_ALIAS(top, fRect.fTop, Float)
 };
 
 #endif
@@ -217,19 +234,19 @@ const SkMemberInfo SkAddRect::fInfo[] = {
 DEFINE_GET_MEMBER(SkAddRect);
 
 SkAddRect::SkAddRect() { 
-       fRect.setEmpty(); 
+    fRect.setEmpty(); 
 }
 
 bool SkAddRect::add() {
-       fPath->fPath.addRect(fRect, (SkPath::Direction) direction);
-       return false;
+    fPath->fPath.addRect(fRect, (SkPath::Direction) direction);
+    return false;
 }
 
 
 #if SK_USE_CONDENSED_INFO == 0
 
 const SkMemberInfo SkAddOval::fInfo[] = {
-       SK_MEMBER_INHERITED
+    SK_MEMBER_INHERITED
 };
 
 #endif
@@ -237,18 +254,18 @@ const SkMemberInfo SkAddOval::fInfo[] = {
 DEFINE_GET_MEMBER(SkAddOval);
 
 bool SkAddOval::add() {
-       fPath->fPath.addOval(fRect,  (SkPath::Direction) direction);
-       return false;
+    fPath->fPath.addOval(fRect,  (SkPath::Direction) direction);
+    return false;
 }
 
 
 #if SK_USE_CONDENSED_INFO == 0
 
 const SkMemberInfo SkAddCircle::fInfo[] = {
-       SK_MEMBER_INHERITED,
-       SK_MEMBER(radius, Float),
-       SK_MEMBER(x, Float),
-       SK_MEMBER(y, Float)
+    SK_MEMBER_INHERITED,
+    SK_MEMBER(radius, Float),
+    SK_MEMBER(x, Float),
+    SK_MEMBER(y, Float)
 };
 
 #endif
@@ -259,17 +276,17 @@ SkAddCircle::SkAddCircle() : radius(0), x(0), y(0) {
 }
 
 bool SkAddCircle::add() {
-       fPath->fPath.addCircle(x, y, radius,  (SkPath::Direction) direction);
-       return false;
+    fPath->fPath.addCircle(x, y, radius,  (SkPath::Direction) direction);
+    return false;
 }
 
 
 #if SK_USE_CONDENSED_INFO == 0
 
 const SkMemberInfo SkAddRoundRect::fInfo[] = {
-       SK_MEMBER_INHERITED,
-       SK_MEMBER(rx, Float),
-       SK_MEMBER(ry, Float)
+    SK_MEMBER_INHERITED,
+    SK_MEMBER(rx, Float),
+    SK_MEMBER(ry, Float)
 };
 
 #endif
@@ -280,16 +297,16 @@ SkAddRoundRect::SkAddRoundRect() : rx(0), ry(0) {
 }
 
 bool SkAddRoundRect::add() {
-       fPath->fPath.addRoundRect(fRect, rx, ry,  (SkPath::Direction) direction);
-       return false;
+    fPath->fPath.addRoundRect(fRect, rx, ry,  (SkPath::Direction) direction);
+    return false;
 }
 
 
 #if SK_USE_CONDENSED_INFO == 0
 
 const SkMemberInfo SkAddPath::fInfo[] = {
-       SK_MEMBER(matrix, Matrix),
-       SK_MEMBER(path, Path)
+    SK_MEMBER(matrix, Matrix),
+    SK_MEMBER(path, Path)
 };
 
 #endif
@@ -300,12 +317,12 @@ SkAddPath::SkAddPath() : matrix(nil), path(nil) {
 }
 
 bool SkAddPath::add() {
-       SkASSERT (path != nil); 
-       if (matrix)
-               fPath->fPath.addPath(path->fPath, matrix->getMatrix());
-       else
-               fPath->fPath.addPath(path->fPath);
-       return false;
+    SkASSERT (path != nil); 
+    if (matrix)
+        fPath->fPath.addPath(path->fPath, matrix->getMatrix());
+    else
+        fPath->fPath.addPath(path->fPath);
+    return false;
 }
 
 
index ed78c92..4af0295 100644 (file)
@@ -1,3 +1,20 @@
+/* libs/graphics/animator/SkPathParts.h
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #ifndef SkPathParts_DEFINED
 #define SkPathParts_DEFINED
 
@@ -10,146 +27,146 @@ class SkDrawMatrix;
 
 class SkPathPart : public SkDisplayable {
 public:
-       SkPathPart();
-       virtual bool add() = 0;
-       virtual void dirty();
-       virtual SkDisplayable* getParent() const;
-       virtual bool setParent(SkDisplayable* parent);
+    SkPathPart();
+    virtual bool add() = 0;
+    virtual void dirty();
+    virtual SkDisplayable* getParent() const;
+    virtual bool setParent(SkDisplayable* parent);
 #ifdef SK_DEBUG
-       virtual bool isPathPart() const { return true; }
+    virtual bool isPathPart() const { return true; }
 #endif
 protected:
-       SkDrawPath* fPath;
+    SkDrawPath* fPath;
 };
 
 class SkMoveTo : public SkPathPart {
-       DECLARE_MEMBER_INFO(MoveTo);
-       SkMoveTo();
-       virtual bool add();
+    DECLARE_MEMBER_INFO(MoveTo);
+    SkMoveTo();
+    virtual bool add();
 protected:
-       SkScalar x;
-       SkScalar y;
+    SkScalar x;
+    SkScalar y;
 };
 
 class SkRMoveTo : public SkMoveTo {
-       DECLARE_MEMBER_INFO(RMoveTo);
-       virtual bool add();
+    DECLARE_MEMBER_INFO(RMoveTo);
+    virtual bool add();
 private:
-       typedef SkMoveTo INHERITED;
+    typedef SkMoveTo INHERITED;
 };
 
 class SkLineTo : public SkPathPart {
-       DECLARE_MEMBER_INFO(LineTo);
-       SkLineTo();
-       virtual bool add();
+    DECLARE_MEMBER_INFO(LineTo);
+    SkLineTo();
+    virtual bool add();
 protected:
-       SkScalar x;
-       SkScalar y;
+    SkScalar x;
+    SkScalar y;
 };
 
 class SkRLineTo : public SkLineTo {
-       DECLARE_MEMBER_INFO(RLineTo);
-       virtual bool add();
+    DECLARE_MEMBER_INFO(RLineTo);
+    virtual bool add();
 private:
-       typedef SkLineTo INHERITED;
+    typedef SkLineTo INHERITED;
 };
 
 class SkQuadTo : public SkPathPart {
-       DECLARE_MEMBER_INFO(QuadTo);
-       SkQuadTo();
-       virtual bool add();
+    DECLARE_MEMBER_INFO(QuadTo);
+    SkQuadTo();
+    virtual bool add();
 protected:
-       SkScalar x1;
-       SkScalar y1;
-       SkScalar x2;
-       SkScalar y2;
+    SkScalar x1;
+    SkScalar y1;
+    SkScalar x2;
+    SkScalar y2;
 };
 
 class SkRQuadTo : public SkQuadTo {
-       DECLARE_MEMBER_INFO(RQuadTo);
-       virtual bool add();
+    DECLARE_MEMBER_INFO(RQuadTo);
+    virtual bool add();
 private:
-       typedef SkQuadTo INHERITED;
+    typedef SkQuadTo INHERITED;
 };
 
 class SkCubicTo : public SkPathPart {
-       DECLARE_MEMBER_INFO(CubicTo);
-       SkCubicTo();
-       virtual bool add();
+    DECLARE_MEMBER_INFO(CubicTo);
+    SkCubicTo();
+    virtual bool add();
 protected:
-       SkScalar x1;
-       SkScalar y1;
-       SkScalar x2;
-       SkScalar y2;
-       SkScalar x3;
-       SkScalar y3;
+    SkScalar x1;
+    SkScalar y1;
+    SkScalar x2;
+    SkScalar y2;
+    SkScalar x3;
+    SkScalar y3;
 };
 
 class SkRCubicTo : public SkCubicTo {
-       DECLARE_MEMBER_INFO(RCubicTo);
-       virtual bool add();
+    DECLARE_MEMBER_INFO(RCubicTo);
+    virtual bool add();
 private:
-       typedef SkCubicTo INHERITED;
+    typedef SkCubicTo INHERITED;
 };
 
 class SkClose : public SkPathPart {
-       DECLARE_EMPTY_MEMBER_INFO(Close);
-       virtual bool add();
+    DECLARE_EMPTY_MEMBER_INFO(Close);
+    virtual bool add();
 };
 
 class SkAddGeom : public SkPathPart {
-       DECLARE_PRIVATE_MEMBER_INFO(AddGeom);
-       SkAddGeom();
+    DECLARE_PRIVATE_MEMBER_INFO(AddGeom);
+    SkAddGeom();
 protected:
-       int /*SkPath::Direction*/ direction;
+    int /*SkPath::Direction*/ direction;
 };
 
 class SkAddRect : public SkAddGeom {
-       DECLARE_MEMBER_INFO(AddRect);
-       SkAddRect();
-       virtual bool add();
+    DECLARE_MEMBER_INFO(AddRect);
+    SkAddRect();
+    virtual bool add();
 protected:
-       SkRect fRect;
+    SkRect fRect;
 private:
-       typedef SkAddGeom INHERITED;
+    typedef SkAddGeom INHERITED;
 };
 
 class SkAddOval : public SkAddRect {
-       DECLARE_MEMBER_INFO(AddOval);
-       virtual bool add();
+    DECLARE_MEMBER_INFO(AddOval);
+    virtual bool add();
 private:
-       typedef SkAddRect INHERITED;
+    typedef SkAddRect INHERITED;
 };
 
 class SkAddCircle : public SkAddGeom {
-       DECLARE_MEMBER_INFO(AddCircle);
-       SkAddCircle();
-       virtual bool add();
+    DECLARE_MEMBER_INFO(AddCircle);
+    SkAddCircle();
+    virtual bool add();
 private:
-       SkScalar radius;
-       SkScalar x;
-       SkScalar y;
-       typedef SkAddGeom INHERITED;
+    SkScalar radius;
+    SkScalar x;
+    SkScalar y;
+    typedef SkAddGeom INHERITED;
 };
 
 class SkAddRoundRect : public SkAddRect {
-       DECLARE_MEMBER_INFO(AddRoundRect);
-       SkAddRoundRect();
-       virtual bool add();
+    DECLARE_MEMBER_INFO(AddRoundRect);
+    SkAddRoundRect();
+    virtual bool add();
 private:
-       SkScalar rx;
-       SkScalar ry;
-       typedef SkAddRect INHERITED;
+    SkScalar rx;
+    SkScalar ry;
+    typedef SkAddRect INHERITED;
 };
 
 class SkAddPath : public SkPathPart {
-       DECLARE_MEMBER_INFO(AddPath);
-       SkAddPath();
-       virtual bool add();
+    DECLARE_MEMBER_INFO(AddPath);
+    SkAddPath();
+    virtual bool add();
 private:
-       typedef SkPathPart INHERITED;
-       SkDrawMatrix* matrix;
-       SkDrawPath* path;
+    typedef SkPathPart INHERITED;
+    SkDrawMatrix* matrix;
+    SkDrawPath* path;
 };
 
 #endif // SkPathParts_DEFINED
index 3782e47..830b88b 100644 (file)
@@ -1,10 +1,27 @@
+/* libs/graphics/animator/SkPostParts.cpp
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #include "SkPostParts.h"
 #include "SkDisplayPost.h"
 
 #if SK_USE_CONDENSED_INFO == 0
 
 const SkMemberInfo SkData::fInfo[] = {
-       SK_MEMBER_INHERITED
+    SK_MEMBER_INHERITED
 };
 
 #endif
@@ -14,35 +31,35 @@ DEFINE_GET_MEMBER(SkData);
 SkData::SkData() : fParent(nil) {}
 
 bool SkData::add() {
-       SkASSERT(name.size() > 0);
-       const char* dataName = name.c_str();
-       if (fInt != (int) SK_NaN32)
-               fParent->fEvent.setS32(dataName, fInt);
-       else if (SkScalarIsNaN(fFloat) == false)
-               fParent->fEvent.setScalar(dataName, fFloat);
-       else if (string.size() > 0) 
-               fParent->fEvent.setString(dataName, string);
-//     else
-//             SkASSERT(0);
-       return false;
+    SkASSERT(name.size() > 0);
+    const char* dataName = name.c_str();
+    if (fInt != (int) SK_NaN32)
+        fParent->fEvent.setS32(dataName, fInt);
+    else if (SkScalarIsNaN(fFloat) == false)
+        fParent->fEvent.setScalar(dataName, fFloat);
+    else if (string.size() > 0) 
+        fParent->fEvent.setString(dataName, string);
+//  else
+//      SkASSERT(0);
+    return false;
 }
 
 void SkData::dirty() {
-       fParent->dirty();
+    fParent->dirty();
 }
 
 SkDisplayable* SkData::getParent() const {
-       return fParent;
+    return fParent;
 }
 
 bool SkData::setParent(SkDisplayable* displayable) {
-       if (displayable->isPost() == false)
-               return true;
-       fParent = (SkPost*) displayable;
-       return false;
+    if (displayable->isPost() == false)
+        return true;
+    fParent = (SkPost*) displayable;
+    return false;
 }
 
 void SkData::onEndElement(SkAnimateMaker&) {
-       add();
+    add();
 }
 
index 4aca6c0..f02b4b0 100644 (file)
@@ -1,3 +1,20 @@
+/* libs/graphics/animator/SkPostParts.h
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #ifndef SkPostParts_DEFINED
 #define SkPostParts_DEFINED
 
 class SkPost;
 
 class SkData: public SkInput {
-       DECLARE_MEMBER_INFO(Data);
-       SkData();
-       bool add();
-       virtual void dirty();
-       virtual SkDisplayable* getParent() const;
-       virtual void onEndElement(SkAnimateMaker& );
-       virtual bool setParent(SkDisplayable* );
+    DECLARE_MEMBER_INFO(Data);
+    SkData();
+    bool add();
+    virtual void dirty();
+    virtual SkDisplayable* getParent() const;
+    virtual void onEndElement(SkAnimateMaker& );
+    virtual bool setParent(SkDisplayable* );
 protected:
-       SkPost* fParent;
-       typedef SkInput INHERITED;
-       friend class SkPost;
+    SkPost* fParent;
+    typedef SkInput INHERITED;
+    friend class SkPost;
 };
 
 #endif // SkPostParts_DEFINED
index e3c4083..04c12e9 100644 (file)
@@ -1,3 +1,20 @@
+/* libs/graphics/animator/SkSVGPath.cpp
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #include <ctype.h>
 #include "SkDrawPath.h"
 #include "SkParse.h"
 ////////////////////////////////////////////////////////////////////////////////////
 //functions to approximate a cubic using two quadratics
 
-//             midPt sets the first argument to be the midpoint of the other two
-//             it is used by quadApprox
+//      midPt sets the first argument to be the midpoint of the other two
+//      it is used by quadApprox
 static inline void midPt(SkPoint& dest,const SkPoint& a,const SkPoint& b)
 {
-       dest.set(SkScalarAve(a.fX, b.fX),SkScalarAve(a.fY, b.fY));
+    dest.set(SkScalarAve(a.fX, b.fX),SkScalarAve(a.fY, b.fY));
 }
-//             quadApprox - makes an approximation, which we hope is faster
+//      quadApprox - makes an approximation, which we hope is faster
 static void quadApprox(SkPath &fPath, const SkPoint &p0, const SkPoint &p1, const SkPoint &p2)
 {
-       //divide the cubic up into two cubics, then convert them into quadratics
-       //define our points
-       SkPoint c,j,k,l,m,n,o,p,q, mid;
-       fPath.getLastPt(&c);
-       midPt(j, p0, c);
-       midPt(k, p0, p1);
-       midPt(l, p1, p2);
-       midPt(o, j, k);
-       midPt(p, k, l);
-       midPt(q, o, p);
-       //compute the first half
-       m.set(SkScalarHalf(3*j.fX - c.fX), SkScalarHalf(3*j.fY - c.fY));
-       n.set(SkScalarHalf(3*o.fX -q.fX), SkScalarHalf(3*o.fY - q.fY));
-       midPt(mid,m,n);
-       fPath.quadTo(mid,q);
-       c = q;
-       //compute the second half
-       m.set(SkScalarHalf(3*p.fX - c.fX), SkScalarHalf(3*p.fY - c.fY));
-       n.set(SkScalarHalf(3*l.fX -p2.fX),SkScalarHalf(3*l.fY -p2.fY));
-       midPt(mid,m,n);
-       fPath.quadTo(mid,p2);
+    //divide the cubic up into two cubics, then convert them into quadratics
+    //define our points
+    SkPoint c,j,k,l,m,n,o,p,q, mid;
+    fPath.getLastPt(&c);
+    midPt(j, p0, c);
+    midPt(k, p0, p1);
+    midPt(l, p1, p2);
+    midPt(o, j, k);
+    midPt(p, k, l);
+    midPt(q, o, p);
+    //compute the first half
+    m.set(SkScalarHalf(3*j.fX - c.fX), SkScalarHalf(3*j.fY - c.fY));
+    n.set(SkScalarHalf(3*o.fX -q.fX), SkScalarHalf(3*o.fY - q.fY));
+    midPt(mid,m,n);
+    fPath.quadTo(mid,q);
+    c = q;
+    //compute the second half
+    m.set(SkScalarHalf(3*p.fX - c.fX), SkScalarHalf(3*p.fY - c.fY));
+    n.set(SkScalarHalf(3*l.fX -p2.fX),SkScalarHalf(3*l.fY -p2.fY));
+    midPt(mid,m,n);
+    fPath.quadTo(mid,p2);
 }
 #endif
 
 
 static inline bool is_between(int c, int min, int max)
 {
-       return (unsigned)(c - min) <= (unsigned)(max - min);
+    return (unsigned)(c - min) <= (unsigned)(max - min);
 }
 
 static inline bool is_ws(int c)
 {
-       return is_between(c, 1, 32);
+    return is_between(c, 1, 32);
 }
 
 static inline bool is_digit(int c)
 {
-       return is_between(c, '0', '9');
+    return is_between(c, '0', '9');
 }
 
 static inline bool is_sep(int c)
 {
-       return is_ws(c) || c == ',';
+    return is_ws(c) || c == ',';
 }
 
 static const char* skip_ws(const char str[])
 {
-       SkASSERT(str);
-       while (is_ws(*str))
-               str++;
-       return str;
+    SkASSERT(str);
+    while (is_ws(*str))
+        str++;
+    return str;
 }
 
 static const char* skip_sep(const char str[])
 {
-       SkASSERT(str);
-       while (is_sep(*str))
-               str++;
-       return str;
+    SkASSERT(str);
+    while (is_sep(*str))
+        str++;
+    return str;
 }
 
 static const char* find_points(const char str[], SkPoint value[], int count,
-        bool isRelative, SkPoint* relative)
+     bool isRelative, SkPoint* relative)
 {
-       str = SkParse::FindScalars(str, &value[0].fX, count * 2);
-       if (isRelative) {
-               for (int index = 0; index < count; index++) {
-                       value[index].fX += relative->fX;
-                       value[index].fY += relative->fY;
-               }
-       }
-       return str;
+    str = SkParse::FindScalars(str, &value[0].fX, count * 2);
+    if (isRelative) {
+        for (int index = 0; index < count; index++) {
+            value[index].fX += relative->fX;
+            value[index].fY += relative->fY;
+        }
+    }
+    return str;
 }
 
 static const char* find_scalar(const char str[], SkScalar* value, 
-       bool isRelative, SkScalar relative)
+    bool isRelative, SkScalar relative)
 {
-       str = SkParse::FindScalar(str, value);
-       if (isRelative)
-               *value += relative;
-       return str;
+    str = SkParse::FindScalar(str, value);
+    if (isRelative)
+        *value += relative;
+    return str;
 }
 
 void SkDrawPath::parseSVG() {
     fPath.reset();
-       const char* data = d.c_str();
-       SkPoint f = {0, 0};
-       SkPoint c = {0, 0};
-       SkPoint lastc = {0, 0};
-       SkPoint points[3];
-       char op = '\0';
-       char previousOp = '\0';
-       bool relative = false;
-       do {
-               data = skip_ws(data);
-               if (data[0] == '\0')
-                       break;
-               char ch = data[0];
-               if (is_digit(ch) || ch == '-' || ch == '+') {
-                       if (op == '\0')
-                               return;
-               }
-               else {
-                       op = ch;
-                       relative = false;
-                       if (islower(op)) {
-                               op = (char) toupper(op);
-                               relative = true;
-                       }
-                       data++;
-                       data = skip_sep(data);
-               }
-               switch (op) {
-                       case 'M':
-                               data = find_points(data, points, 1, relative, &c);
-                               fPath.moveTo(points[0]);
-                               op = 'L';
-                               c = points[0];
-                               break;
-                       case 'L': 
-                               data = find_points(data, points, 1, relative, &c);
-                               fPath.lineTo(points[0]);
-                               c = points[0];
-                               break;
-                       case 'H': {
-                               SkScalar x;
-                               data = find_scalar(data, &x, relative, c.fX);
-                               fPath.lineTo(x, c.fY);
-                               c.fX = x;
-                       }
-                               break;
-                       case 'V': {
-                               SkScalar y;
-                               data = find_scalar(data, &y, relative, c.fY);
-                               fPath.lineTo(c.fX, y);
-                               c.fY = y;
-                       }
-                               break;
-                       case 'C': 
-                               data = find_points(data, points, 3, relative, &c);
-                               goto cubicCommon;
-                       case 'S': 
-                               data = find_points(data, &points[1], 2, relative, &c);
-                               points[0] = c;
-                               if (previousOp == 'C' || previousOp == 'S') {
-                                       points[0].fX -= lastc.fX - c.fX;
-                                       points[0].fY -= lastc.fY - c.fY;
-                               }
-                       cubicCommon:
-       //                      if (data[0] == '\0')
-       //                              return;
+    const char* data = d.c_str();
+    SkPoint f = {0, 0};
+    SkPoint c = {0, 0};
+    SkPoint lastc = {0, 0};
+    SkPoint points[3];
+    char op = '\0';
+    char previousOp = '\0';
+    bool relative = false;
+    do {
+        data = skip_ws(data);
+        if (data[0] == '\0')
+            break;
+        char ch = data[0];
+        if (is_digit(ch) || ch == '-' || ch == '+') {
+            if (op == '\0')
+                return;
+        }
+        else {
+            op = ch;
+            relative = false;
+            if (islower(op)) {
+                op = (char) toupper(op);
+                relative = true;
+            }
+            data++;
+            data = skip_sep(data);
+        }
+        switch (op) {
+            case 'M':
+                data = find_points(data, points, 1, relative, &c);
+                fPath.moveTo(points[0]);
+                op = 'L';
+                c = points[0];
+                break;
+            case 'L': 
+                data = find_points(data, points, 1, relative, &c);
+                fPath.lineTo(points[0]);
+                c = points[0];
+                break;
+            case 'H': {
+                SkScalar x;
+                data = find_scalar(data, &x, relative, c.fX);
+                fPath.lineTo(x, c.fY);
+                c.fX = x;
+            }
+                break;
+            case 'V': {
+                SkScalar y;
+                data = find_scalar(data, &y, relative, c.fY);
+                fPath.lineTo(c.fX, y);
+                c.fY = y;
+            }
+                break;
+            case 'C': 
+                data = find_points(data, points, 3, relative, &c);
+                goto cubicCommon;
+            case 'S': 
+                data = find_points(data, &points[1], 2, relative, &c);
+                points[0] = c;
+                if (previousOp == 'C' || previousOp == 'S') {
+                    points[0].fX -= lastc.fX - c.fX;
+                    points[0].fY -= lastc.fY - c.fY;
+                }
+            cubicCommon:
+    //          if (data[0] == '\0')
+    //              return;
 #if QUADRATIC_APPROXIMATION
-                                       quadApprox(fPath, points[0], points[1], points[2]);
-#else  //this way just does a boring, slow old cubic
-                                       fPath.cubicTo(points[0], points[1], points[2]);
+                    quadApprox(fPath, points[0], points[1], points[2]);
+#else   //this way just does a boring, slow old cubic
+                    fPath.cubicTo(points[0], points[1], points[2]);
 #endif
-               //if we are using the quadApprox, lastc is what it would have been if we had used
-               //cubicTo
-                                       lastc = points[1];
-                                       c = points[2];
-                               break;
-                       case 'Q':  // Quadratic Bezier Curve
-                               data = find_points(data, points, 2, relative, &c);
-                               goto quadraticCommon;
-                       case 'T':
-                               data = find_points(data, &points[1], 1, relative, &c);
-                               points[0] = points[1];
-                               if (previousOp == 'Q' || previousOp == 'T') {
-                                       points[0].fX = c.fX * 2 - lastc.fX;
-                                       points[0].fY = c.fY * 2 - lastc.fY;
-                               }
-                       quadraticCommon:
-                               fPath.quadTo(points[0], points[1]);
-                               lastc = points[0];
-                               c = points[1];
-                               break;
-                       case 'Z':
-                               fPath.close();
-#if 0  // !!! still a bug?
-                               if (fPath.isEmpty() && (f.fX != 0 || f.fY != 0)) {
-                                       c.fX -= SkScalar.Epsilon;       // !!! enough?
-                                       fPath.moveTo(c);
-                                       fPath.lineTo(f);
-                                       fPath.close();
-                               }
+        //if we are using the quadApprox, lastc is what it would have been if we had used
+        //cubicTo
+                    lastc = points[1];
+                    c = points[2];
+                break;
+            case 'Q':  // Quadratic Bezier Curve
+                data = find_points(data, points, 2, relative, &c);
+                goto quadraticCommon;
+            case 'T':
+                data = find_points(data, &points[1], 1, relative, &c);
+                points[0] = points[1];
+                if (previousOp == 'Q' || previousOp == 'T') {
+                    points[0].fX = c.fX * 2 - lastc.fX;
+                    points[0].fY = c.fY * 2 - lastc.fY;
+                }
+            quadraticCommon:
+                fPath.quadTo(points[0], points[1]);
+                lastc = points[0];
+                c = points[1];
+                break;
+            case 'Z':
+                fPath.close();
+#if 0   // !!! still a bug?
+                if (fPath.isEmpty() && (f.fX != 0 || f.fY != 0)) {
+                    c.fX -= SkScalar.Epsilon;   // !!! enough?
+                    fPath.moveTo(c);
+                    fPath.lineTo(f);
+                    fPath.close();
+                }
 #endif
-                               c = f;
-                               op = '\0';
-                               break;
-                       case '~': {
-                               SkPoint args[2];
-                               data = find_points(data, args, 2, false, nil);
-                               fPath.moveTo(args[0].fX, args[0].fY);
-                               fPath.lineTo(args[1].fX, args[1].fY);
-                       }
-                               break;
-                       default:
-                               SkASSERT(0);
-                               return;
-               }
-               if (previousOp == 0)
-                       f = c;
-               previousOp = op;
-       } while (data[0] > 0);
+                c = f;
+                op = '\0';
+                break;
+            case '~': {
+                SkPoint args[2];
+                data = find_points(data, args, 2, false, nil);
+                fPath.moveTo(args[0].fX, args[0].fY);
+                fPath.lineTo(args[1].fX, args[1].fY);
+            }
+                break;
+            default:
+                SkASSERT(0);
+                return;
+        }
+        if (previousOp == 0)
+            f = c;
+        previousOp = op;
+    } while (data[0] > 0);
 }
 
index 136e1fd..39b2644 100644 (file)
@@ -1,3 +1,20 @@
+/* libs/graphics/animator/SkScript.cpp
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #include "SkScript.h"
 #include "SkMath.h"
 #include "SkParse.h"
 #include "SkTypedArray.h"
 
 /* things to do
-       ? re-enable support for struct literals (e.g., for initializing points or rects)
-               {x:1, y:2}
-       ? use standard XML / script notation like document.getElementById("canvas");  
-       finish support for typed arrays
-               ? allow indexing arrays by string
-                       this could map to the 'name' attribute of a given child of an array
-               ? allow multiple types in the array
-       remove SkDisplayType.h  // from SkOperand.h
-       merge type and operand arrays into scriptvalue array
+    ? re-enable support for struct literals (e.g., for initializing points or rects)
+        {x:1, y:2}
+    ? use standard XML / script notation like document.getElementById("canvas");  
+    finish support for typed arrays
+        ? allow indexing arrays by string
+            this could map to the 'name' attribute of a given child of an array
+        ? allow multiple types in the array
+    remove SkDisplayType.h  // from SkOperand.h
+    merge type and operand arrays into scriptvalue array
 */
 
 #ifdef SK_DEBUG
 static const char* errorStrings[] = {
-               "array index of out bounds", // kArrayIndexOutOfBounds
-               "could not find reference id", // kCouldNotFindReferencedID
-               "dot operator expects object", // kDotOperatorExpectsObject
-               "error in array index", // kErrorInArrrayIndex
-               "error in function parameters", // kErrorInFunctionParameters
-               "expected array", // kExpectedArray
-               "expected boolean expression", // kExpectedBooleanExpression
-               "expected field name", // kExpectedFieldName
-               "expected hex", // kExpectedHex
-               "expected int for condition operator", // kExpectedIntForConditionOperator
-               "expected number", // kExpectedNumber
-               "expected number for array index", // kExpectedNumberForArrayIndex
-               "expected operator", // kExpectedOperator
-               "expected token", // kExpectedToken
-               "expected token before dot operator", // kExpectedTokenBeforeDotOperator
-               "expected value", // kExpectedValue
-               "handle member failed", // kHandleMemberFailed
-               "handle member function failed", // kHandleMemberFunctionFailed
-               "handle unbox failed", // kHandleUnboxFailed
-               "index out of range", // kIndexOutOfRange
-               "mismatched array brace", // kMismatchedArrayBrace
-               "mismatched brackets", // kMismatchedBrackets
-               "no function handler found", // kNoFunctionHandlerFound
-               "premature end", // kPrematureEnd
-               "too many parameters", // kTooManyParameters
-               "type conversion failed", // kTypeConversionFailed
-               "unterminated string" // kUnterminatedString
+        "array index of out bounds", // kArrayIndexOutOfBounds
+        "could not find reference id", // kCouldNotFindReferencedID
+        "dot operator expects object", // kDotOperatorExpectsObject
+        "error in array index", // kErrorInArrrayIndex
+        "error in function parameters", // kErrorInFunctionParameters
+        "expected array", // kExpectedArray
+        "expected boolean expression", // kExpectedBooleanExpression
+        "expected field name", // kExpectedFieldName
+        "expected hex", // kExpectedHex
+        "expected int for condition operator", // kExpectedIntForConditionOperator
+        "expected number", // kExpectedNumber
+        "expected number for array index", // kExpectedNumberForArrayIndex
+        "expected operator", // kExpectedOperator
+        "expected token", // kExpectedToken
+        "expected token before dot operator", // kExpectedTokenBeforeDotOperator
+        "expected value", // kExpectedValue
+        "handle member failed", // kHandleMemberFailed
+        "handle member function failed", // kHandleMemberFunctionFailed
+        "handle unbox failed", // kHandleUnboxFailed
+        "index out of range", // kIndexOutOfRange
+        "mismatched array brace", // kMismatchedArrayBrace
+        "mismatched brackets", // kMismatchedBrackets
+        "no function handler found", // kNoFunctionHandlerFound
+        "premature end", // kPrematureEnd
+        "too many parameters", // kTooManyParameters
+        "type conversion failed", // kTypeConversionFailed
+        "unterminated string" // kUnterminatedString
 };
 #endif
 
 const SkScriptEngine::SkOperatorAttributes SkScriptEngine::gOpAttributes[] = {
-       { kNoType, kNoType, kNoBias }, //       kUnassigned,
-       { SkOpType(kInt | kScalar | kString), SkOpType(kInt | kScalar | kString), kTowardsString },     // kAdd
-       // kAddInt = kAdd,
-       { kNoType, kNoType, kNoBias },  // kAddScalar,
-       { kNoType, kNoType, kNoBias },  // kAddString,
-       { kNoType, kNoType, kNoBias },  // kArrayOp,
-       { kInt, kInt, kNoBias }, // kBitAnd
-       { kNoType, kInt, kNoBias }, // kBitNot
-       { kInt, kInt, kNoBias }, // kBitOr
-       { SkOpType(kInt | kScalar), SkOpType(kInt | kScalar), kNoBias }, // kDivide
-       // kDivideInt = kDivide
-       { kNoType, kNoType, kNoBias },  // kDivideScalar
-       { kNoType, kNoType, kNoBias },  // kElse
-       { SkOpType(kInt | kScalar | kString), SkOpType(kInt | kScalar | kString), kTowardsNumber }, // kEqual
-       // kEqualInt = kEqual
-       { kNoType, kNoType, kNoBias },  // kEqualScalar
-       { kNoType, kNoType, kNoBias },  // kEqualString
-       { kInt, kNoType, kNoBias },     // kFlipOps
-       { SkOpType(kInt | kScalar | kString), SkOpType(kInt | kScalar | kString), kTowardsNumber }, // kGreaterEqual
-       // kGreaterEqualInt = kGreaterEqual
-       { kNoType, kNoType, kNoBias },  // kGreaterEqualScalar
-       { kNoType, kNoType, kNoBias },  // kGreaterEqualString
-       { kNoType, kNoType, kNoBias },  // kIf
-       { kNoType, kInt, kNoBias }, // kLogicalAnd      (really, ToBool)
-       { kNoType, kInt, kNoBias }, // kLogicalNot
-       { kInt, kInt, kNoBias }, // kLogicalOr
-       { kNoType, SkOpType(kInt | kScalar), kNoBias }, // kMinus
-       // kMinusInt = kMinus
-       { kNoType, kNoType, kNoBias },  // kMinusScalar
-       { SkOpType(kInt | kScalar), SkOpType(kInt | kScalar), kNoBias }, // kModulo
-       // kModuloInt = kModulo
-       { kNoType, kNoType, kNoBias },  // kModuloScalar
-       { SkOpType(kInt | kScalar), SkOpType(kInt | kScalar), kNoBias }, // kMultiply
-       // kMultiplyInt = kMultiply
-       { kNoType, kNoType, kNoBias },  // kMultiplyScalar
-       { kNoType, kNoType, kNoBias },  // kParen
-       { kInt, kInt, kNoBias }, // kShiftLeft
-       { kInt, kInt, kNoBias }, // kShiftRight
-       { SkOpType(kInt | kScalar), SkOpType(kInt | kScalar), kNoBias }, // kSubtract
-       // kSubtractInt = kSubtract
-       { kNoType, kNoType, kNoBias },  // kSubtractScalar
-       { kInt, kInt, kNoBias } // kXor
+    { kNoType, kNoType, kNoBias }, //   kUnassigned,
+    { SkOpType(kInt | kScalar | kString), SkOpType(kInt | kScalar | kString), kTowardsString }, // kAdd
+    // kAddInt = kAdd,
+    { kNoType, kNoType, kNoBias },  // kAddScalar,
+    { kNoType, kNoType, kNoBias },  // kAddString,
+    { kNoType, kNoType, kNoBias },  // kArrayOp,
+    { kInt, kInt, kNoBias }, // kBitAnd
+    { kNoType, kInt, kNoBias }, // kBitNot
+    { kInt, kInt, kNoBias }, // kBitOr
+    { SkOpType(kInt | kScalar), SkOpType(kInt | kScalar), kNoBias }, // kDivide
+    // kDivideInt = kDivide
+    { kNoType, kNoType, kNoBias },  // kDivideScalar
+    { kNoType, kNoType, kNoBias },  // kElse
+    { SkOpType(kInt | kScalar | kString), SkOpType(kInt | kScalar | kString), kTowardsNumber }, // kEqual
+    // kEqualInt = kEqual
+    { kNoType, kNoType, kNoBias },  // kEqualScalar
+    { kNoType, kNoType, kNoBias },  // kEqualString
+    { kInt, kNoType, kNoBias },     // kFlipOps
+    { SkOpType(kInt | kScalar | kString), SkOpType(kInt | kScalar | kString), kTowardsNumber }, // kGreaterEqual
+    // kGreaterEqualInt = kGreaterEqual
+    { kNoType, kNoType, kNoBias },  // kGreaterEqualScalar
+    { kNoType, kNoType, kNoBias },  // kGreaterEqualString
+    { kNoType, kNoType, kNoBias },  // kIf
+    { kNoType, kInt, kNoBias }, // kLogicalAnd  (really, ToBool)
+    { kNoType, kInt, kNoBias }, // kLogicalNot
+    { kInt, kInt, kNoBias }, // kLogicalOr
+    { kNoType, SkOpType(kInt | kScalar), kNoBias }, // kMinus
+    // kMinusInt = kMinus
+    { kNoType, kNoType, kNoBias },  // kMinusScalar
+    { SkOpType(kInt | kScalar), SkOpType(kInt | kScalar), kNoBias }, // kModulo
+    // kModuloInt = kModulo
+    { kNoType, kNoType, kNoBias },  // kModuloScalar
+    { SkOpType(kInt | kScalar), SkOpType(kInt | kScalar), kNoBias }, // kMultiply
+    // kMultiplyInt = kMultiply
+    { kNoType, kNoType, kNoBias },  // kMultiplyScalar
+    { kNoType, kNoType, kNoBias },  // kParen
+    { kInt, kInt, kNoBias }, // kShiftLeft
+    { kInt, kInt, kNoBias }, // kShiftRight
+    { SkOpType(kInt | kScalar), SkOpType(kInt | kScalar), kNoBias }, // kSubtract
+    // kSubtractInt = kSubtract
+    { kNoType, kNoType, kNoBias },  // kSubtractScalar
+    { kInt, kInt, kNoBias } // kXor
 };
 
 // Note that the real precedence for () [] is '2'
@@ -102,1533 +119,1533 @@ const SkScriptEngine::SkOperatorAttributes SkScriptEngine::gOpAttributes[] = {
 #define kIfElsePrecedence 15
 
 const signed char SkScriptEngine::gPrecedence[] = {
-               -1, //  kUnassigned,
-               6, // kAdd,
-               // kAddInt = kAdd,
-               6, // kAddScalar,
-               6, // kAddString,       // string concat
-               kBracketPrecedence, // kArrayOp,
-               10, // kBitAnd,
-               4, // kBitNot,
-               12, // kBitOr,
-               5, // kDivide,
-               // kDivideInt = kDivide,
-               5, // kDivideScalar,
-               kIfElsePrecedence, // kElse,
-               9, // kEqual,
-               // kEqualInt = kEqual,
-               9, // kEqualScalar,
-               9, // kEqualString,
-               -1, // kFlipOps,
-               8, // kGreaterEqual,
-               // kGreaterEqualInt = kGreaterEqual,
-               8, // kGreaterEqualScalar,
-               8, // kGreaterEqualString,
-               kIfElsePrecedence, // kIf,
-               13, // kLogicalAnd,
-               4, // kLogicalNot,
-               14, // kLogicalOr,
-               4, // kMinus,
-               // kMinusInt = kMinus,
-               4, // kMinusScalar,
-               5, // kModulo,
-               // kModuloInt = kModulo,
-               5, // kModuloScalar,
-               5, // kMultiply,
-               // kMultiplyInt = kMultiply,
-               5, // kMultiplyScalar,
-               kBracketPrecedence, // kParen,
-               7, // kShiftLeft,
-               7, // kShiftRight,      // signed
-               6, // kSubtract,
-               // kSubtractInt = kSubtract,
-               6, // kSubtractScalar,
-               11, // kXor
+        -1, //  kUnassigned,
+        6, // kAdd,
+        // kAddInt = kAdd,
+        6, // kAddScalar,
+        6, // kAddString,   // string concat
+        kBracketPrecedence, // kArrayOp,
+        10, // kBitAnd,
+        4, // kBitNot,
+        12, // kBitOr,
+        5, // kDivide,
+        // kDivideInt = kDivide,
+        5, // kDivideScalar,
+        kIfElsePrecedence, // kElse,
+        9, // kEqual,
+        // kEqualInt = kEqual,
+        9, // kEqualScalar,
+        9, // kEqualString,
+        -1, // kFlipOps,
+        8, // kGreaterEqual,
+        // kGreaterEqualInt = kGreaterEqual,
+        8, // kGreaterEqualScalar,
+        8, // kGreaterEqualString,
+        kIfElsePrecedence, // kIf,
+        13, // kLogicalAnd,
+        4, // kLogicalNot,
+        14, // kLogicalOr,
+        4, // kMinus,
+        // kMinusInt = kMinus,
+        4, // kMinusScalar,
+        5, // kModulo,
+        // kModuloInt = kModulo,
+        5, // kModuloScalar,
+        5, // kMultiply,
+        // kMultiplyInt = kMultiply,
+        5, // kMultiplyScalar,
+        kBracketPrecedence, // kParen,
+        7, // kShiftLeft,
+        7, // kShiftRight,  // signed
+        6, // kSubtract,
+        // kSubtractInt = kSubtract,
+        6, // kSubtractScalar,
+        11, // kXor
 };
 
 static inline bool is_between(int c, int min, int max)
 {
-       return (unsigned)(c - min) <= (unsigned)(max - min);
+    return (unsigned)(c - min) <= (unsigned)(max - min);
 }
 
 static inline bool is_ws(int c)
 {
-       return is_between(c, 1, 32);
+    return is_between(c, 1, 32);
 }
 
 static int token_length(const char* start) {
-       char ch = start[0];
-       if (! is_between(ch, 'a' , 'z') &&  ! is_between(ch, 'A', 'Z') && ch != '_' && ch != '$')
-               return -1;
-       int length = 0;
-       do
-               ch = start[++length];
-       while (is_between(ch, 'a' , 'z') || is_between(ch, 'A', 'Z') || is_between(ch, '0', '9') ||
-               ch == '_' || ch == '$');
-       return length;
+    char ch = start[0];
+    if (! is_between(ch, 'a' , 'z') &&  ! is_between(ch, 'A', 'Z') && ch != '_' && ch != '$')
+        return -1;
+    int length = 0;
+    do
+        ch = start[++length];
+    while (is_between(ch, 'a' , 'z') || is_between(ch, 'A', 'Z') || is_between(ch, '0', '9') ||
+        ch == '_' || ch == '$');
+    return length;
 }
 
 SkScriptEngine::SkScriptEngine(SkOpType returnType) :
-       fTokenLength(0), fReturnType(returnType), fError(kNoError)
+    fTokenLength(0), fReturnType(returnType), fError(kNoError)
 {
-       SkSuppress noInitialSuppress;
-       noInitialSuppress.fOperator = kUnassigned;
-       noInitialSuppress.fOpStackDepth = 0;
-       noInitialSuppress.fSuppress = false;
-       fSuppressStack.push(noInitialSuppress);
-       *fOpStack.push() = kParen;
-       fTrackArray.appendClear();
-       fTrackString.appendClear();
+    SkSuppress noInitialSuppress;
+    noInitialSuppress.fOperator = kUnassigned;
+    noInitialSuppress.fOpStackDepth = 0;
+    noInitialSuppress.fSuppress = false;
+    fSuppressStack.push(noInitialSuppress);
+    *fOpStack.push() = kParen;
+    fTrackArray.appendClear();
+    fTrackString.appendClear();
 }
 
 SkScriptEngine::~SkScriptEngine() {
-       for (SkString** stringPtr = fTrackString.begin(); stringPtr < fTrackString.end(); stringPtr++)
-               delete *stringPtr;
-       for (SkTypedArray** arrayPtr = fTrackArray.begin(); arrayPtr < fTrackArray.end(); arrayPtr++)
-               delete *arrayPtr;
+    for (SkString** stringPtr = fTrackString.begin(); stringPtr < fTrackString.end(); stringPtr++)
+        delete *stringPtr;
+    for (SkTypedArray** arrayPtr = fTrackArray.begin(); arrayPtr < fTrackArray.end(); arrayPtr++)
+        delete *arrayPtr;
 }
 
 int SkScriptEngine::arithmeticOp(char ch, char nextChar, bool lastPush) {
-       SkOp op = kUnassigned;
-       bool reverseOperands = false;
-       bool negateResult = false;
-       int advance = 1;
-       switch (ch) {
-               case '+':
-                       // !!! ignoring unary plus as implemented here has the side effect of
-                       // suppressing errors like +"hi"
-                       if (lastPush == false)  // unary plus, don't push an operator
-                               goto returnAdv;
-                       op = kAdd;
-                       break;
-               case '-':
-                       op = lastPush ? kSubtract : kMinus;
-                       break;
-               case '*':
-                       op = kMultiply;
-                       break;
-               case '/':
-                       op = kDivide;
-                       break;
-               case '>':
-                       if (nextChar == '>') {
-                               op = kShiftRight;
-                               goto twoChar;
-                       
-                       op = kGreaterEqual;
-                       if (nextChar == '=')
-                               goto twoChar;
-                       reverseOperands = negateResult = true;
-                       break;
-               case '<':
-                       if (nextChar == '<') {
-                               op = kShiftLeft;
-                               goto twoChar;
-                       }
-                       op = kGreaterEqual;
-                       reverseOperands = nextChar == '=';
-                       negateResult = ! reverseOperands;
-                       advance += reverseOperands;
-                       break;
-               case '=':
-                       if (nextChar == '=') {
-                               op = kEqual;
-                               goto twoChar;
-                       }
-                       break;
-               case '!':
-                       if (nextChar == '=') {
-                               op = kEqual;
-                               negateResult = true;
+    SkOp op = kUnassigned;
+    bool reverseOperands = false;
+    bool negateResult = false;
+    int advance = 1;
+    switch (ch) {
+        case '+':
+            // !!! ignoring unary plus as implemented here has the side effect of
+            // suppressing errors like +"hi"
+            if (lastPush == false)  // unary plus, don't push an operator
+                goto returnAdv;
+            op = kAdd;
+            break;
+        case '-':
+            op = lastPush ? kSubtract : kMinus;
+            break;
+        case '*':
+            op = kMultiply;
+            break;
+        case '/':
+            op = kDivide;
+            break;
+        case '>':
+            if (nextChar == '>') {
+                op = kShiftRight;
+                goto twoChar;
+            } 
+            op = kGreaterEqual;
+            if (nextChar == '=')
+                goto twoChar;
+            reverseOperands = negateResult = true;
+            break;
+        case '<':
+            if (nextChar == '<') {
+                op = kShiftLeft;
+                goto twoChar;
+            }
+            op = kGreaterEqual;
+            reverseOperands = nextChar == '=';
+            negateResult = ! reverseOperands;
+            advance += reverseOperands;
+            break;
+        case '=':
+            if (nextChar == '=') {
+                op = kEqual;
+                goto twoChar;
+            }
+            break;
+        case '!':
+            if (nextChar == '=') {
+                op = kEqual;
+                negateResult = true;
 twoChar:
-                               advance++;
-                               break;
-                       
-                       op = kLogicalNot;
-                       break;
-               case '?':
-                       op = kIf;
-                       break;
-               case ':':
-                       op = kElse;
-                       break;
-               case '^':
-                       op = kXor;
-                       break;
-               case '(':
-                       *fOpStack.push() = kParen;      // push even if eval is suppressed
-                       goto returnAdv;
-               case '&':
-                       SkASSERT(nextChar != '&');
-                       op = kBitAnd;
-                       break;
-               case '|':
-                       SkASSERT(nextChar != '|');
-                       op = kBitOr;
-                       break;
-               case '%':
-                       op = kModulo;
-                       break;
-               case '~':
-                       op = kBitNot;
-                       break;
-       }
-       if (op == kUnassigned)
-               return 0;
-       if (fSuppressStack.top().fSuppress == false) {
-               signed char precedence = gPrecedence[op];
-               do {
-                       int idx = 0;
-                       SkOp compare;
-                       do {
-                               compare = fOpStack.index(idx);
-                               if ((compare & kArtificialOp) == 0)
-                                       break;
-                               idx++;
-                       } while (true);
-                       signed char topPrecedence = gPrecedence[compare];
-                       SkASSERT(topPrecedence != -1);
-                       if (topPrecedence > precedence || topPrecedence == precedence && 
-                                       gOpAttributes[op].fLeftType == kNoType) {
-                               break;
-                       }
-                       if (processOp() == false)
-                               return 0;       // error
-               } while (true);
-               if (negateResult)
-                       *fOpStack.push() = (SkOp) (kLogicalNot | kArtificialOp);
-               fOpStack.push(op);
-               if (reverseOperands)
-                       *fOpStack.push() = (SkOp) (kFlipOps | kArtificialOp);
-       }
+                advance++;
+                break;
+            } 
+            op = kLogicalNot;
+            break;
+        case '?':
+            op = kIf;
+            break;
+        case ':':
+            op = kElse;
+            break;
+        case '^':
+            op = kXor;
+            break;
+        case '(':
+            *fOpStack.push() = kParen;  // push even if eval is suppressed
+            goto returnAdv;
+        case '&':
+            SkASSERT(nextChar != '&');
+            op = kBitAnd;
+            break;
+        case '|':
+            SkASSERT(nextChar != '|');
+            op = kBitOr;
+            break;
+        case '%':
+            op = kModulo;
+            break;
+        case '~':
+            op = kBitNot;
+            break;
+    }
+    if (op == kUnassigned)
+        return 0;
+    if (fSuppressStack.top().fSuppress == false) {
+        signed char precedence = gPrecedence[op];
+        do {
+            int idx = 0;
+            SkOp compare;
+            do {
+                compare = fOpStack.index(idx);
+                if ((compare & kArtificialOp) == 0)
+                    break;
+                idx++;
+            } while (true);
+            signed char topPrecedence = gPrecedence[compare];
+            SkASSERT(topPrecedence != -1);
+            if (topPrecedence > precedence || topPrecedence == precedence && 
+                    gOpAttributes[op].fLeftType == kNoType) {
+                break;
+            }
+            if (processOp() == false)
+                return 0;   // error
+        } while (true);
+        if (negateResult)
+            *fOpStack.push() = (SkOp) (kLogicalNot | kArtificialOp);
+        fOpStack.push(op);
+        if (reverseOperands)
+            *fOpStack.push() = (SkOp) (kFlipOps | kArtificialOp);
+    }
 returnAdv:
-       return advance;
+    return advance;
 }
 
 void SkScriptEngine::boxCallBack(_boxCallBack func, void* userStorage) {
-       UserCallBack callBack;
-       callBack.fBoxCallBack = func;
-       commonCallBack(kBox, callBack, userStorage);
+    UserCallBack callBack;
+    callBack.fBoxCallBack = func;
+    commonCallBack(kBox, callBack, userStorage);
 }
 
 void SkScriptEngine::commonCallBack(CallBackType type, UserCallBack& callBack, void* userStorage) {
-       callBack.fCallBackType = type;
-       callBack.fUserStorage = userStorage;
-       *fUserCallBacks.prepend() = callBack;
+    callBack.fCallBackType = type;
+    callBack.fUserStorage = userStorage;
+    *fUserCallBacks.prepend() = callBack;
 }
 
 bool SkScriptEngine::convertParams(SkTDArray<SkScriptValue>& params, 
-               const SkFunctionParamType* paramTypes, int paramCount) {
-       if (params.count() > paramCount) {
-               fError = kTooManyParameters;
-               return false;   // too many parameters passed
-       }
-       for (int index = 0; index < params.count(); index++) {
-               if (convertTo((SkDisplayTypes) paramTypes[index], &params[index]) == false)
-                       return false;
-       }
-       return true;
+        const SkFunctionParamType* paramTypes, int paramCount) {
+    if (params.count() > paramCount) {
+        fError = kTooManyParameters;
+        return false;   // too many parameters passed
+    }
+    for (int index = 0; index < params.count(); index++) {
+        if (convertTo((SkDisplayTypes) paramTypes[index], &params[index]) == false)
+            return false;
+    }
+    return true;
 }
 
 bool SkScriptEngine::convertTo(SkDisplayTypes toType, SkScriptValue* value ) {
-       SkDisplayTypes type = value->fType;
-       if (type == toType)
-               return true;
-       if (ToOpType(type) == kObject) {
-#if 0  // !!! I want object->string to get string from displaystringtype, not id
-               if (ToOpType(toType) == kString) {
-                       bool success = handleObjectToString(value->fOperand.fObject);
-                       if (success == false)
-                               return false;
-                       SkOpType type;
-                       fTypeStack.pop(&type);
-                       value->fType = ToDisplayType(type);
-                       fOperandStack.pop(&value->fOperand);
-                       return true;
-               }
+    SkDisplayTypes type = value->fType;
+    if (type == toType)
+        return true;
+    if (ToOpType(type) == kObject) {
+#if 0   // !!! I want object->string to get string from displaystringtype, not id
+        if (ToOpType(toType) == kString) {
+            bool success = handleObjectToString(value->fOperand.fObject);
+            if (success == false)
+                return false;
+            SkOpType type;
+            fTypeStack.pop(&type);
+            value->fType = ToDisplayType(type);
+            fOperandStack.pop(&value->fOperand);
+            return true;
+        }
 #endif
-               if (handleUnbox(value) == false) {
-                       fError = kHandleUnboxFailed;
-                       return false;
-               }
-               return convertTo(toType, value);
-       }
-       return ConvertTo(this, toType, value);
+        if (handleUnbox(value) == false) {
+            fError = kHandleUnboxFailed;
+            return false;
+        }
+        return convertTo(toType, value);
+    }
+    return ConvertTo(this, toType, value);
 }
 
 bool SkScriptEngine::evaluateDot(const char*& script, bool suppressed) { 
-       size_t fieldLength = token_length(++script);            // skip dot
-       if (fieldLength == 0) {
-               fError = kExpectedFieldName;
-               return false;
-       }
-       const char* field = script;
-       script += fieldLength;
-       bool success = handleProperty(suppressed);
-       if (success == false) {
-               fError = kCouldNotFindReferencedID;     // note: never generated by standard animator plugins
-               return false;
-       }
-       return evaluateDotParam(script, suppressed, field, fieldLength);
+    size_t fieldLength = token_length(++script);        // skip dot
+    if (fieldLength == 0) {
+        fError = kExpectedFieldName;
+        return false;
+    }
+    const char* field = script;
+    script += fieldLength;
+    bool success = handleProperty(suppressed);
+    if (success == false) {
+        fError = kCouldNotFindReferencedID; // note: never generated by standard animator plugins
+        return false;
+    }
+    return evaluateDotParam(script, suppressed, field, fieldLength);
 }
 
 bool SkScriptEngine::evaluateDotParam(const char*& script, bool suppressed, 
-               const char* field, size_t fieldLength) { 
-       void* object;
-       if (suppressed)
-               object = nil;
-       else {
-               if (fTypeStack.top() != kObject) {
-                       fError = kDotOperatorExpectsObject;
-                       return false;
-               }
-               object = fOperandStack.top().fObject;
-               fTypeStack.pop();
-               fOperandStack.pop();
-       }
-       char ch; // see if it is a simple member or a function
-       while (is_ws(ch = script[0])) 
-               script++;
-       bool success = true;
-       if (ch != '(') {
-                       if (suppressed == false) {
-                               if ((success = handleMember(field, fieldLength, object)) == false)
-                                       fError = kHandleMemberFailed;
-                       }
-       } else {
-               SkTDArray<SkScriptValue> params;
-               *fBraceStack.push() = kFunctionBrace;
-               success = functionParams(&script, params);
-               if (success && suppressed == false &&
-                               (success = handleMemberFunction(field, fieldLength, object, params)) == false) 
-                       fError = kHandleMemberFunctionFailed;           
-       }
-       return success; 
+        const char* field, size_t fieldLength) { 
+    void* object;
+    if (suppressed)
+        object = nil;
+    else {
+        if (fTypeStack.top() != kObject) {
+            fError = kDotOperatorExpectsObject;
+            return false;
+        }
+        object = fOperandStack.top().fObject;
+        fTypeStack.pop();
+        fOperandStack.pop();
+    }
+    char ch; // see if it is a simple member or a function
+    while (is_ws(ch = script[0])) 
+        script++;
+    bool success = true;
+    if (ch != '(') {
+            if (suppressed == false) {
+                if ((success = handleMember(field, fieldLength, object)) == false)
+                    fError = kHandleMemberFailed;
+            }
+    } else {
+        SkTDArray<SkScriptValue> params;
+        *fBraceStack.push() = kFunctionBrace;
+        success = functionParams(&script, params);
+        if (success && suppressed == false &&
+                (success = handleMemberFunction(field, fieldLength, object, params)) == false) 
+            fError = kHandleMemberFunctionFailed;       
+    }
+    return success; 
 }
 
 bool SkScriptEngine::evaluateScript(const char** scriptPtr, SkScriptValue* value) {
 #ifdef SK_DEBUG
-       const char** original = scriptPtr;
+    const char** original = scriptPtr;
 #endif
-       bool success;
-       const char* inner;
-       if (strncmp(*scriptPtr, "#script:", sizeof("#script:") - 1) == 0) {
-               *scriptPtr += sizeof("#script:") - 1;
-               if (fReturnType == kNoType || fReturnType == kString) {
-                       success = innerScript(scriptPtr, value);
-                       if (success == false)
-                               goto end;
-                       inner = value->fOperand.fString->c_str();
-                       scriptPtr = &inner;
-               }
-       }
-       {
-               success = innerScript(scriptPtr, value);
-               if (success == false)
-                       goto end;
-               const char* script = *scriptPtr;
-               char ch;
-               while (is_ws(ch = script[0]))
-                       script++;
-               if (ch != '\0') {
-                       // error may trigger on scripts like "50,0" that were intended to be written as "[50, 0]"
-                       fError = kPrematureEnd;
-                       success = false;
-               }
-       }
+    bool success;
+    const char* inner;
+    if (strncmp(*scriptPtr, "#script:", sizeof("#script:") - 1) == 0) {
+        *scriptPtr += sizeof("#script:") - 1;
+        if (fReturnType == kNoType || fReturnType == kString) {
+            success = innerScript(scriptPtr, value);
+            if (success == false)
+                goto end;
+            inner = value->fOperand.fString->c_str();
+            scriptPtr = &inner;
+        }
+    }
+    {
+        success = innerScript(scriptPtr, value);
+        if (success == false)
+            goto end;
+        const char* script = *scriptPtr;
+        char ch;
+        while (is_ws(ch = script[0]))
+            script++;
+        if (ch != '\0') {
+            // error may trigger on scripts like "50,0" that were intended to be written as "[50, 0]"
+            fError = kPrematureEnd;
+            success = false;
+        }
+    }
 end:
 #ifdef SK_DEBUG
-       if (success == false) {
-               SkDebugf("script failed: %s", *original);
-               if (fError)
-                       SkDebugf(" %s", errorStrings[fError - 1]);
-               SkDebugf("\n");
-       }
+    if (success == false) {
+        SkDebugf("script failed: %s", *original);
+        if (fError)
+            SkDebugf(" %s", errorStrings[fError - 1]);
+        SkDebugf("\n");
+    }
 #endif
-       return success;
+    return success;
 }
 
 void SkScriptEngine::forget(SkTypedArray* array) {
-       if (array->getType() == SkType_String) {
-               for (int index = 0; index < array->count(); index++) {
-                       SkString* string = (*array)[index].fString;
-                       int found = fTrackString.find(string);
-                       if (found >= 0)
-                               fTrackString.remove(found);
-               }
-               return;
-       }
-       if (array->getType() == SkType_Array) {
-               for (int index = 0; index < array->count(); index++) {
-                       SkTypedArray* child = (*array)[index].fArray;
-                       forget(child);  // forgets children of child
-                       int found = fTrackArray.find(child);
-                       if (found >= 0)
-                               fTrackArray.remove(found);
-               }
-       }
+    if (array->getType() == SkType_String) {
+        for (int index = 0; index < array->count(); index++) {
+            SkString* string = (*array)[index].fString;
+            int found = fTrackString.find(string);
+            if (found >= 0)
+                fTrackString.remove(found);
+        }
+        return;
+    }
+    if (array->getType() == SkType_Array) {
+        for (int index = 0; index < array->count(); index++) {
+            SkTypedArray* child = (*array)[index].fArray;
+            forget(child);  // forgets children of child
+            int found = fTrackArray.find(child);
+            if (found >= 0)
+                fTrackArray.remove(found);
+        }
+    }
 }
 
 void SkScriptEngine::functionCallBack(_functionCallBack func, void* userStorage) {
-       UserCallBack callBack;
-       callBack.fFunctionCallBack = func;
-       commonCallBack(kFunction, callBack, userStorage);
+    UserCallBack callBack;
+    callBack.fFunctionCallBack = func;
+    commonCallBack(kFunction, callBack, userStorage);
 }
 
 bool SkScriptEngine::functionParams(const char** scriptPtr, SkTDArray<SkScriptValue>& params) {
-       (*scriptPtr)++; // skip open paren
-       *fOpStack.push() = kParen;
-       *fBraceStack.push() = kFunctionBrace;
-       SkBool suppressed = fSuppressStack.top().fSuppress;
-       do {
-               SkScriptValue value;
-               bool success = innerScript(scriptPtr, suppressed ? nil : &value);
-               if (success == false) {
-                       fError = kErrorInFunctionParameters;
-                       return false;
-               }
-               if (suppressed)
-                       continue;
-               *params.append() = value;
-       } while ((*scriptPtr)[-1] == ',');
-       fBraceStack.pop();
-       fOpStack.pop(); // pop paren
-       (*scriptPtr)++; // advance beyond close paren
-       return true;
+    (*scriptPtr)++; // skip open paren
+    *fOpStack.push() = kParen;
+    *fBraceStack.push() = kFunctionBrace;
+    SkBool suppressed = fSuppressStack.top().fSuppress;
+    do {
+        SkScriptValue value;
+        bool success = innerScript(scriptPtr, suppressed ? nil : &value);
+        if (success == false) {
+            fError = kErrorInFunctionParameters;
+            return false;
+        }
+        if (suppressed)
+            continue;
+        *params.append() = value;
+    } while ((*scriptPtr)[-1] == ',');
+    fBraceStack.pop();
+    fOpStack.pop(); // pop paren
+    (*scriptPtr)++; // advance beyond close paren
+    return true;
 }
 
 #ifdef SK_DEBUG
 bool SkScriptEngine::getErrorString(SkString* str) const {
-       if (fError)
-               str->set(errorStrings[fError - 1]);
-       return fError != 0;
+    if (fError)
+        str->set(errorStrings[fError - 1]);
+    return fError != 0;
 }
 #endif
 
 bool SkScriptEngine::innerScript(const char** scriptPtr, SkScriptValue* value) {
-       const char* script = *scriptPtr;
-       char ch;
-       bool lastPush = false;
-       bool success = true;
-       int opBalance = fOpStack.count();
-       int baseBrace = fBraceStack.count();
-       int suppressBalance = fSuppressStack.count();
-       while ((ch = script[0]) != '\0') {
-               if (is_ws(ch)) {
-                       script++;
-                       continue;
-               }
-               SkBool suppressed = fSuppressStack.top().fSuppress;
-               SkOperand operand;
-               const char* dotCheck;
-               if (fBraceStack.count() > baseBrace) {
-#if 0  // disable support for struct brace
-                       if (ch == ':') {
-                               SkASSERT(fTokenLength > 0);
-                               SkASSERT(fBraceStack.top() == kStructBrace);
-                               ++script;
-                               SkASSERT(fDisplayable);
-                               SkString token(fToken, fTokenLength);
-                               fTokenLength = 0;
-                               const char* tokenName = token.c_str();
-                               const SkMemberInfo* tokenInfo SK_INIT_TO_AVOID_WARNING;
-                               if (suppressed == false) {
-                                       SkDisplayTypes type = fInfo->getType();
-                                       tokenInfo = SkDisplayType::GetMember(type, &tokenName);
-                                       SkASSERT(tokenInfo);
-                               }
-                               SkScriptValue tokenValue;
-                               success = innerScript(&script, &tokenValue);    // terminate and return on comma, close brace
-                               SkASSERT(success);
-                               if (suppressed == false) {
-                                       if (tokenValue.fType == SkType_Displayable) {
-                                               SkASSERT(SkDisplayType::IsDisplayable(tokenInfo->getType()));
-                                               fDisplayable->setReference(tokenInfo, tokenValue.fOperand.fDisplayable);
-                                       } else {
-                                               if (tokenValue.fType != tokenInfo->getType()) {
-                                                       if (convertTo(tokenInfo->getType(), &tokenValue) == false)
-                                                               return false;
-                                               }
-                                               tokenInfo->writeValue(fDisplayable, nil, 0, 0, 
-                                                       (void*) ((char*) fInfo->memberData(fDisplayable) + tokenInfo->fOffset + fArrayOffset),
-                                                       tokenInfo->getType(), tokenValue);
-                                       }
-                               }
-                               lastPush = false;
-                               continue;
-                       } else 
-#endif                         
-                       if (fBraceStack.top() == kArrayBrace) {
-                               SkScriptValue tokenValue;
-                               success = innerScript(&script, &tokenValue);    // terminate and return on comma, close brace
-                               if (success == false) {
-                                       fError = kErrorInArrrayIndex;
-                                       return false;
-                               }
-                               if (suppressed == false) {
+    const char* script = *scriptPtr;
+    char ch;
+    bool lastPush = false;
+    bool success = true;
+    int opBalance = fOpStack.count();
+    int baseBrace = fBraceStack.count();
+    int suppressBalance = fSuppressStack.count();
+    while ((ch = script[0]) != '\0') {
+        if (is_ws(ch)) {
+            script++;
+            continue;
+        }
+        SkBool suppressed = fSuppressStack.top().fSuppress;
+        SkOperand operand;
+        const char* dotCheck;
+        if (fBraceStack.count() > baseBrace) {
+#if 0   // disable support for struct brace
+            if (ch == ':') {
+                SkASSERT(fTokenLength > 0);
+                SkASSERT(fBraceStack.top() == kStructBrace);
+                ++script;
+                SkASSERT(fDisplayable);
+                SkString token(fToken, fTokenLength);
+                fTokenLength = 0;
+                const char* tokenName = token.c_str();
+                const SkMemberInfo* tokenInfo SK_INIT_TO_AVOID_WARNING;
+                if (suppressed == false) {
+                    SkDisplayTypes type = fInfo->getType();
+                    tokenInfo = SkDisplayType::GetMember(type, &tokenName);
+                    SkASSERT(tokenInfo);
+                }
+                SkScriptValue tokenValue;
+                success = innerScript(&script, &tokenValue);    // terminate and return on comma, close brace
+                SkASSERT(success);
+                if (suppressed == false) {
+                    if (tokenValue.fType == SkType_Displayable) {
+                        SkASSERT(SkDisplayType::IsDisplayable(tokenInfo->getType()));
+                        fDisplayable->setReference(tokenInfo, tokenValue.fOperand.fDisplayable);
+                    } else {
+                        if (tokenValue.fType != tokenInfo->getType()) {
+                            if (convertTo(tokenInfo->getType(), &tokenValue) == false)
+                                return false;
+                        }
+                        tokenInfo->writeValue(fDisplayable, nil, 0, 0, 
+                            (void*) ((char*) fInfo->memberData(fDisplayable) + tokenInfo->fOffset + fArrayOffset),
+                            tokenInfo->getType(), tokenValue);
+                    }
+                }
+                lastPush = false;
+                continue;
+            } else 
+#endif              
+            if (fBraceStack.top() == kArrayBrace) {
+                SkScriptValue tokenValue;
+                success = innerScript(&script, &tokenValue);    // terminate and return on comma, close brace
+                if (success == false) {
+                    fError = kErrorInArrrayIndex;
+                    return false;
+                }
+                if (suppressed == false) {
 #if 0 // no support for structures for now
-                                       if (tokenValue.fType == SkType_Structure) {
-                                               fArrayOffset += (int) fInfo->getSize(fDisplayable);
-                                       } else 
+                    if (tokenValue.fType == SkType_Structure) {
+                        fArrayOffset += (int) fInfo->getSize(fDisplayable);
+                    } else 
 #endif
-                                       {
-                                               SkDisplayTypes type = ToDisplayType(fReturnType);
-                                               if (fReturnType == kNoType) {
-                                                       // !!! short sighted; in the future, allow each returned array component to carry 
-                                                       // its own type, and let caller do any needed conversions
-                                                       if (value->fOperand.fArray->count() == 0)
-                                                               value->fOperand.fArray->setType(type = tokenValue.fType);
-                                                       else
-                                                               type = value->fOperand.fArray->getType();
-                                               }
-                                               if (tokenValue.fType != type) {
-                                                       if (convertTo(type, &tokenValue) == false)
-                                                               return false;
-                                               }
-                                               *value->fOperand.fArray->append() = tokenValue.fOperand;
-                                       }
-                               }
-                               lastPush = false;
-                               continue;
-                       } else {
-                               if (token_length(script) == 0) {
-                                       fError = kExpectedToken;
-                                       return false;
-                               }
-                       }
-               }
-               if (lastPush != false && fTokenLength > 0) {
-                       if (ch == '(') {
-                               *fBraceStack.push() = kFunctionBrace;
-                               if (handleFunction(&script, SkToBool(suppressed)) == false)
-                                       return false;
-                               lastPush = true;
-                               continue;
-                       } else if (ch == '[') {
-                               if (handleProperty(SkToBool(suppressed)) == false)
-                                       return false;   // note: never triggered by standard animator plugins
-                               if (handleArrayIndexer(&script, SkToBool(suppressed)) == false)
-                                       return false;
-                               lastPush = true;
-                               continue;
-                       } else if (ch != '.') {
-                               if (handleProperty(SkToBool(suppressed)) == false)
-                                       return false;   // note: never triggered by standard animator plugins
-                               lastPush = true;
-                               continue;
-                       }
-               }
-               if (ch == '0' && (script[1] & ~0x20) == 'X') {
-                       if (lastPush != false) {
-                               fError = kExpectedOperator;
-                               return false;
-                       }
-                       script += 2;
-                       script = SkParse::FindHex(script, (uint32_t*)&operand.fS32);
-                       if (script == nil) {
-                               fError = kExpectedHex;
-                               return false;
-                       }
-                       goto intCommon;
-               }
-               if (lastPush == false && ch == '.')
-                       goto scalarCommon;
-               if (ch >= '0' && ch <= '9') {
-                       if (lastPush != false) {
-                               fError = kExpectedOperator;
-                               return false;
-                       }
-                       dotCheck = SkParse::FindS32(script, &operand.fS32);
-                       if (dotCheck[0] != '.') {
-                               script = dotCheck;
+                    {
+                        SkDisplayTypes type = ToDisplayType(fReturnType);
+                        if (fReturnType == kNoType) {
+                            // !!! short sighted; in the future, allow each returned array component to carry 
+                            // its own type, and let caller do any needed conversions
+                            if (value->fOperand.fArray->count() == 0)
+                                value->fOperand.fArray->setType(type = tokenValue.fType);
+                            else
+                                type = value->fOperand.fArray->getType();
+                        }
+                        if (tokenValue.fType != type) {
+                            if (convertTo(type, &tokenValue) == false)
+                                return false;
+                        }
+                        *value->fOperand.fArray->append() = tokenValue.fOperand;
+                    }
+                }
+                lastPush = false;
+                continue;
+            } else {
+                if (token_length(script) == 0) {
+                    fError = kExpectedToken;
+                    return false;
+                }
+            }
+        }
+        if (lastPush != false && fTokenLength > 0) {
+            if (ch == '(') {
+                *fBraceStack.push() = kFunctionBrace;
+                if (handleFunction(&script, SkToBool(suppressed)) == false)
+                    return false;
+                lastPush = true;
+                continue;
+            } else if (ch == '[') {
+                if (handleProperty(SkToBool(suppressed)) == false)
+                    return false;   // note: never triggered by standard animator plugins
+                if (handleArrayIndexer(&script, SkToBool(suppressed)) == false)
+                    return false;
+                lastPush = true;
+                continue;
+            } else if (ch != '.') {
+                if (handleProperty(SkToBool(suppressed)) == false)
+                    return false;   // note: never triggered by standard animator plugins
+                lastPush = true;
+                continue;
+            }
+        }
+        if (ch == '0' && (script[1] & ~0x20) == 'X') {
+            if (lastPush != false) {
+                fError = kExpectedOperator;
+                return false;
+            }
+            script += 2;
+            script = SkParse::FindHex(script, (uint32_t*)&operand.fS32);
+            if (script == nil) {
+                fError = kExpectedHex;
+                return false;
+            }
+            goto intCommon;
+        }
+        if (lastPush == false && ch == '.')
+            goto scalarCommon;
+        if (ch >= '0' && ch <= '9') {
+            if (lastPush != false) {
+                fError = kExpectedOperator;
+                return false;
+            }
+            dotCheck = SkParse::FindS32(script, &operand.fS32);
+            if (dotCheck[0] != '.') {
+                script = dotCheck;
 intCommon:
-                               if (suppressed == false)
-                                       *fTypeStack.push() = kInt;
-                       } else {
+                if (suppressed == false)
+                    *fTypeStack.push() = kInt;
+            } else {
 scalarCommon:
-                               script = SkParse::FindScalar(script, &operand.fScalar);
-                               if (suppressed == false)
-                                       *fTypeStack.push() = kScalar;
-                       }
-                       if (suppressed == false)
-                               fOperandStack.push(operand);
-                       lastPush = true;
-                       continue;
-               }
-               int length = token_length(script);
-               if (length > 0) {
-                       if (lastPush != false) {
-                               fError = kExpectedOperator;
-                               return false;
-                       }
-                       fToken = script;
-                       fTokenLength = length;
-                       script += length;
-                       lastPush = true;
-                       continue;
-               }
-               char startQuote = ch;
-               if (startQuote == '\'' || startQuote == '\"') {
-                       if (lastPush != false) {
-                               fError = kExpectedOperator;
-                               return false;
-                       }
-                       operand.fString = new SkString();
-                       track(operand.fString);
-                       ++script;
+                script = SkParse::FindScalar(script, &operand.fScalar);
+                if (suppressed == false)
+                    *fTypeStack.push() = kScalar;
+            }
+            if (suppressed == false)
+                fOperandStack.push(operand);
+            lastPush = true;
+            continue;
+        }
+        int length = token_length(script);
+        if (length > 0) {
+            if (lastPush != false) {
+                fError = kExpectedOperator;
+                return false;
+            }
+            fToken = script;
+            fTokenLength = length;
+            script += length;
+            lastPush = true;
+            continue;
+        }
+        char startQuote = ch;
+        if (startQuote == '\'' || startQuote == '\"') {
+            if (lastPush != false) {
+                fError = kExpectedOperator;
+                return false;
+            }
+            operand.fString = new SkString();
+            track(operand.fString);
+            ++script;
 
-                       // <mrr> this is a lot of calls to append() one char at at time
-                       // how hard to preflight script so we know how much to grow fString by?
-                       do {
-                               if (script[0] == '\\')
-                                       ++script;
-                               operand.fString->append(script, 1);
-                               ++script;
-                               if (script[0] == '\0') {
-                                       fError = kUnterminatedString;
-                                       return false;
-                               }
-                       } while (script[0] != startQuote);
-                       ++script;
-                       if (suppressed == false) {
-                               *fTypeStack.push() = kString;
-                               fOperandStack.push(operand);
-                       }
-                       lastPush = true;
-                       continue;
-               }
-               ;
-               if (ch ==  '.') {
-                       if (fTokenLength == 0) {
-                               SkScriptValue scriptValue;
-                               SkDEBUGCODE(scriptValue.fOperand.fObject = nil);
-                               int tokenLength = token_length(++script);
-                               const char* token = script;
-                               script += tokenLength;
-                               if (suppressed == false) {
-                                       if (fTypeStack.count() == 0) {
-                                               fError = kExpectedTokenBeforeDotOperator;
-                                               return false;
-                                       }
-                                       SkOpType topType;
-                                       fTypeStack.pop(&topType);
-                                       fOperandStack.pop(&scriptValue.fOperand);
-                                       scriptValue.fType = ToDisplayType(topType);
-                                       handleBox(&scriptValue);
-                               }
-                               success = evaluateDotParam(script, SkToBool(suppressed), token, tokenLength);
-                               if (success == false)
-                                       return false;
-                               lastPush = true;
-                               continue; 
-                       }
-                       // get next token, and evaluate immediately
-                       success = evaluateDot(script, SkToBool(suppressed));
-                       if (success == false)                           
-                               return false;
-                       lastPush = true;
-                       continue;
-               }
-               if (ch == '[') {
-                       if (lastPush == false) {
-                               script++;
-                               *fBraceStack.push() = kArrayBrace;
-                               if (suppressed)
-                                       continue;
-                               operand.fArray = value->fOperand.fArray = new SkTypedArray(ToDisplayType(fReturnType));
-                               track(value->fOperand.fArray);
-                               *fTypeStack.push() = (SkOpType) kArray;
-                               fOperandStack.push(operand);
-                               continue;
-                       }
-                       if (handleArrayIndexer(&script, SkToBool(suppressed)) == false)
-                               return false;
-                       lastPush = true;
-                       continue;
-               }
+            // <mrr> this is a lot of calls to append() one char at at time
+            // how hard to preflight script so we know how much to grow fString by?
+            do {
+                if (script[0] == '\\')
+                    ++script;
+                operand.fString->append(script, 1);
+                ++script;
+                if (script[0] == '\0') {
+                    fError = kUnterminatedString;
+                    return false;
+                }
+            } while (script[0] != startQuote);
+            ++script;
+            if (suppressed == false) {
+                *fTypeStack.push() = kString;
+                fOperandStack.push(operand);
+            }
+            lastPush = true;
+            continue;
+        }
+        ;
+        if (ch ==  '.') {
+            if (fTokenLength == 0) {
+                SkScriptValue scriptValue;
+                SkDEBUGCODE(scriptValue.fOperand.fObject = nil);
+                int tokenLength = token_length(++script);
+                const char* token = script;
+                script += tokenLength;
+                if (suppressed == false) {
+                    if (fTypeStack.count() == 0) {
+                        fError = kExpectedTokenBeforeDotOperator;
+                        return false;
+                    }
+                    SkOpType topType;
+                    fTypeStack.pop(&topType);
+                    fOperandStack.pop(&scriptValue.fOperand);
+                    scriptValue.fType = ToDisplayType(topType);
+                    handleBox(&scriptValue);
+                }
+                success = evaluateDotParam(script, SkToBool(suppressed), token, tokenLength);
+                if (success == false)
+                    return false;
+                lastPush = true;
+                continue; 
+            }
+            // get next token, and evaluate immediately
+            success = evaluateDot(script, SkToBool(suppressed));
+            if (success == false)               
+                return false;
+            lastPush = true;
+            continue;
+        }
+        if (ch == '[') {
+            if (lastPush == false) {
+                script++;
+                *fBraceStack.push() = kArrayBrace;
+                if (suppressed)
+                    continue;
+                operand.fArray = value->fOperand.fArray = new SkTypedArray(ToDisplayType(fReturnType));
+                track(value->fOperand.fArray);
+                *fTypeStack.push() = (SkOpType) kArray;
+                fOperandStack.push(operand);
+                continue;
+            }
+            if (handleArrayIndexer(&script, SkToBool(suppressed)) == false)
+                return false;
+            lastPush = true;
+            continue;
+        }
 #if 0 // structs not supported for now
-               if (ch == '{') {
-                       if (lastPush == false) {
-                               script++;
-                               *fBraceStack.push() = kStructBrace;
-                               if (suppressed)
-                                       continue;
-                               operand.fS32 = 0;
-                               *fTypeStack.push() = (SkOpType) kStruct;
-                               fOperandStack.push(operand);
-                               continue;
-                       }
-                       SkASSERT(0); // braces in other contexts aren't supported yet
-               }
+        if (ch == '{') {
+            if (lastPush == false) {
+                script++;
+                *fBraceStack.push() = kStructBrace;
+                if (suppressed)
+                    continue;
+                operand.fS32 = 0;
+                *fTypeStack.push() = (SkOpType) kStruct;
+                fOperandStack.push(operand);
+                continue;
+            }
+            SkASSERT(0); // braces in other contexts aren't supported yet
+        }
 #endif
-               if (ch == ')' && fBraceStack.count() > 0) {
-                       SkBraceStyle braceStyle = fBraceStack.top(); 
-                       if (braceStyle == kFunctionBrace) {
-                               fBraceStack.pop();
-                               break;
-                       }
-               }
-               if (ch == ',' || ch == ']') {
-                       if (ch != ',') {
-                               SkBraceStyle match;
-                               fBraceStack.pop(&match);
-                               if (match != kArrayBrace) {
-                                       fError = kMismatchedArrayBrace;
-                                       return false;
-                               }
-                       }
-                       script++;
-                       // !!! see if brace or bracket is correct closer
-                       break;
-               }
-               char nextChar = script[1];
-               int advance = logicalOp(ch, nextChar);
-               if (advance < 0)         // error
-                       return false;
-               if (advance == 0) 
-                       advance = arithmeticOp(ch, nextChar, lastPush);
-               if (advance == 0) // unknown token
-                       return false;
-               if (advance > 0)
-                       script += advance;
-               lastPush = ch == ']' || ch == ')';
-       }
-       bool suppressed = SkToBool(fSuppressStack.top().fSuppress);
-       if (fTokenLength > 0) {
-               success = handleProperty(suppressed);
-               if (success == false)
-                       return false;   // note: never triggered by standard animator plugins
-       }
-       while (fOpStack.count() > opBalance) {   // leave open paren
-               if ((fError = opError()) != kNoError)
-                       return false;
-               if (processOp() == false)
-                       return false;
-       }       
-       SkOpType topType = fTypeStack.count() > 0 ? fTypeStack.top() : kNoType;
-       if (suppressed == false && topType != fReturnType &&
-                       topType == kString && fReturnType != kNoType) { // if result is a string, give handle property a chance to convert it to the property value
-               SkString* string = fOperandStack.top().fString;
-               fToken = string->c_str();
-               fTokenLength = string->size();
-               fOperandStack.pop();
-               fTypeStack.pop();
-               success = handleProperty(SkToBool(fSuppressStack.top().fSuppress));
-               if (success == false) { // if it couldn't convert, return string (error?)
-                       SkOperand operand;
-                       operand.fS32 = 0;
-                       *fTypeStack.push() = kString;
-                       operand.fString = string;
-                       fOperandStack.push(operand);
-               }
-       }
-       if (value) {
-               if (fOperandStack.count() == 0)
-                       return false;
-               SkASSERT(fOperandStack.count() >= 1);
-               SkASSERT(fTypeStack.count() >= 1);
-               fOperandStack.pop(&value->fOperand);
-               SkOpType type;
-               fTypeStack.pop(&type);
-               value->fType = ToDisplayType(type);
-//             SkASSERT(value->fType != SkType_Unknown);
-               if (topType != fReturnType && topType == kObject && fReturnType != kNoType) {
-                       if (convertTo(ToDisplayType(fReturnType), value) == false)
-                               return false;
-               }
-       }
-       while (fSuppressStack.count() > suppressBalance)
-               fSuppressStack.pop();
-       *scriptPtr = script;
-       return true; // no error
+        if (ch == ')' && fBraceStack.count() > 0) {
+            SkBraceStyle braceStyle = fBraceStack.top(); 
+            if (braceStyle == kFunctionBrace) {
+                fBraceStack.pop();
+                break;
+            }
+        }
+        if (ch == ',' || ch == ']') {
+            if (ch != ',') {
+                SkBraceStyle match;
+                fBraceStack.pop(&match);
+                if (match != kArrayBrace) {
+                    fError = kMismatchedArrayBrace;
+                    return false;
+                }
+            }
+            script++;
+            // !!! see if brace or bracket is correct closer
+            break;
+        }
+        char nextChar = script[1];
+        int advance = logicalOp(ch, nextChar);
+        if (advance < 0)     // error
+            return false;
+        if (advance == 0) 
+            advance = arithmeticOp(ch, nextChar, lastPush);
+        if (advance == 0) // unknown token
+            return false;
+        if (advance > 0)
+            script += advance;
+        lastPush = ch == ']' || ch == ')';
+    }
+    bool suppressed = SkToBool(fSuppressStack.top().fSuppress);
+    if (fTokenLength > 0) {
+        success = handleProperty(suppressed);
+        if (success == false)
+            return false;   // note: never triggered by standard animator plugins
+    }
+    while (fOpStack.count() > opBalance) {   // leave open paren
+        if ((fError = opError()) != kNoError)
+            return false;
+        if (processOp() == false)
+            return false;
+    }   
+    SkOpType topType = fTypeStack.count() > 0 ? fTypeStack.top() : kNoType;
+    if (suppressed == false && topType != fReturnType &&
+            topType == kString && fReturnType != kNoType) { // if result is a string, give handle property a chance to convert it to the property value
+        SkString* string = fOperandStack.top().fString;
+        fToken = string->c_str();
+        fTokenLength = string->size();
+        fOperandStack.pop();
+        fTypeStack.pop();
+        success = handleProperty(SkToBool(fSuppressStack.top().fSuppress));
+        if (success == false) { // if it couldn't convert, return string (error?)
+            SkOperand operand;
+            operand.fS32 = 0;
+            *fTypeStack.push() = kString;
+            operand.fString = string;
+            fOperandStack.push(operand);
+        }
+    }
+    if (value) {
+        if (fOperandStack.count() == 0)
+            return false;
+        SkASSERT(fOperandStack.count() >= 1);
+        SkASSERT(fTypeStack.count() >= 1);
+        fOperandStack.pop(&value->fOperand);
+        SkOpType type;
+        fTypeStack.pop(&type);
+        value->fType = ToDisplayType(type);
+//      SkASSERT(value->fType != SkType_Unknown);
+        if (topType != fReturnType && topType == kObject && fReturnType != kNoType) {
+            if (convertTo(ToDisplayType(fReturnType), value) == false)
+                return false;
+        }
+    }
+    while (fSuppressStack.count() > suppressBalance)
+        fSuppressStack.pop();
+    *scriptPtr = script;
+    return true; // no error
 }
 
 void SkScriptEngine::memberCallBack(_memberCallBack member , void* userStorage) {
-       UserCallBack callBack;
-       callBack.fMemberCallBack = member;
-       commonCallBack(kMember, callBack, userStorage);
+    UserCallBack callBack;
+    callBack.fMemberCallBack = member;
+    commonCallBack(kMember, callBack, userStorage);
 }
 
 void SkScriptEngine::memberFunctionCallBack(_memberFunctionCallBack func, void* userStorage) {
-       UserCallBack callBack;
-       callBack.fMemberFunctionCallBack = func;
-       commonCallBack(kMemberFunction, callBack, userStorage);
+    UserCallBack callBack;
+    callBack.fMemberFunctionCallBack = func;
+    commonCallBack(kMemberFunction, callBack, userStorage);
 }
 
 #if 0
 void SkScriptEngine::objectToStringCallBack(_objectToStringCallBack func, void* userStorage) {
-       UserCallBack callBack;
-       callBack.fObjectToStringCallBack = func;
-       commonCallBack(kObjectToString, callBack, userStorage);
+    UserCallBack callBack;
+    callBack.fObjectToStringCallBack = func;
+    commonCallBack(kObjectToString, callBack, userStorage);
 }
 #endif
 
 bool SkScriptEngine::handleArrayIndexer(const char** scriptPtr, bool suppressed) {
-       SkScriptValue scriptValue;
-       (*scriptPtr)++;
-       *fOpStack.push() = kParen;
-       *fBraceStack.push() = kArrayBrace;
-       SkOpType saveType = fReturnType;
-       fReturnType = kInt;
-       bool success = innerScript(scriptPtr, suppressed == false ? &scriptValue : nil);
-       if (success == false)
-               return false;
-       fReturnType = saveType;
-       if (suppressed == false) {
-               if (convertTo(SkType_Int, &scriptValue) == false)
-                       return false;
-               int index = scriptValue.fOperand.fS32;
-               SkScriptValue scriptValue;
-               SkOpType type;
-               fTypeStack.pop(&type);
-               fOperandStack.pop(&scriptValue.fOperand);
-               scriptValue.fType = ToDisplayType(type);
-               if (type == kObject) {
-                       success = handleUnbox(&scriptValue);
-                       if (success == false)
-                               return false;
-                       if (ToOpType(scriptValue.fType) != kArray) {
-                               fError = kExpectedArray;
-                               return false;
-                       }
-               }
-               *fTypeStack.push() = scriptValue.fOperand.fArray->getOpType();
-//             SkASSERT(index >= 0);
-               if ((unsigned) index >= (unsigned) scriptValue.fOperand.fArray->count()) {
-                       fError = kArrayIndexOutOfBounds;
-                       return false;
-               }
-               scriptValue.fOperand = scriptValue.fOperand.fArray->begin()[index];
-               fOperandStack.push(scriptValue.fOperand);
-       }
-       fOpStack.pop(); // pop paren
-       return success;
+    SkScriptValue scriptValue;
+    (*scriptPtr)++;
+    *fOpStack.push() = kParen;
+    *fBraceStack.push() = kArrayBrace;
+    SkOpType saveType = fReturnType;
+    fReturnType = kInt;
+    bool success = innerScript(scriptPtr, suppressed == false ? &scriptValue : nil);
+    if (success == false)
+        return false;
+    fReturnType = saveType;
+    if (suppressed == false) {
+        if (convertTo(SkType_Int, &scriptValue) == false)
+            return false;
+        int index = scriptValue.fOperand.fS32;
+        SkScriptValue scriptValue;
+        SkOpType type;
+        fTypeStack.pop(&type);
+        fOperandStack.pop(&scriptValue.fOperand);
+        scriptValue.fType = ToDisplayType(type);
+        if (type == kObject) {
+            success = handleUnbox(&scriptValue);
+            if (success == false)
+                return false;
+            if (ToOpType(scriptValue.fType) != kArray) {
+                fError = kExpectedArray;
+                return false;
+            }
+        }
+        *fTypeStack.push() = scriptValue.fOperand.fArray->getOpType();
+//      SkASSERT(index >= 0);
+        if ((unsigned) index >= (unsigned) scriptValue.fOperand.fArray->count()) {
+            fError = kArrayIndexOutOfBounds;
+            return false;
+        }
+        scriptValue.fOperand = scriptValue.fOperand.fArray->begin()[index];
+        fOperandStack.push(scriptValue.fOperand);
+    }
+    fOpStack.pop(); // pop paren
+    return success;
 }
 
 bool SkScriptEngine::handleBox(SkScriptValue* scriptValue) {
-       bool success = true;
-       for (UserCallBack* callBack = fUserCallBacks.begin(); callBack < fUserCallBacks.end(); callBack++) {
-               if (callBack->fCallBackType != kBox)
-                       continue;
-               success = (*callBack->fBoxCallBack)(callBack->fUserStorage, scriptValue);
-               if (success) {
-                       fOperandStack.push(scriptValue->fOperand);
-                       *fTypeStack.push() = ToOpType(scriptValue->fType);
-                       goto done;
-               }
-       }
+    bool success = true;
+    for (UserCallBack* callBack = fUserCallBacks.begin(); callBack < fUserCallBacks.end(); callBack++) {
+        if (callBack->fCallBackType != kBox)
+            continue;
+        success = (*callBack->fBoxCallBack)(callBack->fUserStorage, scriptValue);
+        if (success) {
+            fOperandStack.push(scriptValue->fOperand);
+            *fTypeStack.push() = ToOpType(scriptValue->fType);
+            goto done;
+        }
+    }
 done:
-       return success;
+    return success;
 }
 
 bool SkScriptEngine::handleFunction(const char** scriptPtr, bool suppressed) {
-       SkScriptValue callbackResult;
-       SkTDArray<SkScriptValue> params;
-       SkString functionName(fToken, fTokenLength);
-       fTokenLength = 0;
-       bool success = functionParams(scriptPtr, params);
-       if (success == false)
-               goto done;
-       if (suppressed == true)
-               return true;
-       {
-               for (UserCallBack* callBack = fUserCallBacks.begin(); callBack < fUserCallBacks.end(); callBack++) {
-                       if (callBack->fCallBackType != kFunction)
-                               continue;
-                       success = (*callBack->fFunctionCallBack)(functionName.c_str(), functionName.size(), params, 
-                               callBack->fUserStorage, &callbackResult);
-                       if (success) {
-                               fOperandStack.push(callbackResult.fOperand);
-                               *fTypeStack.push() = ToOpType(callbackResult.fType);
-                               goto done;
-                       }
-               }
-       }
-       fError = kNoFunctionHandlerFound;
-       return false;
+    SkScriptValue callbackResult;
+    SkTDArray<SkScriptValue> params;
+    SkString functionName(fToken, fTokenLength);
+    fTokenLength = 0;
+    bool success = functionParams(scriptPtr, params);
+    if (success == false)
+        goto done;
+    if (suppressed == true)
+        return true;
+    {
+        for (UserCallBack* callBack = fUserCallBacks.begin(); callBack < fUserCallBacks.end(); callBack++) {
+            if (callBack->fCallBackType != kFunction)
+                continue;
+            success = (*callBack->fFunctionCallBack)(functionName.c_str(), functionName.size(), params, 
+                callBack->fUserStorage, &callbackResult);
+            if (success) {
+                fOperandStack.push(callbackResult.fOperand);
+                *fTypeStack.push() = ToOpType(callbackResult.fType);
+                goto done;
+            }
+        }
+    }
+    fError = kNoFunctionHandlerFound;
+    return false;
 done:
-       return success;
+    return success;
 }
 
 bool SkScriptEngine::handleMember(const char* field, size_t len, void* object) {
-       SkScriptValue callbackResult;
-       bool success = true;
-       for (UserCallBack* callBack = fUserCallBacks.begin(); callBack < fUserCallBacks.end(); callBack++) {
-               if (callBack->fCallBackType != kMember)
-                       continue;
-               success = (*callBack->fMemberCallBack)(field, len, object, callBack->fUserStorage, &callbackResult);
-               if (success) {
-                       if (callbackResult.fType == SkType_String)
-                               track(callbackResult.fOperand.fString);
-                       fOperandStack.push(callbackResult.fOperand);
-                       *fTypeStack.push() = ToOpType(callbackResult.fType);
-                       goto done;
-               }
-       }
-       return false;
+    SkScriptValue callbackResult;
+    bool success = true;
+    for (UserCallBack* callBack = fUserCallBacks.begin(); callBack < fUserCallBacks.end(); callBack++) {
+        if (callBack->fCallBackType != kMember)
+            continue;
+        success = (*callBack->fMemberCallBack)(field, len, object, callBack->fUserStorage, &callbackResult);
+        if (success) {
+            if (callbackResult.fType == SkType_String)
+                track(callbackResult.fOperand.fString);
+            fOperandStack.push(callbackResult.fOperand);
+            *fTypeStack.push() = ToOpType(callbackResult.fType);
+            goto done;
+        }
+    }
+    return false;
 done:
-       return success;
+    return success;
 }
 
 bool SkScriptEngine::handleMemberFunction(const char* field, size_t len, void* object, SkTDArray<SkScriptValue>& params) {
-       SkScriptValue callbackResult;
-       bool success = true;
-       for (UserCallBack* callBack = fUserCallBacks.begin(); callBack < fUserCallBacks.end(); callBack++) {
-               if (callBack->fCallBackType != kMemberFunction)
-                       continue;
-               success = (*callBack->fMemberFunctionCallBack)(field, len, object, params, 
-                       callBack->fUserStorage, &callbackResult);
-               if (success) {
-                       if (callbackResult.fType == SkType_String)
-                               track(callbackResult.fOperand.fString);
-                       fOperandStack.push(callbackResult.fOperand);
-                       *fTypeStack.push() = ToOpType(callbackResult.fType);
-                       goto done;
-               }
-       }
-       return false;
+    SkScriptValue callbackResult;
+    bool success = true;
+    for (UserCallBack* callBack = fUserCallBacks.begin(); callBack < fUserCallBacks.end(); callBack++) {
+        if (callBack->fCallBackType != kMemberFunction)
+            continue;
+        success = (*callBack->fMemberFunctionCallBack)(field, len, object, params, 
+            callBack->fUserStorage, &callbackResult);
+        if (success) {
+            if (callbackResult.fType == SkType_String)
+                track(callbackResult.fOperand.fString);
+            fOperandStack.push(callbackResult.fOperand);
+            *fTypeStack.push() = ToOpType(callbackResult.fType);
+            goto done;
+        }
+    }
+    return false;
 done:
-       return success;
+    return success;
 }
 
 #if 0
 bool SkScriptEngine::handleObjectToString(void* object) {
-       SkScriptValue callbackResult;
-       bool success = true;
-       for (UserCallBack* callBack = fUserCallBacks.begin(); callBack < fUserCallBacks.end(); callBack++) {
-               if (callBack->fCallBackType != kObjectToString)
-                       continue;
-               success = (*callBack->fObjectToStringCallBack)(object, 
-                       callBack->fUserStorage, &callbackResult);
-               if (success) {
-                       if (callbackResult.fType == SkType_String)
-                               track(callbackResult.fOperand.fString);
-                       fOperandStack.push(callbackResult.fOperand);
-                       *fTypeStack.push() = ToOpType(callbackResult.fType);
-                       goto done;
-               }
-       }
-       return false;
+    SkScriptValue callbackResult;
+    bool success = true;
+    for (UserCallBack* callBack = fUserCallBacks.begin(); callBack < fUserCallBacks.end(); callBack++) {
+        if (callBack->fCallBackType != kObjectToString)
+            continue;
+        success = (*callBack->fObjectToStringCallBack)(object, 
+            callBack->fUserStorage, &callbackResult);
+        if (success) {
+            if (callbackResult.fType == SkType_String)
+                track(callbackResult.fOperand.fString);
+            fOperandStack.push(callbackResult.fOperand);
+            *fTypeStack.push() = ToOpType(callbackResult.fType);
+            goto done;
+        }
+    }
+    return false;
 done:
-       return success;
+    return success;
 }
 #endif
 
 bool SkScriptEngine::handleProperty(bool suppressed) {
-       SkScriptValue callbackResult;
-       bool success = true;
-       if (suppressed) 
-               goto done;
-       success = false; // note that with standard animator-script plugins, callback never returns false
-       {
-               for (UserCallBack* callBack = fUserCallBacks.begin(); callBack < fUserCallBacks.end(); callBack++) {
-                       if (callBack->fCallBackType != kProperty)
-                               continue;
-                       success = (*callBack->fPropertyCallBack)(fToken, fTokenLength, 
-                               callBack->fUserStorage, &callbackResult);
-                       if (success) {
-                               if (callbackResult.fType == SkType_String && callbackResult.fOperand.fString == nil) {
-                                       callbackResult.fOperand.fString = new SkString(fToken, fTokenLength);
-                                       track(callbackResult.fOperand.fString);
-                               }
-                               fOperandStack.push(callbackResult.fOperand);
-                               *fTypeStack.push() = ToOpType(callbackResult.fType);
-                               goto done;
-                       }
-               }
-       }
+    SkScriptValue callbackResult;
+    bool success = true;
+    if (suppressed) 
+        goto done;
+    success = false; // note that with standard animator-script plugins, callback never returns false
+    {
+        for (UserCallBack* callBack = fUserCallBacks.begin(); callBack < fUserCallBacks.end(); callBack++) {
+            if (callBack->fCallBackType != kProperty)
+                continue;
+            success = (*callBack->fPropertyCallBack)(fToken, fTokenLength, 
+                callBack->fUserStorage, &callbackResult);
+            if (success) {
+                if (callbackResult.fType == SkType_String && callbackResult.fOperand.fString == nil) {
+                    callbackResult.fOperand.fString = new SkString(fToken, fTokenLength);
+                    track(callbackResult.fOperand.fString);
+                }
+                fOperandStack.push(callbackResult.fOperand);
+                *fTypeStack.push() = ToOpType(callbackResult.fType);
+                goto done;
+            }
+        }
+    }
 done:
-       fTokenLength = 0;
-       return success;
+    fTokenLength = 0;
+    return success;
 }
 
 bool SkScriptEngine::handleUnbox(SkScriptValue* scriptValue) {
-       bool success = true;
-       for (UserCallBack* callBack = fUserCallBacks.begin(); callBack < fUserCallBacks.end(); callBack++) {
-               if (callBack->fCallBackType != kUnbox)
-                       continue;
-               success = (*callBack->fUnboxCallBack)(callBack->fUserStorage, scriptValue);
-               if (success) {
-                       if (scriptValue->fType == SkType_String)
-                               track(scriptValue->fOperand.fString);
-                       goto done;
-               }
-       }
-       return false;
+    bool success = true;
+    for (UserCallBack* callBack = fUserCallBacks.begin(); callBack < fUserCallBacks.end(); callBack++) {
+        if (callBack->fCallBackType != kUnbox)
+            continue;
+        success = (*callBack->fUnboxCallBack)(callBack->fUserStorage, scriptValue);
+        if (success) {
+            if (scriptValue->fType == SkType_String)
+                track(scriptValue->fOperand.fString);
+            goto done;
+        }
+    }
+    return false;
 done:
-       return success;
+    return success;
 }
 
 // note that entire expression is treated as if it were enclosed in parens
 // an open paren is always the first thing in the op stack
 
 int SkScriptEngine::logicalOp(char ch, char nextChar) {
-       int advance = 1;
-       SkOp match;
-       signed char precedence;
-       switch (ch) {
-               case ')':
-                       match = kParen;
-                       break;
-               case ']':
-                       match = kArrayOp;
-                       break;
-               case '?':
-                       match = kIf;
-                       break;
-               case ':':
-                       match = kElse;
-                       break;
-               case '&':
-                       if (nextChar != '&')
-                               goto noMatch;
-                       match = kLogicalAnd;
-                       advance = 2;
-                       break;
-               case '|':
-                       if (nextChar != '|')
-                               goto noMatch;
-                       match = kLogicalOr;
-                       advance = 2;
-                       break;
-               default:
+    int advance = 1;
+    SkOp match;
+    signed char precedence;
+    switch (ch) {
+        case ')':
+            match = kParen;
+            break;
+        case ']':
+            match = kArrayOp;
+            break;
+        case '?':
+            match = kIf;
+            break;
+        case ':':
+            match = kElse;
+            break;
+        case '&':
+            if (nextChar != '&')
+                goto noMatch;
+            match = kLogicalAnd;
+            advance = 2;
+            break;
+        case '|':
+            if (nextChar != '|')
+                goto noMatch;
+            match = kLogicalOr;
+            advance = 2;
+            break;
+        default:
 noMatch:
-                       return 0;
-       }
-       SkSuppress suppress;
-       precedence = gPrecedence[match];
-       if (fSuppressStack.top().fSuppress) {
-               if (fSuppressStack.top().fOpStackDepth < fOpStack.count()) {
-                       SkOp topOp = fOpStack.top();
-                       if (gPrecedence[topOp] <= precedence)
-                               fOpStack.pop();
-                       goto goHome;
-               }
-               bool changedPrecedence = gPrecedence[fSuppressStack.top().fOperator] < precedence;
-               if (changedPrecedence)
-                       fSuppressStack.pop();
-               if (precedence == kIfElsePrecedence) {
-                       if (match == kIf) {
-                               if (changedPrecedence)
-                                       fOpStack.pop();
-                               else
-                                       *fOpStack.push() = kIf;
-                       } else {
-                               if (fSuppressStack.top().fOpStackDepth == fOpStack.count()) {
-                                       goto flipSuppress;
-                               }
-                               fOpStack.pop();
-                       }
-               }
-               if (changedPrecedence == false)
-                       goto goHome;
-       }
-       while (gPrecedence[fOpStack.top() & ~kArtificialOp] < precedence) {
-               if (processOp() == false)
-                       return false;
-       }
-       if (fSuppressStack.top().fOpStackDepth > fOpStack.count())
-               fSuppressStack.pop();
-       switch (match) {
-               case kParen:
-               case kArrayOp:
-                       if (fOpStack.count() <= 1 || fOpStack.top() != match) {
-                               fError = kMismatchedBrackets;
-                               return -1;
-                       }
-                       if (match == kParen) 
-                               fOpStack.pop();
-                       else {
-                               SkOpType indexType;
-                               fTypeStack.pop(&indexType);
-                               if (indexType != kInt && indexType != kScalar) {
-                                       fError = kExpectedNumberForArrayIndex; // (although, could permit strings eventually)
-                                       return -1;
-                               }
-                               SkOperand indexOperand;
-                               fOperandStack.pop(&indexOperand);
-                               int index = indexType == kScalar ? SkScalarFloor(indexOperand.fScalar) : 
-                                       indexOperand.fS32;
-                               SkOpType arrayType;
-                               fTypeStack.pop(&arrayType);
-                               if ((unsigned)arrayType != (unsigned)kArray) {
-                                       fError = kExpectedArray;
-                                       return -1;
-                               }
-                               SkOperand arrayOperand;
-                               fOperandStack.pop(&arrayOperand);
-                               SkTypedArray* array = arrayOperand.fArray;
-                               SkOperand operand;
-                               if (array->getIndex(index, &operand) == false) {
-                                       fError = kIndexOutOfRange;
-                                       return -1;
-                               }
-                               SkOpType resultType = array->getOpType();
-                               fTypeStack.push(resultType);
-                               fOperandStack.push(operand);
-                       }
-                       break;
-               case kIf: {
-                       SkScriptValue ifValue;
-                       SkOpType ifType;
-                       fTypeStack.pop(&ifType);
-                       ifValue.fType = ToDisplayType(ifType);
-                       fOperandStack.pop(&ifValue.fOperand);
-                       if (convertTo(SkType_Int, &ifValue) == false)
-                               return -1;
-                       if (ifValue.fType != SkType_Int) {
-                               fError = kExpectedIntForConditionOperator;
-                               return -1;
-                       }
-                       suppress.fSuppress = ifValue.fOperand.fS32 == 0;
-                       suppress.fOperator = kIf;
-                       suppress.fOpStackDepth = fOpStack.count(); 
-                       suppress.fElse = false;
-                       fSuppressStack.push(suppress);
-                       // if left is true, do only up to colon
-                       // if left is false, do only after colon
-                       } break;
-               case kElse:
+            return 0;
+    }
+    SkSuppress suppress;
+    precedence = gPrecedence[match];
+    if (fSuppressStack.top().fSuppress) {
+        if (fSuppressStack.top().fOpStackDepth < fOpStack.count()) {
+            SkOp topOp = fOpStack.top();
+            if (gPrecedence[topOp] <= precedence)
+                fOpStack.pop();
+            goto goHome;
+        }
+        bool changedPrecedence = gPrecedence[fSuppressStack.top().fOperator] < precedence;
+        if (changedPrecedence)
+            fSuppressStack.pop();
+        if (precedence == kIfElsePrecedence) {
+            if (match == kIf) {
+                if (changedPrecedence)
+                    fOpStack.pop();
+                else
+                    *fOpStack.push() = kIf;
+            } else {
+                if (fSuppressStack.top().fOpStackDepth == fOpStack.count()) {
+                    goto flipSuppress;
+                }
+                fOpStack.pop();
+            }
+        }
+        if (changedPrecedence == false)
+            goto goHome;
+    }
+    while (gPrecedence[fOpStack.top() & ~kArtificialOp] < precedence) {
+        if (processOp() == false)
+            return false;
+    }
+    if (fSuppressStack.top().fOpStackDepth > fOpStack.count())
+        fSuppressStack.pop();
+    switch (match) {
+        case kParen:
+        case kArrayOp:
+            if (fOpStack.count() <= 1 || fOpStack.top() != match) {
+                fError = kMismatchedBrackets;
+                return -1;
+            }
+            if (match == kParen) 
+                fOpStack.pop();
+            else {
+                SkOpType indexType;
+                fTypeStack.pop(&indexType);
+                if (indexType != kInt && indexType != kScalar) {
+                    fError = kExpectedNumberForArrayIndex; // (although, could permit strings eventually)
+                    return -1;
+                }
+                SkOperand indexOperand;
+                fOperandStack.pop(&indexOperand);
+                int index = indexType == kScalar ? SkScalarFloor(indexOperand.fScalar) : 
+                    indexOperand.fS32;
+                SkOpType arrayType;
+                fTypeStack.pop(&arrayType);
+                if ((unsigned)arrayType != (unsigned)kArray) {
+                    fError = kExpectedArray;
+                    return -1;
+                }
+                SkOperand arrayOperand;
+                fOperandStack.pop(&arrayOperand);
+                SkTypedArray* array = arrayOperand.fArray;
+                SkOperand operand;
+                if (array->getIndex(index, &operand) == false) {
+                    fError = kIndexOutOfRange;
+                    return -1;
+                }
+                SkOpType resultType = array->getOpType();
+                fTypeStack.push(resultType);
+                fOperandStack.push(operand);
+            }
+            break;
+        case kIf: {
+            SkScriptValue ifValue;
+            SkOpType ifType;
+            fTypeStack.pop(&ifType);
+            ifValue.fType = ToDisplayType(ifType);
+            fOperandStack.pop(&ifValue.fOperand);
+            if (convertTo(SkType_Int, &ifValue) == false)
+                return -1;
+            if (ifValue.fType != SkType_Int) {
+                fError = kExpectedIntForConditionOperator;
+                return -1;
+            }
+            suppress.fSuppress = ifValue.fOperand.fS32 == 0;
+            suppress.fOperator = kIf;
+            suppress.fOpStackDepth = fOpStack.count(); 
+            suppress.fElse = false;
+            fSuppressStack.push(suppress);
+            // if left is true, do only up to colon
+            // if left is false, do only after colon
+            } break;
+        case kElse:
 flipSuppress:
-                       if (fSuppressStack.top().fElse == true)
-                               fSuppressStack.pop();
-                       fSuppressStack.top().fElse = true;
-                       fSuppressStack.top().fSuppress ^= true;
-                       // flip last do / don't do consideration from last '?'
-                       break;
-               case kLogicalAnd:
-               case kLogicalOr: {
-                       if (fTypeStack.top() != kInt) {
-                               fError = kExpectedBooleanExpression;
-                               return -1;
-                       }
-                       S32 topInt = fOperandStack.top().fS32;
-                       if (fOpStack.top() != kLogicalAnd)
-                               *fOpStack.push() = kLogicalAnd; // really means 'to bool', and is appropriate for 'or'
-                       if (match == kLogicalOr ? topInt != 0 : topInt == 0) {
-                               suppress.fSuppress = true;
-                               suppress.fOperator = match;
-                               suppress.fOpStackDepth = fOpStack.count(); 
-                               fSuppressStack.push(suppress);
-                       } else {
-                               fTypeStack.pop();
-                               fOperandStack.pop();
-                       }
-               }       break;
-               default:
-                       SkASSERT(0);
-       }
+            if (fSuppressStack.top().fElse == true)
+                fSuppressStack.pop();
+            fSuppressStack.top().fElse = true;
+            fSuppressStack.top().fSuppress ^= true;
+            // flip last do / don't do consideration from last '?'
+            break;
+        case kLogicalAnd:
+        case kLogicalOr: {
+            if (fTypeStack.top() != kInt) {
+                fError = kExpectedBooleanExpression;
+                return -1;
+            }
+            S32 topInt = fOperandStack.top().fS32;
+            if (fOpStack.top() != kLogicalAnd)
+                *fOpStack.push() = kLogicalAnd; // really means 'to bool', and is appropriate for 'or'
+            if (match == kLogicalOr ? topInt != 0 : topInt == 0) {
+                suppress.fSuppress = true;
+                suppress.fOperator = match;
+                suppress.fOpStackDepth = fOpStack.count(); 
+                fSuppressStack.push(suppress);
+            } else {
+                fTypeStack.pop();
+                fOperandStack.pop();
+            }
+        }   break;
+        default:
+            SkASSERT(0);
+    }
 goHome:
-       return advance;
+    return advance;
 }
 
 SkScriptEngine::Error SkScriptEngine::opError() {
-       int opCount = fOpStack.count();
-       int operandCount = fOperandStack.count();
-       if (opCount == 0) {
-               if (operandCount != 1)
-                       return kExpectedOperator;
-               return kNoError;
-       }
-       SkOp op = (SkOp) (fOpStack.top() & ~kArtificialOp);
-       const SkOperatorAttributes* attributes = &gOpAttributes[op];
-       if (attributes->fLeftType != kNoType && operandCount < 2)
-               return kExpectedValue;
-       if (attributes->fLeftType == kNoType && operandCount < 1)
-               return kExpectedValue;
-       return kNoError;
+    int opCount = fOpStack.count();
+    int operandCount = fOperandStack.count();
+    if (opCount == 0) {
+        if (operandCount != 1)
+            return kExpectedOperator;
+        return kNoError;
+    }
+    SkOp op = (SkOp) (fOpStack.top() & ~kArtificialOp);
+    const SkOperatorAttributes* attributes = &gOpAttributes[op];
+    if (attributes->fLeftType != kNoType && operandCount < 2)
+        return kExpectedValue;
+    if (attributes->fLeftType == kNoType && operandCount < 1)
+        return kExpectedValue;
+    return kNoError;
 }
 
 bool SkScriptEngine::processOp() {
-       SkOp op;
-       fOpStack.pop(&op);
-       op = (SkOp) (op & ~kArtificialOp);
-       const SkOperatorAttributes* attributes = &gOpAttributes[op];
-       SkOpType type2;
-       fTypeStack.pop(&type2);
-       SkOpType type1 = type2;
-       SkOperand operand2;
-       fOperandStack.pop(&operand2);
-       SkOperand operand1 = operand2; // !!! not really needed, suppresses warning
-       if (attributes->fLeftType != kNoType) {
-               fTypeStack.pop(&type1);
-               fOperandStack.pop(&operand1);
-               if (op == kFlipOps) {
-                       SkTSwap(type1, type2);
-                       SkTSwap(operand1, operand2);
-                       fOpStack.pop(&op);
-                       op = (SkOp) (op & ~kArtificialOp);
-                       attributes = &gOpAttributes[op];
-               }
-               if (type1 == kObject && (type1 & attributes->fLeftType) == 0) {
-                       SkScriptValue val;
-                       val.fType = ToDisplayType(type1);
-                       val.fOperand = operand1;
-                       bool success = handleUnbox(&val);
-                       if (success == false)
-                               return false;
-                       type1 = ToOpType(val.fType);
-                       operand1 = val.fOperand;
-               }
-       }
-       if (type2 == kObject && (type2 & attributes->fLeftType) == 0) {
-               SkScriptValue val;
-               val.fType = ToDisplayType(type2);
-               val.fOperand = operand2;
-               bool success = handleUnbox(&val);
-               if (success == false)
-                       return false;
-               type2 = ToOpType(val.fType);
-               operand2 = val.fOperand;
-       }
-       if (attributes->fLeftType != kNoType) {
-               if (type1 != type2) {
-                       if ((attributes->fLeftType & kString) && attributes->fBias & kTowardsString && ((type1 | type2) & kString)) {
-                               if (type1 == kInt || type1 == kScalar) {
-                                       convertToString(operand1, type1 == kInt ? SkType_Int : SkType_Float);
-                                       type1 = kString;
-                               }
-                               if (type2 == kInt || type2 == kScalar) {
-                                       convertToString(operand2, type2 == kInt ? SkType_Int : SkType_Float);
-                                       type2 = kString;
-                               }
-                       } else if (attributes->fLeftType & kScalar && ((type1 | type2) & kScalar)) {
-                               if (type1 == kInt) {
-                                       operand1.fScalar = IntToScalar(operand1.fS32);
-                                       type1 = kScalar;
-                               }
-                               if (type2 == kInt) {
-                                       operand2.fScalar = IntToScalar(operand2.fS32);
-                                        type2 = kScalar;
-                               }
-                       }
-               }
-               if ((type1 & attributes->fLeftType) == 0 || type1 != type2) {
-                       if (type1 == kString) {
-                               const char* result = SkParse::FindScalar(operand1.fString->c_str(), &operand1.fScalar);
-                               if (result == nil) {
-                                       fError = kExpectedNumber;
-                                       return false;
-                               }
-                               type1 = kScalar;
-                       }
-                       if (type1 == kScalar && (attributes->fLeftType == kInt || type2 == kInt)) {
-                               operand1.fS32 = SkScalarFloor(operand1.fScalar);
-                               type1 = kInt;
-                       }
-               }
-       }
-       if ((type2 & attributes->fRightType) == 0 || type1 != type2) {
-               if (type2 == kString) {
-                       const char* result = SkParse::FindScalar(operand2.fString->c_str(), &operand2.fScalar);
-                       if (result == nil) {
-                               fError = kExpectedNumber;
-                               return false;
-                       }
-                       type2 = kScalar;
-               }
-               if (type2 == kScalar && (attributes->fRightType == kInt || type1 == kInt)) {
-                       operand2.fS32 = SkScalarFloor(operand2.fScalar);
-                       type2 = kInt;
-               }
-       }
-       if (type2 == kScalar)
-               op = (SkOp) (op + 1);
-       else if (type2 == kString)
-               op = (SkOp) (op + 2);
-       switch(op) {
-               case kAddInt:
-                       operand2.fS32 += operand1.fS32;
-                       break;
-               case kAddScalar:
-                       operand2.fScalar += operand1.fScalar;
-                       break;
-               case kAddString:
-                       if (fTrackString.find(operand1.fString) < 0) {
-                               operand1.fString = SkNEW_ARGS(SkString, (*operand1.fString));
-                               track(operand1.fString);
-                       }
-                       operand1.fString->append(*operand2.fString);
-                       operand2 = operand1;
-                       break;
-               case kBitAnd:
-                       operand2.fS32 &= operand1.fS32;
-                       break;
-               case kBitNot:
-                       operand2.fS32 = ~operand2.fS32;
-                       break;
-               case kBitOr:
-                       operand2.fS32 |= operand1.fS32;
-                       break;
-               case kDivideInt:
-                       if (operand2.fS32 == 0) {
-                               operand2.fS32 = operand1.fS32 == 0 ? SK_NaN32 : operand1.fS32 > 0 ? SK_MaxS32 : -SK_MaxS32;
-                               break;
-                       } else {
-                               S32 original = operand2.fS32;
-                               operand2.fS32 = operand1.fS32 / operand2.fS32;
-                               if (original * operand2.fS32 == operand1.fS32)
-                                       break;    // integer divide was good enough
-                               operand2.fS32 = original;
-                               type2 = kScalar;
-                       }
-               case kDivideScalar:
-                       if (operand2.fScalar == 0)
-                               operand2.fScalar = operand1.fScalar == 0 ? SK_ScalarNaN : operand1.fScalar > 0 ? SK_ScalarMax : -SK_ScalarMax;
-                       else
-                               operand2.fScalar = SkScalarDiv(operand1.fScalar, operand2.fScalar);
-                       break;
-               case kEqualInt:
-                       operand2.fS32 = operand1.fS32 == operand2.fS32;
-                       break;
-               case kEqualScalar:
-                       operand2.fS32 = operand1.fScalar == operand2.fScalar;
-                       type2 = kInt;
-                       break;
-               case kEqualString:
-                       operand2.fS32 = *operand1.fString == *operand2.fString;
-                       type2 = kInt;
-                       break;
-               case kGreaterEqualInt:
-                       operand2.fS32 = operand1.fS32 >= operand2.fS32;
-                       break;
-               case kGreaterEqualScalar:
-                       operand2.fS32 = operand1.fScalar >= operand2.fScalar;
-                       type2 = kInt;
-                       break;
-               case kGreaterEqualString:
-                       operand2.fS32 = strcmp(operand1.fString->c_str(), operand2.fString->c_str()) >= 0;
-                       type2 = kInt;
-                       break;
-               case kLogicalAnd:
-                       operand2.fS32 = !! operand2.fS32;       // really, ToBool
-                       break;
-               case kLogicalNot:
-                       operand2.fS32 = ! operand2.fS32;
-                       break;
-               case kLogicalOr:
-                       SkASSERT(0);    // should have already been processed
-                       break;
-               case kMinusInt:
-                       operand2.fS32 = -operand2.fS32;
-                       break;
-               case kMinusScalar:
-                       operand2.fScalar = -operand2.fScalar;
-                       break;
-               case kModuloInt:
-                       operand2.fS32 = operand1.fS32 % operand2.fS32;
-                       break;
-               case kModuloScalar:
-                       operand2.fScalar = SkScalarMod(operand1.fScalar, operand2.fScalar);
-                       break;
-               case kMultiplyInt:
-                       operand2.fS32 *= operand1.fS32;
-                       break;
-               case kMultiplyScalar:
-                       operand2.fScalar = SkScalarMul(operand1.fScalar, operand2.fScalar);
-                       break;
-               case kShiftLeft:
-                       operand2.fS32 = operand1.fS32 << operand2.fS32;
-                       break;
-               case kShiftRight:
-                       operand2.fS32 = operand1.fS32 >> operand2.fS32;
-                       break;
-               case kSubtractInt:
-                       operand2.fS32 = operand1.fS32 - operand2.fS32;
-                       break;
-               case kSubtractScalar:
-                       operand2.fScalar = operand1.fScalar - operand2.fScalar;
-                       break;
-               case kXor:
-                       operand2.fS32 ^= operand1.fS32;
-                       break;
-               default:
-                       SkASSERT(0);
-       }
-       fTypeStack.push(type2);
-       fOperandStack.push(operand2);
-       return true;
+    SkOp op;
+    fOpStack.pop(&op);
+    op = (SkOp) (op & ~kArtificialOp);
+    const SkOperatorAttributes* attributes = &gOpAttributes[op];
+    SkOpType type2;
+    fTypeStack.pop(&type2);
+    SkOpType type1 = type2;
+    SkOperand operand2;
+    fOperandStack.pop(&operand2);
+    SkOperand operand1 = operand2; // !!! not really needed, suppresses warning
+    if (attributes->fLeftType != kNoType) {
+        fTypeStack.pop(&type1);
+        fOperandStack.pop(&operand1);
+        if (op == kFlipOps) {
+            SkTSwap(type1, type2);
+            SkTSwap(operand1, operand2);
+            fOpStack.pop(&op);
+            op = (SkOp) (op & ~kArtificialOp);
+            attributes = &gOpAttributes[op];
+        }
+        if (type1 == kObject && (type1 & attributes->fLeftType) == 0) {
+            SkScriptValue val;
+            val.fType = ToDisplayType(type1);
+            val.fOperand = operand1;
+            bool success = handleUnbox(&val);
+            if (success == false)
+                return false;
+            type1 = ToOpType(val.fType);
+            operand1 = val.fOperand;
+        }
+    }
+    if (type2 == kObject && (type2 & attributes->fLeftType) == 0) {
+        SkScriptValue val;
+        val.fType = ToDisplayType(type2);
+        val.fOperand = operand2;
+        bool success = handleUnbox(&val);
+        if (success == false)
+            return false;
+        type2 = ToOpType(val.fType);
+        operand2 = val.fOperand;
+    }
+    if (attributes->fLeftType != kNoType) {
+        if (type1 != type2) {
+            if ((attributes->fLeftType & kString) && attributes->fBias & kTowardsString && ((type1 | type2) & kString)) {
+                if (type1 == kInt || type1 == kScalar) {
+                    convertToString(operand1, type1 == kInt ? SkType_Int : SkType_Float);
+                    type1 = kString;
+                }
+                if (type2 == kInt || type2 == kScalar) {
+                    convertToString(operand2, type2 == kInt ? SkType_Int : SkType_Float);
+                    type2 = kString;
+                }
+            } else if (attributes->fLeftType & kScalar && ((type1 | type2) & kScalar)) {
+                if (type1 == kInt) {
+                    operand1.fScalar = IntToScalar(operand1.fS32);
+                    type1 = kScalar;
+                }
+                if (type2 == kInt) {
+                    operand2.fScalar = IntToScalar(operand2.fS32);
+                     type2 = kScalar;
+                }
+            }
+        }
+        if ((type1 & attributes->fLeftType) == 0 || type1 != type2) {
+            if (type1 == kString) {
+                const char* result = SkParse::FindScalar(operand1.fString->c_str(), &operand1.fScalar);
+                if (result == nil) {
+                    fError = kExpectedNumber;
+                    return false;
+                }
+                type1 = kScalar;
+            }
+            if (type1 == kScalar && (attributes->fLeftType == kInt || type2 == kInt)) {
+                operand1.fS32 = SkScalarFloor(operand1.fScalar);
+                type1 = kInt;
+            }
+        }
+    }
+    if ((type2 & attributes->fRightType) == 0 || type1 != type2) {
+        if (type2 == kString) {
+            const char* result = SkParse::FindScalar(operand2.fString->c_str(), &operand2.fScalar);
+            if (result == nil) {
+                fError = kExpectedNumber;
+                return false;
+            }
+            type2 = kScalar;
+        }
+        if (type2 == kScalar && (attributes->fRightType == kInt || type1 == kInt)) {
+            operand2.fS32 = SkScalarFloor(operand2.fScalar);
+            type2 = kInt;
+        }
+    }
+    if (type2 == kScalar)
+        op = (SkOp) (op + 1);
+    else if (type2 == kString)
+        op = (SkOp) (op + 2);
+    switch(op) {
+        case kAddInt:
+            operand2.fS32 += operand1.fS32;
+            break;
+        case kAddScalar:
+            operand2.fScalar += operand1.fScalar;
+            break;
+        case kAddString:
+            if (fTrackString.find(operand1.fString) < 0) {
+                operand1.fString = SkNEW_ARGS(SkString, (*operand1.fString));
+                track(operand1.fString);
+            }
+            operand1.fString->append(*operand2.fString);
+            operand2 = operand1;
+            break;
+        case kBitAnd:
+            operand2.fS32 &= operand1.fS32;
+            break;
+        case kBitNot:
+            operand2.fS32 = ~operand2.fS32;
+            break;
+        case kBitOr:
+            operand2.fS32 |= operand1.fS32;
+            break;
+        case kDivideInt:
+            if (operand2.fS32 == 0) {
+                operand2.fS32 = operand1.fS32 == 0 ? SK_NaN32 : operand1.fS32 > 0 ? SK_MaxS32 : -SK_MaxS32;
+                break;
+            } else {
+                S32 original = operand2.fS32;
+                operand2.fS32 = operand1.fS32 / operand2.fS32;
+                if (original * operand2.fS32 == operand1.fS32)
+                    break;    // integer divide was good enough
+                operand2.fS32 = original;
+                type2 = kScalar;
+            }
+        case kDivideScalar:
+            if (operand2.fScalar == 0)
+                operand2.fScalar = operand1.fScalar == 0 ? SK_ScalarNaN : operand1.fScalar > 0 ? SK_ScalarMax : -SK_ScalarMax;
+            else
+                operand2.fScalar = SkScalarDiv(operand1.fScalar, operand2.fScalar);
+            break;
+        case kEqualInt:
+            operand2.fS32 = operand1.fS32 == operand2.fS32;
+            break;
+        case kEqualScalar:
+            operand2.fS32 = operand1.fScalar == operand2.fScalar;
+            type2 = kInt;
+            break;
+        case kEqualString:
+            operand2.fS32 = *operand1.fString == *operand2.fString;
+            type2 = kInt;
+            break;
+        case kGreaterEqualInt:
+            operand2.fS32 = operand1.fS32 >= operand2.fS32;
+            break;
+        case kGreaterEqualScalar:
+            operand2.fS32 = operand1.fScalar >= operand2.fScalar;
+            type2 = kInt;
+            break;
+        case kGreaterEqualString:
+            operand2.fS32 = strcmp(operand1.fString->c_str(), operand2.fString->c_str()) >= 0;
+            type2 = kInt;
+            break;
+        case kLogicalAnd:
+            operand2.fS32 = !! operand2.fS32;   // really, ToBool
+            break;
+        case kLogicalNot:
+            operand2.fS32 = ! operand2.fS32;
+            break;
+        case kLogicalOr:
+            SkASSERT(0);    // should have already been processed
+            break;
+        case kMinusInt:
+            operand2.fS32 = -operand2.fS32;
+            break;
+        case kMinusScalar:
+            operand2.fScalar = -operand2.fScalar;
+            break;
+        case kModuloInt:
+            operand2.fS32 = operand1.fS32 % operand2.fS32;
+            break;
+        case kModuloScalar:
+            operand2.fScalar = SkScalarMod(operand1.fScalar, operand2.fScalar);
+            break;
+        case kMultiplyInt:
+            operand2.fS32 *= operand1.fS32;
+            break;
+        case kMultiplyScalar:
+            operand2.fScalar = SkScalarMul(operand1.fScalar, operand2.fScalar);
+            break;
+        case kShiftLeft:
+            operand2.fS32 = operand1.fS32 << operand2.fS32;
+            break;
+        case kShiftRight:
+            operand2.fS32 = operand1.fS32 >> operand2.fS32;
+            break;
+        case kSubtractInt:
+            operand2.fS32 = operand1.fS32 - operand2.fS32;
+            break;
+        case kSubtractScalar:
+            operand2.fScalar = operand1.fScalar - operand2.fScalar;
+            break;
+        case kXor:
+            operand2.fS32 ^= operand1.fS32;
+            break;
+        default:
+            SkASSERT(0);
+    }
+    fTypeStack.push(type2);
+    fOperandStack.push(operand2);
+    return true;
 }
 
 void SkScriptEngine::propertyCallBack(_propertyCallBack prop, void* userStorage) {
-       UserCallBack callBack;
-       callBack.fPropertyCallBack = prop;
-       commonCallBack(kProperty, callBack, userStorage);
+    UserCallBack callBack;
+    callBack.fPropertyCallBack = prop;
+    commonCallBack(kProperty, callBack, userStorage);
 }
 
 void SkScriptEngine::track(SkTypedArray* array) { 
-       SkASSERT(fTrackArray.find(array) < 0);  
-       *(fTrackArray.end() - 1) = array; 
-       fTrackArray.appendClear(); 
+    SkASSERT(fTrackArray.find(array) < 0);  
+    *(fTrackArray.end() - 1) = array; 
+    fTrackArray.appendClear(); 
 }
 
 void SkScriptEngine::track(SkString* string) { 
-       SkASSERT(fTrackString.find(string) < 0);  
-       *(fTrackString.end() - 1) = string; 
-       fTrackString.appendClear(); 
+    SkASSERT(fTrackString.find(string) < 0);  
+    *(fTrackString.end() - 1) = string; 
+    fTrackString.appendClear(); 
 }
 
 void SkScriptEngine::unboxCallBack(_unboxCallBack func, void* userStorage) {
-       UserCallBack callBack;
-       callBack.fUnboxCallBack = func;
-       commonCallBack(kUnbox, callBack, userStorage);
+    UserCallBack callBack;
+    callBack.fUnboxCallBack = func;
+    commonCallBack(kUnbox, callBack, userStorage);
 }
 
 bool SkScriptEngine::ConvertTo(SkScriptEngine* engine, SkDisplayTypes toType, SkScriptValue* value ) {
-       SkASSERT(value);
-       if (SkDisplayType::IsEnum(nil /* fMaker */, toType))
-               toType = SkType_Int;
-       if (toType == SkType_Point || toType == SkType_3D_Point)
-               toType = SkType_Float;
-       if (toType == SkType_Drawable)
-               toType = SkType_Displayable;
-       SkDisplayTypes type = value->fType;
-       if (type == toType) 
-               return true;
-       SkOperand& operand = value->fOperand;
-       bool success = true;
-       switch (toType) {
-               case SkType_Int:
-                       if (type == SkType_Boolean)
-                               break;
-                       if (type == SkType_Float)
-                               operand.fS32 = SkScalarFloor(operand.fScalar);
-                       else {
-                               if (type != SkType_String) {
-                                       success = false;
-                                       break; // error
-                               }
-                               success = SkParse::FindS32(operand.fString->c_str(), &operand.fS32) != nil;
-                       }
-                       break;
-               case SkType_Float:
-                       if (type == SkType_Int) {
-                               if ((uint32_t)operand.fS32 == SK_NaN32)
-                                       operand.fScalar = SK_ScalarNaN;
-                               else if (SkAbs32(operand.fS32) == SK_MaxS32)
-                                       operand.fScalar = SkSign32(operand.fS32) * SK_ScalarMax;
-                               else
-                                       operand.fScalar = SkIntToScalar(operand.fS32);
-                       } else {
-                               if (type != SkType_String) {
-                                       success = false;
-                                       break; // error
-                               }
-                               success = SkParse::FindScalar(operand.fString->c_str(), &operand.fScalar) != nil;
-                       }
-                       break;
-               case SkType_String: {
-                       SkString* strPtr = new SkString();
-                       SkASSERT(engine);
-                       engine->track(strPtr);
-                       if (type == SkType_Int)
-                               strPtr->appendS32(operand.fS32);
-                       else if (type == SkType_Displayable) 
-                               SkASSERT(0); // must call through instance version instead of static version
-                       else {
-                               if (type != SkType_Float) {
-                                       success = false;
-                                       break;
-                               }
-                               strPtr->appendScalar(operand.fScalar);
-                       }
-                       operand.fString = strPtr;
-                       } break;
-               case SkType_Array: {
-                       SkTypedArray* array = new SkTypedArray(type);
-                       *array->append() = operand;
-                       engine->track(array);
-                       operand.fArray = array;
-                       } break;
-               default:
-                       SkASSERT(0);
-       }
-       value->fType = toType;
-       if (success == false)
-               engine->fError = kTypeConversionFailed;
-       return success;
+    SkASSERT(value);
+    if (SkDisplayType::IsEnum(nil /* fMaker */, toType))
+        toType = SkType_Int;
+    if (toType == SkType_Point || toType == SkType_3D_Point)
+        toType = SkType_Float;
+    if (toType == SkType_Drawable)
+        toType = SkType_Displayable;
+    SkDisplayTypes type = value->fType;
+    if (type == toType) 
+        return true;
+    SkOperand& operand = value->fOperand;
+    bool success = true;
+    switch (toType) {
+        case SkType_Int:
+            if (type == SkType_Boolean)
+                break;
+            if (type == SkType_Float)
+                operand.fS32 = SkScalarFloor(operand.fScalar);
+            else {
+                if (type != SkType_String) {
+                    success = false;
+                    break; // error
+                }
+                success = SkParse::FindS32(operand.fString->c_str(), &operand.fS32) != nil;
+            }
+            break;
+        case SkType_Float:
+            if (type == SkType_Int) {
+                if ((uint32_t)operand.fS32 == SK_NaN32)
+                    operand.fScalar = SK_ScalarNaN;
+                else if (SkAbs32(operand.fS32) == SK_MaxS32)
+                    operand.fScalar = SkSign32(operand.fS32) * SK_ScalarMax;
+                else
+                    operand.fScalar = SkIntToScalar(operand.fS32);
+            } else {
+                if (type != SkType_String) {
+                    success = false;
+                    break; // error
+                }
+                success = SkParse::FindScalar(operand.fString->c_str(), &operand.fScalar) != nil;
+            }
+            break;
+        case SkType_String: {
+            SkString* strPtr = new SkString();
+            SkASSERT(engine);
+            engine->track(strPtr);
+            if (type == SkType_Int)
+                strPtr->appendS32(operand.fS32);
+            else if (type == SkType_Displayable) 
+                SkASSERT(0); // must call through instance version instead of static version
+            else {
+                if (type != SkType_Float) {
+                    success = false;
+                    break;
+                }
+                strPtr->appendScalar(operand.fScalar);
+            }
+            operand.fString = strPtr;
+            } break;
+        case SkType_Array: {
+            SkTypedArray* array = new SkTypedArray(type);
+            *array->append() = operand;
+            engine->track(array);
+            operand.fArray = array;
+            } break;
+        default:
+            SkASSERT(0);
+    }
+    value->fType = toType;
+    if (success == false)
+        engine->fError = kTypeConversionFailed;
+    return success;
 }
 
 SkScalar SkScriptEngine::IntToScalar(S32 s32) {
-       SkScalar scalar;
-       if ((uint32_t)s32 == SK_NaN32)
-               scalar = SK_ScalarNaN;
-       else if (SkAbs32(s32) == SK_MaxS32)
-               scalar = SkSign32(s32) * SK_ScalarMax;
-       else
-               scalar = SkIntToScalar(s32);
-       return scalar;
+    SkScalar scalar;
+    if ((uint32_t)s32 == SK_NaN32)
+        scalar = SK_ScalarNaN;
+    else if (SkAbs32(s32) == SK_MaxS32)
+        scalar = SkSign32(s32) * SK_ScalarMax;
+    else
+        scalar = SkIntToScalar(s32);
+    return scalar;
 }
 
 SkDisplayTypes SkScriptEngine::ToDisplayType(SkOpType type) {
-       int val = type;
-       switch (val) {
-               case kNoType:
-                       return SkType_Unknown;
-               case kInt:
-                       return SkType_Int;
-               case kScalar:
-                       return SkType_Float;
-               case kString:
-                       return SkType_String;
-               case kArray:
-                       return SkType_Array;
-               case kObject:
-                       return SkType_Displayable;
-//             case kStruct:
-//                     return SkType_Structure;
-               default:
-                       SkASSERT(0);
-                       return SkType_Unknown;
-       }
+    int val = type;
+    switch (val) {
+        case kNoType:
+            return SkType_Unknown;
+        case kInt:
+            return SkType_Int;
+        case kScalar:
+            return SkType_Float;
+        case kString:
+            return SkType_String;
+        case kArray:
+            return SkType_Array;
+        case kObject:
+            return SkType_Displayable;
+//      case kStruct:
+//          return SkType_Structure;
+        default:
+            SkASSERT(0);
+            return SkType_Unknown;
+    }
 }
 
 SkScriptEngine::SkOpType SkScriptEngine::ToOpType(SkDisplayTypes type) {
-       if (SkDisplayType::IsDisplayable(nil /* fMaker */, type))
-               return (SkOpType) kObject;
-       if (SkDisplayType::IsEnum(nil /* fMaker */, type))
-               return kInt;
-       switch (type) {
-               case SkType_ARGB:
-               case SkType_MSec:
-               case SkType_Int:
-                       return kInt;
-               case SkType_Float:
-               case SkType_Point:
-               case SkType_3D_Point:
-                       return kScalar;
-               case SkType_Base64:
-               case SkType_DynamicString:
-               case SkType_String:
-                       return kString;
-               case SkType_Array:
-                       return (SkOpType) kArray;
-               case SkType_Unknown:
-                       return kNoType;
-               default:
-                       SkASSERT(0);
-                       return kNoType;
-       }
+    if (SkDisplayType::IsDisplayable(nil /* fMaker */, type))
+        return (SkOpType) kObject;
+    if (SkDisplayType::IsEnum(nil /* fMaker */, type))
+        return kInt;
+    switch (type) {
+        case SkType_ARGB:
+        case SkType_MSec:
+        case SkType_Int:
+            return kInt;
+        case SkType_Float:
+        case SkType_Point:
+        case SkType_3D_Point:
+            return kScalar;
+        case SkType_Base64:
+        case SkType_DynamicString:
+        case SkType_String:
+            return kString;
+        case SkType_Array:
+            return (SkOpType) kArray;
+        case SkType_Unknown:
+            return kNoType;
+        default:
+            SkASSERT(0);
+            return kNoType;
+    }
 }
 
 bool SkScriptEngine::ValueToString(SkScriptValue value, SkString* string) {
-       switch (value.fType) {
-               case kInt:
-                       string->reset();
-                       string->appendS32(value.fOperand.fS32);
-                       break;
-               case kScalar:
-                       string->reset();
-                       string->appendScalar(value.fOperand.fScalar);
-                       break;
-               case kString:
-                       string->set(*value.fOperand.fString);
-                       break;
-               default:
-                       SkASSERT(0);
-                       return false;
-       }
-       return true; // no error
+    switch (value.fType) {
+        case kInt:
+            string->reset();
+            string->appendS32(value.fOperand.fS32);
+            break;
+        case kScalar:
+            string->reset();
+            string->appendScalar(value.fOperand.fScalar);
+            break;
+        case kString:
+            string->set(*value.fOperand.fString);
+            break;
+        default:
+            SkASSERT(0);
+            return false;
+    }
+    return true; // no error
 }
 
 #ifdef SK_SUPPORT_UNITTEST
@@ -1645,256 +1662,256 @@ bool SkScriptEngine::ValueToString(SkScriptValue value, SkString* string) {
     #define testScalar(expression) { #expression, SkType_Float, 0, (float) expression, DEF_STRING_ANSWER }
     #define testRemainder(exp1, exp2) { #exp1 "%" #exp2, SkType_Float, 0, sk_float_mod(exp1, exp2), DEF_STRING_ANSWER }
 #else
-       #ifdef SK_CAN_USE_FLOAT
-               #define testScalar(expression) { #expression, SkType_Float, 0, (int) ((expression) * 65536.0f), DEF_STRING_ANSWER }
-               #define testRemainder(exp1, exp2) { #exp1 "%" #exp2, SkType_Float, 0, (int) (sk_float_mod(exp1, exp2)  * 65536.0f), DEF_STRING_ANSWER }
-       #endif
+    #ifdef SK_CAN_USE_FLOAT
+        #define testScalar(expression) { #expression, SkType_Float, 0, (int) ((expression) * 65536.0f), DEF_STRING_ANSWER }
+        #define testRemainder(exp1, exp2) { #exp1 "%" #exp2, SkType_Float, 0, (int) (sk_float_mod(exp1, exp2)  * 65536.0f), DEF_STRING_ANSWER }
+    #endif
 #endif
 #define testTrue(expression) { #expression, SkType_Int, 1, DEF_SCALAR_ANSWER, DEF_STRING_ANSWER }
 #define testFalse(expression) { #expression, SkType_Int, 0, DEF_SCALAR_ANSWER, DEF_STRING_ANSWER }
 
 #if !defined(SK_BUILD_FOR_BREW)
 static const SkScriptNAnswer scriptTests[]  = {
-       testInt(1>1/2),
-       testInt((6+7)*8),
-       testInt(0&&1?2:3),
-       testInt(3*(4+5)),
+    testInt(1>1/2),
+    testInt((6+7)*8),
+    testInt(0&&1?2:3),
+    testInt(3*(4+5)),
 #ifdef SK_CAN_USE_FLOAT
-       testScalar(1.0+2.0), 
-       testScalar(1.0+5), 
-       testScalar(3.0-1.0), 
-       testScalar(6-1.0), 
-       testScalar(- -5.5- -1.5), 
-       testScalar(2.5*6.), 
-       testScalar(0.5*4), 
-       testScalar(4.5/.5), 
-       testScalar(9.5/19), 
-       testRemainder(9.5, 0.5), 
-       testRemainder(9.,2), 
-       testRemainder(9,2.5),
-       testRemainder(-9,2.5),
-       testTrue(-9==-9.0),
-       testTrue(-9.==-4.0-5),
-       testTrue(-9.*1==-4-5),
-       testFalse(-9!=-9.0),
-       testFalse(-9.!=-4.0-5),
-       testFalse(-9.*1!=-4-5),
+    testScalar(1.0+2.0), 
+    testScalar(1.0+5), 
+    testScalar(3.0-1.0), 
+    testScalar(6-1.0), 
+    testScalar(- -5.5- -1.5), 
+    testScalar(2.5*6.), 
+    testScalar(0.5*4), 
+    testScalar(4.5/.5), 
+    testScalar(9.5/19), 
+    testRemainder(9.5, 0.5), 
+    testRemainder(9.,2), 
+    testRemainder(9,2.5),
+    testRemainder(-9,2.5),
+    testTrue(-9==-9.0),
+    testTrue(-9.==-4.0-5),
+    testTrue(-9.*1==-4-5),
+    testFalse(-9!=-9.0),
+    testFalse(-9.!=-4.0-5),
+    testFalse(-9.*1!=-4-5),
 #endif
-       testInt(0x123),
-       testInt(0XABC),
-       testInt(0xdeadBEEF),
-       {       "'123'+\"456\"", SkType_String, 0, 0, "123456" },
-       {       "123+\"456\"", SkType_String, 0, 0, "123456" },
-       {       "'123'+456", SkType_String, 0, 0, "123456" },
-       {       "'123'|\"456\"", SkType_Int, 123|456, DEF_SCALAR_ANSWER, DEF_STRING_ANSWER },
-       {       "123|\"456\"", SkType_Int, 123|456, DEF_SCALAR_ANSWER, DEF_STRING_ANSWER },
-       {       "'123'|456", SkType_Int, 123|456, DEF_SCALAR_ANSWER, DEF_STRING_ANSWER },
-       {       "'2'<11", SkType_Int, 1, DEF_SCALAR_ANSWER, DEF_STRING_ANSWER },
-       {       "2<'11'", SkType_Int, 1, DEF_SCALAR_ANSWER, DEF_STRING_ANSWER },
-       {       "'2'<'11'", SkType_Int, 0, DEF_SCALAR_ANSWER, DEF_STRING_ANSWER },
-       testInt(123),
-       testInt(-345),
-       testInt(+678),
-       testInt(1+2+3),
-       testInt(3*4+5),
-       testInt(6+7*8),
-       testInt(-1-2-8/4),
-       testInt(-9%4),
-       testInt(9%-4),
-       testInt(-9%-4),
-       testInt(123|978),
-       testInt(123&978),
-       testInt(123^978),
-       testInt(2<<4),
-       testInt(99>>3),
-       testInt(~55),
-       testInt(~~55),
-       testInt(!55),
-       testInt(!!55),
-       // both int
-       testInt(2<2),
-       testInt(2<11),
-       testInt(20<11),
-       testInt(2<=2),
-       testInt(2<=11),
-       testInt(20<=11),
-       testInt(2>2),
-       testInt(2>11),
-       testInt(20>11),
-       testInt(2>=2),
-       testInt(2>=11),
-       testInt(20>=11),
-       testInt(2==2),
-       testInt(2==11),
-       testInt(20==11),
-       testInt(2!=2),
-       testInt(2!=11),
-       testInt(20!=11),
+    testInt(0x123),
+    testInt(0XABC),
+    testInt(0xdeadBEEF),
+    {   "'123'+\"456\"", SkType_String, 0, 0, "123456" },
+    {   "123+\"456\"", SkType_String, 0, 0, "123456" },
+    {   "'123'+456", SkType_String, 0, 0, "123456" },
+    {   "'123'|\"456\"", SkType_Int, 123|456, DEF_SCALAR_ANSWER, DEF_STRING_ANSWER },
+    {   "123|\"456\"", SkType_Int, 123|456, DEF_SCALAR_ANSWER, DEF_STRING_ANSWER },
+    {   "'123'|456", SkType_Int, 123|456, DEF_SCALAR_ANSWER, DEF_STRING_ANSWER },
+    {   "'2'<11", SkType_Int, 1, DEF_SCALAR_ANSWER, DEF_STRING_ANSWER },
+    {   "2<'11'", SkType_Int, 1, DEF_SCALAR_ANSWER, DEF_STRING_ANSWER },
+    {   "'2'<'11'", SkType_Int, 0, DEF_SCALAR_ANSWER, DEF_STRING_ANSWER },
+    testInt(123),
+    testInt(-345),
+    testInt(+678),
+    testInt(1+2+3),
+    testInt(3*4+5),
+    testInt(6+7*8),
+    testInt(-1-2-8/4),
+    testInt(-9%4),
+    testInt(9%-4),
+    testInt(-9%-4),
+    testInt(123|978),
+    testInt(123&978),
+    testInt(123^978),
+    testInt(2<<4),
+    testInt(99>>3),
+    testInt(~55),
+    testInt(~~55),
+    testInt(!55),
+    testInt(!!55),
+    // both int
+    testInt(2<2),
+    testInt(2<11),
+    testInt(20<11),
+    testInt(2<=2),
+    testInt(2<=11),
+    testInt(20<=11),
+    testInt(2>2),
+    testInt(2>11),
+    testInt(20>11),
+    testInt(2>=2),
+    testInt(2>=11),
+    testInt(20>=11),
+    testInt(2==2),
+    testInt(2==11),
+    testInt(20==11),
+    testInt(2!=2),
+    testInt(2!=11),
+    testInt(20!=11),
 #ifdef SK_CAN_USE_FLOAT
-       // left int, right scalar
-       testInt(2<2.),
-       testInt(2<11.),
-       testInt(20<11.),
-       testInt(2<=2.),
-       testInt(2<=11.),
-       testInt(20<=11.),
-       testInt(2>2.),
-       testInt(2>11.),
-       testInt(20>11.),
-       testInt(2>=2.),
-       testInt(2>=11.),
-       testInt(20>=11.),
-       testInt(2==2.),
-       testInt(2==11.),
-       testInt(20==11.),
-       testInt(2!=2.),
-       testInt(2!=11.),
-       testInt(20!=11.),
-       // left scalar, right int
-               testInt(2.<2),
-       testInt(2.<11),
-       testInt(20.<11),
-       testInt(2.<=2),
-       testInt(2.<=11),
-       testInt(20.<=11),
-       testInt(2.>2),
-       testInt(2.>11),
-       testInt(20.>11),
-       testInt(2.>=2),
-       testInt(2.>=11),
-       testInt(20.>=11),
-       testInt(2.==2),
-       testInt(2.==11),
-       testInt(20.==11),
-       testInt(2.!=2),
-       testInt(2.!=11),
-       testInt(20.!=11),
-       // both scalar
-       testInt(2.<11.),
-       testInt(20.<11.),
-       testInt(2.<=2.),
-       testInt(2.<=11.),
-       testInt(20.<=11.),
-       testInt(2.>2.),
-       testInt(2.>11.),
-       testInt(20.>11.),
-       testInt(2.>=2.),
-       testInt(2.>=11.),
-       testInt(20.>=11.),
-       testInt(2.==2.),
-       testInt(2.==11.),
-       testInt(20.==11.),
-       testInt(2.!=2.),
-       testInt(2.!=11.),
-       testInt(20.!=11.),
+    // left int, right scalar
+    testInt(2<2.),
+    testInt(2<11.),
+    testInt(20<11.),
+    testInt(2<=2.),
+    testInt(2<=11.),
+    testInt(20<=11.),
+    testInt(2>2.),
+    testInt(2>11.),
+    testInt(20>11.),
+    testInt(2>=2.),
+    testInt(2>=11.),
+    testInt(20>=11.),
+    testInt(2==2.),
+    testInt(2==11.),
+    testInt(20==11.),
+    testInt(2!=2.),
+    testInt(2!=11.),
+    testInt(20!=11.),
+    // left scalar, right int
+        testInt(2.<2),
+    testInt(2.<11),
+    testInt(20.<11),
+    testInt(2.<=2),
+    testInt(2.<=11),
+    testInt(20.<=11),
+    testInt(2.>2),
+    testInt(2.>11),
+    testInt(20.>11),
+    testInt(2.>=2),
+    testInt(2.>=11),
+    testInt(20.>=11),
+    testInt(2.==2),
+    testInt(2.==11),
+    testInt(20.==11),
+    testInt(2.!=2),
+    testInt(2.!=11),
+    testInt(20.!=11),
+    // both scalar
+    testInt(2.<11.),
+    testInt(20.<11.),
+    testInt(2.<=2.),
+    testInt(2.<=11.),
+    testInt(20.<=11.),
+    testInt(2.>2.),
+    testInt(2.>11.),
+    testInt(20.>11.),
+    testInt(2.>=2.),
+    testInt(2.>=11.),
+    testInt(20.>=11.),
+    testInt(2.==2.),
+    testInt(2.==11.),
+    testInt(20.==11.),
+    testInt(2.!=2.),
+    testInt(2.!=11.),
+    testInt(20.!=11.),
 #endif
-       // int, string (string is int)
-       testFalse(2<'2'),
-       testTrue(2<'11'),
-       testFalse(20<'11'),
-       testTrue(2<='2'),
-       testTrue(2<='11'),
-       testFalse(20<='11'),
-       testFalse(2>'2'),
-       testFalse(2>'11'),
-       testTrue(20>'11'),
-       testTrue(2>='2'),
-       testFalse(2>='11'),
-       testTrue(20>='11'),
-       testTrue(2=='2'),
-       testFalse(2=='11'),
-       testFalse(2!='2'),
-       testTrue(2!='11'),
-       // int, string (string is scalar)
-       testFalse(2<'2.'),
-       testTrue(2<'11.'),
-       testFalse(20<'11.'),
-       testTrue(2=='2.'),
-       testFalse(2=='11.'),
+    // int, string (string is int)
+    testFalse(2<'2'),
+    testTrue(2<'11'),
+    testFalse(20<'11'),
+    testTrue(2<='2'),
+    testTrue(2<='11'),
+    testFalse(20<='11'),
+    testFalse(2>'2'),
+    testFalse(2>'11'),
+    testTrue(20>'11'),
+    testTrue(2>='2'),
+    testFalse(2>='11'),
+    testTrue(20>='11'),
+    testTrue(2=='2'),
+    testFalse(2=='11'),
+    testFalse(2!='2'),
+    testTrue(2!='11'),
+    // int, string (string is scalar)
+    testFalse(2<'2.'),
+    testTrue(2<'11.'),
+    testFalse(20<'11.'),
+    testTrue(2=='2.'),
+    testFalse(2=='11.'),
 #ifdef SK_CAN_USE_FLOAT
-       // scalar, string
-       testFalse(2.<'2.'),
-       testTrue(2.<'11.'),
-       testFalse(20.<'11.'),
-       testTrue(2.=='2.'),
-       testFalse(2.=='11.'),
-       // string, int
-       testFalse('2'<2),
-       testTrue('2'<11),
-       testFalse('20'<11),
-       testTrue('2'==2),
-       testFalse('2'==11),
-       // string, scalar
-       testFalse('2'<2.),
-       testTrue('2'<11.),
-       testFalse('20'<11.),
-       testTrue('2'==2.),
-       testFalse('2'==11.),
+    // scalar, string
+    testFalse(2.<'2.'),
+    testTrue(2.<'11.'),
+    testFalse(20.<'11.'),
+    testTrue(2.=='2.'),
+    testFalse(2.=='11.'),
+    // string, int
+    testFalse('2'<2),
+    testTrue('2'<11),
+    testFalse('20'<11),
+    testTrue('2'==2),
+    testFalse('2'==11),
+    // string, scalar
+    testFalse('2'<2.),
+    testTrue('2'<11.),
+    testFalse('20'<11.),
+    testTrue('2'==2.),
+    testFalse('2'==11.),
 #endif
-       // string, string
-       testFalse('2'<'2'),
-       testFalse('2'<'11'),
-       testFalse('20'<'11'),
-       testTrue('2'=='2'),
-       testFalse('2'=='11'),
-       // logic
-       testInt(1?2:3),
-       testInt(0?2:3),
-       testInt(1&&2||3),
-       testInt(1&&0||3),
-       testInt(1&&0||0),
-       testInt(1||0&&3),
-       testInt(0||0&&3),
-       testInt(0||1&&3),
-       testInt(1?(2?3:4):5),
-       testInt(0?(2?3:4):5),
-       testInt(1?(0?3:4):5),
-       testInt(0?(0?3:4):5),
-       testInt(1?2?3:4:5),
-       testInt(0?2?3:4:5),
-       testInt(1?0?3:4:5),
-       testInt(0?0?3:4:5),
-       
-       testInt(1?2:(3?4:5)),
-       testInt(0?2:(3?4:5)),
-       testInt(1?0:(3?4:5)),
-       testInt(0?0:(3?4:5)),
-       testInt(1?2:3?4:5),
-       testInt(0?2:3?4:5),
-       testInt(1?0:3?4:5),
-       testInt(0?0:3?4:5)
+    // string, string
+    testFalse('2'<'2'),
+    testFalse('2'<'11'),
+    testFalse('20'<'11'),
+    testTrue('2'=='2'),
+    testFalse('2'=='11'),
+    // logic
+    testInt(1?2:3),
+    testInt(0?2:3),
+    testInt(1&&2||3),
+    testInt(1&&0||3),
+    testInt(1&&0||0),
+    testInt(1||0&&3),
+    testInt(0||0&&3),
+    testInt(0||1&&3),
+    testInt(1?(2?3:4):5),
+    testInt(0?(2?3:4):5),
+    testInt(1?(0?3:4):5),
+    testInt(0?(0?3:4):5),
+    testInt(1?2?3:4:5),
+    testInt(0?2?3:4:5),
+    testInt(1?0?3:4:5),
+    testInt(0?0?3:4:5),
+    
+    testInt(1?2:(3?4:5)),
+    testInt(0?2:(3?4:5)),
+    testInt(1?0:(3?4:5)),
+    testInt(0?0:(3?4:5)),
+    testInt(1?2:3?4:5),
+    testInt(0?2:3?4:5),
+    testInt(1?0:3?4:5),
+    testInt(0?0:3?4:5)
 #ifdef SK_CAN_USE_FLOAT
-       , {     "123.5", SkType_Float, 0, SkIntToScalar(123) + SK_Scalar1/2, DEF_STRING_ANSWER }
+    , { "123.5", SkType_Float, 0, SkIntToScalar(123) + SK_Scalar1/2, DEF_STRING_ANSWER }
 #endif
 };
 #endif // build for brew
 
-#define SkScriptNAnswer_testCount      SK_ARRAY_COUNT(scriptTests)
+#define SkScriptNAnswer_testCount   SK_ARRAY_COUNT(scriptTests)
 
 void SkScriptEngine::UnitTest() {
 #if !defined(SK_BUILD_FOR_BREW)
-       for (unsigned index = 0; index < SkScriptNAnswer_testCount; index++) {
-               SkScriptEngine engine(SkScriptEngine::ToOpType(scriptTests[index].fType));
-               SkScriptValue value;
-               const char* script = scriptTests[index].fScript;
-               SkASSERT(engine.evaluateScript(&script, &value) == true);
-               SkASSERT(value.fType == scriptTests[index].fType);
-               SkScalar error;
-               switch (value.fType) {
-                       case SkType_Int:
-                               SkASSERT(value.fOperand.fS32 == scriptTests[index].fIntAnswer);
-                               break;
-                       case SkType_Float:
-                               error = SkScalarAbs(value.fOperand.fScalar - scriptTests[index].fScalarAnswer);
-                               SkASSERT(error < SK_Scalar1 / 10000);
-                               break;
-                       case SkType_String:
-                               SkASSERT(strcmp(value.fOperand.fString->c_str(), scriptTests[index].fStringAnswer) == 0);
-                               break;
-                       default:
-                               SkASSERT(0);
-               }
-       }
+    for (unsigned index = 0; index < SkScriptNAnswer_testCount; index++) {
+        SkScriptEngine engine(SkScriptEngine::ToOpType(scriptTests[index].fType));
+        SkScriptValue value;
+        const char* script = scriptTests[index].fScript;
+        SkASSERT(engine.evaluateScript(&script, &value) == true);
+        SkASSERT(value.fType == scriptTests[index].fType);
+        SkScalar error;
+        switch (value.fType) {
+            case SkType_Int:
+                SkASSERT(value.fOperand.fS32 == scriptTests[index].fIntAnswer);
+                break;
+            case SkType_Float:
+                error = SkScalarAbs(value.fOperand.fScalar - scriptTests[index].fScalarAnswer);
+                SkASSERT(error < SK_Scalar1 / 10000);
+                break;
+            case SkType_String:
+                SkASSERT(strcmp(value.fOperand.fString->c_str(), scriptTests[index].fStringAnswer) == 0);
+                break;
+            default:
+                SkASSERT(0);
+        }
+    }
 #endif
 }
 #endif
index e172c9e..d683a3d 100644 (file)
@@ -1,3 +1,20 @@
+/* libs/graphics/animator/SkScript.h
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #ifndef SkScript_DEFINED
 #define SkScript_DEFINED
 
@@ -10,246 +27,246 @@ class SkAnimateMaker;
 
 class SkScriptEngine {
 public:
-       enum Error {
-               kNoError,
-               kArrayIndexOutOfBounds,
-               kCouldNotFindReferencedID,
-               kDotOperatorExpectsObject,
-               kErrorInArrrayIndex,
-               kErrorInFunctionParameters,
-               kExpectedArray,
-               kExpectedBooleanExpression,
-               kExpectedFieldName,
-               kExpectedHex,
-               kExpectedIntForConditionOperator,
-               kExpectedNumber,
-               kExpectedNumberForArrayIndex,
-               kExpectedOperator,
-               kExpectedToken,
-               kExpectedTokenBeforeDotOperator,
-               kExpectedValue,
-               kHandleMemberFailed,
-               kHandleMemberFunctionFailed,
-               kHandleUnboxFailed,
-               kIndexOutOfRange,
-               kMismatchedArrayBrace,
-               kMismatchedBrackets,
-               kNoFunctionHandlerFound,
-               kPrematureEnd,
-               kTooManyParameters,
-               kTypeConversionFailed,
-               kUnterminatedString
-       };
+    enum Error {
+        kNoError,
+        kArrayIndexOutOfBounds,
+        kCouldNotFindReferencedID,
+        kDotOperatorExpectsObject,
+        kErrorInArrrayIndex,
+        kErrorInFunctionParameters,
+        kExpectedArray,
+        kExpectedBooleanExpression,
+        kExpectedFieldName,
+        kExpectedHex,
+        kExpectedIntForConditionOperator,
+        kExpectedNumber,
+        kExpectedNumberForArrayIndex,
+        kExpectedOperator,
+        kExpectedToken,
+        kExpectedTokenBeforeDotOperator,
+        kExpectedValue,
+        kHandleMemberFailed,
+        kHandleMemberFunctionFailed,
+        kHandleUnboxFailed,
+        kIndexOutOfRange,
+        kMismatchedArrayBrace,
+        kMismatchedBrackets,
+        kNoFunctionHandlerFound,
+        kPrematureEnd,
+        kTooManyParameters,
+        kTypeConversionFailed,
+        kUnterminatedString
+    };
 
-       enum SkOpType {
-               kNoType,
-               kInt = 1,
-               kScalar = 2,
-               kString = 4,
-               kArray = 8,
-               kObject = 16
-//             kStruct = 32
-       };
+    enum SkOpType {
+        kNoType,
+        kInt = 1,
+        kScalar = 2,
+        kString = 4,
+        kArray = 8,
+        kObject = 16
+//      kStruct = 32
+    };
 
-       typedef bool (*_boxCallBack)(void* userStorage, SkScriptValue* result);
-       typedef bool (*_functionCallBack)(const char* func, size_t len, SkTDArray<SkScriptValue>& params,
-               void* userStorage, SkScriptValue* result);
-       typedef bool (*_memberCallBack)(const char* member, size_t len, void* object, 
-               void* userStorage, SkScriptValue* result);
-       typedef bool (*_memberFunctionCallBack)(const char* member, size_t len, void* object, 
-               SkTDArray<SkScriptValue>& params, void* userStorage, SkScriptValue* result);
-//     typedef bool (*_objectToStringCallBack)(void* object, void* userStorage, SkScriptValue* result);
-       typedef bool (*_propertyCallBack)(const char* prop, size_t len, void* userStorage, SkScriptValue* result);
-       typedef bool (*_unboxCallBack)(void* userStorage, SkScriptValue* result);
-       SkScriptEngine(SkOpType returnType);
-       ~SkScriptEngine();
-       void boxCallBack(_boxCallBack func, void* userStorage);
-       bool convertTo(SkDisplayTypes , SkScriptValue* );
-       bool evaluateScript(const char** script, SkScriptValue* value);
-       void forget(SkTypedArray* array);
-       void functionCallBack(_functionCallBack func, void* userStorage);
-       Error getError() const { return fError; }
+    typedef bool (*_boxCallBack)(void* userStorage, SkScriptValue* result);
+    typedef bool (*_functionCallBack)(const char* func, size_t len, SkTDArray<SkScriptValue>& params,
+        void* userStorage, SkScriptValue* result);
+    typedef bool (*_memberCallBack)(const char* member, size_t len, void* object, 
+        void* userStorage, SkScriptValue* result);
+    typedef bool (*_memberFunctionCallBack)(const char* member, size_t len, void* object, 
+        SkTDArray<SkScriptValue>& params, void* userStorage, SkScriptValue* result);
+//  typedef bool (*_objectToStringCallBack)(void* object, void* userStorage, SkScriptValue* result);
+    typedef bool (*_propertyCallBack)(const char* prop, size_t len, void* userStorage, SkScriptValue* result);
+    typedef bool (*_unboxCallBack)(void* userStorage, SkScriptValue* result);
+    SkScriptEngine(SkOpType returnType);
+    ~SkScriptEngine();
+    void boxCallBack(_boxCallBack func, void* userStorage);
+    bool convertTo(SkDisplayTypes , SkScriptValue* );
+    bool evaluateScript(const char** script, SkScriptValue* value);
+    void forget(SkTypedArray* array);
+    void functionCallBack(_functionCallBack func, void* userStorage);
+    Error getError() const { return fError; }
 #ifdef SK_DEBUG
-       bool getErrorString(SkString* err) const;
+    bool getErrorString(SkString* err) const;
 #endif
-       void memberCallBack(_memberCallBack , void* userStorage);
-       void memberFunctionCallBack(_memberFunctionCallBack , void* userStorage);
-//     void objectToStringCallBack(_objectToStringCallBack , void* userStorage);
-       void propertyCallBack(_propertyCallBack prop, void* userStorage);
-       void track(SkTypedArray* array);
-       void track(SkString* string);
-       void unboxCallBack(_unboxCallBack func, void* userStorage);
-       static bool ConvertTo(SkScriptEngine* , SkDisplayTypes toType, SkScriptValue* value);
-       static SkScalar IntToScalar(S32 );
-       static SkDisplayTypes ToDisplayType(SkOpType type);
-       static SkOpType ToOpType(SkDisplayTypes type);
-       static bool ValueToString(SkScriptValue value, SkString* string);
+    void memberCallBack(_memberCallBack , void* userStorage);
+    void memberFunctionCallBack(_memberFunctionCallBack , void* userStorage);
+//  void objectToStringCallBack(_objectToStringCallBack , void* userStorage);
+    void propertyCallBack(_propertyCallBack prop, void* userStorage);
+    void track(SkTypedArray* array);
+    void track(SkString* string);
+    void unboxCallBack(_unboxCallBack func, void* userStorage);
+    static bool ConvertTo(SkScriptEngine* , SkDisplayTypes toType, SkScriptValue* value);
+    static SkScalar IntToScalar(S32 );
+    static SkDisplayTypes ToDisplayType(SkOpType type);
+    static SkOpType ToOpType(SkDisplayTypes type);
+    static bool ValueToString(SkScriptValue value, SkString* string);
 
-       enum CallBackType {
-               kBox,
-               kFunction,
-               kMember,
-               kMemberFunction,
-       //      kObjectToString,
-               kProperty,
-               kUnbox
-       };
+    enum CallBackType {
+        kBox,
+        kFunction,
+        kMember,
+        kMemberFunction,
+    //  kObjectToString,
+        kProperty,
+        kUnbox
+    };
 
-       struct UserCallBack {
-               CallBackType fCallBackType;
-               void* fUserStorage;
-               union {
-                       _boxCallBack fBoxCallBack;
-                       _functionCallBack fFunctionCallBack;
-                       _memberCallBack fMemberCallBack;
-                       _memberFunctionCallBack fMemberFunctionCallBack;
-       //              _objectToStringCallBack fObjectToStringCallBack;
-                       _propertyCallBack fPropertyCallBack;
-                       _unboxCallBack fUnboxCallBack;
-               };
-       };
+    struct UserCallBack {
+        CallBackType fCallBackType;
+        void* fUserStorage;
+        union {
+            _boxCallBack fBoxCallBack;
+            _functionCallBack fFunctionCallBack;
+            _memberCallBack fMemberCallBack;
+            _memberFunctionCallBack fMemberFunctionCallBack;
+    //      _objectToStringCallBack fObjectToStringCallBack;
+            _propertyCallBack fPropertyCallBack;
+            _unboxCallBack fUnboxCallBack;
+        };
+    };
 
-       enum SkOp {
-               kUnassigned,
-               kAdd,
-               kAddInt = kAdd,
-               kAddScalar,
-               kAddString,     // string concat
-               kArrayOp,
-               kBitAnd,
-               kBitNot,
-               kBitOr,
-               kDivide,
-               kDivideInt = kDivide,
-               kDivideScalar,
-               kElse,
-               kEqual,
-               kEqualInt = kEqual,
-               kEqualScalar,
-               kEqualString,
-               kFlipOps,
-               kGreaterEqual,
-               kGreaterEqualInt = kGreaterEqual,
-               kGreaterEqualScalar,
-               kGreaterEqualString,
-               kIf,
-               kLogicalAnd,
-               kLogicalNot,
-               kLogicalOr,
-               kMinus,
-               kMinusInt = kMinus,
-               kMinusScalar,
-               kModulo,
-               kModuloInt = kModulo,
-               kModuloScalar,
-               kMultiply,
-               kMultiplyInt = kMultiply,
-               kMultiplyScalar,
-               kParen,
-               kShiftLeft,
-               kShiftRight,    // signed
-               kSubtract,
-               kSubtractInt = kSubtract,
-               kSubtractScalar,
-               kXor,
-               kArtificialOp = 0x40
-       };
+    enum SkOp {
+        kUnassigned,
+        kAdd,
+        kAddInt = kAdd,
+        kAddScalar,
+        kAddString, // string concat
+        kArrayOp,
+        kBitAnd,
+        kBitNot,
+        kBitOr,
+        kDivide,
+        kDivideInt = kDivide,
+        kDivideScalar,
+        kElse,
+        kEqual,
+        kEqualInt = kEqual,
+        kEqualScalar,
+        kEqualString,
+        kFlipOps,
+        kGreaterEqual,
+        kGreaterEqualInt = kGreaterEqual,
+        kGreaterEqualScalar,
+        kGreaterEqualString,
+        kIf,
+        kLogicalAnd,
+        kLogicalNot,
+        kLogicalOr,
+        kMinus,
+        kMinusInt = kMinus,
+        kMinusScalar,
+        kModulo,
+        kModuloInt = kModulo,
+        kModuloScalar,
+        kMultiply,
+        kMultiplyInt = kMultiply,
+        kMultiplyScalar,
+        kParen,
+        kShiftLeft,
+        kShiftRight,    // signed
+        kSubtract,
+        kSubtractInt = kSubtract,
+        kSubtractScalar,
+        kXor,
+        kArtificialOp = 0x40
+    };
 
-       enum SkOpBias {
-               kNoBias,
-               kTowardsNumber = 0,
-               kTowardsString
-       };
-       
+    enum SkOpBias {
+        kNoBias,
+        kTowardsNumber = 0,
+        kTowardsString
+    };
+    
 protected:
 
-       struct SkOperatorAttributes {
-               unsigned int fLeftType : 3;     // SkOpType, but only lower values
-               unsigned int fRightType : 3;     // SkOpType, but only lower values
-               SkOpBias fBias : 1;
-       };
+    struct SkOperatorAttributes {
+        unsigned int fLeftType : 3; // SkOpType, but only lower values
+        unsigned int fRightType : 3;     // SkOpType, but only lower values
+        SkOpBias fBias : 1;
+    };
 
-       struct SkSuppress {     // !!! could be compressed to a long
-               SkOp fOperator; // operand which enabled suppression
-               int fOpStackDepth; // depth when suppression operator was found
-               SkBool8 fSuppress; // set if suppression happens now, as opposed to later
-               SkBool8 fElse; // set on the : half of ? :
-       };
+    struct SkSuppress { // !!! could be compressed to a long
+        SkOp fOperator; // operand which enabled suppression
+        int fOpStackDepth; // depth when suppression operator was found
+        SkBool8 fSuppress; // set if suppression happens now, as opposed to later
+        SkBool8 fElse; // set on the : half of ? :
+    };
 
-       static const SkOperatorAttributes gOpAttributes[];
-       static const signed char gPrecedence[];
-       int arithmeticOp(char ch, char nextChar, bool lastPush);
-       void commonCallBack(CallBackType type, UserCallBack& callBack, void* userStorage);
-       bool convertParams(SkTDArray<SkScriptValue>&, const SkFunctionParamType* ,
-                                                                       int paramTypeCount);
-       void convertToString(SkOperand& operand, SkDisplayTypes type) {
-               SkScriptValue scriptValue;
-               scriptValue.fOperand = operand;
-               scriptValue.fType = type;
-               convertTo(SkType_String, &scriptValue);
-               operand = scriptValue.fOperand;
-       }
-       bool evaluateDot(const char*& script, bool suppressed);
-       bool evaluateDotParam(const char*& script, bool suppressed, const char* field, size_t fieldLength);
-       bool functionParams(const char** scriptPtr, SkTDArray<SkScriptValue>& params);
-       bool handleArrayIndexer(const char** scriptPtr, bool suppressed);
-       bool handleBox(SkScriptValue* value);
-       bool handleFunction(const char** scriptPtr, bool suppressed);
-       bool handleMember(const char* field, size_t len, void* object);
-       bool handleMemberFunction(const char* field, size_t len, void* object, SkTDArray<SkScriptValue>& params);
-//     bool handleObjectToString(void* object);
-       bool handleProperty(bool suppressed);
-       bool handleUnbox(SkScriptValue* scriptValue);
-       bool innerScript(const char** scriptPtr, SkScriptValue* value);
-       int logicalOp(char ch, char nextChar);
-       Error opError();
-       bool processOp();
-       void setAnimateMaker(SkAnimateMaker* maker) { fMaker = maker; }
-       bool setError(Error , const char* pos);
-       enum SkBraceStyle {
-       //      kStructBrace,
-               kArrayBrace,
-               kFunctionBrace
-       };
+    static const SkOperatorAttributes gOpAttributes[];
+    static const signed char gPrecedence[];
+    int arithmeticOp(char ch, char nextChar, bool lastPush);
+    void commonCallBack(CallBackType type, UserCallBack& callBack, void* userStorage);
+    bool convertParams(SkTDArray<SkScriptValue>&, const SkFunctionParamType* ,
+                                    int paramTypeCount);
+    void convertToString(SkOperand& operand, SkDisplayTypes type) {
+        SkScriptValue scriptValue;
+        scriptValue.fOperand = operand;
+        scriptValue.fType = type;
+        convertTo(SkType_String, &scriptValue);
+        operand = scriptValue.fOperand;
+    }
+    bool evaluateDot(const char*& script, bool suppressed);
+    bool evaluateDotParam(const char*& script, bool suppressed, const char* field, size_t fieldLength);
+    bool functionParams(const char** scriptPtr, SkTDArray<SkScriptValue>& params);
+    bool handleArrayIndexer(const char** scriptPtr, bool suppressed);
+    bool handleBox(SkScriptValue* value);
+    bool handleFunction(const char** scriptPtr, bool suppressed);
+    bool handleMember(const char* field, size_t len, void* object);
+    bool handleMemberFunction(const char* field, size_t len, void* object, SkTDArray<SkScriptValue>& params);
+//  bool handleObjectToString(void* object);
+    bool handleProperty(bool suppressed);
+    bool handleUnbox(SkScriptValue* scriptValue);
+    bool innerScript(const char** scriptPtr, SkScriptValue* value);
+    int logicalOp(char ch, char nextChar);
+    Error opError();
+    bool processOp();
+    void setAnimateMaker(SkAnimateMaker* maker) { fMaker = maker; }
+    bool setError(Error , const char* pos);
+    enum SkBraceStyle {
+    //  kStructBrace,
+        kArrayBrace,
+        kFunctionBrace
+    };
 
 #if 0
-       SkIntArray(SkBraceStyle) fBraceStack;           // curly, square, function paren
-       SkIntArray(SkOp) fOpStack;
-       SkIntArray(SkOpType) fTypeStack;
-       SkTDOperandArray fOperandStack;
-       SkTDArray<SkSuppress> fSuppressStack;
+    SkIntArray(SkBraceStyle) fBraceStack;       // curly, square, function paren
+    SkIntArray(SkOp) fOpStack;
+    SkIntArray(SkOpType) fTypeStack;
+    SkTDOperandArray fOperandStack;
+    SkTDArray<SkSuppress> fSuppressStack;
 #else
-       SkTDStack<SkBraceStyle> fBraceStack;            // curly, square, function paren
-       SkTDStack<SkOp> fOpStack;
-       SkTDStack<SkOpType> fTypeStack;
-       SkTDStack<SkOperand> fOperandStack;
-       SkTDStack<SkSuppress> fSuppressStack;
+    SkTDStack<SkBraceStyle> fBraceStack;        // curly, square, function paren
+    SkTDStack<SkOp> fOpStack;
+    SkTDStack<SkOpType> fTypeStack;
+    SkTDStack<SkOperand> fOperandStack;
+    SkTDStack<SkSuppress> fSuppressStack;
 #endif
-       SkAnimateMaker* fMaker;
-       SkTDTypedArrayArray fTrackArray;
-       SkTDStringArray fTrackString;
-       const char* fToken; // one-deep stack
-       size_t fTokenLength;
-       SkTDArray<UserCallBack> fUserCallBacks;
-       SkOpType fReturnType;
-       Error fError;
-       int fErrorPosition;
+    SkAnimateMaker* fMaker;
+    SkTDTypedArrayArray fTrackArray;
+    SkTDStringArray fTrackString;
+    const char* fToken; // one-deep stack
+    size_t fTokenLength;
+    SkTDArray<UserCallBack> fUserCallBacks;
+    SkOpType fReturnType;
+    Error fError;
+    int fErrorPosition;
 private:
-       friend class SkTypedArray;
+    friend class SkTypedArray;
 #ifdef SK_SUPPORT_UNITTEST
 public:
-       static void UnitTest();
+    static void UnitTest();
 #endif
 };
 
 #ifdef SK_SUPPORT_UNITTEST
 
 struct SkScriptNAnswer {
-       const char* fScript;
-       SkDisplayTypes fType;
-       S32 fIntAnswer;
-       SkScalar fScalarAnswer;
-       const char* fStringAnswer;
+    const char* fScript;
+    SkDisplayTypes fType;
+    S32 fIntAnswer;
+    SkScalar fScalarAnswer;
+    const char* fStringAnswer;
 };
 
 #endif
index a9f25b7..04e67ee 100644 (file)
@@ -1,3 +1,20 @@
+/* libs/graphics/animator/SkScriptDecompile.cpp
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #include "SkScript2.h"
 
 #ifdef SK_DEBUG
 #define TypeOpName(op) {SkScriptEngine2::op, #op }
 
 static const struct OpName {
-       SkScriptEngine2::TypeOp fOp;
-       const char* fName;
+    SkScriptEngine2::TypeOp fOp;
+    const char* fName;
 } gOpNames[] = {
-       TypeOpName(kNop), // should never get generated
-       TypeOpName(kAccumulatorPop),
-       TypeOpName(kAccumulatorPush),
-       TypeOpName(kAddInt),
-       TypeOpName(kAddScalar),
-       TypeOpName(kAddString), // string concat
-       TypeOpName(kArrayIndex),
-       TypeOpName(kArrayParam),
-       TypeOpName(kArrayToken),
-       TypeOpName(kBitAndInt),
-       TypeOpName(kBitNotInt),
-       TypeOpName(kBitOrInt),
-       TypeOpName(kBoxToken),
-       TypeOpName(kCallback),
-       TypeOpName(kDivideInt),
-       TypeOpName(kDivideScalar),
-       TypeOpName(kDotOperator),
-       TypeOpName(kElseOp),
-       TypeOpName(kEnd),
-       TypeOpName(kEqualInt),
-       TypeOpName(kEqualScalar),
-       TypeOpName(kEqualString),
-       TypeOpName(kFunctionCall),
-       TypeOpName(kFlipOpsOp),
-       TypeOpName(kFunctionToken),
-       TypeOpName(kGreaterEqualInt),
-       TypeOpName(kGreaterEqualScalar),
-       TypeOpName(kGreaterEqualString),
-       TypeOpName(kIfOp),
-       TypeOpName(kIntToScalar),
-       TypeOpName(kIntToScalar2),
-       TypeOpName(kIntToString),
-       TypeOpName(kIntToString2),
-       TypeOpName(kIntegerAccumulator),
-       TypeOpName(kIntegerOperand),
-       TypeOpName(kLogicalAndInt),
-       TypeOpName(kLogicalNotInt),
-       TypeOpName(kLogicalOrInt),
-       TypeOpName(kMemberOp),
-       TypeOpName(kMinusInt),
-       TypeOpName(kMinusScalar),
-       TypeOpName(kModuloInt),
-       TypeOpName(kModuloScalar),
-       TypeOpName(kMultiplyInt),
-       TypeOpName(kMultiplyScalar),
-       TypeOpName(kPropertyOp),
-       TypeOpName(kScalarAccumulator),
-       TypeOpName(kScalarOperand),
-       TypeOpName(kScalarToInt),
-       TypeOpName(kScalarToInt2),
-       TypeOpName(kScalarToString),
-       TypeOpName(kScalarToString2),
-       TypeOpName(kShiftLeftInt),
-       TypeOpName(kShiftRightInt),     // signed
-       TypeOpName(kStringAccumulator),
-       TypeOpName(kStringOperand),
-       TypeOpName(kStringToInt),
-       TypeOpName(kStringToScalar),
-       TypeOpName(kStringToScalar2),
-       TypeOpName(kStringTrack),
-       TypeOpName(kSubtractInt),
-       TypeOpName(kSubtractScalar),
-       TypeOpName(kToBool),
-       TypeOpName(kUnboxToken),
-       TypeOpName(kUnboxToken2),
-       TypeOpName(kXorInt)
+    TypeOpName(kNop), // should never get generated
+    TypeOpName(kAccumulatorPop),
+    TypeOpName(kAccumulatorPush),
+    TypeOpName(kAddInt),
+    TypeOpName(kAddScalar),
+    TypeOpName(kAddString), // string concat
+    TypeOpName(kArrayIndex),
+    TypeOpName(kArrayParam),
+    TypeOpName(kArrayToken),
+    TypeOpName(kBitAndInt),
+    TypeOpName(kBitNotInt),
+    TypeOpName(kBitOrInt),
+    TypeOpName(kBoxToken),
+    TypeOpName(kCallback),
+    TypeOpName(kDivideInt),
+    TypeOpName(kDivideScalar),
+    TypeOpName(kDotOperator),
+    TypeOpName(kElseOp),
+    TypeOpName(kEnd),
+    TypeOpName(kEqualInt),
+    TypeOpName(kEqualScalar),
+    TypeOpName(kEqualString),
+    TypeOpName(kFunctionCall),
+    TypeOpName(kFlipOpsOp),
+    TypeOpName(kFunctionToken),
+    TypeOpName(kGreaterEqualInt),
+    TypeOpName(kGreaterEqualScalar),
+    TypeOpName(kGreaterEqualString),
+    TypeOpName(kIfOp),
+    TypeOpName(kIntToScalar),
+    TypeOpName(kIntToScalar2),
+    TypeOpName(kIntToString),
+    TypeOpName(kIntToString2),
+    TypeOpName(kIntegerAccumulator),
+    TypeOpName(kIntegerOperand),
+    TypeOpName(kLogicalAndInt),
+    TypeOpName(kLogicalNotInt),
+    TypeOpName(kLogicalOrInt),
+    TypeOpName(kMemberOp),
+    TypeOpName(kMinusInt),
+    TypeOpName(kMinusScalar),
+    TypeOpName(kModuloInt),
+    TypeOpName(kModuloScalar),
+    TypeOpName(kMultiplyInt),
+    TypeOpName(kMultiplyScalar),
+    TypeOpName(kPropertyOp),
+    TypeOpName(kScalarAccumulator),
+    TypeOpName(kScalarOperand),
+    TypeOpName(kScalarToInt),
+    TypeOpName(kScalarToInt2),
+    TypeOpName(kScalarToString),
+    TypeOpName(kScalarToString2),
+    TypeOpName(kShiftLeftInt),
+    TypeOpName(kShiftRightInt), // signed
+    TypeOpName(kStringAccumulator),
+    TypeOpName(kStringOperand),
+    TypeOpName(kStringToInt),
+    TypeOpName(kStringToScalar),
+    TypeOpName(kStringToScalar2),
+    TypeOpName(kStringTrack),
+    TypeOpName(kSubtractInt),
+    TypeOpName(kSubtractScalar),
+    TypeOpName(kToBool),
+    TypeOpName(kUnboxToken),
+    TypeOpName(kUnboxToken2),
+    TypeOpName(kXorInt)
 };
 
 static size_t gOpNamesSize = sizeof(gOpNames) / sizeof(gOpNames[0]);
@@ -81,124 +98,124 @@ static size_t gOpNamesSize = sizeof(gOpNames) / sizeof(gOpNames[0]);
 #define OperandName(op) {SkOperand2::op, #op }
 
 static const struct OperName {
-       SkOperand2::OpType fType;
-       const char* fName;
+    SkOperand2::OpType fType;
+    const char* fName;
 } gOperandNames[] = {
-       OperandName(kNoType),
-       OperandName(kS32),
-       OperandName(kScalar),
-       OperandName(kString),
-       OperandName(kArray),
-       OperandName(kObject)
-};     
+    OperandName(kNoType),
+    OperandName(kS32),
+    OperandName(kScalar),
+    OperandName(kString),
+    OperandName(kArray),
+    OperandName(kObject)
+};  
 
 static size_t gOperandNamesSize = sizeof(gOperandNames) / sizeof(gOperandNames[0]);
 
 // check to see that there are no missing or duplicate entries
 void SkScriptEngine2::ValidateDecompileTable() {
-       SkScriptEngine2::TypeOp op = SkScriptEngine2::kNop;
-       int index;
-       for (index = 0; index < gOpNamesSize; index++) {
-               SkASSERT(gOpNames[index].fOp == op);
-               op = (SkScriptEngine2::TypeOp) (op + 1);
-       }
-       index = 0;
-       SkOperand2::OpType type = SkOperand2::kNoType;
-       SkASSERT(gOperandNames[index].fType == type);
-       for (; index < gOperandNamesSize - 1; ) {
-               type = (SkOperand2::OpType) (1 << index);
-               SkASSERT(gOperandNames[++index].fType == type);
-       }
+    SkScriptEngine2::TypeOp op = SkScriptEngine2::kNop;
+    int index;
+    for (index = 0; index < gOpNamesSize; index++) {
+        SkASSERT(gOpNames[index].fOp == op);
+        op = (SkScriptEngine2::TypeOp) (op + 1);
+    }
+    index = 0;
+    SkOperand2::OpType type = SkOperand2::kNoType;
+    SkASSERT(gOperandNames[index].fType == type);
+    for (; index < gOperandNamesSize - 1; ) {
+        type = (SkOperand2::OpType) (1 << index);
+        SkASSERT(gOperandNames[++index].fType == type);
+    }
 }
 
 void SkScriptEngine2::decompile(const unsigned char* start, size_t length) {
-       SkASSERT(length > 0);
-       const unsigned char* opCode = start;
-       do {
-               SkASSERT(opCode - start < length);
-               SkScriptEngine2::TypeOp op = (SkScriptEngine2::TypeOp) *opCode++;
-               SkASSERT(op < gOpNamesSize);
-               SkDebugf("%d: %s", opCode - start - 1, gOpNames[op].fName);
-               switch (op) {
-               case SkScriptEngine2::kCallback: {
-                       int index;
-                       memcpy(&index, opCode, sizeof(index));
-                       opCode += sizeof(index);
-                       SkDebugf(" index: %d", index);
-                       } break;
-               case SkScriptEngine2::kFunctionCall: 
-               case SkScriptEngine2::kMemberOp:
-               case SkScriptEngine2::kPropertyOp: {
-                       size_t ref;
-                       memcpy(&ref, opCode, sizeof(ref));
-                       opCode += sizeof(ref);
-                       SkDebugf(" ref: %d", ref);
-                       } break;
-               case SkScriptEngine2::kIntegerAccumulator:
-               case SkScriptEngine2::kIntegerOperand: {
-                       S32 integer;
-                       memcpy(&integer, opCode, sizeof(integer));
-                       opCode += sizeof(S32);
-                       SkDebugf(" integer: %d", integer);
-                       } break;
-               case SkScriptEngine2::kScalarAccumulator:
-               case SkScriptEngine2::kScalarOperand: {
-                       SkScalar scalar;
-                       memcpy(&scalar, opCode, sizeof(scalar));
-                       opCode += sizeof(SkScalar);
+    SkASSERT(length > 0);
+    const unsigned char* opCode = start;
+    do {
+        SkASSERT(opCode - start < length);
+        SkScriptEngine2::TypeOp op = (SkScriptEngine2::TypeOp) *opCode++;
+        SkASSERT(op < gOpNamesSize);
+        SkDebugf("%d: %s", opCode - start - 1, gOpNames[op].fName);
+        switch (op) {
+        case SkScriptEngine2::kCallback: {
+            int index;
+            memcpy(&index, opCode, sizeof(index));
+            opCode += sizeof(index);
+            SkDebugf(" index: %d", index);
+            } break;
+        case SkScriptEngine2::kFunctionCall: 
+        case SkScriptEngine2::kMemberOp:
+        case SkScriptEngine2::kPropertyOp: {
+            size_t ref;
+            memcpy(&ref, opCode, sizeof(ref));
+            opCode += sizeof(ref);
+            SkDebugf(" ref: %d", ref);
+            } break;
+        case SkScriptEngine2::kIntegerAccumulator:
+        case SkScriptEngine2::kIntegerOperand: {
+            S32 integer;
+            memcpy(&integer, opCode, sizeof(integer));
+            opCode += sizeof(S32);
+            SkDebugf(" integer: %d", integer);
+            } break;
+        case SkScriptEngine2::kScalarAccumulator:
+        case SkScriptEngine2::kScalarOperand: {
+            SkScalar scalar;
+            memcpy(&scalar, opCode, sizeof(scalar));
+            opCode += sizeof(SkScalar);
 #ifdef SK_CAN_USE_FLOAT
-                       SkDebugf(" scalar: %g", SkScalarToFloat(scalar));
+            SkDebugf(" scalar: %g", SkScalarToFloat(scalar));
 #else
-                       SkDebugf(" scalar: %x", scalar);
+            SkDebugf(" scalar: %x", scalar);
 #endif
-                       } break;
-               case SkScriptEngine2::kStringAccumulator:
-               case SkScriptEngine2::kStringOperand: {
-                       int size;
-                       SkString* strPtr = new SkString();
-                       memcpy(&size, opCode, sizeof(size));
-                       opCode += sizeof(size);
-                       strPtr->set((char*) opCode, size);
-                       opCode += size;
-                       SkDebugf(" string: %s", strPtr->c_str());
-                       delete strPtr;
-                       } break;
-               case SkScriptEngine2::kBoxToken: {
-                       SkOperand2::OpType type;
-                       memcpy(&type, opCode, sizeof(type));
-                       opCode += sizeof(type);
-                       int index = 0;
-                       if (type == 0)
-                               SkDebugf(" type: %s", gOperandNames[index].fName);
-                       else {
-                               while (type != 0) {
-                                       SkASSERT(index + 1 < gOperandNamesSize);
-                                       if (type & (1 << index)) {
-                                               type = (SkOperand2::OpType) (type & ~(1 << index));
-                                               SkDebugf(" type: %s", gOperandNames[index + 1].fName);
-                                       }
-                                       index++;
-                               }
-                       }
-                       } break;
-               case SkScriptEngine2::kIfOp:
-               case SkScriptEngine2::kLogicalAndInt:
-               case SkScriptEngine2::kElseOp:
-               case SkScriptEngine2::kLogicalOrInt: {
-                       int size;
-                       memcpy(&size, opCode, sizeof(size));
-                       opCode += sizeof(size);
-                       SkDebugf(" offset (address): %d (%d)", size, opCode - start + size);
-                       } break;
-               case SkScriptEngine2::kEnd:
-                       goto done;
-               case SkScriptEngine2::kNop:
-                               SkASSERT(0);
-       }
-       SkDebugf("\n");
-       } while (true);
+            } break;
+        case SkScriptEngine2::kStringAccumulator:
+        case SkScriptEngine2::kStringOperand: {
+            int size;
+            SkString* strPtr = new SkString();
+            memcpy(&size, opCode, sizeof(size));
+            opCode += sizeof(size);
+            strPtr->set((char*) opCode, size);
+            opCode += size;
+            SkDebugf(" string: %s", strPtr->c_str());
+            delete strPtr;
+            } break;
+        case SkScriptEngine2::kBoxToken: {
+            SkOperand2::OpType type;
+            memcpy(&type, opCode, sizeof(type));
+            opCode += sizeof(type);
+            int index = 0;
+            if (type == 0)
+                SkDebugf(" type: %s", gOperandNames[index].fName);
+            else {
+                while (type != 0) {
+                    SkASSERT(index + 1 < gOperandNamesSize);
+                    if (type & (1 << index)) {
+                        type = (SkOperand2::OpType) (type & ~(1 << index));
+                        SkDebugf(" type: %s", gOperandNames[index + 1].fName);
+                    }
+                    index++;
+                }
+            }
+            } break;
+        case SkScriptEngine2::kIfOp:
+        case SkScriptEngine2::kLogicalAndInt:
+        case SkScriptEngine2::kElseOp:
+        case SkScriptEngine2::kLogicalOrInt: {
+            int size;
+            memcpy(&size, opCode, sizeof(size));
+            opCode += sizeof(size);
+            SkDebugf(" offset (address): %d (%d)", size, opCode - start + size);
+            } break;
+        case SkScriptEngine2::kEnd:
+            goto done;
+        case SkScriptEngine2::kNop:
+                SkASSERT(0);
+    }
+    SkDebugf("\n");
+    } while (true);
 done:
-       SkDebugf("\n");
+    SkDebugf("\n");
 }
 
 #endif
index 9bb74e6..06c5d65 100644 (file)
@@ -1,3 +1,20 @@
+/* libs/graphics/animator/SkSnapshot.cpp
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #include "SkTypes.h"
 
 #ifdef SK_SUPPORT_IMAGE_ENCODE
 #if SK_USE_CONDENSED_INFO == 0
 
 const SkMemberInfo SkSnapshot::fInfo[] = {
-       SK_MEMBER(filename, String),
-       SK_MEMBER(quality, Float),
-       SK_MEMBER(sequence, Boolean),
-       SK_MEMBER(type, BitmapEncoding)
+    SK_MEMBER(filename, String),
+    SK_MEMBER(quality, Float),
+    SK_MEMBER(sequence, Boolean),
+    SK_MEMBER(type, BitmapEncoding)
 };
 
 #endif
@@ -21,34 +38,34 @@ DEFINE_GET_MEMBER(SkSnapshot);
 
 SkSnapshot::SkSnapshot()
 {
-       quality         = 100 * SK_Scalar1;
-       type            = (SkImageEncoder::Type) -1;
-       sequence        = false;
-       fSeqVal         = 0;
+    quality     = 100 * SK_Scalar1;
+    type        = (SkImageEncoder::Type) -1;
+    sequence    = false;
+    fSeqVal     = 0;
 }
 
 bool SkSnapshot::draw(SkAnimateMaker& maker) {
-       SkASSERT(type >= 0);
-       SkASSERT(filename.size() > 0);
-       SkImageEncoder* encoder = SkImageEncoder::Create((SkImageEncoder::Type) type);
-       SkBitmap bitmap;
-       maker.fCanvas->getPixels(&bitmap);
-       SkString name(filename);
-       if (sequence) {
-               char num[4] = "000";
-               num[0] = (char) (num[0] + fSeqVal / 100);
-               num[1] = (char) (num[1] + fSeqVal / 10 % 10);
-               num[2] = (char) (num[2] + fSeqVal % 10);
-               name.append(num);
-               if (++fSeqVal > 999)
-                       sequence = false;
-       }
-       if (type == SkImageEncoder::kJPEG_Type)
-               name.append(".jpg");
-       else if (type == SkImageEncoder::kPNG_Type)
-               name.append(".png");
-       encoder->encodeFile(name.c_str(), bitmap, SkScalarFloor(quality));
-       return false;
+    SkASSERT(type >= 0);
+    SkASSERT(filename.size() > 0);
+    SkImageEncoder* encoder = SkImageEncoder::Create((SkImageEncoder::Type) type);
+    SkBitmap bitmap;
+    maker.fCanvas->getPixels(&bitmap);
+    SkString name(filename);
+    if (sequence) {
+        char num[4] = "000";
+        num[0] = (char) (num[0] + fSeqVal / 100);
+        num[1] = (char) (num[1] + fSeqVal / 10 % 10);
+        num[2] = (char) (num[2] + fSeqVal % 10);
+        name.append(num);
+        if (++fSeqVal > 999)
+            sequence = false;
+    }
+    if (type == SkImageEncoder::kJPEG_Type)
+        name.append(".jpg");
+    else if (type == SkImageEncoder::kPNG_Type)
+        name.append(".png");
+    encoder->encodeFile(name.c_str(), bitmap, SkScalarFloor(quality));
+    return false;
 }
 
 #endif
index 941df79..b63145d 100644 (file)
@@ -1,3 +1,20 @@
+/* libs/graphics/animator/SkSnapshot.h
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #ifndef SkSnapShot_DEFINED
 #define SkSnapShot_DEFINED
 
 #include "SkString.h"
 
 class SkSnapshot: public SkDrawable {
-       DECLARE_MEMBER_INFO(Snapshot);
-       SkSnapshot();
-       virtual bool draw(SkAnimateMaker& );
-       private:
-       SkString filename;
-       SkScalar quality;
-       SkBool sequence;
-       int /*SkImageEncoder::Type*/    type;
-       int fSeqVal;
+    DECLARE_MEMBER_INFO(Snapshot);
+    SkSnapshot();
+    virtual bool draw(SkAnimateMaker& );
+    private:
+    SkString filename;
+    SkScalar quality;
+    SkBool sequence;
+    int /*SkImageEncoder::Type*/    type;
+    int fSeqVal;
 };
 
 #endif // SK_SUPPORT_IMAGE_ENCODE
index 9511d4e..478423d 100644 (file)
@@ -1,3 +1,20 @@
+/* libs/graphics/animator/SkTDArray_Experimental.h
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #ifndef SkTDArray_Experimental_DEFINED
 #define SkTDArray_Experimental_DEFINED
 
 
 class SkDS32Array {
 protected:
-       SkDS32Array();
-       SkDS32Array(const SkDS32Array& src);
-       SkDS32Array(const int32_t src[], U16CPU count);
-       SkDS32Array& operator=(const SkDS32Array& src);
-       friend int operator==(const SkDS32Array& a, const SkDS32Array& b);
-       int32_t* append() { return this->append(1, nil); }
-       int32_t* append(U16CPU count, const int32_t* src = nil);
-
-       int32_t* appendClear() 
-       
-               int32_t* result = this->append(); 
-               *result = 0;
-               return result;
-       }
-
-       int find(const int32_t& elem) const;
-       int32_t* insert(U16CPU index, U16CPU count, const int32_t* src);
-       int rfind(const int32_t& elem) const;
-       void swap(SkDS32Array& other);
+    SkDS32Array();
+    SkDS32Array(const SkDS32Array& src);
+    SkDS32Array(const int32_t src[], U16CPU count);
+    SkDS32Array& operator=(const SkDS32Array& src);
+    friend int operator==(const SkDS32Array& a, const SkDS32Array& b);
+    int32_t* append() { return this->append(1, nil); }
+    int32_t* append(U16CPU count, const int32_t* src = nil);
+
+    int32_t* appendClear() 
+    { 
+        int32_t* result = this->append(); 
+        *result = 0;
+        return result;
+    }
+
+    int find(const int32_t& elem) const;
+    int32_t* insert(U16CPU index, U16CPU count, const int32_t* src);
+    int rfind(const int32_t& elem) const;
+    void swap(SkDS32Array& other);
 public:
-       bool isEmpty() const { return fCount == 0; }
-       int     count() const { return fCount; }
-
-       void remove(U16CPU index, U16CPU count = 1)
-       {
-               SkASSERT(index + count <= fCount);
-               fCount = SkToU16(fCount - count);
-               memmove(fArray + index, fArray + index + count, sizeof(int32_t) * (fCount - index));
-       }
-
-       void reset()
-       {
-               if (fArray)
-               {
-                       sk_free(fArray);
-                       fArray = nil;
+    bool isEmpty() const { return fCount == 0; }
+    int count() const { return fCount; }
+
+    void remove(U16CPU index, U16CPU count = 1)
+    {
+        SkASSERT(index + count <= fCount);
+        fCount = SkToU16(fCount - count);
+        memmove(fArray + index, fArray + index + count, sizeof(int32_t) * (fCount - index));
+    }
+
+    void reset()
+    {
+        if (fArray)
+        {
+            sk_free(fArray);
+            fArray = nil;
 #ifdef SK_DEBUG
-                       fData = nil;
+            fData = nil;
 #endif
-                       fReserve = fCount = 0;
-               }
-               else
-               {
-                       SkASSERT(fReserve == 0 && fCount == 0);
-               }
-       }
-
-       void setCount(U16CPU count)
-       {
-               if (count > fReserve)
-                       this->growBy(count - fCount);
-               else
-                       fCount = SkToU16(count);
-       }
+            fReserve = fCount = 0;
+        }
+        else
+        {
+            SkASSERT(fReserve == 0 && fCount == 0);
+        }
+    }
+
+    void setCount(U16CPU count)
+    {
+        if (count > fReserve)
+            this->growBy(count - fCount);
+        else
+            fCount = SkToU16(count);
+    }
 protected:
 #ifdef SK_DEBUG
     enum {
         kDebugArraySize = 24
     };
-       int32_t(* fData)[kDebugArraySize];
+    int32_t(* fData)[kDebugArraySize];
 #endif
-       int32_t*        fArray;
-       uint16_t        fReserve, fCount;
-       void growBy(U16CPU extra);
+    int32_t*    fArray;
+    uint16_t    fReserve, fCount;
+    void growBy(U16CPU extra);
 };
 
 #ifdef SK_DEBUG
-       #define SYNC() fTData = (T (*)[kDebugArraySize]) fArray
+    #define SYNC() fTData = (T (*)[kDebugArraySize]) fArray
 #else
-       #define SYNC()
+    #define SYNC()
 #endif
 
 template <typename T> class SkTDS32Array : public SkDS32Array {
 public:
-       SkTDS32Array() { SkDEBUGCODE(fTData=nil); SkASSERT(sizeof(T) == sizeof(int32_t)); }
-       SkTDS32Array(const SkTDS32Array<T>& src) : SkDS32Array(src) {}
-       ~SkTDS32Array() { sk_free(fArray); }
-       T&      operator[](int index) const { SYNC(); SkASSERT((unsigned)index < fCount); return ((T*) fArray)[index]; }
-       SkTDS32Array<T>& operator=(const SkTDS32Array<T>& src) { 
-               return (SkTDS32Array<T>&) SkDS32Array::operator=(src); }
-       friend int operator==(const SkTDS32Array<T>& a, const SkTDS32Array<T>& b) { 
-               return operator==((const SkDS32Array&) a, (const SkDS32Array&) b); }
-       T* append() { return (T*) SkDS32Array::append(); }
-       T* appendClear() { return (T*) SkDS32Array::appendClear(); }
-       T* append(U16CPU count, const T* src = nil) { return (T*) SkDS32Array::append(count, (const int32_t*) src); }
-       T*      begin() const { SYNC(); return (T*) fArray; }
-       T*      end() const { return (T*) (fArray ? fArray + fCount : nil); }
-       int find(const T& elem) const { return SkDS32Array::find((const int32_t&) elem); }
-       T* insert(U16CPU index) { return this->insert(index, 1, nil); }
-       T* insert(U16CPU index, U16CPU count, const T* src = nil) {
-               return (T*) SkDS32Array::insert(index, count, (const int32_t*) src); }
-       int rfind(const T& elem) const { return SkDS32Array::rfind((const int32_t&) elem); }
-       T*                      push() { return this->append(); }
-       void            push(T& elem) { *this->append() = elem; }
-       const T&        top() const { return (*this)[fCount - 1]; }
-       T&                      top() { return (*this)[fCount - 1]; }
-       void            pop(T* elem) { if (elem) *elem = (*this)[fCount - 1]; --fCount; }
-       void            pop() { --fCount; }
+    SkTDS32Array() { SkDEBUGCODE(fTData=nil); SkASSERT(sizeof(T) == sizeof(int32_t)); }
+    SkTDS32Array(const SkTDS32Array<T>& src) : SkDS32Array(src) {}
+    ~SkTDS32Array() { sk_free(fArray); }
+    T&  operator[](int index) const { SYNC(); SkASSERT((unsigned)index < fCount); return ((T*) fArray)[index]; }
+    SkTDS32Array<T>& operator=(const SkTDS32Array<T>& src) { 
+        return (SkTDS32Array<T>&) SkDS32Array::operator=(src); }
+    friend int operator==(const SkTDS32Array<T>& a, const SkTDS32Array<T>& b) { 
+        return operator==((const SkDS32Array&) a, (const SkDS32Array&) b); }
+    T* append() { return (T*) SkDS32Array::append(); }
+    T* appendClear() { return (T*) SkDS32Array::appendClear(); }
+    T* append(U16CPU count, const T* src = nil) { return (T*) SkDS32Array::append(count, (const int32_t*) src); }
+    T*  begin() const { SYNC(); return (T*) fArray; }
+    T*  end() const { return (T*) (fArray ? fArray + fCount : nil); }
+    int find(const T& elem) const { return SkDS32Array::find((const int32_t&) elem); }
+    T* insert(U16CPU index) { return this->insert(index, 1, nil); }
+    T* insert(U16CPU index, U16CPU count, const T* src = nil) {
+        return (T*) SkDS32Array::insert(index, count, (const int32_t*) src); }
+    int rfind(const T& elem) const { return SkDS32Array::rfind((const int32_t&) elem); }
+    T*          push() { return this->append(); }
+    void        push(T& elem) { *this->append() = elem; }
+    const T&    top() const { return (*this)[fCount - 1]; }
+    T&          top() { return (*this)[fCount - 1]; }
+    void        pop(T* elem) { if (elem) *elem = (*this)[fCount - 1]; --fCount; }
+    void        pop() { --fCount; }
 private:
 #ifdef SK_DEBUG
-       mutable T(* fTData)[kDebugArraySize];
+    mutable T(* fTData)[kDebugArraySize];
 #endif
 };
 
-#define SkIntArray(type) SkTDS32Array<type>    // holds 32 bit data types
-#define SkLongArray(type) SkTDS32Array<type>   // holds 32/64 bit data types depending on pointer size
+#define SkIntArray(type) SkTDS32Array<type> // holds 32 bit data types
+#define SkLongArray(type) SkTDS32Array<type>    // holds 32/64 bit data types depending on pointer size
 
 #endif // SK_SMALLER_ARRAY_TEMPLATE_EXPERIMENT
 
index c0e9917..b0b4784 100644 (file)
@@ -1,3 +1,20 @@
+/* libs/graphics/animator/SkTextOnPath.cpp
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #include "SkTextOnPath.h"
 #include "SkAnimateMaker.h"
 #include "SkCanvas.h"
@@ -8,9 +25,9 @@
 #if SK_USE_CONDENSED_INFO == 0
 
 const SkMemberInfo SkTextOnPath::fInfo[] = {
-       SK_MEMBER(offset, Float),
-       SK_MEMBER(path, Path),
-       SK_MEMBER(text, Text)
+    SK_MEMBER(offset, Float),
+    SK_MEMBER(path, Path),
+    SK_MEMBER(text, Text)
 };
 
 #endif
@@ -21,10 +38,10 @@ SkTextOnPath::SkTextOnPath() : offset(0), path(nil), text(nil) {
 }
 
 bool SkTextOnPath::draw(SkAnimateMaker& maker) {
-       SkASSERT(text);
-       SkASSERT(path);
-       SkBoundableAuto boundable(this, maker);
-       maker.fCanvas->drawTextOnPath(text->getText(), text->getSize(), 
-               path->getPath(), offset, *maker.fPaint);
-       return false;
+    SkASSERT(text);
+    SkASSERT(path);
+    SkBoundableAuto boundable(this, maker);
+    maker.fCanvas->drawTextOnPath(text->getText(), text->getSize(), 
+        path->getPath(), offset, *maker.fPaint);
+    return false;
 }
index c818aed..f01e118 100644 (file)
@@ -1,3 +1,20 @@
+/* libs/graphics/animator/SkTextOnPath.h
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #ifndef SkTextOnPath_DEFINED
 #define SkTextOnPath_DEFINED
 
@@ -8,14 +25,14 @@ class SkDrawPath;
 class SkText;
 
 class SkTextOnPath : public SkBoundable {
-       DECLARE_MEMBER_INFO(TextOnPath);
-       SkTextOnPath();
-       virtual bool draw(SkAnimateMaker& );
+    DECLARE_MEMBER_INFO(TextOnPath);
+    SkTextOnPath();
+    virtual bool draw(SkAnimateMaker& );
 private:
-       SkScalar offset;
-       SkDrawPath* path;
-       SkText* text;
-       typedef SkBoundable INHERITED;
+    SkScalar offset;
+    SkDrawPath* path;
+    SkText* text;
+    typedef SkBoundable INHERITED;
 };
 
 #endif // SkTextOnPath_DEFINED
index d259c69..726d05a 100644 (file)
@@ -1,3 +1,20 @@
+/* libs/graphics/animator/SkTextToPath.cpp
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #include "SkTextToPath.h"
 #include "SkAnimateMaker.h"
 #include "SkDrawPaint.h"
@@ -8,9 +25,9 @@
 #if SK_USE_CONDENSED_INFO == 0
 
 const SkMemberInfo SkTextToPath::fInfo[] = {
-       SK_MEMBER(paint, Paint),
-       SK_MEMBER(path, Path),
-       SK_MEMBER(text, Text)
+    SK_MEMBER(paint, Paint),
+    SK_MEMBER(path, Path),
+    SK_MEMBER(text, Text)
 };
 
 #endif
@@ -21,19 +38,19 @@ SkTextToPath::SkTextToPath() : paint(nil), path(nil), text(nil) {
 }
 
 bool SkTextToPath::draw(SkAnimateMaker& maker) {
-       path->draw(maker);
-       return false;
+    path->draw(maker);
+    return false;
 }
 
 void SkTextToPath::onEndElement(SkAnimateMaker& maker) {
-       if (paint == nil || path == nil || text == nil) {
-               // !!! add error message here
-               maker.setErrorCode(SkDisplayXMLParserError::kErrorInAttributeValue);
-               return;
-       }
-       SkPaint realPaint;
-       paint->setupPaint(&realPaint);
-       realPaint.getTextPath(text->getText(), text->getSize(), text->x, 
-               text->y, &path->getPath());
+    if (paint == nil || path == nil || text == nil) {
+        // !!! add error message here
+        maker.setErrorCode(SkDisplayXMLParserError::kErrorInAttributeValue);
+        return;
+    }
+    SkPaint realPaint;
+    paint->setupPaint(&realPaint);
+    realPaint.getTextPath(text->getText(), text->getSize(), text->x, 
+        text->y, &path->getPath());
 }
 
index e36083f..2ba41cf 100644 (file)
@@ -1,3 +1,20 @@
+/* libs/graphics/animator/SkTextToPath.h
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #ifndef SkTextToPath_DEFINED
 #define SkTextToPath_DEFINED
 
@@ -9,14 +26,14 @@ class SkDrawPath;
 class SkText;
 
 class SkTextToPath : public SkDrawable {
-       DECLARE_MEMBER_INFO(TextToPath);
-       SkTextToPath();
-       virtual bool draw(SkAnimateMaker& );
-       virtual void onEndElement(SkAnimateMaker& );
+    DECLARE_MEMBER_INFO(TextToPath);
+    SkTextToPath();
+    virtual bool draw(SkAnimateMaker& );
+    virtual void onEndElement(SkAnimateMaker& );
 private:
-       SkDrawPaint* paint;
-       SkDrawPath* path;
-       SkText* text;
+    SkDrawPaint* paint;
+    SkDrawPath* path;
+    SkText* text;
 };
 
 #endif // SkTextToPath_DEFINED
index 928480f..de091fe 100644 (file)
@@ -1,3 +1,20 @@
+/* libs/graphics/animator/SkTime.cpp
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #include "SkTime.h"
 
 #ifdef SK_BUILD_FOR_WIN
@@ -8,28 +25,28 @@ SkMSec gForceTickCount = (SkMSec) -1;
 
 void SkTime::GetDateTime(DateTime* t)
 {
-       if (t)
-       {
-               SYSTEMTIME      syst;
+    if (t)
+    {
+        SYSTEMTIME  syst;
 
-               ::GetLocalTime(&syst);
-               t->fYear                = SkToU16(syst.wYear);
-               t->fMonth               = SkToU8(syst.wMonth);
-               t->fDayOfWeek   = SkToU8(syst.wDayOfWeek);
-               t->fDay                 = SkToU8(syst.wDay);
-               t->fHour                = SkToU8(syst.wHour);
-               t->fMinute              = SkToU8(syst.wMinute);
-               t->fSecond              = SkToU8(syst.wSecond);
-       }
+        ::GetLocalTime(&syst);
+        t->fYear        = SkToU16(syst.wYear);
+        t->fMonth       = SkToU8(syst.wMonth);
+        t->fDayOfWeek   = SkToU8(syst.wDayOfWeek);
+        t->fDay         = SkToU8(syst.wDay);
+        t->fHour        = SkToU8(syst.wHour);
+        t->fMinute      = SkToU8(syst.wMinute);
+        t->fSecond      = SkToU8(syst.wSecond);
+    }
 }
 
 SkMSec SkTime::GetMSecs()
 {
 #ifdef SK_DEBUG
-       if (gForceTickCount != (SkMSec) -1)
-               return gForceTickCount;
+    if (gForceTickCount != (SkMSec) -1)
+        return gForceTickCount;
 #endif
-       return ::GetTickCount();
+    return ::GetTickCount();
 }
 
 #elif defined(xSK_BUILD_FOR_MAC)
@@ -38,34 +55,34 @@ SkMSec SkTime::GetMSecs()
 
 void SkTime::GetDateTime(DateTime* t)
 {
-       if (t)
-       {
-               tm              syst;
-               time_t  tm;
-               
-               time(&tm);
-               localtime_r(&tm, &syst);
-               t->fYear                = SkToU16(syst.tm_year);
-               t->fMonth               = SkToU8(syst.tm_mon + 1);
-               t->fDayOfWeek   = SkToU8(syst.tm_wday);
-               t->fDay                 = SkToU8(syst.tm_mday);
-               t->fHour                = SkToU8(syst.tm_hour);
-               t->fMinute              = SkToU8(syst.tm_min);
-               t->fSecond              = SkToU8(syst.tm_sec);
-       }
+    if (t)
+    {
+        tm      syst;
+        time_t  tm;
+        
+        time(&tm);
+        localtime_r(&tm, &syst);
+        t->fYear        = SkToU16(syst.tm_year);
+        t->fMonth       = SkToU8(syst.tm_mon + 1);
+        t->fDayOfWeek   = SkToU8(syst.tm_wday);
+        t->fDay         = SkToU8(syst.tm_mday);
+        t->fHour        = SkToU8(syst.tm_hour);
+        t->fMinute      = SkToU8(syst.tm_min);
+        t->fSecond      = SkToU8(syst.tm_sec);
+    }
 }
 
 #include "Sk64.h"
 
 SkMSec SkTime::GetMSecs()
 {
-       UnsignedWide    wide;
-       Sk64                    s;
+    UnsignedWide    wide;
+    Sk64            s;
 
-       ::Microseconds(&wide);
-       s.set(wide.hi, wide.lo);
-       s.div(1000, Sk64::kRound_DivOption);
-       return s.get32();
+    ::Microseconds(&wide);
+    s.set(wide.hi, wide.lo);
+    s.div(1000, Sk64::kRound_DivOption);
+    return s.get32();
 }
 
 #endif
index f73d8aa..a3e4634 100644 (file)
@@ -1,3 +1,20 @@
+/* libs/graphics/animator/SkTypedArray.cpp
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #include "SkTypedArray.h"
 
 SkTypedArray::SkTypedArray() : fType(SkType_Unknown) {
@@ -7,164 +24,164 @@ SkTypedArray::SkTypedArray(SkDisplayTypes type) : fType(type) {
 }
 
 bool SkTypedArray::getIndex(int index, SkOperand* operand) {
-       if (index >= count()) {
-               SkASSERT(0);
-               return false;
-       }
-       *operand = begin()[index];
-       return true;
+    if (index >= count()) {
+        SkASSERT(0);
+        return false;
+    }
+    *operand = begin()[index];
+    return true;
 }
 
 
 #if SK_SMALLER_ARRAY_TEMPLATE_EXPERIMENT == 1
 SkDS32Array::SkDS32Array()
 {
-       fReserve = fCount = 0;
-       fArray = nil;
+    fReserve = fCount = 0;
+    fArray = nil;
 #ifdef SK_DEBUG
-       fData = nil;
+    fData = nil;
 #endif
 }
 
 SkDS32Array::SkDS32Array(const SkDS32Array& src)
 {
-       fReserve = fCount = 0;
-       fArray = nil;
+    fReserve = fCount = 0;
+    fArray = nil;
 #ifdef SK_DEBUG
-       fData = nil;
+    fData = nil;
 #endif
-       SkDS32Array tmp(src.fArray, src.fCount);
-       this->swap(tmp);
+    SkDS32Array tmp(src.fArray, src.fCount);
+    this->swap(tmp);
 }
 
 SkDS32Array::SkDS32Array(const S32 src[], U16CPU count)
 {
-       SkASSERT(src || count == 0);
+    SkASSERT(src || count == 0);
 
-       fReserve = fCount = 0;
-       fArray = nil;
+    fReserve = fCount = 0;
+    fArray = nil;
 #ifdef SK_DEBUG
-       fData = nil;
+    fData = nil;
 #endif
-       if (count)
-       {
-               fArray = (S32*)sk_malloc_throw(count * sizeof(S32));
+    if (count)
+    {
+        fArray = (S32*)sk_malloc_throw(count * sizeof(S32));
 #ifdef SK_DEBUG
-               fData = (S32 (*)[kDebugArraySize]) fArray;
+        fData = (S32 (*)[kDebugArraySize]) fArray;
 #endif
-               memcpy(fArray, src, sizeof(S32) * count);
-               fReserve = fCount = SkToU16(count);
-       }
+        memcpy(fArray, src, sizeof(S32) * count);
+        fReserve = fCount = SkToU16(count);
+    }
 }
 
 SkDS32Array& SkDS32Array::operator=(const SkDS32Array& src)
 {
-       if (this != &src)
-       {
-               if (src.fCount > fReserve)
-               {
-                       SkDS32Array tmp(src.fArray, src.fCount);
-                       this->swap(tmp);
-               }
-               else
-               {
-                       memcpy(fArray, src.fArray, sizeof(S32) * src.fCount);
-                       fCount = src.fCount;
-               }
-       }
-       return *this;
+    if (this != &src)
+    {
+        if (src.fCount > fReserve)
+        {
+            SkDS32Array tmp(src.fArray, src.fCount);
+            this->swap(tmp);
+        }
+        else
+        {
+            memcpy(fArray, src.fArray, sizeof(S32) * src.fCount);
+            fCount = src.fCount;
+        }
+    }
+    return *this;
 }
 
 int operator==(const SkDS32Array& a, const SkDS32Array& b)
 {
-       return a.fCount == b.fCount &&
-                       (a.fCount == 0 || !memcmp(a.fArray, b.fArray, a.fCount * sizeof(S32)));
+    return a.fCount == b.fCount &&
+            (a.fCount == 0 || !memcmp(a.fArray, b.fArray, a.fCount * sizeof(S32)));
 }
 
 void SkDS32Array::swap(SkDS32Array& other)
 {
-       SkTSwap(fArray, other.fArray);
+    SkTSwap(fArray, other.fArray);
 #ifdef SK_DEBUG
-       SkTSwap(fData, other.fData);
+    SkTSwap(fData, other.fData);
 #endif
-       SkTSwap(fReserve, other.fReserve);
-       SkTSwap(fCount, other.fCount);
+    SkTSwap(fReserve, other.fReserve);
+    SkTSwap(fCount, other.fCount);
 }
 
 S32* SkDS32Array::append(U16CPU count, const S32* src)
 {
-       unsigned oldCount = fCount;
-       if (count)
-       {
-               SkASSERT(src == nil || fArray == nil ||
-                               src + count <= fArray || fArray + count <= src);
-
-               this->growBy(count);
-               if (src)
-                       memcpy(fArray + oldCount, src, sizeof(S32) * count);
-       }
-       return fArray + oldCount;
+    unsigned oldCount = fCount;
+    if (count)
+    {
+        SkASSERT(src == nil || fArray == nil ||
+                src + count <= fArray || fArray + count <= src);
+
+        this->growBy(count);
+        if (src)
+            memcpy(fArray + oldCount, src, sizeof(S32) * count);
+    }
+    return fArray + oldCount;
 }
 
 int SkDS32Array::find(const S32& elem) const
 {
-       const S32* iter = fArray;
-       const S32* stop = fArray + fCount;
-
-       for (; iter < stop; iter++)
-       {
-               if (*iter == elem)
-                       return (int) (iter - fArray);
-       }
-       return -1;
+    const S32* iter = fArray;
+    const S32* stop = fArray + fCount;
+
+    for (; iter < stop; iter++)
+    {
+        if (*iter == elem)
+            return (int) (iter - fArray);
+    }
+    return -1;
 }
 
 void SkDS32Array::growBy(U16CPU extra)
 {
-       SkASSERT(extra);
-       SkASSERT(fCount + extra <= 0xFFFF);
-
-       if (fCount + extra > fReserve)
-       {
-               size_t size = fCount + extra + 4;
-               size += size >> 2;
-               S32* array = (S32*)sk_malloc_throw(size * sizeof(S32));
-               memcpy(array, fArray, fCount * sizeof(S32));
-
-               sk_free(fArray);
-               fArray = array;
+    SkASSERT(extra);
+    SkASSERT(fCount + extra <= 0xFFFF);
+
+    if (fCount + extra > fReserve)
+    {
+        size_t size = fCount + extra + 4;
+        size += size >> 2;
+        S32* array = (S32*)sk_malloc_throw(size * sizeof(S32));
+        memcpy(array, fArray, fCount * sizeof(S32));
+
+        sk_free(fArray);
+        fArray = array;
 #ifdef SK_DEBUG
-               fData = (S32 (*)[kDebugArraySize]) fArray;
+        fData = (S32 (*)[kDebugArraySize]) fArray;
 #endif
-               fReserve = SkToU16((U16CPU)size);
-       }
-       fCount = SkToU16(fCount + extra);
+        fReserve = SkToU16((U16CPU)size);
+    }
+    fCount = SkToU16(fCount + extra);
 }
 
 S32* SkDS32Array::insert(U16CPU index, U16CPU count, const S32* src)
 {
-       SkASSERT(count);
-       int oldCount = fCount;
-       this->growBy(count);
-       S32* dst = fArray + index;
-       memmove(dst + count, dst, sizeof(S32) * (oldCount - index));
-       if (src)
-               memcpy(dst, src, sizeof(S32) * count);
-       return dst;
+    SkASSERT(count);
+    int oldCount = fCount;
+    this->growBy(count);
+    S32* dst = fArray + index;
+    memmove(dst + count, dst, sizeof(S32) * (oldCount - index));
+    if (src)
+        memcpy(dst, src, sizeof(S32) * count);
+    return dst;
 }
 
 
-       int SkDS32Array::rfind(const S32& elem) const
-       {
-               const S32* iter = fArray + fCount;
-               const S32* stop = fArray;
+    int SkDS32Array::rfind(const S32& elem) const
+    {
+        const S32* iter = fArray + fCount;
+        const S32* stop = fArray;
 
-               while (iter > stop)
-               {
-                       if (*--iter == elem)
-                               return (int) (iter - stop);
-               }
-               return -1;
-       }
+        while (iter > stop)
+        {
+            if (*--iter == elem)
+                return (int) (iter - stop);
+        }
+        return -1;
+    }
 
 #endif
index 96b42ac..0535426 100644 (file)
@@ -1,3 +1,20 @@
+/* libs/graphics/animator/SkTypedArray.h
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #ifndef SkTypedArray_DEFINED
 #define SkTypedArray_DEFINED
 
 
 class SkTypedArray : public SkTDOperandArray {
 public:
-       SkTypedArray();
-       SkTypedArray(SkDisplayTypes type);
-       bool getIndex(int index, SkOperand* operand);
-       SkDisplayTypes getType() { return fType; }
-       SkScriptEngine::SkOpType getOpType() { return SkScriptEngine::ToOpType(fType); }
-       void setType(SkDisplayTypes type) { 
-       //      SkASSERT(count() == 0);
-               fType = type;
-       }
+    SkTypedArray();
+    SkTypedArray(SkDisplayTypes type);
+    bool getIndex(int index, SkOperand* operand);
+    SkDisplayTypes getType() { return fType; }
+    SkScriptEngine::SkOpType getOpType() { return SkScriptEngine::ToOpType(fType); }
+    void setType(SkDisplayTypes type) { 
+    //  SkASSERT(count() == 0);
+        fType = type;
+    }
 protected:
-       SkDisplayTypes fType;
+    SkDisplayTypes fType;
 };
 
 #endif // SkTypedArray_DEFINED
index 8045fde..9dd131c 100644 (file)
@@ -1,3 +1,20 @@
+/* libs/graphics/animator/SkXMLAnimatorWriter.cpp
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #include "SkXMLAnimatorWriter.h"
 #include "SkAnimator.h"
 #include "SkAnimateMaker.h"
 
 SkXMLAnimatorWriter::SkXMLAnimatorWriter(SkAnimator* animator) : fAnimator(animator)
 {
-       fParser = new SkDisplayXMLParser(*fAnimator->fMaker);
+    fParser = new SkDisplayXMLParser(*fAnimator->fMaker);
 }
 
 SkXMLAnimatorWriter::~SkXMLAnimatorWriter() {
-       delete fParser;
+    delete fParser;
 }
 
 void SkXMLAnimatorWriter::onAddAttributeLen(const char name[], const char value[], size_t length)
 {
-       fParser->onAddAttributeLen(name, value, length);
+    fParser->onAddAttributeLen(name, value, length);
 }
 
 void SkXMLAnimatorWriter::onEndElement()
 {
-       Elem* elem = getEnd();
-       fParser->onEndElement(elem->fName.c_str());
-       doEnd(elem);
+    Elem* elem = getEnd();
+    fParser->onEndElement(elem->fName.c_str());
+    doEnd(elem);
 }
 
 void SkXMLAnimatorWriter::onStartElementLen(const char name[], size_t length)
 {
-       doStart(name, length);
-       fParser->onStartElementLen(name, length);
+    doStart(name, length);
+    fParser->onStartElementLen(name, length);
 }
 
 void SkXMLAnimatorWriter::writeHeader()
@@ -40,34 +57,34 @@ void SkXMLAnimatorWriter::writeHeader()
 
 void SkXMLAnimatorWriter::UnitTest(SkCanvas* canvas)
 {
-       SkAnimator      s;
-       SkXMLAnimatorWriter             w(&s);
-       w.startElement("screenplay");
-               w.startElement("animateField");
-                       w.addAttribute("field", "x1");
-                       w.addAttribute("id", "to100");
-                       w.addAttribute("from", "0");
-                       w.addAttribute("to", "100");
-                       w.addAttribute("dur", "1");
-               w.endElement();
-               w.startElement("event");
-                       w.addAttribute("kind", "onLoad");
-                       w.startElement("line");
-                               w.addAttribute("id", "line");
-                               w.addAttribute("x1", "-1");
-                               w.addAttribute("y1", "20");
-                               w.addAttribute("x2", "150");
-                               w.addAttribute("y2", "40");
-                       w.endElement();
-                       w.startElement("apply");
-                               w.addAttribute("animator", "to100");
-                               w.addAttribute("scope", "line");
-                       w.endElement();
-               w.endElement();
-       w.endElement();
-       SkPaint paint;
-       canvas->drawRGB(255, 255, 255);
-       s.draw(canvas, &paint, 0);
+    SkAnimator  s;
+    SkXMLAnimatorWriter     w(&s);
+    w.startElement("screenplay");
+        w.startElement("animateField");
+            w.addAttribute("field", "x1");
+            w.addAttribute("id", "to100");
+            w.addAttribute("from", "0");
+            w.addAttribute("to", "100");
+            w.addAttribute("dur", "1");
+        w.endElement();
+        w.startElement("event");
+            w.addAttribute("kind", "onLoad");
+            w.startElement("line");
+                w.addAttribute("id", "line");
+                w.addAttribute("x1", "-1");
+                w.addAttribute("y1", "20");
+                w.addAttribute("x2", "150");
+                w.addAttribute("y2", "40");
+            w.endElement();
+            w.startElement("apply");
+                w.addAttribute("animator", "to100");
+                w.addAttribute("scope", "line");
+            w.endElement();
+        w.endElement();
+    w.endElement();
+    SkPaint paint;
+    canvas->drawRGB(255, 255, 255);
+    s.draw(canvas, &paint, 0);
 }
 
 #endif
index 7180dbd..cc02b1c 100644 (file)
@@ -1,3 +1,20 @@
+/* libs/graphics/animator/SkXMLAnimatorWriter.h
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #ifndef SkXMLAnimatorWriter_DEFINED
 #define SkXMLAnimatorWriter_DEFINED
 
@@ -8,17 +25,17 @@ class SkDisplayXMLParser;
 
 class SkXMLAnimatorWriter : public SkXMLWriter {
 public:
-       SkXMLAnimatorWriter(SkAnimator*);
-       virtual ~SkXMLAnimatorWriter();
-       virtual void    writeHeader();
-       SkDEBUGCODE(static void UnitTest(class SkCanvas* canvas);)
+    SkXMLAnimatorWriter(SkAnimator*);
+    virtual ~SkXMLAnimatorWriter();
+    virtual void    writeHeader();
+    SkDEBUGCODE(static void UnitTest(class SkCanvas* canvas);)
 protected:
-       virtual void onAddAttributeLen(const char name[], const char value[], size_t length);
-       virtual void onEndElement();
-       virtual void onStartElementLen(const char elem[], size_t length);
+    virtual void onAddAttributeLen(const char name[], const char value[], size_t length);
+    virtual void onEndElement();
+    virtual void onStartElementLen(const char elem[], size_t length);
 private:
-       SkAnimator* fAnimator;
-       SkDisplayXMLParser* fParser;
+    SkAnimator* fAnimator;
+    SkDisplayXMLParser* fParser;
 };
 
 #endif // SkXMLAnimatorWriter_DEFINED
index 938858e..9835219 100644 (file)
@@ -1,31 +1,48 @@
+/* libs/graphics/effects/Sk1DPathEffect.cpp
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #include "Sk1DPathEffect.h"
 #include "SkPathMeasure.h"
 
 bool Sk1DPathEffect::filterPath(SkPath* dst, const SkPath& src, SkScalar* width)
 {
-       SkPathMeasure   meas(src, false);
-       do {
-               SkScalar        length = meas.getLength();
-               SkScalar        distance = this->begin(length);
-               while (distance < length)
-               {
-                       SkScalar delta = this->next(dst, distance, meas);
-                       if (delta <= 0)
-                               break;
-                       distance += delta;
-               }
-       } while (meas.nextContour());
-       return true;
+    SkPathMeasure   meas(src, false);
+    do {
+        SkScalar    length = meas.getLength();
+        SkScalar    distance = this->begin(length);
+        while (distance < length)
+        {
+            SkScalar delta = this->next(dst, distance, meas);
+            if (delta <= 0)
+                break;
+            distance += delta;
+        }
+    } while (meas.nextContour());
+    return true;
 }
 
 SkScalar Sk1DPathEffect::begin(SkScalar contourLength)
 {
-       return 0;
+    return 0;
 }
 
 SkScalar Sk1DPathEffect::next(SkPath* dst, SkScalar distance, SkPathMeasure&)
 {
-       return 0;
+    return 0;
 }
 
 ///////////////////////////////////////////////////////////////////////////////////////////
@@ -62,69 +79,69 @@ bool SkPath1DPathEffect::filterPath(SkPath* dst, const SkPath& src, SkScalar* wi
 }
 
 static void morphpoints(SkPoint dst[], const SkPoint src[], int count,
-                                               SkPathMeasure& meas, SkScalar dist)
+                        SkPathMeasure& meas, SkScalar dist)
 {
-       for (int i = 0; i < count; i++)
-       {
-               SkPoint pos;
-               SkVector tangent;
+    for (int i = 0; i < count; i++)
+    {
+        SkPoint pos;
+        SkVector tangent;
 
-               SkScalar sx = src[i].fX;
-               SkScalar sy = src[i].fY;
+        SkScalar sx = src[i].fX;
+        SkScalar sy = src[i].fY;
 
-               meas.getPosTan(dist + sx, &pos, &tangent);
+        meas.getPosTan(dist + sx, &pos, &tangent);
 
-               SkMatrix        matrix;
-               SkPoint         pt;
+        SkMatrix    matrix;
+        SkPoint     pt;
 
-               pt.set(sx, sy);
-               matrix.setSinCos(tangent.fY, tangent.fX, 0, 0);
-               matrix.preTranslate(-sx, 0);
-               matrix.postTranslate(pos.fX, pos.fY);
-               matrix.mapPoints(&dst[i], &pt, 1);
-       }
+        pt.set(sx, sy);
+        matrix.setSinCos(tangent.fY, tangent.fX, 0, 0);
+        matrix.preTranslate(-sx, 0);
+        matrix.postTranslate(pos.fX, pos.fY);
+        matrix.mapPoints(&dst[i], &pt, 1);
+    }
 }
 
-/*     TODO
+/*  TODO
 
-       Need differentially more subdivisions when the follow-path is curvy. Not sure how to
-       determine that, but we need it. I guess a cheap answer is let the caller tell us,
-       but that seems like a cop-out. Another answer is to get Rob Johnson to figure it out.
+    Need differentially more subdivisions when the follow-path is curvy. Not sure how to
+    determine that, but we need it. I guess a cheap answer is let the caller tell us,
+    but that seems like a cop-out. Another answer is to get Rob Johnson to figure it out.
 */
 static void morphpath(SkPath* dst, const SkPath& src, SkPathMeasure& meas, SkScalar dist)
 {
-       SkPath::Iter    iter(src, false);
-       SkPoint                 srcP[4], dstP[3];
-       SkPath::Verb    verb;
-
-       while ((verb = iter.next(srcP)) != SkPath::kDone_Verb)
-       {
-               switch (verb) {
-               case SkPath::kMove_Verb:
-                       morphpoints(dstP, srcP, 1, meas, dist);
-                       dst->moveTo(dstP[0]);
-                       break;
-               case SkPath::kLine_Verb:
-                       srcP[2] = srcP[1];
-                       srcP[1].set(SkScalarAve(srcP[0].fX, srcP[2].fX),
-                                               SkScalarAve(srcP[0].fY, srcP[2].fY));
-                       // fall through to quad
-               case SkPath::kQuad_Verb:
-                       morphpoints(dstP, &srcP[1], 2, meas, dist);
-                       dst->quadTo(dstP[0], dstP[1]);
-                       break;
-               case SkPath::kCubic_Verb:
-                       morphpoints(dstP, &srcP[1], 3, meas, dist);
-                       dst->cubicTo(dstP[0], dstP[1], dstP[2]);
-                       break;
-               case SkPath::kClose_Verb:
-                       dst->close();
-                       break;
-               default:
-                       SkASSERT(!"unknown verb");
-                       break;
-               }
-       }
+    SkPath::Iter    iter(src, false);
+    SkPoint         srcP[4], dstP[3];
+    SkPath::Verb    verb;
+
+    while ((verb = iter.next(srcP)) != SkPath::kDone_Verb)
+    {
+        switch (verb) {
+        case SkPath::kMove_Verb:
+            morphpoints(dstP, srcP, 1, meas, dist);
+            dst->moveTo(dstP[0]);
+            break;
+        case SkPath::kLine_Verb:
+            srcP[2] = srcP[1];
+            srcP[1].set(SkScalarAve(srcP[0].fX, srcP[2].fX),
+                        SkScalarAve(srcP[0].fY, srcP[2].fY));
+            // fall through to quad
+        case SkPath::kQuad_Verb:
+            morphpoints(dstP, &srcP[1], 2, meas, dist);
+            dst->quadTo(dstP[0], dstP[1]);
+            break;
+        case SkPath::kCubic_Verb:
+            morphpoints(dstP, &srcP[1], 3, meas, dist);
+            dst->cubicTo(dstP[0], dstP[1], dstP[2]);
+            break;
+        case SkPath::kClose_Verb:
+            dst->close();
+            break;
+        default:
+            SkASSERT(!"unknown verb");
+            break;
+        }
+    }
 }
 
 SkScalar SkPath1DPathEffect::begin(SkScalar contourLength)
index 601666d..72cac8f 100644 (file)
@@ -1,3 +1,20 @@
+/* libs/graphics/effects/Sk2DPathEffect.cpp
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #include "Sk2DPathEffect.h"
 #include "SkBlitter.h"
 #include "SkPath.h"
 
 class Sk2DPathEffectBlitter : public SkBlitter {
 public:
-       Sk2DPathEffectBlitter(Sk2DPathEffect* pe, SkPath* dst)
-               : fPE(pe), fDst(dst)
-       {}
-       virtual void blitH(int x, int y, int count)
-       {
-               fPE->nextSpan(x, y, count, fDst);
-       }
+    Sk2DPathEffectBlitter(Sk2DPathEffect* pe, SkPath* dst)
+        : fPE(pe), fDst(dst)
+    {}
+    virtual void blitH(int x, int y, int count)
+    {
+        fPE->nextSpan(x, y, count, fDst);
+    }
 private:
-       Sk2DPathEffect* fPE;
-       SkPath*                 fDst;
+    Sk2DPathEffect* fPE;
+    SkPath*         fDst;
 };
 
 ////////////////////////////////////////////////////////////////////////////////////
 
 Sk2DPathEffect::Sk2DPathEffect(const SkMatrix& mat) : fMatrix(mat)
 {
-       mat.invert(&fInverse);
+    mat.invert(&fInverse);
 }
 
 bool Sk2DPathEffect::filterPath(SkPath* dst, const SkPath& src, SkScalar* width)
 {
-       Sk2DPathEffectBlitter   blitter(this, dst);
-       SkPath                                  tmp;
-       SkRect                                  bounds;
-       SkRect16                                r;
-
-       src.transform(fInverse, &tmp);
-       tmp.computeBounds(&bounds, SkPath::kExact_BoundsType);
-       bounds.round(&r);
-       if (!r.isEmpty())
-       {
-               this->begin(r, dst);
-               SkScan::FillPath(tmp, nil, &blitter);
-               this->end(dst);
-       }
-       return true;
+    Sk2DPathEffectBlitter   blitter(this, dst);
+    SkPath                  tmp;
+    SkRect                  bounds;
+    SkRect16                r;
+
+    src.transform(fInverse, &tmp);
+    tmp.computeBounds(&bounds, SkPath::kExact_BoundsType);
+    bounds.round(&r);
+    if (!r.isEmpty())
+    {
+        this->begin(r, dst);
+        SkScan::FillPath(tmp, nil, &blitter);
+        this->end(dst);
+    }
+    return true;
 }
 
 void Sk2DPathEffect::nextSpan(int x, int y, int count, SkPath* path)
 {
-       const SkMatrix& mat = this->getMatrix();
-       SkPoint src, dst;
-
-       src.set(SkIntToScalar(x) + SK_ScalarHalf, SkIntToScalar(y) + SK_ScalarHalf);
-       do {
-               mat.mapPoints(&dst, &src, 1);
-               this->next(dst, x++, y, path);
-               src.fX += SK_Scalar1;
-       } while (--count > 0);
+    const SkMatrix& mat = this->getMatrix();
+    SkPoint src, dst;
+
+    src.set(SkIntToScalar(x) + SK_ScalarHalf, SkIntToScalar(y) + SK_ScalarHalf);
+    do {
+        mat.mapPoints(&dst, &src, 1);
+        this->next(dst, x++, y, path);
+        src.fX += SK_Scalar1;
+    } while (--count > 0);
 }
 
 void Sk2DPathEffect::begin(const SkRect16& uvBounds, SkPath* dst) {}
@@ -72,7 +89,7 @@ void Sk2DPathEffect::flatten(SkWBuffer& buffer)
 Sk2DPathEffect::Sk2DPathEffect(SkRBuffer& buffer) : SkPathEffect(buffer)
 {
     buffer.read(&fMatrix, sizeof(fMatrix));
-       fMatrix.invert(&fInverse);
+    fMatrix.invert(&fInverse);
 }
 
 SkFlattenable::Factory Sk2DPathEffect::getFactory()
index 80f0310..fd466ec 100644 (file)
@@ -1,3 +1,20 @@
+/* libs/graphics/effects/SkAvoidXfermode.cpp
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #include "SkAvoidXfermode.h"
 #include "SkColorPriv.h"
 
@@ -44,28 +61,28 @@ static int scale_dist_14(int dist, uint32_t mul, uint32_t sub)
 
 static SkPMColor SkFourByteInterp(SkPMColor src, SkPMColor dst, U8CPU alpha)
 {
-       unsigned scale = SkAlpha255To256(alpha);
+    unsigned scale = SkAlpha255To256(alpha);
 
-       unsigned a = SkAlphaBlend(SkGetPackedA32(src), SkGetPackedA32(dst), scale);
-       unsigned r = SkAlphaBlend(SkGetPackedR32(src), SkGetPackedR32(dst), scale);
-       unsigned g = SkAlphaBlend(SkGetPackedG32(src), SkGetPackedG32(dst), scale);
-       unsigned b = SkAlphaBlend(SkGetPackedB32(src), SkGetPackedB32(dst), scale);
+    unsigned a = SkAlphaBlend(SkGetPackedA32(src), SkGetPackedA32(dst), scale);
+    unsigned r = SkAlphaBlend(SkGetPackedR32(src), SkGetPackedR32(dst), scale);
+    unsigned g = SkAlphaBlend(SkGetPackedG32(src), SkGetPackedG32(dst), scale);
+    unsigned b = SkAlphaBlend(SkGetPackedB32(src), SkGetPackedB32(dst), scale);
 
-       return SkPackARGB32(a, r, g, b);
+    return SkPackARGB32(a, r, g, b);
 }
 
 void SkAvoidXfermode::xfer32(SkPMColor dst[], const SkPMColor src[], int count, const SkAlpha aa[])
 {
-       // override in subclass
+    // override in subclass
 }
 
 static inline U16CPU SkBlend3216(SkPMColor src, U16CPU dst, unsigned scale)
 {
-       SkASSERT(scale <= 256);
+    SkASSERT(scale <= 256);
 
-       return SkPackRGB16(     SkAlphaBlend(SkPacked32ToR16(src), SkGetPackedR16(dst), scale),
-                                               SkAlphaBlend(SkPacked32ToG16(src), SkGetPackedG16(dst), scale),
-                                               SkAlphaBlend(SkPacked32ToB16(src), SkGetPackedB16(dst), scale));
+    return SkPackRGB16( SkAlphaBlend(SkPacked32ToR16(src), SkGetPackedR16(dst), scale),
+                        SkAlphaBlend(SkPacked32ToG16(src), SkGetPackedG16(dst), scale),
+                        SkAlphaBlend(SkPacked32ToB16(src), SkGetPackedB16(dst), scale));
 }
 
 void SkAvoidXfermode::xfer16(uint16_t dst[], const SkPMColor src[], int count, const SkAlpha aa[])
@@ -126,6 +143,6 @@ void SkAvoidXfermode::xfer16(uint16_t dst[], const SkPMColor src[], int count, c
 
 void SkAvoidXfermode::xferA8(SkAlpha dst[], const SkPMColor src[], int count, const SkAlpha aa[])
 {
-       // override in subclass
+    // override in subclass
 }
 
index 8502342..e5e421c 100644 (file)
+/* libs/graphics/effects/SkBlurMask.cpp
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #include "SkBlurMask.h"
 #include "SkTemplates.h"
 
 static void build_sum_buffer(uint32_t dst[], int w, int h, const uint8_t src[])
 {
-       int     x, y;
-
-       // special case first row
-       uint32_t X = 0;
-       for (x = w - 1; x >= 0; --x)
-       {
-               X = *src++ + X;
-               *dst++ = X;
-       }
-       // now do the rest of the rows
-       for (y = h - 1; y > 0; --y)
-       {
-               uint32_t L = 0;
-               uint32_t C = 0;
-               for (x = w - 1; x >= 0; --x)
-               {
-                       uint32_t T = dst[-w];
-                       X = *src++ + L + T - C;
-                       *dst++ = X;
-                       L = X;
-                       C = T;
-               }
-       }
+    int x, y;
+
+    // special case first row
+    uint32_t X = 0;
+    for (x = w - 1; x >= 0; --x)
+    {
+        X = *src++ + X;
+        *dst++ = X;
+    }
+    // now do the rest of the rows
+    for (y = h - 1; y > 0; --y)
+    {
+        uint32_t L = 0;
+        uint32_t C = 0;
+        for (x = w - 1; x >= 0; --x)
+        {
+            uint32_t T = dst[-w];
+            X = *src++ + L + T - C;
+            *dst++ = X;
+            L = X;
+            C = T;
+        }
+    }
 }
 
 static void apply_kernel(uint8_t dst[], int rx, int ry, const uint32_t src[], int sw, int sh)
 {
-       uint32_t scale = (1 << 24) / ((2*rx + 1)*(2*ry + 1));
+    uint32_t scale = (1 << 24) / ((2*rx + 1)*(2*ry + 1));
 
-       int rowBytes = sw;
+    int rowBytes = sw;
 
-       int     dw = sw + 2*rx;
-       int dh = sh + 2*ry;
+    int dw = sw + 2*rx;
+    int dh = sh + 2*ry;
 
-       sw -= 1;        // now it is max_x
-       sh -= 1;        // now it is max_y
+    sw -= 1;    // now it is max_x
+    sh -= 1;    // now it is max_y
 
-       int     prev_y = -ry - 1        -ry;
-       int     next_y = ry                     -ry;
+    int prev_y = -ry - 1    -ry;
+    int next_y = ry         -ry;
 
-       for (int y = 0; y < dh; y++)
-       {
-               int py = SkClampPos(prev_y) * rowBytes;
-               int     ny = SkFastMin32(next_y, sh) * rowBytes;
+    for (int y = 0; y < dh; y++)
+    {
+        int py = SkClampPos(prev_y) * rowBytes;
+        int ny = SkFastMin32(next_y, sh) * rowBytes;
 
-               int prev_x = -rx - 1    -rx;
-               int next_x = rx                 -rx;
+        int prev_x = -rx - 1    -rx;
+        int next_x = rx         -rx;
 
-               for (int x = 0; x < dw; x++)
-               {
-                       int px = SkClampPos(prev_x);
-                       int     nx = SkFastMin32(next_x, sw);
+        for (int x = 0; x < dw; x++)
+        {
+            int px = SkClampPos(prev_x);
+            int nx = SkFastMin32(next_x, sw);
 
-                       uint32_t sum = src[px+py] + src[nx+ny] - src[nx+py] - src[px+ny];
-                       *dst++ = SkToU8(sum * scale >> 24);
+            uint32_t sum = src[px+py] + src[nx+ny] - src[nx+py] - src[px+ny];
+            *dst++ = SkToU8(sum * scale >> 24);
 
-                       prev_x += 1;
-                       next_x += 1;
-               }
-               prev_y += 1;
-               next_y += 1;
-       }
+            prev_x += 1;
+            next_x += 1;
+        }
+        prev_y += 1;
+        next_y += 1;
+    }
 }
 
 static void apply_kernel_interp(uint8_t dst[], int rx, int ry, const uint32_t src[], int sw, int sh, U8CPU outer_weight)
 {
-       SkASSERT(rx > 0 && ry > 0);
-       SkASSERT(outer_weight <= 255);
+    SkASSERT(rx > 0 && ry > 0);
+    SkASSERT(outer_weight <= 255);
 
-       int inner_weight = 255 - outer_weight;
+    int inner_weight = 255 - outer_weight;
 
-       // round these guys up if they're bigger than 127
-       outer_weight += outer_weight >> 7;
-       inner_weight += inner_weight >> 7;
+    // round these guys up if they're bigger than 127
+    outer_weight += outer_weight >> 7;
+    inner_weight += inner_weight >> 7;
 
-       uint32_t outer_scale = (outer_weight << 16) / ((2*rx + 1)*(2*ry + 1));
-       uint32_t inner_scale = (inner_weight << 16) / ((2*rx - 1)*(2*ry - 1));
+    uint32_t outer_scale = (outer_weight << 16) / ((2*rx + 1)*(2*ry + 1));
+    uint32_t inner_scale = (inner_weight << 16) / ((2*rx - 1)*(2*ry - 1));
 
-       int rowBytes = sw;
+    int rowBytes = sw;
 
-       int     dw = sw + 2*rx;
-       int dh = sh + 2*ry;
+    int dw = sw + 2*rx;
+    int dh = sh + 2*ry;
 
-       sw -= 1;        // now it is max_x
-       sh -= 1;        // now it is max_y
+    sw -= 1;    // now it is max_x
+    sh -= 1;    // now it is max_y
 
-       int     prev_y = -ry - 1        -ry;
-       int     next_y = ry                     -ry;
+    int prev_y = -ry - 1    -ry;
+    int next_y = ry         -ry;
 
-       for (int y = 0; y < dh; y++)
-       {
-               int py = SkClampPos(prev_y) * rowBytes;
-               int     ny = SkFastMin32(next_y, sh) * rowBytes;
+    for (int y = 0; y < dh; y++)
+    {
+        int py = SkClampPos(prev_y) * rowBytes;
+        int ny = SkFastMin32(next_y, sh) * rowBytes;
 
-               int ipy = SkClampPos(prev_y + 1) * rowBytes;
-               int     iny = SkClampMax(next_y - 1, sh) * rowBytes;
+        int ipy = SkClampPos(prev_y + 1) * rowBytes;
+        int iny = SkClampMax(next_y - 1, sh) * rowBytes;
 
-               int prev_x = -rx - 1    -rx;
-               int next_x = rx                 -rx;
+        int prev_x = -rx - 1    -rx;
+        int next_x = rx         -rx;
 
-               for (int x = 0; x < dw; x++)
-               {
-                       int px = SkClampPos(prev_x);
-                       int     nx = SkFastMin32(next_x, sw);
+        for (int x = 0; x < dw; x++)
+        {
+            int px = SkClampPos(prev_x);
+            int nx = SkFastMin32(next_x, sw);
 
-                       int ipx = SkClampPos(prev_x + 1);
-                       int     inx = SkClampMax(next_x - 1, sw);
+            int ipx = SkClampPos(prev_x + 1);
+            int inx = SkClampMax(next_x - 1, sw);
 
-                       uint32_t outer_sum = src[px+py] + src[nx+ny] - src[nx+py] - src[px+ny];
-                       uint32_t inner_sum = src[ipx+ipy] + src[inx+iny] - src[inx+ipy] - src[ipx+iny];
-                       *dst++ = SkToU8((outer_sum * outer_scale + inner_sum * inner_scale) >> 24);
+            uint32_t outer_sum = src[px+py] + src[nx+ny] - src[nx+py] - src[px+ny];
+            uint32_t inner_sum = src[ipx+ipy] + src[inx+iny] - src[inx+ipy] - src[ipx+iny];
+            *dst++ = SkToU8((outer_sum * outer_scale + inner_sum * inner_scale) >> 24);
 
-                       prev_x += 1;
-                       next_x += 1;
-               }
-               prev_y += 1;
-               next_y += 1;
-       }
+            prev_x += 1;
+            next_x += 1;
+        }
+        prev_y += 1;
+        next_y += 1;
+    }
 }
 
 #include "SkColorPriv.h"
 
 static void merge_src_with_blur(uint8_t dst[],
-                                                               const uint8_t src[], int sw, int sh,
-                                                               const uint8_t blur[], int blurRowBytes)
+                                const uint8_t src[], int sw, int sh,
+                                const uint8_t blur[], int blurRowBytes)
 {
-       while (--sh >= 0)
-       {
-               for (int x = sw - 1; x >= 0; --x)
-               {
-                       *dst = SkToU8(SkAlphaMul(*blur, SkAlpha255To256(*src)));
-                       dst += 1;
-                       src += 1;
-                       blur += 1;
-               }
-               blur += blurRowBytes - sw;
-       }
+    while (--sh >= 0)
+    {
+        for (int x = sw - 1; x >= 0; --x)
+        {
+            *dst = SkToU8(SkAlphaMul(*blur, SkAlpha255To256(*src)));
+            dst += 1;
+            src += 1;
+            blur += 1;
+        }
+        blur += blurRowBytes - sw;
+    }
 }
 
 static void clamp_with_orig(uint8_t dst[], int dstRowBytes,
-                                                       const uint8_t src[], int sw, int sh,
-                                                       SkBlurMask::Style style)
+                            const uint8_t src[], int sw, int sh,
+                            SkBlurMask::Style style)
 {
-       int     x;
-       while (--sh >= 0)
-       {
-               switch (style) {
-               case SkBlurMask::kSolid_Style:
-                       for (x = sw - 1; x >= 0; --x)
-                       {
-                               *dst = SkToU8(*src + SkAlphaMul(*dst, SkAlpha255To256(255 - *src)));
-                               dst += 1;
-                               src += 1;
-                       }
-                       break;
-               case SkBlurMask::kOuter_Style:
-                       for (x = sw - 1; x >= 0; --x)
-                       {
-                               if (*src)
-                                       *dst = SkToU8(SkAlphaMul(*dst, SkAlpha255To256(255 - *src)));
-                               dst += 1;
-                               src += 1;
-                       }
-                       break;
-               default:
-                       SkASSERT(!"Unexpected blur style here");
-                       break;
-               }
-               dst += dstRowBytes - sw;
-       }
+    int x;
+    while (--sh >= 0)
+    {
+        switch (style) {
+        case SkBlurMask::kSolid_Style:
+            for (x = sw - 1; x >= 0; --x)
+            {
+                *dst = SkToU8(*src + SkAlphaMul(*dst, SkAlpha255To256(255 - *src)));
+                dst += 1;
+                src += 1;
+            }
+            break;
+        case SkBlurMask::kOuter_Style:
+            for (x = sw - 1; x >= 0; --x)
+            {
+                if (*src)
+                    *dst = SkToU8(SkAlphaMul(*dst, SkAlpha255To256(255 - *src)));
+                dst += 1;
+                src += 1;
+            }
+            break;
+        default:
+            SkASSERT(!"Unexpected blur style here");
+            break;
+        }
+        dst += dstRowBytes - sw;
+    }
 }
 
 ////////////////////////////////////////////////////////////////////////
@@ -186,123 +203,123 @@ void SkMask_FreeImage(uint8_t* image)
 }
 
 bool SkBlurMask::Blur(SkMask* dst, const SkMask& src,
-                                         SkScalar radius, Style style)
+                      SkScalar radius, Style style)
 {
-       if (src.fFormat != SkMask::kA8_Format)
-               return false;
+    if (src.fFormat != SkMask::kA8_Format)
+        return false;
 
-       int     rx = SkScalarCeil(radius);
-       int     outer_weight = 255 - SkScalarRound((SkIntToScalar(rx) - radius) * 255);
+    int rx = SkScalarCeil(radius);
+    int outer_weight = 255 - SkScalarRound((SkIntToScalar(rx) - radius) * 255);
 
-       SkASSERT(rx >= 0);
-       SkASSERT((unsigned)outer_weight <= 255);
+    SkASSERT(rx >= 0);
+    SkASSERT((unsigned)outer_weight <= 255);
 
-       if (rx == 0)
-               return false;
+    if (rx == 0)
+        return false;
 
-       int ry = rx;    // only do square blur for now
+    int ry = rx;    // only do square blur for now
 
-       dst->fBounds.set(src.fBounds.fLeft - rx, src.fBounds.fTop - ry,
-                                               src.fBounds.fRight + rx, src.fBounds.fBottom + ry);
-       dst->fRowBytes = SkToU16(dst->fBounds.width());
-       dst->fFormat = SkMask::kA8_Format;
-       dst->fImage     = nil;
+    dst->fBounds.set(src.fBounds.fLeft - rx, src.fBounds.fTop - ry,
+                        src.fBounds.fRight + rx, src.fBounds.fBottom + ry);
+    dst->fRowBytes = SkToU16(dst->fBounds.width());
+    dst->fFormat = SkMask::kA8_Format;
+    dst->fImage = nil;
 
-       if (src.fImage)
-       {
-               int             sw = src.fBounds.width();
-               int             sh = src.fBounds.height();
-               const uint8_t*  sp = src.fImage;
-               uint8_t*        dp = SkMask::AllocImage(dst->computeImageSize());
+    if (src.fImage)
+    {
+        int             sw = src.fBounds.width();
+        int             sh = src.fBounds.height();
+        const uint8_t*  sp = src.fImage;
+        uint8_t*        dp = SkMask::AllocImage(dst->computeImageSize());
 
-               SkAutoTCallProc<uint8_t, SkMask_FreeImage> autoCall(dp);
+        SkAutoTCallProc<uint8_t, SkMask_FreeImage> autoCall(dp);
 
-               // build the blurry destination
-               {
+        // build the blurry destination
+        {
             SkAutoTMalloc<uint32_t> storage(sw * sh);
-                       uint32_t*               sumBuffer = storage.get();
-
-                       build_sum_buffer(sumBuffer, sw, sh, sp);
-                       if (outer_weight == 255)
-                               apply_kernel(dp, rx, ry, sumBuffer, sw, sh);
-                       else
-                               apply_kernel_interp(dp, rx, ry, sumBuffer, sw, sh, outer_weight);
-               }
-
-               dst->fImage = dp;
-               // if need be, alloc the "real" dst (same size as src) and copy/merge
-               // the blur into it (applying the src)
-               if (style == kInner_Style)
-               {
-                       dst->fImage = SkMask::AllocImage(src.computeImageSize());
-                       merge_src_with_blur(dst->fImage, sp, sw, sh,
-                                                               dp + rx + ry*dst->fBounds.width(),
-                                                               dst->fBounds.width());
-                       SkMask::FreeImage(dp);
-               }
-               else if (style != kNormal_Style)
-               {
-                       clamp_with_orig(dp + rx + ry*dst->fBounds.width(),
-                                                       dst->fBounds.width(),
-                                                       sp, sw, sh,
-                                                       style);
-               }
-               (void)autoCall.detach();
-       }
-
-       if (style == kInner_Style)
-       {
-               dst->fBounds = src.fBounds;     // restore trimmed bounds
-               dst->fRowBytes = SkToU16(dst->fBounds.width());
-       }
+            uint32_t*               sumBuffer = storage.get();
+
+            build_sum_buffer(sumBuffer, sw, sh, sp);
+            if (outer_weight == 255)
+                apply_kernel(dp, rx, ry, sumBuffer, sw, sh);
+            else
+                apply_kernel_interp(dp, rx, ry, sumBuffer, sw, sh, outer_weight);
+        }
+
+        dst->fImage = dp;
+        // if need be, alloc the "real" dst (same size as src) and copy/merge
+        // the blur into it (applying the src)
+        if (style == kInner_Style)
+        {
+            dst->fImage = SkMask::AllocImage(src.computeImageSize());
+            merge_src_with_blur(dst->fImage, sp, sw, sh,
+                                dp + rx + ry*dst->fBounds.width(),
+                                dst->fBounds.width());
+            SkMask::FreeImage(dp);
+        }
+        else if (style != kNormal_Style)
+        {
+            clamp_with_orig(dp + rx + ry*dst->fBounds.width(),
+                            dst->fBounds.width(),
+                            sp, sw, sh,
+                            style);
+        }
+        (void)autoCall.detach();
+    }
+
+    if (style == kInner_Style)
+    {
+        dst->fBounds = src.fBounds; // restore trimmed bounds
+        dst->fRowBytes = SkToU16(dst->fBounds.width());
+    }
 
 #if 0
-       if (gamma && dst->fImage)
-       {
-               uint8_t*        image = dst->fImage;
-               uint8_t*        stop = image + dst->computeImageSize();
-
-               for (; image < stop; image += 1)
-                       *image = gamma[*image];
-       }
+    if (gamma && dst->fImage)
+    {
+        uint8_t*    image = dst->fImage;
+        uint8_t*    stop = image + dst->computeImageSize();
+
+        for (; image < stop; image += 1)
+            *image = gamma[*image];
+    }
 #endif
-       return true;
+    return true;
 }
 
 #if 0
 void SkBlurMask::BuildSqrtGamma(uint8_t gamma[256], SkScalar percent)
 {
-       SkASSERT(gamma);
-       SkASSERT(percent >= 0 && percent <= SK_Scalar1);
-
-       int     scale = SkScalarRound(percent * 256);
-
-       for (int i = 0; i < 256; i++)
-       {
-               SkFixed n = i * 257;
-               n += n >> 15;
-               SkASSERT(n >= 0 && n <= SK_Fixed1);
-               n = SkFixedSqrt(n);
-               n = n * 255 >> 16;
-               n = SkAlphaBlend(n, i, scale);
-               gamma[i] = SkToU8(n);
-       }
+    SkASSERT(gamma);
+    SkASSERT(percent >= 0 && percent <= SK_Scalar1);
+
+    int scale = SkScalarRound(percent * 256);
+
+    for (int i = 0; i < 256; i++)
+    {
+        SkFixed n = i * 257;
+        n += n >> 15;
+        SkASSERT(n >= 0 && n <= SK_Fixed1);
+        n = SkFixedSqrt(n);
+        n = n * 255 >> 16;
+        n = SkAlphaBlend(n, i, scale);
+        gamma[i] = SkToU8(n);
+    }
 }
 
 void SkBlurMask::BuildSqrGamma(uint8_t gamma[256], SkScalar percent)
 {
-       SkASSERT(gamma);
-       SkASSERT(percent >= 0 && percent <= SK_Scalar1);
-
-       int             scale = SkScalarRound(percent * 256);
-       SkFixed div255 = SK_Fixed1 / 255;
-
-       for (int i = 0; i < 256; i++)
-       {
-               int square = i * i;
-               int linear = i * 255;
-               int n = SkAlphaBlend(square, linear, scale);
-               gamma[i] = SkToU8(n * div255 >> 16);
-       }
+    SkASSERT(gamma);
+    SkASSERT(percent >= 0 && percent <= SK_Scalar1);
+
+    int     scale = SkScalarRound(percent * 256);
+    SkFixed div255 = SK_Fixed1 / 255;
+
+    for (int i = 0; i < 256; i++)
+    {
+        int square = i * i;
+        int linear = i * 255;
+        int n = SkAlphaBlend(square, linear, scale);
+        gamma[i] = SkToU8(n * div255 >> 16);
+    }
 }
 #endif
index 40cea94..2df5731 100644 (file)
@@ -1,3 +1,20 @@
+/* libs/graphics/effects/SkBlurMask.h
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #ifndef SkBlurMask_DEFINED
 #define SkBlurMask_DEFINED
 
 
 class SkBlurMask {
 public:
-       enum Style {
-               kNormal_Style,  //!< fuzzy inside and outside
-               kSolid_Style,   //!< solid inside, fuzzy outside
-               kOuter_Style,   //!< nothing inside, fuzzy outside
-               kInner_Style,   //!< fuzzy inside, nothing outside
+    enum Style {
+        kNormal_Style,  //!< fuzzy inside and outside
+        kSolid_Style,   //!< solid inside, fuzzy outside
+        kOuter_Style,   //!< nothing inside, fuzzy outside
+        kInner_Style,   //!< fuzzy inside, nothing outside
 
-               kStyleCount
-       };
+        kStyleCount
+    };
 
-       static bool Blur(SkMask* dst, const SkMask& src, SkScalar radius, Style);
+    static bool Blur(SkMask* dst, const SkMask& src, SkScalar radius, Style);
 };
 
 #endif
index 8073bc5..c05674e 100644 (file)
@@ -1,26 +1,43 @@
+/* libs/graphics/effects/SkBlurMaskFilter.cpp
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #include "SkBlurMaskFilter.h"
 #include "SkBlurMask.h"
 #include "SkBuffer.h"
 
 class SkBlurMaskFilterImpl : public SkMaskFilter {
 public:
-       SkBlurMaskFilterImpl(SkScalar radius, SkBlurMaskFilter::BlurStyle style);
+    SkBlurMaskFilterImpl(SkScalar radius, SkBlurMaskFilter::BlurStyle style);
 
-       // overrides from SkMaskFilter
-       virtual SkMask::Format getFormat();
-       virtual bool filterMask(SkMask* dst, const SkMask& src, const SkMatrix& matrix, SkPoint16* margin);
+    // overrides from SkMaskFilter
+    virtual SkMask::Format getFormat();
+    virtual bool filterMask(SkMask* dst, const SkMask& src, const SkMatrix& matrix, SkPoint16* margin);
 
-       // overrides from SkFlattenable
+    // overrides from SkFlattenable
     // This method is not exported to java.
-       virtual Factory getFactory();
+    virtual Factory getFactory();
     // This method is not exported to java.
-       virtual void flatten(SkWBuffer&);
+    virtual void flatten(SkWBuffer&);
 
 private:
-       SkScalar                    fRadius;
-       SkBlurMaskFilter::BlurStyle     fBlurStyle;
+    SkScalar                    fRadius;
+    SkBlurMaskFilter::BlurStyle fBlurStyle;
 
-       static SkFlattenable* CreateProc(SkRBuffer&);
+    static SkFlattenable* CreateProc(SkRBuffer&);
     SkBlurMaskFilterImpl(SkRBuffer&);
     
     typedef SkMaskFilter INHERITED;
@@ -37,36 +54,36 @@ SkMaskFilter* SkBlurMaskFilter::Create(SkScalar radius, SkBlurMaskFilter::BlurSt
 /////////////////////////////////////////////////////////////////////////////////////////////////////////
 
 SkBlurMaskFilterImpl::SkBlurMaskFilterImpl(SkScalar radius, SkBlurMaskFilter::BlurStyle style)
-       : fRadius(radius), fBlurStyle(style)
+    : fRadius(radius), fBlurStyle(style)
 {
 #if 0
-       fGamma = NULL;
-       if (gammaScale)
-       {
-               fGamma = new U8[256];
-               if (gammaScale > 0)
-                       SkBlurMask::BuildSqrGamma(fGamma, gammaScale);
-               else
-                       SkBlurMask::BuildSqrtGamma(fGamma, -gammaScale);
-       }
+    fGamma = NULL;
+    if (gammaScale)
+    {
+        fGamma = new U8[256];
+        if (gammaScale > 0)
+            SkBlurMask::BuildSqrGamma(fGamma, gammaScale);
+        else
+            SkBlurMask::BuildSqrtGamma(fGamma, -gammaScale);
+    }
 #endif
-       SkASSERT(radius >= 0);
-       SkASSERT((unsigned)style < SkBlurMaskFilter::kBlurStyleCount);
+    SkASSERT(radius >= 0);
+    SkASSERT((unsigned)style < SkBlurMaskFilter::kBlurStyleCount);
 }
 
 SkMask::Format SkBlurMaskFilterImpl::getFormat()
 {
-       return SkMask::kA8_Format;
+    return SkMask::kA8_Format;
 }
 
 bool SkBlurMaskFilterImpl::filterMask(SkMask* dst, const SkMask& src, const SkMatrix& matrix, SkPoint16* margin)
 {
-       SkScalar radius = matrix.mapRadius(fRadius);
+    SkScalar radius = matrix.mapRadius(fRadius);
 
-       if (margin)
-               margin->set(SkScalarCeil(radius), SkScalarCeil(radius));
+    if (margin)
+        margin->set(SkScalarCeil(radius), SkScalarCeil(radius));
 
-       return SkBlurMask::Blur(dst, src, radius, (SkBlurMask::Style)fBlurStyle);
+    return SkBlurMask::Blur(dst, src, radius, (SkBlurMask::Style)fBlurStyle);
 }
 
 SkFlattenable* SkBlurMaskFilterImpl::CreateProc(SkRBuffer& buffer)
@@ -76,15 +93,15 @@ SkFlattenable* SkBlurMaskFilterImpl::CreateProc(SkRBuffer& buffer)
 
 SkFlattenable::Factory SkBlurMaskFilterImpl::getFactory()
 {
-       return CreateProc;
+    return CreateProc;
 }
 
 SkBlurMaskFilterImpl::SkBlurMaskFilterImpl(SkRBuffer& buffer) : SkMaskFilter(buffer)
 {
     fRadius = buffer.readScalar();
     fBlurStyle = (SkBlurMaskFilter::BlurStyle)buffer.readS32();
-       SkASSERT(fRadius >= 0);
-       SkASSERT((unsigned)fBlurStyle < SkBlurMaskFilter::kBlurStyleCount);
+    SkASSERT(fRadius >= 0);
+    SkASSERT((unsigned)fBlurStyle < SkBlurMaskFilter::kBlurStyleCount);
 }
 
 void SkBlurMaskFilterImpl::flatten(SkWBuffer& buffer)
index fcebf44..14c84dd 100644 (file)
@@ -1,37 +1,75 @@
+/* libs/graphics/effects/SkCamera.cpp
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #include "SkCamera.h"
 
-static SkScalar VectorMultiplyDivide(int count, const SkScalar a[], int step_a,
-                                                                        const SkScalar b[], int step_b, SkScalar denom)
+static SkScalar SkScalarDotDiv(int count, const SkScalar a[], int step_a,
+                               const SkScalar b[], int step_b,
+                               SkScalar denom)
+{
+#ifdef SK_SCALAR_IS_FLOAT
+    float prod = 0;
+    for (int i = 0; i < count; i++)
+    {
+        prod += a[0] * b[0];
+        a += step_a;
+        b += step_b;
+    }
+    return prod / denom;
+#else
+    Sk64    prod, tmp;
+
+    prod.set(0);
+    for (int i = 0; i < count; i++)
+    {
+        tmp.setMul(a[0], b[0]);
+        prod.add(tmp);
+        a += step_a;
+        b += step_b;
+    }
+    prod.div(denom, Sk64::kRound_DivOption);
+    return prod.get32();
+#endif
+}
+
+static SkScalar SkScalarDot(int count, const SkScalar a[], int step_a,
+                                       const SkScalar b[], int step_b)
 {
 #ifdef SK_SCALAR_IS_FLOAT
-       float prod = 0;
-       for (int i = 0; i < count; i++)
-       {
-               prod += a[0] * b[0];
-               a += step_a;
-               b += step_b;
-       }
-       if (denom)      // denom == 0 is a formal signal to not divide
-               prod /= denom;
-       return prod;
+    float prod = 0;
+    for (int i = 0; i < count; i++)
+    {
+        prod += a[0] * b[0];
+        a += step_a;
+        b += step_b;
+    }
+    return prod;
 #else
-       Sk64    prod, tmp;
-
-       prod.set(0);
-       for (int i = 0; i < count; i++)
-       {
-               tmp.setMul(a[0], b[0]);
-               prod.add(tmp);
-               a += step_a;
-               b += step_b;
-       }
-       if (denom)
-       {
-               prod.div(denom, Sk64::kRound_DivOption);
-               return prod.get32();
-       }
-       else    // denom == 0 is a formal signal to treat the product as a fixed (i.e. denom = SK_Fixed1)
-               return prod.getFixed();
+    Sk64    prod, tmp;
+
+    prod.set(0);
+    for (int i = 0; i < count; i++)
+    {
+        tmp.setMul(a[0], b[0]);
+        prod.add(tmp);
+        a += step_a;
+        b += step_b;
+    }
+    return prod.getFixed();
 #endif
 }
 
@@ -40,212 +78,368 @@ static SkScalar VectorMultiplyDivide(int count, const SkScalar a[], int step_a,
 SkUnitScalar SkPoint3D::normalize(SkUnit3D* unit) const
 {
 #ifdef SK_SCALAR_IS_FLOAT
-       float mag = sk_float_sqrt(fX*fX + fY*fY + fZ*fZ);
-       if (mag)
-       {
-               float scale = 1.0f / mag;
-               unit->fX = fX * scale;
-               unit->fY = fY * scale;
-               unit->fZ = fZ * scale;
-       }
+    float mag = sk_float_sqrt(fX*fX + fY*fY + fZ*fZ);
+    if (mag)
+    {
+        float scale = 1.0f / mag;
+        unit->fX = fX * scale;
+        unit->fY = fY * scale;
+        unit->fZ = fZ * scale;
+    }
 #else
-       Sk64    tmp1, tmp2;
-
-       tmp1.setMul(fX, fX);
-       tmp2.setMul(fY, fY);
-       tmp1.add(tmp2);
-       tmp2.setMul(fZ, fZ);
-       tmp1.add(tmp2);
-
-       SkFixed mag = tmp1.getSqrt();
-       if (mag)
-       {
-               // what if mag < SK_Fixed1 ??? we will underflow the fixdiv
-               SkFixed scale = SkFixedDiv(SK_Fract1, mag);
-               unit->fX = SkFixedMul(fX, scale);
-               unit->fY = SkFixedMul(fY, scale);
-               unit->fZ = SkFixedMul(fZ, scale);
-       }
+    Sk64    tmp1, tmp2;
+
+    tmp1.setMul(fX, fX);
+    tmp2.setMul(fY, fY);
+    tmp1.add(tmp2);
+    tmp2.setMul(fZ, fZ);
+    tmp1.add(tmp2);
+
+    SkFixed mag = tmp1.getSqrt();
+    if (mag)
+    {
+        // what if mag < SK_Fixed1 ??? we will underflow the fixdiv
+        SkFixed scale = SkFixedDiv(SK_Fract1, mag);
+        unit->fX = SkFixedMul(fX, scale);
+        unit->fY = SkFixedMul(fY, scale);
+        unit->fZ = SkFixedMul(fZ, scale);
+    }
 #endif
-       return mag;
+    return mag;
 }
 
 SkUnitScalar SkUnit3D::Dot(const SkUnit3D& a, const SkUnit3D& b)
 {
-       return  SkUnitScalarMul(a.fX, b.fX) +
-                       SkUnitScalarMul(a.fY, b.fY) +
-                       SkUnitScalarMul(a.fZ, b.fZ);
+    return  SkUnitScalarMul(a.fX, b.fX) +
+            SkUnitScalarMul(a.fY, b.fY) +
+            SkUnitScalarMul(a.fZ, b.fZ);
 }
 
 void SkUnit3D::Cross(const SkUnit3D& a, const SkUnit3D& b, SkUnit3D* cross)
 {
-       SkASSERT(cross);
+    SkASSERT(cross);
 
-       // use x,y,z, in case &a == cross or &b == cross
+    // use x,y,z, in case &a == cross or &b == cross
 
 
-       SkScalar x = SkUnitScalarMul(a.fY, b.fZ) - SkUnitScalarMul(a.fZ, b.fY);
-       SkScalar y = SkUnitScalarMul(a.fZ, b.fX) - SkUnitScalarMul(a.fX, b.fY);
-       SkScalar z = SkUnitScalarMul(a.fX, b.fY) - SkUnitScalarMul(a.fY, b.fX);
+    SkScalar x = SkUnitScalarMul(a.fY, b.fZ) - SkUnitScalarMul(a.fZ, b.fY);
+    SkScalar y = SkUnitScalarMul(a.fZ, b.fX) - SkUnitScalarMul(a.fX, b.fY);
+    SkScalar z = SkUnitScalarMul(a.fX, b.fY) - SkUnitScalarMul(a.fY, b.fX);
 
-       cross->set(x, y, z);
+    cross->set(x, y, z);
 }
 
 ///////////////////////////////////////////////////////////////////////////
 
 SkPatch3D::SkPatch3D()
 {
-       this->reset();
+    this->reset();
 }
 
 void SkPatch3D::reset()
 {
-       fOrigin.set(0, 0, 0);
-       fU.set(SK_Scalar1, 0, 0);
-       fV.set(0, -SK_Scalar1, 0);
+    fOrigin.set(0, 0, 0);
+    fU.set(SK_Scalar1, 0, 0);
+    fV.set(0, -SK_Scalar1, 0);
 }
 
-struct SkMatrix3D {
-       SkScalar        fMat[3][3];
+void SkPatch3D::transform(const SkMatrix3D& m, SkPatch3D* dst) const
+{
+    if (dst == NULL)
+        dst = (SkPatch3D*)this;
 
-       void set(int row, SkScalar a, SkScalar b, SkScalar c)
-       {
-               fMat[row][0] = a;
-               fMat[row][1] = b;
-               fMat[row][2] = c;
-       }
-       void setConcat(const SkMatrix3D& a, const SkMatrix3D& b)
-       {
-               SkMatrix3D      tmp;
-               SkMatrix3D*     c = this;
+    m.mapVector(fU, &dst->fU);
+    m.mapVector(fV, &dst->fV);
+    m.mapPoint(fOrigin, &dst->fOrigin);
+}
 
-               if (this == &a || this == &b)
-                       c = &tmp;
+SkScalar SkPatch3D::dotWith(SkScalar dx, SkScalar dy, SkScalar dz) const
+{
+    SkScalar cx = SkScalarMul(fU.fY, fV.fZ) - SkScalarMul(fU.fZ, fV.fY);
+    SkScalar cy = SkScalarMul(fU.fZ, fV.fX) - SkScalarMul(fU.fX, fV.fY);
+    SkScalar cz = SkScalarMul(fU.fX, fV.fY) - SkScalarMul(fU.fY, fV.fX);
 
-               for (int i = 0; i < 3; i++)
-                       for (int j = 0; j < 3; j++)
-                               c->fMat[i][j] = VectorMultiplyDivide(3, &a.fMat[i][0], 1, &b.fMat[0][j], 3, 0);
+    return SkScalarMul(cx, dx) + SkScalarMul(cy, dy) + SkScalarMul(cz, dz);
+}
 
-               if (c == &tmp)
-                       *this = tmp;
-       }
+///////////////////////////////////////////////////////////////////////////
 
-       void map(SkPoint3D* v) const
-       {
-               SkScalar x = VectorMultiplyDivide(3, &fMat[0][0], 1, &v->fX, 1, 0);
-               SkScalar y = VectorMultiplyDivide(3, &fMat[1][0], 1, &v->fX, 1, 0);
-               SkScalar z = VectorMultiplyDivide(3, &fMat[2][0], 1, &v->fX, 1, 0);
-               v->set(x, y, z);
-       }
-};
+void SkMatrix3D::reset()
+{
+    memset(fMat, 0, sizeof(fMat));
+    fMat[0][0] = fMat[1][1] = fMat[2][2] = SK_Scalar1;
+}
 
-void SkPatch3D::rotate(SkScalar radX, SkScalar radY, SkScalar radZ)
+void SkMatrix3D::setTranslate(SkScalar x, SkScalar y, SkScalar z)
 {
-       SkScalar        s, c;
-       SkMatrix3D      mx, my, mz, m;
+    memset(fMat, 0, sizeof(fMat));
+    fMat[0][0] = x;
+    fMat[1][1] = y;
+    fMat[2][2] = z;
+}
 
-       s = SkScalarSinCos(radX, &c);
-       mx.set(0, SK_Scalar1, 0, 0);
-       mx.set(1, 0, c, -s);
-       mx.set(2, 0, s, c);
+void SkMatrix3D::setRotateX(SkScalar degX)
+{
+    SkScalar    s, c;
 
-       s = SkScalarSinCos(radY, &c);
-       my.set(0, c, 0, -s);
-       my.set(1, 0, SK_Scalar1, 0);
-       my.set(2, s, 0, c);
+    s = SkScalarSinCos(SkDegreesToRadians(degX), &c);
+    this->setRow(0, SK_Scalar1, 0, 0);
+    this->setRow(1, 0, c, -s);
+    this->setRow(2, 0, s, c);
+}
 
-       s = SkScalarSinCos(radZ, &c);
-       mz.set(0, c, -s, 0);
-       mz.set(1, s, c, 0);
-       mz.set(2, 0, 0, SK_Scalar1);
+void SkMatrix3D::setRotateY(SkScalar degY)
+{
+    SkScalar    s, c;
+
+    s = SkScalarSinCos(SkDegreesToRadians(degY), &c);
+    this->setRow(0, c, 0, -s);
+    this->setRow(1, 0, SK_Scalar1, 0);
+    this->setRow(2, s, 0, c);
+}
 
-       m.setConcat(mx, my);
-       m.setConcat(m, mz);
+void SkMatrix3D::setRotateZ(SkScalar degZ)
+{
+    SkScalar    s, c;
 
-       m.map(&fU);
-       m.map(&fV);
+    s = SkScalarSinCos(SkDegreesToRadians(degZ), &c);
+    this->setRow(0, c, -s, 0);
+    this->setRow(1, s, c, 0);
+    this->setRow(2, 0, 0, SK_Scalar1);
 }
 
-SkScalar SkPatch3D::dotWith(SkScalar dx, SkScalar dy, SkScalar dz) const
+void SkMatrix3D::preTranslate(SkScalar x, SkScalar y, SkScalar z)
+{
+    SkScalar col[3] = { x, y, z};
+
+    for (int i = 0; i < 3; i++)
+        fMat[i][3] += SkScalarDot(3, &fMat[i][0], 1, col, 1);
+}
+
+void SkMatrix3D::preRotateX(SkScalar degX)
+{
+    SkMatrix3D m;    
+    m.setRotateX(degX);
+    this->setConcat(*this, m);
+}
+
+void SkMatrix3D::preRotateY(SkScalar degY)
+{
+    SkMatrix3D m;    
+    m.setRotateY(degY);
+    this->setConcat(*this, m);
+}
+
+void SkMatrix3D::preRotateZ(SkScalar degZ)
+{
+    SkMatrix3D m;    
+    m.setRotateZ(degZ);
+    this->setConcat(*this, m);
+}
+
+void SkMatrix3D::setConcat(const SkMatrix3D& a, const SkMatrix3D& b)
+{
+    SkMatrix3D  tmp;
+    SkMatrix3D* c = this;
+
+    if (this == &a || this == &b)
+        c = &tmp;
+
+    for (int i = 0; i < 3; i++) {
+        for (int j = 0; j < 3; j++)
+            c->fMat[i][j] = SkScalarDot(3, &a.fMat[i][0], 1, &b.fMat[0][j], 4);
+        c->fMat[i][3] = SkScalarDot(3, &a.fMat[i][0], 1, &b.fMat[0][3], 4) + a.fMat[i][3];
+    }
+
+    if (c == &tmp)
+        *this = tmp;
+}
+
+void SkMatrix3D::mapPoint(const SkPoint3D& src, SkPoint3D* dst) const
 {
-       SkUnit3D        normal;
+    SkScalar x = SkScalarDot(3, &fMat[0][0], 1, &src.fX, 1) + fMat[0][3];
+    SkScalar y = SkScalarDot(3, &fMat[1][0], 1, &src.fX, 1) + fMat[1][3];
+    SkScalar z = SkScalarDot(3, &fMat[2][0], 1, &src.fX, 1) + fMat[2][3];
+    dst->set(x, y, z);
+}
 
-       SkUnit3D::Cross(*(SkUnit3D*)&fU, *(SkUnit3D*)&fV, &normal);
-       return  SkUnitScalarMul(normal.fX, dx) +
-                       SkUnitScalarMul(normal.fY, dy) +
-                       SkUnitScalarMul(normal.fZ, dz);
+void SkMatrix3D::mapVector(const SkVector3D& src, SkVector3D* dst) const
+{
+    SkScalar x = SkScalarDot(3, &fMat[0][0], 1, &src.fX, 1);
+    SkScalar y = SkScalarDot(3, &fMat[1][0], 1, &src.fX, 1);
+    SkScalar z = SkScalarDot(3, &fMat[2][0], 1, &src.fX, 1);
+    dst->set(x, y, z);
 }
 
 ///////////////////////////////////////////////////////////////////////////
 
 SkCamera3D::SkCamera3D()
 {
-    fLocation.set(0, 0, -SkIntToScalar(1440)); // 20 inches backward
-       fAxis.set(0, 0, SK_Scalar1);                            // forward
-       fZenith.set(0, -SK_Scalar1, 0);                         // up
-       fObserver.set(0, 0, -SkIntToScalar(1440));      // 20 inches backward
+    this->reset();
+}
+
+void SkCamera3D::reset()
+{
+    fLocation.set(0, 0, -SkIntToScalar(576));   // 8 inches backward
+    fAxis.set(0, 0, SK_Scalar1);                // forward
+    fZenith.set(0, -SK_Scalar1, 0);             // up
+
+    fObserver.set(0, 0, fLocation.fZ);
 
-       this->update();
+    fNeedToUpdate = true;
 }
 
 void SkCamera3D::update()
 {
-       SkUnit3D        axis, zenith, cross;
+    fNeedToUpdate = true;
+}
 
-       fAxis.normalize(&axis);
+void SkCamera3D::doUpdate() const
+{
+    SkUnit3D    axis, zenith, cross;
 
-       {
-               SkScalar dot = SkUnit3D::Dot(*(SkUnit3D*)&fZenith, axis);
+    fAxis.normalize(&axis);
 
-               zenith.fX = fZenith.fX - SkUnitScalarMul(dot, axis.fX);
-               zenith.fY = fZenith.fY - SkUnitScalarMul(dot, axis.fY);
-               zenith.fZ = fZenith.fZ - SkUnitScalarMul(dot, axis.fZ);
+    {
+        SkScalar dot = SkUnit3D::Dot(*(const SkUnit3D*)&fZenith, axis);
 
-               (void)((SkPoint3D*)&zenith)->normalize(&zenith);
-       }
+        zenith.fX = fZenith.fX - SkUnitScalarMul(dot, axis.fX);
+        zenith.fY = fZenith.fY - SkUnitScalarMul(dot, axis.fY);
+        zenith.fZ = fZenith.fZ - SkUnitScalarMul(dot, axis.fZ);
 
-       SkUnit3D::Cross(axis, zenith, &cross);
+        (void)((SkPoint3D*)&zenith)->normalize(&zenith);
+    }
 
-       {
-               SkScalar* destPtr = (SkScalar*)&fOrientation;
-               SkScalar x = fObserver.fX;
-               SkScalar y = fObserver.fY;
-               SkScalar z = fObserver.fZ;
+    SkUnit3D::Cross(axis, zenith, &cross);
+
+    {
+        SkScalar* destPtr = (SkScalar*)&fOrientation;
+        SkScalar x = fObserver.fX;
+        SkScalar y = fObserver.fY;
+        SkScalar z = fObserver.fZ;
+
+        destPtr[0] = SkUnitScalarMul(x, axis.fX) - SkUnitScalarMul(z, cross.fX);
+        destPtr[1] = SkUnitScalarMul(x, axis.fY) - SkUnitScalarMul(z, cross.fY);
+        destPtr[2] = SkUnitScalarMul(x, axis.fZ) - SkUnitScalarMul(z, cross.fZ);
+        destPtr[3] = SkUnitScalarMul(y, axis.fX) - SkUnitScalarMul(z, zenith.fX);
+        destPtr[4] = SkUnitScalarMul(y, axis.fY) - SkUnitScalarMul(z, zenith.fY);
+        destPtr[5] = SkUnitScalarMul(y, axis.fZ) - SkUnitScalarMul(z, zenith.fZ);
+        memcpy(&destPtr[6], &axis, sizeof(axis));
+    }
+}
 
-               destPtr[0] = SkUnitScalarMul(x, axis.fX) - SkUnitScalarMul(z, cross.fX);
-               destPtr[1] = SkUnitScalarMul(x, axis.fY) - SkUnitScalarMul(z, cross.fY);
-               destPtr[2] = SkUnitScalarMul(x, axis.fZ) - SkUnitScalarMul(z, cross.fZ);
-               destPtr[3] = SkUnitScalarMul(y, axis.fX) - SkUnitScalarMul(z, zenith.fX);
-               destPtr[4] = SkUnitScalarMul(y, axis.fY) - SkUnitScalarMul(z, zenith.fY);
-               destPtr[5] = SkUnitScalarMul(y, axis.fZ) - SkUnitScalarMul(z, zenith.fZ);
-               memcpy(&destPtr[6], &axis, sizeof(axis));
+void SkCamera3D::patchToMatrix(const SkPatch3D& quilt, SkMatrix* matrix) const
+{
+    if (fNeedToUpdate)
+    {
+        this->doUpdate();
+        fNeedToUpdate = false;
     }
+
+    SkScalar*       destPtr = (SkScalar*)matrix;
+    const SkScalar* mapPtr = (const SkScalar*)&fOrientation;
+    const SkScalar* patchPtr;
+    SkPoint3D       diff;
+    SkScalar        dot;
+
+    diff.fX = quilt.fOrigin.fX - fLocation.fX;
+    diff.fY = quilt.fOrigin.fY - fLocation.fY;
+    diff.fZ = quilt.fOrigin.fZ - fLocation.fZ;
+
+    dot = SkUnit3D::Dot(*(const SkUnit3D*)&diff, *(const SkUnit3D*)((const SkScalar*)&fOrientation + 6));
+
+    patchPtr = (const SkScalar*)&quilt;
+    destPtr[0] = SkScalarDotDiv(3, patchPtr, 1, mapPtr, 1, dot);
+    destPtr[3] = SkScalarDotDiv(3, patchPtr, 1, mapPtr+3, 1, dot);
+    destPtr[6] = SkScalarDotDiv(3, patchPtr, 1, mapPtr+6, 1, dot);
+    patchPtr += 3;
+    destPtr[1] = SkScalarDotDiv(3, patchPtr, 1, mapPtr, 1, dot);
+    destPtr[4] = SkScalarDotDiv(3, patchPtr, 1, mapPtr+3, 1, dot);
+    destPtr[7] = SkScalarDotDiv(3, patchPtr, 1, mapPtr+6, 1, dot);
+    patchPtr = (const SkScalar*)&diff;
+    destPtr[2] = SkScalarDotDiv(3, patchPtr, 1, mapPtr, 1, dot);
+    destPtr[5] = SkScalarDotDiv(3, patchPtr, 1, mapPtr+3, 1, dot);
+    destPtr[8] = SK_UnitScalar1;
 }
 
-void SkCamera3D::computeMatrix(const SkPatch3D& quilt, SkMatrix* matrix) const
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+Sk3DView::Sk3DView()
 {
-       SkScalar*               destPtr = (SkScalar*)matrix;
-       const SkScalar* mapPtr = (const SkScalar*)&fOrientation;
-       const SkScalar* patchPtr;
-       SkPoint3D               diff;
-       SkScalar                dot;
+    fInitialRec.fMatrix.reset();
+    fRec = &fInitialRec;
+}
 
-       diff.fX = quilt.fOrigin.fX - fLocation.fX;
-       diff.fY = quilt.fOrigin.fY - fLocation.fY;
-       diff.fZ = quilt.fOrigin.fZ - fLocation.fZ;
+Sk3DView::~Sk3DView()
+{
+    Rec* rec = fRec;
+    while (rec != &fInitialRec) {
+        Rec* next = rec->fNext;
+        SkDELETE(rec);
+        rec = next;
+    }
+}
 
-       dot = SkUnit3D::Dot(*(const SkUnit3D*)&diff, *(const SkUnit3D*)((const SkScalar*)&fOrientation + 6));
+void Sk3DView::save()
+{
+    Rec* rec = SkNEW(Rec);
+    rec->fNext = fRec;
+    rec->fMatrix = fRec->fMatrix;
+    fRec = rec;
+}
 
-       patchPtr = (const SkScalar*)&quilt;
-       destPtr[0] = VectorMultiplyDivide(3, patchPtr, 1, mapPtr, 1, dot);
-       destPtr[3] = VectorMultiplyDivide(3, patchPtr, 1, mapPtr+3, 1, dot);
-       destPtr[6] = VectorMultiplyDivide(3, patchPtr, 1, mapPtr+6, 1, dot);
-       patchPtr += 3;
-       destPtr[1] = VectorMultiplyDivide(3, patchPtr, 1, mapPtr, 1, dot);
-       destPtr[4] = VectorMultiplyDivide(3, patchPtr, 1, mapPtr+3, 1, dot);
-       destPtr[7] = VectorMultiplyDivide(3, patchPtr, 1, mapPtr+6, 1, dot);
-       patchPtr = (const SkScalar*)&diff;
-       destPtr[2] = VectorMultiplyDivide(3, patchPtr, 1, mapPtr, 1, dot);
-       destPtr[5] = VectorMultiplyDivide(3, patchPtr, 1, mapPtr+3, 1, dot);
-       destPtr[8] = SK_UnitScalar1;
+void Sk3DView::restore()
+{
+    SkASSERT(fRec != &fInitialRec);
+    Rec* next = fRec->fNext;
+    SkDELETE(fRec);
+    fRec = next;
 }
+
+void Sk3DView::translate(SkScalar x, SkScalar y, SkScalar z)
+{
+    fRec->fMatrix.preTranslate(x, y, z);
+}
+
+void Sk3DView::rotateX(SkScalar deg)
+{
+    fRec->fMatrix.preRotateX(deg);
+}
+
+void Sk3DView::rotateY(SkScalar deg)
+{
+    fRec->fMatrix.preRotateY(deg);
+}
+
+void Sk3DView::rotateZ(SkScalar deg)
+{
+    fRec->fMatrix.preRotateZ(deg);
+}
+
+SkScalar Sk3DView::dotWithNormal(SkScalar x, SkScalar y, SkScalar z) const
+{
+    SkPatch3D   patch;
+    patch.transform(fRec->fMatrix);
+    return patch.dotWith(x, y, z);
+}
+
+void Sk3DView::getMatrix(SkMatrix* matrix) const
+{
+    if (matrix != NULL)
+    {
+        SkPatch3D   patch;
+        patch.transform(fRec->fMatrix);
+        fCamera.patchToMatrix(patch, matrix);
+    }
+}
+
+#include "SkCanvas.h"
+
+void Sk3DView::applyToCanvas(SkCanvas* canvas) const
+{
+    SkMatrix    matrix;
+    
+    this->getMatrix(&matrix);
+    canvas->concat(matrix);
+}
+
index 0809f0f..309d013 100644 (file)
@@ -1,3 +1,20 @@
+/* libs/graphics/effects/SkColorFilters.cpp
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #include "SkColorFilter.h"
 #include "SkColorPriv.h"
 #include "SkPorterDuff.h"
@@ -103,14 +120,14 @@ static inline unsigned pin(unsigned value, unsigned max)
 
 static inline unsigned SkUClampMax(unsigned value, unsigned max)
 {
-       SkASSERT((S32)value >= 0);
-       SkASSERT((S32)max >= 0);
+    SkASSERT((S32)value >= 0);
+    SkASSERT((S32)max >= 0);
 
-       int     diff = max - value;
-       // clear diff if diff is positive
-       diff &= diff >> 31;
+    int diff = max - value;
+    // clear diff if diff is positive
+    diff &= diff >> 31;
 
-       return value + diff;
+    return value + diff;
 }
 
 class SkLightingColorFilter : public SkColorFilter {
index fdc36d4..46af12e 100644 (file)
@@ -1,3 +1,20 @@
+/* libs/graphics/effects/SkCornerPathEffect.cpp
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #include "SkCornerPathEffect.h"
 #include "SkPath.h"
 #include "SkPoint.h"
@@ -41,6 +58,11 @@ bool SkCornerPathEffect::filterPath(SkPath* dst, const SkPath& src, SkScalar* wi
     SkVector    firstStep, step;
     bool        prevIsValid = true;
 
+    // to avoid warnings
+    moveTo.set(0, 0);
+    firstStep.set(0, 0);
+    lastCorner.set(0, 0);
+
     for (;;) {
         switch (verb = iter.next(pts)) {
         case SkPath::kMove_Verb:
@@ -91,12 +113,12 @@ bool SkCornerPathEffect::filterPath(SkPath* dst, const SkPath& src, SkScalar* wi
         prevVerb = verb;
     }
 DONE:
-       return true;
+    return true;
 }
 
 SkFlattenable::Factory SkCornerPathEffect::getFactory()
 {
-       return CreateProc;
+    return CreateProc;
 }
 
 void SkCornerPathEffect::flatten(SkWBuffer& buffer)
index 6d004fa..b7c5ec7 100644 (file)
@@ -1,3 +1,20 @@
+/* libs/graphics/effects/SkCullPoints.cpp
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #include "SkCullPoints.h"
 #include "Sk64.h"
 
@@ -46,12 +63,12 @@ bool SkCullPoints::sect_test(int x0, int y0, int x1, int y1) const
 
 static void toQuad(const SkRect16& r, SkPoint16 quad[4])
 {
-       SkASSERT(quad);
+    SkASSERT(quad);
 
-       quad[0].set(r.fLeft, r.fTop);
-       quad[1].set(r.fRight, r.fTop);
-       quad[2].set(r.fRight, r.fBottom);
-       quad[3].set(r.fLeft, r.fBottom);
+    quad[0].set(r.fLeft, r.fTop);
+    quad[1].set(r.fRight, r.fTop);
+    quad[2].set(r.fRight, r.fBottom);
+    quad[3].set(r.fLeft, r.fBottom);
 }
 
 SkCullPoints::SkCullPoints()
@@ -71,31 +88,41 @@ void SkCullPoints::reset(const SkRect16& r)
     fR = r;
     toQuad(fR, fAsQuad);
     fPrevPt.set(0, 0);
+    fPrevResult = kNo_Result;
 }
 
 void SkCullPoints::moveTo(int x, int y)
 {
     fPrevPt.set(x, y);
+    fPrevResult = kNo_Result;   // so we trigger a movetolineto later
 }
 
-SkCullPoints::LineToResult SkCullPoints::lineTo(int x, int y, SkPoint16 result[])
+SkCullPoints::LineToResult SkCullPoints::lineTo(int x, int y, SkPoint16 line[])
 {
-    SkASSERT(result != NULL);
+    SkASSERT(line != NULL);
 
+    LineToResult result = kNo_Result;
     int x0 = fPrevPt.fX;
     int y0 = fPrevPt.fY;
-    fPrevPt.set(x, y);
     
     // need to upgrade sect_test to chop the result
     // and to correctly return kLineTo_Result when the result is connected
     // to the previous call-out
     if (this->sect_test(x0, y0, x, y))
     {
-        result[0].set(x0, y0);
-        result[1].set(x, y);
-        return kMoveToLineTo_Result;
+        line[0].set(x0, y0);
+        line[1].set(x, y);
+        
+        if (fPrevResult != kNo_Result && fPrevPt.equals(x0, y0))
+            result = kLineTo_Result;
+        else
+            result = kMoveToLineTo_Result;
     }
-    return kNo_Result;
+
+    fPrevPt.set(x, y);
+    fPrevResult = result;
+
+    return result;
 }
 
 /////////////////////////////////////////////////////////////////////////////////////////////////
index 782cf2d..6f74f5c 100644 (file)
+/* libs/graphics/effects/SkDashPathEffect.cpp
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #include "SkDashPathEffect.h"
 #include "SkBuffer.h"
 #include "SkPathMeasure.h"
 
 static inline int is_even(int x)
 {
-       return (~x) << 31;
+    return (~x) << 31;
 }
 
 static SkScalar FindFirstInterval(const SkScalar intervals[], SkScalar phase, int32_t* index)
 {
-       int i;
+    int i;
 
-       for (i = 0; phase > intervals[i]; i++)
-               phase -= intervals[i];
-       *index = i;
-       return intervals[i] - phase;
+    for (i = 0; phase > intervals[i]; i++)
+        phase -= intervals[i];
+    *index = i;
+    return intervals[i] - phase;
 }
 
 SkDashPathEffect::SkDashPathEffect(const SkScalar intervals[], int count, SkScalar phase, bool scaleToFit)
-       : fScaleToFit(scaleToFit)
+    : fScaleToFit(scaleToFit)
 {
-       SkASSERT(intervals);
-       SkASSERT(count > 1 && SkAlign2(count) == count);
-
-       fIntervals = (SkScalar*)sk_malloc_throw(sizeof(SkScalar) * count);
-       fCount = count;
-
-       SkScalar len = 0;
-       for (int i = 0; i < count; i++)
-       {
-               SkASSERT(intervals[i] >= 0);
-               fIntervals[i] = intervals[i];
-               len += intervals[i];
-       }
-       fIntervalLength = len;
-
-       if (len > 0)    // we don't handle 0 length dash arrays
-       {
-               if (phase < 0)
-               {
-                       phase = -phase;
-                       if (phase > len)
-                               phase = SkScalarMod(phase, len);
-                       phase = len - phase;
-               }
-               else if (phase >= len)
-                       phase = SkScalarMod(phase, len);
-
-               SkASSERT(phase >= 0 && phase < len);
-               fInitialDashLength = FindFirstInterval(intervals, phase, &fInitialDashIndex);
-
-               SkASSERT(fInitialDashLength >= 0);
-               SkASSERT(fInitialDashIndex >= 0 && fInitialDashIndex < fCount);
-       }
-       else
-               fInitialDashLength = -1;        // signal bad dash intervals
+    SkASSERT(intervals);
+    SkASSERT(count > 1 && SkAlign2(count) == count);
+
+    fIntervals = (SkScalar*)sk_malloc_throw(sizeof(SkScalar) * count);
+    fCount = count;
+
+    SkScalar len = 0;
+    for (int i = 0; i < count; i++)
+    {
+        SkASSERT(intervals[i] >= 0);
+        fIntervals[i] = intervals[i];
+        len += intervals[i];
+    }
+    fIntervalLength = len;
+
+    if (len > 0)    // we don't handle 0 length dash arrays
+    {
+        if (phase < 0)
+        {
+            phase = -phase;
+            if (phase > len)
+                phase = SkScalarMod(phase, len);
+            phase = len - phase;
+        }
+        else if (phase >= len)
+            phase = SkScalarMod(phase, len);
+
+        SkASSERT(phase >= 0 && phase < len);
+        fInitialDashLength = FindFirstInterval(intervals, phase, &fInitialDashIndex);
+
+        SkASSERT(fInitialDashLength >= 0);
+        SkASSERT(fInitialDashIndex >= 0 && fInitialDashIndex < fCount);
+    }
+    else
+        fInitialDashLength = -1;    // signal bad dash intervals
 }
 
 SkDashPathEffect::~SkDashPathEffect()
 {
-       sk_free(fIntervals);
+    sk_free(fIntervals);
 }
 
 bool SkDashPathEffect::filterPath(SkPath* dst, const SkPath& src, SkScalar* width)
 {
-       // we do nothing if the src wants to be filled, or if our dashlength is 0
-       if (*width < 0 || fInitialDashLength < 0)
-               return false;
-
-       SkPathMeasure   meas(src, false);
-       const SkScalar* intervals = fIntervals;
-
-       do {
-               bool            skipFirstSegment = meas.isClosed();
-               bool            addedSegment = false;
-               SkScalar        length = meas.getLength();
-               int                     index = fInitialDashIndex;
-               SkScalar        scale = SK_Scalar1;
-
-               if (fScaleToFit)
-               {
-                       if (fIntervalLength >= length)
-                               scale = SkScalarDiv(length, fIntervalLength);
-                       else
-                       {
-                               SkScalar div = SkScalarDiv(length, fIntervalLength);
-                               int n = SkScalarFloor(div);
-                               scale = SkScalarDiv(length, n * fIntervalLength);
-                       }
-               }
-
-               SkScalar        distance = 0;
-               SkScalar        dlen = SkScalarMul(fInitialDashLength, scale);
-
-               while (distance < length)
-               {
-                       SkASSERT(dlen >= 0);
-                       addedSegment = false;
-                       if (is_even(index) && dlen > 0 && !skipFirstSegment)
-                       {
-                               addedSegment = true;
-                               meas.getSegment(distance, distance + dlen, dst, true);
-                       }
-                       distance += dlen;
-
-                       // clear this so we only respect it the first time around
-                       skipFirstSegment = false;
-
-                       // wrap around our intervals array if necessary
-                       index += 1;
-                       SkASSERT(index <= fCount);
-                       if (index == fCount)
-                               index = 0;
-
-                       // fetch our next dlen
-                       dlen = SkScalarMul(intervals[index], scale);
-               }
-
-               // extend if we ended on a segment and we need to join up with the (skipped) initial segment
-               if (meas.isClosed() && is_even(fInitialDashIndex) && fInitialDashLength > 0)
-                       meas.getSegment(0, SkScalarMul(fInitialDashLength, scale), dst, !addedSegment);
-       } while (meas.nextContour());
-       return true;
+    // we do nothing if the src wants to be filled, or if our dashlength is 0
+    if (*width < 0 || fInitialDashLength < 0)
+        return false;
+
+    SkPathMeasure   meas(src, false);
+    const SkScalar* intervals = fIntervals;
+
+    do {
+        bool        skipFirstSegment = meas.isClosed();
+        bool        addedSegment = false;
+        SkScalar    length = meas.getLength();
+        int         index = fInitialDashIndex;
+        SkScalar    scale = SK_Scalar1;
+
+        if (fScaleToFit)
+        {
+            if (fIntervalLength >= length)
+                scale = SkScalarDiv(length, fIntervalLength);
+            else
+            {
+                SkScalar div = SkScalarDiv(length, fIntervalLength);
+                int n = SkScalarFloor(div);
+                scale = SkScalarDiv(length, n * fIntervalLength);
+            }
+        }
+
+        SkScalar    distance = 0;
+        SkScalar    dlen = SkScalarMul(fInitialDashLength, scale);
+
+        while (distance < length)
+        {
+            SkASSERT(dlen >= 0);
+            addedSegment = false;
+            if (is_even(index) && dlen > 0 && !skipFirstSegment)
+            {
+                addedSegment = true;
+                meas.getSegment(distance, distance + dlen, dst, true);
+            }
+            distance += dlen;
+
+            // clear this so we only respect it the first time around
+            skipFirstSegment = false;
+
+            // wrap around our intervals array if necessary
+            index += 1;
+            SkASSERT(index <= fCount);
+            if (index == fCount)
+                index = 0;
+
+            // fetch our next dlen
+            dlen = SkScalarMul(intervals[index], scale);
+        }
+
+        // extend if we ended on a segment and we need to join up with the (skipped) initial segment
+        if (meas.isClosed() && is_even(fInitialDashIndex) && fInitialDashLength > 0)
+            meas.getSegment(0, SkScalarMul(fInitialDashLength, scale), dst, !addedSegment);
+    } while (meas.nextContour());
+    return true;
 }
 
 SkFlattenable::Factory SkDashPathEffect::getFactory()
 {
-       return fInitialDashLength < 0 ? nil : CreateProc;
+    return fInitialDashLength < 0 ? nil : CreateProc;
 }
 
 void SkDashPathEffect::flatten(SkWBuffer& buffer)
@@ -145,7 +162,7 @@ void SkDashPathEffect::flatten(SkWBuffer& buffer)
 
 SkFlattenable* SkDashPathEffect::CreateProc(SkRBuffer& buffer)
 {
-       return SkNEW_ARGS(SkDashPathEffect, (buffer));
+    return SkNEW_ARGS(SkDashPathEffect, (buffer));
 }
 
 SkDashPathEffect::SkDashPathEffect(SkRBuffer& buffer) : SkPathEffect(buffer)
@@ -156,7 +173,7 @@ SkDashPathEffect::SkDashPathEffect(SkRBuffer& buffer) : SkPathEffect(buffer)
     fIntervalLength = buffer.readScalar();
     fScaleToFit = (buffer.readS32() != 0);
     
-       fIntervals = (SkScalar*)sk_malloc_throw(sizeof(SkScalar) * fCount);
+    fIntervals = (SkScalar*)sk_malloc_throw(sizeof(SkScalar) * fCount);
     buffer.read(fIntervals, fCount * sizeof(fIntervals[0]));
 }
 
index 78d17d0..a0d2480 100644 (file)
@@ -1,3 +1,20 @@
+/* libs/graphics/effects/SkDiscretePathEffect.cpp
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #include "SkDiscretePathEffect.h"
 #include "SkBuffer.h"
 #include "SkPathMeasure.h"
 
 static void Perterb(SkPoint* p, const SkVector& tangent, SkScalar scale)
 {
-       SkVector normal = tangent;
-       normal.rotateCCW();
-       normal.setLength(scale);
-       *p += normal;
+    SkVector normal = tangent;
+    normal.rotateCCW();
+    normal.setLength(scale);
+    *p += normal;
 }
 
 
 SkDiscretePathEffect::SkDiscretePathEffect(SkScalar segLength, SkScalar deviation)
-       : fSegLength(segLength), fPerterb(deviation)
+    : fSegLength(segLength), fPerterb(deviation)
 {
 }
 
 bool SkDiscretePathEffect::filterPath(SkPath* dst, const SkPath& src, SkScalar* width)
 {
-       bool doFill = *width < 0;
+    bool doFill = *width < 0;
 
-       SkPathMeasure   meas(src, doFill);
-       U32                             seed = SkScalarRound(meas.getLength());
-       SkRandom                rand(seed ^ ((seed << 16) | (seed >> 16)));
-       SkScalar                scale = fPerterb;
-       SkPoint                 p;
-       SkVector                v;
+    SkPathMeasure   meas(src, doFill);
+    U32             seed = SkScalarRound(meas.getLength());
+    SkRandom        rand(seed ^ ((seed << 16) | (seed >> 16)));
+    SkScalar        scale = fPerterb;
+    SkPoint         p;
+    SkVector        v;
 
-       do {
-               SkScalar        length = meas.getLength();
+    do {
+        SkScalar    length = meas.getLength();
 
-               if (fSegLength * (2 + doFill) > length)
-               {
-                       meas.getSegment(0, length, dst, true);  // to short for us to mangle
-               }
-               else
-               {
-                       int                     n = SkScalarRound(SkScalarDiv(length, fSegLength));
-                       SkScalar        delta = length / n;
-                       SkScalar        distance = 0;
+        if (fSegLength * (2 + doFill) > length)
+        {
+            meas.getSegment(0, length, dst, true);  // to short for us to mangle
+        }
+        else
+        {
+            int         n = SkScalarRound(SkScalarDiv(length, fSegLength));
+            SkScalar    delta = length / n;
+            SkScalar    distance = 0;
 
-                       if (meas.isClosed())
-                       {
-                               n -= 1;
-                               distance += delta/2;
-                       }
-                       meas.getPosTan(distance, &p, &v);
-                       Perterb(&p, v, SkScalarMul(rand.nextSScalar1(), scale));
-                       dst->moveTo(p);
-                       while (--n >= 0)
-                       {
-                               distance += delta;
-                               meas.getPosTan(distance, &p, &v);
-                               Perterb(&p, v, SkScalarMul(rand.nextSScalar1(), scale));
-                               dst->lineTo(p);
-                       }
-                       if (meas.isClosed())
-                               dst->close();
-               }
-       } while (meas.nextContour());
-       return true;
+            if (meas.isClosed())
+            {
+                n -= 1;
+                distance += delta/2;
+            }
+            meas.getPosTan(distance, &p, &v);
+            Perterb(&p, v, SkScalarMul(rand.nextSScalar1(), scale));
+            dst->moveTo(p);
+            while (--n >= 0)
+            {
+                distance += delta;
+                meas.getPosTan(distance, &p, &v);
+                Perterb(&p, v, SkScalarMul(rand.nextSScalar1(), scale));
+                dst->lineTo(p);
+            }
+            if (meas.isClosed())
+                dst->close();
+        }
+    } while (meas.nextContour());
+    return true;
 }
 
 SkFlattenable::Factory SkDiscretePathEffect::getFactory()
 {
-       return CreateProc;
+    return CreateProc;
 }
 
 SkFlattenable* SkDiscretePathEffect::CreateProc(SkRBuffer& buffer)
 {
-       return SkNEW_ARGS(SkDiscretePathEffect, (buffer));
+    return SkNEW_ARGS(SkDiscretePathEffect, (buffer));
 }
 
 void SkDiscretePathEffect::flatten(SkWBuffer& buffer)
index b47305f..1dea8b2 100644 (file)
@@ -1,41 +1,58 @@
+/* libs/graphics/effects/SkEmbossMask.cpp
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #include "SkEmbossMask.h"
 
 static inline int nonzero_to_one(int x)
 {
 #if 0
-       return x != 0;
+    return x != 0;
 #else
-       return ((unsigned)(x | -x)) >> 31;
+    return ((unsigned)(x | -x)) >> 31;
 #endif
 }
 
 static inline int neq_to_one(int x, int max)
 {
 #if 0
-       return x != max;
+    return x != max;
 #else
-       SkASSERT(x >= 0 && x <= max);
-       return ((unsigned)(x - max)) >> 31;
+    SkASSERT(x >= 0 && x <= max);
+    return ((unsigned)(x - max)) >> 31;
 #endif
 }
 
 static inline int neq_to_mask(int x, int max)
 {
 #if 0
-       return -(x != max);
+    return -(x != max);
 #else
-       SkASSERT(x >= 0 && x <= max);
-       return (x - max) >> 31;
+    SkASSERT(x >= 0 && x <= max);
+    return (x - max) >> 31;
 #endif
 }
 
 static inline unsigned div255(unsigned x)
 {
-       SkASSERT(x <= (255*255));
-       return x * ((1 << 24) / 255) >> 24;
+    SkASSERT(x <= (255*255));
+    return x * ((1 << 24) / 255) >> 24;
 }
 
-#define kDelta 32      // small enough to show off angle differences
+#define kDelta  32  // small enough to show off angle differences
 
 #include "SkEmbossMask_Table.h"
 
@@ -45,121 +62,121 @@ static inline unsigned div255(unsigned x)
 
 void SkEmbossMask_BuildTable()
 {
-       // build it 0..127 x 0..127, so we use 2^15 - 1 in the numerator for our "fixed" table
-
-       FILE* file = ::fopen("SkEmbossMask_Table.h", "w");
-       SkASSERT(file);
-       ::fprintf(file, "#include \"SkTypes.h\"\n\n");
-       ::fprintf(file, "static const U16 gInvSqrtTable[128 * 128] = {\n");
-       for (int dx = 0; dx <= 255/2; dx++)
-       {
-               for (int dy = 0; dy <= 255/2; dy++)
-               {
-                       if ((dy & 15) == 0)
-                               ::fprintf(file, "\t");
-
-                       U16 value = SkToU16((1 << 15) / SkSqrt32(dx * dx + dy * dy + kDelta*kDelta/4));
-
-                       ::fprintf(file, "0x%04X", value);
-                       if (dx * 128 + dy < 128*128-1)
-                               ::fprintf(file, ", ");
-                       if ((dy & 15) == 15)
-                               ::fprintf(file, "\n");
-               }
-       }
-       ::fprintf(file, "};\n#define kDeltaUsedToBuildTable\t%d\n", kDelta);
-       ::fclose(file);
+    // build it 0..127 x 0..127, so we use 2^15 - 1 in the numerator for our "fixed" table
+
+    FILE* file = ::fopen("SkEmbossMask_Table.h", "w");
+    SkASSERT(file);
+    ::fprintf(file, "#include \"SkTypes.h\"\n\n");
+    ::fprintf(file, "static const U16 gInvSqrtTable[128 * 128] = {\n");
+    for (int dx = 0; dx <= 255/2; dx++)
+    {
+        for (int dy = 0; dy <= 255/2; dy++)
+        {
+            if ((dy & 15) == 0)
+                ::fprintf(file, "\t");
+
+            U16 value = SkToU16((1 << 15) / SkSqrt32(dx * dx + dy * dy + kDelta*kDelta/4));
+
+            ::fprintf(file, "0x%04X", value);
+            if (dx * 128 + dy < 128*128-1)
+                ::fprintf(file, ", ");
+            if ((dy & 15) == 15)
+                ::fprintf(file, "\n");
+        }
+    }
+    ::fprintf(file, "};\n#define kDeltaUsedToBuildTable\t%d\n", kDelta);
+    ::fclose(file);
 }
 
 #endif
 
 void SkEmbossMask::Emboss(SkMask* mask, const SkEmbossMaskFilter::Light& light)
 {
-       SkASSERT(kDelta == kDeltaUsedToBuildTable);
-
-       SkASSERT(mask->fFormat == SkMask::k3D_Format);
-
-       int             specular = light.fSpecular;
-       int             ambient = light.fAmbient;
-       SkFixed lx = SkScalarToFixed(light.fDirection[0]);
-       SkFixed ly = SkScalarToFixed(light.fDirection[1]);
-       SkFixed lz = SkScalarToFixed(light.fDirection[2]);
-       SkFixed lz_dot_nz = lz * kDelta;
-       int             lz_dot8 = lz >> 8;
-
-       size_t          planeSize = mask->computeImageSize();
-       U8*                     alpha = mask->fImage;
-       U8*                     multiply = (U8*)alpha + planeSize;
-       U8*                     additive = multiply + planeSize;
-
-       int     rowBytes = mask->fRowBytes;
-       int     maxy = mask->fBounds.height() - 1;
-       int     maxx = mask->fBounds.width() - 1;
-
-       int     prev_row = 0;
-       for (int y = 0; y <= maxy; y++)
-       {
-               int     next_row = neq_to_mask(y, maxy) & rowBytes;
-
-               for (int x = 0; x <= maxx; x++)
-               {
-                       if (alpha[x])
-                       {
-                               int     nx = alpha[x + neq_to_one(x, maxx)] - alpha[x - nonzero_to_one(x)];
-                               int ny = alpha[x + next_row] - alpha[x - prev_row];
-
-                               SkFixed numer = lx * nx + ly * ny + lz_dot_nz;
-                               int             mul = ambient;
-                               int             add = 0;
-
-                               if (numer > 0)  // preflight when numer/denom will be <= 0
-                               {
+    SkASSERT(kDelta == kDeltaUsedToBuildTable);
+
+    SkASSERT(mask->fFormat == SkMask::k3D_Format);
+
+    int     specular = light.fSpecular;
+    int     ambient = light.fAmbient;
+    SkFixed lx = SkScalarToFixed(light.fDirection[0]);
+    SkFixed ly = SkScalarToFixed(light.fDirection[1]);
+    SkFixed lz = SkScalarToFixed(light.fDirection[2]);
+    SkFixed lz_dot_nz = lz * kDelta;
+    int     lz_dot8 = lz >> 8;
+
+    size_t      planeSize = mask->computeImageSize();
+    U8*         alpha = mask->fImage;
+    U8*         multiply = (U8*)alpha + planeSize;
+    U8*         additive = multiply + planeSize;
+
+    int rowBytes = mask->fRowBytes;
+    int maxy = mask->fBounds.height() - 1;
+    int maxx = mask->fBounds.width() - 1;
+
+    int prev_row = 0;
+    for (int y = 0; y <= maxy; y++)
+    {
+        int next_row = neq_to_mask(y, maxy) & rowBytes;
+
+        for (int x = 0; x <= maxx; x++)
+        {
+            if (alpha[x])
+            {
+                int nx = alpha[x + neq_to_one(x, maxx)] - alpha[x - nonzero_to_one(x)];
+                int ny = alpha[x + next_row] - alpha[x - prev_row];
+
+                SkFixed numer = lx * nx + ly * ny + lz_dot_nz;
+                int     mul = ambient;
+                int     add = 0;
+
+                if (numer > 0)  // preflight when numer/denom will be <= 0
+                {
 #if 0
-                                       int     denom = SkSqrt32(nx * nx + ny * ny + kDelta*kDelta);
-                                       SkFixed dot = numer / denom;
-                                       dot >>= 8;      // now dot is 2^8 instead of 2^16
+                    int denom = SkSqrt32(nx * nx + ny * ny + kDelta*kDelta);
+                    SkFixed dot = numer / denom;
+                    dot >>= 8;  // now dot is 2^8 instead of 2^16
 #else
-                                       // can use full numer, but then we need to call SkFixedMul, since
-                                       // numer is 24 bits, and our table is 12 bits
+                    // can use full numer, but then we need to call SkFixedMul, since
+                    // numer is 24 bits, and our table is 12 bits
 
-                                       // SkFixed dot = SkFixedMul(numer, gTable[]) >> 8
-                                       SkFixed dot = (unsigned)(numer >> 4) * gInvSqrtTable[(SkAbs32(nx) >> 1 << 7) | (SkAbs32(ny) >> 1)] >> 20;
+                    // SkFixed dot = SkFixedMul(numer, gTable[]) >> 8
+                    SkFixed dot = (unsigned)(numer >> 4) * gInvSqrtTable[(SkAbs32(nx) >> 1 << 7) | (SkAbs32(ny) >> 1)] >> 20;
 #endif
-                                       mul = SkFastMin32(mul + dot, 255);
-
-                                       // now for the reflection
-
-                                       //      R = 2 (Light * Normal) Normal - Light
-                                       //      hilite = R * Eye(0, 0, 1)
-
-                                       int hilite = (2 * dot - lz_dot8) * lz_dot8 >> 8;
-                                       if (hilite > 0)
-                                       {
-                                               // pin hilite to 255, since our fast math is also a little sloppy
-                                               hilite = SkClampMax(hilite, 255);
-
-                                               // specular is 4.4
-                                               // would really like to compute the fractional part of this
-                                               // and then possibly cache a 256 table for a given specular
-                                               // value in the light, and just pass that in to this function.
-                                               add = hilite;
-                                               for (int i = specular >> 4; i > 0; --i)
-                                                       add = div255(add * hilite);
-                                       }
-                               }
-                               multiply[x] = SkToU8(mul);
-                               additive[x] = SkToU8(add);
-
-                       //      multiply[x] = 0xFF;
-                       //      additive[x] = 0;
-                       //      ((U8*)alpha)[x] = alpha[x] * multiply[x] >> 8;
-                       }
-               }
-               alpha += rowBytes;
-               multiply += rowBytes;
-               additive += rowBytes;
-               prev_row = rowBytes;
-       }
+                    mul = SkFastMin32(mul + dot, 255);
+
+                    // now for the reflection
+
+                    //  R = 2 (Light * Normal) Normal - Light
+                    //  hilite = R * Eye(0, 0, 1)
+
+                    int hilite = (2 * dot - lz_dot8) * lz_dot8 >> 8;
+                    if (hilite > 0)
+                    {
+                        // pin hilite to 255, since our fast math is also a little sloppy
+                        hilite = SkClampMax(hilite, 255);
+
+                        // specular is 4.4
+                        // would really like to compute the fractional part of this
+                        // and then possibly cache a 256 table for a given specular
+                        // value in the light, and just pass that in to this function.
+                        add = hilite;
+                        for (int i = specular >> 4; i > 0; --i)
+                            add = div255(add * hilite);
+                    }
+                }
+                multiply[x] = SkToU8(mul);
+                additive[x] = SkToU8(add);
+
+            //  multiply[x] = 0xFF;
+            //  additive[x] = 0;
+            //  ((U8*)alpha)[x] = alpha[x] * multiply[x] >> 8;
+            }
+        }
+        alpha += rowBytes;
+        multiply += rowBytes;
+        additive += rowBytes;
+        prev_row = rowBytes;
+    }
 }
 
 
index 0e2ecbe..093e53d 100644 (file)
@@ -1,3 +1,20 @@
+/* libs/graphics/effects/SkEmbossMask.h
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #ifndef SkEmbossMask_DEFINED
 #define SkEmbossMask_DEFINED
 
@@ -5,7 +22,7 @@
 
 class SkEmbossMask {
 public:
-       static void Emboss(SkMask* mask, const SkEmbossMaskFilter::Light&);
+    static void Emboss(SkMask* mask, const SkEmbossMaskFilter::Light&);
 };
 
 #endif
index 248eab9..c71c9d6 100644 (file)
@@ -1,3 +1,20 @@
+/* libs/graphics/effects/SkEmbossMaskFilter.cpp
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #include "SkEmbossMaskFilter.h"
 #include "SkBlurMaskFilter.h"
 #include "SkBlurMask.h"
@@ -34,58 +51,58 @@ SkMaskFilter* SkBlurMaskFilter::CreateEmboss(const SkScalar direction[3],
 
 static void normalize(SkScalar v[3])
 {
-       SkScalar mag = SkScalarSquare(v[0]) + SkScalarSquare(v[1]) + SkScalarSquare(v[2]);
-       mag = SkScalarSqrt(mag);
+    SkScalar mag = SkScalarSquare(v[0]) + SkScalarSquare(v[1]) + SkScalarSquare(v[2]);
+    mag = SkScalarSqrt(mag);
 
-       for (int i = 0; i < 3; i++)
-               v[i] = SkScalarDiv(v[i], mag);
+    for (int i = 0; i < 3; i++)
+        v[i] = SkScalarDiv(v[i], mag);
 }
 
 SkEmbossMaskFilter::SkEmbossMaskFilter(const Light& light, SkScalar blurRadius)
-               : fLight(light), fBlurRadius(blurRadius)
+        : fLight(light), fBlurRadius(blurRadius)
 {
-       normalize(fLight.fDirection);
+    normalize(fLight.fDirection);
 }
 
 SkMask::Format SkEmbossMaskFilter::getFormat()
 {
-       return SkMask::k3D_Format;
+    return SkMask::k3D_Format;
 }
 
 bool SkEmbossMaskFilter::filterMask(SkMask* dst, const SkMask& src, const SkMatrix& matrix, SkPoint16* margin)
 {
-       SkScalar radius = matrix.mapRadius(fBlurRadius);
+    SkScalar radius = matrix.mapRadius(fBlurRadius);
 
-       SkBlurMask::Blur(dst, src, radius, SkBlurMask::kInner_Style);
+    SkBlurMask::Blur(dst, src, radius, SkBlurMask::kInner_Style);
 
-       dst->fFormat = SkMask::k3D_Format;
-       if (src.fImage == NULL)
-               return true;
+    dst->fFormat = SkMask::k3D_Format;
+    if (src.fImage == NULL)
+        return true;
 
-       // create a larger buffer for the other two channels (should force fBlur to do this for us)
+    // create a larger buffer for the other two channels (should force fBlur to do this for us)
 
-       {
-               U8*             alphaPlane = dst->fImage;
-               size_t  planeSize = dst->computeImageSize();
+    {
+        U8*     alphaPlane = dst->fImage;
+        size_t  planeSize = dst->computeImageSize();
 
-               dst->fImage = SkMask::AllocImage(planeSize * 3);
-               memcpy(dst->fImage, alphaPlane, planeSize);
-               SkMask::FreeImage(alphaPlane);
-       }
+        dst->fImage = SkMask::AllocImage(planeSize * 3);
+        memcpy(dst->fImage, alphaPlane, planeSize);
+        SkMask::FreeImage(alphaPlane);
+    }
 
-       // run the light direction through the matrix...
-       Light   light = fLight;
-       matrix.mapVectors((SkVector*)light.fDirection, (SkVector*)fLight.fDirection, 1);
-       // now restore the length of the XY component
-       ((SkVector*)light.fDirection)->setLength(light.fDirection[0], light.fDirection[1],
-                                                                                       SkPoint::Length(fLight.fDirection[0], fLight.fDirection[1]));
+    // run the light direction through the matrix...
+    Light   light = fLight;
+    matrix.mapVectors((SkVector*)light.fDirection, (SkVector*)fLight.fDirection, 1);
+    // now restore the length of the XY component
+    ((SkVector*)light.fDirection)->setLength(light.fDirection[0], light.fDirection[1],
+                                            SkPoint::Length(fLight.fDirection[0], fLight.fDirection[1]));
 
-       SkEmbossMask::Emboss(dst, light);
+    SkEmbossMask::Emboss(dst, light);
 
-       // restore original alpha
-       memcpy(dst->fImage, src.fImage, src.computeImageSize());
+    // restore original alpha
+    memcpy(dst->fImage, src.fImage, src.computeImageSize());
 
-       return true;
+    return true;
 }
 
 SkFlattenable* SkEmbossMaskFilter::CreateProc(SkRBuffer& buffer)
@@ -95,13 +112,13 @@ SkFlattenable* SkEmbossMaskFilter::CreateProc(SkRBuffer& buffer)
 
 SkFlattenable::Factory SkEmbossMaskFilter::getFactory()
 {
-       return CreateProc;
+    return CreateProc;
 }
 
 SkEmbossMaskFilter::SkEmbossMaskFilter(SkRBuffer& buffer) : SkMaskFilter(buffer)
 {
     buffer.read(&fLight, sizeof(fLight));
-    SkASSERT(fLight.fPad == 0);        // for the font-cache lookup to be clean
+    SkASSERT(fLight.fPad == 0); // for the font-cache lookup to be clean
     fBlurRadius = buffer.readScalar();
 }
 
@@ -109,7 +126,7 @@ void SkEmbossMaskFilter::flatten(SkWBuffer& buffer)
 {
     this->INHERITED::flatten(buffer);
 
-    fLight.fPad = 0;   // for the font-cache lookup to be clean
+    fLight.fPad = 0;    // for the font-cache lookup to be clean
     buffer.write(&fLight, sizeof(fLight));
     buffer.writeScalar(fBlurRadius);
 }
index 40b3e73..5e584f4 100644 (file)
+/* libs/graphics/effects/SkEmbossMask_Table.h
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #include "SkTypes.h"
 
 static const U16 gInvSqrtTable[128 * 128] = {
-       0x0800, 0x0800, 0x0800, 0x0800, 0x0800, 0x0800, 0x0787, 0x0787, 0x0787, 0x071C, 0x071C, 0x06BC, 0x0666, 0x0666, 0x0618, 0x0618, 
-       0x05D1, 0x0590, 0x0555, 0x0555, 0x051E, 0x04EC, 0x04BD, 0x0492, 0x0492, 0x0469, 0x0444, 0x0421, 0x0400, 0x03E0, 0x03C3, 0x03C3, 
-       0x03A8, 0x038E, 0x0375, 0x035E, 0x0348, 0x0333, 0x031F, 0x030C, 0x02FA, 0x02E8, 0x02E8, 0x02D8, 0x02C8, 0x02B9, 0x02AA, 0x029C, 
-       0x028F, 0x0282, 0x0276, 0x026A, 0x025E, 0x0253, 0x0249, 0x023E, 0x0234, 0x022B, 0x0222, 0x0219, 0x0210, 0x0208, 0x0200, 0x01F8, 
-       0x01F8, 0x01F0, 0x01E9, 0x01E1, 0x01DA, 0x01D4, 0x01CD, 0x01C7, 0x01C0, 0x01BA, 0x01B4, 0x01AF, 0x01A9, 0x01A4, 0x019E, 0x0199, 
-       0x0194, 0x018F, 0x018A, 0x0186, 0x0181, 0x017D, 0x0178, 0x0174, 0x0170, 0x016C, 0x0168, 0x0164, 0x0160, 0x015C, 0x0158, 0x0155, 
-       0x0151, 0x014E, 0x014A, 0x0147, 0x0144, 0x0141, 0x013E, 0x013B, 0x0138, 0x0135, 0x0132, 0x012F, 0x012C, 0x0129, 0x0127, 0x0124, 
-       0x0121, 0x011F, 0x011C, 0x011A, 0x0118, 0x0115, 0x0113, 0x0111, 0x010E, 0x010C, 0x010A, 0x0108, 0x0106, 0x0104, 0x0102, 0x0100, 
-       0x0800, 0x0800, 0x0800, 0x0800, 0x0800, 0x0800, 0x0787, 0x0787, 0x0787, 0x071C, 0x071C, 0x06BC, 0x0666, 0x0666, 0x0618, 0x0618, 
-       0x05D1, 0x0590, 0x0555, 0x0555, 0x051E, 0x04EC, 0x04BD, 0x0492, 0x0492, 0x0469, 0x0444, 0x0421, 0x0400, 0x03E0, 0x03C3, 0x03C3, 
-       0x03A8, 0x038E, 0x0375, 0x035E, 0x0348, 0x0333, 0x031F, 0x030C, 0x02FA, 0x02E8, 0x02E8, 0x02D8, 0x02C8, 0x02B9, 0x02AA, 0x029C, 
-       0x028F, 0x0282, 0x0276, 0x026A, 0x025E, 0x0253, 0x0249, 0x023E, 0x0234, 0x022B, 0x0222, 0x0219, 0x0210, 0x0208, 0x0200, 0x01F8, 
-       0x01F8, 0x01F0, 0x01E9, 0x01E1, 0x01DA, 0x01D4, 0x01CD, 0x01C7, 0x01C0, 0x01BA, 0x01B4, 0x01AF, 0x01A9, 0x01A4, 0x019E, 0x0199, 
-       0x0194, 0x018F, 0x018A, 0x0186, 0x0181, 0x017D, 0x0178, 0x0174, 0x0170, 0x016C, 0x0168, 0x0164, 0x0160, 0x015C, 0x0158, 0x0155, 
-       0x0151, 0x014E, 0x014A, 0x0147, 0x0144, 0x0141, 0x013E, 0x013B, 0x0138, 0x0135, 0x0132, 0x012F, 0x012C, 0x0129, 0x0127, 0x0124, 
-       0x0121, 0x011F, 0x011C, 0x011A, 0x0118, 0x0115, 0x0113, 0x0111, 0x010E, 0x010C, 0x010A, 0x0108, 0x0106, 0x0104, 0x0102, 0x0100, 
-       0x0800, 0x0800, 0x0800, 0x0800, 0x0800, 0x0800, 0x0787, 0x0787, 0x071C, 0x071C, 0x071C, 0x06BC, 0x0666, 0x0666, 0x0618, 0x05D1, 
-       0x05D1, 0x0590, 0x0555, 0x0555, 0x051E, 0x04EC, 0x04BD, 0x0492, 0x0492, 0x0469, 0x0444, 0x0421, 0x0400, 0x03E0, 0x03C3, 0x03C3, 
-       0x03A8, 0x038E, 0x0375, 0x035E, 0x0348, 0x0333, 0x031F, 0x030C, 0x02FA, 0x02E8, 0x02E8, 0x02D8, 0x02C8, 0x02B9, 0x02AA, 0x029C, 
-       0x028F, 0x0282, 0x0276, 0x026A, 0x025E, 0x0253, 0x0249, 0x023E, 0x0234, 0x022B, 0x0222, 0x0219, 0x0210, 0x0208, 0x0200, 0x01F8, 
-       0x01F0, 0x01F0, 0x01E9, 0x01E1, 0x01DA, 0x01D4, 0x01CD, 0x01C7, 0x01C0, 0x01BA, 0x01B4, 0x01AF, 0x01A9, 0x01A4, 0x019E, 0x0199, 
-       0x0194, 0x018F, 0x018A, 0x0186, 0x0181, 0x017D, 0x0178, 0x0174, 0x0170, 0x016C, 0x0168, 0x0164, 0x0160, 0x015C, 0x0158, 0x0155, 
-       0x0151, 0x014E, 0x014A, 0x0147, 0x0144, 0x0141, 0x013E, 0x013B, 0x0138, 0x0135, 0x0132, 0x012F, 0x012C, 0x0129, 0x0127, 0x0124, 
-       0x0121, 0x011F, 0x011C, 0x011A, 0x0118, 0x0115, 0x0113, 0x0111, 0x010E, 0x010C, 0x010A, 0x0108, 0x0106, 0x0104, 0x0102, 0x0100, 
-       0x0800, 0x0800, 0x0800, 0x0800, 0x0800, 0x0787, 0x0787, 0x0787, 0x071C, 0x071C, 0x06BC, 0x06BC, 0x0666, 0x0666, 0x0618, 0x05D1, 
-       0x05D1, 0x0590, 0x0555, 0x051E, 0x051E, 0x04EC, 0x04BD, 0x0492, 0x0469, 0x0469, 0x0444, 0x0421, 0x0400, 0x03E0, 0x03C3, 0x03A8, 
-       0x03A8, 0x038E, 0x0375, 0x035E, 0x0348, 0x0333, 0x031F, 0x030C, 0x02FA, 0x02E8, 0x02D8, 0x02D8, 0x02C8, 0x02B9, 0x02AA, 0x029C, 
-       0x028F, 0x0282, 0x0276, 0x026A, 0x025E, 0x0253, 0x0249, 0x023E, 0x0234, 0x022B, 0x0222, 0x0219, 0x0210, 0x0208, 0x0200, 0x01F8, 
-       0x01F0, 0x01E9, 0x01E9, 0x01E1, 0x01DA, 0x01D4, 0x01CD, 0x01C7, 0x01C0, 0x01BA, 0x01B4, 0x01AF, 0x01A9, 0x01A4, 0x019E, 0x0199, 
-       0x0194, 0x018F, 0x018A, 0x0186, 0x0181, 0x017D, 0x0178, 0x0174, 0x0170, 0x016C, 0x0168, 0x0164, 0x0160, 0x015C, 0x0158, 0x0155, 
-       0x0151, 0x014E, 0x014A, 0x0147, 0x0144, 0x0141, 0x013E, 0x013B, 0x0138, 0x0135, 0x0132, 0x012F, 0x012C, 0x0129, 0x0127, 0x0124, 
-       0x0121, 0x011F, 0x011C, 0x011A, 0x0118, 0x0115, 0x0113, 0x0111, 0x010E, 0x010C, 0x010A, 0x0108, 0x0106, 0x0104, 0x0102, 0x0100, 
-       0x0800, 0x0800, 0x0800, 0x0800, 0x0800, 0x0787, 0x0787, 0x0787, 0x071C, 0x071C, 0x06BC, 0x06BC, 0x0666, 0x0618, 0x0618, 0x05D1, 
-       0x05D1, 0x0590, 0x0555, 0x051E, 0x051E, 0x04EC, 0x04BD, 0x0492, 0x0469, 0x0469, 0x0444, 0x0421, 0x0400, 0x03E0, 0x03C3, 0x03A8, 
-       0x038E, 0x038E, 0x0375, 0x035E, 0x0348, 0x0333, 0x031F, 0x030C, 0x02FA, 0x02E8, 0x02D8, 0x02C8, 0x02C8, 0x02B9, 0x02AA, 0x029C, 
-       0x028F, 0x0282, 0x0276, 0x026A, 0x025E, 0x0253, 0x0249, 0x023E, 0x0234, 0x022B, 0x0222, 0x0219, 0x0210, 0x0208, 0x0200, 0x01F8, 
-       0x01F0, 0x01E9, 0x01E1, 0x01DA, 0x01DA, 0x01D4, 0x01CD, 0x01C7, 0x01C0, 0x01BA, 0x01B4, 0x01AF, 0x01A9, 0x01A4, 0x019E, 0x0199, 
-       0x0194, 0x018F, 0x018A, 0x0186, 0x0181, 0x017D, 0x0178, 0x0174, 0x0170, 0x016C, 0x0168, 0x0164, 0x0160, 0x015C, 0x0158, 0x0155, 
-       0x0151, 0x014E, 0x014A, 0x0147, 0x0144, 0x0141, 0x013E, 0x013B, 0x0138, 0x0135, 0x0132, 0x012F, 0x012C, 0x0129, 0x0127, 0x0124, 
-       0x0121, 0x011F, 0x011C, 0x011A, 0x0118, 0x0115, 0x0113, 0x0111, 0x010E, 0x010C, 0x010A, 0x0108, 0x0106, 0x0104, 0x0102, 0x0100, 
-       0x0800, 0x0800, 0x0800, 0x0787, 0x0787, 0x0787, 0x0787, 0x071C, 0x071C, 0x06BC, 0x06BC, 0x0666, 0x0666, 0x0618, 0x0618, 0x05D1, 
-       0x0590, 0x0590, 0x0555, 0x051E, 0x04EC, 0x04EC, 0x04BD, 0x0492, 0x0469, 0x0444, 0x0444, 0x0421, 0x0400, 0x03E0, 0x03C3, 0x03A8, 
-       0x038E, 0x0375, 0x0375, 0x035E, 0x0348, 0x0333, 0x031F, 0x030C, 0x02FA, 0x02E8, 0x02D8, 0x02C8, 0x02B9, 0x02AA, 0x02AA, 0x029C, 
-       0x028F, 0x0282, 0x0276, 0x026A, 0x025E, 0x0253, 0x0249, 0x023E, 0x0234, 0x022B, 0x0222, 0x0219, 0x0210, 0x0208, 0x0200, 0x01F8, 
-       0x01F0, 0x01E9, 0x01E1, 0x01DA, 0x01D4, 0x01CD, 0x01CD, 0x01C7, 0x01C0, 0x01BA, 0x01B4, 0x01AF, 0x01A9, 0x01A4, 0x019E, 0x0199, 
-       0x0194, 0x018F, 0x018A, 0x0186, 0x0181, 0x017D, 0x0178, 0x0174, 0x0170, 0x016C, 0x0168, 0x0164, 0x0160, 0x015C, 0x0158, 0x0155, 
-       0x0151, 0x014E, 0x014A, 0x0147, 0x0144, 0x0141, 0x013E, 0x013B, 0x0138, 0x0135, 0x0132, 0x012F, 0x012C, 0x0129, 0x0127, 0x0124, 
-       0x0121, 0x011F, 0x011C, 0x011A, 0x0118, 0x0115, 0x0113, 0x0111, 0x010E, 0x010C, 0x010A, 0x0108, 0x0106, 0x0104, 0x0102, 0x0100, 
-       0x0787, 0x0787, 0x0787, 0x0787, 0x0787, 0x0787, 0x071C, 0x071C, 0x071C, 0x06BC, 0x06BC, 0x0666, 0x0666, 0x0618, 0x05D1, 0x05D1, 
-       0x0590, 0x0555, 0x0555, 0x051E, 0x04EC, 0x04BD, 0x04BD, 0x0492, 0x0469, 0x0444, 0x0421, 0x0421, 0x0400, 0x03E0, 0x03C3, 0x03A8, 
-       0x038E, 0x0375, 0x035E, 0x035E, 0x0348, 0x0333, 0x031F, 0x030C, 0x02FA, 0x02E8, 0x02D8, 0x02C8, 0x02B9, 0x02AA, 0x029C, 0x028F, 
-       0x028F, 0x0282, 0x0276, 0x026A, 0x025E, 0x0253, 0x0249, 0x023E, 0x0234, 0x022B, 0x0222, 0x0219, 0x0210, 0x0208, 0x0200, 0x01F8, 
-       0x01F0, 0x01E9, 0x01E1, 0x01DA, 0x01D4, 0x01CD, 0x01C7, 0x01C0, 0x01BA, 0x01BA, 0x01B4, 0x01AF, 0x01A9, 0x01A4, 0x019E, 0x0199, 
-       0x0194, 0x018F, 0x018A, 0x0186, 0x0181, 0x017D, 0x0178, 0x0174, 0x0170, 0x016C, 0x0168, 0x0164, 0x0160, 0x015C, 0x0158, 0x0155, 
-       0x0151, 0x014E, 0x014A, 0x0147, 0x0144, 0x0141, 0x013E, 0x013B, 0x0138, 0x0135, 0x0132, 0x012F, 0x012C, 0x0129, 0x0127, 0x0124, 
-       0x0121, 0x011F, 0x011C, 0x011A, 0x0118, 0x0115, 0x0113, 0x0111, 0x010E, 0x010C, 0x010A, 0x0108, 0x0106, 0x0104, 0x0102, 0x0100, 
-       0x0787, 0x0787, 0x0787, 0x0787, 0x0787, 0x071C, 0x071C, 0x071C, 0x06BC, 0x06BC, 0x0666, 0x0666, 0x0618, 0x0618, 0x05D1, 0x0590, 
-       0x0590, 0x0555, 0x051E, 0x051E, 0x04EC, 0x04BD, 0x0492, 0x0492, 0x0469, 0x0444, 0x0421, 0x0400, 0x03E0, 0x03E0, 0x03C3, 0x03A8, 
-       0x038E, 0x0375, 0x035E, 0x0348, 0x0333, 0x0333, 0x031F, 0x030C, 0x02FA, 0x02E8, 0x02D8, 0x02C8, 0x02B9, 0x02AA, 0x029C, 0x028F, 
-       0x0282, 0x0276, 0x0276, 0x026A, 0x025E, 0x0253, 0x0249, 0x023E, 0x0234, 0x022B, 0x0222, 0x0219, 0x0210, 0x0208, 0x0200, 0x01F8, 
-       0x01F0, 0x01E9, 0x01E1, 0x01DA, 0x01D4, 0x01CD, 0x01C7, 0x01C0, 0x01BA, 0x01B4, 0x01AF, 0x01A9, 0x01A9, 0x01A4, 0x019E, 0x0199, 
-       0x0194, 0x018F, 0x018A, 0x0186, 0x0181, 0x017D, 0x0178, 0x0174, 0x0170, 0x016C, 0x0168, 0x0164, 0x0160, 0x015C, 0x0158, 0x0155, 
-       0x0151, 0x014E, 0x014A, 0x0147, 0x0144, 0x0141, 0x013E, 0x013B, 0x0138, 0x0135, 0x0132, 0x012F, 0x012C, 0x0129, 0x0127, 0x0124, 
-       0x0121, 0x011F, 0x011C, 0x011A, 0x0118, 0x0115, 0x0113, 0x0111, 0x010E, 0x010C, 0x010A, 0x0108, 0x0106, 0x0104, 0x0102, 0x0100, 
-       0x0787, 0x0787, 0x071C, 0x071C, 0x071C, 0x071C, 0x071C, 0x06BC, 0x06BC, 0x0666, 0x0666, 0x0618, 0x0618, 0x05D1, 0x05D1, 0x0590, 
-       0x0555, 0x0555, 0x051E, 0x04EC, 0x04EC, 0x04BD, 0x0492, 0x0469, 0x0469, 0x0444, 0x0421, 0x0400, 0x03E0, 0x03C3, 0x03C3, 0x03A8, 
-       0x038E, 0x0375, 0x035E, 0x0348, 0x0333, 0x031F, 0x030C, 0x030C, 0x02FA, 0x02E8, 0x02D8, 0x02C8, 0x02B9, 0x02AA, 0x029C, 0x028F, 
-       0x0282, 0x0276, 0x026A, 0x025E, 0x025E, 0x0253, 0x0249, 0x023E, 0x0234, 0x022B, 0x0222, 0x0219, 0x0210, 0x0208, 0x0200, 0x01F8, 
-       0x01F0, 0x01E9, 0x01E1, 0x01DA, 0x01D4, 0x01CD, 0x01C7, 0x01C0, 0x01BA, 0x01B4, 0x01AF, 0x01A9, 0x01A4, 0x019E, 0x0199, 0x0194, 
-       0x0194, 0x018F, 0x018A, 0x0186, 0x0181, 0x017D, 0x0178, 0x0174, 0x0170, 0x016C, 0x0168, 0x0164, 0x0160, 0x015C, 0x0158, 0x0155, 
-       0x0151, 0x014E, 0x014A, 0x0147, 0x0144, 0x0141, 0x013E, 0x013B, 0x0138, 0x0135, 0x0132, 0x012F, 0x012C, 0x0129, 0x0127, 0x0124, 
-       0x0121, 0x011F, 0x011C, 0x011A, 0x0118, 0x0115, 0x0113, 0x0111, 0x010E, 0x010C, 0x010A, 0x0108, 0x0106, 0x0104, 0x0102, 0x0100, 
-       0x071C, 0x071C, 0x071C, 0x071C, 0x071C, 0x06BC, 0x06BC, 0x06BC, 0x0666, 0x0666, 0x0666, 0x0618, 0x0618, 0x05D1, 0x0590, 0x0590, 
-       0x0555, 0x051E, 0x051E, 0x04EC, 0x04BD, 0x04BD, 0x0492, 0x0469, 0x0444, 0x0421, 0x0421, 0x0400, 0x03E0, 0x03C3, 0x03A8, 0x038E, 
-       0x038E, 0x0375, 0x035E, 0x0348, 0x0333, 0x031F, 0x030C, 0x02FA, 0x02E8, 0x02E8, 0x02D8, 0x02C8, 0x02B9, 0x02AA, 0x029C, 0x028F, 
-       0x0282, 0x0276, 0x026A, 0x025E, 0x0253, 0x0249, 0x023E, 0x023E, 0x0234, 0x022B, 0x0222, 0x0219, 0x0210, 0x0208, 0x0200, 0x01F8, 
-       0x01F0, 0x01E9, 0x01E1, 0x01DA, 0x01D4, 0x01CD, 0x01C7, 0x01C0, 0x01BA, 0x01B4, 0x01AF, 0x01A9, 0x01A4, 0x019E, 0x0199, 0x0194, 
-       0x018F, 0x018A, 0x0186, 0x0181, 0x0181, 0x017D, 0x0178, 0x0174, 0x0170, 0x016C, 0x0168, 0x0164, 0x0160, 0x015C, 0x0158, 0x0155, 
-       0x0151, 0x014E, 0x014A, 0x0147, 0x0144, 0x0141, 0x013E, 0x013B, 0x0138, 0x0135, 0x0132, 0x012F, 0x012C, 0x0129, 0x0127, 0x0124, 
-       0x0121, 0x011F, 0x011C, 0x011A, 0x0118, 0x0115, 0x0113, 0x0111, 0x010E, 0x010C, 0x010A, 0x0108, 0x0106, 0x0104, 0x0102, 0x0100, 
-       0x071C, 0x071C, 0x071C, 0x06BC, 0x06BC, 0x06BC, 0x06BC, 0x0666, 0x0666, 0x0666, 0x0618, 0x0618, 0x05D1, 0x05D1, 0x0590, 0x0555, 
-       0x0555, 0x051E, 0x04EC, 0x04EC, 0x04BD, 0x0492, 0x0492, 0x0469, 0x0444, 0x0421, 0x0400, 0x0400, 0x03E0, 0x03C3, 0x03A8, 0x038E, 
-       0x0375, 0x035E, 0x035E, 0x0348, 0x0333, 0x031F, 0x030C, 0x02FA, 0x02E8, 0x02D8, 0x02C8, 0x02C8, 0x02B9, 0x02AA, 0x029C, 0x028F, 
-       0x0282, 0x0276, 0x026A, 0x025E, 0x0253, 0x0249, 0x023E, 0x0234, 0x022B, 0x0222, 0x0222, 0x0219, 0x0210, 0x0208, 0x0200, 0x01F8, 
-       0x01F0, 0x01E9, 0x01E1, 0x01DA, 0x01D4, 0x01CD, 0x01C7, 0x01C0, 0x01BA, 0x01B4, 0x01AF, 0x01A9, 0x01A4, 0x019E, 0x0199, 0x0194, 
-       0x018F, 0x018A, 0x0186, 0x0181, 0x017D, 0x0178, 0x0174, 0x0170, 0x016C, 0x016C, 0x0168, 0x0164, 0x0160, 0x015C, 0x0158, 0x0155, 
-       0x0151, 0x014E, 0x014A, 0x0147, 0x0144, 0x0141, 0x013E, 0x013B, 0x0138, 0x0135, 0x0132, 0x012F, 0x012C, 0x0129, 0x0127, 0x0124, 
-       0x0121, 0x011F, 0x011C, 0x011A, 0x0118, 0x0115, 0x0113, 0x0111, 0x010E, 0x010C, 0x010A, 0x0108, 0x0106, 0x0104, 0x0102, 0x0100, 
-       0x06BC, 0x06BC, 0x06BC, 0x06BC, 0x06BC, 0x0666, 0x0666, 0x0666, 0x0618, 0x0618, 0x0618, 0x05D1, 0x05D1, 0x0590, 0x0590, 0x0555, 
-       0x051E, 0x051E, 0x04EC, 0x04BD, 0x04BD, 0x0492, 0x0469, 0x0444, 0x0444, 0x0421, 0x0400, 0x03E0, 0x03C3, 0x03C3, 0x03A8, 0x038E, 
-       0x0375, 0x035E, 0x0348, 0x0333, 0x0333, 0x031F, 0x030C, 0x02FA, 0x02E8, 0x02D8, 0x02C8, 0x02B9, 0x02AA, 0x029C, 0x029C, 0x028F, 
-       0x0282, 0x0276, 0x026A, 0x025E, 0x0253, 0x0249, 0x023E, 0x0234, 0x022B, 0x0222, 0x0219, 0x0210, 0x0208, 0x0200, 0x0200, 0x01F8, 
-       0x01F0, 0x01E9, 0x01E1, 0x01DA, 0x01D4, 0x01CD, 0x01C7, 0x01C0, 0x01BA, 0x01B4, 0x01AF, 0x01A9, 0x01A4, 0x019E, 0x0199, 0x0194, 
-       0x018F, 0x018A, 0x0186, 0x0181, 0x017D, 0x0178, 0x0174, 0x0170, 0x016C, 0x0168, 0x0164, 0x0160, 0x015C, 0x0158, 0x0158, 0x0155, 
-       0x0151, 0x014E, 0x014A, 0x0147, 0x0144, 0x0141, 0x013E, 0x013B, 0x0138, 0x0135, 0x0132, 0x012F, 0x012C, 0x0129, 0x0127, 0x0124, 
-       0x0121, 0x011F, 0x011C, 0x011A, 0x0118, 0x0115, 0x0113, 0x0111, 0x010E, 0x010C, 0x010A, 0x0108, 0x0106, 0x0104, 0x0102, 0x0100, 
-       0x0666, 0x0666, 0x0666, 0x0666, 0x0666, 0x0666, 0x0666, 0x0618, 0x0618, 0x0618, 0x05D1, 0x05D1, 0x0590, 0x0590, 0x0555, 0x051E, 
-       0x051E, 0x04EC, 0x04EC, 0x04BD, 0x0492, 0x0469, 0x0469, 0x0444, 0x0421, 0x0400, 0x0400, 0x03E0, 0x03C3, 0x03A8, 0x038E, 0x038E, 
-       0x0375, 0x035E, 0x0348, 0x0333, 0x031F, 0x030C, 0x030C, 0x02FA, 0x02E8, 0x02D8, 0x02C8, 0x02B9, 0x02AA, 0x029C, 0x028F, 0x0282, 
-       0x0276, 0x0276, 0x026A, 0x025E, 0x0253, 0x0249, 0x023E, 0x0234, 0x022B, 0x0222, 0x0219, 0x0210, 0x0208, 0x0200, 0x01F8, 0x01F0, 
-       0x01E9, 0x01E1, 0x01E1, 0x01DA, 0x01D4, 0x01CD, 0x01C7, 0x01C0, 0x01BA, 0x01B4, 0x01AF, 0x01A9, 0x01A4, 0x019E, 0x0199, 0x0194, 
-       0x018F, 0x018A, 0x0186, 0x0181, 0x017D, 0x0178, 0x0174, 0x0170, 0x016C, 0x0168, 0x0164, 0x0160, 0x015C, 0x0158, 0x0155, 0x0151, 
-       0x014E, 0x014A, 0x0147, 0x0144, 0x0144, 0x0141, 0x013E, 0x013B, 0x0138, 0x0135, 0x0132, 0x012F, 0x012C, 0x0129, 0x0127, 0x0124, 
-       0x0121, 0x011F, 0x011C, 0x011A, 0x0118, 0x0115, 0x0113, 0x0111, 0x010E, 0x010C, 0x010A, 0x0108, 0x0106, 0x0104, 0x0102, 0x0100, 
-       0x0666, 0x0666, 0x0666, 0x0666, 0x0618, 0x0618, 0x0618, 0x0618, 0x05D1, 0x05D1, 0x05D1, 0x0590, 0x0590, 0x0555, 0x0555, 0x051E, 
-       0x04EC, 0x04EC, 0x04BD, 0x0492, 0x0492, 0x0469, 0x0444, 0x0444, 0x0421, 0x0400, 0x03E0, 0x03E0, 0x03C3, 0x03A8, 0x038E, 0x0375, 
-       0x035E, 0x035E, 0x0348, 0x0333, 0x031F, 0x030C, 0x02FA, 0x02E8, 0x02D8, 0x02D8, 0x02C8, 0x02B9, 0x02AA, 0x029C, 0x028F, 0x0282, 
-       0x0276, 0x026A, 0x025E, 0x0253, 0x0253, 0x0249, 0x023E, 0x0234, 0x022B, 0x0222, 0x0219, 0x0210, 0x0208, 0x0200, 0x01F8, 0x01F0, 
-       0x01E9, 0x01E1, 0x01DA, 0x01D4, 0x01CD, 0x01C7, 0x01C7, 0x01C0, 0x01BA, 0x01B4, 0x01AF, 0x01A9, 0x01A4, 0x019E, 0x0199, 0x0194, 
-       0x018F, 0x018A, 0x0186, 0x0181, 0x017D, 0x0178, 0x0174, 0x0170, 0x016C, 0x0168, 0x0164, 0x0160, 0x015C, 0x0158, 0x0155, 0x0151, 
-       0x014E, 0x014A, 0x0147, 0x0144, 0x0141, 0x013E, 0x013B, 0x0138, 0x0135, 0x0132, 0x0132, 0x012F, 0x012C, 0x0129, 0x0127, 0x0124, 
-       0x0121, 0x011F, 0x011C, 0x011A, 0x0118, 0x0115, 0x0113, 0x0111, 0x010E, 0x010C, 0x010A, 0x0108, 0x0106, 0x0104, 0x0102, 0x0100, 
-       0x0618, 0x0618, 0x0618, 0x0618, 0x0618, 0x0618, 0x05D1, 0x05D1, 0x05D1, 0x0590, 0x0590, 0x0590, 0x0555, 0x0555, 0x051E, 0x04EC, 
-       0x04EC, 0x04BD, 0x04BD, 0x0492, 0x0469, 0x0469, 0x0444, 0x0421, 0x0400, 0x0400, 0x03E0, 0x03C3, 0x03A8, 0x03A8, 0x038E, 0x0375, 
-       0x035E, 0x0348, 0x0333, 0x0333, 0x031F, 0x030C, 0x02FA, 0x02E8, 0x02D8, 0x02C8, 0x02B9, 0x02B9, 0x02AA, 0x029C, 0x028F, 0x0282, 
-       0x0276, 0x026A, 0x025E, 0x0253, 0x0249, 0x023E, 0x0234, 0x0234, 0x022B, 0x0222, 0x0219, 0x0210, 0x0208, 0x0200, 0x01F8, 0x01F0, 
-       0x01E9, 0x01E1, 0x01DA, 0x01D4, 0x01CD, 0x01C7, 0x01C0, 0x01BA, 0x01B4, 0x01AF, 0x01AF, 0x01A9, 0x01A4, 0x019E, 0x0199, 0x0194, 
-       0x018F, 0x018A, 0x0186, 0x0181, 0x017D, 0x0178, 0x0174, 0x0170, 0x016C, 0x0168, 0x0164, 0x0160, 0x015C, 0x0158, 0x0155, 0x0151, 
-       0x014E, 0x014A, 0x0147, 0x0144, 0x0141, 0x013E, 0x013B, 0x0138, 0x0135, 0x0132, 0x012F, 0x012C, 0x0129, 0x0127, 0x0124, 0x0121, 
-       0x011F, 0x011F, 0x011C, 0x011A, 0x0118, 0x0115, 0x0113, 0x0111, 0x010E, 0x010C, 0x010A, 0x0108, 0x0106, 0x0104, 0x0102, 0x0100, 
-       0x0618, 0x0618, 0x05D1, 0x05D1, 0x05D1, 0x05D1, 0x05D1, 0x0590, 0x0590, 0x0590, 0x0555, 0x0555, 0x051E, 0x051E, 0x04EC, 0x04EC, 
-       0x04BD, 0x04BD, 0x0492, 0x0469, 0x0469, 0x0444, 0x0421, 0x0421, 0x0400, 0x03E0, 0x03C3, 0x03C3, 0x03A8, 0x038E, 0x0375, 0x0375, 
-       0x035E, 0x0348, 0x0333, 0x031F, 0x030C, 0x02FA, 0x02FA, 0x02E8, 0x02D8, 0x02C8, 0x02B9, 0x02AA, 0x029C, 0x028F, 0x028F, 0x0282, 
-       0x0276, 0x026A, 0x025E, 0x0253, 0x0249, 0x023E, 0x0234, 0x022B, 0x0222, 0x0219, 0x0210, 0x0210, 0x0208, 0x0200, 0x01F8, 0x01F0, 
-       0x01E9, 0x01E1, 0x01DA, 0x01D4, 0x01CD, 0x01C7, 0x01C0, 0x01BA, 0x01B4, 0x01AF, 0x01A9, 0x01A4, 0x019E, 0x0199, 0x0194, 0x0194, 
-       0x018F, 0x018A, 0x0186, 0x0181, 0x017D, 0x0178, 0x0174, 0x0170, 0x016C, 0x0168, 0x0164, 0x0160, 0x015C, 0x0158, 0x0155, 0x0151, 
-       0x014E, 0x014A, 0x0147, 0x0144, 0x0141, 0x013E, 0x013B, 0x0138, 0x0135, 0x0132, 0x012F, 0x012C, 0x0129, 0x0127, 0x0124, 0x0121, 
-       0x011F, 0x011C, 0x011A, 0x0118, 0x0115, 0x0113, 0x0111, 0x010E, 0x010E, 0x010C, 0x010A, 0x0108, 0x0106, 0x0104, 0x0102, 0x0100, 
-       0x05D1, 0x05D1, 0x05D1, 0x05D1, 0x05D1, 0x0590, 0x0590, 0x0590, 0x0555, 0x0555, 0x0555, 0x051E, 0x051E, 0x04EC, 0x04EC, 0x04BD, 
-       0x04BD, 0x0492, 0x0492, 0x0469, 0x0444, 0x0444, 0x0421, 0x0400, 0x0400, 0x03E0, 0x03C3, 0x03A8, 0x038E, 0x038E, 0x0375, 0x035E, 
-       0x0348, 0x0333, 0x0333, 0x031F, 0x030C, 0x02FA, 0x02E8, 0x02D8, 0x02D8, 0x02C8, 0x02B9, 0x02AA, 0x029C, 0x028F, 0x0282, 0x0276, 
-       0x026A, 0x026A, 0x025E, 0x0253, 0x0249, 0x023E, 0x0234, 0x022B, 0x0222, 0x0219, 0x0210, 0x0208, 0x0200, 0x01F8, 0x01F0, 0x01F0, 
-       0x01E9, 0x01E1, 0x01DA, 0x01D4, 0x01CD, 0x01C7, 0x01C0, 0x01BA, 0x01B4, 0x01AF, 0x01A9, 0x01A4, 0x019E, 0x0199, 0x0194, 0x018F, 
-       0x018A, 0x0186, 0x0181, 0x017D, 0x017D, 0x0178, 0x0174, 0x0170, 0x016C, 0x0168, 0x0164, 0x0160, 0x015C, 0x0158, 0x0155, 0x0151, 
-       0x014E, 0x014A, 0x0147, 0x0144, 0x0141, 0x013E, 0x013B, 0x0138, 0x0135, 0x0132, 0x012F, 0x012C, 0x0129, 0x0127, 0x0124, 0x0121, 
-       0x011F, 0x011C, 0x011A, 0x0118, 0x0115, 0x0113, 0x0111, 0x010E, 0x010C, 0x010A, 0x0108, 0x0106, 0x0104, 0x0102, 0x0100, 0x00FE, 
-       0x0590, 0x0590, 0x0590, 0x0590, 0x0590, 0x0590, 0x0555, 0x0555, 0x0555, 0x051E, 0x051E, 0x051E, 0x04EC, 0x04EC, 0x04BD, 0x04BD, 
-       0x0492, 0x0492, 0x0469, 0x0444, 0x0444, 0x0421, 0x0400, 0x0400, 0x03E0, 0x03C3, 0x03C3, 0x03A8, 0x038E, 0x0375, 0x035E, 0x035E, 
-       0x0348, 0x0333, 0x031F, 0x030C, 0x030C, 0x02FA, 0x02E8, 0x02D8, 0x02C8, 0x02B9, 0x02AA, 0x02AA, 0x029C, 0x028F, 0x0282, 0x0276, 
-       0x026A, 0x025E, 0x0253, 0x0249, 0x023E, 0x023E, 0x0234, 0x022B, 0x0222, 0x0219, 0x0210, 0x0208, 0x0200, 0x01F8, 0x01F0, 0x01E9, 
-       0x01E1, 0x01DA, 0x01D4, 0x01D4, 0x01CD, 0x01C7, 0x01C0, 0x01BA, 0x01B4, 0x01AF, 0x01A9, 0x01A4, 0x019E, 0x0199, 0x0194, 0x018F, 
-       0x018A, 0x0186, 0x0181, 0x017D, 0x0178, 0x0174, 0x0170, 0x016C, 0x0168, 0x0164, 0x0164, 0x0160, 0x015C, 0x0158, 0x0155, 0x0151, 
-       0x014E, 0x014A, 0x0147, 0x0144, 0x0141, 0x013E, 0x013B, 0x0138, 0x0135, 0x0132, 0x012F, 0x012C, 0x0129, 0x0127, 0x0124, 0x0121, 
-       0x011F, 0x011C, 0x011A, 0x0118, 0x0115, 0x0113, 0x0111, 0x010E, 0x010C, 0x010A, 0x0108, 0x0106, 0x0104, 0x0102, 0x0100, 0x00FE, 
-       0x0555, 0x0555, 0x0555, 0x0555, 0x0555, 0x0555, 0x0555, 0x051E, 0x051E, 0x051E, 0x04EC, 0x04EC, 0x04EC, 0x04BD, 0x04BD, 0x0492, 
-       0x0492, 0x0469, 0x0444, 0x0444, 0x0421, 0x0421, 0x0400, 0x03E0, 0x03C3, 0x03C3, 0x03A8, 0x038E, 0x038E, 0x0375, 0x035E, 0x0348, 
-       0x0333, 0x0333, 0x031F, 0x030C, 0x02FA, 0x02E8, 0x02E8, 0x02D8, 0x02C8, 0x02B9, 0x02AA, 0x029C, 0x028F, 0x0282, 0x0282, 0x0276, 
-       0x026A, 0x025E, 0x0253, 0x0249, 0x023E, 0x0234, 0x022B, 0x0222, 0x0222, 0x0219, 0x0210, 0x0208, 0x0200, 0x01F8, 0x01F0, 0x01E9, 
-       0x01E1, 0x01DA, 0x01D4, 0x01CD, 0x01C7, 0x01C0, 0x01BA, 0x01BA, 0x01B4, 0x01AF, 0x01A9, 0x01A4, 0x019E, 0x0199, 0x0194, 0x018F, 
-       0x018A, 0x0186, 0x0181, 0x017D, 0x0178, 0x0174, 0x0170, 0x016C, 0x0168, 0x0164, 0x0160, 0x015C, 0x0158, 0x0155, 0x0151, 0x014E, 
-       0x014E, 0x014A, 0x0147, 0x0144, 0x0141, 0x013E, 0x013B, 0x0138, 0x0135, 0x0132, 0x012F, 0x012C, 0x0129, 0x0127, 0x0124, 0x0121, 
-       0x011F, 0x011C, 0x011A, 0x0118, 0x0115, 0x0113, 0x0111, 0x010E, 0x010C, 0x010A, 0x0108, 0x0106, 0x0104, 0x0102, 0x0100, 0x00FE, 
-       0x0555, 0x0555, 0x0555, 0x051E, 0x051E, 0x051E, 0x051E, 0x051E, 0x04EC, 0x04EC, 0x04EC, 0x04BD, 0x04BD, 0x0492, 0x0492, 0x0469, 
-       0x0469, 0x0444, 0x0444, 0x0421, 0x0421, 0x0400, 0x03E0, 0x03E0, 0x03C3, 0x03A8, 0x03A8, 0x038E, 0x0375, 0x035E, 0x035E, 0x0348, 
-       0x0333, 0x031F, 0x030C, 0x030C, 0x02FA, 0x02E8, 0x02D8, 0x02C8, 0x02B9, 0x02B9, 0x02AA, 0x029C, 0x028F, 0x0282, 0x0276, 0x026A, 
-       0x025E, 0x025E, 0x0253, 0x0249, 0x023E, 0x0234, 0x022B, 0x0222, 0x0219, 0x0210, 0x0208, 0x0200, 0x0200, 0x01F8, 0x01F0, 0x01E9, 
-       0x01E1, 0x01DA, 0x01D4, 0x01CD, 0x01C7, 0x01C0, 0x01BA, 0x01B4, 0x01AF, 0x01A9, 0x01A4, 0x019E, 0x019E, 0x0199, 0x0194, 0x018F, 
-       0x018A, 0x0186, 0x0181, 0x017D, 0x0178, 0x0174, 0x0170, 0x016C, 0x0168, 0x0164, 0x0160, 0x015C, 0x0158, 0x0155, 0x0151, 0x014E, 
-       0x014A, 0x0147, 0x0144, 0x0141, 0x013E, 0x013B, 0x013B, 0x0138, 0x0135, 0x0132, 0x012F, 0x012C, 0x0129, 0x0127, 0x0124, 0x0121, 
-       0x011F, 0x011C, 0x011A, 0x0118, 0x0115, 0x0113, 0x0111, 0x010E, 0x010C, 0x010A, 0x0108, 0x0106, 0x0104, 0x0102, 0x0100, 0x00FE, 
-       0x051E, 0x051E, 0x051E, 0x051E, 0x051E, 0x04EC, 0x04EC, 0x04EC, 0x04EC, 0x04BD, 0x04BD, 0x04BD, 0x0492, 0x0492, 0x0469, 0x0469, 
-       0x0444, 0x0444, 0x0421, 0x0421, 0x0400, 0x03E0, 0x03E0, 0x03C3, 0x03A8, 0x03A8, 0x038E, 0x0375, 0x0375, 0x035E, 0x0348, 0x0333, 
-       0x0333, 0x031F, 0x030C, 0x02FA, 0x02E8, 0x02D8, 0x02D8, 0x02C8, 0x02B9, 0x02AA, 0x029C, 0x028F, 0x028F, 0x0282, 0x0276, 0x026A, 
-       0x025E, 0x0253, 0x0249, 0x023E, 0x023E, 0x0234, 0x022B, 0x0222, 0x0219, 0x0210, 0x0208, 0x0200, 0x01F8, 0x01F0, 0x01E9, 0x01E1, 
-       0x01E1, 0x01DA, 0x01D4, 0x01CD, 0x01C7, 0x01C0, 0x01BA, 0x01B4, 0x01AF, 0x01A9, 0x01A4, 0x019E, 0x0199, 0x0194, 0x018F, 0x018A, 
-       0x0186, 0x0186, 0x0181, 0x017D, 0x0178, 0x0174, 0x0170, 0x016C, 0x0168, 0x0164, 0x0160, 0x015C, 0x0158, 0x0155, 0x0151, 0x014E, 
-       0x014A, 0x0147, 0x0144, 0x0141, 0x013E, 0x013B, 0x0138, 0x0135, 0x0132, 0x012F, 0x012C, 0x0129, 0x0129, 0x0127, 0x0124, 0x0121, 
-       0x011F, 0x011C, 0x011A, 0x0118, 0x0115, 0x0113, 0x0111, 0x010E, 0x010C, 0x010A, 0x0108, 0x0106, 0x0104, 0x0102, 0x0100, 0x00FE, 
-       0x04EC, 0x04EC, 0x04EC, 0x04EC, 0x04EC, 0x04EC, 0x04BD, 0x04BD, 0x04BD, 0x04BD, 0x0492, 0x0492, 0x0469, 0x0469, 0x0469, 0x0444, 
-       0x0444, 0x0421, 0x0421, 0x0400, 0x03E0, 0x03E0, 0x03C3, 0x03A8, 0x03A8, 0x038E, 0x0375, 0x0375, 0x035E, 0x0348, 0x0348, 0x0333, 
-       0x031F, 0x030C, 0x02FA, 0x02FA, 0x02E8, 0x02D8, 0x02C8, 0x02B9, 0x02B9, 0x02AA, 0x029C, 0x028F, 0x0282, 0x0276, 0x026A, 0x026A, 
-       0x025E, 0x0253, 0x0249, 0x023E, 0x0234, 0x022B, 0x0222, 0x0219, 0x0219, 0x0210, 0x0208, 0x0200, 0x01F8, 0x01F0, 0x01E9, 0x01E1, 
-       0x01DA, 0x01D4, 0x01CD, 0x01C7, 0x01C7, 0x01C0, 0x01BA, 0x01B4, 0x01AF, 0x01A9, 0x01A4, 0x019E, 0x0199, 0x0194, 0x018F, 0x018A, 
-       0x0186, 0x0181, 0x017D, 0x0178, 0x0174, 0x0170, 0x0170, 0x016C, 0x0168, 0x0164, 0x0160, 0x015C, 0x0158, 0x0155, 0x0151, 0x014E, 
-       0x014A, 0x0147, 0x0144, 0x0141, 0x013E, 0x013B, 0x0138, 0x0135, 0x0132, 0x012F, 0x012C, 0x0129, 0x0127, 0x0124, 0x0121, 0x011F, 
-       0x011C, 0x011A, 0x0118, 0x0118, 0x0115, 0x0113, 0x0111, 0x010E, 0x010C, 0x010A, 0x0108, 0x0106, 0x0104, 0x0102, 0x0100, 0x00FE, 
-       0x04BD, 0x04BD, 0x04BD, 0x04BD, 0x04BD, 0x04BD, 0x04BD, 0x0492, 0x0492, 0x0492, 0x0492, 0x0469, 0x0469, 0x0444, 0x0444, 0x0421, 
-       0x0421, 0x0400, 0x0400, 0x03E0, 0x03E0, 0x03C3, 0x03C3, 0x03A8, 0x038E, 0x038E, 0x0375, 0x035E, 0x0348, 0x0348, 0x0333, 0x031F, 
-       0x030C, 0x030C, 0x02FA, 0x02E8, 0x02D8, 0x02D8, 0x02C8, 0x02B9, 0x02AA, 0x029C, 0x028F, 0x028F, 0x0282, 0x0276, 0x026A, 0x025E, 
-       0x0253, 0x0249, 0x0249, 0x023E, 0x0234, 0x022B, 0x0222, 0x0219, 0x0210, 0x0208, 0x0200, 0x0200, 0x01F8, 0x01F0, 0x01E9, 0x01E1, 
-       0x01DA, 0x01D4, 0x01CD, 0x01C7, 0x01C0, 0x01BA, 0x01B4, 0x01AF, 0x01AF, 0x01A9, 0x01A4, 0x019E, 0x0199, 0x0194, 0x018F, 0x018A, 
-       0x0186, 0x0181, 0x017D, 0x0178, 0x0174, 0x0170, 0x016C, 0x0168, 0x0164, 0x0160, 0x015C, 0x015C, 0x0158, 0x0155, 0x0151, 0x014E, 
-       0x014A, 0x0147, 0x0144, 0x0141, 0x013E, 0x013B, 0x0138, 0x0135, 0x0132, 0x012F, 0x012C, 0x0129, 0x0127, 0x0124, 0x0121, 0x011F, 
-       0x011C, 0x011A, 0x0118, 0x0115, 0x0113, 0x0111, 0x010E, 0x010C, 0x010A, 0x0108, 0x0108, 0x0106, 0x0104, 0x0102, 0x0100, 0x00FE, 
-       0x0492, 0x0492, 0x0492, 0x0492, 0x0492, 0x0492, 0x0492, 0x0492, 0x0469, 0x0469, 0x0469, 0x0444, 0x0444, 0x0444, 0x0421, 0x0421, 
-       0x0400, 0x0400, 0x03E0, 0x03E0, 0x03C3, 0x03A8, 0x03A8, 0x038E, 0x038E, 0x0375, 0x035E, 0x035E, 0x0348, 0x0333, 0x031F, 0x031F, 
-       0x030C, 0x02FA, 0x02E8, 0x02E8, 0x02D8, 0x02C8, 0x02B9, 0x02AA, 0x02AA, 0x029C, 0x028F, 0x0282, 0x0276, 0x026A, 0x026A, 0x025E, 
-       0x0253, 0x0249, 0x023E, 0x0234, 0x022B, 0x022B, 0x0222, 0x0219, 0x0210, 0x0208, 0x0200, 0x01F8, 0x01F0, 0x01E9, 0x01E1, 0x01E1, 
-       0x01DA, 0x01D4, 0x01CD, 0x01C7, 0x01C0, 0x01BA, 0x01B4, 0x01AF, 0x01A9, 0x01A4, 0x019E, 0x0199, 0x0194, 0x0194, 0x018F, 0x018A, 
-       0x0186, 0x0181, 0x017D, 0x0178, 0x0174, 0x0170, 0x016C, 0x0168, 0x0164, 0x0160, 0x015C, 0x0158, 0x0155, 0x0151, 0x014E, 0x014A, 
-       0x0147, 0x0147, 0x0144, 0x0141, 0x013E, 0x013B, 0x0138, 0x0135, 0x0132, 0x012F, 0x012C, 0x0129, 0x0127, 0x0124, 0x0121, 0x011F, 
-       0x011C, 0x011A, 0x0118, 0x0115, 0x0113, 0x0111, 0x010E, 0x010C, 0x010A, 0x0108, 0x0106, 0x0104, 0x0102, 0x0100, 0x00FE, 0x00FC, 
-       0x0492, 0x0492, 0x0492, 0x0469, 0x0469, 0x0469, 0x0469, 0x0469, 0x0469, 0x0444, 0x0444, 0x0444, 0x0421, 0x0421, 0x0400, 0x0400, 
-       0x0400, 0x03E0, 0x03C3, 0x03C3, 0x03A8, 0x03A8, 0x038E, 0x038E, 0x0375, 0x035E, 0x035E, 0x0348, 0x0333, 0x0333, 0x031F, 0x030C, 
-       0x02FA, 0x02FA, 0x02E8, 0x02D8, 0x02C8, 0x02C8, 0x02B9, 0x02AA, 0x029C, 0x028F, 0x028F, 0x0282, 0x0276, 0x026A, 0x025E, 0x0253, 
-       0x0249, 0x0249, 0x023E, 0x0234, 0x022B, 0x0222, 0x0219, 0x0210, 0x0210, 0x0208, 0x0200, 0x01F8, 0x01F0, 0x01E9, 0x01E1, 0x01DA, 
-       0x01D4, 0x01CD, 0x01C7, 0x01C7, 0x01C0, 0x01BA, 0x01B4, 0x01AF, 0x01A9, 0x01A4, 0x019E, 0x0199, 0x0194, 0x018F, 0x018A, 0x0186, 
-       0x0181, 0x0181, 0x017D, 0x0178, 0x0174, 0x0170, 0x016C, 0x0168, 0x0164, 0x0160, 0x015C, 0x0158, 0x0155, 0x0151, 0x014E, 0x014A, 
-       0x0147, 0x0144, 0x0141, 0x013E, 0x013B, 0x0138, 0x0135, 0x0135, 0x0132, 0x012F, 0x012C, 0x0129, 0x0127, 0x0124, 0x0121, 0x011F, 
-       0x011C, 0x011A, 0x0118, 0x0115, 0x0113, 0x0111, 0x010E, 0x010C, 0x010A, 0x0108, 0x0106, 0x0104, 0x0102, 0x0100, 0x00FE, 0x00FC, 
-       0x0469, 0x0469, 0x0469, 0x0469, 0x0469, 0x0444, 0x0444, 0x0444, 0x0444, 0x0421, 0x0421, 0x0421, 0x0400, 0x0400, 0x0400, 0x03E0, 
-       0x03E0, 0x03C3, 0x03C3, 0x03A8, 0x03A8, 0x038E, 0x038E, 0x0375, 0x035E, 0x035E, 0x0348, 0x0333, 0x0333, 0x031F, 0x030C, 0x030C, 
-       0x02FA, 0x02E8, 0x02D8, 0x02D8, 0x02C8, 0x02B9, 0x02AA, 0x029C, 0x029C, 0x028F, 0x0282, 0x0276, 0x026A, 0x026A, 0x025E, 0x0253, 
-       0x0249, 0x023E, 0x0234, 0x022B, 0x022B, 0x0222, 0x0219, 0x0210, 0x0208, 0x0200, 0x01F8, 0x01F0, 0x01F0, 0x01E9, 0x01E1, 0x01DA, 
-       0x01D4, 0x01CD, 0x01C7, 0x01C0, 0x01BA, 0x01B4, 0x01AF, 0x01AF, 0x01A9, 0x01A4, 0x019E, 0x0199, 0x0194, 0x018F, 0x018A, 0x0186, 
-       0x0181, 0x017D, 0x0178, 0x0174, 0x0170, 0x016C, 0x016C, 0x0168, 0x0164, 0x0160, 0x015C, 0x0158, 0x0155, 0x0151, 0x014E, 0x014A, 
-       0x0147, 0x0144, 0x0141, 0x013E, 0x013B, 0x0138, 0x0135, 0x0132, 0x012F, 0x012C, 0x0129, 0x0127, 0x0124, 0x0124, 0x0121, 0x011F, 
-       0x011C, 0x011A, 0x0118, 0x0115, 0x0113, 0x0111, 0x010E, 0x010C, 0x010A, 0x0108, 0x0106, 0x0104, 0x0102, 0x0100, 0x00FE, 0x00FC, 
-       0x0444, 0x0444, 0x0444, 0x0444, 0x0444, 0x0444, 0x0421, 0x0421, 0x0421, 0x0421, 0x0400, 0x0400, 0x0400, 0x03E0, 0x03E0, 0x03C3, 
-       0x03C3, 0x03C3, 0x03A8, 0x03A8, 0x038E, 0x0375, 0x0375, 0x035E, 0x035E, 0x0348, 0x0333, 0x0333, 0x031F, 0x030C, 0x030C, 0x02FA, 
-       0x02E8, 0x02E8, 0x02D8, 0x02C8, 0x02B9, 0x02B9, 0x02AA, 0x029C, 0x028F, 0x0282, 0x0282, 0x0276, 0x026A, 0x025E, 0x0253, 0x0249, 
-       0x0249, 0x023E, 0x0234, 0x022B, 0x0222, 0x0219, 0x0210, 0x0210, 0x0208, 0x0200, 0x01F8, 0x01F0, 0x01E9, 0x01E1, 0x01DA, 0x01D4, 
-       0x01D4, 0x01CD, 0x01C7, 0x01C0, 0x01BA, 0x01B4, 0x01AF, 0x01A9, 0x01A4, 0x019E, 0x0199, 0x0199, 0x0194, 0x018F, 0x018A, 0x0186, 
-       0x0181, 0x017D, 0x0178, 0x0174, 0x0170, 0x016C, 0x0168, 0x0164, 0x0160, 0x015C, 0x0158, 0x0158, 0x0155, 0x0151, 0x014E, 0x014A, 
-       0x0147, 0x0144, 0x0141, 0x013E, 0x013B, 0x0138, 0x0135, 0x0132, 0x012F, 0x012C, 0x0129, 0x0127, 0x0124, 0x0121, 0x011F, 0x011C, 
-       0x011A, 0x0118, 0x0115, 0x0115, 0x0113, 0x0111, 0x010E, 0x010C, 0x010A, 0x0108, 0x0106, 0x0104, 0x0102, 0x0100, 0x00FE, 0x00FC, 
-       0x0421, 0x0421, 0x0421, 0x0421, 0x0421, 0x0421, 0x0421, 0x0400, 0x0400, 0x0400, 0x0400, 0x03E0, 0x03E0, 0x03E0, 0x03C3, 0x03C3, 
-       0x03A8, 0x03A8, 0x038E, 0x038E, 0x0375, 0x0375, 0x035E, 0x035E, 0x0348, 0x0333, 0x0333, 0x031F, 0x030C, 0x030C, 0x02FA, 0x02E8, 
-       0x02E8, 0x02D8, 0x02C8, 0x02B9, 0x02B9, 0x02AA, 0x029C, 0x028F, 0x028F, 0x0282, 0x0276, 0x026A, 0x025E, 0x025E, 0x0253, 0x0249, 
-       0x023E, 0x0234, 0x022B, 0x022B, 0x0222, 0x0219, 0x0210, 0x0208, 0x0200, 0x01F8, 0x01F8, 0x01F0, 0x01E9, 0x01E1, 0x01DA, 0x01D4, 
-       0x01CD, 0x01C7, 0x01C0, 0x01C0, 0x01BA, 0x01B4, 0x01AF, 0x01A9, 0x01A4, 0x019E, 0x0199, 0x0194, 0x018F, 0x018A, 0x0186, 0x0181, 
-       0x0181, 0x017D, 0x0178, 0x0174, 0x0170, 0x016C, 0x0168, 0x0164, 0x0160, 0x015C, 0x0158, 0x0155, 0x0151, 0x014E, 0x014A, 0x0147, 
-       0x0144, 0x0144, 0x0141, 0x013E, 0x013B, 0x0138, 0x0135, 0x0132, 0x012F, 0x012C, 0x0129, 0x0127, 0x0124, 0x0121, 0x011F, 0x011C, 
-       0x011A, 0x0118, 0x0115, 0x0113, 0x0111, 0x010E, 0x010C, 0x010A, 0x0108, 0x0106, 0x0106, 0x0104, 0x0102, 0x0100, 0x00FE, 0x00FC, 
-       0x0400, 0x0400, 0x0400, 0x0400, 0x0400, 0x0400, 0x0400, 0x03E0, 0x03E0, 0x03E0, 0x03E0, 0x03C3, 0x03C3, 0x03C3, 0x03A8, 0x03A8, 
-       0x038E, 0x038E, 0x038E, 0x0375, 0x0375, 0x035E, 0x0348, 0x0348, 0x0333, 0x0333, 0x031F, 0x030C, 0x030C, 0x02FA, 0x02E8, 0x02E8, 
-       0x02D8, 0x02C8, 0x02C8, 0x02B9, 0x02AA, 0x029C, 0x029C, 0x028F, 0x0282, 0x0276, 0x0276, 0x026A, 0x025E, 0x0253, 0x0249, 0x023E, 
-       0x023E, 0x0234, 0x022B, 0x0222, 0x0219, 0x0210, 0x0210, 0x0208, 0x0200, 0x01F8, 0x01F0, 0x01E9, 0x01E1, 0x01DA, 0x01DA, 0x01D4, 
-       0x01CD, 0x01C7, 0x01C0, 0x01BA, 0x01B4, 0x01AF, 0x01A9, 0x01A9, 0x01A4, 0x019E, 0x0199, 0x0194, 0x018F, 0x018A, 0x0186, 0x0181, 
-       0x017D, 0x0178, 0x0174, 0x0170, 0x0170, 0x016C, 0x0168, 0x0164, 0x0160, 0x015C, 0x0158, 0x0155, 0x0151, 0x014E, 0x014A, 0x0147, 
-       0x0144, 0x0141, 0x013E, 0x013B, 0x0138, 0x0135, 0x0135, 0x0132, 0x012F, 0x012C, 0x0129, 0x0127, 0x0124, 0x0121, 0x011F, 0x011C, 
-       0x011A, 0x0118, 0x0115, 0x0113, 0x0111, 0x010E, 0x010C, 0x010A, 0x0108, 0x0106, 0x0104, 0x0102, 0x0100, 0x00FE, 0x00FC, 0x00FA, 
-       0x03E0, 0x03E0, 0x03E0, 0x03E0, 0x03E0, 0x03E0, 0x03E0, 0x03E0, 0x03C3, 0x03C3, 0x03C3, 0x03C3, 0x03A8, 0x03A8, 0x03A8, 0x038E, 
-       0x038E, 0x0375, 0x0375, 0x035E, 0x035E, 0x0348, 0x0348, 0x0333, 0x0333, 0x031F, 0x030C, 0x030C, 0x02FA, 0x02E8, 0x02E8, 0x02D8, 
-       0x02C8, 0x02C8, 0x02B9, 0x02AA, 0x02AA, 0x029C, 0x028F, 0x0282, 0x0282, 0x0276, 0x026A, 0x025E, 0x0253, 0x0253, 0x0249, 0x023E, 
-       0x0234, 0x022B, 0x022B, 0x0222, 0x0219, 0x0210, 0x0208, 0x0200, 0x01F8, 0x01F8, 0x01F0, 0x01E9, 0x01E1, 0x01DA, 0x01D4, 0x01CD, 
-       0x01C7, 0x01C7, 0x01C0, 0x01BA, 0x01B4, 0x01AF, 0x01A9, 0x01A4, 0x019E, 0x0199, 0x0194, 0x0194, 0x018F, 0x018A, 0x0186, 0x0181, 
-       0x017D, 0x0178, 0x0174, 0x0170, 0x016C, 0x0168, 0x0164, 0x0160, 0x015C, 0x015C, 0x0158, 0x0155, 0x0151, 0x014E, 0x014A, 0x0147, 
-       0x0144, 0x0141, 0x013E, 0x013B, 0x0138, 0x0135, 0x0132, 0x012F, 0x012C, 0x0129, 0x0127, 0x0124, 0x0124, 0x0121, 0x011F, 0x011C, 
-       0x011A, 0x0118, 0x0115, 0x0113, 0x0111, 0x010E, 0x010C, 0x010A, 0x0108, 0x0106, 0x0104, 0x0102, 0x0100, 0x00FE, 0x00FC, 0x00FA, 
-       0x03C3, 0x03C3, 0x03C3, 0x03C3, 0x03C3, 0x03C3, 0x03C3, 0x03C3, 0x03C3, 0x03A8, 0x03A8, 0x03A8, 0x038E, 0x038E, 0x038E, 0x0375, 
-       0x0375, 0x035E, 0x035E, 0x035E, 0x0348, 0x0348, 0x0333, 0x031F, 0x031F, 0x030C, 0x030C, 0x02FA, 0x02E8, 0x02E8, 0x02D8, 0x02C8, 
-       0x02C8, 0x02B9, 0x02AA, 0x02AA, 0x029C, 0x028F, 0x028F, 0x0282, 0x0276, 0x026A, 0x025E, 0x025E, 0x0253, 0x0249, 0x023E, 0x0234, 
-       0x0234, 0x022B, 0x0222, 0x0219, 0x0210, 0x0210, 0x0208, 0x0200, 0x01F8, 0x01F0, 0x01E9, 0x01E1, 0x01E1, 0x01DA, 0x01D4, 0x01CD, 
-       0x01C7, 0x01C0, 0x01BA, 0x01B4, 0x01AF, 0x01AF, 0x01A9, 0x01A4, 0x019E, 0x0199, 0x0194, 0x018F, 0x018A, 0x0186, 0x0181, 0x017D, 
-       0x017D, 0x0178, 0x0174, 0x0170, 0x016C, 0x0168, 0x0164, 0x0160, 0x015C, 0x0158, 0x0155, 0x0151, 0x014E, 0x014A, 0x014A, 0x0147, 
-       0x0144, 0x0141, 0x013E, 0x013B, 0x0138, 0x0135, 0x0132, 0x012F, 0x012C, 0x0129, 0x0127, 0x0124, 0x0121, 0x011F, 0x011C, 0x011A, 
-       0x0118, 0x0115, 0x0115, 0x0113, 0x0111, 0x010E, 0x010C, 0x010A, 0x0108, 0x0106, 0x0104, 0x0102, 0x0100, 0x00FE, 0x00FC, 0x00FA, 
-       0x03C3, 0x03C3, 0x03C3, 0x03A8, 0x03A8, 0x03A8, 0x03A8, 0x03A8, 0x03A8, 0x038E, 0x038E, 0x038E, 0x038E, 0x0375, 0x0375, 0x0375, 
-       0x035E, 0x035E, 0x0348, 0x0348, 0x0333, 0x0333, 0x031F, 0x031F, 0x030C, 0x030C, 0x02FA, 0x02E8, 0x02E8, 0x02D8, 0x02C8, 0x02C8, 
-       0x02B9, 0x02AA, 0x02AA, 0x029C, 0x028F, 0x028F, 0x0282, 0x0276, 0x026A, 0x026A, 0x025E, 0x0253, 0x0249, 0x0249, 0x023E, 0x0234, 
-       0x022B, 0x0222, 0x0222, 0x0219, 0x0210, 0x0208, 0x0200, 0x01F8, 0x01F8, 0x01F0, 0x01E9, 0x01E1, 0x01DA, 0x01D4, 0x01CD, 0x01C7, 
-       0x01C7, 0x01C0, 0x01BA, 0x01B4, 0x01AF, 0x01A9, 0x01A4, 0x019E, 0x0199, 0x0199, 0x0194, 0x018F, 0x018A, 0x0186, 0x0181, 0x017D, 
-       0x0178, 0x0174, 0x0170, 0x016C, 0x016C, 0x0168, 0x0164, 0x0160, 0x015C, 0x0158, 0x0155, 0x0151, 0x014E, 0x014A, 0x0147, 0x0144, 
-       0x0141, 0x013E, 0x013B, 0x013B, 0x0138, 0x0135, 0x0132, 0x012F, 0x012C, 0x0129, 0x0127, 0x0124, 0x0121, 0x011F, 0x011C, 0x011A, 
-       0x0118, 0x0115, 0x0113, 0x0111, 0x010E, 0x010C, 0x010A, 0x0108, 0x0108, 0x0106, 0x0104, 0x0102, 0x0100, 0x00FE, 0x00FC, 0x00FA, 
-       0x03A8, 0x03A8, 0x03A8, 0x03A8, 0x038E, 0x038E, 0x038E, 0x038E, 0x038E, 0x038E, 0x0375, 0x0375, 0x0375, 0x035E, 0x035E, 0x035E, 
-       0x0348, 0x0348, 0x0333, 0x0333, 0x0333, 0x031F, 0x030C, 0x030C, 0x02FA, 0x02FA, 0x02E8, 0x02E8, 0x02D8, 0x02C8, 0x02C8, 0x02B9, 
-       0x02AA, 0x02AA, 0x029C, 0x028F, 0x028F, 0x0282, 0x0276, 0x0276, 0x026A, 0x025E, 0x0253, 0x0253, 0x0249, 0x023E, 0x0234, 0x022B, 
-       0x022B, 0x0222, 0x0219, 0x0210, 0x0208, 0x0208, 0x0200, 0x01F8, 0x01F0, 0x01E9, 0x01E1, 0x01DA, 0x01DA, 0x01D4, 0x01CD, 0x01C7, 
-       0x01C0, 0x01BA, 0x01B4, 0x01B4, 0x01AF, 0x01A9, 0x01A4, 0x019E, 0x0199, 0x0194, 0x018F, 0x018A, 0x0186, 0x0186, 0x0181, 0x017D, 
-       0x0178, 0x0174, 0x0170, 0x016C, 0x0168, 0x0164, 0x0160, 0x015C, 0x015C, 0x0158, 0x0155, 0x0151, 0x014E, 0x014A, 0x0147, 0x0144, 
-       0x0141, 0x013E, 0x013B, 0x0138, 0x0135, 0x0132, 0x012F, 0x012C, 0x012C, 0x0129, 0x0127, 0x0124, 0x0121, 0x011F, 0x011C, 0x011A, 
-       0x0118, 0x0115, 0x0113, 0x0111, 0x010E, 0x010C, 0x010A, 0x0108, 0x0106, 0x0104, 0x0102, 0x0100, 0x00FE, 0x00FC, 0x00FC, 0x00FA, 
-       0x038E, 0x038E, 0x038E, 0x038E, 0x038E, 0x0375, 0x0375, 0x0375, 0x0375, 0x0375, 0x035E, 0x035E, 0x035E, 0x035E, 0x0348, 0x0348, 
-       0x0333, 0x0333, 0x0333, 0x031F, 0x031F, 0x030C, 0x030C, 0x02FA, 0x02FA, 0x02E8, 0x02E8, 0x02D8, 0x02C8, 0x02C8, 0x02B9, 0x02AA, 
-       0x02AA, 0x029C, 0x028F, 0x028F, 0x0282, 0x0276, 0x0276, 0x026A, 0x025E, 0x0253, 0x0253, 0x0249, 0x023E, 0x0234, 0x0234, 0x022B, 
-       0x0222, 0x0219, 0x0210, 0x0210, 0x0208, 0x0200, 0x01F8, 0x01F0, 0x01F0, 0x01E9, 0x01E1, 0x01DA, 0x01D4, 0x01CD, 0x01C7, 0x01C7, 
-       0x01C0, 0x01BA, 0x01B4, 0x01AF, 0x01A9, 0x01A4, 0x019E, 0x019E, 0x0199, 0x0194, 0x018F, 0x018A, 0x0186, 0x0181, 0x017D, 0x0178, 
-       0x0174, 0x0174, 0x0170, 0x016C, 0x0168, 0x0164, 0x0160, 0x015C, 0x0158, 0x0155, 0x0151, 0x014E, 0x014A, 0x014A, 0x0147, 0x0144, 
-       0x0141, 0x013E, 0x013B, 0x0138, 0x0135, 0x0132, 0x012F, 0x012C, 0x0129, 0x0127, 0x0124, 0x0121, 0x011F, 0x011C, 0x011C, 0x011A, 
-       0x0118, 0x0115, 0x0113, 0x0111, 0x010E, 0x010C, 0x010A, 0x0108, 0x0106, 0x0104, 0x0102, 0x0100, 0x00FE, 0x00FC, 0x00FA, 0x00F8, 
-       0x0375, 0x0375, 0x0375, 0x0375, 0x0375, 0x0375, 0x035E, 0x035E, 0x035E, 0x035E, 0x035E, 0x0348, 0x0348, 0x0348, 0x0333, 0x0333, 
-       0x0333, 0x031F, 0x031F, 0x030C, 0x030C, 0x02FA, 0x02FA, 0x02E8, 0x02E8, 0x02D8, 0x02D8, 0x02C8, 0x02C8, 0x02B9, 0x02AA, 0x02AA, 
-       0x029C, 0x028F, 0x028F, 0x0282, 0x0276, 0x0276, 0x026A, 0x025E, 0x025E, 0x0253, 0x0249, 0x023E, 0x023E, 0x0234, 0x022B, 0x0222, 
-       0x0222, 0x0219, 0x0210, 0x0208, 0x0200, 0x0200, 0x01F8, 0x01F0, 0x01E9, 0x01E1, 0x01DA, 0x01DA, 0x01D4, 0x01CD, 0x01C7, 0x01C0, 
-       0x01BA, 0x01B4, 0x01B4, 0x01AF, 0x01A9, 0x01A4, 0x019E, 0x0199, 0x0194, 0x018F, 0x018F, 0x018A, 0x0186, 0x0181, 0x017D, 0x0178, 
-       0x0174, 0x0170, 0x016C, 0x0168, 0x0164, 0x0164, 0x0160, 0x015C, 0x0158, 0x0155, 0x0151, 0x014E, 0x014A, 0x0147, 0x0144, 0x0141, 
-       0x013E, 0x013B, 0x013B, 0x0138, 0x0135, 0x0132, 0x012F, 0x012C, 0x0129, 0x0127, 0x0124, 0x0121, 0x011F, 0x011C, 0x011A, 0x0118, 
-       0x0115, 0x0113, 0x0111, 0x0111, 0x010E, 0x010C, 0x010A, 0x0108, 0x0106, 0x0104, 0x0102, 0x0100, 0x00FE, 0x00FC, 0x00FA, 0x00F8, 
-       0x035E, 0x035E, 0x035E, 0x035E, 0x035E, 0x035E, 0x035E, 0x0348, 0x0348, 0x0348, 0x0348, 0x0333, 0x0333, 0x0333, 0x0333, 0x031F, 
-       0x031F, 0x030C, 0x030C, 0x030C, 0x02FA, 0x02FA, 0x02E8, 0x02E8, 0x02D8, 0x02D8, 0x02C8, 0x02B9, 0x02B9, 0x02AA, 0x02AA, 0x029C, 
-       0x028F, 0x028F, 0x0282, 0x0276, 0x0276, 0x026A, 0x025E, 0x025E, 0x0253, 0x0249, 0x0249, 0x023E, 0x0234, 0x022B, 0x022B, 0x0222, 
-       0x0219, 0x0210, 0x0208, 0x0208, 0x0200, 0x01F8, 0x01F0, 0x01E9, 0x01E9, 0x01E1, 0x01DA, 0x01D4, 0x01CD, 0x01C7, 0x01C7, 0x01C0, 
-       0x01BA, 0x01B4, 0x01AF, 0x01A9, 0x01A4, 0x019E, 0x019E, 0x0199, 0x0194, 0x018F, 0x018A, 0x0186, 0x0181, 0x017D, 0x017D, 0x0178, 
-       0x0174, 0x0170, 0x016C, 0x0168, 0x0164, 0x0160, 0x015C, 0x0158, 0x0155, 0x0155, 0x0151, 0x014E, 0x014A, 0x0147, 0x0144, 0x0141, 
-       0x013E, 0x013B, 0x0138, 0x0135, 0x0132, 0x012F, 0x012C, 0x012C, 0x0129, 0x0127, 0x0124, 0x0121, 0x011F, 0x011C, 0x011A, 0x0118, 
-       0x0115, 0x0113, 0x0111, 0x010E, 0x010C, 0x010A, 0x0108, 0x0106, 0x0104, 0x0104, 0x0102, 0x0100, 0x00FE, 0x00FC, 0x00FA, 0x00F8, 
-       0x0348, 0x0348, 0x0348, 0x0348, 0x0348, 0x0348, 0x0348, 0x0333, 0x0333, 0x0333, 0x0333, 0x0333, 0x031F, 0x031F, 0x031F, 0x030C, 
-       0x030C, 0x030C, 0x02FA, 0x02FA, 0x02E8, 0x02E8, 0x02D8, 0x02D8, 0x02C8, 0x02C8, 0x02B9, 0x02B9, 0x02AA, 0x02AA, 0x029C, 0x028F, 
-       0x028F, 0x0282, 0x0276, 0x0276, 0x026A, 0x025E, 0x025E, 0x0253, 0x0249, 0x0249, 0x023E, 0x0234, 0x022B, 0x022B, 0x0222, 0x0219, 
-       0x0210, 0x0210, 0x0208, 0x0200, 0x01F8, 0x01F0, 0x01F0, 0x01E9, 0x01E1, 0x01DA, 0x01D4, 0x01D4, 0x01CD, 0x01C7, 0x01C0, 0x01BA, 
-       0x01B4, 0x01AF, 0x01AF, 0x01A9, 0x01A4, 0x019E, 0x0199, 0x0194, 0x018F, 0x018F, 0x018A, 0x0186, 0x0181, 0x017D, 0x0178, 0x0174, 
-       0x0170, 0x016C, 0x016C, 0x0168, 0x0164, 0x0160, 0x015C, 0x0158, 0x0155, 0x0151, 0x014E, 0x014A, 0x0147, 0x0144, 0x0144, 0x0141, 
-       0x013E, 0x013B, 0x0138, 0x0135, 0x0132, 0x012F, 0x012C, 0x0129, 0x0127, 0x0124, 0x0121, 0x011F, 0x011F, 0x011C, 0x011A, 0x0118, 
-       0x0115, 0x0113, 0x0111, 0x010E, 0x010C, 0x010A, 0x0108, 0x0106, 0x0104, 0x0102, 0x0100, 0x00FE, 0x00FC, 0x00FA, 0x00F8, 0x00F8, 
-       0x0333, 0x0333, 0x0333, 0x0333, 0x0333, 0x0333, 0x0333, 0x0333, 0x031F, 0x031F, 0x031F, 0x031F, 0x030C, 0x030C, 0x030C, 0x02FA, 
-       0x02FA, 0x02FA, 0x02E8, 0x02E8, 0x02D8, 0x02D8, 0x02D8, 0x02C8, 0x02C8, 0x02B9, 0x02B9, 0x02AA, 0x029C, 0x029C, 0x028F, 0x028F, 
-       0x0282, 0x0276, 0x0276, 0x026A, 0x025E, 0x025E, 0x0253, 0x0249, 0x0249, 0x023E, 0x0234, 0x0234, 0x022B, 0x0222, 0x0219, 0x0219, 
-       0x0210, 0x0208, 0x0200, 0x01F8, 0x01F8, 0x01F0, 0x01E9, 0x01E1, 0x01DA, 0x01DA, 0x01D4, 0x01CD, 0x01C7, 0x01C0, 0x01C0, 0x01BA, 
-       0x01B4, 0x01AF, 0x01A9, 0x01A4, 0x019E, 0x019E, 0x0199, 0x0194, 0x018F, 0x018A, 0x0186, 0x0181, 0x017D, 0x017D, 0x0178, 0x0174, 
-       0x0170, 0x016C, 0x0168, 0x0164, 0x0160, 0x015C, 0x015C, 0x0158, 0x0155, 0x0151, 0x014E, 0x014A, 0x0147, 0x0144, 0x0141, 0x013E, 
-       0x013B, 0x0138, 0x0138, 0x0135, 0x0132, 0x012F, 0x012C, 0x0129, 0x0127, 0x0124, 0x0121, 0x011F, 0x011C, 0x011A, 0x0118, 0x0115, 
-       0x0113, 0x0113, 0x0111, 0x010E, 0x010C, 0x010A, 0x0108, 0x0106, 0x0104, 0x0102, 0x0100, 0x00FE, 0x00FC, 0x00FA, 0x00F8, 0x00F6, 
-       0x031F, 0x031F, 0x031F, 0x031F, 0x031F, 0x031F, 0x031F, 0x031F, 0x030C, 0x030C, 0x030C, 0x030C, 0x030C, 0x02FA, 0x02FA, 0x02FA, 
-       0x02E8, 0x02E8, 0x02E8, 0x02D8, 0x02D8, 0x02C8, 0x02C8, 0x02B9, 0x02B9, 0x02AA, 0x02AA, 0x029C, 0x029C, 0x028F, 0x028F, 0x0282, 
-       0x0276, 0x0276, 0x026A, 0x025E, 0x025E, 0x0253, 0x0249, 0x0249, 0x023E, 0x0234, 0x0234, 0x022B, 0x0222, 0x0219, 0x0219, 0x0210, 
-       0x0208, 0x0200, 0x0200, 0x01F8, 0x01F0, 0x01E9, 0x01E9, 0x01E1, 0x01DA, 0x01D4, 0x01CD, 0x01CD, 0x01C7, 0x01C0, 0x01BA, 0x01B4, 
-       0x01AF, 0x01AF, 0x01A9, 0x01A4, 0x019E, 0x0199, 0x0194, 0x018F, 0x018F, 0x018A, 0x0186, 0x0181, 0x017D, 0x0178, 0x0174, 0x0170, 
-       0x016C, 0x016C, 0x0168, 0x0164, 0x0160, 0x015C, 0x0158, 0x0155, 0x0151, 0x014E, 0x014E, 0x014A, 0x0147, 0x0144, 0x0141, 0x013E, 
-       0x013B, 0x0138, 0x0135, 0x0132, 0x012F, 0x012C, 0x0129, 0x0129, 0x0127, 0x0124, 0x0121, 0x011F, 0x011C, 0x011A, 0x0118, 0x0115, 
-       0x0113, 0x0111, 0x010E, 0x010C, 0x010A, 0x0108, 0x0108, 0x0106, 0x0104, 0x0102, 0x0100, 0x00FE, 0x00FC, 0x00FA, 0x00F8, 0x00F6, 
-       0x030C, 0x030C, 0x030C, 0x030C, 0x030C, 0x030C, 0x030C, 0x030C, 0x030C, 0x02FA, 0x02FA, 0x02FA, 0x02FA, 0x02E8, 0x02E8, 0x02E8, 
-       0x02D8, 0x02D8, 0x02D8, 0x02C8, 0x02C8, 0x02B9, 0x02B9, 0x02AA, 0x02AA, 0x029C, 0x029C, 0x028F, 0x028F, 0x0282, 0x0282, 0x0276, 
-       0x0276, 0x026A, 0x025E, 0x025E, 0x0253, 0x0249, 0x0249, 0x023E, 0x0234, 0x0234, 0x022B, 0x0222, 0x0222, 0x0219, 0x0210, 0x0208, 
-       0x0208, 0x0200, 0x01F8, 0x01F0, 0x01F0, 0x01E9, 0x01E1, 0x01DA, 0x01D4, 0x01D4, 0x01CD, 0x01C7, 0x01C0, 0x01BA, 0x01BA, 0x01B4, 
-       0x01AF, 0x01A9, 0x01A4, 0x019E, 0x0199, 0x0199, 0x0194, 0x018F, 0x018A, 0x0186, 0x0181, 0x017D, 0x017D, 0x0178, 0x0174, 0x0170, 
-       0x016C, 0x0168, 0x0164, 0x0160, 0x0160, 0x015C, 0x0158, 0x0155, 0x0151, 0x014E, 0x014A, 0x0147, 0x0144, 0x0141, 0x013E, 0x013E, 
-       0x013B, 0x0138, 0x0135, 0x0132, 0x012F, 0x012C, 0x0129, 0x0127, 0x0124, 0x0121, 0x011F, 0x011C, 0x011C, 0x011A, 0x0118, 0x0115, 
-       0x0113, 0x0111, 0x010E, 0x010C, 0x010A, 0x0108, 0x0106, 0x0104, 0x0102, 0x0100, 0x00FE, 0x00FC, 0x00FC, 0x00FA, 0x00F8, 0x00F6, 
-       0x02FA, 0x02FA, 0x02FA, 0x02FA, 0x02FA, 0x02FA, 0x02FA, 0x02FA, 0x02FA, 0x02E8, 0x02E8, 0x02E8, 0x02E8, 0x02D8, 0x02D8, 0x02D8, 
-       0x02D8, 0x02C8, 0x02C8, 0x02B9, 0x02B9, 0x02B9, 0x02AA, 0x02AA, 0x029C, 0x029C, 0x028F, 0x028F, 0x0282, 0x0282, 0x0276, 0x026A, 
-       0x026A, 0x025E, 0x025E, 0x0253, 0x0249, 0x0249, 0x023E, 0x0234, 0x0234, 0x022B, 0x0222, 0x0222, 0x0219, 0x0210, 0x0208, 0x0208, 
-       0x0200, 0x01F8, 0x01F0, 0x01F0, 0x01E9, 0x01E1, 0x01DA, 0x01DA, 0x01D4, 0x01CD, 0x01C7, 0x01C0, 0x01C0, 0x01BA, 0x01B4, 0x01AF, 
-       0x01A9, 0x01A9, 0x01A4, 0x019E, 0x0199, 0x0194, 0x018F, 0x018A, 0x018A, 0x0186, 0x0181, 0x017D, 0x0178, 0x0174, 0x0170, 0x0170, 
-       0x016C, 0x0168, 0x0164, 0x0160, 0x015C, 0x0158, 0x0155, 0x0151, 0x0151, 0x014E, 0x014A, 0x0147, 0x0144, 0x0141, 0x013E, 0x013B, 
-       0x0138, 0x0135, 0x0132, 0x0132, 0x012F, 0x012C, 0x0129, 0x0127, 0x0124, 0x0121, 0x011F, 0x011C, 0x011A, 0x0118, 0x0115, 0x0113, 
-       0x0111, 0x0111, 0x010E, 0x010C, 0x010A, 0x0108, 0x0106, 0x0104, 0x0102, 0x0100, 0x00FE, 0x00FC, 0x00FA, 0x00F8, 0x00F6, 0x00F4, 
-       0x02E8, 0x02E8, 0x02E8, 0x02E8, 0x02E8, 0x02E8, 0x02E8, 0x02E8, 0x02E8, 0x02E8, 0x02D8, 0x02D8, 0x02D8, 0x02D8, 0x02C8, 0x02C8, 
-       0x02C8, 0x02B9, 0x02B9, 0x02B9, 0x02AA, 0x02AA, 0x029C, 0x029C, 0x028F, 0x028F, 0x0282, 0x0282, 0x0276, 0x0276, 0x026A, 0x026A, 
-       0x025E, 0x0253, 0x0253, 0x0249, 0x0249, 0x023E, 0x0234, 0x0234, 0x022B, 0x0222, 0x0222, 0x0219, 0x0210, 0x0210, 0x0208, 0x0200, 
-       0x01F8, 0x01F8, 0x01F0, 0x01E9, 0x01E1, 0x01E1, 0x01DA, 0x01D4, 0x01CD, 0x01C7, 0x01C7, 0x01C0, 0x01BA, 0x01B4, 0x01AF, 0x01AF, 
-       0x01A9, 0x01A4, 0x019E, 0x0199, 0x0194, 0x0194, 0x018F, 0x018A, 0x0186, 0x0181, 0x017D, 0x017D, 0x0178, 0x0174, 0x0170, 0x016C, 
-       0x0168, 0x0164, 0x0160, 0x0160, 0x015C, 0x0158, 0x0155, 0x0151, 0x014E, 0x014A, 0x0147, 0x0144, 0x0144, 0x0141, 0x013E, 0x013B, 
-       0x0138, 0x0135, 0x0132, 0x012F, 0x012C, 0x0129, 0x0127, 0x0124, 0x0124, 0x0121, 0x011F, 0x011C, 0x011A, 0x0118, 0x0115, 0x0113, 
-       0x0111, 0x010E, 0x010C, 0x010A, 0x0108, 0x0106, 0x0106, 0x0104, 0x0102, 0x0100, 0x00FE, 0x00FC, 0x00FA, 0x00F8, 0x00F6, 0x00F4, 
-       0x02E8, 0x02E8, 0x02E8, 0x02D8, 0x02D8, 0x02D8, 0x02D8, 0x02D8, 0x02D8, 0x02D8, 0x02C8, 0x02C8, 0x02C8, 0x02C8, 0x02B9, 0x02B9, 
-       0x02B9, 0x02AA, 0x02AA, 0x02AA, 0x029C, 0x029C, 0x028F, 0x028F, 0x028F, 0x0282, 0x0282, 0x0276, 0x0276, 0x026A, 0x025E, 0x025E, 
-       0x0253, 0x0253, 0x0249, 0x0249, 0x023E, 0x0234, 0x0234, 0x022B, 0x0222, 0x0222, 0x0219, 0x0210, 0x0210, 0x0208, 0x0200, 0x01F8, 
-       0x01F8, 0x01F0, 0x01E9, 0x01E9, 0x01E1, 0x01DA, 0x01D4, 0x01CD, 0x01CD, 0x01C7, 0x01C0, 0x01BA, 0x01BA, 0x01B4, 0x01AF, 0x01A9, 
-       0x01A4, 0x019E, 0x019E, 0x0199, 0x0194, 0x018F, 0x018A, 0x0186, 0x0186, 0x0181, 0x017D, 0x0178, 0x0174, 0x0170, 0x016C, 0x016C, 
-       0x0168, 0x0164, 0x0160, 0x015C, 0x0158, 0x0155, 0x0151, 0x0151, 0x014E, 0x014A, 0x0147, 0x0144, 0x0141, 0x013E, 0x013B, 0x0138, 
-       0x0135, 0x0135, 0x0132, 0x012F, 0x012C, 0x0129, 0x0127, 0x0124, 0x0121, 0x011F, 0x011C, 0x011A, 0x011A, 0x0118, 0x0115, 0x0113, 
-       0x0111, 0x010E, 0x010C, 0x010A, 0x0108, 0x0106, 0x0104, 0x0102, 0x0100, 0x00FE, 0x00FC, 0x00FC, 0x00FA, 0x00F8, 0x00F6, 0x00F4, 
-       0x02D8, 0x02D8, 0x02D8, 0x02D8, 0x02C8, 0x02C8, 0x02C8, 0x02C8, 0x02C8, 0x02C8, 0x02C8, 0x02B9, 0x02B9, 0x02B9, 0x02B9, 0x02AA, 
-       0x02AA, 0x02AA, 0x029C, 0x029C, 0x028F, 0x028F, 0x028F, 0x0282, 0x0282, 0x0276, 0x0276, 0x026A, 0x026A, 0x025E, 0x025E, 0x0253, 
-       0x0253, 0x0249, 0x023E, 0x023E, 0x0234, 0x0234, 0x022B, 0x0222, 0x0222, 0x0219, 0x0210, 0x0210, 0x0208, 0x0200, 0x0200, 0x01F8, 
-       0x01F0, 0x01E9, 0x01E9, 0x01E1, 0x01DA, 0x01D4, 0x01D4, 0x01CD, 0x01C7, 0x01C0, 0x01C0, 0x01BA, 0x01B4, 0x01AF, 0x01A9, 0x01A9, 
-       0x01A4, 0x019E, 0x0199, 0x0194, 0x018F, 0x018F, 0x018A, 0x0186, 0x0181, 0x017D, 0x0178, 0x0178, 0x0174, 0x0170, 0x016C, 0x0168, 
-       0x0164, 0x0160, 0x0160, 0x015C, 0x0158, 0x0155, 0x0151, 0x014E, 0x014A, 0x0147, 0x0144, 0x0144, 0x0141, 0x013E, 0x013B, 0x0138, 
-       0x0135, 0x0132, 0x012F, 0x012C, 0x0129, 0x0129, 0x0127, 0x0124, 0x0121, 0x011F, 0x011C, 0x011A, 0x0118, 0x0115, 0x0113, 0x0111, 
-       0x010E, 0x010E, 0x010C, 0x010A, 0x0108, 0x0106, 0x0104, 0x0102, 0x0100, 0x00FE, 0x00FC, 0x00FA, 0x00F8, 0x00F6, 0x00F4, 0x00F2, 
-       0x02C8, 0x02C8, 0x02C8, 0x02C8, 0x02C8, 0x02B9, 0x02B9, 0x02B9, 0x02B9, 0x02B9, 0x02B9, 0x02AA, 0x02AA, 0x02AA, 0x02AA, 0x029C, 
-       0x029C, 0x029C, 0x028F, 0x028F, 0x028F, 0x0282, 0x0282, 0x0276, 0x0276, 0x026A, 0x026A, 0x025E, 0x025E, 0x0253, 0x0253, 0x0249, 
-       0x0249, 0x023E, 0x023E, 0x0234, 0x022B, 0x022B, 0x0222, 0x0222, 0x0219, 0x0210, 0x0210, 0x0208, 0x0200, 0x0200, 0x01F8, 0x01F0, 
-       0x01E9, 0x01E9, 0x01E1, 0x01DA, 0x01DA, 0x01D4, 0x01CD, 0x01C7, 0x01C7, 0x01C0, 0x01BA, 0x01B4, 0x01AF, 0x01AF, 0x01A9, 0x01A4, 
-       0x019E, 0x0199, 0x0199, 0x0194, 0x018F, 0x018A, 0x0186, 0x0181, 0x0181, 0x017D, 0x0178, 0x0174, 0x0170, 0x016C, 0x016C, 0x0168, 
-       0x0164, 0x0160, 0x015C, 0x0158, 0x0155, 0x0151, 0x0151, 0x014E, 0x014A, 0x0147, 0x0144, 0x0141, 0x013E, 0x013B, 0x0138, 0x0138, 
-       0x0135, 0x0132, 0x012F, 0x012C, 0x0129, 0x0127, 0x0124, 0x0121, 0x011F, 0x011F, 0x011C, 0x011A, 0x0118, 0x0115, 0x0113, 0x0111, 
-       0x010E, 0x010C, 0x010A, 0x0108, 0x0106, 0x0104, 0x0104, 0x0102, 0x0100, 0x00FE, 0x00FC, 0x00FA, 0x00F8, 0x00F6, 0x00F4, 0x00F2, 
-       0x02B9, 0x02B9, 0x02B9, 0x02B9, 0x02B9, 0x02AA, 0x02AA, 0x02AA, 0x02AA, 0x02AA, 0x02AA, 0x029C, 0x029C, 0x029C, 0x029C, 0x028F, 
-       0x028F, 0x028F, 0x0282, 0x0282, 0x0282, 0x0276, 0x0276, 0x026A, 0x026A, 0x026A, 0x025E, 0x025E, 0x0253, 0x0253, 0x0249, 0x0249, 
-       0x023E, 0x0234, 0x0234, 0x022B, 0x022B, 0x0222, 0x0219, 0x0219, 0x0210, 0x0210, 0x0208, 0x0200, 0x0200, 0x01F8, 0x01F0, 0x01E9, 
-       0x01E9, 0x01E1, 0x01DA, 0x01DA, 0x01D4, 0x01CD, 0x01C7, 0x01C7, 0x01C0, 0x01BA, 0x01B4, 0x01B4, 0x01AF, 0x01A9, 0x01A4, 0x019E, 
-       0x019E, 0x0199, 0x0194, 0x018F, 0x018A, 0x018A, 0x0186, 0x0181, 0x017D, 0x0178, 0x0174, 0x0174, 0x0170, 0x016C, 0x0168, 0x0164, 
-       0x0160, 0x015C, 0x015C, 0x0158, 0x0155, 0x0151, 0x014E, 0x014A, 0x0147, 0x0144, 0x0144, 0x0141, 0x013E, 0x013B, 0x0138, 0x0135, 
-       0x0132, 0x012F, 0x012C, 0x012C, 0x0129, 0x0127, 0x0124, 0x0121, 0x011F, 0x011C, 0x011A, 0x0118, 0x0115, 0x0113, 0x0113, 0x0111, 
-       0x010E, 0x010C, 0x010A, 0x0108, 0x0106, 0x0104, 0x0102, 0x0100, 0x00FE, 0x00FC, 0x00FA, 0x00FA, 0x00F8, 0x00F6, 0x00F4, 0x00F2, 
-       0x02AA, 0x02AA, 0x02AA, 0x02AA, 0x02AA, 0x02AA, 0x029C, 0x029C, 0x029C, 0x029C, 0x029C, 0x029C, 0x028F, 0x028F, 0x028F, 0x028F, 
-       0x0282, 0x0282, 0x0282, 0x0276, 0x0276, 0x026A, 0x026A, 0x026A, 0x025E, 0x025E, 0x0253, 0x0253, 0x0249, 0x0249, 0x023E, 0x023E, 
-       0x0234, 0x0234, 0x022B, 0x022B, 0x0222, 0x0219, 0x0219, 0x0210, 0x0208, 0x0208, 0x0200, 0x0200, 0x01F8, 0x01F0, 0x01F0, 0x01E9, 
-       0x01E1, 0x01DA, 0x01DA, 0x01D4, 0x01CD, 0x01CD, 0x01C7, 0x01C0, 0x01BA, 0x01BA, 0x01B4, 0x01AF, 0x01A9, 0x01A4, 0x01A4, 0x019E, 
-       0x0199, 0x0194, 0x018F, 0x018F, 0x018A, 0x0186, 0x0181, 0x017D, 0x017D, 0x0178, 0x0174, 0x0170, 0x016C, 0x0168, 0x0168, 0x0164, 
-       0x0160, 0x015C, 0x0158, 0x0155, 0x0151, 0x0151, 0x014E, 0x014A, 0x0147, 0x0144, 0x0141, 0x013E, 0x013B, 0x013B, 0x0138, 0x0135, 
-       0x0132, 0x012F, 0x012C, 0x0129, 0x0127, 0x0124, 0x0121, 0x0121, 0x011F, 0x011C, 0x011A, 0x0118, 0x0115, 0x0113, 0x0111, 0x010E, 
-       0x010C, 0x010A, 0x010A, 0x0108, 0x0106, 0x0104, 0x0102, 0x0100, 0x00FE, 0x00FC, 0x00FA, 0x00F8, 0x00F6, 0x00F4, 0x00F2, 0x00F0, 
-       0x029C, 0x029C, 0x029C, 0x029C, 0x029C, 0x029C, 0x028F, 0x028F, 0x028F, 0x028F, 0x028F, 0x028F, 0x0282, 0x0282, 0x0282, 0x0282, 
-       0x0276, 0x0276, 0x0276, 0x026A, 0x026A, 0x026A, 0x025E, 0x025E, 0x0253, 0x0253, 0x0249, 0x0249, 0x023E, 0x023E, 0x0234, 0x0234, 
-       0x022B, 0x022B, 0x0222, 0x0222, 0x0219, 0x0219, 0x0210, 0x0208, 0x0208, 0x0200, 0x01F8, 0x01F8, 0x01F0, 0x01E9, 0x01E9, 0x01E1, 
-       0x01DA, 0x01DA, 0x01D4, 0x01CD, 0x01CD, 0x01C7, 0x01C0, 0x01BA, 0x01BA, 0x01B4, 0x01AF, 0x01A9, 0x01A9, 0x01A4, 0x019E, 0x0199, 
-       0x0194, 0x0194, 0x018F, 0x018A, 0x0186, 0x0181, 0x0181, 0x017D, 0x0178, 0x0174, 0x0170, 0x0170, 0x016C, 0x0168, 0x0164, 0x0160, 
-       0x015C, 0x0158, 0x0158, 0x0155, 0x0151, 0x014E, 0x014A, 0x0147, 0x0144, 0x0144, 0x0141, 0x013E, 0x013B, 0x0138, 0x0135, 0x0132, 
-       0x012F, 0x012F, 0x012C, 0x0129, 0x0127, 0x0124, 0x0121, 0x011F, 0x011C, 0x011A, 0x0118, 0x0118, 0x0115, 0x0113, 0x0111, 0x010E, 
-       0x010C, 0x010A, 0x0108, 0x0106, 0x0104, 0x0102, 0x0100, 0x0100, 0x00FE, 0x00FC, 0x00FA, 0x00F8, 0x00F6, 0x00F4, 0x00F2, 0x00F0, 
-       0x028F, 0x028F, 0x028F, 0x028F, 0x028F, 0x028F, 0x028F, 0x0282, 0x0282, 0x0282, 0x0282, 0x0282, 0x0276, 0x0276, 0x0276, 0x0276, 
-       0x026A, 0x026A, 0x026A, 0x025E, 0x025E, 0x025E, 0x0253, 0x0253, 0x0249, 0x0249, 0x0249, 0x023E, 0x023E, 0x0234, 0x0234, 0x022B, 
-       0x022B, 0x0222, 0x0222, 0x0219, 0x0210, 0x0210, 0x0208, 0x0208, 0x0200, 0x01F8, 0x01F8, 0x01F0, 0x01E9, 0x01E9, 0x01E1, 0x01DA, 
-       0x01DA, 0x01D4, 0x01CD, 0x01CD, 0x01C7, 0x01C0, 0x01BA, 0x01BA, 0x01B4, 0x01AF, 0x01AF, 0x01A9, 0x01A4, 0x019E, 0x0199, 0x0199, 
-       0x0194, 0x018F, 0x018A, 0x018A, 0x0186, 0x0181, 0x017D, 0x0178, 0x0174, 0x0174, 0x0170, 0x016C, 0x0168, 0x0164, 0x0164, 0x0160, 
-       0x015C, 0x0158, 0x0155, 0x0151, 0x014E, 0x014E, 0x014A, 0x0147, 0x0144, 0x0141, 0x013E, 0x013B, 0x013B, 0x0138, 0x0135, 0x0132, 
-       0x012F, 0x012C, 0x0129, 0x0127, 0x0124, 0x0124, 0x0121, 0x011F, 0x011C, 0x011A, 0x0118, 0x0115, 0x0113, 0x0111, 0x010E, 0x010E, 
-       0x010C, 0x010A, 0x0108, 0x0106, 0x0104, 0x0102, 0x0100, 0x00FE, 0x00FC, 0x00FA, 0x00F8, 0x00F6, 0x00F6, 0x00F4, 0x00F2, 0x00F0, 
-       0x0282, 0x0282, 0x0282, 0x0282, 0x0282, 0x0282, 0x0282, 0x0276, 0x0276, 0x0276, 0x0276, 0x0276, 0x0276, 0x026A, 0x026A, 0x026A, 
-       0x026A, 0x025E, 0x025E, 0x025E, 0x0253, 0x0253, 0x0249, 0x0249, 0x0249, 0x023E, 0x023E, 0x0234, 0x0234, 0x022B, 0x022B, 0x0222, 
-       0x0222, 0x0219, 0x0219, 0x0210, 0x0210, 0x0208, 0x0200, 0x0200, 0x01F8, 0x01F8, 0x01F0, 0x01E9, 0x01E9, 0x01E1, 0x01DA, 0x01DA, 
-       0x01D4, 0x01CD, 0x01CD, 0x01C7, 0x01C0, 0x01C0, 0x01BA, 0x01B4, 0x01AF, 0x01AF, 0x01A9, 0x01A4, 0x019E, 0x019E, 0x0199, 0x0194, 
-       0x018F, 0x018F, 0x018A, 0x0186, 0x0181, 0x017D, 0x017D, 0x0178, 0x0174, 0x0170, 0x016C, 0x0168, 0x0168, 0x0164, 0x0160, 0x015C, 
-       0x0158, 0x0155, 0x0155, 0x0151, 0x014E, 0x014A, 0x0147, 0x0144, 0x0144, 0x0141, 0x013E, 0x013B, 0x0138, 0x0135, 0x0132, 0x012F, 
-       0x012F, 0x012C, 0x0129, 0x0127, 0x0124, 0x0121, 0x011F, 0x011C, 0x011A, 0x011A, 0x0118, 0x0115, 0x0113, 0x0111, 0x010E, 0x010C, 
-       0x010A, 0x0108, 0x0106, 0x0104, 0x0104, 0x0102, 0x0100, 0x00FE, 0x00FC, 0x00FA, 0x00F8, 0x00F6, 0x00F4, 0x00F2, 0x00F0, 0x00EF, 
-       0x0276, 0x0276, 0x0276, 0x0276, 0x0276, 0x0276, 0x0276, 0x0276, 0x026A, 0x026A, 0x026A, 0x026A, 0x026A, 0x025E, 0x025E, 0x025E, 
-       0x025E, 0x0253, 0x0253, 0x0253, 0x0249, 0x0249, 0x0249, 0x023E, 0x023E, 0x0234, 0x0234, 0x022B, 0x022B, 0x022B, 0x0222, 0x0222, 
-       0x0219, 0x0210, 0x0210, 0x0208, 0x0208, 0x0200, 0x0200, 0x01F8, 0x01F0, 0x01F0, 0x01E9, 0x01E9, 0x01E1, 0x01DA, 0x01DA, 0x01D4, 
-       0x01CD, 0x01CD, 0x01C7, 0x01C0, 0x01C0, 0x01BA, 0x01B4, 0x01AF, 0x01AF, 0x01A9, 0x01A4, 0x01A4, 0x019E, 0x0199, 0x0194, 0x018F, 
-       0x018F, 0x018A, 0x0186, 0x0181, 0x0181, 0x017D, 0x0178, 0x0174, 0x0170, 0x0170, 0x016C, 0x0168, 0x0164, 0x0160, 0x015C, 0x015C, 
-       0x0158, 0x0155, 0x0151, 0x014E, 0x014A, 0x014A, 0x0147, 0x0144, 0x0141, 0x013E, 0x013B, 0x0138, 0x0138, 0x0135, 0x0132, 0x012F, 
-       0x012C, 0x0129, 0x0127, 0x0124, 0x0124, 0x0121, 0x011F, 0x011C, 0x011A, 0x0118, 0x0115, 0x0113, 0x0111, 0x0111, 0x010E, 0x010C, 
-       0x010A, 0x0108, 0x0106, 0x0104, 0x0102, 0x0100, 0x00FE, 0x00FC, 0x00FC, 0x00FA, 0x00F8, 0x00F6, 0x00F4, 0x00F2, 0x00F0, 0x00EF, 
-       0x026A, 0x026A, 0x026A, 0x026A, 0x026A, 0x026A, 0x026A, 0x026A, 0x025E, 0x025E, 0x025E, 0x025E, 0x025E, 0x0253, 0x0253, 0x0253, 
-       0x0253, 0x0249, 0x0249, 0x0249, 0x023E, 0x023E, 0x023E, 0x0234, 0x0234, 0x022B, 0x022B, 0x022B, 0x0222, 0x0222, 0x0219, 0x0219, 
-       0x0210, 0x0210, 0x0208, 0x0208, 0x0200, 0x01F8, 0x01F8, 0x01F0, 0x01F0, 0x01E9, 0x01E9, 0x01E1, 0x01DA, 0x01DA, 0x01D4, 0x01CD, 
-       0x01CD, 0x01C7, 0x01C0, 0x01C0, 0x01BA, 0x01B4, 0x01B4, 0x01AF, 0x01A9, 0x01A4, 0x01A4, 0x019E, 0x0199, 0x0194, 0x0194, 0x018F, 
-       0x018A, 0x0186, 0x0186, 0x0181, 0x017D, 0x0178, 0x0174, 0x0174, 0x0170, 0x016C, 0x0168, 0x0164, 0x0164, 0x0160, 0x015C, 0x0158, 
-       0x0155, 0x0151, 0x0151, 0x014E, 0x014A, 0x0147, 0x0144, 0x0141, 0x0141, 0x013E, 0x013B, 0x0138, 0x0135, 0x0132, 0x012F, 0x012C, 
-       0x012C, 0x0129, 0x0127, 0x0124, 0x0121, 0x011F, 0x011C, 0x011A, 0x011A, 0x0118, 0x0115, 0x0113, 0x0111, 0x010E, 0x010C, 0x010A, 
-       0x0108, 0x0106, 0x0106, 0x0104, 0x0102, 0x0100, 0x00FE, 0x00FC, 0x00FA, 0x00F8, 0x00F6, 0x00F4, 0x00F2, 0x00F2, 0x00F0, 0x00EF, 
-       0x025E, 0x025E, 0x025E, 0x025E, 0x025E, 0x025E, 0x025E, 0x025E, 0x025E, 0x0253, 0x0253, 0x0253, 0x0253, 0x0253, 0x0249, 0x0249, 
-       0x0249, 0x023E, 0x023E, 0x023E, 0x023E, 0x0234, 0x0234, 0x022B, 0x022B, 0x022B, 0x0222, 0x0222, 0x0219, 0x0219, 0x0210, 0x0210, 
-       0x0208, 0x0208, 0x0200, 0x0200, 0x01F8, 0x01F8, 0x01F0, 0x01F0, 0x01E9, 0x01E1, 0x01E1, 0x01DA, 0x01DA, 0x01D4, 0x01CD, 0x01CD, 
-       0x01C7, 0x01C0, 0x01C0, 0x01BA, 0x01B4, 0x01B4, 0x01AF, 0x01A9, 0x01A4, 0x01A4, 0x019E, 0x0199, 0x0199, 0x0194, 0x018F, 0x018A, 
-       0x0186, 0x0186, 0x0181, 0x017D, 0x0178, 0x0178, 0x0174, 0x0170, 0x016C, 0x0168, 0x0168, 0x0164, 0x0160, 0x015C, 0x0158, 0x0158, 
-       0x0155, 0x0151, 0x014E, 0x014A, 0x0147, 0x0147, 0x0144, 0x0141, 0x013E, 0x013B, 0x0138, 0x0135, 0x0135, 0x0132, 0x012F, 0x012C, 
-       0x0129, 0x0127, 0x0124, 0x0124, 0x0121, 0x011F, 0x011C, 0x011A, 0x0118, 0x0115, 0x0113, 0x0111, 0x0111, 0x010E, 0x010C, 0x010A, 
-       0x0108, 0x0106, 0x0104, 0x0102, 0x0100, 0x00FE, 0x00FE, 0x00FC, 0x00FA, 0x00F8, 0x00F6, 0x00F4, 0x00F2, 0x00F0, 0x00EF, 0x00ED, 
-       0x0253, 0x0253, 0x0253, 0x0253, 0x0253, 0x0253, 0x0253, 0x0253, 0x0253, 0x0249, 0x0249, 0x0249, 0x0249, 0x0249, 0x023E, 0x023E, 
-       0x023E, 0x023E, 0x0234, 0x0234, 0x0234, 0x022B, 0x022B, 0x022B, 0x0222, 0x0222, 0x0219, 0x0219, 0x0210, 0x0210, 0x0210, 0x0208, 
-       0x0208, 0x0200, 0x0200, 0x01F8, 0x01F0, 0x01F0, 0x01E9, 0x01E9, 0x01E1, 0x01E1, 0x01DA, 0x01D4, 0x01D4, 0x01CD, 0x01CD, 0x01C7, 
-       0x01C0, 0x01C0, 0x01BA, 0x01B4, 0x01B4, 0x01AF, 0x01A9, 0x01A4, 0x01A4, 0x019E, 0x0199, 0x0199, 0x0194, 0x018F, 0x018A, 0x018A, 
-       0x0186, 0x0181, 0x017D, 0x017D, 0x0178, 0x0174, 0x0170, 0x016C, 0x016C, 0x0168, 0x0164, 0x0160, 0x015C, 0x015C, 0x0158, 0x0155, 
-       0x0151, 0x014E, 0x014E, 0x014A, 0x0147, 0x0144, 0x0141, 0x013E, 0x013E, 0x013B, 0x0138, 0x0135, 0x0132, 0x012F, 0x012C, 0x012C, 
-       0x0129, 0x0127, 0x0124, 0x0121, 0x011F, 0x011C, 0x011A, 0x011A, 0x0118, 0x0115, 0x0113, 0x0111, 0x010E, 0x010C, 0x010A, 0x0108, 
-       0x0108, 0x0106, 0x0104, 0x0102, 0x0100, 0x00FE, 0x00FC, 0x00FA, 0x00F8, 0x00F6, 0x00F6, 0x00F4, 0x00F2, 0x00F0, 0x00EF, 0x00ED, 
-       0x0249, 0x0249, 0x0249, 0x0249, 0x0249, 0x0249, 0x0249, 0x0249, 0x0249, 0x023E, 0x023E, 0x023E, 0x023E, 0x023E, 0x0234, 0x0234, 
-       0x0234, 0x0234, 0x022B, 0x022B, 0x022B, 0x0222, 0x0222, 0x0222, 0x0219, 0x0219, 0x0210, 0x0210, 0x0210, 0x0208, 0x0208, 0x0200, 
-       0x0200, 0x01F8, 0x01F8, 0x01F0, 0x01F0, 0x01E9, 0x01E9, 0x01E1, 0x01DA, 0x01DA, 0x01D4, 0x01D4, 0x01CD, 0x01C7, 0x01C7, 0x01C0, 
-       0x01BA, 0x01BA, 0x01B4, 0x01B4, 0x01AF, 0x01A9, 0x01A4, 0x01A4, 0x019E, 0x0199, 0x0199, 0x0194, 0x018F, 0x018A, 0x018A, 0x0186, 
-       0x0181, 0x017D, 0x017D, 0x0178, 0x0174, 0x0170, 0x0170, 0x016C, 0x0168, 0x0164, 0x0164, 0x0160, 0x015C, 0x0158, 0x0155, 0x0151, 
-       0x0151, 0x014E, 0x014A, 0x0147, 0x0144, 0x0144, 0x0141, 0x013E, 0x013B, 0x0138, 0x0135, 0x0132, 0x0132, 0x012F, 0x012C, 0x0129, 
-       0x0127, 0x0124, 0x0121, 0x0121, 0x011F, 0x011C, 0x011A, 0x0118, 0x0115, 0x0113, 0x0111, 0x0111, 0x010E, 0x010C, 0x010A, 0x0108, 
-       0x0106, 0x0104, 0x0102, 0x0100, 0x0100, 0x00FE, 0x00FC, 0x00FA, 0x00F8, 0x00F6, 0x00F4, 0x00F2, 0x00F0, 0x00EF, 0x00ED, 0x00ED, 
-       0x023E, 0x023E, 0x023E, 0x023E, 0x023E, 0x023E, 0x023E, 0x023E, 0x023E, 0x023E, 0x0234, 0x0234, 0x0234, 0x0234, 0x0234, 0x022B, 
-       0x022B, 0x022B, 0x0222, 0x0222, 0x0222, 0x0219, 0x0219, 0x0219, 0x0210, 0x0210, 0x0210, 0x0208, 0x0208, 0x0200, 0x0200, 0x01F8, 
-       0x01F8, 0x01F0, 0x01F0, 0x01E9, 0x01E9, 0x01E1, 0x01E1, 0x01DA, 0x01DA, 0x01D4, 0x01CD, 0x01CD, 0x01C7, 0x01C7, 0x01C0, 0x01BA, 
-       0x01BA, 0x01B4, 0x01AF, 0x01AF, 0x01A9, 0x01A4, 0x01A4, 0x019E, 0x0199, 0x0199, 0x0194, 0x018F, 0x018F, 0x018A, 0x0186, 0x0181, 
-       0x0181, 0x017D, 0x0178, 0x0174, 0x0174, 0x0170, 0x016C, 0x0168, 0x0164, 0x0164, 0x0160, 0x015C, 0x0158, 0x0158, 0x0155, 0x0151, 
-       0x014E, 0x014A, 0x0147, 0x0147, 0x0144, 0x0141, 0x013E, 0x013B, 0x0138, 0x0138, 0x0135, 0x0132, 0x012F, 0x012C, 0x0129, 0x0129, 
-       0x0127, 0x0124, 0x0121, 0x011F, 0x011C, 0x011A, 0x011A, 0x0118, 0x0115, 0x0113, 0x0111, 0x010E, 0x010C, 0x010A, 0x0108, 0x0108, 
-       0x0106, 0x0104, 0x0102, 0x0100, 0x00FE, 0x00FC, 0x00FA, 0x00F8, 0x00F8, 0x00F6, 0x00F4, 0x00F2, 0x00F0, 0x00EF, 0x00ED, 0x00EB, 
-       0x0234, 0x0234, 0x0234, 0x0234, 0x0234, 0x0234, 0x0234, 0x0234, 0x0234, 0x0234, 0x022B, 0x022B, 0x022B, 0x022B, 0x022B, 0x0222, 
-       0x0222, 0x0222, 0x0222, 0x0219, 0x0219, 0x0219, 0x0210, 0x0210, 0x0210, 0x0208, 0x0208, 0x0200, 0x0200, 0x01F8, 0x01F8, 0x01F8, 
-       0x01F0, 0x01F0, 0x01E9, 0x01E9, 0x01E1, 0x01DA, 0x01DA, 0x01D4, 0x01D4, 0x01CD, 0x01CD, 0x01C7, 0x01C7, 0x01C0, 0x01BA, 0x01BA, 
-       0x01B4, 0x01AF, 0x01AF, 0x01A9, 0x01A4, 0x01A4, 0x019E, 0x0199, 0x0199, 0x0194, 0x018F, 0x018F, 0x018A, 0x0186, 0x0181, 0x0181, 
-       0x017D, 0x0178, 0x0174, 0x0174, 0x0170, 0x016C, 0x0168, 0x0168, 0x0164, 0x0160, 0x015C, 0x015C, 0x0158, 0x0155, 0x0151, 0x014E, 
-       0x014E, 0x014A, 0x0147, 0x0144, 0x0141, 0x013E, 0x013E, 0x013B, 0x0138, 0x0135, 0x0132, 0x012F, 0x012F, 0x012C, 0x0129, 0x0127, 
-       0x0124, 0x0121, 0x011F, 0x011F, 0x011C, 0x011A, 0x0118, 0x0115, 0x0113, 0x0111, 0x0111, 0x010E, 0x010C, 0x010A, 0x0108, 0x0106, 
-       0x0104, 0x0102, 0x0100, 0x0100, 0x00FE, 0x00FC, 0x00FA, 0x00F8, 0x00F6, 0x00F4, 0x00F2, 0x00F0, 0x00F0, 0x00EF, 0x00ED, 0x00EB, 
-       0x022B, 0x022B, 0x022B, 0x022B, 0x022B, 0x022B, 0x022B, 0x022B, 0x022B, 0x022B, 0x0222, 0x0222, 0x0222, 0x0222, 0x0222, 0x0219, 
-       0x0219, 0x0219, 0x0219, 0x0210, 0x0210, 0x0210, 0x0208, 0x0208, 0x0208, 0x0200, 0x0200, 0x01F8, 0x01F8, 0x01F8, 0x01F0, 0x01F0, 
-       0x01E9, 0x01E9, 0x01E1, 0x01E1, 0x01DA, 0x01DA, 0x01D4, 0x01D4, 0x01CD, 0x01C7, 0x01C7, 0x01C0, 0x01C0, 0x01BA, 0x01BA, 0x01B4, 
-       0x01AF, 0x01AF, 0x01A9, 0x01A4, 0x01A4, 0x019E, 0x0199, 0x0199, 0x0194, 0x018F, 0x018F, 0x018A, 0x0186, 0x0181, 0x0181, 0x017D, 
-       0x0178, 0x0178, 0x0174, 0x0170, 0x016C, 0x016C, 0x0168, 0x0164, 0x0160, 0x0160, 0x015C, 0x0158, 0x0155, 0x0151, 0x0151, 0x014E, 
-       0x014A, 0x0147, 0x0144, 0x0144, 0x0141, 0x013E, 0x013B, 0x0138, 0x0135, 0x0135, 0x0132, 0x012F, 0x012C, 0x0129, 0x0127, 0x0127, 
-       0x0124, 0x0121, 0x011F, 0x011C, 0x011A, 0x0118, 0x0118, 0x0115, 0x0113, 0x0111, 0x010E, 0x010C, 0x010A, 0x0108, 0x0108, 0x0106, 
-       0x0104, 0x0102, 0x0100, 0x00FE, 0x00FC, 0x00FA, 0x00F8, 0x00F8, 0x00F6, 0x00F4, 0x00F2, 0x00F0, 0x00EF, 0x00ED, 0x00EB, 0x00EA, 
-       0x0222, 0x0222, 0x0222, 0x0222, 0x0222, 0x0222, 0x0222, 0x0222, 0x0222, 0x0222, 0x0222, 0x0219, 0x0219, 0x0219, 0x0219, 0x0210, 
-       0x0210, 0x0210, 0x0210, 0x0208, 0x0208, 0x0208, 0x0200, 0x0200, 0x0200, 0x01F8, 0x01F8, 0x01F8, 0x01F0, 0x01F0, 0x01E9, 0x01E9, 
-       0x01E1, 0x01E1, 0x01DA, 0x01DA, 0x01D4, 0x01D4, 0x01CD, 0x01CD, 0x01C7, 0x01C7, 0x01C0, 0x01C0, 0x01BA, 0x01B4, 0x01B4, 0x01AF, 
-       0x01AF, 0x01A9, 0x01A4, 0x01A4, 0x019E, 0x0199, 0x0199, 0x0194, 0x018F, 0x018F, 0x018A, 0x0186, 0x0186, 0x0181, 0x017D, 0x0178, 
-       0x0178, 0x0174, 0x0170, 0x016C, 0x016C, 0x0168, 0x0164, 0x0160, 0x0160, 0x015C, 0x0158, 0x0155, 0x0155, 0x0151, 0x014E, 0x014A, 
-       0x0147, 0x0147, 0x0144, 0x0141, 0x013E, 0x013B, 0x013B, 0x0138, 0x0135, 0x0132, 0x012F, 0x012C, 0x012C, 0x0129, 0x0127, 0x0124, 
-       0x0121, 0x011F, 0x011F, 0x011C, 0x011A, 0x0118, 0x0115, 0x0113, 0x0111, 0x010E, 0x010E, 0x010C, 0x010A, 0x0108, 0x0106, 0x0104, 
-       0x0102, 0x0100, 0x0100, 0x00FE, 0x00FC, 0x00FA, 0x00F8, 0x00F6, 0x00F4, 0x00F2, 0x00F0, 0x00F0, 0x00EF, 0x00ED, 0x00EB, 0x00EA, 
-       0x0219, 0x0219, 0x0219, 0x0219, 0x0219, 0x0219, 0x0219, 0x0219, 0x0219, 0x0219, 0x0219, 0x0210, 0x0210, 0x0210, 0x0210, 0x0210, 
-       0x0208, 0x0208, 0x0208, 0x0200, 0x0200, 0x0200, 0x0200, 0x01F8, 0x01F8, 0x01F0, 0x01F0, 0x01F0, 0x01E9, 0x01E9, 0x01E1, 0x01E1, 
-       0x01DA, 0x01DA, 0x01DA, 0x01D4, 0x01D4, 0x01CD, 0x01CD, 0x01C7, 0x01C0, 0x01C0, 0x01BA, 0x01BA, 0x01B4, 0x01B4, 0x01AF, 0x01A9, 
-       0x01A9, 0x01A4, 0x01A4, 0x019E, 0x0199, 0x0199, 0x0194, 0x018F, 0x018F, 0x018A, 0x0186, 0x0186, 0x0181, 0x017D, 0x0178, 0x0178, 
-       0x0174, 0x0170, 0x0170, 0x016C, 0x0168, 0x0164, 0x0164, 0x0160, 0x015C, 0x0158, 0x0158, 0x0155, 0x0151, 0x014E, 0x014A, 0x014A, 
-       0x0147, 0x0144, 0x0141, 0x013E, 0x013E, 0x013B, 0x0138, 0x0135, 0x0132, 0x0132, 0x012F, 0x012C, 0x0129, 0x0127, 0x0124, 0x0124, 
-       0x0121, 0x011F, 0x011C, 0x011A, 0x0118, 0x0115, 0x0115, 0x0113, 0x0111, 0x010E, 0x010C, 0x010A, 0x0108, 0x0108, 0x0106, 0x0104, 
-       0x0102, 0x0100, 0x00FE, 0x00FC, 0x00FA, 0x00F8, 0x00F8, 0x00F6, 0x00F4, 0x00F2, 0x00F0, 0x00EF, 0x00ED, 0x00EB, 0x00EA, 0x00EA, 
-       0x0210, 0x0210, 0x0210, 0x0210, 0x0210, 0x0210, 0x0210, 0x0210, 0x0210, 0x0210, 0x0210, 0x0208, 0x0208, 0x0208, 0x0208, 0x0208, 
-       0x0200, 0x0200, 0x0200, 0x0200, 0x01F8, 0x01F8, 0x01F8, 0x01F0, 0x01F0, 0x01F0, 0x01E9, 0x01E9, 0x01E1, 0x01E1, 0x01E1, 0x01DA, 
-       0x01DA, 0x01D4, 0x01D4, 0x01CD, 0x01CD, 0x01C7, 0x01C7, 0x01C0, 0x01C0, 0x01BA, 0x01BA, 0x01B4, 0x01AF, 0x01AF, 0x01A9, 0x01A9, 
-       0x01A4, 0x019E, 0x019E, 0x0199, 0x0199, 0x0194, 0x018F, 0x018F, 0x018A, 0x0186, 0x0186, 0x0181, 0x017D, 0x0178, 0x0178, 0x0174, 
-       0x0170, 0x0170, 0x016C, 0x0168, 0x0164, 0x0164, 0x0160, 0x015C, 0x0158, 0x0158, 0x0155, 0x0151, 0x014E, 0x014E, 0x014A, 0x0147, 
-       0x0144, 0x0141, 0x0141, 0x013E, 0x013B, 0x0138, 0x0135, 0x0135, 0x0132, 0x012F, 0x012C, 0x0129, 0x0129, 0x0127, 0x0124, 0x0121, 
-       0x011F, 0x011C, 0x011A, 0x011A, 0x0118, 0x0115, 0x0113, 0x0111, 0x010E, 0x010E, 0x010C, 0x010A, 0x0108, 0x0106, 0x0104, 0x0102, 
-       0x0100, 0x0100, 0x00FE, 0x00FC, 0x00FA, 0x00F8, 0x00F6, 0x00F4, 0x00F2, 0x00F0, 0x00F0, 0x00EF, 0x00ED, 0x00EB, 0x00EA, 0x00E8, 
-       0x0208, 0x0208, 0x0208, 0x0208, 0x0208, 0x0208, 0x0208, 0x0208, 0x0208, 0x0208, 0x0208, 0x0200, 0x0200, 0x0200, 0x0200, 0x0200, 
-       0x01F8, 0x01F8, 0x01F8, 0x01F8, 0x01F0, 0x01F0, 0x01F0, 0x01E9, 0x01E9, 0x01E9, 0x01E1, 0x01E1, 0x01DA, 0x01DA, 0x01DA, 0x01D4, 
-       0x01D4, 0x01CD, 0x01CD, 0x01C7, 0x01C7, 0x01C0, 0x01C0, 0x01BA, 0x01BA, 0x01B4, 0x01B4, 0x01AF, 0x01AF, 0x01A9, 0x01A4, 0x01A4, 
-       0x019E, 0x019E, 0x0199, 0x0194, 0x0194, 0x018F, 0x018A, 0x018A, 0x0186, 0x0181, 0x0181, 0x017D, 0x0178, 0x0178, 0x0174, 0x0170, 
-       0x0170, 0x016C, 0x0168, 0x0164, 0x0164, 0x0160, 0x015C, 0x015C, 0x0158, 0x0155, 0x0151, 0x0151, 0x014E, 0x014A, 0x0147, 0x0144, 
-       0x0144, 0x0141, 0x013E, 0x013B, 0x0138, 0x0138, 0x0135, 0x0132, 0x012F, 0x012C, 0x012C, 0x0129, 0x0127, 0x0124, 0x0121, 0x011F, 
-       0x011F, 0x011C, 0x011A, 0x0118, 0x0115, 0x0113, 0x0113, 0x0111, 0x010E, 0x010C, 0x010A, 0x0108, 0x0106, 0x0106, 0x0104, 0x0102, 
-       0x0100, 0x00FE, 0x00FC, 0x00FA, 0x00F8, 0x00F8, 0x00F6, 0x00F4, 0x00F2, 0x00F0, 0x00EF, 0x00ED, 0x00EB, 0x00EA, 0x00EA, 0x00E8, 
-       0x0200, 0x0200, 0x0200, 0x0200, 0x0200, 0x0200, 0x0200, 0x0200, 0x0200, 0x0200, 0x0200, 0x0200, 0x01F8, 0x01F8, 0x01F8, 0x01F8, 
-       0x01F0, 0x01F0, 0x01F0, 0x01F0, 0x01E9, 0x01E9, 0x01E9, 0x01E1, 0x01E1, 0x01E1, 0x01DA, 0x01DA, 0x01DA, 0x01D4, 0x01D4, 0x01CD, 
-       0x01CD, 0x01C7, 0x01C7, 0x01C7, 0x01C0, 0x01C0, 0x01BA, 0x01BA, 0x01B4, 0x01AF, 0x01AF, 0x01A9, 0x01A9, 0x01A4, 0x01A4, 0x019E, 
-       0x0199, 0x0199, 0x0194, 0x0194, 0x018F, 0x018A, 0x018A, 0x0186, 0x0181, 0x0181, 0x017D, 0x0178, 0x0178, 0x0174, 0x0170, 0x0170, 
-       0x016C, 0x0168, 0x0168, 0x0164, 0x0160, 0x015C, 0x015C, 0x0158, 0x0155, 0x0151, 0x0151, 0x014E, 0x014A, 0x0147, 0x0147, 0x0144, 
-       0x0141, 0x013E, 0x013B, 0x013B, 0x0138, 0x0135, 0x0132, 0x012F, 0x012F, 0x012C, 0x0129, 0x0127, 0x0124, 0x0124, 0x0121, 0x011F, 
-       0x011C, 0x011A, 0x0118, 0x0118, 0x0115, 0x0113, 0x0111, 0x010E, 0x010C, 0x010C, 0x010A, 0x0108, 0x0106, 0x0104, 0x0102, 0x0100, 
-       0x00FE, 0x00FE, 0x00FC, 0x00FA, 0x00F8, 0x00F6, 0x00F4, 0x00F2, 0x00F0, 0x00F0, 0x00EF, 0x00ED, 0x00EB, 0x00EA, 0x00E8, 0x00E6, 
-       0x01F8, 0x01F8, 0x01F8, 0x01F8, 0x01F8, 0x01F8, 0x01F8, 0x01F8, 0x01F8, 0x01F8, 0x01F8, 0x01F8, 0x01F0, 0x01F0, 0x01F0, 0x01F0, 
-       0x01F0, 0x01E9, 0x01E9, 0x01E9, 0x01E1, 0x01E1, 0x01E1, 0x01E1, 0x01DA, 0x01DA, 0x01D4, 0x01D4, 0x01D4, 0x01CD, 0x01CD, 0x01C7, 
-       0x01C7, 0x01C7, 0x01C0, 0x01C0, 0x01BA, 0x01BA, 0x01B4, 0x01B4, 0x01AF, 0x01AF, 0x01A9, 0x01A9, 0x01A4, 0x019E, 0x019E, 0x0199, 
-       0x0199, 0x0194, 0x018F, 0x018F, 0x018A, 0x018A, 0x0186, 0x0181, 0x0181, 0x017D, 0x0178, 0x0178, 0x0174, 0x0170, 0x0170, 0x016C, 
-       0x0168, 0x0168, 0x0164, 0x0160, 0x015C, 0x015C, 0x0158, 0x0155, 0x0151, 0x0151, 0x014E, 0x014A, 0x0147, 0x0147, 0x0144, 0x0141, 
-       0x013E, 0x013E, 0x013B, 0x0138, 0x0135, 0x0132, 0x0132, 0x012F, 0x012C, 0x0129, 0x0127, 0x0127, 0x0124, 0x0121, 0x011F, 0x011C, 
-       0x011C, 0x011A, 0x0118, 0x0115, 0x0113, 0x0111, 0x0111, 0x010E, 0x010C, 0x010A, 0x0108, 0x0106, 0x0104, 0x0104, 0x0102, 0x0100, 
-       0x00FE, 0x00FC, 0x00FA, 0x00F8, 0x00F8, 0x00F6, 0x00F4, 0x00F2, 0x00F0, 0x00EF, 0x00ED, 0x00EB, 0x00EA, 0x00EA, 0x00E8, 0x00E6, 
-       0x01F8, 0x01F8, 0x01F0, 0x01F0, 0x01F0, 0x01F0, 0x01F0, 0x01F0, 0x01F0, 0x01F0, 0x01F0, 0x01F0, 0x01E9, 0x01E9, 0x01E9, 0x01E9, 
-       0x01E9, 0x01E1, 0x01E1, 0x01E1, 0x01E1, 0x01DA, 0x01DA, 0x01DA, 0x01D4, 0x01D4, 0x01D4, 0x01CD, 0x01CD, 0x01C7, 0x01C7, 0x01C7, 
-       0x01C0, 0x01C0, 0x01BA, 0x01BA, 0x01B4, 0x01B4, 0x01AF, 0x01AF, 0x01A9, 0x01A9, 0x01A4, 0x01A4, 0x019E, 0x019E, 0x0199, 0x0194, 
-       0x0194, 0x018F, 0x018F, 0x018A, 0x0186, 0x0186, 0x0181, 0x0181, 0x017D, 0x0178, 0x0178, 0x0174, 0x0170, 0x0170, 0x016C, 0x0168, 
-       0x0168, 0x0164, 0x0160, 0x015C, 0x015C, 0x0158, 0x0155, 0x0155, 0x0151, 0x014E, 0x014A, 0x014A, 0x0147, 0x0144, 0x0141, 0x0141, 
-       0x013E, 0x013B, 0x0138, 0x0135, 0x0135, 0x0132, 0x012F, 0x012C, 0x012C, 0x0129, 0x0127, 0x0124, 0x0121, 0x011F, 0x011F, 0x011C, 
-       0x011A, 0x0118, 0x0115, 0x0115, 0x0113, 0x0111, 0x010E, 0x010C, 0x010A, 0x0108, 0x0108, 0x0106, 0x0104, 0x0102, 0x0100, 0x00FE, 
-       0x00FE, 0x00FC, 0x00FA, 0x00F8, 0x00F6, 0x00F4, 0x00F2, 0x00F0, 0x00F0, 0x00EF, 0x00ED, 0x00EB, 0x00EA, 0x00E8, 0x00E6, 0x00E5, 
-       0x01F0, 0x01F0, 0x01F0, 0x01E9, 0x01E9, 0x01E9, 0x01E9, 0x01E9, 0x01E9, 0x01E9, 0x01E9, 0x01E9, 0x01E1, 0x01E1, 0x01E1, 0x01E1, 
-       0x01E1, 0x01DA, 0x01DA, 0x01DA, 0x01DA, 0x01D4, 0x01D4, 0x01D4, 0x01CD, 0x01CD, 0x01CD, 0x01C7, 0x01C7, 0x01C7, 0x01C0, 0x01C0, 
-       0x01BA, 0x01BA, 0x01B4, 0x01B4, 0x01AF, 0x01AF, 0x01AF, 0x01A9, 0x01A9, 0x01A4, 0x019E, 0x019E, 0x0199, 0x0199, 0x0194, 0x0194, 
-       0x018F, 0x018F, 0x018A, 0x0186, 0x0186, 0x0181, 0x017D, 0x017D, 0x0178, 0x0178, 0x0174, 0x0170, 0x0170, 0x016C, 0x0168, 0x0168, 
-       0x0164, 0x0160, 0x015C, 0x015C, 0x0158, 0x0155, 0x0155, 0x0151, 0x014E, 0x014A, 0x014A, 0x0147, 0x0144, 0x0141, 0x0141, 0x013E, 
-       0x013B, 0x0138, 0x0138, 0x0135, 0x0132, 0x012F, 0x012F, 0x012C, 0x0129, 0x0127, 0x0124, 0x0124, 0x0121, 0x011F, 0x011C, 0x011A, 
-       0x0118, 0x0118, 0x0115, 0x0113, 0x0111, 0x010E, 0x010C, 0x010C, 0x010A, 0x0108, 0x0106, 0x0104, 0x0102, 0x0102, 0x0100, 0x00FE, 
-       0x00FC, 0x00FA, 0x00F8, 0x00F6, 0x00F6, 0x00F4, 0x00F2, 0x00F0, 0x00EF, 0x00ED, 0x00EB, 0x00EA, 0x00EA, 0x00E8, 0x00E6, 0x00E5, 
-       0x01E9, 0x01E9, 0x01E9, 0x01E9, 0x01E1, 0x01E1, 0x01E1, 0x01E1, 0x01E1, 0x01E1, 0x01E1, 0x01E1, 0x01E1, 0x01DA, 0x01DA, 0x01DA, 
-       0x01DA, 0x01D4, 0x01D4, 0x01D4, 0x01D4, 0x01CD, 0x01CD, 0x01CD, 0x01C7, 0x01C7, 0x01C7, 0x01C0, 0x01C0, 0x01C0, 0x01BA, 0x01BA, 
-       0x01B4, 0x01B4, 0x01B4, 0x01AF, 0x01AF, 0x01A9, 0x01A9, 0x01A4, 0x01A4, 0x019E, 0x019E, 0x0199, 0x0199, 0x0194, 0x018F, 0x018F, 
-       0x018A, 0x018A, 0x0186, 0x0186, 0x0181, 0x017D, 0x017D, 0x0178, 0x0174, 0x0174, 0x0170, 0x0170, 0x016C, 0x0168, 0x0168, 0x0164, 
-       0x0160, 0x015C, 0x015C, 0x0158, 0x0155, 0x0155, 0x0151, 0x014E, 0x014E, 0x014A, 0x0147, 0x0144, 0x0144, 0x0141, 0x013E, 0x013B, 
-       0x013B, 0x0138, 0x0135, 0x0132, 0x012F, 0x012F, 0x012C, 0x0129, 0x0127, 0x0127, 0x0124, 0x0121, 0x011F, 0x011C, 0x011C, 0x011A, 
-       0x0118, 0x0115, 0x0113, 0x0111, 0x0111, 0x010E, 0x010C, 0x010A, 0x0108, 0x0106, 0x0106, 0x0104, 0x0102, 0x0100, 0x00FE, 0x00FC, 
-       0x00FC, 0x00FA, 0x00F8, 0x00F6, 0x00F4, 0x00F2, 0x00F0, 0x00EF, 0x00EF, 0x00ED, 0x00EB, 0x00EA, 0x00E8, 0x00E6, 0x00E5, 0x00E3, 
-       0x01E1, 0x01E1, 0x01E1, 0x01E1, 0x01DA, 0x01DA, 0x01DA, 0x01DA, 0x01DA, 0x01DA, 0x01DA, 0x01DA, 0x01DA, 0x01D4, 0x01D4, 0x01D4, 
-       0x01D4, 0x01D4, 0x01CD, 0x01CD, 0x01CD, 0x01C7, 0x01C7, 0x01C7, 0x01C7, 0x01C0, 0x01C0, 0x01C0, 0x01BA, 0x01BA, 0x01B4, 0x01B4, 
-       0x01B4, 0x01AF, 0x01AF, 0x01A9, 0x01A9, 0x01A4, 0x01A4, 0x019E, 0x019E, 0x0199, 0x0199, 0x0194, 0x0194, 0x018F, 0x018F, 0x018A, 
-       0x018A, 0x0186, 0x0181, 0x0181, 0x017D, 0x017D, 0x0178, 0x0174, 0x0174, 0x0170, 0x016C, 0x016C, 0x0168, 0x0164, 0x0164, 0x0160, 
-       0x015C, 0x015C, 0x0158, 0x0155, 0x0155, 0x0151, 0x014E, 0x014E, 0x014A, 0x0147, 0x0144, 0x0144, 0x0141, 0x013E, 0x013B, 0x013B, 
-       0x0138, 0x0135, 0x0132, 0x0132, 0x012F, 0x012C, 0x0129, 0x0129, 0x0127, 0x0124, 0x0121, 0x011F, 0x011F, 0x011C, 0x011A, 0x0118, 
-       0x0115, 0x0115, 0x0113, 0x0111, 0x010E, 0x010C, 0x010A, 0x010A, 0x0108, 0x0106, 0x0104, 0x0102, 0x0100, 0x0100, 0x00FE, 0x00FC, 
-       0x00FA, 0x00F8, 0x00F6, 0x00F4, 0x00F4, 0x00F2, 0x00F0, 0x00EF, 0x00ED, 0x00EB, 0x00EA, 0x00EA, 0x00E8, 0x00E6, 0x00E5, 0x00E3, 
-       0x01DA, 0x01DA, 0x01DA, 0x01DA, 0x01DA, 0x01D4, 0x01D4, 0x01D4, 0x01D4, 0x01D4, 0x01D4, 0x01D4, 0x01D4, 0x01CD, 0x01CD, 0x01CD, 
-       0x01CD, 0x01CD, 0x01C7, 0x01C7, 0x01C7, 0x01C7, 0x01C0, 0x01C0, 0x01C0, 0x01BA, 0x01BA, 0x01BA, 0x01B4, 0x01B4, 0x01AF, 0x01AF, 
-       0x01AF, 0x01A9, 0x01A9, 0x01A4, 0x01A4, 0x019E, 0x019E, 0x0199, 0x0199, 0x0194, 0x0194, 0x018F, 0x018F, 0x018A, 0x018A, 0x0186, 
-       0x0186, 0x0181, 0x0181, 0x017D, 0x0178, 0x0178, 0x0174, 0x0174, 0x0170, 0x016C, 0x016C, 0x0168, 0x0164, 0x0164, 0x0160, 0x015C, 
-       0x015C, 0x0158, 0x0155, 0x0155, 0x0151, 0x014E, 0x014E, 0x014A, 0x0147, 0x0144, 0x0144, 0x0141, 0x013E, 0x013E, 0x013B, 0x0138, 
-       0x0135, 0x0135, 0x0132, 0x012F, 0x012C, 0x0129, 0x0129, 0x0127, 0x0124, 0x0121, 0x0121, 0x011F, 0x011C, 0x011A, 0x0118, 0x0118, 
-       0x0115, 0x0113, 0x0111, 0x010E, 0x010E, 0x010C, 0x010A, 0x0108, 0x0106, 0x0104, 0x0104, 0x0102, 0x0100, 0x00FE, 0x00FC, 0x00FA, 
-       0x00F8, 0x00F8, 0x00F6, 0x00F4, 0x00F2, 0x00F0, 0x00EF, 0x00EF, 0x00ED, 0x00EB, 0x00EA, 0x00E8, 0x00E6, 0x00E5, 0x00E3, 0x00E3, 
-       0x01D4, 0x01D4, 0x01D4, 0x01D4, 0x01D4, 0x01CD, 0x01CD, 0x01CD, 0x01CD, 0x01CD, 0x01CD, 0x01CD, 0x01CD, 0x01C7, 0x01C7, 0x01C7, 
-       0x01C7, 0x01C7, 0x01C0, 0x01C0, 0x01C0, 0x01C0, 0x01BA, 0x01BA, 0x01BA, 0x01B4, 0x01B4, 0x01B4, 0x01AF, 0x01AF, 0x01AF, 0x01A9, 
-       0x01A9, 0x01A4, 0x01A4, 0x019E, 0x019E, 0x019E, 0x0199, 0x0199, 0x0194, 0x0194, 0x018F, 0x018F, 0x018A, 0x018A, 0x0186, 0x0181, 
-       0x0181, 0x017D, 0x017D, 0x0178, 0x0178, 0x0174, 0x0170, 0x0170, 0x016C, 0x016C, 0x0168, 0x0164, 0x0164, 0x0160, 0x015C, 0x015C, 
-       0x0158, 0x0155, 0x0155, 0x0151, 0x014E, 0x014E, 0x014A, 0x0147, 0x0144, 0x0144, 0x0141, 0x013E, 0x013E, 0x013B, 0x0138, 0x0135, 
-       0x0135, 0x0132, 0x012F, 0x012C, 0x012C, 0x0129, 0x0127, 0x0124, 0x0124, 0x0121, 0x011F, 0x011C, 0x011A, 0x011A, 0x0118, 0x0115, 
-       0x0113, 0x0111, 0x0111, 0x010E, 0x010C, 0x010A, 0x0108, 0x0106, 0x0106, 0x0104, 0x0102, 0x0100, 0x00FE, 0x00FE, 0x00FC, 0x00FA, 
-       0x00F8, 0x00F6, 0x00F4, 0x00F2, 0x00F2, 0x00F0, 0x00EF, 0x00ED, 0x00EB, 0x00EA, 0x00E8, 0x00E8, 0x00E6, 0x00E5, 0x00E3, 0x00E1, 
-       0x01CD, 0x01CD, 0x01CD, 0x01CD, 0x01CD, 0x01CD, 0x01C7, 0x01C7, 0x01C7, 0x01C7, 0x01C7, 0x01C7, 0x01C7, 0x01C7, 0x01C0, 0x01C0, 
-       0x01C0, 0x01C0, 0x01BA, 0x01BA, 0x01BA, 0x01BA, 0x01B4, 0x01B4, 0x01B4, 0x01AF, 0x01AF, 0x01AF, 0x01A9, 0x01A9, 0x01A9, 0x01A4, 
-       0x01A4, 0x019E, 0x019E, 0x019E, 0x0199, 0x0199, 0x0194, 0x0194, 0x018F, 0x018F, 0x018A, 0x018A, 0x0186, 0x0186, 0x0181, 0x0181, 
-       0x017D, 0x017D, 0x0178, 0x0174, 0x0174, 0x0170, 0x0170, 0x016C, 0x0168, 0x0168, 0x0164, 0x0164, 0x0160, 0x015C, 0x015C, 0x0158, 
-       0x0155, 0x0155, 0x0151, 0x014E, 0x014E, 0x014A, 0x0147, 0x0147, 0x0144, 0x0141, 0x013E, 0x013E, 0x013B, 0x0138, 0x0135, 0x0135, 
-       0x0132, 0x012F, 0x012F, 0x012C, 0x0129, 0x0127, 0x0124, 0x0124, 0x0121, 0x011F, 0x011C, 0x011C, 0x011A, 0x0118, 0x0115, 0x0113, 
-       0x0113, 0x0111, 0x010E, 0x010C, 0x010A, 0x010A, 0x0108, 0x0106, 0x0104, 0x0102, 0x0100, 0x0100, 0x00FE, 0x00FC, 0x00FA, 0x00F8, 
-       0x00F6, 0x00F6, 0x00F4, 0x00F2, 0x00F0, 0x00EF, 0x00ED, 0x00ED, 0x00EB, 0x00EA, 0x00E8, 0x00E6, 0x00E5, 0x00E3, 0x00E1, 0x00E1, 
-       0x01C7, 0x01C7, 0x01C7, 0x01C7, 0x01C7, 0x01C7, 0x01C0, 0x01C0, 0x01C0, 0x01C0, 0x01C0, 0x01C0, 0x01C0, 0x01C0, 0x01BA, 0x01BA, 
-       0x01BA, 0x01BA, 0x01BA, 0x01B4, 0x01B4, 0x01B4, 0x01AF, 0x01AF, 0x01AF, 0x01AF, 0x01A9, 0x01A9, 0x01A9, 0x01A4, 0x01A4, 0x019E, 
-       0x019E, 0x019E, 0x0199, 0x0199, 0x0194, 0x0194, 0x018F, 0x018F, 0x018A, 0x018A, 0x0186, 0x0186, 0x0181, 0x0181, 0x017D, 0x017D, 
-       0x0178, 0x0178, 0x0174, 0x0174, 0x0170, 0x016C, 0x016C, 0x0168, 0x0168, 0x0164, 0x0160, 0x0160, 0x015C, 0x015C, 0x0158, 0x0155, 
-       0x0155, 0x0151, 0x014E, 0x014E, 0x014A, 0x0147, 0x0147, 0x0144, 0x0141, 0x013E, 0x013E, 0x013B, 0x0138, 0x0138, 0x0135, 0x0132, 
-       0x012F, 0x012F, 0x012C, 0x0129, 0x0127, 0x0127, 0x0124, 0x0121, 0x011F, 0x011F, 0x011C, 0x011A, 0x0118, 0x0115, 0x0115, 0x0113, 
-       0x0111, 0x010E, 0x010C, 0x010C, 0x010A, 0x0108, 0x0106, 0x0104, 0x0104, 0x0102, 0x0100, 0x00FE, 0x00FC, 0x00FA, 0x00FA, 0x00F8, 
-       0x00F6, 0x00F4, 0x00F2, 0x00F0, 0x00F0, 0x00EF, 0x00ED, 0x00EB, 0x00EA, 0x00E8, 0x00E6, 0x00E6, 0x00E5, 0x00E3, 0x00E1, 0x00E0, 
-       0x01C0, 0x01C0, 0x01C0, 0x01C0, 0x01C0, 0x01C0, 0x01BA, 0x01BA, 0x01BA, 0x01BA, 0x01BA, 0x01BA, 0x01BA, 0x01BA, 0x01B4, 0x01B4, 
-       0x01B4, 0x01B4, 0x01B4, 0x01AF, 0x01AF, 0x01AF, 0x01AF, 0x01A9, 0x01A9, 0x01A9, 0x01A4, 0x01A4, 0x01A4, 0x019E, 0x019E, 0x0199, 
-       0x0199, 0x0199, 0x0194, 0x0194, 0x018F, 0x018F, 0x018F, 0x018A, 0x018A, 0x0186, 0x0186, 0x0181, 0x0181, 0x017D, 0x017D, 0x0178, 
-       0x0174, 0x0174, 0x0170, 0x0170, 0x016C, 0x016C, 0x0168, 0x0164, 0x0164, 0x0160, 0x0160, 0x015C, 0x0158, 0x0158, 0x0155, 0x0151, 
-       0x0151, 0x014E, 0x014E, 0x014A, 0x0147, 0x0144, 0x0144, 0x0141, 0x013E, 0x013E, 0x013B, 0x0138, 0x0138, 0x0135, 0x0132, 0x012F, 
-       0x012F, 0x012C, 0x0129, 0x0127, 0x0127, 0x0124, 0x0121, 0x011F, 0x011F, 0x011C, 0x011A, 0x0118, 0x0118, 0x0115, 0x0113, 0x0111, 
-       0x010E, 0x010E, 0x010C, 0x010A, 0x0108, 0x0106, 0x0106, 0x0104, 0x0102, 0x0100, 0x00FE, 0x00FE, 0x00FC, 0x00FA, 0x00F8, 0x00F6, 
-       0x00F4, 0x00F4, 0x00F2, 0x00F0, 0x00EF, 0x00ED, 0x00EB, 0x00EA, 0x00EA, 0x00E8, 0x00E6, 0x00E5, 0x00E3, 0x00E1, 0x00E0, 0x00E0, 
-       0x01BA, 0x01BA, 0x01BA, 0x01BA, 0x01BA, 0x01BA, 0x01BA, 0x01B4, 0x01B4, 0x01B4, 0x01B4, 0x01B4, 0x01B4, 0x01B4, 0x01AF, 0x01AF, 
-       0x01AF, 0x01AF, 0x01AF, 0x01A9, 0x01A9, 0x01A9, 0x01A9, 0x01A4, 0x01A4, 0x01A4, 0x019E, 0x019E, 0x019E, 0x0199, 0x0199, 0x0199, 
-       0x0194, 0x0194, 0x018F, 0x018F, 0x018F, 0x018A, 0x018A, 0x0186, 0x0186, 0x0181, 0x0181, 0x017D, 0x017D, 0x0178, 0x0178, 0x0174, 
-       0x0174, 0x0170, 0x0170, 0x016C, 0x0168, 0x0168, 0x0164, 0x0164, 0x0160, 0x0160, 0x015C, 0x0158, 0x0158, 0x0155, 0x0151, 0x0151, 
-       0x014E, 0x014A, 0x014A, 0x0147, 0x0144, 0x0144, 0x0141, 0x013E, 0x013E, 0x013B, 0x0138, 0x0138, 0x0135, 0x0132, 0x012F, 0x012F, 
-       0x012C, 0x0129, 0x0129, 0x0127, 0x0124, 0x0121, 0x0121, 0x011F, 0x011C, 0x011A, 0x011A, 0x0118, 0x0115, 0x0113, 0x0111, 0x0111, 
-       0x010E, 0x010C, 0x010A, 0x0108, 0x0108, 0x0106, 0x0104, 0x0102, 0x0100, 0x0100, 0x00FE, 0x00FC, 0x00FA, 0x00F8, 0x00F8, 0x00F6, 
-       0x00F4, 0x00F2, 0x00F0, 0x00EF, 0x00EF, 0x00ED, 0x00EB, 0x00EA, 0x00E8, 0x00E6, 0x00E5, 0x00E5, 0x00E3, 0x00E1, 0x00E0, 0x00DE, 
-       0x01B4, 0x01B4, 0x01B4, 0x01B4, 0x01B4, 0x01B4, 0x01B4, 0x01AF, 0x01AF, 0x01AF, 0x01AF, 0x01AF, 0x01AF, 0x01AF, 0x01AF, 0x01A9, 
-       0x01A9, 0x01A9, 0x01A9, 0x01A4, 0x01A4, 0x01A4, 0x01A4, 0x019E, 0x019E, 0x019E, 0x0199, 0x0199, 0x0199, 0x0194, 0x0194, 0x0194, 
-       0x018F, 0x018F, 0x018F, 0x018A, 0x018A, 0x0186, 0x0186, 0x0181, 0x0181, 0x017D, 0x017D, 0x0178, 0x0178, 0x0174, 0x0174, 0x0170, 
-       0x0170, 0x016C, 0x016C, 0x0168, 0x0168, 0x0164, 0x0164, 0x0160, 0x015C, 0x015C, 0x0158, 0x0158, 0x0155, 0x0151, 0x0151, 0x014E, 
-       0x014A, 0x014A, 0x0147, 0x0144, 0x0144, 0x0141, 0x013E, 0x013E, 0x013B, 0x0138, 0x0138, 0x0135, 0x0132, 0x0132, 0x012F, 0x012C, 
-       0x0129, 0x0129, 0x0127, 0x0124, 0x0121, 0x0121, 0x011F, 0x011C, 0x011A, 0x011A, 0x0118, 0x0115, 0x0113, 0x0113, 0x0111, 0x010E, 
-       0x010C, 0x010A, 0x010A, 0x0108, 0x0106, 0x0104, 0x0102, 0x0102, 0x0100, 0x00FE, 0x00FC, 0x00FA, 0x00FA, 0x00F8, 0x00F6, 0x00F4, 
-       0x00F2, 0x00F0, 0x00F0, 0x00EF, 0x00ED, 0x00EB, 0x00EA, 0x00E8, 0x00E8, 0x00E6, 0x00E5, 0x00E3, 0x00E1, 0x00E0, 0x00E0, 0x00DE, 
-       0x01AF, 0x01AF, 0x01AF, 0x01AF, 0x01AF, 0x01AF, 0x01AF, 0x01A9, 0x01A9, 0x01A9, 0x01A9, 0x01A9, 0x01A9, 0x01A9, 0x01A9, 0x01A4, 
-       0x01A4, 0x01A4, 0x01A4, 0x019E, 0x019E, 0x019E, 0x019E, 0x0199, 0x0199, 0x0199, 0x0199, 0x0194, 0x0194, 0x0194, 0x018F, 0x018F, 
-       0x018A, 0x018A, 0x018A, 0x0186, 0x0186, 0x0181, 0x0181, 0x017D, 0x017D, 0x017D, 0x0178, 0x0178, 0x0174, 0x0174, 0x0170, 0x0170, 
-       0x016C, 0x0168, 0x0168, 0x0164, 0x0164, 0x0160, 0x0160, 0x015C, 0x015C, 0x0158, 0x0155, 0x0155, 0x0151, 0x0151, 0x014E, 0x014A, 
-       0x014A, 0x0147, 0x0144, 0x0144, 0x0141, 0x013E, 0x013E, 0x013B, 0x0138, 0x0138, 0x0135, 0x0132, 0x0132, 0x012F, 0x012C, 0x0129, 
-       0x0129, 0x0127, 0x0124, 0x0121, 0x0121, 0x011F, 0x011C, 0x011C, 0x011A, 0x0118, 0x0115, 0x0113, 0x0113, 0x0111, 0x010E, 0x010C, 
-       0x010C, 0x010A, 0x0108, 0x0106, 0x0104, 0x0104, 0x0102, 0x0100, 0x00FE, 0x00FC, 0x00FC, 0x00FA, 0x00F8, 0x00F6, 0x00F4, 0x00F4, 
-       0x00F2, 0x00F0, 0x00EF, 0x00ED, 0x00EB, 0x00EB, 0x00EA, 0x00E8, 0x00E6, 0x00E5, 0x00E3, 0x00E3, 0x00E1, 0x00E0, 0x00DE, 0x00DD, 
-       0x01A9, 0x01A9, 0x01A9, 0x01A9, 0x01A9, 0x01A9, 0x01A9, 0x01A9, 0x01A4, 0x01A4, 0x01A4, 0x01A4, 0x01A4, 0x01A4, 0x01A4, 0x019E, 
-       0x019E, 0x019E, 0x019E, 0x019E, 0x0199, 0x0199, 0x0199, 0x0194, 0x0194, 0x0194, 0x0194, 0x018F, 0x018F, 0x018F, 0x018A, 0x018A, 
-       0x0186, 0x0186, 0x0186, 0x0181, 0x0181, 0x017D, 0x017D, 0x017D, 0x0178, 0x0178, 0x0174, 0x0174, 0x0170, 0x0170, 0x016C, 0x016C, 
-       0x0168, 0x0168, 0x0164, 0x0164, 0x0160, 0x015C, 0x015C, 0x0158, 0x0158, 0x0155, 0x0155, 0x0151, 0x014E, 0x014E, 0x014A, 0x0147, 
-       0x0147, 0x0144, 0x0144, 0x0141, 0x013E, 0x013E, 0x013B, 0x0138, 0x0138, 0x0135, 0x0132, 0x0132, 0x012F, 0x012C, 0x0129, 0x0129, 
-       0x0127, 0x0124, 0x0124, 0x0121, 0x011F, 0x011C, 0x011C, 0x011A, 0x0118, 0x0115, 0x0115, 0x0113, 0x0111, 0x010E, 0x010E, 0x010C, 
-       0x010A, 0x0108, 0x0106, 0x0106, 0x0104, 0x0102, 0x0100, 0x00FE, 0x00FE, 0x00FC, 0x00FA, 0x00F8, 0x00F6, 0x00F6, 0x00F4, 0x00F2, 
-       0x00F0, 0x00EF, 0x00EF, 0x00ED, 0x00EB, 0x00EA, 0x00E8, 0x00E6, 0x00E6, 0x00E5, 0x00E3, 0x00E1, 0x00E0, 0x00DE, 0x00DD, 0x00DD, 
-       0x01A4, 0x01A4, 0x01A4, 0x01A4, 0x01A4, 0x01A4, 0x01A4, 0x01A4, 0x019E, 0x019E, 0x019E, 0x019E, 0x019E, 0x019E, 0x019E, 0x0199, 
-       0x0199, 0x0199, 0x0199, 0x0199, 0x0194, 0x0194, 0x0194, 0x0194, 0x018F, 0x018F, 0x018F, 0x018A, 0x018A, 0x018A, 0x0186, 0x0186, 
-       0x0186, 0x0181, 0x0181, 0x017D, 0x017D, 0x017D, 0x0178, 0x0178, 0x0174, 0x0174, 0x0170, 0x0170, 0x016C, 0x016C, 0x0168, 0x0168, 
-       0x0164, 0x0164, 0x0160, 0x0160, 0x015C, 0x015C, 0x0158, 0x0158, 0x0155, 0x0151, 0x0151, 0x014E, 0x014E, 0x014A, 0x0147, 0x0147, 
-       0x0144, 0x0141, 0x0141, 0x013E, 0x013E, 0x013B, 0x0138, 0x0138, 0x0135, 0x0132, 0x0132, 0x012F, 0x012C, 0x0129, 0x0129, 0x0127, 
-       0x0124, 0x0124, 0x0121, 0x011F, 0x011C, 0x011C, 0x011A, 0x0118, 0x0115, 0x0115, 0x0113, 0x0111, 0x010E, 0x010E, 0x010C, 0x010A, 
-       0x0108, 0x0108, 0x0106, 0x0104, 0x0102, 0x0100, 0x0100, 0x00FE, 0x00FC, 0x00FA, 0x00FA, 0x00F8, 0x00F6, 0x00F4, 0x00F2, 0x00F0, 
-       0x00F0, 0x00EF, 0x00ED, 0x00EB, 0x00EA, 0x00EA, 0x00E8, 0x00E6, 0x00E5, 0x00E3, 0x00E1, 0x00E1, 0x00E0, 0x00DE, 0x00DD, 0x00DB, 
-       0x019E, 0x019E, 0x019E, 0x019E, 0x019E, 0x019E, 0x019E, 0x019E, 0x0199, 0x0199, 0x0199, 0x0199, 0x0199, 0x0199, 0x0199, 0x0194, 
-       0x0194, 0x0194, 0x0194, 0x0194, 0x018F, 0x018F, 0x018F, 0x018F, 0x018A, 0x018A, 0x018A, 0x0186, 0x0186, 0x0186, 0x0181, 0x0181, 
-       0x0181, 0x017D, 0x017D, 0x017D, 0x0178, 0x0178, 0x0174, 0x0174, 0x0170, 0x0170, 0x016C, 0x016C, 0x016C, 0x0168, 0x0168, 0x0164, 
-       0x0164, 0x0160, 0x015C, 0x015C, 0x0158, 0x0158, 0x0155, 0x0155, 0x0151, 0x0151, 0x014E, 0x014A, 0x014A, 0x0147, 0x0147, 0x0144, 
-       0x0141, 0x0141, 0x013E, 0x013B, 0x013B, 0x0138, 0x0135, 0x0135, 0x0132, 0x012F, 0x012F, 0x012C, 0x0129, 0x0129, 0x0127, 0x0124, 
-       0x0124, 0x0121, 0x011F, 0x011C, 0x011C, 0x011A, 0x0118, 0x0118, 0x0115, 0x0113, 0x0111, 0x0111, 0x010E, 0x010C, 0x010A, 0x010A, 
-       0x0108, 0x0106, 0x0104, 0x0102, 0x0102, 0x0100, 0x00FE, 0x00FC, 0x00FC, 0x00FA, 0x00F8, 0x00F6, 0x00F4, 0x00F4, 0x00F2, 0x00F0, 
-       0x00EF, 0x00ED, 0x00EB, 0x00EB, 0x00EA, 0x00E8, 0x00E6, 0x00E5, 0x00E3, 0x00E3, 0x00E1, 0x00E0, 0x00DE, 0x00DD, 0x00DB, 0x00DB, 
-       0x0199, 0x0199, 0x0199, 0x0199, 0x0199, 0x0199, 0x0199, 0x0199, 0x0194, 0x0194, 0x0194, 0x0194, 0x0194, 0x0194, 0x0194, 0x0194, 
-       0x018F, 0x018F, 0x018F, 0x018F, 0x018A, 0x018A, 0x018A, 0x018A, 0x0186, 0x0186, 0x0186, 0x0181, 0x0181, 0x0181, 0x017D, 0x017D, 
-       0x017D, 0x0178, 0x0178, 0x0178, 0x0174, 0x0174, 0x0170, 0x0170, 0x0170, 0x016C, 0x016C, 0x0168, 0x0168, 0x0164, 0x0164, 0x0160, 
-       0x0160, 0x015C, 0x015C, 0x0158, 0x0158, 0x0155, 0x0151, 0x0151, 0x014E, 0x014E, 0x014A, 0x014A, 0x0147, 0x0144, 0x0144, 0x0141, 
-       0x0141, 0x013E, 0x013B, 0x013B, 0x0138, 0x0135, 0x0135, 0x0132, 0x012F, 0x012F, 0x012C, 0x0129, 0x0129, 0x0127, 0x0124, 0x0124, 
-       0x0121, 0x011F, 0x011F, 0x011C, 0x011A, 0x0118, 0x0118, 0x0115, 0x0113, 0x0111, 0x0111, 0x010E, 0x010C, 0x010A, 0x010A, 0x0108, 
-       0x0106, 0x0104, 0x0104, 0x0102, 0x0100, 0x00FE, 0x00FC, 0x00FC, 0x00FA, 0x00F8, 0x00F6, 0x00F6, 0x00F4, 0x00F2, 0x00F0, 0x00EF, 
-       0x00EF, 0x00ED, 0x00EB, 0x00EA, 0x00E8, 0x00E6, 0x00E6, 0x00E5, 0x00E3, 0x00E1, 0x00E0, 0x00DE, 0x00DE, 0x00DD, 0x00DB, 0x00DA, 
-       0x0194, 0x0194, 0x0194, 0x0194, 0x0194, 0x0194, 0x0194, 0x0194, 0x0194, 0x018F, 0x018F, 0x018F, 0x018F, 0x018F, 0x018F, 0x018F, 
-       0x018A, 0x018A, 0x018A, 0x018A, 0x0186, 0x0186, 0x0186, 0x0186, 0x0181, 0x0181, 0x0181, 0x0181, 0x017D, 0x017D, 0x017D, 0x0178, 
-       0x0178, 0x0174, 0x0174, 0x0174, 0x0170, 0x0170, 0x016C, 0x016C, 0x016C, 0x0168, 0x0168, 0x0164, 0x0164, 0x0160, 0x0160, 0x015C, 
-       0x015C, 0x0158, 0x0158, 0x0155, 0x0155, 0x0151, 0x0151, 0x014E, 0x014E, 0x014A, 0x0147, 0x0147, 0x0144, 0x0144, 0x0141, 0x013E, 
-       0x013E, 0x013B, 0x013B, 0x0138, 0x0135, 0x0135, 0x0132, 0x012F, 0x012F, 0x012C, 0x0129, 0x0129, 0x0127, 0x0124, 0x0124, 0x0121, 
-       0x011F, 0x011F, 0x011C, 0x011A, 0x0118, 0x0118, 0x0115, 0x0113, 0x0111, 0x0111, 0x010E, 0x010C, 0x010C, 0x010A, 0x0108, 0x0106, 
-       0x0106, 0x0104, 0x0102, 0x0100, 0x00FE, 0x00FE, 0x00FC, 0x00FA, 0x00F8, 0x00F8, 0x00F6, 0x00F4, 0x00F2, 0x00F0, 0x00F0, 0x00EF, 
-       0x00ED, 0x00EB, 0x00EA, 0x00E8, 0x00E8, 0x00E6, 0x00E5, 0x00E3, 0x00E1, 0x00E1, 0x00E0, 0x00DE, 0x00DD, 0x00DB, 0x00DA, 0x00DA, 
-       0x018F, 0x018F, 0x018F, 0x018F, 0x018F, 0x018F, 0x018F, 0x018F, 0x018F, 0x018A, 0x018A, 0x018A, 0x018A, 0x018A, 0x018A, 0x018A, 
-       0x0186, 0x0186, 0x0186, 0x0186, 0x0186, 0x0181, 0x0181, 0x0181, 0x0181, 0x017D, 0x017D, 0x017D, 0x0178, 0x0178, 0x0178, 0x0174, 
-       0x0174, 0x0174, 0x0170, 0x0170, 0x016C, 0x016C, 0x016C, 0x0168, 0x0168, 0x0164, 0x0164, 0x0160, 0x0160, 0x015C, 0x015C, 0x0158, 
-       0x0158, 0x0155, 0x0155, 0x0151, 0x0151, 0x014E, 0x014E, 0x014A, 0x014A, 0x0147, 0x0147, 0x0144, 0x0141, 0x0141, 0x013E, 0x013E, 
-       0x013B, 0x0138, 0x0138, 0x0135, 0x0135, 0x0132, 0x012F, 0x012F, 0x012C, 0x0129, 0x0129, 0x0127, 0x0124, 0x0124, 0x0121, 0x011F, 
-       0x011F, 0x011C, 0x011A, 0x0118, 0x0118, 0x0115, 0x0113, 0x0113, 0x0111, 0x010E, 0x010C, 0x010C, 0x010A, 0x0108, 0x0106, 0x0106, 
-       0x0104, 0x0102, 0x0100, 0x0100, 0x00FE, 0x00FC, 0x00FA, 0x00F8, 0x00F8, 0x00F6, 0x00F4, 0x00F2, 0x00F2, 0x00F0, 0x00EF, 0x00ED, 
-       0x00EB, 0x00EB, 0x00EA, 0x00E8, 0x00E6, 0x00E5, 0x00E3, 0x00E3, 0x00E1, 0x00E0, 0x00DE, 0x00DD, 0x00DD, 0x00DB, 0x00DA, 0x00D9, 
-       0x018A, 0x018A, 0x018A, 0x018A, 0x018A, 0x018A, 0x018A, 0x018A, 0x018A, 0x0186, 0x0186, 0x0186, 0x0186, 0x0186, 0x0186, 0x0186, 
-       0x0181, 0x0181, 0x0181, 0x0181, 0x0181, 0x017D, 0x017D, 0x017D, 0x017D, 0x0178, 0x0178, 0x0178, 0x0174, 0x0174, 0x0174, 0x0170, 
-       0x0170, 0x0170, 0x016C, 0x016C, 0x016C, 0x0168, 0x0168, 0x0164, 0x0164, 0x0160, 0x0160, 0x0160, 0x015C, 0x015C, 0x0158, 0x0158, 
-       0x0155, 0x0155, 0x0151, 0x0151, 0x014E, 0x014E, 0x014A, 0x0147, 0x0147, 0x0144, 0x0144, 0x0141, 0x0141, 0x013E, 0x013B, 0x013B, 
-       0x0138, 0x0138, 0x0135, 0x0132, 0x0132, 0x012F, 0x012F, 0x012C, 0x0129, 0x0129, 0x0127, 0x0124, 0x0124, 0x0121, 0x011F, 0x011F, 
-       0x011C, 0x011A, 0x0118, 0x0118, 0x0115, 0x0113, 0x0113, 0x0111, 0x010E, 0x010C, 0x010C, 0x010A, 0x0108, 0x0106, 0x0106, 0x0104, 
-       0x0102, 0x0100, 0x0100, 0x00FE, 0x00FC, 0x00FA, 0x00FA, 0x00F8, 0x00F6, 0x00F4, 0x00F4, 0x00F2, 0x00F0, 0x00EF, 0x00ED, 0x00ED, 
-       0x00EB, 0x00EA, 0x00E8, 0x00E6, 0x00E6, 0x00E5, 0x00E3, 0x00E1, 0x00E0, 0x00DE, 0x00DE, 0x00DD, 0x00DB, 0x00DA, 0x00D9, 0x00D7, 
-       0x0186, 0x0186, 0x0186, 0x0186, 0x0186, 0x0186, 0x0186, 0x0186, 0x0186, 0x0181, 0x0181, 0x0181, 0x0181, 0x0181, 0x0181, 0x0181, 
-       0x017D, 0x017D, 0x017D, 0x017D, 0x017D, 0x0178, 0x0178, 0x0178, 0x0178, 0x0174, 0x0174, 0x0174, 0x0170, 0x0170, 0x0170, 0x016C, 
-       0x016C, 0x016C, 0x0168, 0x0168, 0x0168, 0x0164, 0x0164, 0x0160, 0x0160, 0x0160, 0x015C, 0x015C, 0x0158, 0x0158, 0x0155, 0x0155, 
-       0x0151, 0x0151, 0x014E, 0x014E, 0x014A, 0x014A, 0x0147, 0x0147, 0x0144, 0x0144, 0x0141, 0x013E, 0x013E, 0x013B, 0x013B, 0x0138, 
-       0x0135, 0x0135, 0x0132, 0x0132, 0x012F, 0x012C, 0x012C, 0x0129, 0x0127, 0x0127, 0x0124, 0x0121, 0x0121, 0x011F, 0x011C, 0x011C, 
-       0x011A, 0x0118, 0x0118, 0x0115, 0x0113, 0x0113, 0x0111, 0x010E, 0x010C, 0x010C, 0x010A, 0x0108, 0x0108, 0x0106, 0x0104, 0x0102, 
-       0x0102, 0x0100, 0x00FE, 0x00FC, 0x00FC, 0x00FA, 0x00F8, 0x00F6, 0x00F4, 0x00F4, 0x00F2, 0x00F0, 0x00EF, 0x00EF, 0x00ED, 0x00EB, 
-       0x00EA, 0x00E8, 0x00E8, 0x00E6, 0x00E5, 0x00E3, 0x00E1, 0x00E1, 0x00E0, 0x00DE, 0x00DD, 0x00DB, 0x00DA, 0x00DA, 0x00D9, 0x00D7, 
-       0x0181, 0x0181, 0x0181, 0x0181, 0x0181, 0x0181, 0x0181, 0x0181, 0x0181, 0x0181, 0x017D, 0x017D, 0x017D, 0x017D, 0x017D, 0x017D, 
-       0x017D, 0x0178, 0x0178, 0x0178, 0x0178, 0x0174, 0x0174, 0x0174, 0x0174, 0x0170, 0x0170, 0x0170, 0x0170, 0x016C, 0x016C, 0x016C, 
-       0x0168, 0x0168, 0x0164, 0x0164, 0x0164, 0x0160, 0x0160, 0x0160, 0x015C, 0x015C, 0x0158, 0x0158, 0x0155, 0x0155, 0x0151, 0x0151, 
-       0x014E, 0x014E, 0x014A, 0x014A, 0x0147, 0x0147, 0x0144, 0x0144, 0x0141, 0x0141, 0x013E, 0x013E, 0x013B, 0x0138, 0x0138, 0x0135, 
-       0x0135, 0x0132, 0x012F, 0x012F, 0x012C, 0x012C, 0x0129, 0x0127, 0x0127, 0x0124, 0x0121, 0x0121, 0x011F, 0x011C, 0x011C, 0x011A, 
-       0x0118, 0x0118, 0x0115, 0x0113, 0x0113, 0x0111, 0x010E, 0x010E, 0x010C, 0x010A, 0x0108, 0x0108, 0x0106, 0x0104, 0x0102, 0x0102, 
-       0x0100, 0x00FE, 0x00FC, 0x00FC, 0x00FA, 0x00F8, 0x00F6, 0x00F6, 0x00F4, 0x00F2, 0x00F0, 0x00F0, 0x00EF, 0x00ED, 0x00EB, 0x00EA, 
-       0x00EA, 0x00E8, 0x00E6, 0x00E5, 0x00E3, 0x00E3, 0x00E1, 0x00E0, 0x00DE, 0x00DD, 0x00DD, 0x00DB, 0x00DA, 0x00D9, 0x00D7, 0x00D6, 
-       0x017D, 0x017D, 0x017D, 0x017D, 0x017D, 0x017D, 0x017D, 0x017D, 0x017D, 0x017D, 0x0178, 0x0178, 0x0178, 0x0178, 0x0178, 0x0178, 
-       0x0178, 0x0174, 0x0174, 0x0174, 0x0174, 0x0170, 0x0170, 0x0170, 0x0170, 0x016C, 0x016C, 0x016C, 0x016C, 0x0168, 0x0168, 0x0168, 
-       0x0164, 0x0164, 0x0164, 0x0160, 0x0160, 0x015C, 0x015C, 0x015C, 0x0158, 0x0158, 0x0155, 0x0155, 0x0151, 0x0151, 0x0151, 0x014E, 
-       0x014E, 0x014A, 0x014A, 0x0147, 0x0147, 0x0144, 0x0144, 0x0141, 0x013E, 0x013E, 0x013B, 0x013B, 0x0138, 0x0138, 0x0135, 0x0132, 
-       0x0132, 0x012F, 0x012F, 0x012C, 0x0129, 0x0129, 0x0127, 0x0127, 0x0124, 0x0121, 0x0121, 0x011F, 0x011C, 0x011C, 0x011A, 0x0118, 
-       0x0118, 0x0115, 0x0113, 0x0113, 0x0111, 0x010E, 0x010E, 0x010C, 0x010A, 0x0108, 0x0108, 0x0106, 0x0104, 0x0102, 0x0102, 0x0100, 
-       0x00FE, 0x00FE, 0x00FC, 0x00FA, 0x00F8, 0x00F8, 0x00F6, 0x00F4, 0x00F2, 0x00F0, 0x00F0, 0x00EF, 0x00ED, 0x00EB, 0x00EB, 0x00EA, 
-       0x00E8, 0x00E6, 0x00E5, 0x00E5, 0x00E3, 0x00E1, 0x00E0, 0x00DE, 0x00DE, 0x00DD, 0x00DB, 0x00DA, 0x00D9, 0x00D7, 0x00D7, 0x00D6, 
-       0x0178, 0x0178, 0x0178, 0x0178, 0x0178, 0x0178, 0x0178, 0x0178, 0x0178, 0x0178, 0x0174, 0x0174, 0x0174, 0x0174, 0x0174, 0x0174, 
-       0x0174, 0x0170, 0x0170, 0x0170, 0x0170, 0x0170, 0x016C, 0x016C, 0x016C, 0x016C, 0x0168, 0x0168, 0x0168, 0x0164, 0x0164, 0x0164, 
-       0x0160, 0x0160, 0x0160, 0x015C, 0x015C, 0x015C, 0x0158, 0x0158, 0x0155, 0x0155, 0x0151, 0x0151, 0x0151, 0x014E, 0x014E, 0x014A, 
-       0x014A, 0x0147, 0x0147, 0x0144, 0x0144, 0x0141, 0x0141, 0x013E, 0x013E, 0x013B, 0x013B, 0x0138, 0x0135, 0x0135, 0x0132, 0x0132, 
-       0x012F, 0x012F, 0x012C, 0x0129, 0x0129, 0x0127, 0x0124, 0x0124, 0x0121, 0x0121, 0x011F, 0x011C, 0x011C, 0x011A, 0x0118, 0x0118, 
-       0x0115, 0x0113, 0x0113, 0x0111, 0x010E, 0x010E, 0x010C, 0x010A, 0x0108, 0x0108, 0x0106, 0x0104, 0x0104, 0x0102, 0x0100, 0x00FE, 
-       0x00FE, 0x00FC, 0x00FA, 0x00F8, 0x00F8, 0x00F6, 0x00F4, 0x00F2, 0x00F2, 0x00F0, 0x00EF, 0x00ED, 0x00ED, 0x00EB, 0x00EA, 0x00E8, 
-       0x00E6, 0x00E6, 0x00E5, 0x00E3, 0x00E1, 0x00E0, 0x00E0, 0x00DE, 0x00DD, 0x00DB, 0x00DA, 0x00DA, 0x00D9, 0x00D7, 0x00D6, 0x00D4, 
-       0x0174, 0x0174, 0x0174, 0x0174, 0x0174, 0x0174, 0x0174, 0x0174, 0x0174, 0x0174, 0x0170, 0x0170, 0x0170, 0x0170, 0x0170, 0x0170, 
-       0x0170, 0x016C, 0x016C, 0x016C, 0x016C, 0x016C, 0x0168, 0x0168, 0x0168, 0x0168, 0x0164, 0x0164, 0x0164, 0x0160, 0x0160, 0x0160, 
-       0x015C, 0x015C, 0x015C, 0x0158, 0x0158, 0x0158, 0x0155, 0x0155, 0x0151, 0x0151, 0x0151, 0x014E, 0x014E, 0x014A, 0x014A, 0x0147, 
-       0x0147, 0x0144, 0x0144, 0x0141, 0x0141, 0x013E, 0x013E, 0x013B, 0x013B, 0x0138, 0x0138, 0x0135, 0x0135, 0x0132, 0x012F, 0x012F, 
-       0x012C, 0x012C, 0x0129, 0x0129, 0x0127, 0x0124, 0x0124, 0x0121, 0x011F, 0x011F, 0x011C, 0x011C, 0x011A, 0x0118, 0x0118, 0x0115, 
-       0x0113, 0x0113, 0x0111, 0x010E, 0x010E, 0x010C, 0x010A, 0x0108, 0x0108, 0x0106, 0x0104, 0x0104, 0x0102, 0x0100, 0x00FE, 0x00FE, 
-       0x00FC, 0x00FA, 0x00F8, 0x00F8, 0x00F6, 0x00F4, 0x00F2, 0x00F2, 0x00F0, 0x00EF, 0x00ED, 0x00ED, 0x00EB, 0x00EA, 0x00E8, 0x00E8, 
-       0x00E6, 0x00E5, 0x00E3, 0x00E1, 0x00E1, 0x00E0, 0x00DE, 0x00DD, 0x00DB, 0x00DB, 0x00DA, 0x00D9, 0x00D7, 0x00D6, 0x00D6, 0x00D4, 
-       0x0170, 0x0170, 0x0170, 0x0170, 0x0170, 0x0170, 0x0170, 0x0170, 0x0170, 0x0170, 0x016C, 0x016C, 0x016C, 0x016C, 0x016C, 0x016C, 
-       0x016C, 0x0168, 0x0168, 0x0168, 0x0168, 0x0168, 0x0164, 0x0164, 0x0164, 0x0164, 0x0160, 0x0160, 0x0160, 0x015C, 0x015C, 0x015C, 
-       0x015C, 0x0158, 0x0158, 0x0155, 0x0155, 0x0155, 0x0151, 0x0151, 0x0151, 0x014E, 0x014E, 0x014A, 0x014A, 0x0147, 0x0147, 0x0144, 
-       0x0144, 0x0144, 0x0141, 0x0141, 0x013E, 0x013E, 0x013B, 0x0138, 0x0138, 0x0135, 0x0135, 0x0132, 0x0132, 0x012F, 0x012F, 0x012C, 
-       0x012C, 0x0129, 0x0127, 0x0127, 0x0124, 0x0124, 0x0121, 0x011F, 0x011F, 0x011C, 0x011A, 0x011A, 0x0118, 0x0115, 0x0115, 0x0113, 
-       0x0111, 0x0111, 0x010E, 0x010C, 0x010C, 0x010A, 0x0108, 0x0108, 0x0106, 0x0104, 0x0104, 0x0102, 0x0100, 0x00FE, 0x00FE, 0x00FC, 
-       0x00FA, 0x00FA, 0x00F8, 0x00F6, 0x00F4, 0x00F4, 0x00F2, 0x00F0, 0x00EF, 0x00EF, 0x00ED, 0x00EB, 0x00EA, 0x00E8, 0x00E8, 0x00E6, 
-       0x00E5, 0x00E3, 0x00E3, 0x00E1, 0x00E0, 0x00DE, 0x00DD, 0x00DD, 0x00DB, 0x00DA, 0x00D9, 0x00D7, 0x00D7, 0x00D6, 0x00D4, 0x00D3, 
-       0x016C, 0x016C, 0x016C, 0x016C, 0x016C, 0x016C, 0x016C, 0x016C, 0x016C, 0x016C, 0x016C, 0x0168, 0x0168, 0x0168, 0x0168, 0x0168, 
-       0x0168, 0x0164, 0x0164, 0x0164, 0x0164, 0x0164, 0x0160, 0x0160, 0x0160, 0x0160, 0x015C, 0x015C, 0x015C, 0x015C, 0x0158, 0x0158, 
-       0x0158, 0x0155, 0x0155, 0x0155, 0x0151, 0x0151, 0x014E, 0x014E, 0x014E, 0x014A, 0x014A, 0x0147, 0x0147, 0x0144, 0x0144, 0x0144, 
-       0x0141, 0x0141, 0x013E, 0x013E, 0x013B, 0x013B, 0x0138, 0x0138, 0x0135, 0x0135, 0x0132, 0x0132, 0x012F, 0x012C, 0x012C, 0x0129, 
-       0x0129, 0x0127, 0x0127, 0x0124, 0x0121, 0x0121, 0x011F, 0x011F, 0x011C, 0x011A, 0x011A, 0x0118, 0x0115, 0x0115, 0x0113, 0x0111, 
-       0x0111, 0x010E, 0x010C, 0x010C, 0x010A, 0x0108, 0x0108, 0x0106, 0x0104, 0x0104, 0x0102, 0x0100, 0x00FE, 0x00FE, 0x00FC, 0x00FA, 
-       0x00FA, 0x00F8, 0x00F6, 0x00F4, 0x00F4, 0x00F2, 0x00F0, 0x00EF, 0x00EF, 0x00ED, 0x00EB, 0x00EA, 0x00EA, 0x00E8, 0x00E6, 0x00E5, 
-       0x00E5, 0x00E3, 0x00E1, 0x00E0, 0x00DE, 0x00DE, 0x00DD, 0x00DB, 0x00DA, 0x00D9, 0x00D9, 0x00D7, 0x00D6, 0x00D4, 0x00D3, 0x00D3, 
-       0x0168, 0x0168, 0x0168, 0x0168, 0x0168, 0x0168, 0x0168, 0x0168, 0x0168, 0x0168, 0x0168, 0x0164, 0x0164, 0x0164, 0x0164, 0x0164, 
-       0x0164, 0x0164, 0x0160, 0x0160, 0x0160, 0x0160, 0x015C, 0x015C, 0x015C, 0x015C, 0x0158, 0x0158, 0x0158, 0x0158, 0x0155, 0x0155, 
-       0x0155, 0x0151, 0x0151, 0x0151, 0x014E, 0x014E, 0x014E, 0x014A, 0x014A, 0x0147, 0x0147, 0x0144, 0x0144, 0x0144, 0x0141, 0x0141, 
-       0x013E, 0x013E, 0x013B, 0x013B, 0x0138, 0x0138, 0x0135, 0x0135, 0x0132, 0x0132, 0x012F, 0x012F, 0x012C, 0x012C, 0x0129, 0x0127, 
-       0x0127, 0x0124, 0x0124, 0x0121, 0x0121, 0x011F, 0x011C, 0x011C, 0x011A, 0x011A, 0x0118, 0x0115, 0x0115, 0x0113, 0x0111, 0x0111, 
-       0x010E, 0x010C, 0x010C, 0x010A, 0x0108, 0x0108, 0x0106, 0x0104, 0x0104, 0x0102, 0x0100, 0x0100, 0x00FE, 0x00FC, 0x00FA, 0x00FA, 
-       0x00F8, 0x00F6, 0x00F4, 0x00F4, 0x00F2, 0x00F0, 0x00F0, 0x00EF, 0x00ED, 0x00EB, 0x00EB, 0x00EA, 0x00E8, 0x00E6, 0x00E5, 0x00E5, 
-       0x00E3, 0x00E1, 0x00E0, 0x00E0, 0x00DE, 0x00DD, 0x00DB, 0x00DA, 0x00DA, 0x00D9, 0x00D7, 0x00D6, 0x00D4, 0x00D4, 0x00D3, 0x00D2, 
-       0x0164, 0x0164, 0x0164, 0x0164, 0x0164, 0x0164, 0x0164, 0x0164, 0x0164, 0x0164, 0x0164, 0x0160, 0x0160, 0x0160, 0x0160, 0x0160, 
-       0x0160, 0x0160, 0x015C, 0x015C, 0x015C, 0x015C, 0x015C, 0x0158, 0x0158, 0x0158, 0x0158, 0x0155, 0x0155, 0x0155, 0x0151, 0x0151, 
-       0x0151, 0x014E, 0x014E, 0x014E, 0x014A, 0x014A, 0x014A, 0x0147, 0x0147, 0x0144, 0x0144, 0x0144, 0x0141, 0x0141, 0x013E, 0x013E, 
-       0x013B, 0x013B, 0x0138, 0x0138, 0x0135, 0x0135, 0x0132, 0x0132, 0x012F, 0x012F, 0x012C, 0x012C, 0x0129, 0x0129, 0x0127, 0x0127, 
-       0x0124, 0x0124, 0x0121, 0x011F, 0x011F, 0x011C, 0x011C, 0x011A, 0x0118, 0x0118, 0x0115, 0x0113, 0x0113, 0x0111, 0x0111, 0x010E, 
-       0x010C, 0x010C, 0x010A, 0x0108, 0x0108, 0x0106, 0x0104, 0x0104, 0x0102, 0x0100, 0x0100, 0x00FE, 0x00FC, 0x00FA, 0x00FA, 0x00F8, 
-       0x00F6, 0x00F6, 0x00F4, 0x00F2, 0x00F0, 0x00F0, 0x00EF, 0x00ED, 0x00EB, 0x00EB, 0x00EA, 0x00E8, 0x00E6, 0x00E6, 0x00E5, 0x00E3, 
-       0x00E1, 0x00E1, 0x00E0, 0x00DE, 0x00DD, 0x00DB, 0x00DB, 0x00DA, 0x00D9, 0x00D7, 0x00D6, 0x00D6, 0x00D4, 0x00D3, 0x00D2, 0x00D0, 
-       0x0160, 0x0160, 0x0160, 0x0160, 0x0160, 0x0160, 0x0160, 0x0160, 0x0160, 0x0160, 0x0160, 0x015C, 0x015C, 0x015C, 0x015C, 0x015C, 
-       0x015C, 0x015C, 0x0158, 0x0158, 0x0158, 0x0158, 0x0158, 0x0155, 0x0155, 0x0155, 0x0155, 0x0151, 0x0151, 0x0151, 0x014E, 0x014E, 
-       0x014E, 0x014A, 0x014A, 0x014A, 0x0147, 0x0147, 0x0147, 0x0144, 0x0144, 0x0144, 0x0141, 0x0141, 0x013E, 0x013E, 0x013B, 0x013B, 
-       0x013B, 0x0138, 0x0138, 0x0135, 0x0135, 0x0132, 0x0132, 0x012F, 0x012F, 0x012C, 0x012C, 0x0129, 0x0129, 0x0127, 0x0124, 0x0124, 
-       0x0121, 0x0121, 0x011F, 0x011F, 0x011C, 0x011A, 0x011A, 0x0118, 0x0118, 0x0115, 0x0113, 0x0113, 0x0111, 0x010E, 0x010E, 0x010C, 
-       0x010C, 0x010A, 0x0108, 0x0108, 0x0106, 0x0104, 0x0104, 0x0102, 0x0100, 0x00FE, 0x00FE, 0x00FC, 0x00FA, 0x00FA, 0x00F8, 0x00F6, 
-       0x00F6, 0x00F4, 0x00F2, 0x00F0, 0x00F0, 0x00EF, 0x00ED, 0x00EB, 0x00EB, 0x00EA, 0x00E8, 0x00E6, 0x00E6, 0x00E5, 0x00E3, 0x00E1, 
-       0x00E1, 0x00E0, 0x00DE, 0x00DD, 0x00DD, 0x00DB, 0x00DA, 0x00D9, 0x00D7, 0x00D7, 0x00D6, 0x00D4, 0x00D3, 0x00D2, 0x00D2, 0x00D0, 
-       0x015C, 0x015C, 0x015C, 0x015C, 0x015C, 0x015C, 0x015C, 0x015C, 0x015C, 0x015C, 0x015C, 0x0158, 0x0158, 0x0158, 0x0158, 0x0158, 
-       0x0158, 0x0158, 0x0155, 0x0155, 0x0155, 0x0155, 0x0155, 0x0151, 0x0151, 0x0151, 0x0151, 0x014E, 0x014E, 0x014E, 0x014A, 0x014A, 
-       0x014A, 0x014A, 0x0147, 0x0147, 0x0144, 0x0144, 0x0144, 0x0141, 0x0141, 0x0141, 0x013E, 0x013E, 0x013B, 0x013B, 0x013B, 0x0138, 
-       0x0138, 0x0135, 0x0135, 0x0132, 0x0132, 0x012F, 0x012F, 0x012C, 0x012C, 0x0129, 0x0129, 0x0127, 0x0127, 0x0124, 0x0124, 0x0121, 
-       0x011F, 0x011F, 0x011C, 0x011C, 0x011A, 0x011A, 0x0118, 0x0115, 0x0115, 0x0113, 0x0113, 0x0111, 0x010E, 0x010E, 0x010C, 0x010A, 
-       0x010A, 0x0108, 0x0106, 0x0106, 0x0104, 0x0102, 0x0102, 0x0100, 0x00FE, 0x00FE, 0x00FC, 0x00FA, 0x00FA, 0x00F8, 0x00F6, 0x00F6, 
-       0x00F4, 0x00F2, 0x00F0, 0x00F0, 0x00EF, 0x00ED, 0x00ED, 0x00EB, 0x00EA, 0x00E8, 0x00E8, 0x00E6, 0x00E5, 0x00E3, 0x00E3, 0x00E1, 
-       0x00E0, 0x00DE, 0x00DE, 0x00DD, 0x00DB, 0x00DA, 0x00D9, 0x00D9, 0x00D7, 0x00D6, 0x00D4, 0x00D3, 0x00D3, 0x00D2, 0x00D0, 0x00CF, 
-       0x0158, 0x0158, 0x0158, 0x0158, 0x0158, 0x0158, 0x0158, 0x0158, 0x0158, 0x0158, 0x0158, 0x0158, 0x0155, 0x0155, 0x0155, 0x0155, 
-       0x0155, 0x0155, 0x0151, 0x0151, 0x0151, 0x0151, 0x0151, 0x014E, 0x014E, 0x014E, 0x014E, 0x014A, 0x014A, 0x014A, 0x014A, 0x0147, 
-       0x0147, 0x0147, 0x0144, 0x0144, 0x0144, 0x0141, 0x0141, 0x013E, 0x013E, 0x013E, 0x013B, 0x013B, 0x0138, 0x0138, 0x0138, 0x0135, 
-       0x0135, 0x0132, 0x0132, 0x012F, 0x012F, 0x012C, 0x012C, 0x0129, 0x0129, 0x0127, 0x0127, 0x0124, 0x0124, 0x0121, 0x0121, 0x011F, 
-       0x011F, 0x011C, 0x011C, 0x011A, 0x0118, 0x0118, 0x0115, 0x0115, 0x0113, 0x0111, 0x0111, 0x010E, 0x010E, 0x010C, 0x010A, 0x010A, 
-       0x0108, 0x0106, 0x0106, 0x0104, 0x0102, 0x0102, 0x0100, 0x00FE, 0x00FE, 0x00FC, 0x00FA, 0x00FA, 0x00F8, 0x00F6, 0x00F6, 0x00F4, 
-       0x00F2, 0x00F0, 0x00F0, 0x00EF, 0x00ED, 0x00ED, 0x00EB, 0x00EA, 0x00E8, 0x00E8, 0x00E6, 0x00E5, 0x00E3, 0x00E3, 0x00E1, 0x00E0, 
-       0x00DE, 0x00DE, 0x00DD, 0x00DB, 0x00DA, 0x00DA, 0x00D9, 0x00D7, 0x00D6, 0x00D4, 0x00D4, 0x00D3, 0x00D2, 0x00D0, 0x00CF, 0x00CF, 
-       0x0155, 0x0155, 0x0155, 0x0155, 0x0155, 0x0155, 0x0155, 0x0155, 0x0155, 0x0155, 0x0155, 0x0155, 0x0151, 0x0151, 0x0151, 0x0151, 
-       0x0151, 0x0151, 0x014E, 0x014E, 0x014E, 0x014E, 0x014E, 0x014A, 0x014A, 0x014A, 0x014A, 0x0147, 0x0147, 0x0147, 0x0147, 0x0144, 
-       0x0144, 0x0144, 0x0141, 0x0141, 0x0141, 0x013E, 0x013E, 0x013E, 0x013B, 0x013B, 0x0138, 0x0138, 0x0138, 0x0135, 0x0135, 0x0132, 
-       0x0132, 0x012F, 0x012F, 0x012C, 0x012C, 0x012C, 0x0129, 0x0129, 0x0127, 0x0127, 0x0124, 0x0124, 0x0121, 0x011F, 0x011F, 0x011C, 
-       0x011C, 0x011A, 0x011A, 0x0118, 0x0118, 0x0115, 0x0113, 0x0113, 0x0111, 0x0111, 0x010E, 0x010C, 0x010C, 0x010A, 0x010A, 0x0108, 
-       0x0106, 0x0106, 0x0104, 0x0102, 0x0102, 0x0100, 0x00FE, 0x00FE, 0x00FC, 0x00FA, 0x00FA, 0x00F8, 0x00F6, 0x00F6, 0x00F4, 0x00F2, 
-       0x00F0, 0x00F0, 0x00EF, 0x00ED, 0x00ED, 0x00EB, 0x00EA, 0x00E8, 0x00E8, 0x00E6, 0x00E5, 0x00E5, 0x00E3, 0x00E1, 0x00E0, 0x00E0, 
-       0x00DE, 0x00DD, 0x00DB, 0x00DA, 0x00DA, 0x00D9, 0x00D7, 0x00D6, 0x00D6, 0x00D4, 0x00D3, 0x00D2, 0x00D0, 0x00D0, 0x00CF, 0x00CE, 
-       0x0151, 0x0151, 0x0151, 0x0151, 0x0151, 0x0151, 0x0151, 0x0151, 0x0151, 0x0151, 0x0151, 0x0151, 0x014E, 0x014E, 0x014E, 0x014E, 
-       0x014E, 0x014E, 0x014E, 0x014A, 0x014A, 0x014A, 0x014A, 0x0147, 0x0147, 0x0147, 0x0147, 0x0144, 0x0144, 0x0144, 0x0144, 0x0141, 
-       0x0141, 0x0141, 0x013E, 0x013E, 0x013E, 0x013B, 0x013B, 0x013B, 0x0138, 0x0138, 0x0135, 0x0135, 0x0135, 0x0132, 0x0132, 0x012F, 
-       0x012F, 0x012F, 0x012C, 0x012C, 0x0129, 0x0129, 0x0127, 0x0127, 0x0124, 0x0124, 0x0121, 0x0121, 0x011F, 0x011F, 0x011C, 0x011C, 
-       0x011A, 0x0118, 0x0118, 0x0115, 0x0115, 0x0113, 0x0113, 0x0111, 0x010E, 0x010E, 0x010C, 0x010C, 0x010A, 0x0108, 0x0108, 0x0106, 
-       0x0106, 0x0104, 0x0102, 0x0102, 0x0100, 0x00FE, 0x00FE, 0x00FC, 0x00FA, 0x00FA, 0x00F8, 0x00F6, 0x00F6, 0x00F4, 0x00F2, 0x00F0, 
-       0x00F0, 0x00EF, 0x00ED, 0x00ED, 0x00EB, 0x00EA, 0x00EA, 0x00E8, 0x00E6, 0x00E5, 0x00E5, 0x00E3, 0x00E1, 0x00E0, 0x00E0, 0x00DE, 
-       0x00DD, 0x00DB, 0x00DB, 0x00DA, 0x00D9, 0x00D7, 0x00D7, 0x00D6, 0x00D4, 0x00D3, 0x00D2, 0x00D2, 0x00D0, 0x00CF, 0x00CE, 0x00CC, 
-       0x014E, 0x014E, 0x014E, 0x014E, 0x014E, 0x014E, 0x014E, 0x014E, 0x014E, 0x014E, 0x014E, 0x014E, 0x014A, 0x014A, 0x014A, 0x014A, 
-       0x014A, 0x014A, 0x014A, 0x0147, 0x0147, 0x0147, 0x0147, 0x0147, 0x0144, 0x0144, 0x0144, 0x0144, 0x0141, 0x0141, 0x0141, 0x013E, 
-       0x013E, 0x013E, 0x013B, 0x013B, 0x013B, 0x0138, 0x0138, 0x0138, 0x0135, 0x0135, 0x0135, 0x0132, 0x0132, 0x012F, 0x012F, 0x012F, 
-       0x012C, 0x012C, 0x0129, 0x0129, 0x0127, 0x0127, 0x0124, 0x0124, 0x0121, 0x0121, 0x011F, 0x011F, 0x011C, 0x011C, 0x011A, 0x011A, 
-       0x0118, 0x0118, 0x0115, 0x0115, 0x0113, 0x0111, 0x0111, 0x010E, 0x010E, 0x010C, 0x010A, 0x010A, 0x0108, 0x0108, 0x0106, 0x0104, 
-       0x0104, 0x0102, 0x0100, 0x0100, 0x00FE, 0x00FE, 0x00FC, 0x00FA, 0x00FA, 0x00F8, 0x00F6, 0x00F6, 0x00F4, 0x00F2, 0x00F0, 0x00F0, 
-       0x00EF, 0x00ED, 0x00ED, 0x00EB, 0x00EA, 0x00EA, 0x00E8, 0x00E6, 0x00E5, 0x00E5, 0x00E3, 0x00E1, 0x00E0, 0x00E0, 0x00DE, 0x00DD, 
-       0x00DB, 0x00DB, 0x00DA, 0x00D9, 0x00D7, 0x00D7, 0x00D6, 0x00D4, 0x00D3, 0x00D3, 0x00D2, 0x00D0, 0x00CF, 0x00CE, 0x00CE, 0x00CC, 
-       0x014A, 0x014A, 0x014A, 0x014A, 0x014A, 0x014A, 0x014A, 0x014A, 0x014A, 0x014A, 0x014A, 0x014A, 0x0147, 0x0147, 0x0147, 0x0147, 
-       0x0147, 0x0147, 0x0147, 0x0144, 0x0144, 0x0144, 0x0144, 0x0144, 0x0141, 0x0141, 0x0141, 0x0141, 0x013E, 0x013E, 0x013E, 0x013B, 
-       0x013B, 0x013B, 0x013B, 0x0138, 0x0138, 0x0138, 0x0135, 0x0135, 0x0132, 0x0132, 0x0132, 0x012F, 0x012F, 0x012C, 0x012C, 0x012C, 
-       0x0129, 0x0129, 0x0127, 0x0127, 0x0124, 0x0124, 0x0121, 0x0121, 0x011F, 0x011F, 0x011F, 0x011C, 0x011A, 0x011A, 0x0118, 0x0118, 
-       0x0115, 0x0115, 0x0113, 0x0113, 0x0111, 0x0111, 0x010E, 0x010C, 0x010C, 0x010A, 0x010A, 0x0108, 0x0106, 0x0106, 0x0104, 0x0104, 
-       0x0102, 0x0100, 0x0100, 0x00FE, 0x00FC, 0x00FC, 0x00FA, 0x00F8, 0x00F8, 0x00F6, 0x00F4, 0x00F4, 0x00F2, 0x00F0, 0x00F0, 0x00EF, 
-       0x00ED, 0x00ED, 0x00EB, 0x00EA, 0x00EA, 0x00E8, 0x00E6, 0x00E5, 0x00E5, 0x00E3, 0x00E1, 0x00E1, 0x00E0, 0x00DE, 0x00DD, 0x00DD, 
-       0x00DB, 0x00DA, 0x00D9, 0x00D9, 0x00D7, 0x00D6, 0x00D4, 0x00D4, 0x00D3, 0x00D2, 0x00D0, 0x00CF, 0x00CF, 0x00CE, 0x00CC, 0x00CB, 
-       0x0147, 0x0147, 0x0147, 0x0147, 0x0147, 0x0147, 0x0147, 0x0147, 0x0147, 0x0147, 0x0147, 0x0147, 0x0144, 0x0144, 0x0144, 0x0144, 
-       0x0144, 0x0144, 0x0144, 0x0141, 0x0141, 0x0141, 0x0141, 0x0141, 0x013E, 0x013E, 0x013E, 0x013E, 0x013B, 0x013B, 0x013B, 0x013B, 
-       0x0138, 0x0138, 0x0138, 0x0135, 0x0135, 0x0135, 0x0132, 0x0132, 0x0132, 0x012F, 0x012F, 0x012C, 0x012C, 0x012C, 0x0129, 0x0129, 
-       0x0127, 0x0127, 0x0124, 0x0124, 0x0124, 0x0121, 0x0121, 0x011F, 0x011F, 0x011C, 0x011C, 0x011A, 0x011A, 0x0118, 0x0118, 0x0115, 
-       0x0115, 0x0113, 0x0111, 0x0111, 0x010E, 0x010E, 0x010C, 0x010C, 0x010A, 0x0108, 0x0108, 0x0106, 0x0106, 0x0104, 0x0102, 0x0102, 
-       0x0100, 0x0100, 0x00FE, 0x00FC, 0x00FC, 0x00FA, 0x00F8, 0x00F8, 0x00F6, 0x00F4, 0x00F4, 0x00F2, 0x00F0, 0x00F0, 0x00EF, 0x00ED, 
-       0x00ED, 0x00EB, 0x00EA, 0x00EA, 0x00E8, 0x00E6, 0x00E5, 0x00E5, 0x00E3, 0x00E1, 0x00E1, 0x00E0, 0x00DE, 0x00DD, 0x00DD, 0x00DB, 
-       0x00DA, 0x00D9, 0x00D9, 0x00D7, 0x00D6, 0x00D4, 0x00D4, 0x00D3, 0x00D2, 0x00D0, 0x00D0, 0x00CF, 0x00CE, 0x00CC, 0x00CB, 0x00CB, 
-       0x0144, 0x0144, 0x0144, 0x0144, 0x0144, 0x0144, 0x0144, 0x0144, 0x0144, 0x0144, 0x0144, 0x0144, 0x0144, 0x0141, 0x0141, 0x0141, 
-       0x0141, 0x0141, 0x0141, 0x013E, 0x013E, 0x013E, 0x013E, 0x013E, 0x013B, 0x013B, 0x013B, 0x013B, 0x0138, 0x0138, 0x0138, 0x0138, 
-       0x0135, 0x0135, 0x0135, 0x0132, 0x0132, 0x0132, 0x012F, 0x012F, 0x012F, 0x012C, 0x012C, 0x0129, 0x0129, 0x0129, 0x0127, 0x0127, 
-       0x0124, 0x0124, 0x0124, 0x0121, 0x0121, 0x011F, 0x011F, 0x011C, 0x011C, 0x011A, 0x011A, 0x0118, 0x0118, 0x0115, 0x0115, 0x0113, 
-       0x0113, 0x0111, 0x0111, 0x010E, 0x010E, 0x010C, 0x010A, 0x010A, 0x0108, 0x0108, 0x0106, 0x0104, 0x0104, 0x0102, 0x0102, 0x0100, 
-       0x00FE, 0x00FE, 0x00FC, 0x00FC, 0x00FA, 0x00F8, 0x00F8, 0x00F6, 0x00F4, 0x00F4, 0x00F2, 0x00F0, 0x00F0, 0x00EF, 0x00ED, 0x00ED, 
-       0x00EB, 0x00EA, 0x00EA, 0x00E8, 0x00E6, 0x00E5, 0x00E5, 0x00E3, 0x00E1, 0x00E1, 0x00E0, 0x00DE, 0x00DD, 0x00DD, 0x00DB, 0x00DA, 
-       0x00DA, 0x00D9, 0x00D7, 0x00D6, 0x00D6, 0x00D4, 0x00D3, 0x00D2, 0x00D0, 0x00D0, 0x00CF, 0x00CE, 0x00CC, 0x00CC, 0x00CB, 0x00CA, 
-       0x0141, 0x0141, 0x0141, 0x0141, 0x0141, 0x0141, 0x0141, 0x0141, 0x0141, 0x0141, 0x0141, 0x0141, 0x0141, 0x013E, 0x013E, 0x013E, 
-       0x013E, 0x013E, 0x013E, 0x013B, 0x013B, 0x013B, 0x013B, 0x013B, 0x0138, 0x0138, 0x0138, 0x0138, 0x0135, 0x0135, 0x0135, 0x0135, 
-       0x0132, 0x0132, 0x0132, 0x012F, 0x012F, 0x012F, 0x012C, 0x012C, 0x012C, 0x0129, 0x0129, 0x0129, 0x0127, 0x0127, 0x0124, 0x0124, 
-       0x0124, 0x0121, 0x0121, 0x011F, 0x011F, 0x011C, 0x011C, 0x011A, 0x011A, 0x0118, 0x0118, 0x0115, 0x0115, 0x0113, 0x0113, 0x0111, 
-       0x0111, 0x010E, 0x010E, 0x010C, 0x010C, 0x010A, 0x010A, 0x0108, 0x0106, 0x0106, 0x0104, 0x0104, 0x0102, 0x0100, 0x0100, 0x00FE, 
-       0x00FE, 0x00FC, 0x00FA, 0x00FA, 0x00F8, 0x00F8, 0x00F6, 0x00F4, 0x00F4, 0x00F2, 0x00F0, 0x00F0, 0x00EF, 0x00ED, 0x00ED, 0x00EB, 
-       0x00EA, 0x00EA, 0x00E8, 0x00E6, 0x00E5, 0x00E5, 0x00E3, 0x00E1, 0x00E1, 0x00E0, 0x00DE, 0x00DD, 0x00DD, 0x00DB, 0x00DA, 0x00DA, 
-       0x00D9, 0x00D7, 0x00D6, 0x00D6, 0x00D4, 0x00D3, 0x00D2, 0x00D2, 0x00D0, 0x00CF, 0x00CE, 0x00CE, 0x00CC, 0x00CB, 0x00CA, 0x00C9, 
-       0x013E, 0x013E, 0x013E, 0x013E, 0x013E, 0x013E, 0x013E, 0x013E, 0x013E, 0x013E, 0x013E, 0x013E, 0x013E, 0x013B, 0x013B, 0x013B, 
-       0x013B, 0x013B, 0x013B, 0x013B, 0x0138, 0x0138, 0x0138, 0x0138, 0x0135, 0x0135, 0x0135, 0x0135, 0x0135, 0x0132, 0x0132, 0x0132, 
-       0x012F, 0x012F, 0x012F, 0x012C, 0x012C, 0x012C, 0x0129, 0x0129, 0x0129, 0x0127, 0x0127, 0x0127, 0x0124, 0x0124, 0x0121, 0x0121, 
-       0x0121, 0x011F, 0x011F, 0x011C, 0x011C, 0x011A, 0x011A, 0x011A, 0x0118, 0x0118, 0x0115, 0x0115, 0x0113, 0x0113, 0x0111, 0x0111, 
-       0x010E, 0x010C, 0x010C, 0x010A, 0x010A, 0x0108, 0x0108, 0x0106, 0x0106, 0x0104, 0x0102, 0x0102, 0x0100, 0x0100, 0x00FE, 0x00FC, 
-       0x00FC, 0x00FA, 0x00FA, 0x00F8, 0x00F6, 0x00F6, 0x00F4, 0x00F2, 0x00F2, 0x00F0, 0x00F0, 0x00EF, 0x00ED, 0x00ED, 0x00EB, 0x00EA, 
-       0x00EA, 0x00E8, 0x00E6, 0x00E5, 0x00E5, 0x00E3, 0x00E1, 0x00E1, 0x00E0, 0x00DE, 0x00DE, 0x00DD, 0x00DB, 0x00DA, 0x00DA, 0x00D9, 
-       0x00D7, 0x00D6, 0x00D6, 0x00D4, 0x00D3, 0x00D2, 0x00D2, 0x00D0, 0x00CF, 0x00CE, 0x00CE, 0x00CC, 0x00CB, 0x00CA, 0x00CA, 0x00C9, 
-       0x013B, 0x013B, 0x013B, 0x013B, 0x013B, 0x013B, 0x013B, 0x013B, 0x013B, 0x013B, 0x013B, 0x013B, 0x013B, 0x0138, 0x0138, 0x0138, 
-       0x0138, 0x0138, 0x0138, 0x0138, 0x0135, 0x0135, 0x0135, 0x0135, 0x0135, 0x0132, 0x0132, 0x0132, 0x0132, 0x012F, 0x012F, 0x012F, 
-       0x012C, 0x012C, 0x012C, 0x012C, 0x0129, 0x0129, 0x0129, 0x0127, 0x0127, 0x0124, 0x0124, 0x0124, 0x0121, 0x0121, 0x0121, 0x011F, 
-       0x011F, 0x011C, 0x011C, 0x011A, 0x011A, 0x011A, 0x0118, 0x0118, 0x0115, 0x0115, 0x0113, 0x0113, 0x0111, 0x0111, 0x010E, 0x010E, 
-       0x010C, 0x010C, 0x010A, 0x010A, 0x0108, 0x0106, 0x0106, 0x0104, 0x0104, 0x0102, 0x0102, 0x0100, 0x00FE, 0x00FE, 0x00FC, 0x00FC, 
-       0x00FA, 0x00F8, 0x00F8, 0x00F6, 0x00F6, 0x00F4, 0x00F2, 0x00F2, 0x00F0, 0x00EF, 0x00EF, 0x00ED, 0x00EB, 0x00EB, 0x00EA, 0x00E8, 
-       0x00E8, 0x00E6, 0x00E5, 0x00E5, 0x00E3, 0x00E1, 0x00E1, 0x00E0, 0x00DE, 0x00DE, 0x00DD, 0x00DB, 0x00DA, 0x00DA, 0x00D9, 0x00D7, 
-       0x00D6, 0x00D6, 0x00D4, 0x00D3, 0x00D3, 0x00D2, 0x00D0, 0x00CF, 0x00CF, 0x00CE, 0x00CC, 0x00CB, 0x00CB, 0x00CA, 0x00C9, 0x00C7, 
-       0x0138, 0x0138, 0x0138, 0x0138, 0x0138, 0x0138, 0x0138, 0x0138, 0x0138, 0x0138, 0x0138, 0x0138, 0x0138, 0x0135, 0x0135, 0x0135, 
-       0x0135, 0x0135, 0x0135, 0x0135, 0x0132, 0x0132, 0x0132, 0x0132, 0x0132, 0x012F, 0x012F, 0x012F, 0x012F, 0x012C, 0x012C, 0x012C, 
-       0x012C, 0x0129, 0x0129, 0x0129, 0x0127, 0x0127, 0x0127, 0x0124, 0x0124, 0x0124, 0x0121, 0x0121, 0x011F, 0x011F, 0x011F, 0x011C, 
-       0x011C, 0x011A, 0x011A, 0x011A, 0x0118, 0x0118, 0x0115, 0x0115, 0x0113, 0x0113, 0x0111, 0x0111, 0x010E, 0x010E, 0x010C, 0x010C, 
-       0x010A, 0x010A, 0x0108, 0x0108, 0x0106, 0x0106, 0x0104, 0x0104, 0x0102, 0x0100, 0x0100, 0x00FE, 0x00FE, 0x00FC, 0x00FC, 0x00FA, 
-       0x00F8, 0x00F8, 0x00F6, 0x00F4, 0x00F4, 0x00F2, 0x00F2, 0x00F0, 0x00EF, 0x00EF, 0x00ED, 0x00EB, 0x00EB, 0x00EA, 0x00E8, 0x00E8, 
-       0x00E6, 0x00E5, 0x00E5, 0x00E3, 0x00E1, 0x00E1, 0x00E0, 0x00DE, 0x00DE, 0x00DD, 0x00DB, 0x00DA, 0x00DA, 0x00D9, 0x00D7, 0x00D7, 
-       0x00D6, 0x00D4, 0x00D3, 0x00D3, 0x00D2, 0x00D0, 0x00CF, 0x00CF, 0x00CE, 0x00CC, 0x00CB, 0x00CB, 0x00CA, 0x00C9, 0x00C7, 0x00C7, 
-       0x0135, 0x0135, 0x0135, 0x0135, 0x0135, 0x0135, 0x0135, 0x0135, 0x0135, 0x0135, 0x0135, 0x0135, 0x0135, 0x0132, 0x0132, 0x0132, 
-       0x0132, 0x0132, 0x0132, 0x0132, 0x012F, 0x012F, 0x012F, 0x012F, 0x012F, 0x012C, 0x012C, 0x012C, 0x012C, 0x0129, 0x0129, 0x0129, 
-       0x0129, 0x0127, 0x0127, 0x0127, 0x0124, 0x0124, 0x0124, 0x0121, 0x0121, 0x0121, 0x011F, 0x011F, 0x011F, 0x011C, 0x011C, 0x011A, 
-       0x011A, 0x011A, 0x0118, 0x0118, 0x0115, 0x0115, 0x0113, 0x0113, 0x0111, 0x0111, 0x010E, 0x010E, 0x010E, 0x010C, 0x010C, 0x010A, 
-       0x0108, 0x0108, 0x0106, 0x0106, 0x0104, 0x0104, 0x0102, 0x0102, 0x0100, 0x0100, 0x00FE, 0x00FC, 0x00FC, 0x00FA, 0x00FA, 0x00F8, 
-       0x00F8, 0x00F6, 0x00F4, 0x00F4, 0x00F2, 0x00F0, 0x00F0, 0x00EF, 0x00EF, 0x00ED, 0x00EB, 0x00EB, 0x00EA, 0x00E8, 0x00E8, 0x00E6, 
-       0x00E5, 0x00E5, 0x00E3, 0x00E1, 0x00E1, 0x00E0, 0x00DE, 0x00DE, 0x00DD, 0x00DB, 0x00DA, 0x00DA, 0x00D9, 0x00D7, 0x00D7, 0x00D6, 
-       0x00D4, 0x00D3, 0x00D3, 0x00D2, 0x00D0, 0x00CF, 0x00CF, 0x00CE, 0x00CC, 0x00CB, 0x00CB, 0x00CA, 0x00C9, 0x00C7, 0x00C7, 0x00C6, 
-       0x0132, 0x0132, 0x0132, 0x0132, 0x0132, 0x0132, 0x0132, 0x0132, 0x0132, 0x0132, 0x0132, 0x0132, 0x0132, 0x0132, 0x012F, 0x012F, 
-       0x012F, 0x012F, 0x012F, 0x012F, 0x012C, 0x012C, 0x012C, 0x012C, 0x012C, 0x0129, 0x0129, 0x0129, 0x0129, 0x0127, 0x0127, 0x0127, 
-       0x0127, 0x0124, 0x0124, 0x0124, 0x0121, 0x0121, 0x0121, 0x011F, 0x011F, 0x011F, 0x011C, 0x011C, 0x011C, 0x011A, 0x011A, 0x0118, 
-       0x0118, 0x0118, 0x0115, 0x0115, 0x0113, 0x0113, 0x0111, 0x0111, 0x0111, 0x010E, 0x010E, 0x010C, 0x010C, 0x010A, 0x010A, 0x0108, 
-       0x0108, 0x0106, 0x0106, 0x0104, 0x0104, 0x0102, 0x0100, 0x0100, 0x00FE, 0x00FE, 0x00FC, 0x00FC, 0x00FA, 0x00FA, 0x00F8, 0x00F6, 
-       0x00F6, 0x00F4, 0x00F4, 0x00F2, 0x00F0, 0x00F0, 0x00EF, 0x00ED, 0x00ED, 0x00EB, 0x00EB, 0x00EA, 0x00E8, 0x00E8, 0x00E6, 0x00E5, 
-       0x00E5, 0x00E3, 0x00E1, 0x00E1, 0x00E0, 0x00DE, 0x00DE, 0x00DD, 0x00DB, 0x00DA, 0x00DA, 0x00D9, 0x00D7, 0x00D7, 0x00D6, 0x00D4, 
-       0x00D3, 0x00D3, 0x00D2, 0x00D0, 0x00D0, 0x00CF, 0x00CE, 0x00CC, 0x00CC, 0x00CB, 0x00CA, 0x00C9, 0x00C9, 0x00C7, 0x00C6, 0x00C5, 
-       0x012F, 0x012F, 0x012F, 0x012F, 0x012F, 0x012F, 0x012F, 0x012F, 0x012F, 0x012F, 0x012F, 0x012F, 0x012F, 0x012F, 0x012C, 0x012C, 
-       0x012C, 0x012C, 0x012C, 0x012C, 0x0129, 0x0129, 0x0129, 0x0129, 0x0129, 0x0127, 0x0127, 0x0127, 0x0127, 0x0124, 0x0124, 0x0124, 
-       0x0124, 0x0121, 0x0121, 0x0121, 0x011F, 0x011F, 0x011F, 0x011C, 0x011C, 0x011C, 0x011A, 0x011A, 0x011A, 0x0118, 0x0118, 0x0118, 
-       0x0115, 0x0115, 0x0113, 0x0113, 0x0111, 0x0111, 0x0111, 0x010E, 0x010E, 0x010C, 0x010C, 0x010A, 0x010A, 0x0108, 0x0108, 0x0106, 
-       0x0106, 0x0104, 0x0104, 0x0102, 0x0102, 0x0100, 0x0100, 0x00FE, 0x00FE, 0x00FC, 0x00FA, 0x00FA, 0x00F8, 0x00F8, 0x00F6, 0x00F6, 
-       0x00F4, 0x00F2, 0x00F2, 0x00F0, 0x00F0, 0x00EF, 0x00ED, 0x00ED, 0x00EB, 0x00EA, 0x00EA, 0x00E8, 0x00E6, 0x00E6, 0x00E5, 0x00E5, 
-       0x00E3, 0x00E1, 0x00E1, 0x00E0, 0x00DE, 0x00DD, 0x00DD, 0x00DB, 0x00DA, 0x00DA, 0x00D9, 0x00D7, 0x00D7, 0x00D6, 0x00D4, 0x00D3, 
-       0x00D3, 0x00D2, 0x00D0, 0x00D0, 0x00CF, 0x00CE, 0x00CC, 0x00CC, 0x00CB, 0x00CA, 0x00C9, 0x00C9, 0x00C7, 0x00C6, 0x00C5, 0x00C5, 
-       0x012C, 0x012C, 0x012C, 0x012C, 0x012C, 0x012C, 0x012C, 0x012C, 0x012C, 0x012C, 0x012C, 0x012C, 0x012C, 0x012C, 0x0129, 0x0129, 
-       0x0129, 0x0129, 0x0129, 0x0129, 0x0129, 0x0127, 0x0127, 0x0127, 0x0127, 0x0124, 0x0124, 0x0124, 0x0124, 0x0124, 0x0121, 0x0121, 
-       0x0121, 0x011F, 0x011F, 0x011F, 0x011F, 0x011C, 0x011C, 0x011C, 0x011A, 0x011A, 0x011A, 0x0118, 0x0118, 0x0115, 0x0115, 0x0115, 
-       0x0113, 0x0113, 0x0111, 0x0111, 0x0111, 0x010E, 0x010E, 0x010C, 0x010C, 0x010A, 0x010A, 0x0108, 0x0108, 0x0106, 0x0106, 0x0104, 
-       0x0104, 0x0102, 0x0102, 0x0100, 0x0100, 0x00FE, 0x00FE, 0x00FC, 0x00FC, 0x00FA, 0x00FA, 0x00F8, 0x00F6, 0x00F6, 0x00F4, 0x00F4, 
-       0x00F2, 0x00F2, 0x00F0, 0x00EF, 0x00EF, 0x00ED, 0x00ED, 0x00EB, 0x00EA, 0x00EA, 0x00E8, 0x00E6, 0x00E6, 0x00E5, 0x00E3, 0x00E3, 
-       0x00E1, 0x00E0, 0x00E0, 0x00DE, 0x00DD, 0x00DD, 0x00DB, 0x00DA, 0x00DA, 0x00D9, 0x00D7, 0x00D7, 0x00D6, 0x00D4, 0x00D4, 0x00D3, 
-       0x00D2, 0x00D0, 0x00D0, 0x00CF, 0x00CE, 0x00CC, 0x00CC, 0x00CB, 0x00CA, 0x00CA, 0x00C9, 0x00C7, 0x00C6, 0x00C6, 0x00C5, 0x00C4, 
-       0x0129, 0x0129, 0x0129, 0x0129, 0x0129, 0x0129, 0x0129, 0x0129, 0x0129, 0x0129, 0x0129, 0x0129, 0x0129, 0x0129, 0x0127, 0x0127, 
-       0x0127, 0x0127, 0x0127, 0x0127, 0x0127, 0x0124, 0x0124, 0x0124, 0x0124, 0x0124, 0x0121, 0x0121, 0x0121, 0x0121, 0x011F, 0x011F, 
-       0x011F, 0x011C, 0x011C, 0x011C, 0x011C, 0x011A, 0x011A, 0x011A, 0x0118, 0x0118, 0x0118, 0x0115, 0x0115, 0x0113, 0x0113, 0x0113, 
-       0x0111, 0x0111, 0x0111, 0x010E, 0x010E, 0x010C, 0x010C, 0x010A, 0x010A, 0x0108, 0x0108, 0x0108, 0x0106, 0x0106, 0x0104, 0x0104, 
-       0x0102, 0x0102, 0x0100, 0x0100, 0x00FE, 0x00FE, 0x00FC, 0x00FA, 0x00FA, 0x00F8, 0x00F8, 0x00F6, 0x00F6, 0x00F4, 0x00F4, 0x00F2, 
-       0x00F0, 0x00F0, 0x00EF, 0x00EF, 0x00ED, 0x00EB, 0x00EB, 0x00EA, 0x00E8, 0x00E8, 0x00E6, 0x00E6, 0x00E5, 0x00E3, 0x00E3, 0x00E1, 
-       0x00E0, 0x00E0, 0x00DE, 0x00DD, 0x00DD, 0x00DB, 0x00DA, 0x00DA, 0x00D9, 0x00D7, 0x00D7, 0x00D6, 0x00D4, 0x00D4, 0x00D3, 0x00D2, 
-       0x00D0, 0x00D0, 0x00CF, 0x00CE, 0x00CE, 0x00CC, 0x00CB, 0x00CA, 0x00CA, 0x00C9, 0x00C7, 0x00C6, 0x00C6, 0x00C5, 0x00C4, 0x00C3, 
-       0x0127, 0x0127, 0x0127, 0x0127, 0x0127, 0x0127, 0x0127, 0x0127, 0x0127, 0x0127, 0x0127, 0x0127, 0x0127, 0x0127, 0x0124, 0x0124, 
-       0x0124, 0x0124, 0x0124, 0x0124, 0x0124, 0x0121, 0x0121, 0x0121, 0x0121, 0x0121, 0x011F, 0x011F, 0x011F, 0x011F, 0x011C, 0x011C, 
-       0x011C, 0x011C, 0x011A, 0x011A, 0x011A, 0x0118, 0x0118, 0x0118, 0x0115, 0x0115, 0x0115, 0x0113, 0x0113, 0x0113, 0x0111, 0x0111, 
-       0x010E, 0x010E, 0x010E, 0x010C, 0x010C, 0x010A, 0x010A, 0x0108, 0x0108, 0x0108, 0x0106, 0x0106, 0x0104, 0x0104, 0x0102, 0x0102, 
-       0x0100, 0x0100, 0x00FE, 0x00FE, 0x00FC, 0x00FC, 0x00FA, 0x00FA, 0x00F8, 0x00F8, 0x00F6, 0x00F4, 0x00F4, 0x00F2, 0x00F2, 0x00F0, 
-       0x00F0, 0x00EF, 0x00ED, 0x00ED, 0x00EB, 0x00EB, 0x00EA, 0x00E8, 0x00E8, 0x00E6, 0x00E5, 0x00E5, 0x00E3, 0x00E3, 0x00E1, 0x00E0, 
-       0x00E0, 0x00DE, 0x00DD, 0x00DD, 0x00DB, 0x00DA, 0x00DA, 0x00D9, 0x00D7, 0x00D7, 0x00D6, 0x00D4, 0x00D4, 0x00D3, 0x00D2, 0x00D0, 
-       0x00D0, 0x00CF, 0x00CE, 0x00CE, 0x00CC, 0x00CB, 0x00CA, 0x00CA, 0x00C9, 0x00C7, 0x00C6, 0x00C6, 0x00C5, 0x00C4, 0x00C3, 0x00C3, 
-       0x0124, 0x0124, 0x0124, 0x0124, 0x0124, 0x0124, 0x0124, 0x0124, 0x0124, 0x0124, 0x0124, 0x0124, 0x0124, 0x0124, 0x0121, 0x0121, 
-       0x0121, 0x0121, 0x0121, 0x0121, 0x0121, 0x011F, 0x011F, 0x011F, 0x011F, 0x011F, 0x011C, 0x011C, 0x011C, 0x011C, 0x011A, 0x011A, 
-       0x011A, 0x011A, 0x0118, 0x0118, 0x0118, 0x0115, 0x0115, 0x0115, 0x0113, 0x0113, 0x0113, 0x0111, 0x0111, 0x0111, 0x010E, 0x010E, 
-       0x010E, 0x010C, 0x010C, 0x010A, 0x010A, 0x0108, 0x0108, 0x0108, 0x0106, 0x0106, 0x0104, 0x0104, 0x0102, 0x0102, 0x0100, 0x0100, 
-       0x00FE, 0x00FE, 0x00FC, 0x00FC, 0x00FA, 0x00FA, 0x00F8, 0x00F8, 0x00F6, 0x00F6, 0x00F4, 0x00F4, 0x00F2, 0x00F0, 0x00F0, 0x00EF, 
-       0x00EF, 0x00ED, 0x00ED, 0x00EB, 0x00EA, 0x00EA, 0x00E8, 0x00E8, 0x00E6, 0x00E5, 0x00E5, 0x00E3, 0x00E1, 0x00E1, 0x00E0, 0x00E0, 
-       0x00DE, 0x00DD, 0x00DD, 0x00DB, 0x00DA, 0x00DA, 0x00D9, 0x00D7, 0x00D7, 0x00D6, 0x00D4, 0x00D3, 0x00D3, 0x00D2, 0x00D0, 0x00D0, 
-       0x00CF, 0x00CE, 0x00CE, 0x00CC, 0x00CB, 0x00CA, 0x00CA, 0x00C9, 0x00C7, 0x00C7, 0x00C6, 0x00C5, 0x00C4, 0x00C4, 0x00C3, 0x00C1, 
-       0x0121, 0x0121, 0x0121, 0x0121, 0x0121, 0x0121, 0x0121, 0x0121, 0x0121, 0x0121, 0x0121, 0x0121, 0x0121, 0x0121, 0x011F, 0x011F, 
-       0x011F, 0x011F, 0x011F, 0x011F, 0x011F, 0x011C, 0x011C, 0x011C, 0x011C, 0x011C, 0x011A, 0x011A, 0x011A, 0x011A, 0x0118, 0x0118, 
-       0x0118, 0x0118, 0x0115, 0x0115, 0x0115, 0x0113, 0x0113, 0x0113, 0x0111, 0x0111, 0x0111, 0x010E, 0x010E, 0x010E, 0x010C, 0x010C, 
-       0x010C, 0x010A, 0x010A, 0x0108, 0x0108, 0x0108, 0x0106, 0x0106, 0x0104, 0x0104, 0x0102, 0x0102, 0x0100, 0x0100, 0x00FE, 0x00FE, 
-       0x00FE, 0x00FC, 0x00FC, 0x00FA, 0x00F8, 0x00F8, 0x00F6, 0x00F6, 0x00F4, 0x00F4, 0x00F2, 0x00F2, 0x00F0, 0x00F0, 0x00EF, 0x00EF, 
-       0x00ED, 0x00EB, 0x00EB, 0x00EA, 0x00EA, 0x00E8, 0x00E6, 0x00E6, 0x00E5, 0x00E5, 0x00E3, 0x00E1, 0x00E1, 0x00E0, 0x00DE, 0x00DE, 
-       0x00DD, 0x00DB, 0x00DB, 0x00DA, 0x00DA, 0x00D9, 0x00D7, 0x00D6, 0x00D6, 0x00D4, 0x00D3, 0x00D3, 0x00D2, 0x00D0, 0x00D0, 0x00CF, 
-       0x00CE, 0x00CE, 0x00CC, 0x00CB, 0x00CA, 0x00CA, 0x00C9, 0x00C7, 0x00C7, 0x00C6, 0x00C5, 0x00C4, 0x00C4, 0x00C3, 0x00C1, 0x00C0, 
-       0x011F, 0x011F, 0x011F, 0x011F, 0x011F, 0x011F, 0x011F, 0x011F, 0x011F, 0x011F, 0x011F, 0x011F, 0x011F, 0x011F, 0x011F, 0x011C, 
-       0x011C, 0x011C, 0x011C, 0x011C, 0x011C, 0x011A, 0x011A, 0x011A, 0x011A, 0x011A, 0x0118, 0x0118, 0x0118, 0x0118, 0x0115, 0x0115, 
-       0x0115, 0x0115, 0x0113, 0x0113, 0x0113, 0x0113, 0x0111, 0x0111, 0x0111, 0x010E, 0x010E, 0x010E, 0x010C, 0x010C, 0x010A, 0x010A, 
-       0x010A, 0x0108, 0x0108, 0x0106, 0x0106, 0x0106, 0x0104, 0x0104, 0x0102, 0x0102, 0x0100, 0x0100, 0x0100, 0x00FE, 0x00FE, 0x00FC, 
-       0x00FC, 0x00FA, 0x00FA, 0x00F8, 0x00F8, 0x00F6, 0x00F6, 0x00F4, 0x00F4, 0x00F2, 0x00F0, 0x00F0, 0x00EF, 0x00EF, 0x00ED, 0x00ED, 
-       0x00EB, 0x00EB, 0x00EA, 0x00E8, 0x00E8, 0x00E6, 0x00E6, 0x00E5, 0x00E3, 0x00E3, 0x00E1, 0x00E1, 0x00E0, 0x00DE, 0x00DE, 0x00DD, 
-       0x00DB, 0x00DB, 0x00DA, 0x00D9, 0x00D9, 0x00D7, 0x00D6, 0x00D6, 0x00D4, 0x00D3, 0x00D3, 0x00D2, 0x00D0, 0x00D0, 0x00CF, 0x00CE, 
-       0x00CE, 0x00CC, 0x00CB, 0x00CA, 0x00CA, 0x00C9, 0x00C7, 0x00C7, 0x00C6, 0x00C5, 0x00C4, 0x00C4, 0x00C3, 0x00C1, 0x00C0, 0x00C0, 
-       0x011C, 0x011C, 0x011C, 0x011C, 0x011C, 0x011C, 0x011C, 0x011C, 0x011C, 0x011C, 0x011C, 0x011C, 0x011C, 0x011C, 0x011C, 0x011A, 
-       0x011A, 0x011A, 0x011A, 0x011A, 0x011A, 0x0118, 0x0118, 0x0118, 0x0118, 0x0118, 0x0115, 0x0115, 0x0115, 0x0115, 0x0115, 0x0113, 
-       0x0113, 0x0113, 0x0111, 0x0111, 0x0111, 0x0111, 0x010E, 0x010E, 0x010E, 0x010C, 0x010C, 0x010C, 0x010A, 0x010A, 0x010A, 0x0108, 
-       0x0108, 0x0106, 0x0106, 0x0106, 0x0104, 0x0104, 0x0102, 0x0102, 0x0100, 0x0100, 0x0100, 0x00FE, 0x00FE, 0x00FC, 0x00FC, 0x00FA, 
-       0x00FA, 0x00F8, 0x00F8, 0x00F6, 0x00F6, 0x00F4, 0x00F4, 0x00F2, 0x00F2, 0x00F0, 0x00F0, 0x00EF, 0x00EF, 0x00ED, 0x00EB, 0x00EB, 
-       0x00EA, 0x00EA, 0x00E8, 0x00E8, 0x00E6, 0x00E5, 0x00E5, 0x00E3, 0x00E3, 0x00E1, 0x00E0, 0x00E0, 0x00DE, 0x00DE, 0x00DD, 0x00DB, 
-       0x00DB, 0x00DA, 0x00D9, 0x00D9, 0x00D7, 0x00D6, 0x00D6, 0x00D4, 0x00D3, 0x00D3, 0x00D2, 0x00D0, 0x00D0, 0x00CF, 0x00CE, 0x00CE, 
-       0x00CC, 0x00CB, 0x00CA, 0x00CA, 0x00C9, 0x00C7, 0x00C7, 0x00C6, 0x00C5, 0x00C4, 0x00C4, 0x00C3, 0x00C1, 0x00C1, 0x00C0, 0x00BF, 
-       0x011A, 0x011A, 0x011A, 0x011A, 0x011A, 0x011A, 0x011A, 0x011A, 0x011A, 0x011A, 0x011A, 0x011A, 0x011A, 0x011A, 0x011A, 0x0118, 
-       0x0118, 0x0118, 0x0118, 0x0118, 0x0118, 0x0118, 0x0115, 0x0115, 0x0115, 0x0115, 0x0115, 0x0113, 0x0113, 0x0113, 0x0113, 0x0111, 
-       0x0111, 0x0111, 0x0111, 0x010E, 0x010E, 0x010E, 0x010C, 0x010C, 0x010C, 0x010A, 0x010A, 0x010A, 0x0108, 0x0108, 0x0108, 0x0106, 
-       0x0106, 0x0104, 0x0104, 0x0104, 0x0102, 0x0102, 0x0100, 0x0100, 0x0100, 0x00FE, 0x00FE, 0x00FC, 0x00FC, 0x00FA, 0x00FA, 0x00F8, 
-       0x00F8, 0x00F6, 0x00F6, 0x00F4, 0x00F4, 0x00F2, 0x00F2, 0x00F0, 0x00F0, 0x00EF, 0x00EF, 0x00ED, 0x00ED, 0x00EB, 0x00EB, 0x00EA, 
-       0x00E8, 0x00E8, 0x00E6, 0x00E6, 0x00E5, 0x00E5, 0x00E3, 0x00E1, 0x00E1, 0x00E0, 0x00E0, 0x00DE, 0x00DD, 0x00DD, 0x00DB, 0x00DA, 
-       0x00DA, 0x00D9, 0x00D9, 0x00D7, 0x00D6, 0x00D6, 0x00D4, 0x00D3, 0x00D3, 0x00D2, 0x00D0, 0x00D0, 0x00CF, 0x00CE, 0x00CE, 0x00CC, 
-       0x00CB, 0x00CA, 0x00CA, 0x00C9, 0x00C7, 0x00C7, 0x00C6, 0x00C5, 0x00C5, 0x00C4, 0x00C3, 0x00C1, 0x00C1, 0x00C0, 0x00BF, 0x00BE, 
-       0x0118, 0x0118, 0x0118, 0x0118, 0x0118, 0x0118, 0x0118, 0x0118, 0x0118, 0x0118, 0x0118, 0x0118, 0x0118, 0x0118, 0x0118, 0x0115, 
-       0x0115, 0x0115, 0x0115, 0x0115, 0x0115, 0x0115, 0x0113, 0x0113, 0x0113, 0x0113, 0x0113, 0x0111, 0x0111, 0x0111, 0x0111, 0x010E, 
-       0x010E, 0x010E, 0x010E, 0x010C, 0x010C, 0x010C, 0x010A, 0x010A, 0x010A, 0x0108, 0x0108, 0x0108, 0x0106, 0x0106, 0x0106, 0x0104, 
-       0x0104, 0x0104, 0x0102, 0x0102, 0x0100, 0x0100, 0x0100, 0x00FE, 0x00FE, 0x00FC, 0x00FC, 0x00FA, 0x00FA, 0x00F8, 0x00F8, 0x00F8, 
-       0x00F6, 0x00F6, 0x00F4, 0x00F4, 0x00F2, 0x00F2, 0x00F0, 0x00F0, 0x00EF, 0x00EF, 0x00ED, 0x00EB, 0x00EB, 0x00EA, 0x00EA, 0x00E8, 
-       0x00E8, 0x00E6, 0x00E6, 0x00E5, 0x00E3, 0x00E3, 0x00E1, 0x00E1, 0x00E0, 0x00DE, 0x00DE, 0x00DD, 0x00DD, 0x00DB, 0x00DA, 0x00DA, 
-       0x00D9, 0x00D7, 0x00D7, 0x00D6, 0x00D6, 0x00D4, 0x00D3, 0x00D3, 0x00D2, 0x00D0, 0x00D0, 0x00CF, 0x00CE, 0x00CE, 0x00CC, 0x00CB, 
-       0x00CA, 0x00CA, 0x00C9, 0x00C7, 0x00C7, 0x00C6, 0x00C5, 0x00C5, 0x00C4, 0x00C3, 0x00C1, 0x00C1, 0x00C0, 0x00BF, 0x00BE, 0x00BE, 
-       0x0115, 0x0115, 0x0115, 0x0115, 0x0115, 0x0115, 0x0115, 0x0115, 0x0115, 0x0115, 0x0115, 0x0115, 0x0115, 0x0115, 0x0115, 0x0113, 
-       0x0113, 0x0113, 0x0113, 0x0113, 0x0113, 0x0113, 0x0111, 0x0111, 0x0111, 0x0111, 0x0111, 0x010E, 0x010E, 0x010E, 0x010E, 0x010C, 
-       0x010C, 0x010C, 0x010C, 0x010A, 0x010A, 0x010A, 0x0108, 0x0108, 0x0108, 0x0106, 0x0106, 0x0106, 0x0104, 0x0104, 0x0104, 0x0102, 
-       0x0102, 0x0102, 0x0100, 0x0100, 0x00FE, 0x00FE, 0x00FE, 0x00FC, 0x00FC, 0x00FA, 0x00FA, 0x00F8, 0x00F8, 0x00F8, 0x00F6, 0x00F6, 
-       0x00F4, 0x00F4, 0x00F2, 0x00F2, 0x00F0, 0x00F0, 0x00EF, 0x00EF, 0x00ED, 0x00ED, 0x00EB, 0x00EB, 0x00EA, 0x00EA, 0x00E8, 0x00E6, 
-       0x00E6, 0x00E5, 0x00E5, 0x00E3, 0x00E3, 0x00E1, 0x00E0, 0x00E0, 0x00DE, 0x00DE, 0x00DD, 0x00DB, 0x00DB, 0x00DA, 0x00DA, 0x00D9, 
-       0x00D7, 0x00D7, 0x00D6, 0x00D4, 0x00D4, 0x00D3, 0x00D2, 0x00D2, 0x00D0, 0x00CF, 0x00CF, 0x00CE, 0x00CC, 0x00CC, 0x00CB, 0x00CA, 
-       0x00CA, 0x00C9, 0x00C7, 0x00C7, 0x00C6, 0x00C5, 0x00C5, 0x00C4, 0x00C3, 0x00C1, 0x00C1, 0x00C0, 0x00BF, 0x00BF, 0x00BE, 0x00BD, 
-       0x0113, 0x0113, 0x0113, 0x0113, 0x0113, 0x0113, 0x0113, 0x0113, 0x0113, 0x0113, 0x0113, 0x0113, 0x0113, 0x0113, 0x0113, 0x0111, 
-       0x0111, 0x0111, 0x0111, 0x0111, 0x0111, 0x0111, 0x010E, 0x010E, 0x010E, 0x010E, 0x010E, 0x010C, 0x010C, 0x010C, 0x010C, 0x010A, 
-       0x010A, 0x010A, 0x010A, 0x0108, 0x0108, 0x0108, 0x0108, 0x0106, 0x0106, 0x0106, 0x0104, 0x0104, 0x0104, 0x0102, 0x0102, 0x0100, 
-       0x0100, 0x0100, 0x00FE, 0x00FE, 0x00FE, 0x00FC, 0x00FC, 0x00FA, 0x00FA, 0x00F8, 0x00F8, 0x00F8, 0x00F6, 0x00F6, 0x00F4, 0x00F4, 
-       0x00F2, 0x00F2, 0x00F0, 0x00F0, 0x00EF, 0x00EF, 0x00ED, 0x00ED, 0x00EB, 0x00EB, 0x00EA, 0x00EA, 0x00E8, 0x00E8, 0x00E6, 0x00E6, 
-       0x00E5, 0x00E3, 0x00E3, 0x00E1, 0x00E1, 0x00E0, 0x00E0, 0x00DE, 0x00DD, 0x00DD, 0x00DB, 0x00DB, 0x00DA, 0x00D9, 0x00D9, 0x00D7, 
-       0x00D7, 0x00D6, 0x00D4, 0x00D4, 0x00D3, 0x00D2, 0x00D2, 0x00D0, 0x00CF, 0x00CF, 0x00CE, 0x00CC, 0x00CC, 0x00CB, 0x00CA, 0x00CA, 
-       0x00C9, 0x00C7, 0x00C7, 0x00C6, 0x00C5, 0x00C5, 0x00C4, 0x00C3, 0x00C1, 0x00C1, 0x00C0, 0x00BF, 0x00BF, 0x00BE, 0x00BD, 0x00BC, 
-       0x0111, 0x0111, 0x0111, 0x0111, 0x0111, 0x0111, 0x0111, 0x0111, 0x0111, 0x0111, 0x0111, 0x0111, 0x0111, 0x0111, 0x0111, 0x010E, 
-       0x010E, 0x010E, 0x010E, 0x010E, 0x010E, 0x010E, 0x010C, 0x010C, 0x010C, 0x010C, 0x010C, 0x010A, 0x010A, 0x010A, 0x010A, 0x0108, 
-       0x0108, 0x0108, 0x0108, 0x0106, 0x0106, 0x0106, 0x0106, 0x0104, 0x0104, 0x0104, 0x0102, 0x0102, 0x0102, 0x0100, 0x0100, 0x0100, 
-       0x00FE, 0x00FE, 0x00FC, 0x00FC, 0x00FC, 0x00FA, 0x00FA, 0x00F8, 0x00F8, 0x00F8, 0x00F6, 0x00F6, 0x00F4, 0x00F4, 0x00F2, 0x00F2, 
-       0x00F0, 0x00F0, 0x00EF, 0x00EF, 0x00EF, 0x00ED, 0x00ED, 0x00EB, 0x00EA, 0x00EA, 0x00E8, 0x00E8, 0x00E6, 0x00E6, 0x00E5, 0x00E5, 
-       0x00E3, 0x00E3, 0x00E1, 0x00E1, 0x00E0, 0x00DE, 0x00DE, 0x00DD, 0x00DD, 0x00DB, 0x00DA, 0x00DA, 0x00D9, 0x00D9, 0x00D7, 0x00D6, 
-       0x00D6, 0x00D4, 0x00D4, 0x00D3, 0x00D2, 0x00D2, 0x00D0, 0x00CF, 0x00CF, 0x00CE, 0x00CC, 0x00CC, 0x00CB, 0x00CA, 0x00CA, 0x00C9, 
-       0x00C7, 0x00C7, 0x00C6, 0x00C5, 0x00C5, 0x00C4, 0x00C3, 0x00C1, 0x00C1, 0x00C0, 0x00BF, 0x00BF, 0x00BE, 0x00BD, 0x00BC, 0x00BC, 
-       0x010E, 0x010E, 0x010E, 0x010E, 0x010E, 0x010E, 0x010E, 0x010E, 0x010E, 0x010E, 0x010E, 0x010E, 0x010E, 0x010E, 0x010E, 0x010E, 
-       0x010C, 0x010C, 0x010C, 0x010C, 0x010C, 0x010C, 0x010A, 0x010A, 0x010A, 0x010A, 0x010A, 0x0108, 0x0108, 0x0108, 0x0108, 0x0108, 
-       0x0106, 0x0106, 0x0106, 0x0104, 0x0104, 0x0104, 0x0104, 0x0102, 0x0102, 0x0102, 0x0100, 0x0100, 0x0100, 0x00FE, 0x00FE, 0x00FE, 
-       0x00FC, 0x00FC, 0x00FC, 0x00FA, 0x00FA, 0x00F8, 0x00F8, 0x00F8, 0x00F6, 0x00F6, 0x00F4, 0x00F4, 0x00F2, 0x00F2, 0x00F0, 0x00F0, 
-       0x00F0, 0x00EF, 0x00EF, 0x00ED, 0x00ED, 0x00EB, 0x00EB, 0x00EA, 0x00EA, 0x00E8, 0x00E8, 0x00E6, 0x00E6, 0x00E5, 0x00E3, 0x00E3, 
-       0x00E1, 0x00E1, 0x00E0, 0x00E0, 0x00DE, 0x00DE, 0x00DD, 0x00DB, 0x00DB, 0x00DA, 0x00DA, 0x00D9, 0x00D7, 0x00D7, 0x00D6, 0x00D6, 
-       0x00D4, 0x00D3, 0x00D3, 0x00D2, 0x00D0, 0x00D0, 0x00CF, 0x00CF, 0x00CE, 0x00CC, 0x00CC, 0x00CB, 0x00CA, 0x00CA, 0x00C9, 0x00C7, 
-       0x00C7, 0x00C6, 0x00C5, 0x00C5, 0x00C4, 0x00C3, 0x00C1, 0x00C1, 0x00C0, 0x00BF, 0x00BF, 0x00BE, 0x00BD, 0x00BC, 0x00BC, 0x00BB, 
-       0x010C, 0x010C, 0x010C, 0x010C, 0x010C, 0x010C, 0x010C, 0x010C, 0x010C, 0x010C, 0x010C, 0x010C, 0x010C, 0x010C, 0x010C, 0x010C, 
-       0x010A, 0x010A, 0x010A, 0x010A, 0x010A, 0x010A, 0x0108, 0x0108, 0x0108, 0x0108, 0x0108, 0x0106, 0x0106, 0x0106, 0x0106, 0x0106, 
-       0x0104, 0x0104, 0x0104, 0x0104, 0x0102, 0x0102, 0x0102, 0x0100, 0x0100, 0x0100, 0x00FE, 0x00FE, 0x00FE, 0x00FC, 0x00FC, 0x00FC, 
-       0x00FA, 0x00FA, 0x00FA, 0x00F8, 0x00F8, 0x00F6, 0x00F6, 0x00F6, 0x00F4, 0x00F4, 0x00F2, 0x00F2, 0x00F0, 0x00F0, 0x00F0, 0x00EF, 
-       0x00EF, 0x00ED, 0x00ED, 0x00EB, 0x00EB, 0x00EA, 0x00EA, 0x00E8, 0x00E8, 0x00E6, 0x00E6, 0x00E5, 0x00E5, 0x00E3, 0x00E3, 0x00E1, 
-       0x00E1, 0x00E0, 0x00DE, 0x00DE, 0x00DD, 0x00DD, 0x00DB, 0x00DB, 0x00DA, 0x00D9, 0x00D9, 0x00D7, 0x00D7, 0x00D6, 0x00D4, 0x00D4, 
-       0x00D3, 0x00D3, 0x00D2, 0x00D0, 0x00D0, 0x00CF, 0x00CE, 0x00CE, 0x00CC, 0x00CB, 0x00CB, 0x00CA, 0x00CA, 0x00C9, 0x00C7, 0x00C7, 
-       0x00C6, 0x00C5, 0x00C4, 0x00C4, 0x00C3, 0x00C1, 0x00C1, 0x00C0, 0x00BF, 0x00BF, 0x00BE, 0x00BD, 0x00BD, 0x00BC, 0x00BB, 0x00BA, 
-       0x010A, 0x010A, 0x010A, 0x010A, 0x010A, 0x010A, 0x010A, 0x010A, 0x010A, 0x010A, 0x010A, 0x010A, 0x010A, 0x010A, 0x010A, 0x010A, 
-       0x0108, 0x0108, 0x0108, 0x0108, 0x0108, 0x0108, 0x0108, 0x0106, 0x0106, 0x0106, 0x0106, 0x0106, 0x0104, 0x0104, 0x0104, 0x0104, 
-       0x0102, 0x0102, 0x0102, 0x0102, 0x0100, 0x0100, 0x0100, 0x00FE, 0x00FE, 0x00FE, 0x00FC, 0x00FC, 0x00FC, 0x00FA, 0x00FA, 0x00FA, 
-       0x00F8, 0x00F8, 0x00F8, 0x00F6, 0x00F6, 0x00F6, 0x00F4, 0x00F4, 0x00F2, 0x00F2, 0x00F0, 0x00F0, 0x00F0, 0x00EF, 0x00EF, 0x00ED, 
-       0x00ED, 0x00EB, 0x00EB, 0x00EA, 0x00EA, 0x00E8, 0x00E8, 0x00E6, 0x00E6, 0x00E5, 0x00E5, 0x00E3, 0x00E3, 0x00E1, 0x00E1, 0x00E0, 
-       0x00E0, 0x00DE, 0x00DE, 0x00DD, 0x00DD, 0x00DB, 0x00DA, 0x00DA, 0x00D9, 0x00D9, 0x00D7, 0x00D6, 0x00D6, 0x00D4, 0x00D4, 0x00D3, 
-       0x00D2, 0x00D2, 0x00D0, 0x00D0, 0x00CF, 0x00CE, 0x00CE, 0x00CC, 0x00CB, 0x00CB, 0x00CA, 0x00C9, 0x00C9, 0x00C7, 0x00C6, 0x00C6, 
-       0x00C5, 0x00C4, 0x00C4, 0x00C3, 0x00C1, 0x00C1, 0x00C0, 0x00BF, 0x00BF, 0x00BE, 0x00BD, 0x00BD, 0x00BC, 0x00BB, 0x00BA, 0x00BA, 
-       0x0108, 0x0108, 0x0108, 0x0108, 0x0108, 0x0108, 0x0108, 0x0108, 0x0108, 0x0108, 0x0108, 0x0108, 0x0108, 0x0108, 0x0108, 0x0108, 
-       0x0106, 0x0106, 0x0106, 0x0106, 0x0106, 0x0106, 0x0106, 0x0104, 0x0104, 0x0104, 0x0104, 0x0104, 0x0102, 0x0102, 0x0102, 0x0102, 
-       0x0100, 0x0100, 0x0100, 0x0100, 0x00FE, 0x00FE, 0x00FE, 0x00FC, 0x00FC, 0x00FC, 0x00FC, 0x00FA, 0x00FA, 0x00FA, 0x00F8, 0x00F8, 
-       0x00F6, 0x00F6, 0x00F6, 0x00F4, 0x00F4, 0x00F4, 0x00F2, 0x00F2, 0x00F0, 0x00F0, 0x00F0, 0x00EF, 0x00EF, 0x00ED, 0x00ED, 0x00EB, 
-       0x00EB, 0x00EA, 0x00EA, 0x00EA, 0x00E8, 0x00E8, 0x00E6, 0x00E6, 0x00E5, 0x00E5, 0x00E3, 0x00E3, 0x00E1, 0x00E1, 0x00E0, 0x00DE, 
-       0x00DE, 0x00DD, 0x00DD, 0x00DB, 0x00DB, 0x00DA, 0x00DA, 0x00D9, 0x00D7, 0x00D7, 0x00D6, 0x00D6, 0x00D4, 0x00D3, 0x00D3, 0x00D2, 
-       0x00D2, 0x00D0, 0x00CF, 0x00CF, 0x00CE, 0x00CE, 0x00CC, 0x00CB, 0x00CB, 0x00CA, 0x00C9, 0x00C9, 0x00C7, 0x00C6, 0x00C6, 0x00C5, 
-       0x00C4, 0x00C4, 0x00C3, 0x00C1, 0x00C1, 0x00C0, 0x00BF, 0x00BF, 0x00BE, 0x00BD, 0x00BD, 0x00BC, 0x00BB, 0x00BA, 0x00BA, 0x00B9, 
-       0x0106, 0x0106, 0x0106, 0x0106, 0x0106, 0x0106, 0x0106, 0x0106, 0x0106, 0x0106, 0x0106, 0x0106, 0x0106, 0x0106, 0x0106, 0x0106, 
-       0x0104, 0x0104, 0x0104, 0x0104, 0x0104, 0x0104, 0x0104, 0x0102, 0x0102, 0x0102, 0x0102, 0x0102, 0x0100, 0x0100, 0x0100, 0x0100, 
-       0x00FE, 0x00FE, 0x00FE, 0x00FE, 0x00FC, 0x00FC, 0x00FC, 0x00FC, 0x00FA, 0x00FA, 0x00FA, 0x00F8, 0x00F8, 0x00F8, 0x00F6, 0x00F6, 
-       0x00F6, 0x00F4, 0x00F4, 0x00F2, 0x00F2, 0x00F2, 0x00F0, 0x00F0, 0x00F0, 0x00EF, 0x00EF, 0x00ED, 0x00ED, 0x00EB, 0x00EB, 0x00EA, 
-       0x00EA, 0x00EA, 0x00E8, 0x00E8, 0x00E6, 0x00E6, 0x00E5, 0x00E5, 0x00E3, 0x00E3, 0x00E1, 0x00E1, 0x00E0, 0x00E0, 0x00DE, 0x00DE, 
-       0x00DD, 0x00DD, 0x00DB, 0x00DA, 0x00DA, 0x00D9, 0x00D9, 0x00D7, 0x00D7, 0x00D6, 0x00D4, 0x00D4, 0x00D3, 0x00D3, 0x00D2, 0x00D0, 
-       0x00D0, 0x00CF, 0x00CF, 0x00CE, 0x00CC, 0x00CC, 0x00CB, 0x00CB, 0x00CA, 0x00C9, 0x00C9, 0x00C7, 0x00C6, 0x00C6, 0x00C5, 0x00C4, 
-       0x00C4, 0x00C3, 0x00C1, 0x00C1, 0x00C0, 0x00BF, 0x00BF, 0x00BE, 0x00BD, 0x00BD, 0x00BC, 0x00BB, 0x00BA, 0x00BA, 0x00B9, 0x00B8, 
-       0x0104, 0x0104, 0x0104, 0x0104, 0x0104, 0x0104, 0x0104, 0x0104, 0x0104, 0x0104, 0x0104, 0x0104, 0x0104, 0x0104, 0x0104, 0x0104, 
-       0x0102, 0x0102, 0x0102, 0x0102, 0x0102, 0x0102, 0x0102, 0x0100, 0x0100, 0x0100, 0x0100, 0x0100, 0x00FE, 0x00FE, 0x00FE, 0x00FE, 
-       0x00FC, 0x00FC, 0x00FC, 0x00FC, 0x00FA, 0x00FA, 0x00FA, 0x00FA, 0x00F8, 0x00F8, 0x00F8, 0x00F6, 0x00F6, 0x00F6, 0x00F4, 0x00F4, 
-       0x00F4, 0x00F2, 0x00F2, 0x00F2, 0x00F0, 0x00F0, 0x00EF, 0x00EF, 0x00EF, 0x00ED, 0x00ED, 0x00EB, 0x00EB, 0x00EA, 0x00EA, 0x00EA, 
-       0x00E8, 0x00E8, 0x00E6, 0x00E6, 0x00E5, 0x00E5, 0x00E3, 0x00E3, 0x00E1, 0x00E1, 0x00E0, 0x00E0, 0x00DE, 0x00DE, 0x00DD, 0x00DD, 
-       0x00DB, 0x00DB, 0x00DA, 0x00DA, 0x00D9, 0x00D7, 0x00D7, 0x00D6, 0x00D6, 0x00D4, 0x00D4, 0x00D3, 0x00D2, 0x00D2, 0x00D0, 0x00D0, 
-       0x00CF, 0x00CE, 0x00CE, 0x00CC, 0x00CC, 0x00CB, 0x00CA, 0x00CA, 0x00C9, 0x00C7, 0x00C7, 0x00C6, 0x00C6, 0x00C5, 0x00C4, 0x00C4, 
-       0x00C3, 0x00C1, 0x00C1, 0x00C0, 0x00BF, 0x00BF, 0x00BE, 0x00BD, 0x00BC, 0x00BC, 0x00BB, 0x00BA, 0x00BA, 0x00B9, 0x00B8, 0x00B8, 
-       0x0102, 0x0102, 0x0102, 0x0102, 0x0102, 0x0102, 0x0102, 0x0102, 0x0102, 0x0102, 0x0102, 0x0102, 0x0102, 0x0102, 0x0102, 0x0102, 
-       0x0100, 0x0100, 0x0100, 0x0100, 0x0100, 0x0100, 0x0100, 0x00FE, 0x00FE, 0x00FE, 0x00FE, 0x00FE, 0x00FC, 0x00FC, 0x00FC, 0x00FC, 
-       0x00FC, 0x00FA, 0x00FA, 0x00FA, 0x00F8, 0x00F8, 0x00F8, 0x00F8, 0x00F6, 0x00F6, 0x00F6, 0x00F4, 0x00F4, 0x00F4, 0x00F2, 0x00F2, 
-       0x00F2, 0x00F0, 0x00F0, 0x00F0, 0x00EF, 0x00EF, 0x00ED, 0x00ED, 0x00ED, 0x00EB, 0x00EB, 0x00EA, 0x00EA, 0x00EA, 0x00E8, 0x00E8, 
-       0x00E6, 0x00E6, 0x00E5, 0x00E5, 0x00E3, 0x00E3, 0x00E1, 0x00E1, 0x00E0, 0x00E0, 0x00E0, 0x00DE, 0x00DD, 0x00DD, 0x00DB, 0x00DB, 
-       0x00DA, 0x00DA, 0x00D9, 0x00D9, 0x00D7, 0x00D7, 0x00D6, 0x00D6, 0x00D4, 0x00D3, 0x00D3, 0x00D2, 0x00D2, 0x00D0, 0x00CF, 0x00CF, 
-       0x00CE, 0x00CE, 0x00CC, 0x00CB, 0x00CB, 0x00CA, 0x00CA, 0x00C9, 0x00C7, 0x00C7, 0x00C6, 0x00C5, 0x00C5, 0x00C4, 0x00C3, 0x00C3, 
-       0x00C1, 0x00C0, 0x00C0, 0x00BF, 0x00BE, 0x00BE, 0x00BD, 0x00BC, 0x00BC, 0x00BB, 0x00BA, 0x00BA, 0x00B9, 0x00B8, 0x00B8, 0x00B7, 
-       0x0100, 0x0100, 0x0100, 0x0100, 0x0100, 0x0100, 0x0100, 0x0100, 0x0100, 0x0100, 0x0100, 0x0100, 0x0100, 0x0100, 0x0100, 0x0100, 
-       0x00FE, 0x00FE, 0x00FE, 0x00FE, 0x00FE, 0x00FE, 0x00FE, 0x00FC, 0x00FC, 0x00FC, 0x00FC, 0x00FC, 0x00FA, 0x00FA, 0x00FA, 0x00FA, 
-       0x00FA, 0x00F8, 0x00F8, 0x00F8, 0x00F8, 0x00F6, 0x00F6, 0x00F6, 0x00F4, 0x00F4, 0x00F4, 0x00F2, 0x00F2, 0x00F2, 0x00F0, 0x00F0, 
-       0x00F0, 0x00EF, 0x00EF, 0x00EF, 0x00ED, 0x00ED, 0x00ED, 0x00EB, 0x00EB, 0x00EA, 0x00EA, 0x00EA, 0x00E8, 0x00E8, 0x00E6, 0x00E6, 
-       0x00E5, 0x00E5, 0x00E3, 0x00E3, 0x00E3, 0x00E1, 0x00E1, 0x00E0, 0x00E0, 0x00DE, 0x00DE, 0x00DD, 0x00DD, 0x00DB, 0x00DB, 0x00DA, 
-       0x00DA, 0x00D9, 0x00D7, 0x00D7, 0x00D6, 0x00D6, 0x00D4, 0x00D4, 0x00D3, 0x00D3, 0x00D2, 0x00D0, 0x00D0, 0x00CF, 0x00CF, 0x00CE, 
-       0x00CC, 0x00CC, 0x00CB, 0x00CB, 0x00CA, 0x00C9, 0x00C9, 0x00C7, 0x00C7, 0x00C6, 0x00C5, 0x00C5, 0x00C4, 0x00C3, 0x00C3, 0x00C1, 
-       0x00C0, 0x00C0, 0x00BF, 0x00BE, 0x00BE, 0x00BD, 0x00BC, 0x00BC, 0x00BB, 0x00BA, 0x00BA, 0x00B9, 0x00B8, 0x00B8, 0x00B7, 0x00B6
+    0x0800, 0x0800, 0x0800, 0x0800, 0x0800, 0x0800, 0x0787, 0x0787, 0x0787, 0x071C, 0x071C, 0x06BC, 0x0666, 0x0666, 0x0618, 0x0618, 
+    0x05D1, 0x0590, 0x0555, 0x0555, 0x051E, 0x04EC, 0x04BD, 0x0492, 0x0492, 0x0469, 0x0444, 0x0421, 0x0400, 0x03E0, 0x03C3, 0x03C3, 
+    0x03A8, 0x038E, 0x0375, 0x035E, 0x0348, 0x0333, 0x031F, 0x030C, 0x02FA, 0x02E8, 0x02E8, 0x02D8, 0x02C8, 0x02B9, 0x02AA, 0x029C, 
+    0x028F, 0x0282, 0x0276, 0x026A, 0x025E, 0x0253, 0x0249, 0x023E, 0x0234, 0x022B, 0x0222, 0x0219, 0x0210, 0x0208, 0x0200, 0x01F8, 
+    0x01F8, 0x01F0, 0x01E9, 0x01E1, 0x01DA, 0x01D4, 0x01CD, 0x01C7, 0x01C0, 0x01BA, 0x01B4, 0x01AF, 0x01A9, 0x01A4, 0x019E, 0x0199, 
+    0x0194, 0x018F, 0x018A, 0x0186, 0x0181, 0x017D, 0x0178, 0x0174, 0x0170, 0x016C, 0x0168, 0x0164, 0x0160, 0x015C, 0x0158, 0x0155, 
+    0x0151, 0x014E, 0x014A, 0x0147, 0x0144, 0x0141, 0x013E, 0x013B, 0x0138, 0x0135, 0x0132, 0x012F, 0x012C, 0x0129, 0x0127, 0x0124, 
+    0x0121, 0x011F, 0x011C, 0x011A, 0x0118, 0x0115, 0x0113, 0x0111, 0x010E, 0x010C, 0x010A, 0x0108, 0x0106, 0x0104, 0x0102, 0x0100, 
+    0x0800, 0x0800, 0x0800, 0x0800, 0x0800, 0x0800, 0x0787, 0x0787, 0x0787, 0x071C, 0x071C, 0x06BC, 0x0666, 0x0666, 0x0618, 0x0618, 
+    0x05D1, 0x0590, 0x0555, 0x0555, 0x051E, 0x04EC, 0x04BD, 0x0492, 0x0492, 0x0469, 0x0444, 0x0421, 0x0400, 0x03E0, 0x03C3, 0x03C3, 
+    0x03A8, 0x038E, 0x0375, 0x035E, 0x0348, 0x0333, 0x031F, 0x030C, 0x02FA, 0x02E8, 0x02E8, 0x02D8, 0x02C8, 0x02B9, 0x02AA, 0x029C, 
+    0x028F, 0x0282, 0x0276, 0x026A, 0x025E, 0x0253, 0x0249, 0x023E, 0x0234, 0x022B, 0x0222, 0x0219, 0x0210, 0x0208, 0x0200, 0x01F8, 
+    0x01F8, 0x01F0, 0x01E9, 0x01E1, 0x01DA, 0x01D4, 0x01CD, 0x01C7, 0x01C0, 0x01BA, 0x01B4, 0x01AF, 0x01A9, 0x01A4, 0x019E, 0x0199, 
+    0x0194, 0x018F, 0x018A, 0x0186, 0x0181, 0x017D, 0x0178, 0x0174, 0x0170, 0x016C, 0x0168, 0x0164, 0x0160, 0x015C, 0x0158, 0x0155, 
+    0x0151, 0x014E, 0x014A, 0x0147, 0x0144, 0x0141, 0x013E, 0x013B, 0x0138, 0x0135, 0x0132, 0x012F, 0x012C, 0x0129, 0x0127, 0x0124, 
+    0x0121, 0x011F, 0x011C, 0x011A, 0x0118, 0x0115, 0x0113, 0x0111, 0x010E, 0x010C, 0x010A, 0x0108, 0x0106, 0x0104, 0x0102, 0x0100, 
+    0x0800, 0x0800, 0x0800, 0x0800, 0x0800, 0x0800, 0x0787, 0x0787, 0x071C, 0x071C, 0x071C, 0x06BC, 0x0666, 0x0666, 0x0618, 0x05D1, 
+    0x05D1, 0x0590, 0x0555, 0x0555, 0x051E, 0x04EC, 0x04BD, 0x0492, 0x0492, 0x0469, 0x0444, 0x0421, 0x0400, 0x03E0, 0x03C3, 0x03C3, 
+    0x03A8, 0x038E, 0x0375, 0x035E, 0x0348, 0x0333, 0x031F, 0x030C, 0x02FA, 0x02E8, 0x02E8, 0x02D8, 0x02C8, 0x02B9, 0x02AA, 0x029C, 
+    0x028F, 0x0282, 0x0276, 0x026A, 0x025E, 0x0253, 0x0249, 0x023E, 0x0234, 0x022B, 0x0222, 0x0219, 0x0210, 0x0208, 0x0200, 0x01F8, 
+    0x01F0, 0x01F0, 0x01E9, 0x01E1, 0x01DA, 0x01D4, 0x01CD, 0x01C7, 0x01C0, 0x01BA, 0x01B4, 0x01AF, 0x01A9, 0x01A4, 0x019E, 0x0199, 
+    0x0194, 0x018F, 0x018A, 0x0186, 0x0181, 0x017D, 0x0178, 0x0174, 0x0170, 0x016C, 0x0168, 0x0164, 0x0160, 0x015C, 0x0158, 0x0155, 
+    0x0151, 0x014E, 0x014A, 0x0147, 0x0144, 0x0141, 0x013E, 0x013B, 0x0138, 0x0135, 0x0132, 0x012F, 0x012C, 0x0129, 0x0127, 0x0124, 
+    0x0121, 0x011F, 0x011C, 0x011A, 0x0118, 0x0115, 0x0113, 0x0111, 0x010E, 0x010C, 0x010A, 0x0108, 0x0106, 0x0104, 0x0102, 0x0100, 
+    0x0800, 0x0800, 0x0800, 0x0800, 0x0800, 0x0787, 0x0787, 0x0787, 0x071C, 0x071C, 0x06BC, 0x06BC, 0x0666, 0x0666, 0x0618, 0x05D1, 
+    0x05D1, 0x0590, 0x0555, 0x051E, 0x051E, 0x04EC, 0x04BD, 0x0492, 0x0469, 0x0469, 0x0444, 0x0421, 0x0400, 0x03E0, 0x03C3, 0x03A8, 
+    0x03A8, 0x038E, 0x0375, 0x035E, 0x0348, 0x0333, 0x031F, 0x030C, 0x02FA, 0x02E8, 0x02D8, 0x02D8, 0x02C8, 0x02B9, 0x02AA, 0x029C, 
+    0x028F, 0x0282, 0x0276, 0x026A, 0x025E, 0x0253, 0x0249, 0x023E, 0x0234, 0x022B, 0x0222, 0x0219, 0x0210, 0x0208, 0x0200, 0x01F8, 
+    0x01F0, 0x01E9, 0x01E9, 0x01E1, 0x01DA, 0x01D4, 0x01CD, 0x01C7, 0x01C0, 0x01BA, 0x01B4, 0x01AF, 0x01A9, 0x01A4, 0x019E, 0x0199, 
+    0x0194, 0x018F, 0x018A, 0x0186, 0x0181, 0x017D, 0x0178, 0x0174, 0x0170, 0x016C, 0x0168, 0x0164, 0x0160, 0x015C, 0x0158, 0x0155, 
+    0x0151, 0x014E, 0x014A, 0x0147, 0x0144, 0x0141, 0x013E, 0x013B, 0x0138, 0x0135, 0x0132, 0x012F, 0x012C, 0x0129, 0x0127, 0x0124, 
+    0x0121, 0x011F, 0x011C, 0x011A, 0x0118, 0x0115, 0x0113, 0x0111, 0x010E, 0x010C, 0x010A, 0x0108, 0x0106, 0x0104, 0x0102, 0x0100, 
+    0x0800, 0x0800, 0x0800, 0x0800, 0x0800, 0x0787, 0x0787, 0x0787, 0x071C, 0x071C, 0x06BC, 0x06BC, 0x0666, 0x0618, 0x0618, 0x05D1, 
+    0x05D1, 0x0590, 0x0555, 0x051E, 0x051E, 0x04EC, 0x04BD, 0x0492, 0x0469, 0x0469, 0x0444, 0x0421, 0x0400, 0x03E0, 0x03C3, 0x03A8, 
+    0x038E, 0x038E, 0x0375, 0x035E, 0x0348, 0x0333, 0x031F, 0x030C, 0x02FA, 0x02E8, 0x02D8, 0x02C8, 0x02C8, 0x02B9, 0x02AA, 0x029C, 
+    0x028F, 0x0282, 0x0276, 0x026A, 0x025E, 0x0253, 0x0249, 0x023E, 0x0234, 0x022B, 0x0222, 0x0219, 0x0210, 0x0208, 0x0200, 0x01F8, 
+    0x01F0, 0x01E9, 0x01E1, 0x01DA, 0x01DA, 0x01D4, 0x01CD, 0x01C7, 0x01C0, 0x01BA, 0x01B4, 0x01AF, 0x01A9, 0x01A4, 0x019E, 0x0199, 
+    0x0194, 0x018F, 0x018A, 0x0186, 0x0181, 0x017D, 0x0178, 0x0174, 0x0170, 0x016C, 0x0168, 0x0164, 0x0160, 0x015C, 0x0158, 0x0155, 
+    0x0151, 0x014E, 0x014A, 0x0147, 0x0144, 0x0141, 0x013E, 0x013B, 0x0138, 0x0135, 0x0132, 0x012F, 0x012C, 0x0129, 0x0127, 0x0124, 
+    0x0121, 0x011F, 0x011C, 0x011A, 0x0118, 0x0115, 0x0113, 0x0111, 0x010E, 0x010C, 0x010A, 0x0108, 0x0106, 0x0104, 0x0102, 0x0100, 
+    0x0800, 0x0800, 0x0800, 0x0787, 0x0787, 0x0787, 0x0787, 0x071C, 0x071C, 0x06BC, 0x06BC, 0x0666, 0x0666, 0x0618, 0x0618, 0x05D1, 
+    0x0590, 0x0590, 0x0555, 0x051E, 0x04EC, 0x04EC, 0x04BD, 0x0492, 0x0469, 0x0444, 0x0444, 0x0421, 0x0400, 0x03E0, 0x03C3, 0x03A8, 
+    0x038E, 0x0375, 0x0375, 0x035E, 0x0348, 0x0333, 0x031F, 0x030C, 0x02FA, 0x02E8, 0x02D8, 0x02C8, 0x02B9, 0x02AA, 0x02AA, 0x029C, 
+    0x028F, 0x0282, 0x0276, 0x026A, 0x025E, 0x0253, 0x0249, 0x023E, 0x0234, 0x022B, 0x0222, 0x0219, 0x0210, 0x0208, 0x0200, 0x01F8, 
+    0x01F0, 0x01E9, 0x01E1, 0x01DA, 0x01D4, 0x01CD, 0x01CD, 0x01C7, 0x01C0, 0x01BA, 0x01B4, 0x01AF, 0x01A9, 0x01A4, 0x019E, 0x0199, 
+    0x0194, 0x018F, 0x018A, 0x0186, 0x0181, 0x017D, 0x0178, 0x0174, 0x0170, 0x016C, 0x0168, 0x0164, 0x0160, 0x015C, 0x0158, 0x0155, 
+    0x0151, 0x014E, 0x014A, 0x0147, 0x0144, 0x0141, 0x013E, 0x013B, 0x0138, 0x0135, 0x0132, 0x012F, 0x012C, 0x0129, 0x0127, 0x0124, 
+    0x0121, 0x011F, 0x011C, 0x011A, 0x0118, 0x0115, 0x0113, 0x0111, 0x010E, 0x010C, 0x010A, 0x0108, 0x0106, 0x0104, 0x0102, 0x0100, 
+    0x0787, 0x0787, 0x0787, 0x0787, 0x0787, 0x0787, 0x071C, 0x071C, 0x071C, 0x06BC, 0x06BC, 0x0666, 0x0666, 0x0618, 0x05D1, 0x05D1, 
+    0x0590, 0x0555, 0x0555, 0x051E, 0x04EC, 0x04BD, 0x04BD, 0x0492, 0x0469, 0x0444, 0x0421, 0x0421, 0x0400, 0x03E0, 0x03C3, 0x03A8, 
+    0x038E, 0x0375, 0x035E, 0x035E, 0x0348, 0x0333, 0x031F, 0x030C, 0x02FA, 0x02E8, 0x02D8, 0x02C8, 0x02B9, 0x02AA, 0x029C, 0x028F, 
+    0x028F, 0x0282, 0x0276, 0x026A, 0x025E, 0x0253, 0x0249, 0x023E, 0x0234, 0x022B, 0x0222, 0x0219, 0x0210, 0x0208, 0x0200, 0x01F8, 
+    0x01F0, 0x01E9, 0x01E1, 0x01DA, 0x01D4, 0x01CD, 0x01C7, 0x01C0, 0x01BA, 0x01BA, 0x01B4, 0x01AF, 0x01A9, 0x01A4, 0x019E, 0x0199, 
+    0x0194, 0x018F, 0x018A, 0x0186, 0x0181, 0x017D, 0x0178, 0x0174, 0x0170, 0x016C, 0x0168, 0x0164, 0x0160, 0x015C, 0x0158, 0x0155, 
+    0x0151, 0x014E, 0x014A, 0x0147, 0x0144, 0x0141, 0x013E, 0x013B, 0x0138, 0x0135, 0x0132, 0x012F, 0x012C, 0x0129, 0x0127, 0x0124, 
+    0x0121, 0x011F, 0x011C, 0x011A, 0x0118, 0x0115, 0x0113, 0x0111, 0x010E, 0x010C, 0x010A, 0x0108, 0x0106, 0x0104, 0x0102, 0x0100, 
+    0x0787, 0x0787, 0x0787, 0x0787, 0x0787, 0x071C, 0x071C, 0x071C, 0x06BC, 0x06BC, 0x0666, 0x0666, 0x0618, 0x0618, 0x05D1, 0x0590, 
+    0x0590, 0x0555, 0x051E, 0x051E, 0x04EC, 0x04BD, 0x0492, 0x0492, 0x0469, 0x0444, 0x0421, 0x0400, 0x03E0, 0x03E0, 0x03C3, 0x03A8, 
+    0x038E, 0x0375, 0x035E, 0x0348, 0x0333, 0x0333, 0x031F, 0x030C, 0x02FA, 0x02E8, 0x02D8, 0x02C8, 0x02B9, 0x02AA, 0x029C, 0x028F, 
+    0x0282, 0x0276, 0x0276, 0x026A, 0x025E, 0x0253, 0x0249, 0x023E, 0x0234, 0x022B, 0x0222, 0x0219, 0x0210, 0x0208, 0x0200, 0x01F8, 
+    0x01F0, 0x01E9, 0x01E1, 0x01DA, 0x01D4, 0x01CD, 0x01C7, 0x01C0, 0x01BA, 0x01B4, 0x01AF, 0x01A9, 0x01A9, 0x01A4, 0x019E, 0x0199, 
+    0x0194, 0x018F, 0x018A, 0x0186, 0x0181, 0x017D, 0x0178, 0x0174, 0x0170, 0x016C, 0x0168, 0x0164, 0x0160, 0x015C, 0x0158, 0x0155, 
+    0x0151, 0x014E, 0x014A, 0x0147, 0x0144, 0x0141, 0x013E, 0x013B, 0x0138, 0x0135, 0x0132, 0x012F, 0x012C, 0x0129, 0x0127, 0x0124, 
+    0x0121, 0x011F, 0x011C, 0x011A, 0x0118, 0x0115, 0x0113, 0x0111, 0x010E, 0x010C, 0x010A, 0x0108, 0x0106, 0x0104, 0x0102, 0x0100, 
+    0x0787, 0x0787, 0x071C, 0x071C, 0x071C, 0x071C, 0x071C, 0x06BC, 0x06BC, 0x0666, 0x0666, 0x0618, 0x0618, 0x05D1, 0x05D1, 0x0590, 
+    0x0555, 0x0555, 0x051E, 0x04EC, 0x04EC, 0x04BD, 0x0492, 0x0469, 0x0469, 0x0444, 0x0421, 0x0400, 0x03E0, 0x03C3, 0x03C3, 0x03A8, 
+    0x038E, 0x0375, 0x035E, 0x0348, 0x0333, 0x031F, 0x030C, 0x030C, 0x02FA, 0x02E8, 0x02D8, 0x02C8, 0x02B9, 0x02AA, 0x029C, 0x028F, 
+    0x0282, 0x0276, 0x026A, 0x025E, 0x025E, 0x0253, 0x0249, 0x023E, 0x0234, 0x022B, 0x0222, 0x0219, 0x0210, 0x0208, 0x0200, 0x01F8, 
+    0x01F0, 0x01E9, 0x01E1, 0x01DA, 0x01D4, 0x01CD, 0x01C7, 0x01C0, 0x01BA, 0x01B4, 0x01AF, 0x01A9, 0x01A4, 0x019E, 0x0199, 0x0194, 
+    0x0194, 0x018F, 0x018A, 0x0186, 0x0181, 0x017D, 0x0178, 0x0174, 0x0170, 0x016C, 0x0168, 0x0164, 0x0160, 0x015C, 0x0158, 0x0155, 
+    0x0151, 0x014E, 0x014A, 0x0147, 0x0144, 0x0141, 0x013E, 0x013B, 0x0138, 0x0135, 0x0132, 0x012F, 0x012C, 0x0129, 0x0127, 0x0124, 
+    0x0121, 0x011F, 0x011C, 0x011A, 0x0118, 0x0115, 0x0113, 0x0111, 0x010E, 0x010C, 0x010A, 0x0108, 0x0106, 0x0104, 0x0102, 0x0100, 
+    0x071C, 0x071C, 0x071C, 0x071C, 0x071C, 0x06BC, 0x06BC, 0x06BC, 0x0666, 0x0666, 0x0666, 0x0618, 0x0618, 0x05D1, 0x0590, 0x0590, 
+    0x0555, 0x051E, 0x051E, 0x04EC, 0x04BD, 0x04BD, 0x0492, 0x0469, 0x0444, 0x0421, 0x0421, 0x0400, 0x03E0, 0x03C3, 0x03A8, 0x038E, 
+    0x038E, 0x0375, 0x035E, 0x0348, 0x0333, 0x031F, 0x030C, 0x02FA, 0x02E8, 0x02E8, 0x02D8, 0x02C8, 0x02B9, 0x02AA, 0x029C, 0x028F, 
+    0x0282, 0x0276, 0x026A, 0x025E, 0x0253, 0x0249, 0x023E, 0x023E, 0x0234, 0x022B, 0x0222, 0x0219, 0x0210, 0x0208, 0x0200, 0x01F8, 
+    0x01F0, 0x01E9, 0x01E1, 0x01DA, 0x01D4, 0x01CD, 0x01C7, 0x01C0, 0x01BA, 0x01B4, 0x01AF, 0x01A9, 0x01A4, 0x019E, 0x0199, 0x0194, 
+    0x018F, 0x018A, 0x0186, 0x0181, 0x0181, 0x017D, 0x0178, 0x0174, 0x0170, 0x016C, 0x0168, 0x0164, 0x0160, 0x015C, 0x0158, 0x0155, 
+    0x0151, 0x014E, 0x014A, 0x0147, 0x0144, 0x0141, 0x013E, 0x013B, 0x0138, 0x0135, 0x0132, 0x012F, 0x012C, 0x0129, 0x0127, 0x0124, 
+    0x0121, 0x011F, 0x011C, 0x011A, 0x0118, 0x0115, 0x0113, 0x0111, 0x010E, 0x010C, 0x010A, 0x0108, 0x0106, 0x0104, 0x0102, 0x0100, 
+    0x071C, 0x071C, 0x071C, 0x06BC, 0x06BC, 0x06BC, 0x06BC, 0x0666, 0x0666, 0x0666, 0x0618, 0x0618, 0x05D1, 0x05D1, 0x0590, 0x0555, 
+    0x0555, 0x051E, 0x04EC, 0x04EC, 0x04BD, 0x0492, 0x0492, 0x0469, 0x0444, 0x0421, 0x0400, 0x0400, 0x03E0, 0x03C3, 0x03A8, 0x038E, 
+    0x0375, 0x035E, 0x035E, 0x0348, 0x0333, 0x031F, 0x030C, 0x02FA, 0x02E8, 0x02D8, 0x02C8, 0x02C8, 0x02B9, 0x02AA, 0x029C, 0x028F, 
+    0x0282, 0x0276, 0x026A, 0x025E, 0x0253, 0x0249, 0x023E, 0x0234, 0x022B, 0x0222, 0x0222, 0x0219, 0x0210, 0x0208, 0x0200, 0x01F8, 
+    0x01F0, 0x01E9, 0x01E1, 0x01DA, 0x01D4, 0x01CD, 0x01C7, 0x01C0, 0x01BA, 0x01B4, 0x01AF, 0x01A9, 0x01A4, 0x019E, 0x0199, 0x0194, 
+    0x018F, 0x018A, 0x0186, 0x0181, 0x017D, 0x0178, 0x0174, 0x0170, 0x016C, 0x016C, 0x0168, 0x0164, 0x0160, 0x015C, 0x0158, 0x0155, 
+    0x0151, 0x014E, 0x014A, 0x0147, 0x0144, 0x0141, 0x013E, 0x013B, 0x0138, 0x0135, 0x0132, 0x012F, 0x012C, 0x0129, 0x0127, 0x0124, 
+    0x0121, 0x011F, 0x011C, 0x011A, 0x0118, 0x0115, 0x0113, 0x0111, 0x010E, 0x010C, 0x010A, 0x0108, 0x0106, 0x0104, 0x0102, 0x0100, 
+    0x06BC, 0x06BC, 0x06BC, 0x06BC, 0x06BC, 0x0666, 0x0666, 0x0666, 0x0618, 0x0618, 0x0618, 0x05D1, 0x05D1, 0x0590, 0x0590, 0x0555, 
+    0x051E, 0x051E, 0x04EC, 0x04BD, 0x04BD, 0x0492, 0x0469, 0x0444, 0x0444, 0x0421, 0x0400, 0x03E0, 0x03C3, 0x03C3, 0x03A8, 0x038E, 
+    0x0375, 0x035E, 0x0348, 0x0333, 0x0333, 0x031F, 0x030C, 0x02FA, 0x02E8, 0x02D8, 0x02C8, 0x02B9, 0x02AA, 0x029C, 0x029C, 0x028F, 
+    0x0282, 0x0276, 0x026A, 0x025E, 0x0253, 0x0249, 0x023E, 0x0234, 0x022B, 0x0222, 0x0219, 0x0210, 0x0208, 0x0200, 0x0200, 0x01F8, 
+    0x01F0, 0x01E9, 0x01E1, 0x01DA, 0x01D4, 0x01CD, 0x01C7, 0x01C0, 0x01BA, 0x01B4, 0x01AF, 0x01A9, 0x01A4, 0x019E, 0x0199, 0x0194, 
+    0x018F, 0x018A, 0x0186, 0x0181, 0x017D, 0x0178, 0x0174, 0x0170, 0x016C, 0x0168, 0x0164, 0x0160, 0x015C, 0x0158, 0x0158, 0x0155, 
+    0x0151, 0x014E, 0x014A, 0x0147, 0x0144, 0x0141, 0x013E, 0x013B, 0x0138, 0x0135, 0x0132, 0x012F, 0x012C, 0x0129, 0x0127, 0x0124, 
+    0x0121, 0x011F, 0x011C, 0x011A, 0x0118, 0x0115, 0x0113, 0x0111, 0x010E, 0x010C, 0x010A, 0x0108, 0x0106, 0x0104, 0x0102, 0x0100, 
+    0x0666, 0x0666, 0x0666, 0x0666, 0x0666, 0x0666, 0x0666, 0x0618, 0x0618, 0x0618, 0x05D1, 0x05D1, 0x0590, 0x0590, 0x0555, 0x051E, 
+    0x051E, 0x04EC, 0x04EC, 0x04BD, 0x0492, 0x0469, 0x0469, 0x0444, 0x0421, 0x0400, 0x0400, 0x03E0, 0x03C3, 0x03A8, 0x038E, 0x038E, 
+    0x0375, 0x035E, 0x0348, 0x0333, 0x031F, 0x030C, 0x030C, 0x02FA, 0x02E8, 0x02D8, 0x02C8, 0x02B9, 0x02AA, 0x029C, 0x028F, 0x0282, 
+    0x0276, 0x0276, 0x026A, 0x025E, 0x0253, 0x0249, 0x023E, 0x0234, 0x022B, 0x0222, 0x0219, 0x0210, 0x0208, 0x0200, 0x01F8, 0x01F0, 
+    0x01E9, 0x01E1, 0x01E1, 0x01DA, 0x01D4, 0x01CD, 0x01C7, 0x01C0, 0x01BA, 0x01B4, 0x01AF, 0x01A9, 0x01A4, 0x019E, 0x0199, 0x0194, 
+    0x018F, 0x018A, 0x0186, 0x0181, 0x017D, 0x0178, 0x0174, 0x0170, 0x016C, 0x0168, 0x0164, 0x0160, 0x015C, 0x0158, 0x0155, 0x0151, 
+    0x014E, 0x014A, 0x0147, 0x0144, 0x0144, 0x0141, 0x013E, 0x013B, 0x0138, 0x0135, 0x0132, 0x012F, 0x012C, 0x0129, 0x0127, 0x0124, 
+    0x0121, 0x011F, 0x011C, 0x011A, 0x0118, 0x0115, 0x0113, 0x0111, 0x010E, 0x010C, 0x010A, 0x0108, 0x0106, 0x0104, 0x0102, 0x0100, 
+    0x0666, 0x0666, 0x0666, 0x0666, 0x0618, 0x0618, 0x0618, 0x0618, 0x05D1, 0x05D1, 0x05D1, 0x0590, 0x0590, 0x0555, 0x0555, 0x051E, 
+    0x04EC, 0x04EC, 0x04BD, 0x0492, 0x0492, 0x0469, 0x0444, 0x0444, 0x0421, 0x0400, 0x03E0, 0x03E0, 0x03C3, 0x03A8, 0x038E, 0x0375, 
+    0x035E, 0x035E, 0x0348, 0x0333, 0x031F, 0x030C, 0x02FA, 0x02E8, 0x02D8, 0x02D8, 0x02C8, 0x02B9, 0x02AA, 0x029C, 0x028F, 0x0282, 
+    0x0276, 0x026A, 0x025E, 0x0253, 0x0253, 0x0249, 0x023E, 0x0234, 0x022B, 0x0222, 0x0219, 0x0210, 0x0208, 0x0200, 0x01F8, 0x01F0, 
+    0x01E9, 0x01E1, 0x01DA, 0x01D4, 0x01CD, 0x01C7, 0x01C7, 0x01C0, 0x01BA, 0x01B4, 0x01AF, 0x01A9, 0x01A4, 0x019E, 0x0199, 0x0194, 
+    0x018F, 0x018A, 0x0186, 0x0181, 0x017D, 0x0178, 0x0174, 0x0170, 0x016C, 0x0168, 0x0164, 0x0160, 0x015C, 0x0158, 0x0155, 0x0151, 
+    0x014E, 0x014A, 0x0147, 0x0144, 0x0141, 0x013E, 0x013B, 0x0138, 0x0135, 0x0132, 0x0132, 0x012F, 0x012C, 0x0129, 0x0127, 0x0124, 
+    0x0121, 0x011F, 0x011C, 0x011A, 0x0118, 0x0115, 0x0113, 0x0111, 0x010E, 0x010C, 0x010A, 0x0108, 0x0106, 0x0104, 0x0102, 0x0100, 
+    0x0618, 0x0618, 0x0618, 0x0618, 0x0618, 0x0618, 0x05D1, 0x05D1, 0x05D1, 0x0590, 0x0590, 0x0590, 0x0555, 0x0555, 0x051E, 0x04EC, 
+    0x04EC, 0x04BD, 0x04BD, 0x0492, 0x0469, 0x0469, 0x0444, 0x0421, 0x0400, 0x0400, 0x03E0, 0x03C3, 0x03A8, 0x03A8, 0x038E, 0x0375, 
+    0x035E, 0x0348, 0x0333, 0x0333, 0x031F, 0x030C, 0x02FA, 0x02E8, 0x02D8, 0x02C8, 0x02B9, 0x02B9, 0x02AA, 0x029C, 0x028F, 0x0282, 
+    0x0276, 0x026A, 0x025E, 0x0253, 0x0249, 0x023E, 0x0234, 0x0234, 0x022B, 0x0222, 0x0219, 0x0210, 0x0208, 0x0200, 0x01F8, 0x01F0, 
+    0x01E9, 0x01E1, 0x01DA, 0x01D4, 0x01CD, 0x01C7, 0x01C0, 0x01BA, 0x01B4, 0x01AF, 0x01AF, 0x01A9, 0x01A4, 0x019E, 0x0199, 0x0194, 
+    0x018F, 0x018A, 0x0186, 0x0181, 0x017D, 0x0178, 0x0174, 0x0170, 0x016C, 0x0168, 0x0164, 0x0160, 0x015C, 0x0158, 0x0155, 0x0151, 
+    0x014E, 0x014A, 0x0147, 0x0144, 0x0141, 0x013E, 0x013B, 0x0138, 0x0135, 0x0132, 0x012F, 0x012C, 0x0129, 0x0127, 0x0124, 0x0121, 
+    0x011F, 0x011F, 0x011C, 0x011A, 0x0118, 0x0115, 0x0113, 0x0111, 0x010E, 0x010C, 0x010A, 0x0108, 0x0106, 0x0104, 0x0102, 0x0100, 
+    0x0618, 0x0618, 0x05D1, 0x05D1, 0x05D1, 0x05D1, 0x05D1, 0x0590, 0x0590, 0x0590, 0x0555, 0x0555, 0x051E, 0x051E, 0x04EC, 0x04EC, 
+    0x04BD, 0x04BD, 0x0492, 0x0469, 0x0469, 0x0444, 0x0421, 0x0421, 0x0400, 0x03E0, 0x03C3, 0x03C3, 0x03A8, 0x038E, 0x0375, 0x0375, 
+    0x035E, 0x0348, 0x0333, 0x031F, 0x030C, 0x02FA, 0x02FA, 0x02E8, 0x02D8, 0x02C8, 0x02B9, 0x02AA, 0x029C, 0x028F, 0x028F, 0x0282, 
+    0x0276, 0x026A, 0x025E, 0x0253, 0x0249, 0x023E, 0x0234, 0x022B, 0x0222, 0x0219, 0x0210, 0x0210, 0x0208, 0x0200, 0x01F8, 0x01F0, 
+    0x01E9, 0x01E1, 0x01DA, 0x01D4, 0x01CD, 0x01C7, 0x01C0, 0x01BA, 0x01B4, 0x01AF, 0x01A9, 0x01A4, 0x019E, 0x0199, 0x0194, 0x0194, 
+    0x018F, 0x018A, 0x0186, 0x0181, 0x017D, 0x0178, 0x0174, 0x0170, 0x016C, 0x0168, 0x0164, 0x0160, 0x015C, 0x0158, 0x0155, 0x0151, 
+    0x014E, 0x014A, 0x0147, 0x0144, 0x0141, 0x013E, 0x013B, 0x0138, 0x0135, 0x0132, 0x012F, 0x012C, 0x0129, 0x0127, 0x0124, 0x0121, 
+    0x011F, 0x011C, 0x011A, 0x0118, 0x0115, 0x0113, 0x0111, 0x010E, 0x010E, 0x010C, 0x010A, 0x0108, 0x0106, 0x0104, 0x0102, 0x0100, 
+    0x05D1, 0x05D1, 0x05D1, 0x05D1, 0x05D1, 0x0590, 0x0590, 0x0590, 0x0555, 0x0555, 0x0555, 0x051E, 0x051E, 0x04EC, 0x04EC, 0x04BD, 
+    0x04BD, 0x0492, 0x0492, 0x0469, 0x0444, 0x0444, 0x0421, 0x0400, 0x0400, 0x03E0, 0x03C3, 0x03A8, 0x038E, 0x038E, 0x0375, 0x035E, 
+    0x0348, 0x0333, 0x0333, 0x031F, 0x030C, 0x02FA, 0x02E8, 0x02D8, 0x02D8, 0x02C8, 0x02B9, 0x02AA, 0x029C, 0x028F, 0x0282, 0x0276, 
+    0x026A, 0x026A, 0x025E, 0x0253, 0x0249, 0x023E, 0x0234, 0x022B, 0x0222, 0x0219, 0x0210, 0x0208, 0x0200, 0x01F8, 0x01F0, 0x01F0, 
+    0x01E9, 0x01E1, 0x01DA, 0x01D4, 0x01CD, 0x01C7, 0x01C0, 0x01BA, 0x01B4, 0x01AF, 0x01A9, 0x01A4, 0x019E, 0x0199, 0x0194, 0x018F, 
+    0x018A, 0x0186, 0x0181, 0x017D, 0x017D, 0x0178, 0x0174, 0x0170, 0x016C, 0x0168, 0x0164, 0x0160, 0x015C, 0x0158, 0x0155, 0x0151, 
+    0x014E, 0x014A, 0x0147, 0x0144, 0x0141, 0x013E, 0x013B, 0x0138, 0x0135, 0x0132, 0x012F, 0x012C, 0x0129, 0x0127, 0x0124, 0x0121, 
+    0x011F, 0x011C, 0x011A, 0x0118, 0x0115, 0x0113, 0x0111, 0x010E, 0x010C, 0x010A, 0x0108, 0x0106, 0x0104, 0x0102, 0x0100, 0x00FE, 
+    0x0590, 0x0590, 0x0590, 0x0590, 0x0590, 0x0590, 0x0555, 0x0555, 0x0555, 0x051E, 0x051E, 0x051E, 0x04EC, 0x04EC, 0x04BD, 0x04BD, 
+    0x0492, 0x0492, 0x0469, 0x0444, 0x0444, 0x0421, 0x0400, 0x0400, 0x03E0, 0x03C3, 0x03C3, 0x03A8, 0x038E, 0x0375, 0x035E, 0x035E, 
+    0x0348, 0x0333, 0x031F, 0x030C, 0x030C, 0x02FA, 0x02E8, 0x02D8, 0x02C8, 0x02B9, 0x02AA, 0x02AA, 0x029C, 0x028F, 0x0282, 0x0276, 
+    0x026A, 0x025E, 0x0253, 0x0249, 0x023E, 0x023E, 0x0234, 0x022B, 0x0222, 0x0219, 0x0210, 0x0208, 0x0200, 0x01F8, 0x01F0, 0x01E9, 
+    0x01E1, 0x01DA, 0x01D4, 0x01D4, 0x01CD, 0x01C7, 0x01C0, 0x01BA, 0x01B4, 0x01AF, 0x01A9, 0x01A4, 0x019E, 0x0199, 0x0194, 0x018F, 
+    0x018A, 0x0186, 0x0181, 0x017D, 0x0178, 0x0174, 0x0170, 0x016C, 0x0168, 0x0164, 0x0164, 0x0160, 0x015C, 0x0158, 0x0155, 0x0151, 
+    0x014E, 0x014A, 0x0147, 0x0144, 0x0141, 0x013E, 0x013B, 0x0138, 0x0135, 0x0132, 0x012F, 0x012C, 0x0129, 0x0127, 0x0124, 0x0121, 
+    0x011F, 0x011C, 0x011A, 0x0118, 0x0115, 0x0113, 0x0111, 0x010E, 0x010C, 0x010A, 0x0108, 0x0106, 0x0104, 0x0102, 0x0100, 0x00FE, 
+    0x0555, 0x0555, 0x0555, 0x0555, 0x0555, 0x0555, 0x0555, 0x051E, 0x051E, 0x051E, 0x04EC, 0x04EC, 0x04EC, 0x04BD, 0x04BD, 0x0492, 
+    0x0492, 0x0469, 0x0444, 0x0444, 0x0421, 0x0421, 0x0400, 0x03E0, 0x03C3, 0x03C3, 0x03A8, 0x038E, 0x038E, 0x0375, 0x035E, 0x0348, 
+    0x0333, 0x0333, 0x031F, 0x030C, 0x02FA, 0x02E8, 0x02E8, 0x02D8, 0x02C8, 0x02B9, 0x02AA, 0x029C, 0x028F, 0x0282, 0x0282, 0x0276, 
+    0x026A, 0x025E, 0x0253, 0x0249, 0x023E, 0x0234, 0x022B, 0x0222, 0x0222, 0x0219, 0x0210, 0x0208, 0x0200, 0x01F8, 0x01F0, 0x01E9, 
+    0x01E1, 0x01DA, 0x01D4, 0x01CD, 0x01C7, 0x01C0, 0x01BA, 0x01BA, 0x01B4, 0x01AF, 0x01A9, 0x01A4, 0x019E, 0x0199, 0x0194, 0x018F, 
+    0x018A, 0x0186, 0x0181, 0x017D, 0x0178, 0x0174, 0x0170, 0x016C, 0x0168, 0x0164, 0x0160, 0x015C, 0x0158, 0x0155, 0x0151, 0x014E, 
+    0x014E, 0x014A, 0x0147, 0x0144, 0x0141, 0x013E, 0x013B, 0x0138, 0x0135, 0x0132, 0x012F, 0x012C, 0x0129, 0x0127, 0x0124, 0x0121, 
+    0x011F, 0x011C, 0x011A, 0x0118, 0x0115, 0x0113, 0x0111, 0x010E, 0x010C, 0x010A, 0x0108, 0x0106, 0x0104, 0x0102, 0x0100, 0x00FE, 
+    0x0555, 0x0555, 0x0555, 0x051E, 0x051E, 0x051E, 0x051E, 0x051E, 0x04EC, 0x04EC, 0x04EC, 0x04BD, 0x04BD, 0x0492, 0x0492, 0x0469, 
+    0x0469, 0x0444, 0x0444, 0x0421, 0x0421, 0x0400, 0x03E0, 0x03E0, 0x03C3, 0x03A8, 0x03A8, 0x038E, 0x0375, 0x035E, 0x035E, 0x0348, 
+    0x0333, 0x031F, 0x030C, 0x030C, 0x02FA, 0x02E8, 0x02D8, 0x02C8, 0x02B9, 0x02B9, 0x02AA, 0x029C, 0x028F, 0x0282, 0x0276, 0x026A, 
+    0x025E, 0x025E, 0x0253, 0x0249, 0x023E, 0x0234, 0x022B, 0x0222, 0x0219, 0x0210, 0x0208, 0x0200, 0x0200, 0x01F8, 0x01F0, 0x01E9, 
+    0x01E1, 0x01DA, 0x01D4, 0x01CD, 0x01C7, 0x01C0, 0x01BA, 0x01B4, 0x01AF, 0x01A9, 0x01A4, 0x019E, 0x019E, 0x0199, 0x0194, 0x018F, 
+    0x018A, 0x0186, 0x0181, 0x017D, 0x0178, 0x0174, 0x0170, 0x016C, 0x0168, 0x0164, 0x0160, 0x015C, 0x0158, 0x0155, 0x0151, 0x014E, 
+    0x014A, 0x0147, 0x0144, 0x0141, 0x013E, 0x013B, 0x013B, 0x0138, 0x0135, 0x0132, 0x012F, 0x012C, 0x0129, 0x0127, 0x0124, 0x0121, 
+    0x011F, 0x011C, 0x011A, 0x0118, 0x0115, 0x0113, 0x0111, 0x010E, 0x010C, 0x010A, 0x0108, 0x0106, 0x0104, 0x0102, 0x0100, 0x00FE, 
+    0x051E, 0x051E, 0x051E, 0x051E, 0x051E, 0x04EC, 0x04EC, 0x04EC, 0x04EC, 0x04BD, 0x04BD, 0x04BD, 0x0492, 0x0492, 0x0469, 0x0469, 
+    0x0444, 0x0444, 0x0421, 0x0421, 0x0400, 0x03E0, 0x03E0, 0x03C3, 0x03A8, 0x03A8, 0x038E, 0x0375, 0x0375, 0x035E, 0x0348, 0x0333, 
+    0x0333, 0x031F, 0x030C, 0x02FA, 0x02E8, 0x02D8, 0x02D8, 0x02C8, 0x02B9, 0x02AA, 0x029C, 0x028F, 0x028F, 0x0282, 0x0276, 0x026A, 
+    0x025E, 0x0253, 0x0249, 0x023E, 0x023E, 0x0234, 0x022B, 0x0222, 0x0219, 0x0210, 0x0208, 0x0200, 0x01F8, 0x01F0, 0x01E9, 0x01E1, 
+    0x01E1, 0x01DA, 0x01D4, 0x01CD, 0x01C7, 0x01C0, 0x01BA, 0x01B4, 0x01AF, 0x01A9, 0x01A4, 0x019E, 0x0199, 0x0194, 0x018F, 0x018A, 
+    0x0186, 0x0186, 0x0181, 0x017D, 0x0178, 0x0174, 0x0170, 0x016C, 0x0168, 0x0164, 0x0160, 0x015C, 0x0158, 0x0155, 0x0151, 0x014E, 
+    0x014A, 0x0147, 0x0144, 0x0141, 0x013E, 0x013B, 0x0138, 0x0135, 0x0132, 0x012F, 0x012C, 0x0129, 0x0129, 0x0127, 0x0124, 0x0121, 
+    0x011F, 0x011C, 0x011A, 0x0118, 0x0115, 0x0113, 0x0111, 0x010E, 0x010C, 0x010A, 0x0108, 0x0106, 0x0104, 0x0102, 0x0100, 0x00FE, 
+    0x04EC, 0x04EC, 0x04EC, 0x04EC, 0x04EC, 0x04EC, 0x04BD, 0x04BD, 0x04BD, 0x04BD, 0x0492, 0x0492, 0x0469, 0x0469, 0x0469, 0x0444, 
+    0x0444, 0x0421, 0x0421, 0x0400, 0x03E0, 0x03E0, 0x03C3, 0x03A8, 0x03A8, 0x038E, 0x0375, 0x0375, 0x035E, 0x0348, 0x0348, 0x0333, 
+    0x031F, 0x030C, 0x02FA, 0x02FA, 0x02E8, 0x02D8, 0x02C8, 0x02B9, 0x02B9, 0x02AA, 0x029C, 0x028F, 0x0282, 0x0276, 0x026A, 0x026A, 
+    0x025E, 0x0253, 0x0249, 0x023E, 0x0234, 0x022B, 0x0222, 0x0219, 0x0219, 0x0210, 0x0208, 0x0200, 0x01F8, 0x01F0, 0x01E9, 0x01E1, 
+    0x01DA, 0x01D4, 0x01CD, 0x01C7, 0x01C7, 0x01C0, 0x01BA, 0x01B4, 0x01AF, 0x01A9, 0x01A4, 0x019E, 0x0199, 0x0194, 0x018F, 0x018A, 
+    0x0186, 0x0181, 0x017D, 0x0178, 0x0174, 0x0170, 0x0170, 0x016C, 0x0168, 0x0164, 0x0160, 0x015C, 0x0158, 0x0155, 0x0151, 0x014E, 
+    0x014A, 0x0147, 0x0144, 0x0141, 0x013E, 0x013B, 0x0138, 0x0135, 0x0132, 0x012F, 0x012C, 0x0129, 0x0127, 0x0124, 0x0121, 0x011F, 
+    0x011C, 0x011A, 0x0118, 0x0118, 0x0115, 0x0113, 0x0111, 0x010E, 0x010C, 0x010A, 0x0108, 0x0106, 0x0104, 0x0102, 0x0100, 0x00FE, 
+    0x04BD, 0x04BD, 0x04BD, 0x04BD, 0x04BD, 0x04BD, 0x04BD, 0x0492, 0x0492, 0x0492, 0x0492, 0x0469, 0x0469, 0x0444, 0x0444, 0x0421, 
+    0x0421, 0x0400, 0x0400, 0x03E0, 0x03E0, 0x03C3, 0x03C3, 0x03A8, 0x038E, 0x038E, 0x0375, 0x035E, 0x0348, 0x0348, 0x0333, 0x031F, 
+    0x030C, 0x030C, 0x02FA, 0x02E8, 0x02D8, 0x02D8, 0x02C8, 0x02B9, 0x02AA, 0x029C, 0x028F, 0x028F, 0x0282, 0x0276, 0x026A, 0x025E, 
+    0x0253, 0x0249, 0x0249, 0x023E, 0x0234, 0x022B, 0x0222, 0x0219, 0x0210, 0x0208, 0x0200, 0x0200, 0x01F8, 0x01F0, 0x01E9, 0x01E1, 
+    0x01DA, 0x01D4, 0x01CD, 0x01C7, 0x01C0, 0x01BA, 0x01B4, 0x01AF, 0x01AF, 0x01A9, 0x01A4, 0x019E, 0x0199, 0x0194, 0x018F, 0x018A, 
+    0x0186, 0x0181, 0x017D, 0x0178, 0x0174, 0x0170, 0x016C, 0x0168, 0x0164, 0x0160, 0x015C, 0x015C, 0x0158, 0x0155, 0x0151, 0x014E, 
+    0x014A, 0x0147, 0x0144, 0x0141, 0x013E, 0x013B, 0x0138, 0x0135, 0x0132, 0x012F, 0x012C, 0x0129, 0x0127, 0x0124, 0x0121, 0x011F, 
+    0x011C, 0x011A, 0x0118, 0x0115, 0x0113, 0x0111, 0x010E, 0x010C, 0x010A, 0x0108, 0x0108, 0x0106, 0x0104, 0x0102, 0x0100, 0x00FE, 
+    0x0492, 0x0492, 0x0492, 0x0492, 0x0492, 0x0492, 0x0492, 0x0492, 0x0469, 0x0469, 0x0469, 0x0444, 0x0444, 0x0444, 0x0421, 0x0421, 
+    0x0400, 0x0400, 0x03E0, 0x03E0, 0x03C3, 0x03A8, 0x03A8, 0x038E, 0x038E, 0x0375, 0x035E, 0x035E, 0x0348, 0x0333, 0x031F, 0x031F, 
+    0x030C, 0x02FA, 0x02E8, 0x02E8, 0x02D8, 0x02C8, 0x02B9, 0x02AA, 0x02AA, 0x029C, 0x028F, 0x0282, 0x0276, 0x026A, 0x026A, 0x025E, 
+    0x0253, 0x0249, 0x023E, 0x0234, 0x022B, 0x022B, 0x0222, 0x0219, 0x0210, 0x0208, 0x0200, 0x01F8, 0x01F0, 0x01E9, 0x01E1, 0x01E1, 
+    0x01DA, 0x01D4, 0x01CD, 0x01C7, 0x01C0, 0x01BA, 0x01B4, 0x01AF, 0x01A9, 0x01A4, 0x019E, 0x0199, 0x0194, 0x0194, 0x018F, 0x018A, 
+    0x0186, 0x0181, 0x017D, 0x0178, 0x0174, 0x0170, 0x016C, 0x0168, 0x0164, 0x0160, 0x015C, 0x0158, 0x0155, 0x0151, 0x014E, 0x014A, 
+    0x0147, 0x0147, 0x0144, 0x0141, 0x013E, 0x013B, 0x0138, 0x0135, 0x0132, 0x012F, 0x012C, 0x0129, 0x0127, 0x0124, 0x0121, 0x011F, 
+    0x011C, 0x011A, 0x0118, 0x0115, 0x0113, 0x0111, 0x010E, 0x010C, 0x010A, 0x0108, 0x0106, 0x0104, 0x0102, 0x0100, 0x00FE, 0x00FC, 
+    0x0492, 0x0492, 0x0492, 0x0469, 0x0469, 0x0469, 0x0469, 0x0469, 0x0469, 0x0444, 0x0444, 0x0444, 0x0421, 0x0421, 0x0400, 0x0400, 
+    0x0400, 0x03E0, 0x03C3, 0x03C3, 0x03A8, 0x03A8, 0x038E, 0x038E, 0x0375, 0x035E, 0x035E, 0x0348, 0x0333, 0x0333, 0x031F, 0x030C, 
+    0x02FA, 0x02FA, 0x02E8, 0x02D8, 0x02C8, 0x02C8, 0x02B9, 0x02AA, 0x029C, 0x028F, 0x028F, 0x0282, 0x0276, 0x026A, 0x025E, 0x0253, 
+    0x0249, 0x0249, 0x023E, 0x0234, 0x022B, 0x0222, 0x0219, 0x0210, 0x0210, 0x0208, 0x0200, 0x01F8, 0x01F0, 0x01E9, 0x01E1, 0x01DA, 
+    0x01D4, 0x01CD, 0x01C7, 0x01C7, 0x01C0, 0x01BA, 0x01B4, 0x01AF, 0x01A9, 0x01A4, 0x019E, 0x0199, 0x0194, 0x018F, 0x018A, 0x0186, 
+    0x0181, 0x0181, 0x017D, 0x0178, 0x0174, 0x0170, 0x016C, 0x0168, 0x0164, 0x0160, 0x015C, 0x0158, 0x0155, 0x0151, 0x014E, 0x014A, 
+    0x0147, 0x0144, 0x0141, 0x013E, 0x013B, 0x0138, 0x0135, 0x0135, 0x0132, 0x012F, 0x012C, 0x0129, 0x0127, 0x0124, 0x0121, 0x011F, 
+    0x011C, 0x011A, 0x0118, 0x0115, 0x0113, 0x0111, 0x010E, 0x010C, 0x010A, 0x0108, 0x0106, 0x0104, 0x0102, 0x0100, 0x00FE, 0x00FC, 
+    0x0469, 0x0469, 0x0469, 0x0469, 0x0469, 0x0444, 0x0444, 0x0444, 0x0444, 0x0421, 0x0421, 0x0421, 0x0400, 0x0400, 0x0400, 0x03E0, 
+    0x03E0, 0x03C3, 0x03C3, 0x03A8, 0x03A8, 0x038E, 0x038E, 0x0375, 0x035E, 0x035E, 0x0348, 0x0333, 0x0333, 0x031F, 0x030C, 0x030C, 
+    0x02FA, 0x02E8, 0x02D8, 0x02D8, 0x02C8, 0x02B9, 0x02AA, 0x029C, 0x029C, 0x028F, 0x0282, 0x0276, 0x026A, 0x026A, 0x025E, 0x0253, 
+    0x0249, 0x023E, 0x0234, 0x022B, 0x022B, 0x0222, 0x0219, 0x0210, 0x0208, 0x0200, 0x01F8, 0x01F0, 0x01F0, 0x01E9, 0x01E1, 0x01DA, 
+    0x01D4, 0x01CD, 0x01C7, 0x01C0, 0x01BA, 0x01B4, 0x01AF, 0x01AF, 0x01A9, 0x01A4, 0x019E, 0x0199, 0x0194, 0x018F, 0x018A, 0x0186, 
+    0x0181, 0x017D, 0x0178, 0x0174, 0x0170, 0x016C, 0x016C, 0x0168, 0x0164, 0x0160, 0x015C, 0x0158, 0x0155, 0x0151, 0x014E, 0x014A, 
+    0x0147, 0x0144, 0x0141, 0x013E, 0x013B, 0x0138, 0x0135, 0x0132, 0x012F, 0x012C, 0x0129, 0x0127, 0x0124, 0x0124, 0x0121, 0x011F, 
+    0x011C, 0x011A, 0x0118, 0x0115, 0x0113, 0x0111, 0x010E, 0x010C, 0x010A, 0x0108, 0x0106, 0x0104, 0x0102, 0x0100, 0x00FE, 0x00FC, 
+    0x0444, 0x0444, 0x0444, 0x0444, 0x0444, 0x0444, 0x0421, 0x0421, 0x0421, 0x0421, 0x0400, 0x0400, 0x0400, 0x03E0, 0x03E0, 0x03C3, 
+    0x03C3, 0x03C3, 0x03A8, 0x03A8, 0x038E, 0x0375, 0x0375, 0x035E, 0x035E, 0x0348, 0x0333, 0x0333, 0x031F, 0x030C, 0x030C, 0x02FA, 
+    0x02E8, 0x02E8, 0x02D8, 0x02C8, 0x02B9, 0x02B9, 0x02AA, 0x029C, 0x028F, 0x0282, 0x0282, 0x0276, 0x026A, 0x025E, 0x0253, 0x0249, 
+    0x0249, 0x023E, 0x0234, 0x022B, 0x0222, 0x0219, 0x0210, 0x0210, 0x0208, 0x0200, 0x01F8, 0x01F0, 0x01E9, 0x01E1, 0x01DA, 0x01D4, 
+    0x01D4, 0x01CD, 0x01C7, 0x01C0, 0x01BA, 0x01B4, 0x01AF, 0x01A9, 0x01A4, 0x019E, 0x0199, 0x0199, 0x0194, 0x018F, 0x018A, 0x0186, 
+    0x0181, 0x017D, 0x0178, 0x0174, 0x0170, 0x016C, 0x0168, 0x0164, 0x0160, 0x015C, 0x0158, 0x0158, 0x0155, 0x0151, 0x014E, 0x014A, 
+    0x0147, 0x0144, 0x0141, 0x013E, 0x013B, 0x0138, 0x0135, 0x0132, 0x012F, 0x012C, 0x0129, 0x0127, 0x0124, 0x0121, 0x011F, 0x011C, 
+    0x011A, 0x0118, 0x0115, 0x0115, 0x0113, 0x0111, 0x010E, 0x010C, 0x010A, 0x0108, 0x0106, 0x0104, 0x0102, 0x0100, 0x00FE, 0x00FC, 
+    0x0421, 0x0421, 0x0421, 0x0421, 0x0421, 0x0421, 0x0421, 0x0400, 0x0400, 0x0400, 0x0400, 0x03E0, 0x03E0, 0x03E0, 0x03C3, 0x03C3, 
+    0x03A8, 0x03A8, 0x038E, 0x038E, 0x0375, 0x0375, 0x035E, 0x035E, 0x0348, 0x0333, 0x0333, 0x031F, 0x030C, 0x030C, 0x02FA, 0x02E8, 
+    0x02E8, 0x02D8, 0x02C8, 0x02B9, 0x02B9, 0x02AA, 0x029C, 0x028F, 0x028F, 0x0282, 0x0276, 0x026A, 0x025E, 0x025E, 0x0253, 0x0249, 
+    0x023E, 0x0234, 0x022B, 0x022B, 0x0222, 0x0219, 0x0210, 0x0208, 0x0200, 0x01F8, 0x01F8, 0x01F0, 0x01E9, 0x01E1, 0x01DA, 0x01D4, 
+    0x01CD, 0x01C7, 0x01C0, 0x01C0, 0x01BA, 0x01B4, 0x01AF, 0x01A9, 0x01A4, 0x019E, 0x0199, 0x0194, 0x018F, 0x018A, 0x0186, 0x0181, 
+    0x0181, 0x017D, 0x0178, 0x0174, 0x0170, 0x016C, 0x0168, 0x0164, 0x0160, 0x015C, 0x0158, 0x0155, 0x0151, 0x014E, 0x014A, 0x0147, 
+    0x0144, 0x0144, 0x0141, 0x013E, 0x013B, 0x0138, 0x0135, 0x0132, 0x012F, 0x012C, 0x0129, 0x0127, 0x0124, 0x0121, 0x011F, 0x011C, 
+    0x011A, 0x0118, 0x0115, 0x0113, 0x0111, 0x010E, 0x010C, 0x010A, 0x0108, 0x0106, 0x0106, 0x0104, 0x0102, 0x0100, 0x00FE, 0x00FC, 
+    0x0400, 0x0400, 0x0400, 0x0400, 0x0400, 0x0400, 0x0400, 0x03E0, 0x03E0, 0x03E0, 0x03E0, 0x03C3, 0x03C3, 0x03C3, 0x03A8, 0x03A8, 
+    0x038E, 0x038E, 0x038E, 0x0375, 0x0375, 0x035E, 0x0348, 0x0348, 0x0333, 0x0333, 0x031F, 0x030C, 0x030C, 0x02FA, 0x02E8, 0x02E8, 
+    0x02D8, 0x02C8, 0x02C8, 0x02B9, 0x02AA, 0x029C, 0x029C, 0x028F, 0x0282, 0x0276, 0x0276, 0x026A, 0x025E, 0x0253, 0x0249, 0x023E, 
+    0x023E, 0x0234, 0x022B, 0x0222, 0x0219, 0x0210, 0x0210, 0x0208, 0x0200, 0x01F8, 0x01F0, 0x01E9, 0x01E1, 0x01DA, 0x01DA, 0x01D4, 
+    0x01CD, 0x01C7, 0x01C0, 0x01BA, 0x01B4, 0x01AF, 0x01A9, 0x01A9, 0x01A4, 0x019E, 0x0199, 0x0194, 0x018F, 0x018A, 0x0186, 0x0181, 
+    0x017D, 0x0178, 0x0174, 0x0170, 0x0170, 0x016C, 0x0168, 0x0164, 0x0160, 0x015C, 0x0158, 0x0155, 0x0151, 0x014E, 0x014A, 0x0147, 
+    0x0144, 0x0141, 0x013E, 0x013B, 0x0138, 0x0135, 0x0135, 0x0132, 0x012F, 0x012C, 0x0129, 0x0127, 0x0124, 0x0121, 0x011F, 0x011C, 
+    0x011A, 0x0118, 0x0115, 0x0113, 0x0111, 0x010E, 0x010C, 0x010A, 0x0108, 0x0106, 0x0104, 0x0102, 0x0100, 0x00FE, 0x00FC, 0x00FA, 
+    0x03E0, 0x03E0, 0x03E0, 0x03E0, 0x03E0, 0x03E0, 0x03E0, 0x03E0, 0x03C3, 0x03C3, 0x03C3, 0x03C3, 0x03A8, 0x03A8, 0x03A8, 0x038E, 
+    0x038E, 0x0375, 0x0375, 0x035E, 0x035E, 0x0348, 0x0348, 0x0333, 0x0333, 0x031F, 0x030C, 0x030C, 0x02FA, 0x02E8, 0x02E8, 0x02D8, 
+    0x02C8, 0x02C8, 0x02B9, 0x02AA, 0x02AA, 0x029C, 0x028F, 0x0282, 0x0282, 0x0276, 0x026A, 0x025E, 0x0253, 0x0253, 0x0249, 0x023E, 
+    0x0234, 0x022B, 0x022B, 0x0222, 0x0219, 0x0210, 0x0208, 0x0200, 0x01F8, 0x01F8, 0x01F0, 0x01E9, 0x01E1, 0x01DA, 0x01D4, 0x01CD, 
+    0x01C7, 0x01C7, 0x01C0, 0x01BA, 0x01B4, 0x01AF, 0x01A9, 0x01A4, 0x019E, 0x0199, 0x0194, 0x0194, 0x018F, 0x018A, 0x0186, 0x0181, 
+    0x017D, 0x0178, 0x0174, 0x0170, 0x016C, 0x0168, 0x0164, 0x0160, 0x015C, 0x015C, 0x0158, 0x0155, 0x0151, 0x014E, 0x014A, 0x0147, 
+    0x0144, 0x0141, 0x013E, 0x013B, 0x0138, 0x0135, 0x0132, 0x012F, 0x012C, 0x0129, 0x0127, 0x0124, 0x0124, 0x0121, 0x011F, 0x011C, 
+    0x011A, 0x0118, 0x0115, 0x0113, 0x0111, 0x010E, 0x010C, 0x010A, 0x0108, 0x0106, 0x0104, 0x0102, 0x0100, 0x00FE, 0x00FC, 0x00FA, 
+    0x03C3, 0x03C3, 0x03C3, 0x03C3, 0x03C3, 0x03C3, 0x03C3, 0x03C3, 0x03C3, 0x03A8, 0x03A8, 0x03A8, 0x038E, 0x038E, 0x038E, 0x0375, 
+    0x0375, 0x035E, 0x035E, 0x035E, 0x0348, 0x0348, 0x0333, 0x031F, 0x031F, 0x030C, 0x030C, 0x02FA, 0x02E8, 0x02E8, 0x02D8, 0x02C8, 
+    0x02C8, 0x02B9, 0x02AA, 0x02AA, 0x029C, 0x028F, 0x028F, 0x0282, 0x0276, 0x026A, 0x025E, 0x025E, 0x0253, 0x0249, 0x023E, 0x0234, 
+    0x0234, 0x022B, 0x0222, 0x0219, 0x0210, 0x0210, 0x0208, 0x0200, 0x01F8, 0x01F0, 0x01E9, 0x01E1, 0x01E1, 0x01DA, 0x01D4, 0x01CD, 
+    0x01C7, 0x01C0, 0x01BA, 0x01B4, 0x01AF, 0x01AF, 0x01A9, 0x01A4, 0x019E, 0x0199, 0x0194, 0x018F, 0x018A, 0x0186, 0x0181, 0x017D, 
+    0x017D, 0x0178, 0x0174, 0x0170, 0x016C, 0x0168, 0x0164, 0x0160, 0x015C, 0x0158, 0x0155, 0x0151, 0x014E, 0x014A, 0x014A, 0x0147, 
+    0x0144, 0x0141, 0x013E, 0x013B, 0x0138, 0x0135, 0x0132, 0x012F, 0x012C, 0x0129, 0x0127, 0x0124, 0x0121, 0x011F, 0x011C, 0x011A, 
+    0x0118, 0x0115, 0x0115, 0x0113, 0x0111, 0x010E, 0x010C, 0x010A, 0x0108, 0x0106, 0x0104, 0x0102, 0x0100, 0x00FE, 0x00FC, 0x00FA, 
+    0x03C3, 0x03C3, 0x03C3, 0x03A8, 0x03A8, 0x03A8, 0x03A8, 0x03A8, 0x03A8, 0x038E, 0x038E, 0x038E, 0x038E, 0x0375, 0x0375, 0x0375, 
+    0x035E, 0x035E, 0x0348, 0x0348, 0x0333, 0x0333, 0x031F, 0x031F, 0x030C, 0x030C, 0x02FA, 0x02E8, 0x02E8, 0x02D8, 0x02C8, 0x02C8, 
+    0x02B9, 0x02AA, 0x02AA, 0x029C, 0x028F, 0x028F, 0x0282, 0x0276, 0x026A, 0x026A, 0x025E, 0x0253, 0x0249, 0x0249, 0x023E, 0x0234, 
+    0x022B, 0x0222, 0x0222, 0x0219, 0x0210, 0x0208, 0x0200, 0x01F8, 0x01F8, 0x01F0, 0x01E9, 0x01E1, 0x01DA, 0x01D4, 0x01CD, 0x01C7, 
+    0x01C7, 0x01C0, 0x01BA, 0x01B4, 0x01AF, 0x01A9, 0x01A4, 0x019E, 0x0199, 0x0199, 0x0194, 0x018F, 0x018A, 0x0186, 0x0181, 0x017D, 
+    0x0178, 0x0174, 0x0170, 0x016C, 0x016C, 0x0168, 0x0164, 0x0160, 0x015C, 0x0158, 0x0155, 0x0151, 0x014E, 0x014A, 0x0147, 0x0144, 
+    0x0141, 0x013E, 0x013B, 0x013B, 0x0138, 0x0135, 0x0132, 0x012F, 0x012C, 0x0129, 0x0127, 0x0124, 0x0121, 0x011F, 0x011C, 0x011A, 
+    0x0118, 0x0115, 0x0113, 0x0111, 0x010E, 0x010C, 0x010A, 0x0108, 0x0108, 0x0106, 0x0104, 0x0102, 0x0100, 0x00FE, 0x00FC, 0x00FA, 
+    0x03A8, 0x03A8, 0x03A8, 0x03A8, 0x038E, 0x038E, 0x038E, 0x038E, 0x038E, 0x038E, 0x0375, 0x0375, 0x0375, 0x035E, 0x035E, 0x035E, 
+    0x0348, 0x0348, 0x0333, 0x0333, 0x0333, 0x031F, 0x030C, 0x030C, 0x02FA, 0x02FA, 0x02E8, 0x02E8, 0x02D8, 0x02C8, 0x02C8, 0x02B9, 
+    0x02AA, 0x02AA, 0x029C, 0x028F, 0x028F, 0x0282, 0x0276, 0x0276, 0x026A, 0x025E, 0x0253, 0x0253, 0x0249, 0x023E, 0x0234, 0x022B, 
+    0x022B, 0x0222, 0x0219, 0x0210, 0x0208, 0x0208, 0x0200, 0x01F8, 0x01F0, 0x01E9, 0x01E1, 0x01DA, 0x01DA, 0x01D4, 0x01CD, 0x01C7, 
+    0x01C0, 0x01BA, 0x01B4, 0x01B4, 0x01AF, 0x01A9, 0x01A4, 0x019E, 0x0199, 0x0194, 0x018F, 0x018A, 0x0186, 0x0186, 0x0181, 0x017D, 
+    0x0178, 0x0174, 0x0170, 0x016C, 0x0168, 0x0164, 0x0160, 0x015C, 0x015C, 0x0158, 0x0155, 0x0151, 0x014E, 0x014A, 0x0147, 0x0144, 
+    0x0141, 0x013E, 0x013B, 0x0138, 0x0135, 0x0132, 0x012F, 0x012C, 0x012C, 0x0129, 0x0127, 0x0124, 0x0121, 0x011F, 0x011C, 0x011A, 
+    0x0118, 0x0115, 0x0113, 0x0111, 0x010E, 0x010C, 0x010A, 0x0108, 0x0106, 0x0104, 0x0102, 0x0100, 0x00FE, 0x00FC, 0x00FC, 0x00FA, 
+    0x038E, 0x038E, 0x038E, 0x038E, 0x038E, 0x0375, 0x0375, 0x0375, 0x0375, 0x0375, 0x035E, 0x035E, 0x035E, 0x035E, 0x0348, 0x0348, 
+    0x0333, 0x0333, 0x0333, 0x031F, 0x031F, 0x030C, 0x030C, 0x02FA, 0x02FA, 0x02E8, 0x02E8, 0x02D8, 0x02C8, 0x02C8, 0x02B9, 0x02AA, 
+    0x02AA, 0x029C, 0x028F, 0x028F, 0x0282, 0x0276, 0x0276, 0x026A, 0x025E, 0x0253, 0x0253, 0x0249, 0x023E, 0x0234, 0x0234, 0x022B, 
+    0x0222, 0x0219, 0x0210, 0x0210, 0x0208, 0x0200, 0x01F8, 0x01F0, 0x01F0, 0x01E9, 0x01E1, 0x01DA, 0x01D4, 0x01CD, 0x01C7, 0x01C7, 
+    0x01C0, 0x01BA, 0x01B4, 0x01AF, 0x01A9, 0x01A4, 0x019E, 0x019E, 0x0199, 0x0194, 0x018F, 0x018A, 0x0186, 0x0181, 0x017D, 0x0178, 
+    0x0174, 0x0174, 0x0170, 0x016C, 0x0168, 0x0164, 0x0160, 0x015C, 0x0158, 0x0155, 0x0151, 0x014E, 0x014A, 0x014A, 0x0147, 0x0144, 
+    0x0141, 0x013E, 0x013B, 0x0138, 0x0135, 0x0132, 0x012F, 0x012C, 0x0129, 0x0127, 0x0124, 0x0121, 0x011F, 0x011C, 0x011C, 0x011A, 
+    0x0118, 0x0115, 0x0113, 0x0111, 0x010E, 0x010C, 0x010A, 0x0108, 0x0106, 0x0104, 0x0102, 0x0100, 0x00FE, 0x00FC, 0x00FA, 0x00F8, 
+    0x0375, 0x0375, 0x0375, 0x0375, 0x0375, 0x0375, 0x035E, 0x035E, 0x035E, 0x035E, 0x035E, 0x0348, 0x0348, 0x0348, 0x0333, 0x0333, 
+    0x0333, 0x031F, 0x031F, 0x030C, 0x030C, 0x02FA, 0x02FA, 0x02E8, 0x02E8, 0x02D8, 0x02D8, 0x02C8, 0x02C8, 0x02B9, 0x02AA, 0x02AA, 
+    0x029C, 0x028F, 0x028F, 0x0282, 0x0276, 0x0276, 0x026A, 0x025E, 0x025E, 0x0253, 0x0249, 0x023E, 0x023E, 0x0234, 0x022B, 0x0222, 
+    0x0222, 0x0219, 0x0210, 0x0208, 0x0200, 0x0200, 0x01F8, 0x01F0, 0x01E9, 0x01E1, 0x01DA, 0x01DA, 0x01D4, 0x01CD, 0x01C7, 0x01C0, 
+    0x01BA, 0x01B4, 0x01B4, 0x01AF, 0x01A9, 0x01A4, 0x019E, 0x0199, 0x0194, 0x018F, 0x018F, 0x018A, 0x0186, 0x0181, 0x017D, 0x0178, 
+    0x0174, 0x0170, 0x016C, 0x0168, 0x0164, 0x0164, 0x0160, 0x015C, 0x0158, 0x0155, 0x0151, 0x014E, 0x014A, 0x0147, 0x0144, 0x0141, 
+    0x013E, 0x013B, 0x013B, 0x0138, 0x0135, 0x0132, 0x012F, 0x012C, 0x0129, 0x0127, 0x0124, 0x0121, 0x011F, 0x011C, 0x011A, 0x0118, 
+    0x0115, 0x0113, 0x0111, 0x0111, 0x010E, 0x010C, 0x010A, 0x0108, 0x0106, 0x0104, 0x0102, 0x0100, 0x00FE, 0x00FC, 0x00FA, 0x00F8, 
+    0x035E, 0x035E, 0x035E, 0x035E, 0x035E, 0x035E, 0x035E, 0x0348, 0x0348, 0x0348, 0x0348, 0x0333, 0x0333, 0x0333, 0x0333, 0x031F, 
+    0x031F, 0x030C, 0x030C, 0x030C, 0x02FA, 0x02FA, 0x02E8, 0x02E8, 0x02D8, 0x02D8, 0x02C8, 0x02B9, 0x02B9, 0x02AA, 0x02AA, 0x029C, 
+    0x028F, 0x028F, 0x0282, 0x0276, 0x0276, 0x026A, 0x025E, 0x025E, 0x0253, 0x0249, 0x0249, 0x023E, 0x0234, 0x022B, 0x022B, 0x0222, 
+    0x0219, 0x0210, 0x0208, 0x0208, 0x0200, 0x01F8, 0x01F0, 0x01E9, 0x01E9, 0x01E1, 0x01DA, 0x01D4, 0x01CD, 0x01C7, 0x01C7, 0x01C0, 
+    0x01BA, 0x01B4, 0x01AF, 0x01A9, 0x01A4, 0x019E, 0x019E, 0x0199, 0x0194, 0x018F, 0x018A, 0x0186, 0x0181, 0x017D, 0x017D, 0x0178, 
+    0x0174, 0x0170, 0x016C, 0x0168, 0x0164, 0x0160, 0x015C, 0x0158, 0x0155, 0x0155, 0x0151, 0x014E, 0x014A, 0x0147, 0x0144, 0x0141, 
+    0x013E, 0x013B, 0x0138, 0x0135, 0x0132, 0x012F, 0x012C, 0x012C, 0x0129, 0x0127, 0x0124, 0x0121, 0x011F, 0x011C, 0x011A, 0x0118, 
+    0x0115, 0x0113, 0x0111, 0x010E, 0x010C, 0x010A, 0x0108, 0x0106, 0x0104, 0x0104, 0x0102, 0x0100, 0x00FE, 0x00FC, 0x00FA, 0x00F8, 
+    0x0348, 0x0348, 0x0348, 0x0348, 0x0348, 0x0348, 0x0348, 0x0333, 0x0333, 0x0333, 0x0333, 0x0333, 0x031F, 0x031F, 0x031F, 0x030C, 
+    0x030C, 0x030C, 0x02FA, 0x02FA, 0x02E8, 0x02E8, 0x02D8, 0x02D8, 0x02C8, 0x02C8, 0x02B9, 0x02B9, 0x02AA, 0x02AA, 0x029C, 0x028F, 
+    0x028F, 0x0282, 0x0276, 0x0276, 0x026A, 0x025E, 0x025E, 0x0253, 0x0249, 0x0249, 0x023E, 0x0234, 0x022B, 0x022B, 0x0222, 0x0219, 
+    0x0210, 0x0210, 0x0208, 0x0200, 0x01F8, 0x01F0, 0x01F0, 0x01E9, 0x01E1, 0x01DA, 0x01D4, 0x01D4, 0x01CD, 0x01C7, 0x01C0, 0x01BA, 
+    0x01B4, 0x01AF, 0x01AF, 0x01A9, 0x01A4, 0x019E, 0x0199, 0x0194, 0x018F, 0x018F, 0x018A, 0x0186, 0x0181, 0x017D, 0x0178, 0x0174, 
+    0x0170, 0x016C, 0x016C, 0x0168, 0x0164, 0x0160, 0x015C, 0x0158, 0x0155, 0x0151, 0x014E, 0x014A, 0x0147, 0x0144, 0x0144, 0x0141, 
+    0x013E, 0x013B, 0x0138, 0x0135, 0x0132, 0x012F, 0x012C, 0x0129, 0x0127, 0x0124, 0x0121, 0x011F, 0x011F, 0x011C, 0x011A, 0x0118, 
+    0x0115, 0x0113, 0x0111, 0x010E, 0x010C, 0x010A, 0x0108, 0x0106, 0x0104, 0x0102, 0x0100, 0x00FE, 0x00FC, 0x00FA, 0x00F8, 0x00F8, 
+    0x0333, 0x0333, 0x0333, 0x0333, 0x0333, 0x0333, 0x0333, 0x0333, 0x031F, 0x031F, 0x031F, 0x031F, 0x030C, 0x030C, 0x030C, 0x02FA, 
+    0x02FA, 0x02FA, 0x02E8, 0x02E8, 0x02D8, 0x02D8, 0x02D8, 0x02C8, 0x02C8, 0x02B9, 0x02B9, 0x02AA, 0x029C, 0x029C, 0x028F, 0x028F, 
+    0x0282, 0x0276, 0x0276, 0x026A, 0x025E, 0x025E, 0x0253, 0x0249, 0x0249, 0x023E, 0x0234, 0x0234, 0x022B, 0x0222, 0x0219, 0x0219, 
+    0x0210, 0x0208, 0x0200, 0x01F8, 0x01F8, 0x01F0, 0x01E9, 0x01E1, 0x01DA, 0x01DA, 0x01D4, 0x01CD, 0x01C7, 0x01C0, 0x01C0, 0x01BA, 
+    0x01B4, 0x01AF, 0x01A9, 0x01A4, 0x019E, 0x019E, 0x0199, 0x0194, 0x018F, 0x018A, 0x0186, 0x0181, 0x017D, 0x017D, 0x0178, 0x0174, 
+    0x0170, 0x016C, 0x0168, 0x0164, 0x0160, 0x015C, 0x015C, 0x0158, 0x0155, 0x0151, 0x014E, 0x014A, 0x0147, 0x0144, 0x0141, 0x013E, 
+    0x013B, 0x0138, 0x0138, 0x0135, 0x0132, 0x012F, 0x012C, 0x0129, 0x0127, 0x0124, 0x0121, 0x011F, 0x011C, 0x011A, 0x0118, 0x0115, 
+    0x0113, 0x0113, 0x0111, 0x010E, 0x010C, 0x010A, 0x0108, 0x0106, 0x0104, 0x0102, 0x0100, 0x00FE, 0x00FC, 0x00FA, 0x00F8, 0x00F6, 
+    0x031F, 0x031F, 0x031F, 0x031F, 0x031F, 0x031F, 0x031F, 0x031F, 0x030C, 0x030C, 0x030C, 0x030C, 0x030C, 0x02FA, 0x02FA, 0x02FA, 
+    0x02E8, 0x02E8, 0x02E8, 0x02D8, 0x02D8, 0x02C8, 0x02C8, 0x02B9, 0x02B9, 0x02AA, 0x02AA, 0x029C, 0x029C, 0x028F, 0x028F, 0x0282, 
+    0x0276, 0x0276, 0x026A, 0x025E, 0x025E, 0x0253, 0x0249, 0x0249, 0x023E, 0x0234, 0x0234, 0x022B, 0x0222, 0x0219, 0x0219, 0x0210, 
+    0x0208, 0x0200, 0x0200, 0x01F8, 0x01F0, 0x01E9, 0x01E9, 0x01E1, 0x01DA, 0x01D4, 0x01CD, 0x01CD, 0x01C7, 0x01C0, 0x01BA, 0x01B4, 
+    0x01AF, 0x01AF, 0x01A9, 0x01A4, 0x019E, 0x0199, 0x0194, 0x018F, 0x018F, 0x018A, 0x0186, 0x0181, 0x017D, 0x0178, 0x0174, 0x0170, 
+    0x016C, 0x016C, 0x0168, 0x0164, 0x0160, 0x015C, 0x0158, 0x0155, 0x0151, 0x014E, 0x014E, 0x014A, 0x0147, 0x0144, 0x0141, 0x013E, 
+    0x013B, 0x0138, 0x0135, 0x0132, 0x012F, 0x012C, 0x0129, 0x0129, 0x0127, 0x0124, 0x0121, 0x011F, 0x011C, 0x011A, 0x0118, 0x0115, 
+    0x0113, 0x0111, 0x010E, 0x010C, 0x010A, 0x0108, 0x0108, 0x0106, 0x0104, 0x0102, 0x0100, 0x00FE, 0x00FC, 0x00FA, 0x00F8, 0x00F6, 
+    0x030C, 0x030C, 0x030C, 0x030C, 0x030C, 0x030C, 0x030C, 0x030C, 0x030C, 0x02FA, 0x02FA, 0x02FA, 0x02FA, 0x02E8, 0x02E8, 0x02E8, 
+    0x02D8, 0x02D8, 0x02D8, 0x02C8, 0x02C8, 0x02B9, 0x02B9, 0x02AA, 0x02AA, 0x029C, 0x029C, 0x028F, 0x028F, 0x0282, 0x0282, 0x0276, 
+    0x0276, 0x026A, 0x025E, 0x025E, 0x0253, 0x0249, 0x0249, 0x023E, 0x0234, 0x0234, 0x022B, 0x0222, 0x0222, 0x0219, 0x0210, 0x0208, 
+    0x0208, 0x0200, 0x01F8, 0x01F0, 0x01F0, 0x01E9, 0x01E1, 0x01DA, 0x01D4, 0x01D4, 0x01CD, 0x01C7, 0x01C0, 0x01BA, 0x01BA, 0x01B4, 
+    0x01AF, 0x01A9, 0x01A4, 0x019E, 0x0199, 0x0199, 0x0194, 0x018F, 0x018A, 0x0186, 0x0181, 0x017D, 0x017D, 0x0178, 0x0174, 0x0170, 
+    0x016C, 0x0168, 0x0164, 0x0160, 0x0160, 0x015C, 0x0158, 0x0155, 0x0151, 0x014E, 0x014A, 0x0147, 0x0144, 0x0141, 0x013E, 0x013E, 
+    0x013B, 0x0138, 0x0135, 0x0132, 0x012F, 0x012C, 0x0129, 0x0127, 0x0124, 0x0121, 0x011F, 0x011C, 0x011C, 0x011A, 0x0118, 0x0115, 
+    0x0113, 0x0111, 0x010E, 0x010C, 0x010A, 0x0108, 0x0106, 0x0104, 0x0102, 0x0100, 0x00FE, 0x00FC, 0x00FC, 0x00FA, 0x00F8, 0x00F6, 
+    0x02FA, 0x02FA, 0x02FA, 0x02FA, 0x02FA, 0x02FA, 0x02FA, 0x02FA, 0x02FA, 0x02E8, 0x02E8, 0x02E8, 0x02E8, 0x02D8, 0x02D8, 0x02D8, 
+    0x02D8, 0x02C8, 0x02C8, 0x02B9, 0x02B9, 0x02B9, 0x02AA, 0x02AA, 0x029C, 0x029C, 0x028F, 0x028F, 0x0282, 0x0282, 0x0276, 0x026A, 
+    0x026A, 0x025E, 0x025E, 0x0253, 0x0249, 0x0249, 0x023E, 0x0234, 0x0234, 0x022B, 0x0222, 0x0222, 0x0219, 0x0210, 0x0208, 0x0208, 
+    0x0200, 0x01F8, 0x01F0, 0x01F0, 0x01E9, 0x01E1, 0x01DA, 0x01DA, 0x01D4, 0x01CD, 0x01C7, 0x01C0, 0x01C0, 0x01BA, 0x01B4, 0x01AF, 
+    0x01A9, 0x01A9, 0x01A4, 0x019E, 0x0199, 0x0194, 0x018F, 0x018A, 0x018A, 0x0186, 0x0181, 0x017D, 0x0178, 0x0174, 0x0170, 0x0170, 
+    0x016C, 0x0168, 0x0164, 0x0160, 0x015C, 0x0158, 0x0155, 0x0151, 0x0151, 0x014E, 0x014A, 0x0147, 0x0144, 0x0141, 0x013E, 0x013B, 
+    0x0138, 0x0135, 0x0132, 0x0132, 0x012F, 0x012C, 0x0129, 0x0127, 0x0124, 0x0121, 0x011F, 0x011C, 0x011A, 0x0118, 0x0115, 0x0113, 
+    0x0111, 0x0111, 0x010E, 0x010C, 0x010A, 0x0108, 0x0106, 0x0104, 0x0102, 0x0100, 0x00FE, 0x00FC, 0x00FA, 0x00F8, 0x00F6, 0x00F4, 
+    0x02E8, 0x02E8, 0x02E8, 0x02E8, 0x02E8, 0x02E8, 0x02E8, 0x02E8, 0x02E8, 0x02E8, 0x02D8, 0x02D8, 0x02D8, 0x02D8, 0x02C8, 0x02C8, 
+    0x02C8, 0x02B9, 0x02B9, 0x02B9, 0x02AA, 0x02AA, 0x029C, 0x029C, 0x028F, 0x028F, 0x0282, 0x0282, 0x0276, 0x0276, 0x026A, 0x026A, 
+    0x025E, 0x0253, 0x0253, 0x0249, 0x0249, 0x023E, 0x0234, 0x0234, 0x022B, 0x0222, 0x0222, 0x0219, 0x0210, 0x0210, 0x0208, 0x0200, 
+    0x01F8, 0x01F8, 0x01F0, 0x01E9, 0x01E1, 0x01E1, 0x01DA, 0x01D4, 0x01CD, 0x01C7, 0x01C7, 0x01C0, 0x01BA, 0x01B4, 0x01AF, 0x01AF, 
+    0x01A9, 0x01A4, 0x019E, 0x0199, 0x0194, 0x0194, 0x018F, 0x018A, 0x0186, 0x0181, 0x017D, 0x017D, 0x0178, 0x0174, 0x0170, 0x016C, 
+    0x0168, 0x0164, 0x0160, 0x0160, 0x015C, 0x0158, 0x0155, 0x0151, 0x014E, 0x014A, 0x0147, 0x0144, 0x0144, 0x0141, 0x013E, 0x013B, 
+    0x0138, 0x0135, 0x0132, 0x012F, 0x012C, 0x0129, 0x0127, 0x0124, 0x0124, 0x0121, 0x011F, 0x011C, 0x011A, 0x0118, 0x0115, 0x0113, 
+    0x0111, 0x010E, 0x010C, 0x010A, 0x0108, 0x0106, 0x0106, 0x0104, 0x0102, 0x0100, 0x00FE, 0x00FC, 0x00FA, 0x00F8, 0x00F6, 0x00F4, 
+    0x02E8, 0x02E8, 0x02E8, 0x02D8, 0x02D8, 0x02D8, 0x02D8, 0x02D8, 0x02D8, 0x02D8, 0x02C8, 0x02C8, 0x02C8, 0x02C8, 0x02B9, 0x02B9, 
+    0x02B9, 0x02AA, 0x02AA, 0x02AA, 0x029C, 0x029C, 0x028F, 0x028F, 0x028F, 0x0282, 0x0282, 0x0276, 0x0276, 0x026A, 0x025E, 0x025E, 
+    0x0253, 0x0253, 0x0249, 0x0249, 0x023E, 0x0234, 0x0234, 0x022B, 0x0222, 0x0222, 0x0219, 0x0210, 0x0210, 0x0208, 0x0200, 0x01F8, 
+    0x01F8, 0x01F0, 0x01E9, 0x01E9, 0x01E1, 0x01DA, 0x01D4, 0x01CD, 0x01CD, 0x01C7, 0x01C0, 0x01BA, 0x01BA, 0x01B4, 0x01AF, 0x01A9, 
+    0x01A4, 0x019E, 0x019E, 0x0199, 0x0194, 0x018F, 0x018A, 0x0186, 0x0186, 0x0181, 0x017D, 0x0178, 0x0174, 0x0170, 0x016C, 0x016C, 
+    0x0168, 0x0164, 0x0160, 0x015C, 0x0158, 0x0155, 0x0151, 0x0151, 0x014E, 0x014A, 0x0147, 0x0144, 0x0141, 0x013E, 0x013B, 0x0138, 
+    0x0135, 0x0135, 0x0132, 0x012F, 0x012C, 0x0129, 0x0127, 0x0124, 0x0121, 0x011F, 0x011C, 0x011A, 0x011A, 0x0118, 0x0115, 0x0113, 
+    0x0111, 0x010E, 0x010C, 0x010A, 0x0108, 0x0106, 0x0104, 0x0102, 0x0100, 0x00FE, 0x00FC, 0x00FC, 0x00FA, 0x00F8, 0x00F6, 0x00F4, 
+    0x02D8, 0x02D8, 0x02D8, 0x02D8, 0x02C8, 0x02C8, 0x02C8, 0x02C8, 0x02C8, 0x02C8, 0x02C8, 0x02B9, 0x02B9, 0x02B9, 0x02B9, 0x02AA, 
+    0x02AA, 0x02AA, 0x029C, 0x029C, 0x028F, 0x028F, 0x028F, 0x0282, 0x0282, 0x0276, 0x0276, 0x026A, 0x026A, 0x025E, 0x025E, 0x0253, 
+    0x0253, 0x0249, 0x023E, 0x023E, 0x0234, 0x0234, 0x022B, 0x0222, 0x0222, 0x0219, 0x0210, 0x0210, 0x0208, 0x0200, 0x0200, 0x01F8, 
+    0x01F0, 0x01E9, 0x01E9, 0x01E1, 0x01DA, 0x01D4, 0x01D4, 0x01CD, 0x01C7, 0x01C0, 0x01C0, 0x01BA, 0x01B4, 0x01AF, 0x01A9, 0x01A9, 
+    0x01A4, 0x019E, 0x0199, 0x0194, 0x018F, 0x018F, 0x018A, 0x0186, 0x0181, 0x017D, 0x0178, 0x0178, 0x0174, 0x0170, 0x016C, 0x0168, 
+    0x0164, 0x0160, 0x0160, 0x015C, 0x0158, 0x0155, 0x0151, 0x014E, 0x014A, 0x0147, 0x0144, 0x0144, 0x0141, 0x013E, 0x013B, 0x0138, 
+    0x0135, 0x0132, 0x012F, 0x012C, 0x0129, 0x0129, 0x0127, 0x0124, 0x0121, 0x011F, 0x011C, 0x011A, 0x0118, 0x0115, 0x0113, 0x0111, 
+    0x010E, 0x010E, 0x010C, 0x010A, 0x0108, 0x0106, 0x0104, 0x0102, 0x0100, 0x00FE, 0x00FC, 0x00FA, 0x00F8, 0x00F6, 0x00F4, 0x00F2, 
+    0x02C8, 0x02C8, 0x02C8, 0x02C8, 0x02C8, 0x02B9, 0x02B9, 0x02B9, 0x02B9, 0x02B9, 0x02B9, 0x02AA, 0x02AA, 0x02AA, 0x02AA, 0x029C, 
+    0x029C, 0x029C, 0x028F, 0x028F, 0x028F, 0x0282, 0x0282, 0x0276, 0x0276, 0x026A, 0x026A, 0x025E, 0x025E, 0x0253, 0x0253, 0x0249, 
+    0x0249, 0x023E, 0x023E, 0x0234, 0x022B, 0x022B, 0x0222, 0x0222, 0x0219, 0x0210, 0x0210, 0x0208, 0x0200, 0x0200, 0x01F8, 0x01F0, 
+    0x01E9, 0x01E9, 0x01E1, 0x01DA, 0x01DA, 0x01D4, 0x01CD, 0x01C7, 0x01C7, 0x01C0, 0x01BA, 0x01B4, 0x01AF, 0x01AF, 0x01A9, 0x01A4, 
+    0x019E, 0x0199, 0x0199, 0x0194, 0x018F, 0x018A, 0x0186, 0x0181, 0x0181, 0x017D, 0x0178, 0x0174, 0x0170, 0x016C, 0x016C, 0x0168, 
+    0x0164, 0x0160, 0x015C, 0x0158, 0x0155, 0x0151, 0x0151, 0x014E, 0x014A, 0x0147, 0x0144, 0x0141, 0x013E, 0x013B, 0x0138, 0x0138, 
+    0x0135, 0x0132, 0x012F, 0x012C, 0x0129, 0x0127, 0x0124, 0x0121, 0x011F, 0x011F, 0x011C, 0x011A, 0x0118, 0x0115, 0x0113, 0x0111, 
+    0x010E, 0x010C, 0x010A, 0x0108, 0x0106, 0x0104, 0x0104, 0x0102, 0x0100, 0x00FE, 0x00FC, 0x00FA, 0x00F8, 0x00F6, 0x00F4, 0x00F2, 
+    0x02B9, 0x02B9, 0x02B9, 0x02B9, 0x02B9, 0x02AA, 0x02AA, 0x02AA, 0x02AA, 0x02AA, 0x02AA, 0x029C, 0x029C, 0x029C, 0x029C, 0x028F, 
+    0x028F, 0x028F, 0x0282, 0x0282, 0x0282, 0x0276, 0x0276, 0x026A, 0x026A, 0x026A, 0x025E, 0x025E, 0x0253, 0x0253, 0x0249, 0x0249, 
+    0x023E, 0x0234, 0x0234, 0x022B, 0x022B, 0x0222, 0x0219, 0x0219, 0x0210, 0x0210, 0x0208, 0x0200, 0x0200, 0x01F8, 0x01F0, 0x01E9, 
+    0x01E9, 0x01E1, 0x01DA, 0x01DA, 0x01D4, 0x01CD, 0x01C7, 0x01C7, 0x01C0, 0x01BA, 0x01B4, 0x01B4, 0x01AF, 0x01A9, 0x01A4, 0x019E, 
+    0x019E, 0x0199, 0x0194, 0x018F, 0x018A, 0x018A, 0x0186, 0x0181, 0x017D, 0x0178, 0x0174, 0x0174, 0x0170, 0x016C, 0x0168, 0x0164, 
+    0x0160, 0x015C, 0x015C, 0x0158, 0x0155, 0x0151, 0x014E, 0x014A, 0x0147, 0x0144, 0x0144, 0x0141, 0x013E, 0x013B, 0x0138, 0x0135, 
+    0x0132, 0x012F, 0x012C, 0x012C, 0x0129, 0x0127, 0x0124, 0x0121, 0x011F, 0x011C, 0x011A, 0x0118, 0x0115, 0x0113, 0x0113, 0x0111, 
+    0x010E, 0x010C, 0x010A, 0x0108, 0x0106, 0x0104, 0x0102, 0x0100, 0x00FE, 0x00FC, 0x00FA, 0x00FA, 0x00F8, 0x00F6, 0x00F4, 0x00F2, 
+    0x02AA, 0x02AA, 0x02AA, 0x02AA, 0x02AA, 0x02AA, 0x029C, 0x029C, 0x029C, 0x029C, 0x029C, 0x029C, 0x028F, 0x028F, 0x028F, 0x028F, 
+    0x0282, 0x0282, 0x0282, 0x0276, 0x0276, 0x026A, 0x026A, 0x026A, 0x025E, 0x025E, 0x0253, 0x0253, 0x0249, 0x0249, 0x023E, 0x023E, 
+    0x0234, 0x0234, 0x022B, 0x022B, 0x0222, 0x0219, 0x0219, 0x0210, 0x0208, 0x0208, 0x0200, 0x0200, 0x01F8, 0x01F0, 0x01F0, 0x01E9, 
+    0x01E1, 0x01DA, 0x01DA, 0x01D4, 0x01CD, 0x01CD, 0x01C7, 0x01C0, 0x01BA, 0x01BA, 0x01B4, 0x01AF, 0x01A9, 0x01A4, 0x01A4, 0x019E, 
+    0x0199, 0x0194, 0x018F, 0x018F, 0x018A, 0x0186, 0x0181, 0x017D, 0x017D, 0x0178, 0x0174, 0x0170, 0x016C, 0x0168, 0x0168, 0x0164, 
+    0x0160, 0x015C, 0x0158, 0x0155, 0x0151, 0x0151, 0x014E, 0x014A, 0x0147, 0x0144, 0x0141, 0x013E, 0x013B, 0x013B, 0x0138, 0x0135, 
+    0x0132, 0x012F, 0x012C, 0x0129, 0x0127, 0x0124, 0x0121, 0x0121, 0x011F, 0x011C, 0x011A, 0x0118, 0x0115, 0x0113, 0x0111, 0x010E, 
+    0x010C, 0x010A, 0x010A, 0x0108, 0x0106, 0x0104, 0x0102, 0x0100, 0x00FE, 0x00FC, 0x00FA, 0x00F8, 0x00F6, 0x00F4, 0x00F2, 0x00F0, 
+    0x029C, 0x029C, 0x029C, 0x029C, 0x029C, 0x029C, 0x028F, 0x028F, 0x028F, 0x028F, 0x028F, 0x028F, 0x0282, 0x0282, 0x0282, 0x0282, 
+    0x0276, 0x0276, 0x0276, 0x026A, 0x026A, 0x026A, 0x025E, 0x025E, 0x0253, 0x0253, 0x0249, 0x0249, 0x023E, 0x023E, 0x0234, 0x0234, 
+    0x022B, 0x022B, 0x0222, 0x0222, 0x0219, 0x0219, 0x0210, 0x0208, 0x0208, 0x0200, 0x01F8, 0x01F8, 0x01F0, 0x01E9, 0x01E9, 0x01E1, 
+    0x01DA, 0x01DA, 0x01D4, 0x01CD, 0x01CD, 0x01C7, 0x01C0, 0x01BA, 0x01BA, 0x01B4, 0x01AF, 0x01A9, 0x01A9, 0x01A4, 0x019E, 0x0199, 
+    0x0194, 0x0194, 0x018F, 0x018A, 0x0186, 0x0181, 0x0181, 0x017D, 0x0178, 0x0174, 0x0170, 0x0170, 0x016C, 0x0168, 0x0164, 0x0160, 
+    0x015C, 0x0158, 0x0158, 0x0155, 0x0151, 0x014E, 0x014A, 0x0147, 0x0144, 0x0144, 0x0141, 0x013E, 0x013B, 0x0138, 0x0135, 0x0132, 
+    0x012F, 0x012F, 0x012C, 0x0129, 0x0127, 0x0124, 0x0121, 0x011F, 0x011C, 0x011A, 0x0118, 0x0118, 0x0115, 0x0113, 0x0111, 0x010E, 
+    0x010C, 0x010A, 0x0108, 0x0106, 0x0104, 0x0102, 0x0100, 0x0100, 0x00FE, 0x00FC, 0x00FA, 0x00F8, 0x00F6, 0x00F4, 0x00F2, 0x00F0, 
+    0x028F, 0x028F, 0x028F, 0x028F, 0x028F, 0x028F, 0x028F, 0x0282, 0x0282, 0x0282, 0x0282, 0x0282, 0x0276, 0x0276, 0x0276, 0x0276, 
+    0x026A, 0x026A, 0x026A, 0x025E, 0x025E, 0x025E, 0x0253, 0x0253, 0x0249, 0x0249, 0x0249, 0x023E, 0x023E, 0x0234, 0x0234, 0x022B, 
+    0x022B, 0x0222, 0x0222, 0x0219, 0x0210, 0x0210, 0x0208, 0x0208, 0x0200, 0x01F8, 0x01F8, 0x01F0, 0x01E9, 0x01E9, 0x01E1, 0x01DA, 
+    0x01DA, 0x01D4, 0x01CD, 0x01CD, 0x01C7, 0x01C0, 0x01BA, 0x01BA, 0x01B4, 0x01AF, 0x01AF, 0x01A9, 0x01A4, 0x019E, 0x0199, 0x0199, 
+    0x0194, 0x018F, 0x018A, 0x018A, 0x0186, 0x0181, 0x017D, 0x0178, 0x0174, 0x0174, 0x0170, 0x016C, 0x0168, 0x0164, 0x0164, 0x0160, 
+    0x015C, 0x0158, 0x0155, 0x0151, 0x014E, 0x014E, 0x014A, 0x0147, 0x0144, 0x0141, 0x013E, 0x013B, 0x013B, 0x0138, 0x0135, 0x0132, 
+    0x012F, 0x012C, 0x0129, 0x0127, 0x0124, 0x0124, 0x0121, 0x011F, 0x011C, 0x011A, 0x0118, 0x0115, 0x0113, 0x0111, 0x010E, 0x010E, 
+    0x010C, 0x010A, 0x0108, 0x0106, 0x0104, 0x0102, 0x0100, 0x00FE, 0x00FC, 0x00FA, 0x00F8, 0x00F6, 0x00F6, 0x00F4, 0x00F2, 0x00F0, 
+    0x0282, 0x0282, 0x0282, 0x0282, 0x0282, 0x0282, 0x0282, 0x0276, 0x0276, 0x0276, 0x0276, 0x0276, 0x0276, 0x026A, 0x026A, 0x026A, 
+    0x026A, 0x025E, 0x025E, 0x025E, 0x0253, 0x0253, 0x0249, 0x0249, 0x0249, 0x023E, 0x023E, 0x0234, 0x0234, 0x022B, 0x022B, 0x0222, 
+    0x0222, 0x0219, 0x0219, 0x0210, 0x0210, 0x0208, 0x0200, 0x0200, 0x01F8, 0x01F8, 0x01F0, 0x01E9, 0x01E9, 0x01E1, 0x01DA, 0x01DA, 
+    0x01D4, 0x01CD, 0x01CD, 0x01C7, 0x01C0, 0x01C0, 0x01BA, 0x01B4, 0x01AF, 0x01AF, 0x01A9, 0x01A4, 0x019E, 0x019E, 0x0199, 0x0194, 
+    0x018F, 0x018F, 0x018A, 0x0186, 0x0181, 0x017D, 0x017D, 0x0178, 0x0174, 0x0170, 0x016C, 0x0168, 0x0168, 0x0164, 0x0160, 0x015C, 
+    0x0158, 0x0155, 0x0155, 0x0151, 0x014E, 0x014A, 0x0147, 0x0144, 0x0144, 0x0141, 0x013E, 0x013B, 0x0138, 0x0135, 0x0132, 0x012F, 
+    0x012F, 0x012C, 0x0129, 0x0127, 0x0124, 0x0121, 0x011F, 0x011C, 0x011A, 0x011A, 0x0118, 0x0115, 0x0113, 0x0111, 0x010E, 0x010C, 
+    0x010A, 0x0108, 0x0106, 0x0104, 0x0104, 0x0102, 0x0100, 0x00FE, 0x00FC, 0x00FA, 0x00F8, 0x00F6, 0x00F4, 0x00F2, 0x00F0, 0x00EF, 
+    0x0276, 0x0276, 0x0276, 0x0276, 0x0276, 0x0276, 0x0276, 0x0276, 0x026A, 0x026A, 0x026A, 0x026A, 0x026A, 0x025E, 0x025E, 0x025E, 
+    0x025E, 0x0253, 0x0253, 0x0253, 0x0249, 0x0249, 0x0249, 0x023E, 0x023E, 0x0234, 0x0234, 0x022B, 0x022B, 0x022B, 0x0222, 0x0222, 
+    0x0219, 0x0210, 0x0210, 0x0208, 0x0208, 0x0200, 0x0200, 0x01F8, 0x01F0, 0x01F0, 0x01E9, 0x01E9, 0x01E1, 0x01DA, 0x01DA, 0x01D4, 
+    0x01CD, 0x01CD, 0x01C7, 0x01C0, 0x01C0, 0x01BA, 0x01B4, 0x01AF, 0x01AF, 0x01A9, 0x01A4, 0x01A4, 0x019E, 0x0199, 0x0194, 0x018F, 
+    0x018F, 0x018A, 0x0186, 0x0181, 0x0181, 0x017D, 0x0178, 0x0174, 0x0170, 0x0170, 0x016C, 0x0168, 0x0164, 0x0160, 0x015C, 0x015C, 
+    0x0158, 0x0155, 0x0151, 0x014E, 0x014A, 0x014A, 0x0147, 0x0144, 0x0141, 0x013E, 0x013B, 0x0138, 0x0138, 0x0135, 0x0132, 0x012F, 
+    0x012C, 0x0129, 0x0127, 0x0124, 0x0124, 0x0121, 0x011F, 0x011C, 0x011A, 0x0118, 0x0115, 0x0113, 0x0111, 0x0111, 0x010E, 0x010C, 
+    0x010A, 0x0108, 0x0106, 0x0104, 0x0102, 0x0100, 0x00FE, 0x00FC, 0x00FC, 0x00FA, 0x00F8, 0x00F6, 0x00F4, 0x00F2, 0x00F0, 0x00EF, 
+    0x026A, 0x026A, 0x026A, 0x026A, 0x026A, 0x026A, 0x026A, 0x026A, 0x025E, 0x025E, 0x025E, 0x025E, 0x025E, 0x0253, 0x0253, 0x0253, 
+    0x0253, 0x0249, 0x0249, 0x0249, 0x023E, 0x023E, 0x023E, 0x0234, 0x0234, 0x022B, 0x022B, 0x022B, 0x0222, 0x0222, 0x0219, 0x0219, 
+    0x0210, 0x0210, 0x0208, 0x0208, 0x0200, 0x01F8, 0x01F8, 0x01F0, 0x01F0, 0x01E9, 0x01E9, 0x01E1, 0x01DA, 0x01DA, 0x01D4, 0x01CD, 
+    0x01CD, 0x01C7, 0x01C0, 0x01C0, 0x01BA, 0x01B4, 0x01B4, 0x01AF, 0x01A9, 0x01A4, 0x01A4, 0x019E, 0x0199, 0x0194, 0x0194, 0x018F, 
+    0x018A, 0x0186, 0x0186, 0x0181, 0x017D, 0x0178, 0x0174, 0x0174, 0x0170, 0x016C, 0x0168, 0x0164, 0x0164, 0x0160, 0x015C, 0x0158, 
+    0x0155, 0x0151, 0x0151, 0x014E, 0x014A, 0x0147, 0x0144, 0x0141, 0x0141, 0x013E, 0x013B, 0x0138, 0x0135, 0x0132, 0x012F, 0x012C, 
+    0x012C, 0x0129, 0x0127, 0x0124, 0x0121, 0x011F, 0x011C, 0x011A, 0x011A, 0x0118, 0x0115, 0x0113, 0x0111, 0x010E, 0x010C, 0x010A, 
+    0x0108, 0x0106, 0x0106, 0x0104, 0x0102, 0x0100, 0x00FE, 0x00FC, 0x00FA, 0x00F8, 0x00F6, 0x00F4, 0x00F2, 0x00F2, 0x00F0, 0x00EF, 
+    0x025E, 0x025E, 0x025E, 0x025E, 0x025E, 0x025E, 0x025E, 0x025E, 0x025E, 0x0253, 0x0253, 0x0253, 0x0253, 0x0253, 0x0249, 0x0249, 
+    0x0249, 0x023E, 0x023E, 0x023E, 0x023E, 0x0234, 0x0234, 0x022B, 0x022B, 0x022B, 0x0222, 0x0222, 0x0219, 0x0219, 0x0210, 0x0210, 
+    0x0208, 0x0208, 0x0200, 0x0200, 0x01F8, 0x01F8, 0x01F0, 0x01F0, 0x01E9, 0x01E1, 0x01E1, 0x01DA, 0x01DA, 0x01D4, 0x01CD, 0x01CD, 
+    0x01C7, 0x01C0, 0x01C0, 0x01BA, 0x01B4, 0x01B4, 0x01AF, 0x01A9, 0x01A4, 0x01A4, 0x019E, 0x0199, 0x0199, 0x0194, 0x018F, 0x018A, 
+    0x0186, 0x0186, 0x0181, 0x017D, 0x0178, 0x0178, 0x0174, 0x0170, 0x016C, 0x0168, 0x0168, 0x0164, 0x0160, 0x015C, 0x0158, 0x0158, 
+    0x0155, 0x0151, 0x014E, 0x014A, 0x0147, 0x0147, 0x0144, 0x0141, 0x013E, 0x013B, 0x0138, 0x0135, 0x0135, 0x0132, 0x012F, 0x012C, 
+    0x0129, 0x0127, 0x0124, 0x0124, 0x0121, 0x011F, 0x011C, 0x011A, 0x0118, 0x0115, 0x0113, 0x0111, 0x0111, 0x010E, 0x010C, 0x010A, 
+    0x0108, 0x0106, 0x0104, 0x0102, 0x0100, 0x00FE, 0x00FE, 0x00FC, 0x00FA, 0x00F8, 0x00F6, 0x00F4, 0x00F2, 0x00F0, 0x00EF, 0x00ED, 
+    0x0253, 0x0253, 0x0253, 0x0253, 0x0253, 0x0253, 0x0253, 0x0253, 0x0253, 0x0249, 0x0249, 0x0249, 0x0249, 0x0249, 0x023E, 0x023E, 
+    0x023E, 0x023E, 0x0234, 0x0234, 0x0234, 0x022B, 0x022B, 0x022B, 0x0222, 0x0222, 0x0219, 0x0219, 0x0210, 0x0210, 0x0210, 0x0208, 
+    0x0208, 0x0200, 0x0200, 0x01F8, 0x01F0, 0x01F0, 0x01E9, 0x01E9, 0x01E1, 0x01E1, 0x01DA, 0x01D4, 0x01D4, 0x01CD, 0x01CD, 0x01C7, 
+    0x01C0, 0x01C0, 0x01BA, 0x01B4, 0x01B4, 0x01AF, 0x01A9, 0x01A4, 0x01A4, 0x019E, 0x0199, 0x0199, 0x0194, 0x018F, 0x018A, 0x018A, 
+    0x0186, 0x0181, 0x017D, 0x017D, 0x0178, 0x0174, 0x0170, 0x016C, 0x016C, 0x0168, 0x0164, 0x0160, 0x015C, 0x015C, 0x0158, 0x0155, 
+    0x0151, 0x014E, 0x014E, 0x014A, 0x0147, 0x0144, 0x0141, 0x013E, 0x013E, 0x013B, 0x0138, 0x0135, 0x0132, 0x012F, 0x012C, 0x012C, 
+    0x0129, 0x0127, 0x0124, 0x0121, 0x011F, 0x011C, 0x011A, 0x011A, 0x0118, 0x0115, 0x0113, 0x0111, 0x010E, 0x010C, 0x010A, 0x0108, 
+    0x0108, 0x0106, 0x0104, 0x0102, 0x0100, 0x00FE, 0x00FC, 0x00FA, 0x00F8, 0x00F6, 0x00F6, 0x00F4, 0x00F2, 0x00F0, 0x00EF, 0x00ED, 
+    0x0249, 0x0249, 0x0249, 0x0249, 0x0249, 0x0249, 0x0249, 0x0249, 0x0249, 0x023E, 0x023E, 0x023E, 0x023E, 0x023E, 0x0234, 0x0234, 
+    0x0234, 0x0234, 0x022B, 0x022B, 0x022B, 0x0222, 0x0222, 0x0222, 0x0219, 0x0219, 0x0210, 0x0210, 0x0210, 0x0208, 0x0208, 0x0200, 
+    0x0200, 0x01F8, 0x01F8, 0x01F0, 0x01F0, 0x01E9, 0x01E9, 0x01E1, 0x01DA, 0x01DA, 0x01D4, 0x01D4, 0x01CD, 0x01C7, 0x01C7, 0x01C0, 
+    0x01BA, 0x01BA, 0x01B4, 0x01B4, 0x01AF, 0x01A9, 0x01A4, 0x01A4, 0x019E, 0x0199, 0x0199, 0x0194, 0x018F, 0x018A, 0x018A, 0x0186, 
+    0x0181, 0x017D, 0x017D, 0x0178, 0x0174, 0x0170, 0x0170, 0x016C, 0x0168, 0x0164, 0x0164, 0x0160, 0x015C, 0x0158, 0x0155, 0x0151, 
+    0x0151, 0x014E, 0x014A, 0x0147, 0x0144, 0x0144, 0x0141, 0x013E, 0x013B, 0x0138, 0x0135, 0x0132, 0x0132, 0x012F, 0x012C, 0x0129, 
+    0x0127, 0x0124, 0x0121, 0x0121, 0x011F, 0x011C, 0x011A, 0x0118, 0x0115, 0x0113, 0x0111, 0x0111, 0x010E, 0x010C, 0x010A, 0x0108, 
+    0x0106, 0x0104, 0x0102, 0x0100, 0x0100, 0x00FE, 0x00FC, 0x00FA, 0x00F8, 0x00F6, 0x00F4, 0x00F2, 0x00F0, 0x00EF, 0x00ED, 0x00ED, 
+    0x023E, 0x023E, 0x023E, 0x023E, 0x023E, 0x023E, 0x023E, 0x023E, 0x023E, 0x023E, 0x0234, 0x0234, 0x0234, 0x0234, 0x0234, 0x022B, 
+    0x022B, 0x022B, 0x0222, 0x0222, 0x0222, 0x0219, 0x0219, 0x0219, 0x0210, 0x0210, 0x0210, 0x0208, 0x0208, 0x0200, 0x0200, 0x01F8, 
+    0x01F8, 0x01F0, 0x01F0, 0x01E9, 0x01E9, 0x01E1, 0x01E1, 0x01DA, 0x01DA, 0x01D4, 0x01CD, 0x01CD, 0x01C7, 0x01C7, 0x01C0, 0x01BA, 
+    0x01BA, 0x01B4, 0x01AF, 0x01AF, 0x01A9, 0x01A4, 0x01A4, 0x019E, 0x0199, 0x0199, 0x0194, 0x018F, 0x018F, 0x018A, 0x0186, 0x0181, 
+    0x0181, 0x017D, 0x0178, 0x0174, 0x0174, 0x0170, 0x016C, 0x0168, 0x0164, 0x0164, 0x0160, 0x015C, 0x0158, 0x0158, 0x0155, 0x0151, 
+    0x014E, 0x014A, 0x0147, 0x0147, 0x0144, 0x0141, 0x013E, 0x013B, 0x0138, 0x0138, 0x0135, 0x0132, 0x012F, 0x012C, 0x0129, 0x0129, 
+    0x0127, 0x0124, 0x0121, 0x011F, 0x011C, 0x011A, 0x011A, 0x0118, 0x0115, 0x0113, 0x0111, 0x010E, 0x010C, 0x010A, 0x0108, 0x0108, 
+    0x0106, 0x0104, 0x0102, 0x0100, 0x00FE, 0x00FC, 0x00FA, 0x00F8, 0x00F8, 0x00F6, 0x00F4, 0x00F2, 0x00F0, 0x00EF, 0x00ED, 0x00EB, 
+    0x0234, 0x0234, 0x0234, 0x0234, 0x0234, 0x0234, 0x0234, 0x0234, 0x0234, 0x0234, 0x022B, 0x022B, 0x022B, 0x022B, 0x022B, 0x0222, 
+    0x0222, 0x0222, 0x0222, 0x0219, 0x0219, 0x0219, 0x0210, 0x0210, 0x0210, 0x0208, 0x0208, 0x0200, 0x0200, 0x01F8, 0x01F8, 0x01F8, 
+    0x01F0, 0x01F0, 0x01E9, 0x01E9, 0x01E1, 0x01DA, 0x01DA, 0x01D4, 0x01D4, 0x01CD, 0x01CD, 0x01C7, 0x01C7, 0x01C0, 0x01BA, 0x01BA, 
+    0x01B4, 0x01AF, 0x01AF, 0x01A9, 0x01A4, 0x01A4, 0x019E, 0x0199, 0x0199, 0x0194, 0x018F, 0x018F, 0x018A, 0x0186, 0x0181, 0x0181, 
+    0x017D, 0x0178, 0x0174, 0x0174, 0x0170, 0x016C, 0x0168, 0x0168, 0x0164, 0x0160, 0x015C, 0x015C, 0x0158, 0x0155, 0x0151, 0x014E, 
+    0x014E, 0x014A, 0x0147, 0x0144, 0x0141, 0x013E, 0x013E, 0x013B, 0x0138, 0x0135, 0x0132, 0x012F, 0x012F, 0x012C, 0x0129, 0x0127, 
+    0x0124, 0x0121, 0x011F, 0x011F, 0x011C, 0x011A, 0x0118, 0x0115, 0x0113, 0x0111, 0x0111, 0x010E, 0x010C, 0x010A, 0x0108, 0x0106, 
+    0x0104, 0x0102, 0x0100, 0x0100, 0x00FE, 0x00FC, 0x00FA, 0x00F8, 0x00F6, 0x00F4, 0x00F2, 0x00F0, 0x00F0, 0x00EF, 0x00ED, 0x00EB, 
+    0x022B, 0x022B, 0x022B, 0x022B, 0x022B, 0x022B, 0x022B, 0x022B, 0x022B, 0x022B, 0x0222, 0x0222, 0x0222, 0x0222, 0x0222, 0x0219, 
+    0x0219, 0x0219, 0x0219, 0x0210, 0x0210, 0x0210, 0x0208, 0x0208, 0x0208, 0x0200, 0x0200, 0x01F8, 0x01F8, 0x01F8, 0x01F0, 0x01F0, 
+    0x01E9, 0x01E9, 0x01E1, 0x01E1, 0x01DA, 0x01DA, 0x01D4, 0x01D4, 0x01CD, 0x01C7, 0x01C7, 0x01C0, 0x01C0, 0x01BA, 0x01BA, 0x01B4, 
+    0x01AF, 0x01AF, 0x01A9, 0x01A4, 0x01A4, 0x019E, 0x0199, 0x0199, 0x0194, 0x018F, 0x018F, 0x018A, 0x0186, 0x0181, 0x0181, 0x017D, 
+    0x0178, 0x0178, 0x0174, 0x0170, 0x016C, 0x016C, 0x0168, 0x0164, 0x0160, 0x0160, 0x015C, 0x0158, 0x0155, 0x0151, 0x0151, 0x014E, 
+    0x014A, 0x0147, 0x0144, 0x0144, 0x0141, 0x013E, 0x013B, 0x0138, 0x0135, 0x0135, 0x0132, 0x012F, 0x012C, 0x0129, 0x0127, 0x0127, 
+    0x0124, 0x0121, 0x011F, 0x011C, 0x011A, 0x0118, 0x0118, 0x0115, 0x0113, 0x0111, 0x010E, 0x010C, 0x010A, 0x0108, 0x0108, 0x0106, 
+    0x0104, 0x0102, 0x0100, 0x00FE, 0x00FC, 0x00FA, 0x00F8, 0x00F8, 0x00F6, 0x00F4, 0x00F2, 0x00F0, 0x00EF, 0x00ED, 0x00EB, 0x00EA, 
+    0x0222, 0x0222, 0x0222, 0x0222, 0x0222, 0x0222, 0x0222, 0x0222, 0x0222, 0x0222, 0x0222, 0x0219, 0x0219, 0x0219, 0x0219, 0x0210, 
+    0x0210, 0x0210, 0x0210, 0x0208, 0x0208, 0x0208, 0x0200, 0x0200, 0x0200, 0x01F8, 0x01F8, 0x01F8, 0x01F0, 0x01F0, 0x01E9, 0x01E9, 
+    0x01E1, 0x01E1, 0x01DA, 0x01DA, 0x01D4, 0x01D4, 0x01CD, 0x01CD, 0x01C7, 0x01C7, 0x01C0, 0x01C0, 0x01BA, 0x01B4, 0x01B4, 0x01AF, 
+    0x01AF, 0x01A9, 0x01A4, 0x01A4, 0x019E, 0x0199, 0x0199, 0x0194, 0x018F, 0x018F, 0x018A, 0x0186, 0x0186, 0x0181, 0x017D, 0x0178, 
+    0x0178, 0x0174, 0x0170, 0x016C, 0x016C, 0x0168, 0x0164, 0x0160, 0x0160, 0x015C, 0x0158, 0x0155, 0x0155, 0x0151, 0x014E, 0x014A, 
+    0x0147, 0x0147, 0x0144, 0x0141, 0x013E, 0x013B, 0x013B, 0x0138, 0x0135, 0x0132, 0x012F, 0x012C, 0x012C, 0x0129, 0x0127, 0x0124, 
+    0x0121, 0x011F, 0x011F, 0x011C, 0x011A, 0x0118, 0x0115, 0x0113, 0x0111, 0x010E, 0x010E, 0x010C, 0x010A, 0x0108, 0x0106, 0x0104, 
+    0x0102, 0x0100, 0x0100, 0x00FE, 0x00FC, 0x00FA, 0x00F8, 0x00F6, 0x00F4, 0x00F2, 0x00F0, 0x00F0, 0x00EF, 0x00ED, 0x00EB, 0x00EA, 
+    0x0219, 0x0219, 0x0219, 0x0219, 0x0219, 0x0219, 0x0219, 0x0219, 0x0219, 0x0219, 0x0219, 0x0210, 0x0210, 0x0210, 0x0210, 0x0210, 
+    0x0208, 0x0208, 0x0208, 0x0200, 0x0200, 0x0200, 0x0200, 0x01F8, 0x01F8, 0x01F0, 0x01F0, 0x01F0, 0x01E9, 0x01E9, 0x01E1, 0x01E1, 
+    0x01DA, 0x01DA, 0x01DA, 0x01D4, 0x01D4, 0x01CD, 0x01CD, 0x01C7, 0x01C0, 0x01C0, 0x01BA, 0x01BA, 0x01B4, 0x01B4, 0x01AF, 0x01A9, 
+    0x01A9, 0x01A4, 0x01A4, 0x019E, 0x0199, 0x0199, 0x0194, 0x018F, 0x018F, 0x018A, 0x0186, 0x0186, 0x0181, 0x017D, 0x0178, 0x0178, 
+    0x0174, 0x0170, 0x0170, 0x016C, 0x0168, 0x0164, 0x0164, 0x0160, 0x015C, 0x0158, 0x0158, 0x0155, 0x0151, 0x014E, 0x014A, 0x014A, 
+    0x0147, 0x0144, 0x0141, 0x013E, 0x013E, 0x013B, 0x0138, 0x0135, 0x0132, 0x0132, 0x012F, 0x012C, 0x0129, 0x0127, 0x0124, 0x0124, 
+    0x0121, 0x011F, 0x011C, 0x011A, 0x0118, 0x0115, 0x0115, 0x0113, 0x0111, 0x010E, 0x010C, 0x010A, 0x0108, 0x0108, 0x0106, 0x0104, 
+    0x0102, 0x0100, 0x00FE, 0x00FC, 0x00FA, 0x00F8, 0x00F8, 0x00F6, 0x00F4, 0x00F2, 0x00F0, 0x00EF, 0x00ED, 0x00EB, 0x00EA, 0x00EA, 
+    0x0210, 0x0210, 0x0210, 0x0210, 0x0210, 0x0210, 0x0210, 0x0210, 0x0210, 0x0210, 0x0210, 0x0208, 0x0208, 0x0208, 0x0208, 0x0208, 
+    0x0200, 0x0200, 0x0200, 0x0200, 0x01F8, 0x01F8, 0x01F8, 0x01F0, 0x01F0, 0x01F0, 0x01E9, 0x01E9, 0x01E1, 0x01E1, 0x01E1, 0x01DA, 
+    0x01DA, 0x01D4, 0x01D4, 0x01CD, 0x01CD, 0x01C7, 0x01C7, 0x01C0, 0x01C0, 0x01BA, 0x01BA, 0x01B4, 0x01AF, 0x01AF, 0x01A9, 0x01A9, 
+    0x01A4, 0x019E, 0x019E, 0x0199, 0x0199, 0x0194, 0x018F, 0x018F, 0x018A, 0x0186, 0x0186, 0x0181, 0x017D, 0x0178, 0x0178, 0x0174, 
+    0x0170, 0x0170, 0x016C, 0x0168, 0x0164, 0x0164, 0x0160, 0x015C, 0x0158, 0x0158, 0x0155, 0x0151, 0x014E, 0x014E, 0x014A, 0x0147, 
+    0x0144, 0x0141, 0x0141, 0x013E, 0x013B, 0x0138, 0x0135, 0x0135, 0x0132, 0x012F, 0x012C, 0x0129, 0x0129, 0x0127, 0x0124, 0x0121, 
+    0x011F, 0x011C, 0x011A, 0x011A, 0x0118, 0x0115, 0x0113, 0x0111, 0x010E, 0x010E, 0x010C, 0x010A, 0x0108, 0x0106, 0x0104, 0x0102, 
+    0x0100, 0x0100, 0x00FE, 0x00FC, 0x00FA, 0x00F8, 0x00F6, 0x00F4, 0x00F2, 0x00F0, 0x00F0, 0x00EF, 0x00ED, 0x00EB, 0x00EA, 0x00E8, 
+    0x0208, 0x0208, 0x0208, 0x0208, 0x0208, 0x0208, 0x0208, 0x0208, 0x0208, 0x0208, 0x0208, 0x0200, 0x0200, 0x0200, 0x0200, 0x0200, 
+    0x01F8, 0x01F8, 0x01F8, 0x01F8, 0x01F0, 0x01F0, 0x01F0, 0x01E9, 0x01E9, 0x01E9, 0x01E1, 0x01E1, 0x01DA, 0x01DA, 0x01DA, 0x01D4, 
+    0x01D4, 0x01CD, 0x01CD, 0x01C7, 0x01C7, 0x01C0, 0x01C0, 0x01BA, 0x01BA, 0x01B4, 0x01B4, 0x01AF, 0x01AF, 0x01A9, 0x01A4, 0x01A4, 
+    0x019E, 0x019E, 0x0199, 0x0194, 0x0194, 0x018F, 0x018A, 0x018A, 0x0186, 0x0181, 0x0181, 0x017D, 0x0178, 0x0178, 0x0174, 0x0170, 
+    0x0170, 0x016C, 0x0168, 0x0164, 0x0164, 0x0160, 0x015C, 0x015C, 0x0158, 0x0155, 0x0151, 0x0151, 0x014E, 0x014A, 0x0147, 0x0144, 
+    0x0144, 0x0141, 0x013E, 0x013B, 0x0138, 0x0138, 0x0135, 0x0132, 0x012F, 0x012C, 0x012C, 0x0129, 0x0127, 0x0124, 0x0121, 0x011F, 
+    0x011F, 0x011C, 0x011A, 0x0118, 0x0115, 0x0113, 0x0113, 0x0111, 0x010E, 0x010C, 0x010A, 0x0108, 0x0106, 0x0106, 0x0104, 0x0102, 
+    0x0100, 0x00FE, 0x00FC, 0x00FA, 0x00F8, 0x00F8, 0x00F6, 0x00F4, 0x00F2, 0x00F0, 0x00EF, 0x00ED, 0x00EB, 0x00EA, 0x00EA, 0x00E8, 
+    0x0200, 0x0200, 0x0200, 0x0200, 0x0200, 0x0200, 0x0200, 0x0200, 0x0200, 0x0200, 0x0200, 0x0200, 0x01F8, 0x01F8, 0x01F8, 0x01F8, 
+    0x01F0, 0x01F0, 0x01F0, 0x01F0, 0x01E9, 0x01E9, 0x01E9, 0x01E1, 0x01E1, 0x01E1, 0x01DA, 0x01DA, 0x01DA, 0x01D4, 0x01D4, 0x01CD, 
+    0x01CD, 0x01C7, 0x01C7, 0x01C7, 0x01C0, 0x01C0, 0x01BA, 0x01BA, 0x01B4, 0x01AF, 0x01AF, 0x01A9, 0x01A9, 0x01A4, 0x01A4, 0x019E, 
+    0x0199, 0x0199, 0x0194, 0x0194, 0x018F, 0x018A, 0x018A, 0x0186, 0x0181, 0x0181, 0x017D, 0x0178, 0x0178, 0x0174, 0x0170, 0x0170, 
+    0x016C, 0x0168, 0x0168, 0x0164, 0x0160, 0x015C, 0x015C, 0x0158, 0x0155, 0x0151, 0x0151, 0x014E, 0x014A, 0x0147, 0x0147, 0x0144, 
+    0x0141, 0x013E, 0x013B, 0x013B, 0x0138, 0x0135, 0x0132, 0x012F, 0x012F, 0x012C, 0x0129, 0x0127, 0x0124, 0x0124, 0x0121, 0x011F, 
+    0x011C, 0x011A, 0x0118, 0x0118, 0x0115, 0x0113, 0x0111, 0x010E, 0x010C, 0x010C, 0x010A, 0x0108, 0x0106, 0x0104, 0x0102, 0x0100, 
+    0x00FE, 0x00FE, 0x00FC, 0x00FA, 0x00F8, 0x00F6, 0x00F4, 0x00F2, 0x00F0, 0x00F0, 0x00EF, 0x00ED, 0x00EB, 0x00EA, 0x00E8, 0x00E6, 
+    0x01F8, 0x01F8, 0x01F8, 0x01F8, 0x01F8, 0x01F8, 0x01F8, 0x01F8, 0x01F8, 0x01F8, 0x01F8, 0x01F8, 0x01F0, 0x01F0, 0x01F0, 0x01F0, 
+    0x01F0, 0x01E9, 0x01E9, 0x01E9, 0x01E1, 0x01E1, 0x01E1, 0x01E1, 0x01DA, 0x01DA, 0x01D4, 0x01D4, 0x01D4, 0x01CD, 0x01CD, 0x01C7, 
+    0x01C7, 0x01C7, 0x01C0, 0x01C0, 0x01BA, 0x01BA, 0x01B4, 0x01B4, 0x01AF, 0x01AF, 0x01A9, 0x01A9, 0x01A4, 0x019E, 0x019E, 0x0199, 
+    0x0199, 0x0194, 0x018F, 0x018F, 0x018A, 0x018A, 0x0186, 0x0181, 0x0181, 0x017D, 0x0178, 0x0178, 0x0174, 0x0170, 0x0170, 0x016C, 
+    0x0168, 0x0168, 0x0164, 0x0160, 0x015C, 0x015C, 0x0158, 0x0155, 0x0151, 0x0151, 0x014E, 0x014A, 0x0147, 0x0147, 0x0144, 0x0141, 
+    0x013E, 0x013E, 0x013B, 0x0138, 0x0135, 0x0132, 0x0132, 0x012F, 0x012C, 0x0129, 0x0127, 0x0127, 0x0124, 0x0121, 0x011F, 0x011C, 
+    0x011C, 0x011A, 0x0118, 0x0115, 0x0113, 0x0111, 0x0111, 0x010E, 0x010C, 0x010A, 0x0108, 0x0106, 0x0104, 0x0104, 0x0102, 0x0100, 
+    0x00FE, 0x00FC, 0x00FA, 0x00F8, 0x00F8, 0x00F6, 0x00F4, 0x00F2, 0x00F0, 0x00EF, 0x00ED, 0x00EB, 0x00EA, 0x00EA, 0x00E8, 0x00E6, 
+    0x01F8, 0x01F8, 0x01F0, 0x01F0, 0x01F0, 0x01F0, 0x01F0, 0x01F0, 0x01F0, 0x01F0, 0x01F0, 0x01F0, 0x01E9, 0x01E9, 0x01E9, 0x01E9, 
+    0x01E9, 0x01E1, 0x01E1, 0x01E1, 0x01E1, 0x01DA, 0x01DA, 0x01DA, 0x01D4, 0x01D4, 0x01D4, 0x01CD, 0x01CD, 0x01C7, 0x01C7, 0x01C7, 
+    0x01C0, 0x01C0, 0x01BA, 0x01BA, 0x01B4, 0x01B4, 0x01AF, 0x01AF, 0x01A9, 0x01A9, 0x01A4, 0x01A4, 0x019E, 0x019E, 0x0199, 0x0194, 
+    0x0194, 0x018F, 0x018F, 0x018A, 0x0186, 0x0186, 0x0181, 0x0181, 0x017D, 0x0178, 0x0178, 0x0174, 0x0170, 0x0170, 0x016C, 0x0168, 
+    0x0168, 0x0164, 0x0160, 0x015C, 0x015C, 0x0158, 0x0155, 0x0155, 0x0151, 0x014E, 0x014A, 0x014A, 0x0147, 0x0144, 0x0141, 0x0141, 
+    0x013E, 0x013B, 0x0138, 0x0135, 0x0135, 0x0132, 0x012F, 0x012C, 0x012C, 0x0129, 0x0127, 0x0124, 0x0121, 0x011F, 0x011F, 0x011C, 
+    0x011A, 0x0118, 0x0115, 0x0115, 0x0113, 0x0111, 0x010E, 0x010C, 0x010A, 0x0108, 0x0108, 0x0106, 0x0104, 0x0102, 0x0100, 0x00FE, 
+    0x00FE, 0x00FC, 0x00FA, 0x00F8, 0x00F6, 0x00F4, 0x00F2, 0x00F0, 0x00F0, 0x00EF, 0x00ED, 0x00EB, 0x00EA, 0x00E8, 0x00E6, 0x00E5, 
+    0x01F0, 0x01F0, 0x01F0, 0x01E9, 0x01E9, 0x01E9, 0x01E9, 0x01E9, 0x01E9, 0x01E9, 0x01E9, 0x01E9, 0x01E1, 0x01E1, 0x01E1, 0x01E1, 
+    0x01E1, 0x01DA, 0x01DA, 0x01DA, 0x01DA, 0x01D4, 0x01D4, 0x01D4, 0x01CD, 0x01CD, 0x01CD, 0x01C7, 0x01C7, 0x01C7, 0x01C0, 0x01C0, 
+    0x01BA, 0x01BA, 0x01B4, 0x01B4, 0x01AF, 0x01AF, 0x01AF, 0x01A9, 0x01A9, 0x01A4, 0x019E, 0x019E, 0x0199, 0x0199, 0x0194, 0x0194, 
+    0x018F, 0x018F, 0x018A, 0x0186, 0x0186, 0x0181, 0x017D, 0x017D, 0x0178, 0x0178, 0x0174, 0x0170, 0x0170, 0x016C, 0x0168, 0x0168, 
+    0x0164, 0x0160, 0x015C, 0x015C, 0x0158, 0x0155, 0x0155, 0x0151, 0x014E, 0x014A, 0x014A, 0x0147, 0x0144, 0x0141, 0x0141, 0x013E, 
+    0x013B, 0x0138, 0x0138, 0x0135, 0x0132, 0x012F, 0x012F, 0x012C, 0x0129, 0x0127, 0x0124, 0x0124, 0x0121, 0x011F, 0x011C, 0x011A, 
+    0x0118, 0x0118, 0x0115, 0x0113, 0x0111, 0x010E, 0x010C, 0x010C, 0x010A, 0x0108, 0x0106, 0x0104, 0x0102, 0x0102, 0x0100, 0x00FE, 
+    0x00FC, 0x00FA, 0x00F8, 0x00F6, 0x00F6, 0x00F4, 0x00F2, 0x00F0, 0x00EF, 0x00ED, 0x00EB, 0x00EA, 0x00EA, 0x00E8, 0x00E6, 0x00E5, 
+    0x01E9, 0x01E9, 0x01E9, 0x01E9, 0x01E1, 0x01E1, 0x01E1, 0x01E1, 0x01E1, 0x01E1, 0x01E1, 0x01E1, 0x01E1, 0x01DA, 0x01DA, 0x01DA, 
+    0x01DA, 0x01D4, 0x01D4, 0x01D4, 0x01D4, 0x01CD, 0x01CD, 0x01CD, 0x01C7, 0x01C7, 0x01C7, 0x01C0, 0x01C0, 0x01C0, 0x01BA, 0x01BA, 
+    0x01B4, 0x01B4, 0x01B4, 0x01AF, 0x01AF, 0x01A9, 0x01A9, 0x01A4, 0x01A4, 0x019E, 0x019E, 0x0199, 0x0199, 0x0194, 0x018F, 0x018F, 
+    0x018A, 0x018A, 0x0186, 0x0186, 0x0181, 0x017D, 0x017D, 0x0178, 0x0174, 0x0174, 0x0170, 0x0170, 0x016C, 0x0168, 0x0168, 0x0164, 
+    0x0160, 0x015C, 0x015C, 0x0158, 0x0155, 0x0155, 0x0151, 0x014E, 0x014E, 0x014A, 0x0147, 0x0144, 0x0144, 0x0141, 0x013E, 0x013B, 
+    0x013B, 0x0138, 0x0135, 0x0132, 0x012F, 0x012F, 0x012C, 0x0129, 0x0127, 0x0127, 0x0124, 0x0121, 0x011F, 0x011C, 0x011C, 0x011A, 
+    0x0118, 0x0115, 0x0113, 0x0111, 0x0111, 0x010E, 0x010C, 0x010A, 0x0108, 0x0106, 0x0106, 0x0104, 0x0102, 0x0100, 0x00FE, 0x00FC, 
+    0x00FC, 0x00FA, 0x00F8, 0x00F6, 0x00F4, 0x00F2, 0x00F0, 0x00EF, 0x00EF, 0x00ED, 0x00EB, 0x00EA, 0x00E8, 0x00E6, 0x00E5, 0x00E3, 
+    0x01E1, 0x01E1, 0x01E1, 0x01E1, 0x01DA, 0x01DA, 0x01DA, 0x01DA, 0x01DA, 0x01DA, 0x01DA, 0x01DA, 0x01DA, 0x01D4, 0x01D4, 0x01D4, 
+    0x01D4, 0x01D4, 0x01CD, 0x01CD, 0x01CD, 0x01C7, 0x01C7, 0x01C7, 0x01C7, 0x01C0, 0x01C0, 0x01C0, 0x01BA, 0x01BA, 0x01B4, 0x01B4, 
+    0x01B4, 0x01AF, 0x01AF, 0x01A9, 0x01A9, 0x01A4, 0x01A4, 0x019E, 0x019E, 0x0199, 0x0199, 0x0194, 0x0194, 0x018F, 0x018F, 0x018A, 
+    0x018A, 0x0186, 0x0181, 0x0181, 0x017D, 0x017D, 0x0178, 0x0174, 0x0174, 0x0170, 0x016C, 0x016C, 0x0168, 0x0164, 0x0164, 0x0160, 
+    0x015C, 0x015C, 0x0158, 0x0155, 0x0155, 0x0151, 0x014E, 0x014E, 0x014A, 0x0147, 0x0144, 0x0144, 0x0141, 0x013E, 0x013B, 0x013B, 
+    0x0138, 0x0135, 0x0132, 0x0132, 0x012F, 0x012C, 0x0129, 0x0129, 0x0127, 0x0124, 0x0121, 0x011F, 0x011F, 0x011C, 0x011A, 0x0118, 
+    0x0115, 0x0115, 0x0113, 0x0111, 0x010E, 0x010C, 0x010A, 0x010A, 0x0108, 0x0106, 0x0104, 0x0102, 0x0100, 0x0100, 0x00FE, 0x00FC, 
+    0x00FA, 0x00F8, 0x00F6, 0x00F4, 0x00F4, 0x00F2, 0x00F0, 0x00EF, 0x00ED, 0x00EB, 0x00EA, 0x00EA, 0x00E8, 0x00E6, 0x00E5, 0x00E3, 
+    0x01DA, 0x01DA, 0x01DA, 0x01DA, 0x01DA, 0x01D4, 0x01D4, 0x01D4, 0x01D4, 0x01D4, 0x01D4, 0x01D4, 0x01D4, 0x01CD, 0x01CD, 0x01CD, 
+    0x01CD, 0x01CD, 0x01C7, 0x01C7, 0x01C7, 0x01C7, 0x01C0, 0x01C0, 0x01C0, 0x01BA, 0x01BA, 0x01BA, 0x01B4, 0x01B4, 0x01AF, 0x01AF, 
+    0x01AF, 0x01A9, 0x01A9, 0x01A4, 0x01A4, 0x019E, 0x019E, 0x0199, 0x0199, 0x0194, 0x0194, 0x018F, 0x018F, 0x018A, 0x018A, 0x0186, 
+    0x0186, 0x0181, 0x0181, 0x017D, 0x0178, 0x0178, 0x0174, 0x0174, 0x0170, 0x016C, 0x016C, 0x0168, 0x0164, 0x0164, 0x0160, 0x015C, 
+    0x015C, 0x0158, 0x0155, 0x0155, 0x0151, 0x014E, 0x014E, 0x014A, 0x0147, 0x0144, 0x0144, 0x0141, 0x013E, 0x013E, 0x013B, 0x0138, 
+    0x0135, 0x0135, 0x0132, 0x012F, 0x012C, 0x0129, 0x0129, 0x0127, 0x0124, 0x0121, 0x0121, 0x011F, 0x011C, 0x011A, 0x0118, 0x0118, 
+    0x0115, 0x0113, 0x0111, 0x010E, 0x010E, 0x010C, 0x010A, 0x0108, 0x0106, 0x0104, 0x0104, 0x0102, 0x0100, 0x00FE, 0x00FC, 0x00FA, 
+    0x00F8, 0x00F8, 0x00F6, 0x00F4, 0x00F2, 0x00F0, 0x00EF, 0x00EF, 0x00ED, 0x00EB, 0x00EA, 0x00E8, 0x00E6, 0x00E5, 0x00E3, 0x00E3, 
+    0x01D4, 0x01D4, 0x01D4, 0x01D4, 0x01D4, 0x01CD, 0x01CD, 0x01CD, 0x01CD, 0x01CD, 0x01CD, 0x01CD, 0x01CD, 0x01C7, 0x01C7, 0x01C7, 
+    0x01C7, 0x01C7, 0x01C0, 0x01C0, 0x01C0, 0x01C0, 0x01BA, 0x01BA, 0x01BA, 0x01B4, 0x01B4, 0x01B4, 0x01AF, 0x01AF, 0x01AF, 0x01A9, 
+    0x01A9, 0x01A4, 0x01A4, 0x019E, 0x019E, 0x019E, 0x0199, 0x0199, 0x0194, 0x0194, 0x018F, 0x018F, 0x018A, 0x018A, 0x0186, 0x0181, 
+    0x0181, 0x017D, 0x017D, 0x0178, 0x0178, 0x0174, 0x0170, 0x0170, 0x016C, 0x016C, 0x0168, 0x0164, 0x0164, 0x0160, 0x015C, 0x015C, 
+    0x0158, 0x0155, 0x0155, 0x0151, 0x014E, 0x014E, 0x014A, 0x0147, 0x0144, 0x0144, 0x0141, 0x013E, 0x013E, 0x013B, 0x0138, 0x0135, 
+    0x0135, 0x0132, 0x012F, 0x012C, 0x012C, 0x0129, 0x0127, 0x0124, 0x0124, 0x0121, 0x011F, 0x011C, 0x011A, 0x011A, 0x0118, 0x0115, 
+    0x0113, 0x0111, 0x0111, 0x010E, 0x010C, 0x010A, 0x0108, 0x0106, 0x0106, 0x0104, 0x0102, 0x0100, 0x00FE, 0x00FE, 0x00FC, 0x00FA, 
+    0x00F8, 0x00F6, 0x00F4, 0x00F2, 0x00F2, 0x00F0, 0x00EF, 0x00ED, 0x00EB, 0x00EA, 0x00E8, 0x00E8, 0x00E6, 0x00E5, 0x00E3, 0x00E1, 
+    0x01CD, 0x01CD, 0x01CD, 0x01CD, 0x01CD, 0x01CD, 0x01C7, 0x01C7, 0x01C7, 0x01C7, 0x01C7, 0x01C7, 0x01C7, 0x01C7, 0x01C0, 0x01C0, 
+    0x01C0, 0x01C0, 0x01BA, 0x01BA, 0x01BA, 0x01BA, 0x01B4, 0x01B4, 0x01B4, 0x01AF, 0x01AF, 0x01AF, 0x01A9, 0x01A9, 0x01A9, 0x01A4, 
+    0x01A4, 0x019E, 0x019E, 0x019E, 0x0199, 0x0199, 0x0194, 0x0194, 0x018F, 0x018F, 0x018A, 0x018A, 0x0186, 0x0186, 0x0181, 0x0181, 
+    0x017D, 0x017D, 0x0178, 0x0174, 0x0174, 0x0170, 0x0170, 0x016C, 0x0168, 0x0168, 0x0164, 0x0164, 0x0160, 0x015C, 0x015C, 0x0158, 
+    0x0155, 0x0155, 0x0151, 0x014E, 0x014E, 0x014A, 0x0147, 0x0147, 0x0144, 0x0141, 0x013E, 0x013E, 0x013B, 0x0138, 0x0135, 0x0135, 
+    0x0132, 0x012F, 0x012F, 0x012C, 0x0129, 0x0127, 0x0124, 0x0124, 0x0121, 0x011F, 0x011C, 0x011C, 0x011A, 0x0118, 0x0115, 0x0113, 
+    0x0113, 0x0111, 0x010E, 0x010C, 0x010A, 0x010A, 0x0108, 0x0106, 0x0104, 0x0102, 0x0100, 0x0100, 0x00FE, 0x00FC, 0x00FA, 0x00F8, 
+    0x00F6, 0x00F6, 0x00F4, 0x00F2, 0x00F0, 0x00EF, 0x00ED, 0x00ED, 0x00EB, 0x00EA, 0x00E8, 0x00E6, 0x00E5, 0x00E3, 0x00E1, 0x00E1, 
+    0x01C7, 0x01C7, 0x01C7, 0x01C7, 0x01C7, 0x01C7, 0x01C0, 0x01C0, 0x01C0, 0x01C0, 0x01C0, 0x01C0, 0x01C0, 0x01C0, 0x01BA, 0x01BA, 
+    0x01BA, 0x01BA, 0x01BA, 0x01B4, 0x01B4, 0x01B4, 0x01AF, 0x01AF, 0x01AF, 0x01AF, 0x01A9, 0x01A9, 0x01A9, 0x01A4, 0x01A4, 0x019E, 
+    0x019E, 0x019E, 0x0199, 0x0199, 0x0194, 0x0194, 0x018F, 0x018F, 0x018A, 0x018A, 0x0186, 0x0186, 0x0181, 0x0181, 0x017D, 0x017D, 
+    0x0178, 0x0178, 0x0174, 0x0174, 0x0170, 0x016C, 0x016C, 0x0168, 0x0168, 0x0164, 0x0160, 0x0160, 0x015C, 0x015C, 0x0158, 0x0155, 
+    0x0155, 0x0151, 0x014E, 0x014E, 0x014A, 0x0147, 0x0147, 0x0144, 0x0141, 0x013E, 0x013E, 0x013B, 0x0138, 0x0138, 0x0135, 0x0132, 
+    0x012F, 0x012F, 0x012C, 0x0129, 0x0127, 0x0127, 0x0124, 0x0121, 0x011F, 0x011F, 0x011C, 0x011A, 0x0118, 0x0115, 0x0115, 0x0113, 
+    0x0111, 0x010E, 0x010C, 0x010C, 0x010A, 0x0108, 0x0106, 0x0104, 0x0104, 0x0102, 0x0100, 0x00FE, 0x00FC, 0x00FA, 0x00FA, 0x00F8, 
+    0x00F6, 0x00F4, 0x00F2, 0x00F0, 0x00F0, 0x00EF, 0x00ED, 0x00EB, 0x00EA, 0x00E8, 0x00E6, 0x00E6, 0x00E5, 0x00E3, 0x00E1, 0x00E0, 
+    0x01C0, 0x01C0, 0x01C0, 0x01C0, 0x01C0, 0x01C0, 0x01BA, 0x01BA, 0x01BA, 0x01BA, 0x01BA, 0x01BA, 0x01BA, 0x01BA, 0x01B4, 0x01B4, 
+    0x01B4, 0x01B4, 0x01B4, 0x01AF, 0x01AF, 0x01AF, 0x01AF, 0x01A9, 0x01A9, 0x01A9, 0x01A4, 0x01A4, 0x01A4, 0x019E, 0x019E, 0x0199, 
+    0x0199, 0x0199, 0x0194, 0x0194, 0x018F, 0x018F, 0x018F, 0x018A, 0x018A, 0x0186, 0x0186, 0x0181, 0x0181, 0x017D, 0x017D, 0x0178, 
+    0x0174, 0x0174, 0x0170, 0x0170, 0x016C, 0x016C, 0x0168, 0x0164, 0x0164, 0x0160, 0x0160, 0x015C, 0x0158, 0x0158, 0x0155, 0x0151, 
+    0x0151, 0x014E, 0x014E, 0x014A, 0x0147, 0x0144, 0x0144, 0x0141, 0x013E, 0x013E, 0x013B, 0x0138, 0x0138, 0x0135, 0x0132, 0x012F, 
+    0x012F, 0x012C, 0x0129, 0x0127, 0x0127, 0x0124, 0x0121, 0x011F, 0x011F, 0x011C, 0x011A, 0x0118, 0x0118, 0x0115, 0x0113, 0x0111, 
+    0x010E, 0x010E, 0x010C, 0x010A, 0x0108, 0x0106, 0x0106, 0x0104, 0x0102, 0x0100, 0x00FE, 0x00FE, 0x00FC, 0x00FA, 0x00F8, 0x00F6, 
+    0x00F4, 0x00F4, 0x00F2, 0x00F0, 0x00EF, 0x00ED, 0x00EB, 0x00EA, 0x00EA, 0x00E8, 0x00E6, 0x00E5, 0x00E3, 0x00E1, 0x00E0, 0x00E0, 
+    0x01BA, 0x01BA, 0x01BA, 0x01BA, 0x01BA, 0x01BA, 0x01BA, 0x01B4, 0x01B4, 0x01B4, 0x01B4, 0x01B4, 0x01B4, 0x01B4, 0x01AF, 0x01AF, 
+    0x01AF, 0x01AF, 0x01AF, 0x01A9, 0x01A9, 0x01A9, 0x01A9, 0x01A4, 0x01A4, 0x01A4, 0x019E, 0x019E, 0x019E, 0x0199, 0x0199, 0x0199, 
+    0x0194, 0x0194, 0x018F, 0x018F, 0x018F, 0x018A, 0x018A, 0x0186, 0x0186, 0x0181, 0x0181, 0x017D, 0x017D, 0x0178, 0x0178, 0x0174, 
+    0x0174, 0x0170, 0x0170, 0x016C, 0x0168, 0x0168, 0x0164, 0x0164, 0x0160, 0x0160, 0x015C, 0x0158, 0x0158, 0x0155, 0x0151, 0x0151, 
+    0x014E, 0x014A, 0x014A, 0x0147, 0x0144, 0x0144, 0x0141, 0x013E, 0x013E, 0x013B, 0x0138, 0x0138, 0x0135, 0x0132, 0x012F, 0x012F, 
+    0x012C, 0x0129, 0x0129, 0x0127, 0x0124, 0x0121, 0x0121, 0x011F, 0x011C, 0x011A, 0x011A, 0x0118, 0x0115, 0x0113, 0x0111, 0x0111, 
+    0x010E, 0x010C, 0x010A, 0x0108, 0x0108, 0x0106, 0x0104, 0x0102, 0x0100, 0x0100, 0x00FE, 0x00FC, 0x00FA, 0x00F8, 0x00F8, 0x00F6, 
+    0x00F4, 0x00F2, 0x00F0, 0x00EF, 0x00EF, 0x00ED, 0x00EB, 0x00EA, 0x00E8, 0x00E6, 0x00E5, 0x00E5, 0x00E3, 0x00E1, 0x00E0, 0x00DE, 
+    0x01B4, 0x01B4, 0x01B4, 0x01B4, 0x01B4, 0x01B4, 0x01B4, 0x01AF, 0x01AF, 0x01AF, 0x01AF, 0x01AF, 0x01AF, 0x01AF, 0x01AF, 0x01A9, 
+    0x01A9, 0x01A9, 0x01A9, 0x01A4, 0x01A4, 0x01A4, 0x01A4, 0x019E, 0x019E, 0x019E, 0x0199, 0x0199, 0x0199, 0x0194, 0x0194, 0x0194, 
+    0x018F, 0x018F, 0x018F, 0x018A, 0x018A, 0x0186, 0x0186, 0x0181, 0x0181, 0x017D, 0x017D, 0x0178, 0x0178, 0x0174, 0x0174, 0x0170, 
+    0x0170, 0x016C, 0x016C, 0x0168, 0x0168, 0x0164, 0x0164, 0x0160, 0x015C, 0x015C, 0x0158, 0x0158, 0x0155, 0x0151, 0x0151, 0x014E, 
+    0x014A, 0x014A, 0x0147, 0x0144, 0x0144, 0x0141, 0x013E, 0x013E, 0x013B, 0x0138, 0x0138, 0x0135, 0x0132, 0x0132, 0x012F, 0x012C, 
+    0x0129, 0x0129, 0x0127, 0x0124, 0x0121, 0x0121, 0x011F, 0x011C, 0x011A, 0x011A, 0x0118, 0x0115, 0x0113, 0x0113, 0x0111, 0x010E, 
+    0x010C, 0x010A, 0x010A, 0x0108, 0x0106, 0x0104, 0x0102, 0x0102, 0x0100, 0x00FE, 0x00FC, 0x00FA, 0x00FA, 0x00F8, 0x00F6, 0x00F4, 
+    0x00F2, 0x00F0, 0x00F0, 0x00EF, 0x00ED, 0x00EB, 0x00EA, 0x00E8, 0x00E8, 0x00E6, 0x00E5, 0x00E3, 0x00E1, 0x00E0, 0x00E0, 0x00DE, 
+    0x01AF, 0x01AF, 0x01AF, 0x01AF, 0x01AF, 0x01AF, 0x01AF, 0x01A9, 0x01A9, 0x01A9, 0x01A9, 0x01A9, 0x01A9, 0x01A9, 0x01A9, 0x01A4, 
+    0x01A4, 0x01A4, 0x01A4, 0x019E, 0x019E, 0x019E, 0x019E, 0x0199, 0x0199, 0x0199, 0x0199, 0x0194, 0x0194, 0x0194, 0x018F, 0x018F, 
+    0x018A, 0x018A, 0x018A, 0x0186, 0x0186, 0x0181, 0x0181, 0x017D, 0x017D, 0x017D, 0x0178, 0x0178, 0x0174, 0x0174, 0x0170, 0x0170, 
+    0x016C, 0x0168, 0x0168, 0x0164, 0x0164, 0x0160, 0x0160, 0x015C, 0x015C, 0x0158, 0x0155, 0x0155, 0x0151, 0x0151, 0x014E, 0x014A, 
+    0x014A, 0x0147, 0x0144, 0x0144, 0x0141, 0x013E, 0x013E, 0x013B, 0x0138, 0x0138, 0x0135, 0x0132, 0x0132, 0x012F, 0x012C, 0x0129, 
+    0x0129, 0x0127, 0x0124, 0x0121, 0x0121, 0x011F, 0x011C, 0x011C, 0x011A, 0x0118, 0x0115, 0x0113, 0x0113, 0x0111, 0x010E, 0x010C, 
+    0x010C, 0x010A, 0x0108, 0x0106, 0x0104, 0x0104, 0x0102, 0x0100, 0x00FE, 0x00FC, 0x00FC, 0x00FA, 0x00F8, 0x00F6, 0x00F4, 0x00F4, 
+    0x00F2, 0x00F0, 0x00EF, 0x00ED, 0x00EB, 0x00EB, 0x00EA, 0x00E8, 0x00E6, 0x00E5, 0x00E3, 0x00E3, 0x00E1, 0x00E0, 0x00DE, 0x00DD, 
+    0x01A9, 0x01A9, 0x01A9, 0x01A9, 0x01A9, 0x01A9, 0x01A9, 0x01A9, 0x01A4, 0x01A4, 0x01A4, 0x01A4, 0x01A4, 0x01A4, 0x01A4, 0x019E, 
+    0x019E, 0x019E, 0x019E, 0x019E, 0x0199, 0x0199, 0x0199, 0x0194, 0x0194, 0x0194, 0x0194, 0x018F, 0x018F, 0x018F, 0x018A, 0x018A, 
+    0x0186, 0x0186, 0x0186, 0x0181, 0x0181, 0x017D, 0x017D, 0x017D, 0x0178, 0x0178, 0x0174, 0x0174, 0x0170, 0x0170, 0x016C, 0x016C, 
+    0x0168, 0x0168, 0x0164, 0x0164, 0x0160, 0x015C, 0x015C, 0x0158, 0x0158, 0x0155, 0x0155, 0x0151, 0x014E, 0x014E, 0x014A, 0x0147, 
+    0x0147, 0x0144, 0x0144, 0x0141, 0x013E, 0x013E, 0x013B, 0x0138, 0x0138, 0x0135, 0x0132, 0x0132, 0x012F, 0x012C, 0x0129, 0x0129, 
+    0x0127, 0x0124, 0x0124, 0x0121, 0x011F, 0x011C, 0x011C, 0x011A, 0x0118, 0x0115, 0x0115, 0x0113, 0x0111, 0x010E, 0x010E, 0x010C, 
+    0x010A, 0x0108, 0x0106, 0x0106, 0x0104, 0x0102, 0x0100, 0x00FE, 0x00FE, 0x00FC, 0x00FA, 0x00F8, 0x00F6, 0x00F6, 0x00F4, 0x00F2, 
+    0x00F0, 0x00EF, 0x00EF, 0x00ED, 0x00EB, 0x00EA, 0x00E8, 0x00E6, 0x00E6, 0x00E5, 0x00E3, 0x00E1, 0x00E0, 0x00DE, 0x00DD, 0x00DD, 
+    0x01A4, 0x01A4, 0x01A4, 0x01A4, 0x01A4, 0x01A4, 0x01A4, 0x01A4, 0x019E, 0x019E, 0x019E, 0x019E, 0x019E, 0x019E, 0x019E, 0x0199, 
+    0x0199, 0x0199, 0x0199, 0x0199, 0x0194, 0x0194, 0x0194, 0x0194, 0x018F, 0x018F, 0x018F, 0x018A, 0x018A, 0x018A, 0x0186, 0x0186, 
+    0x0186, 0x0181, 0x0181, 0x017D, 0x017D, 0x017D, 0x0178, 0x0178, 0x0174, 0x0174, 0x0170, 0x0170, 0x016C, 0x016C, 0x0168, 0x0168, 
+    0x0164, 0x0164, 0x0160, 0x0160, 0x015C, 0x015C, 0x0158, 0x0158, 0x0155, 0x0151, 0x0151, 0x014E, 0x014E, 0x014A, 0x0147, 0x0147, 
+    0x0144, 0x0141, 0x0141, 0x013E, 0x013E, 0x013B, 0x0138, 0x0138, 0x0135, 0x0132, 0x0132, 0x012F, 0x012C, 0x0129, 0x0129, 0x0127, 
+    0x0124, 0x0124, 0x0121, 0x011F, 0x011C, 0x011C, 0x011A, 0x0118, 0x0115, 0x0115, 0x0113, 0x0111, 0x010E, 0x010E, 0x010C, 0x010A, 
+    0x0108, 0x0108, 0x0106, 0x0104, 0x0102, 0x0100, 0x0100, 0x00FE, 0x00FC, 0x00FA, 0x00FA, 0x00F8, 0x00F6, 0x00F4, 0x00F2, 0x00F0, 
+    0x00F0, 0x00EF, 0x00ED, 0x00EB, 0x00EA, 0x00EA, 0x00E8, 0x00E6, 0x00E5, 0x00E3, 0x00E1, 0x00E1, 0x00E0, 0x00DE, 0x00DD, 0x00DB, 
+    0x019E, 0x019E, 0x019E, 0x019E, 0x019E, 0x019E, 0x019E, 0x019E, 0x0199, 0x0199, 0x0199, 0x0199, 0x0199, 0x0199, 0x0199, 0x0194, 
+    0x0194, 0x0194, 0x0194, 0x0194, 0x018F, 0x018F, 0x018F, 0x018F, 0x018A, 0x018A, 0x018A, 0x0186, 0x0186, 0x0186, 0x0181, 0x0181, 
+    0x0181, 0x017D, 0x017D, 0x017D, 0x0178, 0x0178, 0x0174, 0x0174, 0x0170, 0x0170, 0x016C, 0x016C, 0x016C, 0x0168, 0x0168, 0x0164, 
+    0x0164, 0x0160, 0x015C, 0x015C, 0x0158, 0x0158, 0x0155, 0x0155, 0x0151, 0x0151, 0x014E, 0x014A, 0x014A, 0x0147, 0x0147, 0x0144, 
+    0x0141, 0x0141, 0x013E, 0x013B, 0x013B, 0x0138, 0x0135, 0x0135, 0x0132, 0x012F, 0x012F, 0x012C, 0x0129, 0x0129, 0x0127, 0x0124, 
+    0x0124, 0x0121, 0x011F, 0x011C, 0x011C, 0x011A, 0x0118, 0x0118, 0x0115, 0x0113, 0x0111, 0x0111, 0x010E, 0x010C, 0x010A, 0x010A, 
+    0x0108, 0x0106, 0x0104, 0x0102, 0x0102, 0x0100, 0x00FE, 0x00FC, 0x00FC, 0x00FA, 0x00F8, 0x00F6, 0x00F4, 0x00F4, 0x00F2, 0x00F0, 
+    0x00EF, 0x00ED, 0x00EB, 0x00EB, 0x00EA, 0x00E8, 0x00E6, 0x00E5, 0x00E3, 0x00E3, 0x00E1, 0x00E0, 0x00DE, 0x00DD, 0x00DB, 0x00DB, 
+    0x0199, 0x0199, 0x0199, 0x0199, 0x0199, 0x0199, 0x0199, 0x0199, 0x0194, 0x0194, 0x0194, 0x0194, 0x0194, 0x0194, 0x0194, 0x0194, 
+    0x018F, 0x018F, 0x018F, 0x018F, 0x018A, 0x018A, 0x018A, 0x018A, 0x0186, 0x0186, 0x0186, 0x0181, 0x0181, 0x0181, 0x017D, 0x017D, 
+    0x017D, 0x0178, 0x0178, 0x0178, 0x0174, 0x0174, 0x0170, 0x0170, 0x0170, 0x016C, 0x016C, 0x0168, 0x0168, 0x0164, 0x0164, 0x0160, 
+    0x0160, 0x015C, 0x015C, 0x0158, 0x0158, 0x0155, 0x0151, 0x0151, 0x014E, 0x014E, 0x014A, 0x014A, 0x0147, 0x0144, 0x0144, 0x0141, 
+    0x0141, 0x013E, 0x013B, 0x013B, 0x0138, 0x0135, 0x0135, 0x0132, 0x012F, 0x012F, 0x012C, 0x0129, 0x0129, 0x0127, 0x0124, 0x0124, 
+    0x0121, 0x011F, 0x011F, 0x011C, 0x011A, 0x0118, 0x0118, 0x0115, 0x0113, 0x0111, 0x0111, 0x010E, 0x010C, 0x010A, 0x010A, 0x0108, 
+    0x0106, 0x0104, 0x0104, 0x0102, 0x0100, 0x00FE, 0x00FC, 0x00FC, 0x00FA, 0x00F8, 0x00F6, 0x00F6, 0x00F4, 0x00F2, 0x00F0, 0x00EF, 
+    0x00EF, 0x00ED, 0x00EB, 0x00EA, 0x00E8, 0x00E6, 0x00E6, 0x00E5, 0x00E3, 0x00E1, 0x00E0, 0x00DE, 0x00DE, 0x00DD, 0x00DB, 0x00DA, 
+    0x0194, 0x0194, 0x0194, 0x0194, 0x0194, 0x0194, 0x0194, 0x0194, 0x0194, 0x018F, 0x018F, 0x018F, 0x018F, 0x018F, 0x018F, 0x018F, 
+    0x018A, 0x018A, 0x018A, 0x018A, 0x0186, 0x0186, 0x0186, 0x0186, 0x0181, 0x0181, 0x0181, 0x0181, 0x017D, 0x017D, 0x017D, 0x0178, 
+    0x0178, 0x0174, 0x0174, 0x0174, 0x0170, 0x0170, 0x016C, 0x016C, 0x016C, 0x0168, 0x0168, 0x0164, 0x0164, 0x0160, 0x0160, 0x015C, 
+    0x015C, 0x0158, 0x0158, 0x0155, 0x0155, 0x0151, 0x0151, 0x014E, 0x014E, 0x014A, 0x0147, 0x0147, 0x0144, 0x0144, 0x0141, 0x013E, 
+    0x013E, 0x013B, 0x013B, 0x0138, 0x0135, 0x0135, 0x0132, 0x012F, 0x012F, 0x012C, 0x0129, 0x0129, 0x0127, 0x0124, 0x0124, 0x0121, 
+    0x011F, 0x011F, 0x011C, 0x011A, 0x0118, 0x0118, 0x0115, 0x0113, 0x0111, 0x0111, 0x010E, 0x010C, 0x010C, 0x010A, 0x0108, 0x0106, 
+    0x0106, 0x0104, 0x0102, 0x0100, 0x00FE, 0x00FE, 0x00FC, 0x00FA, 0x00F8, 0x00F8, 0x00F6, 0x00F4, 0x00F2, 0x00F0, 0x00F0, 0x00EF, 
+    0x00ED, 0x00EB, 0x00EA, 0x00E8, 0x00E8, 0x00E6, 0x00E5, 0x00E3, 0x00E1, 0x00E1, 0x00E0, 0x00DE, 0x00DD, 0x00DB, 0x00DA, 0x00DA, 
+    0x018F, 0x018F, 0x018F, 0x018F, 0x018F, 0x018F, 0x018F, 0x018F, 0x018F, 0x018A, 0x018A, 0x018A, 0x018A, 0x018A, 0x018A, 0x018A, 
+    0x0186, 0x0186, 0x0186, 0x0186, 0x0186, 0x0181, 0x0181, 0x0181, 0x0181, 0x017D, 0x017D, 0x017D, 0x0178, 0x0178, 0x0178, 0x0174, 
+    0x0174, 0x0174, 0x0170, 0x0170, 0x016C, 0x016C, 0x016C, 0x0168, 0x0168, 0x0164, 0x0164, 0x0160, 0x0160, 0x015C, 0x015C, 0x0158, 
+    0x0158, 0x0155, 0x0155, 0x0151, 0x0151, 0x014E, 0x014E, 0x014A, 0x014A, 0x0147, 0x0147, 0x0144, 0x0141, 0x0141, 0x013E, 0x013E, 
+    0x013B, 0x0138, 0x0138, 0x0135, 0x0135, 0x0132, 0x012F, 0x012F, 0x012C, 0x0129, 0x0129, 0x0127, 0x0124, 0x0124, 0x0121, 0x011F, 
+    0x011F, 0x011C, 0x011A, 0x0118, 0x0118, 0x0115, 0x0113, 0x0113, 0x0111, 0x010E, 0x010C, 0x010C, 0x010A, 0x0108, 0x0106, 0x0106, 
+    0x0104, 0x0102, 0x0100, 0x0100, 0x00FE, 0x00FC, 0x00FA, 0x00F8, 0x00F8, 0x00F6, 0x00F4, 0x00F2, 0x00F2, 0x00F0, 0x00EF, 0x00ED, 
+    0x00EB, 0x00EB, 0x00EA, 0x00E8, 0x00E6, 0x00E5, 0x00E3, 0x00E3, 0x00E1, 0x00E0, 0x00DE, 0x00DD, 0x00DD, 0x00DB, 0x00DA, 0x00D9, 
+    0x018A, 0x018A, 0x018A, 0x018A, 0x018A, 0x018A, 0x018A, 0x018A, 0x018A, 0x0186, 0x0186, 0x0186, 0x0186, 0x0186, 0x0186, 0x0186, 
+    0x0181, 0x0181, 0x0181, 0x0181, 0x0181, 0x017D, 0x017D, 0x017D, 0x017D, 0x0178, 0x0178, 0x0178, 0x0174, 0x0174, 0x0174, 0x0170, 
+    0x0170, 0x0170, 0x016C, 0x016C, 0x016C, 0x0168, 0x0168, 0x0164, 0x0164, 0x0160, 0x0160, 0x0160, 0x015C, 0x015C, 0x0158, 0x0158, 
+    0x0155, 0x0155, 0x0151, 0x0151, 0x014E, 0x014E, 0x014A, 0x0147, 0x0147, 0x0144, 0x0144, 0x0141, 0x0141, 0x013E, 0x013B, 0x013B, 
+    0x0138, 0x0138, 0x0135, 0x0132, 0x0132, 0x012F, 0x012F, 0x012C, 0x0129, 0x0129, 0x0127, 0x0124, 0x0124, 0x0121, 0x011F, 0x011F, 
+    0x011C, 0x011A, 0x0118, 0x0118, 0x0115, 0x0113, 0x0113, 0x0111, 0x010E, 0x010C, 0x010C, 0x010A, 0x0108, 0x0106, 0x0106, 0x0104, 
+    0x0102, 0x0100, 0x0100, 0x00FE, 0x00FC, 0x00FA, 0x00FA, 0x00F8, 0x00F6, 0x00F4, 0x00F4, 0x00F2, 0x00F0, 0x00EF, 0x00ED, 0x00ED, 
+    0x00EB, 0x00EA, 0x00E8, 0x00E6, 0x00E6, 0x00E5, 0x00E3, 0x00E1, 0x00E0, 0x00DE, 0x00DE, 0x00DD, 0x00DB, 0x00DA, 0x00D9, 0x00D7, 
+    0x0186, 0x0186, 0x0186, 0x0186, 0x0186, 0x0186, 0x0186, 0x0186, 0x0186, 0x0181, 0x0181, 0x0181, 0x0181, 0x0181, 0x0181, 0x0181, 
+    0x017D, 0x017D, 0x017D, 0x017D, 0x017D, 0x0178, 0x0178, 0x0178, 0x0178, 0x0174, 0x0174, 0x0174, 0x0170, 0x0170, 0x0170, 0x016C, 
+    0x016C, 0x016C, 0x0168, 0x0168, 0x0168, 0x0164, 0x0164, 0x0160, 0x0160, 0x0160, 0x015C, 0x015C, 0x0158, 0x0158, 0x0155, 0x0155, 
+    0x0151, 0x0151, 0x014E, 0x014E, 0x014A, 0x014A, 0x0147, 0x0147, 0x0144, 0x0144, 0x0141, 0x013E, 0x013E, 0x013B, 0x013B, 0x0138, 
+    0x0135, 0x0135, 0x0132, 0x0132, 0x012F, 0x012C, 0x012C, 0x0129, 0x0127, 0x0127, 0x0124, 0x0121, 0x0121, 0x011F, 0x011C, 0x011C, 
+    0x011A, 0x0118, 0x0118, 0x0115, 0x0113, 0x0113, 0x0111, 0x010E, 0x010C, 0x010C, 0x010A, 0x0108, 0x0108, 0x0106, 0x0104, 0x0102, 
+    0x0102, 0x0100, 0x00FE, 0x00FC, 0x00FC, 0x00FA, 0x00F8, 0x00F6, 0x00F4, 0x00F4, 0x00F2, 0x00F0, 0x00EF, 0x00EF, 0x00ED, 0x00EB, 
+    0x00EA, 0x00E8, 0x00E8, 0x00E6, 0x00E5, 0x00E3, 0x00E1, 0x00E1, 0x00E0, 0x00DE, 0x00DD, 0x00DB, 0x00DA, 0x00DA, 0x00D9, 0x00D7, 
+    0x0181, 0x0181, 0x0181, 0x0181, 0x0181, 0x0181, 0x0181, 0x0181, 0x0181, 0x0181, 0x017D, 0x017D, 0x017D, 0x017D, 0x017D, 0x017D, 
+    0x017D, 0x0178, 0x0178, 0x0178, 0x0178, 0x0174, 0x0174, 0x0174, 0x0174, 0x0170, 0x0170, 0x0170, 0x0170, 0x016C, 0x016C, 0x016C, 
+    0x0168, 0x0168, 0x0164, 0x0164, 0x0164, 0x0160, 0x0160, 0x0160, 0x015C, 0x015C, 0x0158, 0x0158, 0x0155, 0x0155, 0x0151, 0x0151, 
+    0x014E, 0x014E, 0x014A, 0x014A, 0x0147, 0x0147, 0x0144, 0x0144, 0x0141, 0x0141, 0x013E, 0x013E, 0x013B, 0x0138, 0x0138, 0x0135, 
+    0x0135, 0x0132, 0x012F, 0x012F, 0x012C, 0x012C, 0x0129, 0x0127, 0x0127, 0x0124, 0x0121, 0x0121, 0x011F, 0x011C, 0x011C, 0x011A, 
+    0x0118, 0x0118, 0x0115, 0x0113, 0x0113, 0x0111, 0x010E, 0x010E, 0x010C, 0x010A, 0x0108, 0x0108, 0x0106, 0x0104, 0x0102, 0x0102, 
+    0x0100, 0x00FE, 0x00FC, 0x00FC, 0x00FA, 0x00F8, 0x00F6, 0x00F6, 0x00F4, 0x00F2, 0x00F0, 0x00F0, 0x00EF, 0x00ED, 0x00EB, 0x00EA, 
+    0x00EA, 0x00E8, 0x00E6, 0x00E5, 0x00E3, 0x00E3, 0x00E1, 0x00E0, 0x00DE, 0x00DD, 0x00DD, 0x00DB, 0x00DA, 0x00D9, 0x00D7, 0x00D6, 
+    0x017D, 0x017D, 0x017D, 0x017D, 0x017D, 0x017D, 0x017D, 0x017D, 0x017D, 0x017D, 0x0178, 0x0178, 0x0178, 0x0178, 0x0178, 0x0178, 
+    0x0178, 0x0174, 0x0174, 0x0174, 0x0174, 0x0170, 0x0170, 0x0170, 0x0170, 0x016C, 0x016C, 0x016C, 0x016C, 0x0168, 0x0168, 0x0168, 
+    0x0164, 0x0164, 0x0164, 0x0160, 0x0160, 0x015C, 0x015C, 0x015C, 0x0158, 0x0158, 0x0155, 0x0155, 0x0151, 0x0151, 0x0151, 0x014E, 
+    0x014E, 0x014A, 0x014A, 0x0147, 0x0147, 0x0144, 0x0144, 0x0141, 0x013E, 0x013E, 0x013B, 0x013B, 0x0138, 0x0138, 0x0135, 0x0132, 
+    0x0132, 0x012F, 0x012F, 0x012C, 0x0129, 0x0129, 0x0127, 0x0127, 0x0124, 0x0121, 0x0121, 0x011F, 0x011C, 0x011C, 0x011A, 0x0118, 
+    0x0118, 0x0115, 0x0113, 0x0113, 0x0111, 0x010E, 0x010E, 0x010C, 0x010A, 0x0108, 0x0108, 0x0106, 0x0104, 0x0102, 0x0102, 0x0100, 
+    0x00FE, 0x00FE, 0x00FC, 0x00FA, 0x00F8, 0x00F8, 0x00F6, 0x00F4, 0x00F2, 0x00F0, 0x00F0, 0x00EF, 0x00ED, 0x00EB, 0x00EB, 0x00EA, 
+    0x00E8, 0x00E6, 0x00E5, 0x00E5, 0x00E3, 0x00E1, 0x00E0, 0x00DE, 0x00DE, 0x00DD, 0x00DB, 0x00DA, 0x00D9, 0x00D7, 0x00D7, 0x00D6, 
+    0x0178, 0x0178, 0x0178, 0x0178, 0x0178, 0x0178, 0x0178, 0x0178, 0x0178, 0x0178, 0x0174, 0x0174, 0x0174, 0x0174, 0x0174, 0x0174, 
+    0x0174, 0x0170, 0x0170, 0x0170, 0x0170, 0x0170, 0x016C, 0x016C, 0x016C, 0x016C, 0x0168, 0x0168, 0x0168, 0x0164, 0x0164, 0x0164, 
+    0x0160, 0x0160, 0x0160, 0x015C, 0x015C, 0x015C, 0x0158, 0x0158, 0x0155, 0x0155, 0x0151, 0x0151, 0x0151, 0x014E, 0x014E, 0x014A, 
+    0x014A, 0x0147, 0x0147, 0x0144, 0x0144, 0x0141, 0x0141, 0x013E, 0x013E, 0x013B, 0x013B, 0x0138, 0x0135, 0x0135, 0x0132, 0x0132, 
+    0x012F, 0x012F, 0x012C, 0x0129, 0x0129, 0x0127, 0x0124, 0x0124, 0x0121, 0x0121, 0x011F, 0x011C, 0x011C, 0x011A, 0x0118, 0x0118, 
+    0x0115, 0x0113, 0x0113, 0x0111, 0x010E, 0x010E, 0x010C, 0x010A, 0x0108, 0x0108, 0x0106, 0x0104, 0x0104, 0x0102, 0x0100, 0x00FE, 
+    0x00FE, 0x00FC, 0x00FA, 0x00F8, 0x00F8, 0x00F6, 0x00F4, 0x00F2, 0x00F2, 0x00F0, 0x00EF, 0x00ED, 0x00ED, 0x00EB, 0x00EA, 0x00E8, 
+    0x00E6, 0x00E6, 0x00E5, 0x00E3, 0x00E1, 0x00E0, 0x00E0, 0x00DE, 0x00DD, 0x00DB, 0x00DA, 0x00DA, 0x00D9, 0x00D7, 0x00D6, 0x00D4, 
+    0x0174, 0x0174, 0x0174, 0x0174, 0x0174, 0x0174, 0x0174, 0x0174, 0x0174, 0x0174, 0x0170, 0x0170, 0x0170, 0x0170, 0x0170, 0x0170, 
+    0x0170, 0x016C, 0x016C, 0x016C, 0x016C, 0x016C, 0x0168, 0x0168, 0x0168, 0x0168, 0x0164, 0x0164, 0x0164, 0x0160, 0x0160, 0x0160, 
+    0x015C, 0x015C, 0x015C, 0x0158, 0x0158, 0x0158, 0x0155, 0x0155, 0x0151, 0x0151, 0x0151, 0x014E, 0x014E, 0x014A, 0x014A, 0x0147, 
+    0x0147, 0x0144, 0x0144, 0x0141, 0x0141, 0x013E, 0x013E, 0x013B, 0x013B, 0x0138, 0x0138, 0x0135, 0x0135, 0x0132, 0x012F, 0x012F, 
+    0x012C, 0x012C, 0x0129, 0x0129, 0x0127, 0x0124, 0x0124, 0x0121, 0x011F, 0x011F, 0x011C, 0x011C, 0x011A, 0x0118, 0x0118, 0x0115, 
+    0x0113, 0x0113, 0x0111, 0x010E, 0x010E, 0x010C, 0x010A, 0x0108, 0x0108, 0x0106, 0x0104, 0x0104, 0x0102, 0x0100, 0x00FE, 0x00FE, 
+    0x00FC, 0x00FA, 0x00F8, 0x00F8, 0x00F6, 0x00F4, 0x00F2, 0x00F2, 0x00F0, 0x00EF, 0x00ED, 0x00ED, 0x00EB, 0x00EA, 0x00E8, 0x00E8, 
+    0x00E6, 0x00E5, 0x00E3, 0x00E1, 0x00E1, 0x00E0, 0x00DE, 0x00DD, 0x00DB, 0x00DB, 0x00DA, 0x00D9, 0x00D7, 0x00D6, 0x00D6, 0x00D4, 
+    0x0170, 0x0170, 0x0170, 0x0170, 0x0170, 0x0170, 0x0170, 0x0170, 0x0170, 0x0170, 0x016C, 0x016C, 0x016C, 0x016C, 0x016C, 0x016C, 
+    0x016C, 0x0168, 0x0168, 0x0168, 0x0168, 0x0168, 0x0164, 0x0164, 0x0164, 0x0164, 0x0160, 0x0160, 0x0160, 0x015C, 0x015C, 0x015C, 
+    0x015C, 0x0158, 0x0158, 0x0155, 0x0155, 0x0155, 0x0151, 0x0151, 0x0151, 0x014E, 0x014E, 0x014A, 0x014A, 0x0147, 0x0147, 0x0144, 
+    0x0144, 0x0144, 0x0141, 0x0141, 0x013E, 0x013E, 0x013B, 0x0138, 0x0138, 0x0135, 0x0135, 0x0132, 0x0132, 0x012F, 0x012F, 0x012C, 
+    0x012C, 0x0129, 0x0127, 0x0127, 0x0124, 0x0124, 0x0121, 0x011F, 0x011F, 0x011C, 0x011A, 0x011A, 0x0118, 0x0115, 0x0115, 0x0113, 
+    0x0111, 0x0111, 0x010E, 0x010C, 0x010C, 0x010A, 0x0108, 0x0108, 0x0106, 0x0104, 0x0104, 0x0102, 0x0100, 0x00FE, 0x00FE, 0x00FC, 
+    0x00FA, 0x00FA, 0x00F8, 0x00F6, 0x00F4, 0x00F4, 0x00F2, 0x00F0, 0x00EF, 0x00EF, 0x00ED, 0x00EB, 0x00EA, 0x00E8, 0x00E8, 0x00E6, 
+    0x00E5, 0x00E3, 0x00E3, 0x00E1, 0x00E0, 0x00DE, 0x00DD, 0x00DD, 0x00DB, 0x00DA, 0x00D9, 0x00D7, 0x00D7, 0x00D6, 0x00D4, 0x00D3, 
+    0x016C, 0x016C, 0x016C, 0x016C, 0x016C, 0x016C, 0x016C, 0x016C, 0x016C, 0x016C, 0x016C, 0x0168, 0x0168, 0x0168, 0x0168, 0x0168, 
+    0x0168, 0x0164, 0x0164, 0x0164, 0x0164, 0x0164, 0x0160, 0x0160, 0x0160, 0x0160, 0x015C, 0x015C, 0x015C, 0x015C, 0x0158, 0x0158, 
+    0x0158, 0x0155, 0x0155, 0x0155, 0x0151, 0x0151, 0x014E, 0x014E, 0x014E, 0x014A, 0x014A, 0x0147, 0x0147, 0x0144, 0x0144, 0x0144, 
+    0x0141, 0x0141, 0x013E, 0x013E, 0x013B, 0x013B, 0x0138, 0x0138, 0x0135, 0x0135, 0x0132, 0x0132, 0x012F, 0x012C, 0x012C, 0x0129, 
+    0x0129, 0x0127, 0x0127, 0x0124, 0x0121, 0x0121, 0x011F, 0x011F, 0x011C, 0x011A, 0x011A, 0x0118, 0x0115, 0x0115, 0x0113, 0x0111, 
+    0x0111, 0x010E, 0x010C, 0x010C, 0x010A, 0x0108, 0x0108, 0x0106, 0x0104, 0x0104, 0x0102, 0x0100, 0x00FE, 0x00FE, 0x00FC, 0x00FA, 
+    0x00FA, 0x00F8, 0x00F6, 0x00F4, 0x00F4, 0x00F2, 0x00F0, 0x00EF, 0x00EF, 0x00ED, 0x00EB, 0x00EA, 0x00EA, 0x00E8, 0x00E6, 0x00E5, 
+    0x00E5, 0x00E3, 0x00E1, 0x00E0, 0x00DE, 0x00DE, 0x00DD, 0x00DB, 0x00DA, 0x00D9, 0x00D9, 0x00D7, 0x00D6, 0x00D4, 0x00D3, 0x00D3, 
+    0x0168, 0x0168, 0x0168, 0x0168, 0x0168, 0x0168, 0x0168, 0x0168, 0x0168, 0x0168, 0x0168, 0x0164, 0x0164, 0x0164, 0x0164, 0x0164, 
+    0x0164, 0x0164, 0x0160, 0x0160, 0x0160, 0x0160, 0x015C, 0x015C, 0x015C, 0x015C, 0x0158, 0x0158, 0x0158, 0x0158, 0x0155, 0x0155, 
+    0x0155, 0x0151, 0x0151, 0x0151, 0x014E, 0x014E, 0x014E, 0x014A, 0x014A, 0x0147, 0x0147, 0x0144, 0x0144, 0x0144, 0x0141, 0x0141, 
+    0x013E, 0x013E, 0x013B, 0x013B, 0x0138, 0x0138, 0x0135, 0x0135, 0x0132, 0x0132, 0x012F, 0x012F, 0x012C, 0x012C, 0x0129, 0x0127, 
+    0x0127, 0x0124, 0x0124, 0x0121, 0x0121, 0x011F, 0x011C, 0x011C, 0x011A, 0x011A, 0x0118, 0x0115, 0x0115, 0x0113, 0x0111, 0x0111, 
+    0x010E, 0x010C, 0x010C, 0x010A, 0x0108, 0x0108, 0x0106, 0x0104, 0x0104, 0x0102, 0x0100, 0x0100, 0x00FE, 0x00FC, 0x00FA, 0x00FA, 
+    0x00F8, 0x00F6, 0x00F4, 0x00F4, 0x00F2, 0x00F0, 0x00F0, 0x00EF, 0x00ED, 0x00EB, 0x00EB, 0x00EA, 0x00E8, 0x00E6, 0x00E5, 0x00E5, 
+    0x00E3, 0x00E1, 0x00E0, 0x00E0, 0x00DE, 0x00DD, 0x00DB, 0x00DA, 0x00DA, 0x00D9, 0x00D7, 0x00D6, 0x00D4, 0x00D4, 0x00D3, 0x00D2, 
+    0x0164, 0x0164, 0x0164, 0x0164, 0x0164, 0x0164, 0x0164, 0x0164, 0x0164, 0x0164, 0x0164, 0x0160, 0x0160, 0x0160, 0x0160, 0x0160, 
+    0x0160, 0x0160, 0x015C, 0x015C, 0x015C, 0x015C, 0x015C, 0x0158, 0x0158, 0x0158, 0x0158, 0x0155, 0x0155, 0x0155, 0x0151, 0x0151, 
+    0x0151, 0x014E, 0x014E, 0x014E, 0x014A, 0x014A, 0x014A, 0x0147, 0x0147, 0x0144, 0x0144, 0x0144, 0x0141, 0x0141, 0x013E, 0x013E, 
+    0x013B, 0x013B, 0x0138, 0x0138, 0x0135, 0x0135, 0x0132, 0x0132, 0x012F, 0x012F, 0x012C, 0x012C, 0x0129, 0x0129, 0x0127, 0x0127, 
+    0x0124, 0x0124, 0x0121, 0x011F, 0x011F, 0x011C, 0x011C, 0x011A, 0x0118, 0x0118, 0x0115, 0x0113, 0x0113, 0x0111, 0x0111, 0x010E, 
+    0x010C, 0x010C, 0x010A, 0x0108, 0x0108, 0x0106, 0x0104, 0x0104, 0x0102, 0x0100, 0x0100, 0x00FE, 0x00FC, 0x00FA, 0x00FA, 0x00F8, 
+    0x00F6, 0x00F6, 0x00F4, 0x00F2, 0x00F0, 0x00F0, 0x00EF, 0x00ED, 0x00EB, 0x00EB, 0x00EA, 0x00E8, 0x00E6, 0x00E6, 0x00E5, 0x00E3, 
+    0x00E1, 0x00E1, 0x00E0, 0x00DE, 0x00DD, 0x00DB, 0x00DB, 0x00DA, 0x00D9, 0x00D7, 0x00D6, 0x00D6, 0x00D4, 0x00D3, 0x00D2, 0x00D0, 
+    0x0160, 0x0160, 0x0160, 0x0160, 0x0160, 0x0160, 0x0160, 0x0160, 0x0160, 0x0160, 0x0160, 0x015C, 0x015C, 0x015C, 0x015C, 0x015C, 
+    0x015C, 0x015C, 0x0158, 0x0158, 0x0158, 0x0158, 0x0158, 0x0155, 0x0155, 0x0155, 0x0155, 0x0151, 0x0151, 0x0151, 0x014E, 0x014E, 
+    0x014E, 0x014A, 0x014A, 0x014A, 0x0147, 0x0147, 0x0147, 0x0144, 0x0144, 0x0144, 0x0141, 0x0141, 0x013E, 0x013E, 0x013B, 0x013B, 
+    0x013B, 0x0138, 0x0138, 0x0135, 0x0135, 0x0132, 0x0132, 0x012F, 0x012F, 0x012C, 0x012C, 0x0129, 0x0129, 0x0127, 0x0124, 0x0124, 
+    0x0121, 0x0121, 0x011F, 0x011F, 0x011C, 0x011A, 0x011A, 0x0118, 0x0118, 0x0115, 0x0113, 0x0113, 0x0111, 0x010E, 0x010E, 0x010C, 
+    0x010C, 0x010A, 0x0108, 0x0108, 0x0106, 0x0104, 0x0104, 0x0102, 0x0100, 0x00FE, 0x00FE, 0x00FC, 0x00FA, 0x00FA, 0x00F8, 0x00F6, 
+    0x00F6, 0x00F4, 0x00F2, 0x00F0, 0x00F0, 0x00EF, 0x00ED, 0x00EB, 0x00EB, 0x00EA, 0x00E8, 0x00E6, 0x00E6, 0x00E5, 0x00E3, 0x00E1, 
+    0x00E1, 0x00E0, 0x00DE, 0x00DD, 0x00DD, 0x00DB, 0x00DA, 0x00D9, 0x00D7, 0x00D7, 0x00D6, 0x00D4, 0x00D3, 0x00D2, 0x00D2, 0x00D0, 
+    0x015C, 0x015C, 0x015C, 0x015C, 0x015C, 0x015C, 0x015C, 0x015C, 0x015C, 0x015C, 0x015C, 0x0158, 0x0158, 0x0158, 0x0158, 0x0158, 
+    0x0158, 0x0158, 0x0155, 0x0155, 0x0155, 0x0155, 0x0155, 0x0151, 0x0151, 0x0151, 0x0151, 0x014E, 0x014E, 0x014E, 0x014A, 0x014A, 
+    0x014A, 0x014A, 0x0147, 0x0147, 0x0144, 0x0144, 0x0144, 0x0141, 0x0141, 0x0141, 0x013E, 0x013E, 0x013B, 0x013B, 0x013B, 0x0138, 
+    0x0138, 0x0135, 0x0135, 0x0132, 0x0132, 0x012F, 0x012F, 0x012C, 0x012C, 0x0129, 0x0129, 0x0127, 0x0127, 0x0124, 0x0124, 0x0121, 
+    0x011F, 0x011F, 0x011C, 0x011C, 0x011A, 0x011A, 0x0118, 0x0115, 0x0115, 0x0113, 0x0113, 0x0111, 0x010E, 0x010E, 0x010C, 0x010A, 
+    0x010A, 0x0108, 0x0106, 0x0106, 0x0104, 0x0102, 0x0102, 0x0100, 0x00FE, 0x00FE, 0x00FC, 0x00FA, 0x00FA, 0x00F8, 0x00F6, 0x00F6, 
+    0x00F4, 0x00F2, 0x00F0, 0x00F0, 0x00EF, 0x00ED, 0x00ED, 0x00EB, 0x00EA, 0x00E8, 0x00E8, 0x00E6, 0x00E5, 0x00E3, 0x00E3, 0x00E1, 
+    0x00E0, 0x00DE, 0x00DE, 0x00DD, 0x00DB, 0x00DA, 0x00D9, 0x00D9, 0x00D7, 0x00D6, 0x00D4, 0x00D3, 0x00D3, 0x00D2, 0x00D0, 0x00CF, 
+    0x0158, 0x0158, 0x0158, 0x0158, 0x0158, 0x0158, 0x0158, 0x0158, 0x0158, 0x0158, 0x0158, 0x0158, 0x0155, 0x0155, 0x0155, 0x0155, 
+    0x0155, 0x0155, 0x0151, 0x0151, 0x0151, 0x0151, 0x0151, 0x014E, 0x014E, 0x014E, 0x014E, 0x014A, 0x014A, 0x014A, 0x014A, 0x0147, 
+    0x0147, 0x0147, 0x0144, 0x0144, 0x0144, 0x0141, 0x0141, 0x013E, 0x013E, 0x013E, 0x013B, 0x013B, 0x0138, 0x0138, 0x0138, 0x0135, 
+    0x0135, 0x0132, 0x0132, 0x012F, 0x012F, 0x012C, 0x012C, 0x0129, 0x0129, 0x0127, 0x0127, 0x0124, 0x0124, 0x0121, 0x0121, 0x011F, 
+    0x011F, 0x011C, 0x011C, 0x011A, 0x0118, 0x0118, 0x0115, 0x0115, 0x0113, 0x0111, 0x0111, 0x010E, 0x010E, 0x010C, 0x010A, 0x010A, 
+    0x0108, 0x0106, 0x0106, 0x0104, 0x0102, 0x0102, 0x0100, 0x00FE, 0x00FE, 0x00FC, 0x00FA, 0x00FA, 0x00F8, 0x00F6, 0x00F6, 0x00F4, 
+    0x00F2, 0x00F0, 0x00F0, 0x00EF, 0x00ED, 0x00ED, 0x00EB, 0x00EA, 0x00E8, 0x00E8, 0x00E6, 0x00E5, 0x00E3, 0x00E3, 0x00E1, 0x00E0, 
+    0x00DE, 0x00DE, 0x00DD, 0x00DB, 0x00DA, 0x00DA, 0x00D9, 0x00D7, 0x00D6, 0x00D4, 0x00D4, 0x00D3, 0x00D2, 0x00D0, 0x00CF, 0x00CF, 
+    0x0155, 0x0155, 0x0155, 0x0155, 0x0155, 0x0155, 0x0155, 0x0155, 0x0155, 0x0155, 0x0155, 0x0155, 0x0151, 0x0151, 0x0151, 0x0151, 
+    0x0151, 0x0151, 0x014E, 0x014E, 0x014E, 0x014E, 0x014E, 0x014A, 0x014A, 0x014A, 0x014A, 0x0147, 0x0147, 0x0147, 0x0147, 0x0144, 
+    0x0144, 0x0144, 0x0141, 0x0141, 0x0141, 0x013E, 0x013E, 0x013E, 0x013B, 0x013B, 0x0138, 0x0138, 0x0138, 0x0135, 0x0135, 0x0132, 
+    0x0132, 0x012F, 0x012F, 0x012C, 0x012C, 0x012C, 0x0129, 0x0129, 0x0127, 0x0127, 0x0124, 0x0124, 0x0121, 0x011F, 0x011F, 0x011C, 
+    0x011C, 0x011A, 0x011A, 0x0118, 0x0118, 0x0115, 0x0113, 0x0113, 0x0111, 0x0111, 0x010E, 0x010C, 0x010C, 0x010A, 0x010A, 0x0108, 
+    0x0106, 0x0106, 0x0104, 0x0102, 0x0102, 0x0100, 0x00FE, 0x00FE, 0x00FC, 0x00FA, 0x00FA, 0x00F8, 0x00F6, 0x00F6, 0x00F4, 0x00F2, 
+    0x00F0, 0x00F0, 0x00EF, 0x00ED, 0x00ED, 0x00EB, 0x00EA, 0x00E8, 0x00E8, 0x00E6, 0x00E5, 0x00E5, 0x00E3, 0x00E1, 0x00E0, 0x00E0, 
+    0x00DE, 0x00DD, 0x00DB, 0x00DA, 0x00DA, 0x00D9, 0x00D7, 0x00D6, 0x00D6, 0x00D4, 0x00D3, 0x00D2, 0x00D0, 0x00D0, 0x00CF, 0x00CE, 
+    0x0151, 0x0151, 0x0151, 0x0151, 0x0151, 0x0151, 0x0151, 0x0151, 0x0151, 0x0151, 0x0151, 0x0151, 0x014E, 0x014E, 0x014E, 0x014E, 
+    0x014E, 0x014E, 0x014E, 0x014A, 0x014A, 0x014A, 0x014A, 0x0147, 0x0147, 0x0147, 0x0147, 0x0144, 0x0144, 0x0144, 0x0144, 0x0141, 
+    0x0141, 0x0141, 0x013E, 0x013E, 0x013E, 0x013B, 0x013B, 0x013B, 0x0138, 0x0138, 0x0135, 0x0135, 0x0135, 0x0132, 0x0132, 0x012F, 
+    0x012F, 0x012F, 0x012C, 0x012C, 0x0129, 0x0129, 0x0127, 0x0127, 0x0124, 0x0124, 0x0121, 0x0121, 0x011F, 0x011F, 0x011C, 0x011C, 
+    0x011A, 0x0118, 0x0118, 0x0115, 0x0115, 0x0113, 0x0113, 0x0111, 0x010E, 0x010E, 0x010C, 0x010C, 0x010A, 0x0108, 0x0108, 0x0106, 
+    0x0106, 0x0104, 0x0102, 0x0102, 0x0100, 0x00FE, 0x00FE, 0x00FC, 0x00FA, 0x00FA, 0x00F8, 0x00F6, 0x00F6, 0x00F4, 0x00F2, 0x00F0, 
+    0x00F0, 0x00EF, 0x00ED, 0x00ED, 0x00EB, 0x00EA, 0x00EA, 0x00E8, 0x00E6, 0x00E5, 0x00E5, 0x00E3, 0x00E1, 0x00E0, 0x00E0, 0x00DE, 
+    0x00DD, 0x00DB, 0x00DB, 0x00DA, 0x00D9, 0x00D7, 0x00D7, 0x00D6, 0x00D4, 0x00D3, 0x00D2, 0x00D2, 0x00D0, 0x00CF, 0x00CE, 0x00CC, 
+    0x014E, 0x014E, 0x014E, 0x014E, 0x014E, 0x014E, 0x014E, 0x014E, 0x014E, 0x014E, 0x014E, 0x014E, 0x014A, 0x014A, 0x014A, 0x014A, 
+    0x014A, 0x014A, 0x014A, 0x0147, 0x0147, 0x0147, 0x0147, 0x0147, 0x0144, 0x0144, 0x0144, 0x0144, 0x0141, 0x0141, 0x0141, 0x013E, 
+    0x013E, 0x013E, 0x013B, 0x013B, 0x013B, 0x0138, 0x0138, 0x0138, 0x0135, 0x0135, 0x0135, 0x0132, 0x0132, 0x012F, 0x012F, 0x012F, 
+    0x012C, 0x012C, 0x0129, 0x0129, 0x0127, 0x0127, 0x0124, 0x0124, 0x0121, 0x0121, 0x011F, 0x011F, 0x011C, 0x011C, 0x011A, 0x011A, 
+    0x0118, 0x0118, 0x0115, 0x0115, 0x0113, 0x0111, 0x0111, 0x010E, 0x010E, 0x010C, 0x010A, 0x010A, 0x0108, 0x0108, 0x0106, 0x0104, 
+    0x0104, 0x0102, 0x0100, 0x0100, 0x00FE, 0x00FE, 0x00FC, 0x00FA, 0x00FA, 0x00F8, 0x00F6, 0x00F6, 0x00F4, 0x00F2, 0x00F0, 0x00F0, 
+    0x00EF, 0x00ED, 0x00ED, 0x00EB, 0x00EA, 0x00EA, 0x00E8, 0x00E6, 0x00E5, 0x00E5, 0x00E3, 0x00E1, 0x00E0, 0x00E0, 0x00DE, 0x00DD, 
+    0x00DB, 0x00DB, 0x00DA, 0x00D9, 0x00D7, 0x00D7, 0x00D6, 0x00D4, 0x00D3, 0x00D3, 0x00D2, 0x00D0, 0x00CF, 0x00CE, 0x00CE, 0x00CC, 
+    0x014A, 0x014A, 0x014A, 0x014A, 0x014A, 0x014A, 0x014A, 0x014A, 0x014A, 0x014A, 0x014A, 0x014A, 0x0147, 0x0147, 0x0147, 0x0147, 
+    0x0147, 0x0147, 0x0147, 0x0144, 0x0144, 0x0144, 0x0144, 0x0144, 0x0141, 0x0141, 0x0141, 0x0141, 0x013E, 0x013E, 0x013E, 0x013B, 
+    0x013B, 0x013B, 0x013B, 0x0138, 0x0138, 0x0138, 0x0135, 0x0135, 0x0132, 0x0132, 0x0132, 0x012F, 0x012F, 0x012C, 0x012C, 0x012C, 
+    0x0129, 0x0129, 0x0127, 0x0127, 0x0124, 0x0124, 0x0121, 0x0121, 0x011F, 0x011F, 0x011F, 0x011C, 0x011A, 0x011A, 0x0118, 0x0118, 
+    0x0115, 0x0115, 0x0113, 0x0113, 0x0111, 0x0111, 0x010E, 0x010C, 0x010C, 0x010A, 0x010A, 0x0108, 0x0106, 0x0106, 0x0104, 0x0104, 
+    0x0102, 0x0100, 0x0100, 0x00FE, 0x00FC, 0x00FC, 0x00FA, 0x00F8, 0x00F8, 0x00F6, 0x00F4, 0x00F4, 0x00F2, 0x00F0, 0x00F0, 0x00EF, 
+    0x00ED, 0x00ED, 0x00EB, 0x00EA, 0x00EA, 0x00E8, 0x00E6, 0x00E5, 0x00E5, 0x00E3, 0x00E1, 0x00E1, 0x00E0, 0x00DE, 0x00DD, 0x00DD, 
+    0x00DB, 0x00DA, 0x00D9, 0x00D9, 0x00D7, 0x00D6, 0x00D4, 0x00D4, 0x00D3, 0x00D2, 0x00D0, 0x00CF, 0x00CF, 0x00CE, 0x00CC, 0x00CB, 
+    0x0147, 0x0147, 0x0147, 0x0147, 0x0147, 0x0147, 0x0147, 0x0147, 0x0147, 0x0147, 0x0147, 0x0147, 0x0144, 0x0144, 0x0144, 0x0144, 
+    0x0144, 0x0144, 0x0144, 0x0141, 0x0141, 0x0141, 0x0141, 0x0141, 0x013E, 0x013E, 0x013E, 0x013E, 0x013B, 0x013B, 0x013B, 0x013B, 
+    0x0138, 0x0138, 0x0138, 0x0135, 0x0135, 0x0135, 0x0132, 0x0132, 0x0132, 0x012F, 0x012F, 0x012C, 0x012C, 0x012C, 0x0129, 0x0129, 
+    0x0127, 0x0127, 0x0124, 0x0124, 0x0124, 0x0121, 0x0121, 0x011F, 0x011F, 0x011C, 0x011C, 0x011A, 0x011A, 0x0118, 0x0118, 0x0115, 
+    0x0115, 0x0113, 0x0111, 0x0111, 0x010E, 0x010E, 0x010C, 0x010C, 0x010A, 0x0108, 0x0108, 0x0106, 0x0106, 0x0104, 0x0102, 0x0102, 
+    0x0100, 0x0100, 0x00FE, 0x00FC, 0x00FC, 0x00FA, 0x00F8, 0x00F8, 0x00F6, 0x00F4, 0x00F4, 0x00F2, 0x00F0, 0x00F0, 0x00EF, 0x00ED, 
+    0x00ED, 0x00EB, 0x00EA, 0x00EA, 0x00E8, 0x00E6, 0x00E5, 0x00E5, 0x00E3, 0x00E1, 0x00E1, 0x00E0, 0x00DE, 0x00DD, 0x00DD, 0x00DB, 
+    0x00DA, 0x00D9, 0x00D9, 0x00D7, 0x00D6, 0x00D4, 0x00D4, 0x00D3, 0x00D2, 0x00D0, 0x00D0, 0x00CF, 0x00CE, 0x00CC, 0x00CB, 0x00CB, 
+    0x0144, 0x0144, 0x0144, 0x0144, 0x0144, 0x0144, 0x0144, 0x0144, 0x0144, 0x0144, 0x0144, 0x0144, 0x0144, 0x0141, 0x0141, 0x0141, 
+    0x0141, 0x0141, 0x0141, 0x013E, 0x013E, 0x013E, 0x013E, 0x013E, 0x013B, 0x013B, 0x013B, 0x013B, 0x0138, 0x0138, 0x0138, 0x0138, 
+    0x0135, 0x0135, 0x0135, 0x0132, 0x0132, 0x0132, 0x012F, 0x012F, 0x012F, 0x012C, 0x012C, 0x0129, 0x0129, 0x0129, 0x0127, 0x0127, 
+    0x0124, 0x0124, 0x0124, 0x0121, 0x0121, 0x011F, 0x011F, 0x011C, 0x011C, 0x011A, 0x011A, 0x0118, 0x0118, 0x0115, 0x0115, 0x0113, 
+    0x0113, 0x0111, 0x0111, 0x010E, 0x010E, 0x010C, 0x010A, 0x010A, 0x0108, 0x0108, 0x0106, 0x0104, 0x0104, 0x0102, 0x0102, 0x0100, 
+    0x00FE, 0x00FE, 0x00FC, 0x00FC, 0x00FA, 0x00F8, 0x00F8, 0x00F6, 0x00F4, 0x00F4, 0x00F2, 0x00F0, 0x00F0, 0x00EF, 0x00ED, 0x00ED, 
+    0x00EB, 0x00EA, 0x00EA, 0x00E8, 0x00E6, 0x00E5, 0x00E5, 0x00E3, 0x00E1, 0x00E1, 0x00E0, 0x00DE, 0x00DD, 0x00DD, 0x00DB, 0x00DA, 
+    0x00DA, 0x00D9, 0x00D7, 0x00D6, 0x00D6, 0x00D4, 0x00D3, 0x00D2, 0x00D0, 0x00D0, 0x00CF, 0x00CE, 0x00CC, 0x00CC, 0x00CB, 0x00CA, 
+    0x0141, 0x0141, 0x0141, 0x0141, 0x0141, 0x0141, 0x0141, 0x0141, 0x0141, 0x0141, 0x0141, 0x0141, 0x0141, 0x013E, 0x013E, 0x013E, 
+    0x013E, 0x013E, 0x013E, 0x013B, 0x013B, 0x013B, 0x013B, 0x013B, 0x0138, 0x0138, 0x0138, 0x0138, 0x0135, 0x0135, 0x0135, 0x0135, 
+    0x0132, 0x0132, 0x0132, 0x012F, 0x012F, 0x012F, 0x012C, 0x012C, 0x012C, 0x0129, 0x0129, 0x0129, 0x0127, 0x0127, 0x0124, 0x0124, 
+    0x0124, 0x0121, 0x0121, 0x011F, 0x011F, 0x011C, 0x011C, 0x011A, 0x011A, 0x0118, 0x0118, 0x0115, 0x0115, 0x0113, 0x0113, 0x0111, 
+    0x0111, 0x010E, 0x010E, 0x010C, 0x010C, 0x010A, 0x010A, 0x0108, 0x0106, 0x0106, 0x0104, 0x0104, 0x0102, 0x0100, 0x0100, 0x00FE, 
+    0x00FE, 0x00FC, 0x00FA, 0x00FA, 0x00F8, 0x00F8, 0x00F6, 0x00F4, 0x00F4, 0x00F2, 0x00F0, 0x00F0, 0x00EF, 0x00ED, 0x00ED, 0x00EB, 
+    0x00EA, 0x00EA, 0x00E8, 0x00E6, 0x00E5, 0x00E5, 0x00E3, 0x00E1, 0x00E1, 0x00E0, 0x00DE, 0x00DD, 0x00DD, 0x00DB, 0x00DA, 0x00DA, 
+    0x00D9, 0x00D7, 0x00D6, 0x00D6, 0x00D4, 0x00D3, 0x00D2, 0x00D2, 0x00D0, 0x00CF, 0x00CE, 0x00CE, 0x00CC, 0x00CB, 0x00CA, 0x00C9, 
+    0x013E, 0x013E, 0x013E, 0x013E, 0x013E, 0x013E, 0x013E, 0x013E, 0x013E, 0x013E, 0x013E, 0x013E, 0x013E, 0x013B, 0x013B, 0x013B, 
+    0x013B, 0x013B, 0x013B, 0x013B, 0x0138, 0x0138, 0x0138, 0x0138, 0x0135, 0x0135, 0x0135, 0x0135, 0x0135, 0x0132, 0x0132, 0x0132, 
+    0x012F, 0x012F, 0x012F, 0x012C, 0x012C, 0x012C, 0x0129, 0x0129, 0x0129, 0x0127, 0x0127, 0x0127, 0x0124, 0x0124, 0x0121, 0x0121, 
+    0x0121, 0x011F, 0x011F, 0x011C, 0x011C, 0x011A, 0x011A, 0x011A, 0x0118, 0x0118, 0x0115, 0x0115, 0x0113, 0x0113, 0x0111, 0x0111, 
+    0x010E, 0x010C, 0x010C, 0x010A, 0x010A, 0x0108, 0x0108, 0x0106, 0x0106, 0x0104, 0x0102, 0x0102, 0x0100, 0x0100, 0x00FE, 0x00FC, 
+    0x00FC, 0x00FA, 0x00FA, 0x00F8, 0x00F6, 0x00F6, 0x00F4, 0x00F2, 0x00F2, 0x00F0, 0x00F0, 0x00EF, 0x00ED, 0x00ED, 0x00EB, 0x00EA, 
+    0x00EA, 0x00E8, 0x00E6, 0x00E5, 0x00E5, 0x00E3, 0x00E1, 0x00E1, 0x00E0, 0x00DE, 0x00DE, 0x00DD, 0x00DB, 0x00DA, 0x00DA, 0x00D9, 
+    0x00D7, 0x00D6, 0x00D6, 0x00D4, 0x00D3, 0x00D2, 0x00D2, 0x00D0, 0x00CF, 0x00CE, 0x00CE, 0x00CC, 0x00CB, 0x00CA, 0x00CA, 0x00C9, 
+    0x013B, 0x013B, 0x013B, 0x013B, 0x013B, 0x013B, 0x013B, 0x013B, 0x013B, 0x013B, 0x013B, 0x013B, 0x013B, 0x0138, 0x0138, 0x0138, 
+    0x0138, 0x0138, 0x0138, 0x0138, 0x0135, 0x0135, 0x0135, 0x0135, 0x0135, 0x0132, 0x0132, 0x0132, 0x0132, 0x012F, 0x012F, 0x012F, 
+    0x012C, 0x012C, 0x012C, 0x012C, 0x0129, 0x0129, 0x0129, 0x0127, 0x0127, 0x0124, 0x0124, 0x0124, 0x0121, 0x0121, 0x0121, 0x011F, 
+    0x011F, 0x011C, 0x011C, 0x011A, 0x011A, 0x011A, 0x0118, 0x0118, 0x0115, 0x0115, 0x0113, 0x0113, 0x0111, 0x0111, 0x010E, 0x010E, 
+    0x010C, 0x010C, 0x010A, 0x010A, 0x0108, 0x0106, 0x0106, 0x0104, 0x0104, 0x0102, 0x0102, 0x0100, 0x00FE, 0x00FE, 0x00FC, 0x00FC, 
+    0x00FA, 0x00F8, 0x00F8, 0x00F6, 0x00F6, 0x00F4, 0x00F2, 0x00F2, 0x00F0, 0x00EF, 0x00EF, 0x00ED, 0x00EB, 0x00EB, 0x00EA, 0x00E8, 
+    0x00E8, 0x00E6, 0x00E5, 0x00E5, 0x00E3, 0x00E1, 0x00E1, 0x00E0, 0x00DE, 0x00DE, 0x00DD, 0x00DB, 0x00DA, 0x00DA, 0x00D9, 0x00D7, 
+    0x00D6, 0x00D6, 0x00D4, 0x00D3, 0x00D3, 0x00D2, 0x00D0, 0x00CF, 0x00CF, 0x00CE, 0x00CC, 0x00CB, 0x00CB, 0x00CA, 0x00C9, 0x00C7, 
+    0x0138, 0x0138, 0x0138, 0x0138, 0x0138, 0x0138, 0x0138, 0x0138, 0x0138, 0x0138, 0x0138, 0x0138, 0x0138, 0x0135, 0x0135, 0x0135, 
+    0x0135, 0x0135, 0x0135, 0x0135, 0x0132, 0x0132, 0x0132, 0x0132, 0x0132, 0x012F, 0x012F, 0x012F, 0x012F, 0x012C, 0x012C, 0x012C, 
+    0x012C, 0x0129, 0x0129, 0x0129, 0x0127, 0x0127, 0x0127, 0x0124, 0x0124, 0x0124, 0x0121, 0x0121, 0x011F, 0x011F, 0x011F, 0x011C, 
+    0x011C, 0x011A, 0x011A, 0x011A, 0x0118, 0x0118, 0x0115, 0x0115, 0x0113, 0x0113, 0x0111, 0x0111, 0x010E, 0x010E, 0x010C, 0x010C, 
+    0x010A, 0x010A, 0x0108, 0x0108, 0x0106, 0x0106, 0x0104, 0x0104, 0x0102, 0x0100, 0x0100, 0x00FE, 0x00FE, 0x00FC, 0x00FC, 0x00FA, 
+    0x00F8, 0x00F8, 0x00F6, 0x00F4, 0x00F4, 0x00F2, 0x00F2, 0x00F0, 0x00EF, 0x00EF, 0x00ED, 0x00EB, 0x00EB, 0x00EA, 0x00E8, 0x00E8, 
+    0x00E6, 0x00E5, 0x00E5, 0x00E3, 0x00E1, 0x00E1, 0x00E0, 0x00DE, 0x00DE, 0x00DD, 0x00DB, 0x00DA, 0x00DA, 0x00D9, 0x00D7, 0x00D7, 
+    0x00D6, 0x00D4, 0x00D3, 0x00D3, 0x00D2, 0x00D0, 0x00CF, 0x00CF, 0x00CE, 0x00CC, 0x00CB, 0x00CB, 0x00CA, 0x00C9, 0x00C7, 0x00C7, 
+    0x0135, 0x0135, 0x0135, 0x0135, 0x0135, 0x0135, 0x0135, 0x0135, 0x0135, 0x0135, 0x0135, 0x0135, 0x0135, 0x0132, 0x0132, 0x0132, 
+    0x0132, 0x0132, 0x0132, 0x0132, 0x012F, 0x012F, 0x012F, 0x012F, 0x012F, 0x012C, 0x012C, 0x012C, 0x012C, 0x0129, 0x0129, 0x0129, 
+    0x0129, 0x0127, 0x0127, 0x0127, 0x0124, 0x0124, 0x0124, 0x0121, 0x0121, 0x0121, 0x011F, 0x011F, 0x011F, 0x011C, 0x011C, 0x011A, 
+    0x011A, 0x011A, 0x0118, 0x0118, 0x0115, 0x0115, 0x0113, 0x0113, 0x0111, 0x0111, 0x010E, 0x010E, 0x010E, 0x010C, 0x010C, 0x010A, 
+    0x0108, 0x0108, 0x0106, 0x0106, 0x0104, 0x0104, 0x0102, 0x0102, 0x0100, 0x0100, 0x00FE, 0x00FC, 0x00FC, 0x00FA, 0x00FA, 0x00F8, 
+    0x00F8, 0x00F6, 0x00F4, 0x00F4, 0x00F2, 0x00F0, 0x00F0, 0x00EF, 0x00EF, 0x00ED, 0x00EB, 0x00EB, 0x00EA, 0x00E8, 0x00E8, 0x00E6, 
+    0x00E5, 0x00E5, 0x00E3, 0x00E1, 0x00E1, 0x00E0, 0x00DE, 0x00DE, 0x00DD, 0x00DB, 0x00DA, 0x00DA, 0x00D9, 0x00D7, 0x00D7, 0x00D6, 
+    0x00D4, 0x00D3, 0x00D3, 0x00D2, 0x00D0, 0x00CF, 0x00CF, 0x00CE, 0x00CC, 0x00CB, 0x00CB, 0x00CA, 0x00C9, 0x00C7, 0x00C7, 0x00C6, 
+    0x0132, 0x0132, 0x0132, 0x0132, 0x0132, 0x0132, 0x0132, 0x0132, 0x0132, 0x0132, 0x0132, 0x0132, 0x0132, 0x0132, 0x012F, 0x012F, 
+    0x012F, 0x012F, 0x012F, 0x012F, 0x012C, 0x012C, 0x012C, 0x012C, 0x012C, 0x0129, 0x0129, 0x0129, 0x0129, 0x0127, 0x0127, 0x0127, 
+    0x0127, 0x0124, 0x0124, 0x0124, 0x0121, 0x0121, 0x0121, 0x011F, 0x011F, 0x011F, 0x011C, 0x011C, 0x011C, 0x011A, 0x011A, 0x0118, 
+    0x0118, 0x0118, 0x0115, 0x0115, 0x0113, 0x0113, 0x0111, 0x0111, 0x0111, 0x010E, 0x010E, 0x010C, 0x010C, 0x010A, 0x010A, 0x0108, 
+    0x0108, 0x0106, 0x0106, 0x0104, 0x0104, 0x0102, 0x0100, 0x0100, 0x00FE, 0x00FE, 0x00FC, 0x00FC, 0x00FA, 0x00FA, 0x00F8, 0x00F6, 
+    0x00F6, 0x00F4, 0x00F4, 0x00F2, 0x00F0, 0x00F0, 0x00EF, 0x00ED, 0x00ED, 0x00EB, 0x00EB, 0x00EA, 0x00E8, 0x00E8, 0x00E6, 0x00E5, 
+    0x00E5, 0x00E3, 0x00E1, 0x00E1, 0x00E0, 0x00DE, 0x00DE, 0x00DD, 0x00DB, 0x00DA, 0x00DA, 0x00D9, 0x00D7, 0x00D7, 0x00D6, 0x00D4, 
+    0x00D3, 0x00D3, 0x00D2, 0x00D0, 0x00D0, 0x00CF, 0x00CE, 0x00CC, 0x00CC, 0x00CB, 0x00CA, 0x00C9, 0x00C9, 0x00C7, 0x00C6, 0x00C5, 
+    0x012F, 0x012F, 0x012F, 0x012F, 0x012F, 0x012F, 0x012F, 0x012F, 0x012F, 0x012F, 0x012F, 0x012F, 0x012F, 0x012F, 0x012C, 0x012C, 
+    0x012C, 0x012C, 0x012C, 0x012C, 0x0129, 0x0129, 0x0129, 0x0129, 0x0129, 0x0127, 0x0127, 0x0127, 0x0127, 0x0124, 0x0124, 0x0124, 
+    0x0124, 0x0121, 0x0121, 0x0121, 0x011F, 0x011F, 0x011F, 0x011C, 0x011C, 0x011C, 0x011A, 0x011A, 0x011A, 0x0118, 0x0118, 0x0118, 
+    0x0115, 0x0115, 0x0113, 0x0113, 0x0111, 0x0111, 0x0111, 0x010E, 0x010E, 0x010C, 0x010C, 0x010A, 0x010A, 0x0108, 0x0108, 0x0106, 
+    0x0106, 0x0104, 0x0104, 0x0102, 0x0102, 0x0100, 0x0100, 0x00FE, 0x00FE, 0x00FC, 0x00FA, 0x00FA, 0x00F8, 0x00F8, 0x00F6, 0x00F6, 
+    0x00F4, 0x00F2, 0x00F2, 0x00F0, 0x00F0, 0x00EF, 0x00ED, 0x00ED, 0x00EB, 0x00EA, 0x00EA, 0x00E8, 0x00E6, 0x00E6, 0x00E5, 0x00E5, 
+    0x00E3, 0x00E1, 0x00E1, 0x00E0, 0x00DE, 0x00DD, 0x00DD, 0x00DB, 0x00DA, 0x00DA, 0x00D9, 0x00D7, 0x00D7, 0x00D6, 0x00D4, 0x00D3, 
+    0x00D3, 0x00D2, 0x00D0, 0x00D0, 0x00CF, 0x00CE, 0x00CC, 0x00CC, 0x00CB, 0x00CA, 0x00C9, 0x00C9, 0x00C7, 0x00C6, 0x00C5, 0x00C5, 
+    0x012C, 0x012C, 0x012C, 0x012C, 0x012C, 0x012C, 0x012C, 0x012C, 0x012C, 0x012C, 0x012C, 0x012C, 0x012C, 0x012C, 0x0129, 0x0129, 
+    0x0129, 0x0129, 0x0129, 0x0129, 0x0129, 0x0127, 0x0127, 0x0127, 0x0127, 0x0124, 0x0124, 0x0124, 0x0124, 0x0124, 0x0121, 0x0121, 
+    0x0121, 0x011F, 0x011F, 0x011F, 0x011F, 0x011C, 0x011C, 0x011C, 0x011A, 0x011A, 0x011A, 0x0118, 0x0118, 0x0115, 0x0115, 0x0115, 
+    0x0113, 0x0113, 0x0111, 0x0111, 0x0111, 0x010E, 0x010E, 0x010C, 0x010C, 0x010A, 0x010A, 0x0108, 0x0108, 0x0106, 0x0106, 0x0104, 
+    0x0104, 0x0102, 0x0102, 0x0100, 0x0100, 0x00FE, 0x00FE, 0x00FC, 0x00FC, 0x00FA, 0x00FA, 0x00F8, 0x00F6, 0x00F6, 0x00F4, 0x00F4, 
+    0x00F2, 0x00F2, 0x00F0, 0x00EF, 0x00EF, 0x00ED, 0x00ED, 0x00EB, 0x00EA, 0x00EA, 0x00E8, 0x00E6, 0x00E6, 0x00E5, 0x00E3, 0x00E3, 
+    0x00E1, 0x00E0, 0x00E0, 0x00DE, 0x00DD, 0x00DD, 0x00DB, 0x00DA, 0x00DA, 0x00D9, 0x00D7, 0x00D7, 0x00D6, 0x00D4, 0x00D4, 0x00D3, 
+    0x00D2, 0x00D0, 0x00D0, 0x00CF, 0x00CE, 0x00CC, 0x00CC, 0x00CB, 0x00CA, 0x00CA, 0x00C9, 0x00C7, 0x00C6, 0x00C6, 0x00C5, 0x00C4, 
+    0x0129, 0x0129, 0x0129, 0x0129, 0x0129, 0x0129, 0x0129, 0x0129, 0x0129, 0x0129, 0x0129, 0x0129, 0x0129, 0x0129, 0x0127, 0x0127, 
+    0x0127, 0x0127, 0x0127, 0x0127, 0x0127, 0x0124, 0x0124, 0x0124, 0x0124, 0x0124, 0x0121, 0x0121, 0x0121, 0x0121, 0x011F, 0x011F, 
+    0x011F, 0x011C, 0x011C, 0x011C, 0x011C, 0x011A, 0x011A, 0x011A, 0x0118, 0x0118, 0x0118, 0x0115, 0x0115, 0x0113, 0x0113, 0x0113, 
+    0x0111, 0x0111, 0x0111, 0x010E, 0x010E, 0x010C, 0x010C, 0x010A, 0x010A, 0x0108, 0x0108, 0x0108, 0x0106, 0x0106, 0x0104, 0x0104, 
+    0x0102, 0x0102, 0x0100, 0x0100, 0x00FE, 0x00FE, 0x00FC, 0x00FA, 0x00FA, 0x00F8, 0x00F8, 0x00F6, 0x00F6, 0x00F4, 0x00F4, 0x00F2, 
+    0x00F0, 0x00F0, 0x00EF, 0x00EF, 0x00ED, 0x00EB, 0x00EB, 0x00EA, 0x00E8, 0x00E8, 0x00E6, 0x00E6, 0x00E5, 0x00E3, 0x00E3, 0x00E1, 
+    0x00E0, 0x00E0, 0x00DE, 0x00DD, 0x00DD, 0x00DB, 0x00DA, 0x00DA, 0x00D9, 0x00D7, 0x00D7, 0x00D6, 0x00D4, 0x00D4, 0x00D3, 0x00D2, 
+    0x00D0, 0x00D0, 0x00CF, 0x00CE, 0x00CE, 0x00CC, 0x00CB, 0x00CA, 0x00CA, 0x00C9, 0x00C7, 0x00C6, 0x00C6, 0x00C5, 0x00C4, 0x00C3, 
+    0x0127, 0x0127, 0x0127, 0x0127, 0x0127, 0x0127, 0x0127, 0x0127, 0x0127, 0x0127, 0x0127, 0x0127, 0x0127, 0x0127, 0x0124, 0x0124, 
+    0x0124, 0x0124, 0x0124, 0x0124, 0x0124, 0x0121, 0x0121, 0x0121, 0x0121, 0x0121, 0x011F, 0x011F, 0x011F, 0x011F, 0x011C, 0x011C, 
+    0x011C, 0x011C, 0x011A, 0x011A, 0x011A, 0x0118, 0x0118, 0x0118, 0x0115, 0x0115, 0x0115, 0x0113, 0x0113, 0x0113, 0x0111, 0x0111, 
+    0x010E, 0x010E, 0x010E, 0x010C, 0x010C, 0x010A, 0x010A, 0x0108, 0x0108, 0x0108, 0x0106, 0x0106, 0x0104, 0x0104, 0x0102, 0x0102, 
+    0x0100, 0x0100, 0x00FE, 0x00FE, 0x00FC, 0x00FC, 0x00FA, 0x00FA, 0x00F8, 0x00F8, 0x00F6, 0x00F4, 0x00F4, 0x00F2, 0x00F2, 0x00F0, 
+    0x00F0, 0x00EF, 0x00ED, 0x00ED, 0x00EB, 0x00EB, 0x00EA, 0x00E8, 0x00E8, 0x00E6, 0x00E5, 0x00E5, 0x00E3, 0x00E3, 0x00E1, 0x00E0, 
+    0x00E0, 0x00DE, 0x00DD, 0x00DD, 0x00DB, 0x00DA, 0x00DA, 0x00D9, 0x00D7, 0x00D7, 0x00D6, 0x00D4, 0x00D4, 0x00D3, 0x00D2, 0x00D0, 
+    0x00D0, 0x00CF, 0x00CE, 0x00CE, 0x00CC, 0x00CB, 0x00CA, 0x00CA, 0x00C9, 0x00C7, 0x00C6, 0x00C6, 0x00C5, 0x00C4, 0x00C3, 0x00C3, 
+    0x0124, 0x0124, 0x0124, 0x0124, 0x0124, 0x0124, 0x0124, 0x0124, 0x0124, 0x0124, 0x0124, 0x0124, 0x0124, 0x0124, 0x0121, 0x0121, 
+    0x0121, 0x0121, 0x0121, 0x0121, 0x0121, 0x011F, 0x011F, 0x011F, 0x011F, 0x011F, 0x011C, 0x011C, 0x011C, 0x011C, 0x011A, 0x011A, 
+    0x011A, 0x011A, 0x0118, 0x0118, 0x0118, 0x0115, 0x0115, 0x0115, 0x0113, 0x0113, 0x0113, 0x0111, 0x0111, 0x0111, 0x010E, 0x010E, 
+    0x010E, 0x010C, 0x010C, 0x010A, 0x010A, 0x0108, 0x0108, 0x0108, 0x0106, 0x0106, 0x0104, 0x0104, 0x0102, 0x0102, 0x0100, 0x0100, 
+    0x00FE, 0x00FE, 0x00FC, 0x00FC, 0x00FA, 0x00FA, 0x00F8, 0x00F8, 0x00F6, 0x00F6, 0x00F4, 0x00F4, 0x00F2, 0x00F0, 0x00F0, 0x00EF, 
+    0x00EF, 0x00ED, 0x00ED, 0x00EB, 0x00EA, 0x00EA, 0x00E8, 0x00E8, 0x00E6, 0x00E5, 0x00E5, 0x00E3, 0x00E1, 0x00E1, 0x00E0, 0x00E0, 
+    0x00DE, 0x00DD, 0x00DD, 0x00DB, 0x00DA, 0x00DA, 0x00D9, 0x00D7, 0x00D7, 0x00D6, 0x00D4, 0x00D3, 0x00D3, 0x00D2, 0x00D0, 0x00D0, 
+    0x00CF, 0x00CE, 0x00CE, 0x00CC, 0x00CB, 0x00CA, 0x00CA, 0x00C9, 0x00C7, 0x00C7, 0x00C6, 0x00C5, 0x00C4, 0x00C4, 0x00C3, 0x00C1, 
+    0x0121, 0x0121, 0x0121, 0x0121, 0x0121, 0x0121, 0x0121, 0x0121, 0x0121, 0x0121, 0x0121, 0x0121, 0x0121, 0x0121, 0x011F, 0x011F, 
+    0x011F, 0x011F, 0x011F, 0x011F, 0x011F, 0x011C, 0x011C, 0x011C, 0x011C, 0x011C, 0x011A, 0x011A, 0x011A, 0x011A, 0x0118, 0x0118, 
+    0x0118, 0x0118, 0x0115, 0x0115, 0x0115, 0x0113, 0x0113, 0x0113, 0x0111, 0x0111, 0x0111, 0x010E, 0x010E, 0x010E, 0x010C, 0x010C, 
+    0x010C, 0x010A, 0x010A, 0x0108, 0x0108, 0x0108, 0x0106, 0x0106, 0x0104, 0x0104, 0x0102, 0x0102, 0x0100, 0x0100, 0x00FE, 0x00FE, 
+    0x00FE, 0x00FC, 0x00FC, 0x00FA, 0x00F8, 0x00F8, 0x00F6, 0x00F6, 0x00F4, 0x00F4, 0x00F2, 0x00F2, 0x00F0, 0x00F0, 0x00EF, 0x00EF, 
+    0x00ED, 0x00EB, 0x00EB, 0x00EA, 0x00EA, 0x00E8, 0x00E6, 0x00E6, 0x00E5, 0x00E5, 0x00E3, 0x00E1, 0x00E1, 0x00E0, 0x00DE, 0x00DE, 
+    0x00DD, 0x00DB, 0x00DB, 0x00DA, 0x00DA, 0x00D9, 0x00D7, 0x00D6, 0x00D6, 0x00D4, 0x00D3, 0x00D3, 0x00D2, 0x00D0, 0x00D0, 0x00CF, 
+    0x00CE, 0x00CE, 0x00CC, 0x00CB, 0x00CA, 0x00CA, 0x00C9, 0x00C7, 0x00C7, 0x00C6, 0x00C5, 0x00C4, 0x00C4, 0x00C3, 0x00C1, 0x00C0, 
+    0x011F, 0x011F, 0x011F, 0x011F, 0x011F, 0x011F, 0x011F, 0x011F, 0x011F, 0x011F, 0x011F, 0x011F, 0x011F, 0x011F, 0x011F, 0x011C, 
+    0x011C, 0x011C, 0x011C, 0x011C, 0x011C, 0x011A, 0x011A, 0x011A, 0x011A, 0x011A, 0x0118, 0x0118, 0x0118, 0x0118, 0x0115, 0x0115, 
+    0x0115, 0x0115, 0x0113, 0x0113, 0x0113, 0x0113, 0x0111, 0x0111, 0x0111, 0x010E, 0x010E, 0x010E, 0x010C, 0x010C, 0x010A, 0x010A, 
+    0x010A, 0x0108, 0x0108, 0x0106, 0x0106, 0x0106, 0x0104, 0x0104, 0x0102, 0x0102, 0x0100, 0x0100, 0x0100, 0x00FE, 0x00FE, 0x00FC, 
+    0x00FC, 0x00FA, 0x00FA, 0x00F8, 0x00F8, 0x00F6, 0x00F6, 0x00F4, 0x00F4, 0x00F2, 0x00F0, 0x00F0, 0x00EF, 0x00EF, 0x00ED, 0x00ED, 
+    0x00EB, 0x00EB, 0x00EA, 0x00E8, 0x00E8, 0x00E6, 0x00E6, 0x00E5, 0x00E3, 0x00E3, 0x00E1, 0x00E1, 0x00E0, 0x00DE, 0x00DE, 0x00DD, 
+    0x00DB, 0x00DB, 0x00DA, 0x00D9, 0x00D9, 0x00D7, 0x00D6, 0x00D6, 0x00D4, 0x00D3, 0x00D3, 0x00D2, 0x00D0, 0x00D0, 0x00CF, 0x00CE, 
+    0x00CE, 0x00CC, 0x00CB, 0x00CA, 0x00CA, 0x00C9, 0x00C7, 0x00C7, 0x00C6, 0x00C5, 0x00C4, 0x00C4, 0x00C3, 0x00C1, 0x00C0, 0x00C0, 
+    0x011C, 0x011C, 0x011C, 0x011C, 0x011C, 0x011C, 0x011C, 0x011C, 0x011C, 0x011C, 0x011C, 0x011C, 0x011C, 0x011C, 0x011C, 0x011A, 
+    0x011A, 0x011A, 0x011A, 0x011A, 0x011A, 0x0118, 0x0118, 0x0118, 0x0118, 0x0118, 0x0115, 0x0115, 0x0115, 0x0115, 0x0115, 0x0113, 
+    0x0113, 0x0113, 0x0111, 0x0111, 0x0111, 0x0111, 0x010E, 0x010E, 0x010E, 0x010C, 0x010C, 0x010C, 0x010A, 0x010A, 0x010A, 0x0108, 
+    0x0108, 0x0106, 0x0106, 0x0106, 0x0104, 0x0104, 0x0102, 0x0102, 0x0100, 0x0100, 0x0100, 0x00FE, 0x00FE, 0x00FC, 0x00FC, 0x00FA, 
+    0x00FA, 0x00F8, 0x00F8, 0x00F6, 0x00F6, 0x00F4, 0x00F4, 0x00F2, 0x00F2, 0x00F0, 0x00F0, 0x00EF, 0x00EF, 0x00ED, 0x00EB, 0x00EB, 
+    0x00EA, 0x00EA, 0x00E8, 0x00E8, 0x00E6, 0x00E5, 0x00E5, 0x00E3, 0x00E3, 0x00E1, 0x00E0, 0x00E0, 0x00DE, 0x00DE, 0x00DD, 0x00DB, 
+    0x00DB, 0x00DA, 0x00D9, 0x00D9, 0x00D7, 0x00D6, 0x00D6, 0x00D4, 0x00D3, 0x00D3, 0x00D2, 0x00D0, 0x00D0, 0x00CF, 0x00CE, 0x00CE, 
+    0x00CC, 0x00CB, 0x00CA, 0x00CA, 0x00C9, 0x00C7, 0x00C7, 0x00C6, 0x00C5, 0x00C4, 0x00C4, 0x00C3, 0x00C1, 0x00C1, 0x00C0, 0x00BF, 
+    0x011A, 0x011A, 0x011A, 0x011A, 0x011A, 0x011A, 0x011A, 0x011A, 0x011A, 0x011A, 0x011A, 0x011A, 0x011A, 0x011A, 0x011A, 0x0118, 
+    0x0118, 0x0118, 0x0118, 0x0118, 0x0118, 0x0118, 0x0115, 0x0115, 0x0115, 0x0115, 0x0115, 0x0113, 0x0113, 0x0113, 0x0113, 0x0111, 
+    0x0111, 0x0111, 0x0111, 0x010E, 0x010E, 0x010E, 0x010C, 0x010C, 0x010C, 0x010A, 0x010A, 0x010A, 0x0108, 0x0108, 0x0108, 0x0106, 
+    0x0106, 0x0104, 0x0104, 0x0104, 0x0102, 0x0102, 0x0100, 0x0100, 0x0100, 0x00FE, 0x00FE, 0x00FC, 0x00FC, 0x00FA, 0x00FA, 0x00F8, 
+    0x00F8, 0x00F6, 0x00F6, 0x00F4, 0x00F4, 0x00F2, 0x00F2, 0x00F0, 0x00F0, 0x00EF, 0x00EF, 0x00ED, 0x00ED, 0x00EB, 0x00EB, 0x00EA, 
+    0x00E8, 0x00E8, 0x00E6, 0x00E6, 0x00E5, 0x00E5, 0x00E3, 0x00E1, 0x00E1, 0x00E0, 0x00E0, 0x00DE, 0x00DD, 0x00DD, 0x00DB, 0x00DA, 
+    0x00DA, 0x00D9, 0x00D9, 0x00D7, 0x00D6, 0x00D6, 0x00D4, 0x00D3, 0x00D3, 0x00D2, 0x00D0, 0x00D0, 0x00CF, 0x00CE, 0x00CE, 0x00CC, 
+    0x00CB, 0x00CA, 0x00CA, 0x00C9, 0x00C7, 0x00C7, 0x00C6, 0x00C5, 0x00C5, 0x00C4, 0x00C3, 0x00C1, 0x00C1, 0x00C0, 0x00BF, 0x00BE, 
+    0x0118, 0x0118, 0x0118, 0x0118, 0x0118, 0x0118, 0x0118, 0x0118, 0x0118, 0x0118, 0x0118, 0x0118, 0x0118, 0x0118, 0x0118, 0x0115, 
+    0x0115, 0x0115, 0x0115, 0x0115, 0x0115, 0x0115, 0x0113, 0x0113, 0x0113, 0x0113, 0x0113, 0x0111, 0x0111, 0x0111, 0x0111, 0x010E, 
+    0x010E, 0x010E, 0x010E, 0x010C, 0x010C, 0x010C, 0x010A, 0x010A, 0x010A, 0x0108, 0x0108, 0x0108, 0x0106, 0x0106, 0x0106, 0x0104, 
+    0x0104, 0x0104, 0x0102, 0x0102, 0x0100, 0x0100, 0x0100, 0x00FE, 0x00FE, 0x00FC, 0x00FC, 0x00FA, 0x00FA, 0x00F8, 0x00F8, 0x00F8, 
+    0x00F6, 0x00F6, 0x00F4, 0x00F4, 0x00F2, 0x00F2, 0x00F0, 0x00F0, 0x00EF, 0x00EF, 0x00ED, 0x00EB, 0x00EB, 0x00EA, 0x00EA, 0x00E8, 
+    0x00E8, 0x00E6, 0x00E6, 0x00E5, 0x00E3, 0x00E3, 0x00E1, 0x00E1, 0x00E0, 0x00DE, 0x00DE, 0x00DD, 0x00DD, 0x00DB, 0x00DA, 0x00DA, 
+    0x00D9, 0x00D7, 0x00D7, 0x00D6, 0x00D6, 0x00D4, 0x00D3, 0x00D3, 0x00D2, 0x00D0, 0x00D0, 0x00CF, 0x00CE, 0x00CE, 0x00CC, 0x00CB, 
+    0x00CA, 0x00CA, 0x00C9, 0x00C7, 0x00C7, 0x00C6, 0x00C5, 0x00C5, 0x00C4, 0x00C3, 0x00C1, 0x00C1, 0x00C0, 0x00BF, 0x00BE, 0x00BE, 
+    0x0115, 0x0115, 0x0115, 0x0115, 0x0115, 0x0115, 0x0115, 0x0115, 0x0115, 0x0115, 0x0115, 0x0115, 0x0115, 0x0115, 0x0115, 0x0113, 
+    0x0113, 0x0113, 0x0113, 0x0113, 0x0113, 0x0113, 0x0111, 0x0111, 0x0111, 0x0111, 0x0111, 0x010E, 0x010E, 0x010E, 0x010E, 0x010C, 
+    0x010C, 0x010C, 0x010C, 0x010A, 0x010A, 0x010A, 0x0108, 0x0108, 0x0108, 0x0106, 0x0106, 0x0106, 0x0104, 0x0104, 0x0104, 0x0102, 
+    0x0102, 0x0102, 0x0100, 0x0100, 0x00FE, 0x00FE, 0x00FE, 0x00FC, 0x00FC, 0x00FA, 0x00FA, 0x00F8, 0x00F8, 0x00F8, 0x00F6, 0x00F6, 
+    0x00F4, 0x00F4, 0x00F2, 0x00F2, 0x00F0, 0x00F0, 0x00EF, 0x00EF, 0x00ED, 0x00ED, 0x00EB, 0x00EB, 0x00EA, 0x00EA, 0x00E8, 0x00E6, 
+    0x00E6, 0x00E5, 0x00E5, 0x00E3, 0x00E3, 0x00E1, 0x00E0, 0x00E0, 0x00DE, 0x00DE, 0x00DD, 0x00DB, 0x00DB, 0x00DA, 0x00DA, 0x00D9, 
+    0x00D7, 0x00D7, 0x00D6, 0x00D4, 0x00D4, 0x00D3, 0x00D2, 0x00D2, 0x00D0, 0x00CF, 0x00CF, 0x00CE, 0x00CC, 0x00CC, 0x00CB, 0x00CA, 
+    0x00CA, 0x00C9, 0x00C7, 0x00C7, 0x00C6, 0x00C5, 0x00C5, 0x00C4, 0x00C3, 0x00C1, 0x00C1, 0x00C0, 0x00BF, 0x00BF, 0x00BE, 0x00BD, 
+    0x0113, 0x0113, 0x0113, 0x0113, 0x0113, 0x0113, 0x0113, 0x0113, 0x0113, 0x0113, 0x0113, 0x0113, 0x0113, 0x0113, 0x0113, 0x0111, 
+    0x0111, 0x0111, 0x0111, 0x0111, 0x0111, 0x0111, 0x010E, 0x010E, 0x010E, 0x010E, 0x010E, 0x010C, 0x010C, 0x010C, 0x010C, 0x010A, 
+    0x010A, 0x010A, 0x010A, 0x0108, 0x0108, 0x0108, 0x0108, 0x0106, 0x0106, 0x0106, 0x0104, 0x0104, 0x0104, 0x0102, 0x0102, 0x0100, 
+    0x0100, 0x0100, 0x00FE, 0x00FE, 0x00FE, 0x00FC, 0x00FC, 0x00FA, 0x00FA, 0x00F8, 0x00F8, 0x00F8, 0x00F6, 0x00F6, 0x00F4, 0x00F4, 
+    0x00F2, 0x00F2, 0x00F0, 0x00F0, 0x00EF, 0x00EF, 0x00ED, 0x00ED, 0x00EB, 0x00EB, 0x00EA, 0x00EA, 0x00E8, 0x00E8, 0x00E6, 0x00E6, 
+    0x00E5, 0x00E3, 0x00E3, 0x00E1, 0x00E1, 0x00E0, 0x00E0, 0x00DE, 0x00DD, 0x00DD, 0x00DB, 0x00DB, 0x00DA, 0x00D9, 0x00D9, 0x00D7, 
+    0x00D7, 0x00D6, 0x00D4, 0x00D4, 0x00D3, 0x00D2, 0x00D2, 0x00D0, 0x00CF, 0x00CF, 0x00CE, 0x00CC, 0x00CC, 0x00CB, 0x00CA, 0x00CA, 
+    0x00C9, 0x00C7, 0x00C7, 0x00C6, 0x00C5, 0x00C5, 0x00C4, 0x00C3, 0x00C1, 0x00C1, 0x00C0, 0x00BF, 0x00BF, 0x00BE, 0x00BD, 0x00BC, 
+    0x0111, 0x0111, 0x0111, 0x0111, 0x0111, 0x0111, 0x0111, 0x0111, 0x0111, 0x0111, 0x0111, 0x0111, 0x0111, 0x0111, 0x0111, 0x010E, 
+    0x010E, 0x010E, 0x010E, 0x010E, 0x010E, 0x010E, 0x010C, 0x010C, 0x010C, 0x010C, 0x010C, 0x010A, 0x010A, 0x010A, 0x010A, 0x0108, 
+    0x0108, 0x0108, 0x0108, 0x0106, 0x0106, 0x0106, 0x0106, 0x0104, 0x0104, 0x0104, 0x0102, 0x0102, 0x0102, 0x0100, 0x0100, 0x0100, 
+    0x00FE, 0x00FE, 0x00FC, 0x00FC, 0x00FC, 0x00FA, 0x00FA, 0x00F8, 0x00F8, 0x00F8, 0x00F6, 0x00F6, 0x00F4, 0x00F4, 0x00F2, 0x00F2, 
+    0x00F0, 0x00F0, 0x00EF, 0x00EF, 0x00EF, 0x00ED, 0x00ED, 0x00EB, 0x00EA, 0x00EA, 0x00E8, 0x00E8, 0x00E6, 0x00E6, 0x00E5, 0x00E5, 
+    0x00E3, 0x00E3, 0x00E1, 0x00E1, 0x00E0, 0x00DE, 0x00DE, 0x00DD, 0x00DD, 0x00DB, 0x00DA, 0x00DA, 0x00D9, 0x00D9, 0x00D7, 0x00D6, 
+    0x00D6, 0x00D4, 0x00D4, 0x00D3, 0x00D2, 0x00D2, 0x00D0, 0x00CF, 0x00CF, 0x00CE, 0x00CC, 0x00CC, 0x00CB, 0x00CA, 0x00CA, 0x00C9, 
+    0x00C7, 0x00C7, 0x00C6, 0x00C5, 0x00C5, 0x00C4, 0x00C3, 0x00C1, 0x00C1, 0x00C0, 0x00BF, 0x00BF, 0x00BE, 0x00BD, 0x00BC, 0x00BC, 
+    0x010E, 0x010E, 0x010E, 0x010E, 0x010E, 0x010E, 0x010E, 0x010E, 0x010E, 0x010E, 0x010E, 0x010E, 0x010E, 0x010E, 0x010E, 0x010E, 
+    0x010C, 0x010C, 0x010C, 0x010C, 0x010C, 0x010C, 0x010A, 0x010A, 0x010A, 0x010A, 0x010A, 0x0108, 0x0108, 0x0108, 0x0108, 0x0108, 
+    0x0106, 0x0106, 0x0106, 0x0104, 0x0104, 0x0104, 0x0104, 0x0102, 0x0102, 0x0102, 0x0100, 0x0100, 0x0100, 0x00FE, 0x00FE, 0x00FE, 
+    0x00FC, 0x00FC, 0x00FC, 0x00FA, 0x00FA, 0x00F8, 0x00F8, 0x00F8, 0x00F6, 0x00F6, 0x00F4, 0x00F4, 0x00F2, 0x00F2, 0x00F0, 0x00F0, 
+    0x00F0, 0x00EF, 0x00EF, 0x00ED, 0x00ED, 0x00EB, 0x00EB, 0x00EA, 0x00EA, 0x00E8, 0x00E8, 0x00E6, 0x00E6, 0x00E5, 0x00E3, 0x00E3, 
+    0x00E1, 0x00E1, 0x00E0, 0x00E0, 0x00DE, 0x00DE, 0x00DD, 0x00DB, 0x00DB, 0x00DA, 0x00DA, 0x00D9, 0x00D7, 0x00D7, 0x00D6, 0x00D6, 
+    0x00D4, 0x00D3, 0x00D3, 0x00D2, 0x00D0, 0x00D0, 0x00CF, 0x00CF, 0x00CE, 0x00CC, 0x00CC, 0x00CB, 0x00CA, 0x00CA, 0x00C9, 0x00C7, 
+    0x00C7, 0x00C6, 0x00C5, 0x00C5, 0x00C4, 0x00C3, 0x00C1, 0x00C1, 0x00C0, 0x00BF, 0x00BF, 0x00BE, 0x00BD, 0x00BC, 0x00BC, 0x00BB, 
+    0x010C, 0x010C, 0x010C, 0x010C, 0x010C, 0x010C, 0x010C, 0x010C, 0x010C, 0x010C, 0x010C, 0x010C, 0x010C, 0x010C, 0x010C, 0x010C, 
+    0x010A, 0x010A, 0x010A, 0x010A, 0x010A, 0x010A, 0x0108, 0x0108, 0x0108, 0x0108, 0x0108, 0x0106, 0x0106, 0x0106, 0x0106, 0x0106, 
+    0x0104, 0x0104, 0x0104, 0x0104, 0x0102, 0x0102, 0x0102, 0x0100, 0x0100, 0x0100, 0x00FE, 0x00FE, 0x00FE, 0x00FC, 0x00FC, 0x00FC, 
+    0x00FA, 0x00FA, 0x00FA, 0x00F8, 0x00F8, 0x00F6, 0x00F6, 0x00F6, 0x00F4, 0x00F4, 0x00F2, 0x00F2, 0x00F0, 0x00F0, 0x00F0, 0x00EF, 
+    0x00EF, 0x00ED, 0x00ED, 0x00EB, 0x00EB, 0x00EA, 0x00EA, 0x00E8, 0x00E8, 0x00E6, 0x00E6, 0x00E5, 0x00E5, 0x00E3, 0x00E3, 0x00E1, 
+    0x00E1, 0x00E0, 0x00DE, 0x00DE, 0x00DD, 0x00DD, 0x00DB, 0x00DB, 0x00DA, 0x00D9, 0x00D9, 0x00D7, 0x00D7, 0x00D6, 0x00D4, 0x00D4, 
+    0x00D3, 0x00D3, 0x00D2, 0x00D0, 0x00D0, 0x00CF, 0x00CE, 0x00CE, 0x00CC, 0x00CB, 0x00CB, 0x00CA, 0x00CA, 0x00C9, 0x00C7, 0x00C7, 
+    0x00C6, 0x00C5, 0x00C4, 0x00C4, 0x00C3, 0x00C1, 0x00C1, 0x00C0, 0x00BF, 0x00BF, 0x00BE, 0x00BD, 0x00BD, 0x00BC, 0x00BB, 0x00BA, 
+    0x010A, 0x010A, 0x010A, 0x010A, 0x010A, 0x010A, 0x010A, 0x010A, 0x010A, 0x010A, 0x010A, 0x010A, 0x010A, 0x010A, 0x010A, 0x010A, 
+    0x0108, 0x0108, 0x0108, 0x0108, 0x0108, 0x0108, 0x0108, 0x0106, 0x0106, 0x0106, 0x0106, 0x0106, 0x0104, 0x0104, 0x0104, 0x0104, 
+    0x0102, 0x0102, 0x0102, 0x0102, 0x0100, 0x0100, 0x0100, 0x00FE, 0x00FE, 0x00FE, 0x00FC, 0x00FC, 0x00FC, 0x00FA, 0x00FA, 0x00FA, 
+    0x00F8, 0x00F8, 0x00F8, 0x00F6, 0x00F6, 0x00F6, 0x00F4, 0x00F4, 0x00F2, 0x00F2, 0x00F0, 0x00F0, 0x00F0, 0x00EF, 0x00EF, 0x00ED, 
+    0x00ED, 0x00EB, 0x00EB, 0x00EA, 0x00EA, 0x00E8, 0x00E8, 0x00E6, 0x00E6, 0x00E5, 0x00E5, 0x00E3, 0x00E3, 0x00E1, 0x00E1, 0x00E0, 
+    0x00E0, 0x00DE, 0x00DE, 0x00DD, 0x00DD, 0x00DB, 0x00DA, 0x00DA, 0x00D9, 0x00D9, 0x00D7, 0x00D6, 0x00D6, 0x00D4, 0x00D4, 0x00D3, 
+    0x00D2, 0x00D2, 0x00D0, 0x00D0, 0x00CF, 0x00CE, 0x00CE, 0x00CC, 0x00CB, 0x00CB, 0x00CA, 0x00C9, 0x00C9, 0x00C7, 0x00C6, 0x00C6, 
+    0x00C5, 0x00C4, 0x00C4, 0x00C3, 0x00C1, 0x00C1, 0x00C0, 0x00BF, 0x00BF, 0x00BE, 0x00BD, 0x00BD, 0x00BC, 0x00BB, 0x00BA, 0x00BA, 
+    0x0108, 0x0108, 0x0108, 0x0108, 0x0108, 0x0108, 0x0108, 0x0108, 0x0108, 0x0108, 0x0108, 0x0108, 0x0108, 0x0108, 0x0108, 0x0108, 
+    0x0106, 0x0106, 0x0106, 0x0106, 0x0106, 0x0106, 0x0106, 0x0104, 0x0104, 0x0104, 0x0104, 0x0104, 0x0102, 0x0102, 0x0102, 0x0102, 
+    0x0100, 0x0100, 0x0100, 0x0100, 0x00FE, 0x00FE, 0x00FE, 0x00FC, 0x00FC, 0x00FC, 0x00FC, 0x00FA, 0x00FA, 0x00FA, 0x00F8, 0x00F8, 
+    0x00F6, 0x00F6, 0x00F6, 0x00F4, 0x00F4, 0x00F4, 0x00F2, 0x00F2, 0x00F0, 0x00F0, 0x00F0, 0x00EF, 0x00EF, 0x00ED, 0x00ED, 0x00EB, 
+    0x00EB, 0x00EA, 0x00EA, 0x00EA, 0x00E8, 0x00E8, 0x00E6, 0x00E6, 0x00E5, 0x00E5, 0x00E3, 0x00E3, 0x00E1, 0x00E1, 0x00E0, 0x00DE, 
+    0x00DE, 0x00DD, 0x00DD, 0x00DB, 0x00DB, 0x00DA, 0x00DA, 0x00D9, 0x00D7, 0x00D7, 0x00D6, 0x00D6, 0x00D4, 0x00D3, 0x00D3, 0x00D2, 
+    0x00D2, 0x00D0, 0x00CF, 0x00CF, 0x00CE, 0x00CE, 0x00CC, 0x00CB, 0x00CB, 0x00CA, 0x00C9, 0x00C9, 0x00C7, 0x00C6, 0x00C6, 0x00C5, 
+    0x00C4, 0x00C4, 0x00C3, 0x00C1, 0x00C1, 0x00C0, 0x00BF, 0x00BF, 0x00BE, 0x00BD, 0x00BD, 0x00BC, 0x00BB, 0x00BA, 0x00BA, 0x00B9, 
+    0x0106, 0x0106, 0x0106, 0x0106, 0x0106, 0x0106, 0x0106, 0x0106, 0x0106, 0x0106, 0x0106, 0x0106, 0x0106, 0x0106, 0x0106, 0x0106, 
+    0x0104, 0x0104, 0x0104, 0x0104, 0x0104, 0x0104, 0x0104, 0x0102, 0x0102, 0x0102, 0x0102, 0x0102, 0x0100, 0x0100, 0x0100, 0x0100, 
+    0x00FE, 0x00FE, 0x00FE, 0x00FE, 0x00FC, 0x00FC, 0x00FC, 0x00FC, 0x00FA, 0x00FA, 0x00FA, 0x00F8, 0x00F8, 0x00F8, 0x00F6, 0x00F6, 
+    0x00F6, 0x00F4, 0x00F4, 0x00F2, 0x00F2, 0x00F2, 0x00F0, 0x00F0, 0x00F0, 0x00EF, 0x00EF, 0x00ED, 0x00ED, 0x00EB, 0x00EB, 0x00EA, 
+    0x00EA, 0x00EA, 0x00E8, 0x00E8, 0x00E6, 0x00E6, 0x00E5, 0x00E5, 0x00E3, 0x00E3, 0x00E1, 0x00E1, 0x00E0, 0x00E0, 0x00DE, 0x00DE, 
+    0x00DD, 0x00DD, 0x00DB, 0x00DA, 0x00DA, 0x00D9, 0x00D9, 0x00D7, 0x00D7, 0x00D6, 0x00D4, 0x00D4, 0x00D3, 0x00D3, 0x00D2, 0x00D0, 
+    0x00D0, 0x00CF, 0x00CF, 0x00CE, 0x00CC, 0x00CC, 0x00CB, 0x00CB, 0x00CA, 0x00C9, 0x00C9, 0x00C7, 0x00C6, 0x00C6, 0x00C5, 0x00C4, 
+    0x00C4, 0x00C3, 0x00C1, 0x00C1, 0x00C0, 0x00BF, 0x00BF, 0x00BE, 0x00BD, 0x00BD, 0x00BC, 0x00BB, 0x00BA, 0x00BA, 0x00B9, 0x00B8, 
+    0x0104, 0x0104, 0x0104, 0x0104, 0x0104, 0x0104, 0x0104, 0x0104, 0x0104, 0x0104, 0x0104, 0x0104, 0x0104, 0x0104, 0x0104, 0x0104, 
+    0x0102, 0x0102, 0x0102, 0x0102, 0x0102, 0x0102, 0x0102, 0x0100, 0x0100, 0x0100, 0x0100, 0x0100, 0x00FE, 0x00FE, 0x00FE, 0x00FE, 
+    0x00FC, 0x00FC, 0x00FC, 0x00FC, 0x00FA, 0x00FA, 0x00FA, 0x00FA, 0x00F8, 0x00F8, 0x00F8, 0x00F6, 0x00F6, 0x00F6, 0x00F4, 0x00F4, 
+    0x00F4, 0x00F2, 0x00F2, 0x00F2, 0x00F0, 0x00F0, 0x00EF, 0x00EF, 0x00EF, 0x00ED, 0x00ED, 0x00EB, 0x00EB, 0x00EA, 0x00EA, 0x00EA, 
+    0x00E8, 0x00E8, 0x00E6, 0x00E6, 0x00E5, 0x00E5, 0x00E3, 0x00E3, 0x00E1, 0x00E1, 0x00E0, 0x00E0, 0x00DE, 0x00DE, 0x00DD, 0x00DD, 
+    0x00DB, 0x00DB, 0x00DA, 0x00DA, 0x00D9, 0x00D7, 0x00D7, 0x00D6, 0x00D6, 0x00D4, 0x00D4, 0x00D3, 0x00D2, 0x00D2, 0x00D0, 0x00D0, 
+    0x00CF, 0x00CE, 0x00CE, 0x00CC, 0x00CC, 0x00CB, 0x00CA, 0x00CA, 0x00C9, 0x00C7, 0x00C7, 0x00C6, 0x00C6, 0x00C5, 0x00C4, 0x00C4, 
+    0x00C3, 0x00C1, 0x00C1, 0x00C0, 0x00BF, 0x00BF, 0x00BE, 0x00BD, 0x00BC, 0x00BC, 0x00BB, 0x00BA, 0x00BA, 0x00B9, 0x00B8, 0x00B8, 
+    0x0102, 0x0102, 0x0102, 0x0102, 0x0102, 0x0102, 0x0102, 0x0102, 0x0102, 0x0102, 0x0102, 0x0102, 0x0102, 0x0102, 0x0102, 0x0102, 
+    0x0100, 0x0100, 0x0100, 0x0100, 0x0100, 0x0100, 0x0100, 0x00FE, 0x00FE, 0x00FE, 0x00FE, 0x00FE, 0x00FC, 0x00FC, 0x00FC, 0x00FC, 
+    0x00FC, 0x00FA, 0x00FA, 0x00FA, 0x00F8, 0x00F8, 0x00F8, 0x00F8, 0x00F6, 0x00F6, 0x00F6, 0x00F4, 0x00F4, 0x00F4, 0x00F2, 0x00F2, 
+    0x00F2, 0x00F0, 0x00F0, 0x00F0, 0x00EF, 0x00EF, 0x00ED, 0x00ED, 0x00ED, 0x00EB, 0x00EB, 0x00EA, 0x00EA, 0x00EA, 0x00E8, 0x00E8, 
+    0x00E6, 0x00E6, 0x00E5, 0x00E5, 0x00E3, 0x00E3, 0x00E1, 0x00E1, 0x00E0, 0x00E0, 0x00E0, 0x00DE, 0x00DD, 0x00DD, 0x00DB, 0x00DB, 
+    0x00DA, 0x00DA, 0x00D9, 0x00D9, 0x00D7, 0x00D7, 0x00D6, 0x00D6, 0x00D4, 0x00D3, 0x00D3, 0x00D2, 0x00D2, 0x00D0, 0x00CF, 0x00CF, 
+    0x00CE, 0x00CE, 0x00CC, 0x00CB, 0x00CB, 0x00CA, 0x00CA, 0x00C9, 0x00C7, 0x00C7, 0x00C6, 0x00C5, 0x00C5, 0x00C4, 0x00C3, 0x00C3, 
+    0x00C1, 0x00C0, 0x00C0, 0x00BF, 0x00BE, 0x00BE, 0x00BD, 0x00BC, 0x00BC, 0x00BB, 0x00BA, 0x00BA, 0x00B9, 0x00B8, 0x00B8, 0x00B7, 
+    0x0100, 0x0100, 0x0100, 0x0100, 0x0100, 0x0100, 0x0100, 0x0100, 0x0100, 0x0100, 0x0100, 0x0100, 0x0100, 0x0100, 0x0100, 0x0100, 
+    0x00FE, 0x00FE, 0x00FE, 0x00FE, 0x00FE, 0x00FE, 0x00FE, 0x00FC, 0x00FC, 0x00FC, 0x00FC, 0x00FC, 0x00FA, 0x00FA, 0x00FA, 0x00FA, 
+    0x00FA, 0x00F8, 0x00F8, 0x00F8, 0x00F8, 0x00F6, 0x00F6, 0x00F6, 0x00F4, 0x00F4, 0x00F4, 0x00F2, 0x00F2, 0x00F2, 0x00F0, 0x00F0, 
+    0x00F0, 0x00EF, 0x00EF, 0x00EF, 0x00ED, 0x00ED, 0x00ED, 0x00EB, 0x00EB, 0x00EA, 0x00EA, 0x00EA, 0x00E8, 0x00E8, 0x00E6, 0x00E6, 
+    0x00E5, 0x00E5, 0x00E3, 0x00E3, 0x00E3, 0x00E1, 0x00E1, 0x00E0, 0x00E0, 0x00DE, 0x00DE, 0x00DD, 0x00DD, 0x00DB, 0x00DB, 0x00DA, 
+    0x00DA, 0x00D9, 0x00D7, 0x00D7, 0x00D6, 0x00D6, 0x00D4, 0x00D4, 0x00D3, 0x00D3, 0x00D2, 0x00D0, 0x00D0, 0x00CF, 0x00CF, 0x00CE, 
+    0x00CC, 0x00CC, 0x00CB, 0x00CB, 0x00CA, 0x00C9, 0x00C9, 0x00C7, 0x00C7, 0x00C6, 0x00C5, 0x00C5, 0x00C4, 0x00C3, 0x00C3, 0x00C1, 
+    0x00C0, 0x00C0, 0x00BF, 0x00BE, 0x00BE, 0x00BD, 0x00BC, 0x00BC, 0x00BB, 0x00BA, 0x00BA, 0x00B9, 0x00B8, 0x00B8, 0x00B7, 0x00B6
 };
-#define kDeltaUsedToBuildTable 32
+#define kDeltaUsedToBuildTable  32
index ed4dacc..8818380 100644 (file)
@@ -1,17 +1,34 @@
+/* libs/graphics/effects/SkGradientShader.cpp
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #include "SkGradientShader.h"
 #include "SkColorPriv.h"
 #include "SkUnitMapper.h"
 #include "SkUtils.h"
 
 /*
-       ToDo
+    ToDo
 
-       - not sure we still need the full Rec struct, now that we're using a cache
-       - detect const-alpha (but not opaque) in getFlags()
+    - not sure we still need the full Rec struct, now that we're using a cache
+    - detect const-alpha (but not opaque) in getFlags()
 */
 
 /* dither seems to look better, but not stuningly yet, and it slows us down a little
-       so its not on by default yet.
+    so its not on by default yet.
 */
 #define TEST_GRADIENT_DITHER
 
@@ -21,59 +38,59 @@ typedef SkFixed (*TileProc)(SkFixed);
 
 static SkFixed clamp_tileproc(SkFixed x)
 {
-       return SkClampMax(x, 0xFFFF);
+    return SkClampMax(x, 0xFFFF);
 }
 
 static SkFixed repeat_tileproc(SkFixed x)
 {
-       return x & 0xFFFF;
+    return x & 0xFFFF;
 }
 
 static inline SkFixed mirror_tileproc(SkFixed x)
 {
-       int s = x << 15 >> 31;
-       return (x ^ s) & 0xFFFF;
+    int s = x << 15 >> 31;
+    return (x ^ s) & 0xFFFF;
 }
 
 static const TileProc gTileProcs[] = {
-       clamp_tileproc,
-       repeat_tileproc,
-       mirror_tileproc
+    clamp_tileproc,
+    repeat_tileproc,
+    mirror_tileproc
 };
 
 //////////////////////////////////////////////////////////////////////////////
 
 static inline int repeat_6bits(int x)
 {
-       return x & 63;
+    return x & 63;
 }
 
 static inline int mirror_6bits(int x)
 {
 #ifdef SK_CPU_HAS_CONDITIONAL_INSTR
-       if (x & 64)
-               x = ~x;
-       return x & 63;
+    if (x & 64)
+        x = ~x;
+    return x & 63;
 #else
-       int s = x << 25 >> 31;
-       return (x ^ s) & 63;
+    int s = x << 25 >> 31;
+    return (x ^ s) & 63;
 #endif
 }
 
 static inline int repeat_8bits(int x)
 {
-       return x & 0xFF;
+    return x & 0xFF;
 }
 
 static inline int mirror_8bits(int x)
 {
 #ifdef SK_CPU_HAS_CONDITIONAL_INSTR
-       if (x & 256)
-               x = ~x;
-       return x & 255;
+    if (x & 256)
+        x = ~x;
+    return x & 255;
 #else
-       int s = x << 23 >> 31;
-       return (x ^ s) & 0xFF;
+    int s = x << 23 >> 31;
+    return (x ^ s) & 0xFF;
 #endif
 }
 
@@ -81,506 +98,515 @@ static inline int mirror_8bits(int x)
 
 class Gradient_Shader : public SkShader {
 public:
-       Gradient_Shader(const SkColor colors[], const SkScalar pos[],
-                                       int colorCount, SkShader::TileMode mode, SkUnitMapper* mapper);
-       virtual ~Gradient_Shader();
+    Gradient_Shader(const SkColor colors[], const SkScalar pos[],
+                    int colorCount, SkShader::TileMode mode, SkUnitMapper* mapper);
+    virtual ~Gradient_Shader();
 
-       // overrides
-       virtual bool setContext(const SkBitmap&, const SkPaint&, const SkMatrix&);
-       virtual U32  getFlags() { return fFlags; }
+    // overrides
+    virtual bool setContext(const SkBitmap&, const SkPaint&, const SkMatrix&);
+    virtual uint32_t getFlags() { return fFlags; }
 
 protected:
-       SkUnitMapper* fMapper;
-       SkMatrix        fPtsToUnit;             // set by subclass
-       SkMatrix        fDstToIndex;
-       SkMatrix::MapPtProc     fDstToIndexProc;
-       SkPMColor*      fARGB32;
-       TileProc        fTileProc;
-       uint16_t        fColorCount;
-       uint8_t         fDstToIndexClass;
-       uint8_t         fFlags;
-
-       struct Rec {
-               SkFixed     fPos;       // 0...1
-               uint32_t        fScale; // (1 << 24) / range
-       };
-       Rec*            fRecs;
-
-       enum {
-               kCache16Bits    = 6,    // seems like enough for visual accuracy
-               kCache16Count   = 1 << kCache16Bits,
-               kCache32Bits    = 8,    // pretty much should always be 8
-               kCache32Count   = 1 << kCache32Bits
-       };
-       const uint16_t*         getCache16();
-       const SkPMColor*        getCache32();
+    SkUnitMapper* fMapper;
+    SkMatrix    fPtsToUnit;     // set by subclass
+    SkMatrix    fDstToIndex;
+    SkMatrix::MapPtProc fDstToIndexProc;
+    SkPMColor*  fARGB32;
+    TileProc    fTileProc;
+    uint16_t    fColorCount;
+    uint8_t     fDstToIndexClass;
+    uint8_t     fFlags;
+
+    struct Rec {
+        SkFixed     fPos;   // 0...1
+        uint32_t    fScale; // (1 << 24) / range
+    };
+    Rec*        fRecs;
+
+    enum {
+        kCache16Bits    = 6,    // seems like enough for visual accuracy
+        kCache16Count   = 1 << kCache16Bits,
+        kCache32Bits    = 8,    // pretty much should always be 8
+        kCache32Count   = 1 << kCache32Bits
+    };
+    const uint16_t*     getCache16();
+    const SkPMColor*    getCache32();
 
 private:
-       enum {
-               kColorStorageCount = 4, // more than this many colors, and we'll use sk_malloc for the space
+    enum {
+        kColorStorageCount = 4, // more than this many colors, and we'll use sk_malloc for the space
 
-               kStorageSize = kColorStorageCount * (sizeof(SkColor) + sizeof(SkPMColor) + sizeof(Rec))
-       };
-       SkColor         fStorage[(kStorageSize + 3) >> 2];
-       SkColor*        fOrigColors;
+        kStorageSize = kColorStorageCount * (sizeof(SkColor) + sizeof(SkPMColor) + sizeof(Rec))
+    };
+    SkColor     fStorage[(kStorageSize + 3) >> 2];
+    SkColor*    fOrigColors;
 
-       uint16_t*       fCache16;       // working ptr. If this is nil, we need to recompute the cache values
-       SkPMColor*      fCache32;       // working ptr. If this is nil, we need to recompute the cache values
+    uint16_t*   fCache16;   // working ptr. If this is NULL, we need to recompute the cache values
+    SkPMColor*  fCache32;   // working ptr. If this is NULL, we need to recompute the cache values
 
-       uint16_t*       fCache16Storage;        // storage for fCache16, allocated on demand
-       SkPMColor*      fCache32Storage;        // storage for fCache32, allocated on demand
-       unsigned        fCacheAlpha;            // the alpha value we used when we computed the cache. larger than 8bits so we can store uninitialized value
+    uint16_t*   fCache16Storage;    // storage for fCache16, allocated on demand
+    SkPMColor*  fCache32Storage;    // storage for fCache32, allocated on demand
+    unsigned    fCacheAlpha;        // the alpha value we used when we computed the cache. larger than 8bits so we can store uninitialized value
 
-       typedef SkShader INHERITED;
+    typedef SkShader INHERITED;
 };
 
 static inline unsigned scalarToU16(SkScalar x)
 {
-       SkASSERT(x >= 0 && x <= SK_Scalar1);
+    SkASSERT(x >= 0 && x <= SK_Scalar1);
 
 #ifdef SK_SCALAR_IS_FLOAT
-       return (unsigned)(x * 0xFFFF);
+    return (unsigned)(x * 0xFFFF);
 #else
-       return x - (x >> 16);   // probably should be x - (x > 0x7FFF) but that is slower
+    return x - (x >> 16);   // probably should be x - (x > 0x7FFF) but that is slower
 #endif
 }
 
 Gradient_Shader::Gradient_Shader(const SkColor colors[], const SkScalar pos[], int colorCount,
-                                                                SkShader::TileMode mode, SkUnitMapper* mapper)
+                                 SkShader::TileMode mode, SkUnitMapper* mapper)
 {
-       SkASSERT(colorCount > 1);
+    SkASSERT(colorCount > 1);
 
     fCacheAlpha = 256;  // init to a value that paint.getAlpha() can't return
 
-       fMapper = mapper;
-       mapper->safeRef();
-
-       fCache16 = fCache16Storage = nil;
-       fCache32 = fCache32Storage = nil;
-
-       fColorCount = SkToU16(colorCount);
-       if (colorCount > kColorStorageCount)
-               fOrigColors = (SkColor*)sk_malloc_throw((sizeof(SkColor) + sizeof(SkPMColor) + sizeof(Rec)) * colorCount);
-       else
-               fOrigColors = fStorage;
-       memcpy(fOrigColors, colors, colorCount * sizeof(SkColor));
-       // our premul colors point to the 2nd half of the array
-       // these are assigned each time in setContext
-       fARGB32 = fOrigColors + colorCount;
-
-       SkASSERT((unsigned)mode < SkShader::kTileModeCount);
-       SkASSERT(SkShader::kTileModeCount == SK_ARRAY_COUNT(gTileProcs));
-       fTileProc = gTileProcs[mode];
-
-       fRecs = (Rec*)(fARGB32 + colorCount);
-       if (colorCount > 2)
-       {
-               Rec* recs = fRecs;
-
-               recs[0].fPos = 0;
-       //      recs[0].fScale = 0;     // unused;
-               if (pos)
-               {
-                       for (int i = 1; i < colorCount; i++)
-                       {
-                               SkASSERT(pos[i] > pos[i-1] && pos[i] <= SK_Scalar1);
-                               recs[i].fPos    = SkScalarToFixed(pos[i]);
-                               recs[i].fScale  = (1 << 24) / SkScalarToFixed(pos[i] - pos[i-1]);
-                       }
-               }
-               else    // assume even distribution
-               {
-                       SkFixed dp = SK_Fixed1 / (colorCount - 1);
-                       SkFixed p = dp;
-                       SkFixed scale = (colorCount - 1) << 8;  // (1 << 24) / dp
-                       for (int i = 1; i < colorCount; i++)
-                       {
-                               recs[i].fPos    = p;
-                               recs[i].fScale  = scale;
-                               p += dp;
-                       }
-               }
-       }
+    fMapper = mapper;
+    mapper->safeRef();
+
+    fCache16 = fCache16Storage = NULL;
+    fCache32 = fCache32Storage = NULL;
+
+    fColorCount = SkToU16(colorCount);
+    if (colorCount > kColorStorageCount)
+        fOrigColors = (SkColor*)sk_malloc_throw((sizeof(SkColor) + sizeof(SkPMColor) + sizeof(Rec)) * colorCount);
+    else
+        fOrigColors = fStorage;
+    memcpy(fOrigColors, colors, colorCount * sizeof(SkColor));
+    // our premul colors point to the 2nd half of the array
+    // these are assigned each time in setContext
+    fARGB32 = fOrigColors + colorCount;
+
+    SkASSERT((unsigned)mode < SkShader::kTileModeCount);
+    SkASSERT(SkShader::kTileModeCount == SK_ARRAY_COUNT(gTileProcs));
+    fTileProc = gTileProcs[mode];
+
+    fRecs = (Rec*)(fARGB32 + colorCount);
+    if (colorCount > 2)
+    {
+        Rec* recs = fRecs;
+
+        recs[0].fPos = 0;
+    //  recs[0].fScale = 0; // unused;
+        if (pos)
+        {
+            for (int i = 1; i < colorCount; i++)
+            {
+                SkASSERT(pos[i] > pos[i-1] && pos[i] <= SK_Scalar1);
+                recs[i].fPos    = SkScalarToFixed(pos[i]);
+                recs[i].fScale  = (1 << 24) / SkScalarToFixed(pos[i] - pos[i-1]);
+            }
+        }
+        else    // assume even distribution
+        {
+            SkFixed dp = SK_Fixed1 / (colorCount - 1);
+            SkFixed p = dp;
+            SkFixed scale = (colorCount - 1) << 8;  // (1 << 24) / dp
+            for (int i = 1; i < colorCount; i++)
+            {
+                recs[i].fPos    = p;
+                recs[i].fScale  = scale;
+                p += dp;
+            }
+        }
+    }
 }
 
 Gradient_Shader::~Gradient_Shader()
 {
-       if (fCache16Storage)
-               sk_free(fCache16Storage);
-       if (fCache32Storage)
-               sk_free(fCache32Storage);
-       if (fOrigColors != fStorage)
-               sk_free(fOrigColors);
-       fMapper->safeUnref();
+    if (fCache16Storage)
+        sk_free(fCache16Storage);
+    if (fCache32Storage)
+        sk_free(fCache32Storage);
+    if (fOrigColors != fStorage)
+        sk_free(fOrigColors);
+    fMapper->safeUnref();
 }
 
 bool Gradient_Shader::setContext(const SkBitmap& device,
-                                                                const SkPaint& paint,
-                                                                const SkMatrix& matrix)
+                                 const SkPaint& paint,
+                                 const SkMatrix& matrix)
 {
-       if (!this->INHERITED::setContext(device, paint, matrix))
-               return false;
-
-       const SkMatrix& inverse = this->getTotalInverse();
-
-       if (!fDstToIndex.setConcat(fPtsToUnit, inverse))
-               return false;
-
-       fDstToIndexProc = fDstToIndex.getMapPtProc();
-       fDstToIndexClass = (U8)SkShader::ComputeMatrixClass(fDstToIndex);
-
-       // now convert our colors in to PMColors
-       int pa = paint.getAlpha();
-       int     scale = SkAlpha255To256(pa);
-       int prevAlpha = -1;
-
-       for (unsigned i = 0; i < fColorCount; i++)
-       {
-               U32     src = fOrigColors[i];
-               int sa = SkAlphaMul(SkColorGetA(src), scale);
-               int localScale = SkAlpha255To256(sa);
-               pa &= sa;
-
-               if (i == 0)
-                       prevAlpha = sa;
-               else
-               {
-                       if (prevAlpha != sa)
-                               prevAlpha = -1;
-               }
-
-               fARGB32[i] = SkPackARGB32(      sa,
-                                                                       SkAlphaMul(SkColorGetR(src), localScale),
-                                                                       SkAlphaMul(SkColorGetG(src), localScale),
-                                                                       SkAlphaMul(SkColorGetB(src), localScale));
-       }
-
-       if (pa == 0xFF)
-       {
-               SkASSERT(prevAlpha >= 0);
-               fFlags = kOpaqueAlpha_Flag;
-       }
-       else if (prevAlpha >= 0)
-               fFlags = kConstAlpha_Flag;
-       else
-               fFlags = 0;
-
-       // if the new alpha differs from the previous time we were called, inval our cache
-       // this will trigger the cache to be rebuilt.
-       // we don't care about the first time, since the cache ptrs will already be nil
-       if (fCacheAlpha != paint.getAlpha())
-       {
-               fCache16 = nil;                                 // inval the cache
-               fCache32 = nil;                                 // inval the cache
-               fCacheAlpha = paint.getAlpha(); // record the new alpha
-       }
-       return true;
+    if (!this->INHERITED::setContext(device, paint, matrix))
+        return false;
+
+    const SkMatrix& inverse = this->getTotalInverse();
+
+    if (!fDstToIndex.setConcat(fPtsToUnit, inverse))
+        return false;
+
+    fDstToIndexProc = fDstToIndex.getMapPtProc();
+    fDstToIndexClass = (uint8_t)SkShader::ComputeMatrixClass(fDstToIndex);
+
+    // now convert our colors in to PMColors
+    int pa = this->getPaintAlpha();
+    int scale = SkAlpha255To256(pa);
+    int origColorAlpha = 0xFF;
+    int prevAlpha = -1;
+
+    for (unsigned i = 0; i < fColorCount; i++)
+    {
+        SkColor src = fOrigColors[i];
+        int sa = SkColorGetA(src);
+        origColorAlpha &= sa;
+
+        sa = SkAlphaMul(sa, scale);
+        pa &= sa;
+
+        int localScale = SkAlpha255To256(sa);
+
+        if (i == 0)
+            prevAlpha = sa;
+        else
+        {
+            if (prevAlpha != sa)
+                prevAlpha = -1;
+        }
+
+        fARGB32[i] = SkPackARGB32(  sa,
+                                    SkAlphaMul(SkColorGetR(src), localScale),
+                                    SkAlphaMul(SkColorGetG(src), localScale),
+                                    SkAlphaMul(SkColorGetB(src), localScale));
+    }
+
+    fFlags = this->INHERITED::getFlags();
+    if (pa == 0xFF)
+    {
+        SkASSERT(prevAlpha >= 0);
+        fFlags |= kOpaqueAlpha_Flag;
+    }
+    // we can do span16 as long as our individual colors are opaque, regardless of the paint's alpha
+    if (origColorAlpha == 0xFF)
+        fFlags |= kHasSpan16_Flag;
+
+    // if the new alpha differs from the previous time we were called, inval our cache
+    // this will trigger the cache to be rebuilt.
+    // we don't care about the first time, since the cache ptrs will already be NULL
+    if (fCacheAlpha != paint.getAlpha())
+    {
+        fCache16 = NULL;                 // inval the cache
+        fCache32 = NULL;                 // inval the cache
+        fCacheAlpha = paint.getAlpha(); // record the new alpha
+    }
+    return true;
 }
 
 static inline int blend8(int a, int b, int scale)
 {
-       SkASSERT(a == SkToU8(a));
-       SkASSERT(b == SkToU8(b));
-       SkASSERT(scale >= 0 && scale <= 256);
+    SkASSERT(a == SkToU8(a));
+    SkASSERT(b == SkToU8(b));
+    SkASSERT(scale >= 0 && scale <= 256);
 
-       return a + ((b - a) * scale >> 8);
+    return a + ((b - a) * scale >> 8);
 }
 
-static inline U32 dot8_blend_packed32(U32 s0, U32 s1, int blend)
+static inline uint32_t dot8_blend_packed32(uint32_t s0, uint32_t s1, int blend)
 {
 #if 0
-       int     a = blend8(SkGetPackedA32(s0), SkGetPackedA32(s1), blend);
-       int     r = blend8(SkGetPackedR32(s0), SkGetPackedR32(s1), blend);
-       int     g = blend8(SkGetPackedG32(s0), SkGetPackedG32(s1), blend);
-       int     b = blend8(SkGetPackedB32(s0), SkGetPackedB32(s1), blend);
+    int a = blend8(SkGetPackedA32(s0), SkGetPackedA32(s1), blend);
+    int r = blend8(SkGetPackedR32(s0), SkGetPackedR32(s1), blend);
+    int g = blend8(SkGetPackedG32(s0), SkGetPackedG32(s1), blend);
+    int b = blend8(SkGetPackedB32(s0), SkGetPackedB32(s1), blend);
 
-       return SkPackARGB32(a, r, g, b);
+    return SkPackARGB32(a, r, g, b);
 #else
-       int otherBlend = 256 - blend;
+    int otherBlend = 256 - blend;
 
 #if 0
-       U32     t0 = (((s0 & 0xFF00FF) * blend + (s1 & 0xFF00FF) * otherBlend) >> 8) & 0xFF00FF;
-       U32     t1 = (((s0 >> 8) & 0xFF00FF) * blend + ((s1 >> 8) & 0xFF00FF) * otherBlend) & 0xFF00FF00;
-       SkASSERT((t0 & t1) == 0);
-       return t0 | t1;
+    U32 t0 = (((s0 & 0xFF00FF) * blend + (s1 & 0xFF00FF) * otherBlend) >> 8) & 0xFF00FF;
+    U32 t1 = (((s0 >> 8) & 0xFF00FF) * blend + ((s1 >> 8) & 0xFF00FF) * otherBlend) & 0xFF00FF00;
+    SkASSERT((t0 & t1) == 0);
+    return t0 | t1;
 #else
-       return  ((((s0 & 0xFF00FF) * blend + (s1 & 0xFF00FF) * otherBlend) >> 8) & 0xFF00FF) |
-                       ((((s0 >> 8) & 0xFF00FF) * blend + ((s1 >> 8) & 0xFF00FF) * otherBlend) & 0xFF00FF00);
+    return  ((((s0 & 0xFF00FF) * blend + (s1 & 0xFF00FF) * otherBlend) >> 8) & 0xFF00FF) |
+            ((((s0 >> 8) & 0xFF00FF) * blend + ((s1 >> 8) & 0xFF00FF) * otherBlend) & 0xFF00FF00);
 #endif
 
 #endif
 }
 
-#define Fixed_To_Dot8(x)               (((x) + 0x80) >> 8)
+#define Fixed_To_Dot8(x)        (((x) + 0x80) >> 8)
 
-static void build_16bit_cache(U16 cache[], SkPMColor c0, SkPMColor c1, int count)
+/** We take the original colors, not our premultiplied PMColors, since we can build a 16bit table
+    as long as the original colors are opaque, even if the paint specifies a non-opaque alpha.
+*/
+static void build_16bit_cache(uint16_t cache[], SkColor c0, SkColor c1, int count)
 {
-       SkASSERT(count > 1);
+    SkASSERT(count > 1);
+    SkASSERT(SkColorGetA(c0) == 0xFF);
+    SkASSERT(SkColorGetA(c1) == 0xFF);
 
-       SkFixed r = SkGetPackedR32(c0);
-       SkFixed g = SkGetPackedG32(c0);
-       SkFixed b = SkGetPackedB32(c0);
+    SkFixed r = SkColorGetR(c0);
+    SkFixed g = SkColorGetG(c0);
+    SkFixed b = SkColorGetB(c0);
 
-       SkFixed dr = SkIntToFixed(SkGetPackedR32(c1) - r) / (count - 1);
-       SkFixed dg = SkIntToFixed(SkGetPackedG32(c1) - g) / (count - 1);
-       SkFixed db = SkIntToFixed(SkGetPackedB32(c1) - b) / (count - 1);
+    SkFixed dr = SkIntToFixed(SkColorGetR(c1) - r) / (count - 1);
+    SkFixed dg = SkIntToFixed(SkColorGetG(c1) - g) / (count - 1);
+    SkFixed db = SkIntToFixed(SkColorGetB(c1) - b) / (count - 1);
 
-       r = SkIntToFixed(r) + 0x8000;
-       g = SkIntToFixed(g) + 0x8000;
-       b = SkIntToFixed(b) + 0x8000;
+    r = SkIntToFixed(r) + 0x8000;
+    g = SkIntToFixed(g) + 0x8000;
+    b = SkIntToFixed(b) + 0x8000;
 
-       do {
+    do {
         unsigned rr = r >> 16;
         unsigned gg = g >> 16;
         unsigned bb = b >> 16;
-               cache[0] = SkPackRGB16(SkR32ToR16(rr), SkG32ToG16(gg), SkB32ToB16(bb));
+        cache[0] = SkPackRGB16(SkR32ToR16(rr), SkG32ToG16(gg), SkB32ToB16(bb));
         cache[64] = SkDitherPack888ToRGB16(rr, gg, bb);
-               cache += 1;
-               r += dr;
-               g += dg;
-               b += db;
-       } while (--count != 0);
+        cache += 1;
+        r += dr;
+        g += dg;
+        b += db;
+    } while (--count != 0);
 }
 
 static void build_32bit_cache(SkPMColor cache[], SkPMColor c0, SkPMColor c1, int count)
 {
-       SkASSERT(count > 1);
-
-       SkFixed a = SkGetPackedA32(c0);
-       SkFixed r = SkGetPackedR32(c0);
-       SkFixed g = SkGetPackedG32(c0);
-       SkFixed b = SkGetPackedB32(c0);
-
-       SkFixed da = SkIntToFixed(SkGetPackedA32(c1) - a) / (count - 1);
-       SkFixed dr = SkIntToFixed(SkGetPackedR32(c1) - r) / (count - 1);
-       SkFixed dg = SkIntToFixed(SkGetPackedG32(c1) - g) / (count - 1);
-       SkFixed db = SkIntToFixed(SkGetPackedB32(c1) - b) / (count - 1);
-
-       a = SkIntToFixed(a) + 0x8000;
-       r = SkIntToFixed(r) + 0x8000;
-       g = SkIntToFixed(g) + 0x8000;
-       b = SkIntToFixed(b) + 0x8000;
-
-       do {
-               *cache++ = SkPackARGB32(a >> 16, r >> 16, g >> 16, b >> 16);
-               a += da;
-               r += dr;
-               g += dg;
-               b += db;
-       } while (--count != 0);
+    SkASSERT(count > 1);
+
+    SkFixed a = SkGetPackedA32(c0);
+    SkFixed r = SkGetPackedR32(c0);
+    SkFixed g = SkGetPackedG32(c0);
+    SkFixed b = SkGetPackedB32(c0);
+
+    SkFixed da = SkIntToFixed(SkGetPackedA32(c1) - a) / (count - 1);
+    SkFixed dr = SkIntToFixed(SkGetPackedR32(c1) - r) / (count - 1);
+    SkFixed dg = SkIntToFixed(SkGetPackedG32(c1) - g) / (count - 1);
+    SkFixed db = SkIntToFixed(SkGetPackedB32(c1) - b) / (count - 1);
+
+    a = SkIntToFixed(a) + 0x8000;
+    r = SkIntToFixed(r) + 0x8000;
+    g = SkIntToFixed(g) + 0x8000;
+    b = SkIntToFixed(b) + 0x8000;
+
+    do {
+        *cache++ = SkPackARGB32(a >> 16, r >> 16, g >> 16, b >> 16);
+        a += da;
+        r += dr;
+        g += dg;
+        b += db;
+    } while (--count != 0);
 }
 
 static inline int SkFixedToFFFF(SkFixed x)
 {
-       SkASSERT((unsigned)x <= SK_Fixed1);
-       return x - (x >> 16);
+    SkASSERT((unsigned)x <= SK_Fixed1);
+    return x - (x >> 16);
 }
 
 static inline U16CPU dot6to16(unsigned x)
 {
-       SkASSERT(x < 64);
-       return (x << 10) | (x << 4) | (x >> 2);
+    SkASSERT(x < 64);
+    return (x << 10) | (x << 4) | (x >> 2);
 }
 
-const U16* Gradient_Shader::getCache16()
+const uint16_t* Gradient_Shader::getCache16()
 {
-       if (fCache16 == nil)
-       {
-               if (fCache16Storage == nil)     // set the storage and our working ptr
+    if (fCache16 == NULL)
+    {
+        if (fCache16Storage == NULL) // set the storage and our working ptr
 #ifdef TEST_GRADIENT_DITHER
-                       fCache16Storage = (U16*)sk_malloc_throw(sizeof(U16) * kCache16Count * 2);
+            fCache16Storage = (uint16_t*)sk_malloc_throw(sizeof(uint16_t) * kCache16Count * 2);
 #else
-                       fCache16Storage = (U16*)sk_malloc_throw(sizeof(U16) * kCache16Count);
+            fCache16Storage = (uint16_t*)sk_malloc_throw(sizeof(uint16_t) * kCache16Count);
 #endif
-               fCache16 = fCache16Storage;
-               if (fColorCount == 2)
-                       build_16bit_cache(fCache16, fARGB32[0], fARGB32[1], kCache16Count);
-               else
-               {
-                       Rec* rec = fRecs;
-                       int     prevIndex = 0;
-                       for (unsigned i = 1; i < fColorCount; i++)
-                       {
-                               int nextIndex = SkFixedToFFFF(rec[i].fPos) >> (16 - kCache16Bits);
-                               SkASSERT(nextIndex < kCache16Count);
-
-                               if (nextIndex > prevIndex)
-                                       build_16bit_cache(fCache16 + prevIndex, fARGB32[i-1], fARGB32[i], nextIndex - prevIndex + 1);
-                               prevIndex = nextIndex;
-                       }
-                       SkASSERT(prevIndex == kCache16Count - 1);
-               }
-
-               if (fMapper)
-               {
+        fCache16 = fCache16Storage;
+        if (fColorCount == 2)
+            build_16bit_cache(fCache16, fOrigColors[0], fOrigColors[1], kCache16Count);
+        else
+        {
+            Rec* rec = fRecs;
+            int prevIndex = 0;
+            for (unsigned i = 1; i < fColorCount; i++)
+            {
+                int nextIndex = SkFixedToFFFF(rec[i].fPos) >> (16 - kCache16Bits);
+                SkASSERT(nextIndex < kCache16Count);
+
+                if (nextIndex > prevIndex)
+                    build_16bit_cache(fCache16 + prevIndex, fOrigColors[i-1], fOrigColors[i], nextIndex - prevIndex + 1);
+                prevIndex = nextIndex;
+            }
+            SkASSERT(prevIndex == kCache16Count - 1);
+        }
+
+        if (fMapper)
+        {
 #ifdef TEST_GRADIENT_DITHER
-                       fCache16Storage = (U16*)sk_malloc_throw(sizeof(U16) * kCache16Count * 2);
+            fCache16Storage = (uint16_t*)sk_malloc_throw(sizeof(uint16_t) * kCache16Count * 2);
 #else
-                       fCache16Storage = (U16*)sk_malloc_throw(sizeof(U16) * kCache16Count);
+            fCache16Storage = (uint16_t*)sk_malloc_throw(sizeof(uint16_t) * kCache16Count);
 #endif
-                       U16* linear = fCache16;                 // just computed linear data
-                       U16* mapped = fCache16Storage;  // storage for mapped data
-                       SkUnitMapper* map = fMapper;
-                       for (int i = 0; i < 64; i++)
-                       {
-                               int index = map->mapUnit16(dot6to16(i)) >> 10;
-                               mapped[i] = linear[index];
+            uint16_t* linear = fCache16;         // just computed linear data
+            uint16_t* mapped = fCache16Storage;  // storage for mapped data
+            SkUnitMapper* map = fMapper;
+            for (int i = 0; i < 64; i++)
+            {
+                int index = map->mapUnit16(dot6to16(i)) >> 10;
+                mapped[i] = linear[index];
 #ifdef TEST_GRADIENT_DITHER
-                               mapped[i + 64] = linear[index + 64];
+                mapped[i + 64] = linear[index + 64];
 #endif
-                       }
-                       sk_free(fCache16);
-                       fCache16 = fCache16Storage;
-               }
-       }
-       return fCache16;
+            }
+            sk_free(fCache16);
+            fCache16 = fCache16Storage;
+        }
+    }
+    return fCache16;
 }
 
 const SkPMColor* Gradient_Shader::getCache32()
 {
-       if (fCache32 == nil)
-       {
-               if (fCache32Storage == nil)     // set the storage and our working ptr
-                       fCache32Storage = (SkPMColor*)sk_malloc_throw(sizeof(SkPMColor) * kCache32Count);
-
-               fCache32 = fCache32Storage;
-               if (fColorCount == 2)
-                       build_32bit_cache(fCache32, fARGB32[0], fARGB32[1], kCache32Count);
-               else
-               {
-                       Rec* rec = fRecs;
-                       int     prevIndex = 0;
-                       for (unsigned i = 1; i < fColorCount; i++)
-                       {
-                               int nextIndex = SkFixedToFFFF(rec[i].fPos) >> (16 - kCache32Bits);
-                               SkASSERT(nextIndex < kCache32Count);
-
-                               if (nextIndex > prevIndex)
-                                       build_32bit_cache(fCache32 + prevIndex, fARGB32[i-1], fARGB32[i], nextIndex - prevIndex + 1);
-                               prevIndex = nextIndex;
-                       }
-                       SkASSERT(prevIndex == kCache32Count - 1);
-               }
-
-               if (fMapper)
-               {
-                       fCache32Storage = (SkPMColor*)sk_malloc_throw(sizeof(SkPMColor) * kCache32Count);
-                       SkPMColor* linear = fCache32;                   // just computed linear data
-                       SkPMColor* mapped = fCache32Storage;    // storage for mapped data
-                       SkUnitMapper* map = fMapper;
-                       for (int i = 0; i < 256; i++)
-                               mapped[i] = linear[map->mapUnit16((i << 8) | i) >> 8];
-                       sk_free(fCache32);
-                       fCache32 = fCache32Storage;
-               }
-       }
-       return fCache32;
+    if (fCache32 == NULL)
+    {
+        if (fCache32Storage == NULL) // set the storage and our working ptr
+            fCache32Storage = (SkPMColor*)sk_malloc_throw(sizeof(SkPMColor) * kCache32Count);
+
+        fCache32 = fCache32Storage;
+        if (fColorCount == 2)
+            build_32bit_cache(fCache32, fARGB32[0], fARGB32[1], kCache32Count);
+        else
+        {
+            Rec* rec = fRecs;
+            int prevIndex = 0;
+            for (unsigned i = 1; i < fColorCount; i++)
+            {
+                int nextIndex = SkFixedToFFFF(rec[i].fPos) >> (16 - kCache32Bits);
+                SkASSERT(nextIndex < kCache32Count);
+
+                if (nextIndex > prevIndex)
+                    build_32bit_cache(fCache32 + prevIndex, fARGB32[i-1], fARGB32[i], nextIndex - prevIndex + 1);
+                prevIndex = nextIndex;
+            }
+            SkASSERT(prevIndex == kCache32Count - 1);
+        }
+
+        if (fMapper)
+        {
+            fCache32Storage = (SkPMColor*)sk_malloc_throw(sizeof(SkPMColor) * kCache32Count);
+            SkPMColor* linear = fCache32;           // just computed linear data
+            SkPMColor* mapped = fCache32Storage;    // storage for mapped data
+            SkUnitMapper* map = fMapper;
+            for (int i = 0; i < 256; i++)
+                mapped[i] = linear[map->mapUnit16((i << 8) | i) >> 8];
+            sk_free(fCache32);
+            fCache32 = fCache32Storage;
+        }
+    }
+    return fCache32;
 }
 
 ///////////////////////////////////////////////////////////////////////////
 
 static void pts_to_unit_matrix(const SkPoint pts[2], SkMatrix* matrix)
 {
-       SkVector        vec = pts[1] - pts[0];
-       SkScalar        mag = vec.length();
-       SkScalar        inv = mag ? SkScalarInvert(mag) : 0;
-
-       vec.scale(inv);
-       matrix->setSinCos(-vec.fY, vec.fX, pts[0].fX, pts[0].fY);
-       matrix->postTranslate(-pts[0].fX, -pts[0].fY);
-       matrix->postScale(inv, inv, 0, 0);
+    SkVector    vec = pts[1] - pts[0];
+    SkScalar    mag = vec.length();
+    SkScalar    inv = mag ? SkScalarInvert(mag) : 0;
+
+    vec.scale(inv);
+    matrix->setSinCos(-vec.fY, vec.fX, pts[0].fX, pts[0].fY);
+    matrix->postTranslate(-pts[0].fX, -pts[0].fY);
+    matrix->postScale(inv, inv);
 }
 
 class Linear_Gradient : public Gradient_Shader {
 public:
-       Linear_Gradient(const SkPoint pts[2],
-                                       const SkColor colors[], const SkScalar pos[], int colorCount,
-                                       SkShader::TileMode mode, SkUnitMapper* mapper)
-               : Gradient_Shader(colors, pos, colorCount, mode, mapper)
-       {
-               pts_to_unit_matrix(pts, &fPtsToUnit);
-       }
-       virtual U32  getFlags() { return this->INHERITED::getFlags() | kHasSpan16_Flag; }
-       virtual void shadeSpan(int x, int y, SkPMColor dstC[], int count);
-       virtual void shadeSpanOpaque16(int x, int y, U16 dstC[], int count);
+    Linear_Gradient(const SkPoint pts[2],
+                    const SkColor colors[], const SkScalar pos[], int colorCount,
+                    SkShader::TileMode mode, SkUnitMapper* mapper)
+        : Gradient_Shader(colors, pos, colorCount, mode, mapper)
+    {
+        pts_to_unit_matrix(pts, &fPtsToUnit);
+    }
+    virtual void shadeSpan(int x, int y, SkPMColor dstC[], int count);
+    virtual void shadeSpan16(int x, int y, uint16_t dstC[], int count);
 
 private:
-       typedef Gradient_Shader INHERITED;
+    typedef Gradient_Shader INHERITED;
 };
 
 void Linear_Gradient::shadeSpan(int x, int y, SkPMColor dstC[], int count)
 {
-       SkASSERT(count > 0);
-
-       SkPoint                         srcPt;
-       SkMatrix::MapPtProc     dstProc = fDstToIndexProc;
-       TileProc                        proc = fTileProc;
-       const SkPMColor*        cache = this->getCache32();
-
-       if (fDstToIndexClass != kPerspective_MatrixClass)
-       {
-               dstProc(fDstToIndex, SkIntToScalar(x), SkIntToScalar(y), &srcPt);
-               SkFixed dx, fx = SkScalarToFixed(srcPt.fX);
-
-               if (fDstToIndexClass == kFixedStepInX_MatrixClass)
-               {
-                       SkFixed dxStorage[1];
-                       (void)fDstToIndex.fixedStepInX(SkIntToScalar(y), dxStorage, nil);
-                       dx = dxStorage[0];
-               }
-               else
-               {
-                       SkASSERT(fDstToIndexClass == kLinear_MatrixClass);
-                       dx = SkScalarToFixed(fDstToIndex.getScaleX());
-               }
-
-               if (SkFixedNearlyZero(dx))      // we're a vertical gradient, so no change in a span
-               {
-                       unsigned fi = proc(fx);
-                       SkASSERT(fi <= 0xFFFF);
-                       sk_memset32(dstC, cache[fi >> (16 - kCache32Bits)], count);
-               }
-               else if (proc == clamp_tileproc)
-               {
-                       do {
-                               unsigned fi = SkClampMax(fx >> 8, 0xFF);
-                               SkASSERT(fi <= 0xFF);
-                               fx += dx;
-                               *dstC++ = cache[fi];
-                       } while (--count != 0);
-               }
-               else if (proc == mirror_tileproc)
-               {
-                       do {
-                               unsigned fi = mirror_8bits(fx >> 8);
-                               SkASSERT(fi <= 0xFF);
-                               fx += dx;
-                               *dstC++ = cache[fi];
-                       } while (--count != 0);
-               }
-               else
-               {
-                       SkASSERT(proc == repeat_tileproc);
-                       do {
-                               unsigned fi = repeat_8bits(fx >> 8);
-                               SkASSERT(fi <= 0xFF);
-                               fx += dx;
-                               *dstC++ = cache[fi];
-                       } while (--count != 0);
-               }
-       }
-       else
-       {
-               SkScalar        dstX = SkIntToScalar(x);
-               SkScalar        dstY = SkIntToScalar(y);
-               do {
-                       dstProc(fDstToIndex, dstX, dstY, &srcPt);
-                       unsigned fi = proc(SkScalarToFixed(srcPt.fX));
-                       SkASSERT(fi <= 0xFFFF);
-                       *dstC++ = cache[fi >> (16 - kCache32Bits)];
-                       dstX += SK_Scalar1;
-               } while (--count != 0);
-       }
+    SkASSERT(count > 0);
+
+    SkPoint             srcPt;
+    SkMatrix::MapPtProc dstProc = fDstToIndexProc;
+    TileProc            proc = fTileProc;
+    const SkPMColor*    cache = this->getCache32();
+
+    if (fDstToIndexClass != kPerspective_MatrixClass)
+    {
+        dstProc(fDstToIndex, SkIntToScalar(x), SkIntToScalar(y), &srcPt);
+        SkFixed dx, fx = SkScalarToFixed(srcPt.fX);
+
+        if (fDstToIndexClass == kFixedStepInX_MatrixClass)
+        {
+            SkFixed dxStorage[1];
+            (void)fDstToIndex.fixedStepInX(SkIntToScalar(y), dxStorage, NULL);
+            dx = dxStorage[0];
+        }
+        else
+        {
+            SkASSERT(fDstToIndexClass == kLinear_MatrixClass);
+            dx = SkScalarToFixed(fDstToIndex.getScaleX());
+        }
+
+        if (SkFixedNearlyZero(dx))  // we're a vertical gradient, so no change in a span
+        {
+            unsigned fi = proc(fx);
+            SkASSERT(fi <= 0xFFFF);
+            sk_memset32(dstC, cache[fi >> (16 - kCache32Bits)], count);
+        }
+        else if (proc == clamp_tileproc)
+        {
+            do {
+                unsigned fi = SkClampMax(fx >> 8, 0xFF);
+                SkASSERT(fi <= 0xFF);
+                fx += dx;
+                *dstC++ = cache[fi];
+            } while (--count != 0);
+        }
+        else if (proc == mirror_tileproc)
+        {
+            do {
+                unsigned fi = mirror_8bits(fx >> 8);
+                SkASSERT(fi <= 0xFF);
+                fx += dx;
+                *dstC++ = cache[fi];
+            } while (--count != 0);
+        }
+        else
+        {
+            SkASSERT(proc == repeat_tileproc);
+            do {
+                unsigned fi = repeat_8bits(fx >> 8);
+                SkASSERT(fi <= 0xFF);
+                fx += dx;
+                *dstC++ = cache[fi];
+            } while (--count != 0);
+        }
+    }
+    else
+    {
+        SkScalar    dstX = SkIntToScalar(x);
+        SkScalar    dstY = SkIntToScalar(y);
+        do {
+            dstProc(fDstToIndex, dstX, dstY, &srcPt);
+            unsigned fi = proc(SkScalarToFixed(srcPt.fX));
+            SkASSERT(fi <= 0xFFFF);
+            *dstC++ = cache[fi >> (16 - kCache32Bits)];
+            dstX += SK_Scalar1;
+        } while (--count != 0);
+    }
 }
 
 #ifdef TEST_GRADIENT_DITHER
@@ -600,109 +626,116 @@ static void dither_memset16(uint16_t dst[], uint16_t value, uint16_t other, int
 }
 #endif
 
-void Linear_Gradient::shadeSpanOpaque16(int x, int y, U16 dstC[], int count)
+void Linear_Gradient::shadeSpan16(int x, int y, uint16_t dstC[], int count)
 {
-       SkASSERT(count > 0);
-       SkASSERT(this->getPaintAlpha() == 0xFF);
+    SkASSERT(count > 0);
 
-       SkPoint                         srcPt;
-       SkMatrix::MapPtProc     dstProc = fDstToIndexProc;
-       TileProc                        proc = fTileProc;
-       const U16*                      cache = this->getCache16();
+    SkPoint             srcPt;
+    SkMatrix::MapPtProc dstProc = fDstToIndexProc;
+    TileProc            proc = fTileProc;
+    const uint16_t*     cache = this->getCache16();
 #ifdef TEST_GRADIENT_DITHER
-       int                                     toggle = ((x ^ y) & 1) << kCache16Bits;
+    int                 toggle = ((x ^ y) & 1) << kCache16Bits;
 #endif
 
-       if (fDstToIndexClass != kPerspective_MatrixClass)
-       {
-               dstProc(fDstToIndex, SkIntToScalar(x), SkIntToScalar(y), &srcPt);
-               SkFixed dx, fx = SkScalarToFixed(srcPt.fX);
-
-               if (fDstToIndexClass == kFixedStepInX_MatrixClass)
-               {
-                       SkFixed dxStorage[1];
-                       (void)fDstToIndex.fixedStepInX(SkIntToScalar(y), dxStorage, nil);
-                       dx = dxStorage[0];
-               }
-               else
-               {
-                       SkASSERT(fDstToIndexClass == kLinear_MatrixClass);
-                       dx = SkScalarToFixed(fDstToIndex.getScaleX());
-               }
-
-               if (SkFixedNearlyZero(dx))      // we're a vertical gradient, so no change in a span
-               {
-                       unsigned fi = proc(fx) >> 10;
-                       SkASSERT(fi <= 63);
+    if (fDstToIndexClass != kPerspective_MatrixClass)
+    {
+        dstProc(fDstToIndex, SkIntToScalar(x), SkIntToScalar(y), &srcPt);
+        SkFixed dx, fx = SkScalarToFixed(srcPt.fX);
+
+        if (fDstToIndexClass == kFixedStepInX_MatrixClass)
+        {
+            SkFixed dxStorage[1];
+            (void)fDstToIndex.fixedStepInX(SkIntToScalar(y), dxStorage, NULL);
+            dx = dxStorage[0];
+        }
+        else
+        {
+            SkASSERT(fDstToIndexClass == kLinear_MatrixClass);
+            dx = SkScalarToFixed(fDstToIndex.getScaleX());
+        }
+
+        if (SkFixedNearlyZero(dx))  // we're a vertical gradient, so no change in a span
+        {
+            unsigned fi = proc(fx) >> 10;
+            SkASSERT(fi <= 63);
 #ifdef TEST_GRADIENT_DITHER
             dither_memset16(dstC, cache[toggle + fi], cache[(toggle ^ (1 << kCache16Bits)) + fi], count);
 #else
-                       sk_memset16(dstC, cache[fi], count);
+            sk_memset16(dstC, cache[fi], count);
+#endif
+        }
+        else if (proc == clamp_tileproc)
+        {
+            do {
+                unsigned fi = SkClampMax(fx >> 10, 63);
+                SkASSERT(fi <= 63);
+                fx += dx;
+#ifdef TEST_GRADIENT_DITHER
+                *dstC++ = cache[toggle + fi];
+                toggle ^= (1 << kCache16Bits);
+#else
+                *dstC++ = cache[fi];
 #endif
-               }
-               else if (proc == clamp_tileproc)
-               {
-                       do {
-                               unsigned fi = SkClampMax(fx >> 10, 63);
-                               SkASSERT(fi <= 63);
-                               fx += dx;
+            } while (--count != 0);
+        }
+        else if (proc == mirror_tileproc)
+        {
+            do {
+                unsigned fi = mirror_6bits(fx >> 10);
+                SkASSERT(fi <= 0x3F);
+                fx += dx;
 #ifdef TEST_GRADIENT_DITHER
-                               *dstC++ = cache[toggle + fi];
-                               toggle ^= (1 << kCache16Bits);
+                *dstC++ = cache[toggle + fi];
+                toggle ^= (1 << kCache16Bits);
 #else
-                               *dstC++ = cache[fi];
+                *dstC++ = cache[fi];
 #endif
-                       } while (--count != 0);
-               }
-               else if (proc == mirror_tileproc)
-               {
-                       do {
-                               unsigned fi = mirror_6bits(fx >> 10);
-                               SkASSERT(fi <= 0x3F);
-                               fx += dx;
+            } while (--count != 0);
+        }
+        else
+        {
+            SkASSERT(proc == repeat_tileproc);
+            do {
+                unsigned fi = repeat_6bits(fx >> 10);
+                SkASSERT(fi <= 0x3F);
+                fx += dx;
 #ifdef TEST_GRADIENT_DITHER
-                               *dstC++ = cache[toggle + fi];
-                               toggle ^= (1 << kCache16Bits);
+                *dstC++ = cache[toggle + fi];
+                toggle ^= (1 << kCache16Bits);
 #else
-                               *dstC++ = cache[fi];
+                *dstC++ = cache[fi];
 #endif
-                       } while (--count != 0);
-               }
-               else
-               {
-                       SkASSERT(proc == repeat_tileproc);
-                       do {
-                               unsigned fi = repeat_6bits(fx >> 10);
-                               SkASSERT(fi <= 0x3F);
-                               fx += dx;
+            } while (--count != 0);
+        }
+    }
+    else
+    {
+        SkScalar    dstX = SkIntToScalar(x);
+        SkScalar    dstY = SkIntToScalar(y);
+        do {
+            dstProc(fDstToIndex, dstX, dstY, &srcPt);
+            unsigned fi = proc(SkScalarToFixed(srcPt.fX));
+            SkASSERT(fi <= 0xFFFF);
+
+            int index = fi >> (16 - kCache16Bits);
 #ifdef TEST_GRADIENT_DITHER
-                               *dstC++ = cache[toggle + fi];
-                               toggle ^= (1 << kCache16Bits);
+            *dstC++ = cache[toggle + index];
+            toggle ^= (1 << kCache16Bits);
 #else
-                               *dstC++ = cache[fi];
+            *dstC++ = cache[index];
 #endif
-                       } while (--count != 0);
-               }
-       }
-       else
-       {
-               SkScalar        dstX = SkIntToScalar(x);
-               SkScalar        dstY = SkIntToScalar(y);
-               do {
-                       dstProc(fDstToIndex, dstX, dstY, &srcPt);
-                       unsigned fi = proc(SkScalarToFixed(srcPt.fX));
-                       SkASSERT(fi <= 0xFFFF);
-                       *dstC++ = cache[fi >> (16 - kCache16Bits)];
-                       dstX += SK_Scalar1;
-               } while (--count != 0);
-       }
+
+            dstX += SK_Scalar1;
+        } while (--count != 0);
+    }
 }
 
 ////////////////////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////////////////////
 
-#define kSQRT_TABLE_BITS       11
-#define kSQRT_TABLE_SIZE       (1 << kSQRT_TABLE_BITS)
+#define kSQRT_TABLE_BITS    11
+#define kSQRT_TABLE_SIZE    (1 << kSQRT_TABLE_BITS)
 
 #include "SkRadialGradient_Table.h"
 
@@ -712,27 +745,27 @@ void Linear_Gradient::shadeSpanOpaque16(int x, int y, U16 dstC[], int count)
 
 void SkRadialGradient_BuildTable()
 {
-       // build it 0..127 x 0..127, so we use 2^15 - 1 in the numerator for our "fixed" table
-
-       FILE* file = ::fopen("SkRadialGradient_Table.h", "w");
-       SkASSERT(file);
-       ::fprintf(file, "static const U8 gSqrt8Table[] = {\n");
-
-       for (int i = 0; i < kSQRT_TABLE_SIZE; i++)
-       {
-               if ((i & 15) == 0)
-                       ::fprintf(file, "\t");
-
-               U8 value = SkToU8(SkFixedSqrt(i * SK_Fixed1 / kSQRT_TABLE_SIZE) >> 8);
-
-               ::fprintf(file, "0x%02X", value);
-               if (i < kSQRT_TABLE_SIZE-1)
-                       ::fprintf(file, ", ");
-               if ((i & 15) == 15)
-                       ::fprintf(file, "\n");
-       }
-       ::fprintf(file, "};\n");
-       ::fclose(file);
+    // build it 0..127 x 0..127, so we use 2^15 - 1 in the numerator for our "fixed" table
+
+    FILE* file = ::fopen("SkRadialGradient_Table.h", "w");
+    SkASSERT(file);
+    ::fprintf(file, "static const U8 gSqrt8Table[] = {\n");
+
+    for (int i = 0; i < kSQRT_TABLE_SIZE; i++)
+    {
+        if ((i & 15) == 0)
+            ::fprintf(file, "\t");
+
+        U8 value = SkToU8(SkFixedSqrt(i * SK_Fixed1 / kSQRT_TABLE_SIZE) >> 8);
+
+        ::fprintf(file, "0x%02X", value);
+        if (i < kSQRT_TABLE_SIZE-1)
+            ::fprintf(file, ", ");
+        if ((i & 15) == 15)
+            ::fprintf(file, "\n");
+    }
+    ::fprintf(file, "};\n");
+    ::fclose(file);
 }
 
 #endif
@@ -740,238 +773,245 @@ void SkRadialGradient_BuildTable()
 
 static void rad_to_unit_matrix(const SkPoint& center, SkScalar radius, SkMatrix* matrix)
 {
-       SkScalar        inv = SkScalarInvert(radius);
+    SkScalar    inv = SkScalarInvert(radius);
 
-       matrix->setTranslate(-center.fX, -center.fY);
-       matrix->postScale(inv, inv, 0, 0);
+    matrix->setTranslate(-center.fX, -center.fY);
+    matrix->postScale(inv, inv);
 }
 
 class Radial_Gradient : public Gradient_Shader {
 public:
-       Radial_Gradient(const SkPoint& center, SkScalar radius,
-                                       const SkColor colors[], const SkScalar pos[], int colorCount,
-                                       SkShader::TileMode mode, SkUnitMapper* mapper)
-               : Gradient_Shader(colors, pos, colorCount, mode, mapper)
-       {
-               // make sure our table is insync with our current #define for kSQRT_TABLE_SIZE
-               SkASSERT(sizeof(gSqrt8Table) == kSQRT_TABLE_SIZE);
-
-               rad_to_unit_matrix(center, radius, &fPtsToUnit);
-       }
-       virtual U32  getFlags() { return this->INHERITED::getFlags() | kHasSpan16_Flag; }
-       virtual void shadeSpan(int x, int y, SkPMColor dstC[], int count)
-       {
-               SkASSERT(count > 0);
-
-               SkPoint                         srcPt;
-               SkMatrix::MapPtProc     dstProc = fDstToIndexProc;
-               TileProc                        proc = fTileProc;
-               const SkPMColor*        cache = this->getCache32();
-
-               if (fDstToIndexClass != kPerspective_MatrixClass)
-               {
-                       dstProc(fDstToIndex, SkIntToScalar(x), SkIntToScalar(y), &srcPt);
-                       SkFixed dx, fx = SkScalarToFixed(srcPt.fX);
-                       SkFixed dy, fy = SkScalarToFixed(srcPt.fY);
-
-                       if (fDstToIndexClass == kFixedStepInX_MatrixClass)
-                       {
-                               SkFixed storage[2];
-                               (void)fDstToIndex.fixedStepInX(SkIntToScalar(y), &storage[0], &storage[1]);
-                               dx = storage[0];
-                               dy = storage[1];
-                       }
-                       else
-                       {
-                               SkASSERT(fDstToIndexClass == kLinear_MatrixClass);
-                               dx = SkScalarToFixed(fDstToIndex.getScaleX());
-                               dy = SkScalarToFixed(fDstToIndex.getSkewY());
-                       }
-
-                       if (proc == clamp_tileproc)
-                       {
-                               const U8* sqrt_table = gSqrt8Table;
-                               fx >>= 1;
-                               dx >>= 1;
-                               fy >>= 1;
-                               dy >>= 1;
-                               do {
-                                       unsigned xx = SkPin32(fx, -0xFFFF >> 1, 0xFFFF >> 1);
-                                       unsigned fi = SkPin32(fy, -0xFFFF >> 1, 0xFFFF >> 1);
-                                       fi = (xx * xx + fi * fi) >> (14 + 16 - kSQRT_TABLE_BITS);
-                                       fi = SkFastMin32(fi, 0xFFFF >> (16 - kSQRT_TABLE_BITS));
-                                       *dstC++ = cache[sqrt_table[fi] >> (8 - kCache32Bits)];
-                                       fx += dx;
-                                       fy += dy;
-                               } while (--count != 0);
-                       }
-                       else if (proc == mirror_tileproc)
-                       {
-                               do {
-                                       SkFixed dist = SkFixedSqrt(SkFixedSquare(fx) + SkFixedSquare(fy));
-                                       unsigned fi = mirror_tileproc(dist);
-                                       SkASSERT(fi <= 0xFFFF);
-                                       *dstC++ = cache[fi >> (16 - kCache32Bits)];
-                                       fx += dx;
-                                       fy += dy;
-                               } while (--count != 0);
-                       }
-                       else
-                       {
-                               SkASSERT(proc == repeat_tileproc);
-                               do {
-                                       SkFixed dist = SkFixedSqrt(SkFixedSquare(fx) + SkFixedSquare(fy));
-                                       unsigned fi = repeat_tileproc(dist);
-                                       SkASSERT(fi <= 0xFFFF);
-                                       *dstC++ = cache[fi >> (16 - kCache32Bits)];
-                                       fx += dx;
-                                       fy += dy;
-                               } while (--count != 0);
-                       }
-               }
-               else    // perspective case
-               {
-                       SkScalar dstX = SkIntToScalar(x);
-                       SkScalar dstY = SkIntToScalar(y);
-                       do {
-                               dstProc(fDstToIndex, dstX, dstY, &srcPt);
-                               unsigned fi = proc(SkScalarToFixed(srcPt.length()));
-                               SkASSERT(fi <= 0xFFFF);
-                               *dstC++ = cache[fi >> (16 - kCache32Bits)];
-                               dstX += SK_Scalar1;
-                       } while (--count != 0);
-               }
-       }
-       virtual void shadeSpanOpaque16(int x, int y, U16 dstC[], int count)
-       {
-               SkASSERT(count > 0);
-
-               SkPoint                         srcPt;
-               SkMatrix::MapPtProc     dstProc = fDstToIndexProc;
-               TileProc                        proc = fTileProc;
-               const U16*                      cache = this->getCache16();
+    Radial_Gradient(const SkPoint& center, SkScalar radius,
+                    const SkColor colors[], const SkScalar pos[], int colorCount,
+                    SkShader::TileMode mode, SkUnitMapper* mapper)
+        : Gradient_Shader(colors, pos, colorCount, mode, mapper)
+    {
+        // make sure our table is insync with our current #define for kSQRT_TABLE_SIZE
+        SkASSERT(sizeof(gSqrt8Table) == kSQRT_TABLE_SIZE);
+
+        rad_to_unit_matrix(center, radius, &fPtsToUnit);
+    }
+    virtual void shadeSpan(int x, int y, SkPMColor dstC[], int count)
+    {
+        SkASSERT(count > 0);
+
+        SkPoint             srcPt;
+        SkMatrix::MapPtProc dstProc = fDstToIndexProc;
+        TileProc            proc = fTileProc;
+        const SkPMColor*    cache = this->getCache32();
+
+        if (fDstToIndexClass != kPerspective_MatrixClass)
+        {
+            dstProc(fDstToIndex, SkIntToScalar(x), SkIntToScalar(y), &srcPt);
+            SkFixed dx, fx = SkScalarToFixed(srcPt.fX);
+            SkFixed dy, fy = SkScalarToFixed(srcPt.fY);
+
+            if (fDstToIndexClass == kFixedStepInX_MatrixClass)
+            {
+                SkFixed storage[2];
+                (void)fDstToIndex.fixedStepInX(SkIntToScalar(y), &storage[0], &storage[1]);
+                dx = storage[0];
+                dy = storage[1];
+            }
+            else
+            {
+                SkASSERT(fDstToIndexClass == kLinear_MatrixClass);
+                dx = SkScalarToFixed(fDstToIndex.getScaleX());
+                dy = SkScalarToFixed(fDstToIndex.getSkewY());
+            }
+
+            if (proc == clamp_tileproc)
+            {
+                const U8* sqrt_table = gSqrt8Table;
+                fx >>= 1;
+                dx >>= 1;
+                fy >>= 1;
+                dy >>= 1;
+                do {
+                    unsigned xx = SkPin32(fx, -0xFFFF >> 1, 0xFFFF >> 1);
+                    unsigned fi = SkPin32(fy, -0xFFFF >> 1, 0xFFFF >> 1);
+                    fi = (xx * xx + fi * fi) >> (14 + 16 - kSQRT_TABLE_BITS);
+                    fi = SkFastMin32(fi, 0xFFFF >> (16 - kSQRT_TABLE_BITS));
+                    *dstC++ = cache[sqrt_table[fi] >> (8 - kCache32Bits)];
+                    fx += dx;
+                    fy += dy;
+                } while (--count != 0);
+            }
+            else if (proc == mirror_tileproc)
+            {
+                do {
+                    SkFixed dist = SkFixedSqrt(SkFixedSquare(fx) + SkFixedSquare(fy));
+                    unsigned fi = mirror_tileproc(dist);
+                    SkASSERT(fi <= 0xFFFF);
+                    *dstC++ = cache[fi >> (16 - kCache32Bits)];
+                    fx += dx;
+                    fy += dy;
+                } while (--count != 0);
+            }
+            else
+            {
+                SkASSERT(proc == repeat_tileproc);
+                do {
+                    SkFixed dist = SkFixedSqrt(SkFixedSquare(fx) + SkFixedSquare(fy));
+                    unsigned fi = repeat_tileproc(dist);
+                    SkASSERT(fi <= 0xFFFF);
+                    *dstC++ = cache[fi >> (16 - kCache32Bits)];
+                    fx += dx;
+                    fy += dy;
+                } while (--count != 0);
+            }
+        }
+        else    // perspective case
+        {
+            SkScalar dstX = SkIntToScalar(x);
+            SkScalar dstY = SkIntToScalar(y);
+            do {
+                dstProc(fDstToIndex, dstX, dstY, &srcPt);
+                unsigned fi = proc(SkScalarToFixed(srcPt.length()));
+                SkASSERT(fi <= 0xFFFF);
+                *dstC++ = cache[fi >> (16 - kCache32Bits)];
+                dstX += SK_Scalar1;
+            } while (--count != 0);
+        }
+    }
+    virtual void shadeSpan16(int x, int y, uint16_t dstC[], int count)
+    {
+        SkASSERT(count > 0);
+
+        SkPoint             srcPt;
+        SkMatrix::MapPtProc dstProc = fDstToIndexProc;
+        TileProc            proc = fTileProc;
+        const uint16_t*     cache = this->getCache16();
 #ifdef TEST_GRADIENT_DITHER
-               int                                     toggle = ((x ^ y) & 1) << kCache16Bits;
+        int                 toggle = ((x ^ y) & 1) << kCache16Bits;
 #endif
 
-               if (fDstToIndexClass != kPerspective_MatrixClass)
-               {
-                       dstProc(fDstToIndex, SkIntToScalar(x), SkIntToScalar(y), &srcPt);
-                       SkFixed dx, fx = SkScalarToFixed(srcPt.fX);
-                       SkFixed dy, fy = SkScalarToFixed(srcPt.fY);
-
-                       if (fDstToIndexClass == kFixedStepInX_MatrixClass)
-                       {
-                               SkFixed storage[2];
-                               (void)fDstToIndex.fixedStepInX(SkIntToScalar(y), &storage[0], &storage[1]);
-                               dx = storage[0];
-                               dy = storage[1];
-                       }
-                       else
-                       {
-                               SkASSERT(fDstToIndexClass == kLinear_MatrixClass);
-                               dx = SkScalarToFixed(fDstToIndex.getScaleX());
-                               dy = SkScalarToFixed(fDstToIndex.getSkewY());
-                       }
-
-                       if (proc == clamp_tileproc)
-                       {
-                               const U8* sqrt_table = gSqrt8Table;
-
-                               /* knock these down so we can pin against +- 0x7FFF, which is an immediate load,
-                                       rather than 0xFFFF which is slower. This is a compromise, since it reduces our
-                                       precision, but that appears to be visually OK. If we decide this is OK for
-                                       all of our cases, we could (it seems) put this scale-down into fDstToIndex,
-                                       to avoid having to do these extra shifts each time.
-                               */
-                               fx >>= 1;
-                               dx >>= 1;
-                               fy >>= 1;
-                               dy >>= 1;
-                               if (dy == 0)    // might perform this check for the other modes, but the win will be a smaller % of the total
-                               {
-                                       fy = SkPin32(fy, -0xFFFF >> 1, 0xFFFF >> 1);
-                                       fy *= fy;
-                                       do {
-                                               unsigned xx = SkPin32(fx, -0xFFFF >> 1, 0xFFFF >> 1);
-                                               unsigned fi = (xx * xx + fy) >> (14 + 16 - kSQRT_TABLE_BITS);
-                                               fi = SkFastMin32(fi, 0xFFFF >> (16 - kSQRT_TABLE_BITS));
-                                               fx += dx;
+        if (fDstToIndexClass != kPerspective_MatrixClass)
+        {
+            dstProc(fDstToIndex, SkIntToScalar(x), SkIntToScalar(y), &srcPt);
+            SkFixed dx, fx = SkScalarToFixed(srcPt.fX);
+            SkFixed dy, fy = SkScalarToFixed(srcPt.fY);
+
+            if (fDstToIndexClass == kFixedStepInX_MatrixClass)
+            {
+                SkFixed storage[2];
+                (void)fDstToIndex.fixedStepInX(SkIntToScalar(y), &storage[0], &storage[1]);
+                dx = storage[0];
+                dy = storage[1];
+            }
+            else
+            {
+                SkASSERT(fDstToIndexClass == kLinear_MatrixClass);
+                dx = SkScalarToFixed(fDstToIndex.getScaleX());
+                dy = SkScalarToFixed(fDstToIndex.getSkewY());
+            }
+
+            if (proc == clamp_tileproc)
+            {
+                const U8* sqrt_table = gSqrt8Table;
+
+                /* knock these down so we can pin against +- 0x7FFF, which is an immediate load,
+                    rather than 0xFFFF which is slower. This is a compromise, since it reduces our
+                    precision, but that appears to be visually OK. If we decide this is OK for
+                    all of our cases, we could (it seems) put this scale-down into fDstToIndex,
+                    to avoid having to do these extra shifts each time.
+                */
+                fx >>= 1;
+                dx >>= 1;
+                fy >>= 1;
+                dy >>= 1;
+                if (dy == 0)    // might perform this check for the other modes, but the win will be a smaller % of the total
+                {
+                    fy = SkPin32(fy, -0xFFFF >> 1, 0xFFFF >> 1);
+                    fy *= fy;
+                    do {
+                        unsigned xx = SkPin32(fx, -0xFFFF >> 1, 0xFFFF >> 1);
+                        unsigned fi = (xx * xx + fy) >> (14 + 16 - kSQRT_TABLE_BITS);
+                        fi = SkFastMin32(fi, 0xFFFF >> (16 - kSQRT_TABLE_BITS));
+                        fx += dx;
 #ifdef TEST_GRADIENT_DITHER
-                                               *dstC++ = cache[toggle + (sqrt_table[fi] >> (8 - kCache16Bits))];
-                                               toggle ^= (1 << kCache16Bits);
+                        *dstC++ = cache[toggle + (sqrt_table[fi] >> (8 - kCache16Bits))];
+                        toggle ^= (1 << kCache16Bits);
 #else
-                                               *dstC++ = cache[sqrt_table[fi] >> (8 - kCache16Bits)];
+                        *dstC++ = cache[sqrt_table[fi] >> (8 - kCache16Bits)];
 #endif
-                                       } while (--count != 0);
-                               }
-                               else
-                               {
-                                       do {
-                                               unsigned xx = SkPin32(fx, -0xFFFF >> 1, 0xFFFF >> 1);
-                                               unsigned fi = SkPin32(fy, -0xFFFF >> 1, 0xFFFF >> 1);
-                                               fi = (xx * xx + fi * fi) >> (14 + 16 - kSQRT_TABLE_BITS);
-                                               fi = SkFastMin32(fi, 0xFFFF >> (16 - kSQRT_TABLE_BITS));
-                                               fx += dx;
-                                               fy += dy;
+                    } while (--count != 0);
+                }
+                else
+                {
+                    do {
+                        unsigned xx = SkPin32(fx, -0xFFFF >> 1, 0xFFFF >> 1);
+                        unsigned fi = SkPin32(fy, -0xFFFF >> 1, 0xFFFF >> 1);
+                        fi = (xx * xx + fi * fi) >> (14 + 16 - kSQRT_TABLE_BITS);
+                        fi = SkFastMin32(fi, 0xFFFF >> (16 - kSQRT_TABLE_BITS));
+                        fx += dx;
+                        fy += dy;
 #ifdef TEST_GRADIENT_DITHER
-                                               *dstC++ = cache[toggle + (sqrt_table[fi] >> (8 - kCache16Bits))];
-                                               toggle ^= (1 << kCache16Bits);
+                        *dstC++ = cache[toggle + (sqrt_table[fi] >> (8 - kCache16Bits))];
+                        toggle ^= (1 << kCache16Bits);
 #else
-                                               *dstC++ = cache[sqrt_table[fi] >> (8 - kCache16Bits)];
+                        *dstC++ = cache[sqrt_table[fi] >> (8 - kCache16Bits)];
 #endif
-                                       } while (--count != 0);
-                               }
-                       }
-                       else if (proc == mirror_tileproc)
-                       {
-                               do {
-                                       SkFixed dist = SkFixedSqrt(SkFixedSquare(fx) + SkFixedSquare(fy));
-                                       unsigned fi = mirror_tileproc(dist);
-                                       SkASSERT(fi <= 0xFFFF);
-                                       fx += dx;
-                                       fy += dy;
+                    } while (--count != 0);
+                }
+            }
+            else if (proc == mirror_tileproc)
+            {
+                do {
+                    SkFixed dist = SkFixedSqrt(SkFixedSquare(fx) + SkFixedSquare(fy));
+                    unsigned fi = mirror_tileproc(dist);
+                    SkASSERT(fi <= 0xFFFF);
+                    fx += dx;
+                    fy += dy;
 #ifdef TEST_GRADIENT_DITHER
-                                       *dstC++ = cache[toggle + (fi >> (16 - kCache16Bits))];
-                                       toggle ^= (1 << kCache16Bits);
+                    *dstC++ = cache[toggle + (fi >> (16 - kCache16Bits))];
+                    toggle ^= (1 << kCache16Bits);
 #else
-                                       *dstC++ = cache[fi >> (16 - kCache16Bits)];
+                    *dstC++ = cache[fi >> (16 - kCache16Bits)];
 #endif
-                               } while (--count != 0);
-                       }
-                       else
-                       {
-                               SkASSERT(proc == repeat_tileproc);
-                               do {
-                                       SkFixed dist = SkFixedSqrt(SkFixedSquare(fx) + SkFixedSquare(fy));
-                                       unsigned fi = repeat_tileproc(dist);
-                                       SkASSERT(fi <= 0xFFFF);
-                                       fx += dx;
-                                       fy += dy;
+                } while (--count != 0);
+            }
+            else
+            {
+                SkASSERT(proc == repeat_tileproc);
+                do {
+                    SkFixed dist = SkFixedSqrt(SkFixedSquare(fx) + SkFixedSquare(fy));
+                    unsigned fi = repeat_tileproc(dist);
+                    SkASSERT(fi <= 0xFFFF);
+                    fx += dx;
+                    fy += dy;
 #ifdef TEST_GRADIENT_DITHER
-                                       *dstC++ = cache[toggle + (fi >> (16 - kCache16Bits))];
-                                       toggle ^= (1 << kCache16Bits);
+                    *dstC++ = cache[toggle + (fi >> (16 - kCache16Bits))];
+                    toggle ^= (1 << kCache16Bits);
 #else
-                                       *dstC++ = cache[fi >> (16 - kCache16Bits)];
+                    *dstC++ = cache[fi >> (16 - kCache16Bits)];
 #endif
-                               } while (--count != 0);
-                       }
-               }
-               else    // perspective case
-               {
-                       SkScalar dstX = SkIntToScalar(x);
-                       SkScalar dstY = SkIntToScalar(y);
-                       do {
-                               dstProc(fDstToIndex, dstX, dstY, &srcPt);
-                               unsigned fi = proc(SkScalarToFixed(srcPt.length()));
-                               SkASSERT(fi <= 0xFFFF);
-                               *dstC++ = cache[fi >> (16 - kCache16Bits)];
-                               dstX += SK_Scalar1;
-                       } while (--count != 0);
-               }
-       }
+                } while (--count != 0);
+            }
+        }
+        else    // perspective case
+        {
+            SkScalar dstX = SkIntToScalar(x);
+            SkScalar dstY = SkIntToScalar(y);
+            do {
+                dstProc(fDstToIndex, dstX, dstY, &srcPt);
+                unsigned fi = proc(SkScalarToFixed(srcPt.length()));
+                SkASSERT(fi <= 0xFFFF);
+
+                int index = fi >> (16 - kCache16Bits);
+#ifdef TEST_GRADIENT_DITHER
+                *dstC++ = cache[toggle + index];
+                toggle ^= (1 << kCache16Bits);
+#else
+                *dstC++ = cache[index];
+#endif
+
+                dstX += SK_Scalar1;
+            } while (--count != 0);
+        }
+    }
 private:
-       typedef Gradient_Shader INHERITED;
+    typedef Gradient_Shader INHERITED;
 };
 
 ///////////////////////////////////////////////////////////////////////////
@@ -979,47 +1019,47 @@ private:
 
 SkDiscreteMapper::SkDiscreteMapper(unsigned segments)
 {
-       if (segments < 2)
-       {
-               fSegments = 0;
-               fScale = 0;
-       }
-       else
-       {
-               fSegments = segments;
-               fScale = SK_Fract1 / (segments - 1);
-       }
+    if (segments < 2)
+    {
+        fSegments = 0;
+        fScale = 0;
+    }
+    else
+    {
+        fSegments = segments;
+        fScale = SK_Fract1 / (segments - 1);
+    }
 }
 
 U16CPU SkDiscreteMapper::mapUnit16(U16CPU x)
 {
-       x = x * fSegments >> 16;
-       return x * fScale >> 14;
+    x = x * fSegments >> 16;
+    return x * fScale >> 14;
 }
 
 U16CPU SkFlipCosineMapper::mapUnit16(U16CPU x)
 {
-       x = SkFixedCos(x * (SK_FixedPI >> 2) >> 15);
-       x += x << 15 >> 31;     // map 0x10000 to 0xFFFF
-       x = 0xFFFF - x;
-       return x;
+    x = SkFixedCos(x * (SK_FixedPI >> 2) >> 15);
+    x += x << 15 >> 31; // map 0x10000 to 0xFFFF
+    x = 0xFFFF - x;
+    return x;
 }
 
-SkShader* SkGradientShader::CreateLinear(      const SkPoint pts[2],
-                                                                                       const SkColor colors[], const SkScalar pos[], int colorCount,
-                                                                                       TileMode mode, SkUnitMapper* mapper)
+SkShader* SkGradientShader::CreateLinear(   const SkPoint pts[2],
+                                            const SkColor colors[], const SkScalar pos[], int colorCount,
+                                            TileMode mode, SkUnitMapper* mapper)
 {
-       SkASSERT(pts && colors && colorCount >= 2);
+    SkASSERT(pts && colors && colorCount >= 2);
 
-       return SkNEW_ARGS(Linear_Gradient, (pts, colors, pos, colorCount, mode, mapper));
+    return SkNEW_ARGS(Linear_Gradient, (pts, colors, pos, colorCount, mode, mapper));
 }
 
-SkShader* SkGradientShader::CreateRadial(      const SkPoint& center, SkScalar radius,
-                                                                                       const SkColor colors[], const SkScalar pos[], int colorCount,
-                                                                                       TileMode mode, SkUnitMapper* mapper)
+SkShader* SkGradientShader::CreateRadial(   const SkPoint& center, SkScalar radius,
+                                            const SkColor colors[], const SkScalar pos[], int colorCount,
+                                            TileMode mode, SkUnitMapper* mapper)
 {
-       SkASSERT(radius > 0 && colors && colorCount >= 2);
+    SkASSERT(radius > 0 && colors && colorCount >= 2);
 
-       return SkNEW_ARGS(Radial_Gradient, (center, radius, colors, pos, colorCount, mode, mapper));
+    return SkNEW_ARGS(Radial_Gradient, (center, radius, colors, pos, colorCount, mode, mapper));
 }
 
index 896c4f4..51440cb 100644 (file)
@@ -1,3 +1,20 @@
+/* libs/graphics/effects/SkLayerRasterizer.cpp
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #include "SkLayerRasterizer.h"
 #include "SkBuffer.h"
 #include "SkDraw.h"
index dfca76c..fd54cff 100644 (file)
@@ -1,3 +1,20 @@
+/* libs/graphics/effects/SkNinePatch.cpp
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #include "SkNinePatch.h"
 #include "SkBitmap.h"
 #include "SkCanvas.h"
@@ -11,8 +28,8 @@
 
 static void* getSubAddr(const SkBitmap& bm, int x, int y)
 {
-    SkASSERT((unsigned)x < bm.width());
-    SkASSERT((unsigned)y < bm.height());
+    SkASSERT((unsigned)x < (unsigned)bm.width());
+    SkASSERT((unsigned)y < (unsigned)bm.height());
     
     switch (bm.getConfig()) {
     case SkBitmap::kNo_Config:
@@ -25,7 +42,7 @@ static void* getSubAddr(const SkBitmap& bm, int x, int y)
     case SkBitmap::kRGB_565_Config:
         x <<= 1;
         break;
-       case SkBitmap::kARGB_8888_Config:
+    case SkBitmap::kARGB_8888_Config:
         x <<= 2;
         break;
     default:
@@ -61,14 +78,20 @@ static void drawPatch(SkCanvas* canvas, const SkRect16& src, const SkRect& dst,
     canvas->restore();
 }
 
-static bool pixel_is_transparent(const SkBitmap& bm, int x, int y)
+#include "SkColorPriv.h"
+
+static SkColor undo_premultiply(SkPMColor c)
 {
-    switch (bm.getConfig()) {
-    case SkBitmap::kARGB_8888_Config:
-        return 0 == *bm.getAddr32(x, y);
-    default:
-        return false;
+    unsigned a = SkGetPackedA32(c);
+    if (a != 0 && a != 0xFF)
+    {
+        unsigned scale = (SK_Fixed1 * 255) / a;
+        unsigned r = SkFixedRound(SkGetPackedR32(c) * scale);
+        unsigned g = SkFixedRound(SkGetPackedG32(c) * scale);
+        unsigned b = SkFixedRound(SkGetPackedB32(c) * scale);
+        c = SkColorSetARGB(a, r, g, b);
     }
+    return c;
 }
 
 static void drawColumn(SkCanvas* canvas, SkRect16* src, SkRect* dst,
@@ -86,15 +109,48 @@ static void drawColumn(SkCanvas* canvas, SkRect16* src, SkRect* dst,
     src->fBottom = bitmap.height() - mar.fBottom;
     dst->fTop = dst->fBottom;
     dst->fBottom = bounds.fBottom - SkIntToScalar(mar.fBottom);
-    if (src->width() != 1 || src->height() != 1 ||
-        !pixel_is_transparent(bitmap, src->fLeft, src->fTop))
+    
+    if (src->width() == 1 && src->height() == 1)
     {
-        drawPatch(canvas, *src, *dst, bitmap, paint);
+        SkColor c = 0;
+        int     x = src->fLeft;
+        int     y = src->fTop;
+
+        switch (bitmap.getConfig()) {
+        case SkBitmap::kARGB_8888_Config:
+            c = undo_premultiply(*bitmap.getAddr32(x, y));
+            break;
+        case SkBitmap::kRGB_565_Config:
+            c = SkPixel16ToPixel32(*bitmap.getAddr16(x, y));
+            break;
+        case SkBitmap::kIndex8_Config:
+            {
+                SkColorTable* ctable = bitmap.getColorTable();
+                c = undo_premultiply((*ctable)[*bitmap.getAddr8(x, y)]);
+            }
+            break;
+        default:
+            goto SLOW_CASE;
+        }
+
+#ifdef SK_DEBUG
+        printf("---------------- center color for the ninepatch: 0x%X\n", c);
+#endif
+
+        if (0 != c || paint.getXfermode() != NULL)
+        {
+            SkColor prev = paint.getColor();
+            ((SkPaint*)&paint)->setColor(c);
+            canvas->drawRect(*dst, paint);
+            ((SkPaint*)&paint)->setColor(prev);
+        }
     }
     else
     {
-    //    SkDEBUGF(("========= Skip transparent center of ninepatch\n"));
+        SLOW_CASE:
+        drawPatch(canvas, *src, *dst, bitmap, paint);
     }
+
 // lower row
     src->fTop = src->fBottom;
     src->fBottom = bitmap.height();
index 24fc715..adee456 100644 (file)
+/* libs/graphics/effects/SkRadialGradient_Table.h
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 static const U8 gSqrt8Table[] = {
-       0x00, 0x05, 0x08, 0x09, 0x0B, 0x0C, 0x0D, 0x0E, 0x10, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x15, 
-       0x16, 0x17, 0x18, 0x18, 0x19, 0x19, 0x1A, 0x1B, 0x1B, 0x1C, 0x1C, 0x1D, 0x1D, 0x1E, 0x1E, 0x1F, 
-       0x20, 0x20, 0x20, 0x21, 0x21, 0x22, 0x22, 0x23, 0x23, 0x24, 0x24, 0x25, 0x25, 0x25, 0x26, 0x26, 
-       0x27, 0x27, 0x28, 0x28, 0x28, 0x29, 0x29, 0x29, 0x2A, 0x2A, 0x2B, 0x2B, 0x2B, 0x2C, 0x2C, 0x2C, 
-       0x2D, 0x2D, 0x2D, 0x2E, 0x2E, 0x2E, 0x2F, 0x2F, 0x30, 0x30, 0x30, 0x30, 0x31, 0x31, 0x31, 0x32, 
-       0x32, 0x32, 0x33, 0x33, 0x33, 0x34, 0x34, 0x34, 0x35, 0x35, 0x35, 0x35, 0x36, 0x36, 0x36, 0x37, 
-       0x37, 0x37, 0x38, 0x38, 0x38, 0x38, 0x39, 0x39, 0x39, 0x39, 0x3A, 0x3A, 0x3A, 0x3B, 0x3B, 0x3B, 
-       0x3B, 0x3C, 0x3C, 0x3C, 0x3C, 0x3D, 0x3D, 0x3D, 0x3D, 0x3E, 0x3E, 0x3E, 0x3E, 0x3F, 0x3F, 0x3F, 
-       0x40, 0x40, 0x40, 0x40, 0x40, 0x41, 0x41, 0x41, 0x41, 0x42, 0x42, 0x42, 0x42, 0x43, 0x43, 0x43, 
-       0x43, 0x44, 0x44, 0x44, 0x44, 0x45, 0x45, 0x45, 0x45, 0x45, 0x46, 0x46, 0x46, 0x46, 0x47, 0x47, 
-       0x47, 0x47, 0x48, 0x48, 0x48, 0x48, 0x48, 0x49, 0x49, 0x49, 0x49, 0x49, 0x4A, 0x4A, 0x4A, 0x4A, 
-       0x4B, 0x4B, 0x4B, 0x4B, 0x4B, 0x4C, 0x4C, 0x4C, 0x4C, 0x4C, 0x4D, 0x4D, 0x4D, 0x4D, 0x4D, 0x4E, 
-       0x4E, 0x4E, 0x4E, 0x4E, 0x4F, 0x4F, 0x4F, 0x4F, 0x50, 0x50, 0x50, 0x50, 0x50, 0x50, 0x51, 0x51, 
-       0x51, 0x51, 0x51, 0x52, 0x52, 0x52, 0x52, 0x52, 0x53, 0x53, 0x53, 0x53, 0x53, 0x54, 0x54, 0x54, 
-       0x54, 0x54, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x56, 0x56, 0x56, 0x56, 0x56, 0x57, 0x57, 0x57, 
-       0x57, 0x57, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x5A, 0x5A, 
-       0x5A, 0x5A, 0x5A, 0x5B, 0x5B, 0x5B, 0x5B, 0x5B, 0x5B, 0x5C, 0x5C, 0x5C, 0x5C, 0x5C, 0x5C, 0x5D, 
-       0x5D, 0x5D, 0x5D, 0x5D, 0x5D, 0x5E, 0x5E, 0x5E, 0x5E, 0x5E, 0x5E, 0x5F, 0x5F, 0x5F, 0x5F, 0x5F, 
-       0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x61, 0x61, 0x61, 0x61, 0x61, 0x61, 0x62, 0x62, 0x62, 
-       0x62, 0x62, 0x62, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x64, 0x64, 0x64, 0x64, 0x64, 0x64, 0x65, 
-       0x65, 0x65, 0x65, 0x65, 0x65, 0x65, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x67, 0x67, 0x67, 0x67, 
-       0x67, 0x67, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x69, 0x69, 0x69, 0x69, 0x69, 0x69, 0x69, 
-       0x6A, 0x6A, 0x6A, 0x6A, 0x6A, 0x6A, 0x6B, 0x6B, 0x6B, 0x6B, 0x6B, 0x6B, 0x6B, 0x6C, 0x6C, 0x6C, 
-       0x6C, 0x6C, 0x6C, 0x6C, 0x6D, 0x6D, 0x6D, 0x6D, 0x6D, 0x6D, 0x6D, 0x6E, 0x6E, 0x6E, 0x6E, 0x6E, 
-       0x6E, 0x6E, 0x6F, 0x6F, 0x6F, 0x6F, 0x6F, 0x6F, 0x70, 0x70, 0x70, 0x70, 0x70, 0x70, 0x70, 0x70, 
-       0x71, 0x71, 0x71, 0x71, 0x71, 0x71, 0x71, 0x72, 0x72, 0x72, 0x72, 0x72, 0x72, 0x72, 0x73, 0x73, 
-       0x73, 0x73, 0x73, 0x73, 0x73, 0x74, 0x74, 0x74, 0x74, 0x74, 0x74, 0x74, 0x75, 0x75, 0x75, 0x75, 
-       0x75, 0x75, 0x75, 0x75, 0x76, 0x76, 0x76, 0x76, 0x76, 0x76, 0x76, 0x77, 0x77, 0x77, 0x77, 0x77, 
-       0x77, 0x77, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x79, 0x79, 0x79, 0x79, 0x79, 0x79, 
-       0x79, 0x79, 0x7A, 0x7A, 0x7A, 0x7A, 0x7A, 0x7A, 0x7A, 0x7B, 0x7B, 0x7B, 0x7B, 0x7B, 0x7B, 0x7B, 
-       0x7B, 0x7C, 0x7C, 0x7C, 0x7C, 0x7C, 0x7C, 0x7C, 0x7C, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 
-       0x7D, 0x7E, 0x7E, 0x7E, 0x7E, 0x7E, 0x7E, 0x7E, 0x7E, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 
-       0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 
-       0x81, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 
-       0x83, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 
-       0x85, 0x85, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 
-       0x87, 0x87, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x89, 0x89, 0x89, 0x89, 0x89, 
-       0x89, 0x89, 0x89, 0x89, 0x8A, 0x8A, 0x8A, 0x8A, 0x8A, 0x8A, 0x8A, 0x8A, 0x8B, 0x8B, 0x8B, 0x8B, 
-       0x8B, 0x8B, 0x8B, 0x8B, 0x8B, 0x8C, 0x8C, 0x8C, 0x8C, 0x8C, 0x8C, 0x8C, 0x8C, 0x8C, 0x8D, 0x8D, 
-       0x8D, 0x8D, 0x8D, 0x8D, 0x8D, 0x8D, 0x8D, 0x8E, 0x8E, 0x8E, 0x8E, 0x8E, 0x8E, 0x8E, 0x8E, 0x8E, 
-       0x8F, 0x8F, 0x8F, 0x8F, 0x8F, 0x8F, 0x8F, 0x8F, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 
-       0x90, 0x90, 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 0x92, 0x92, 0x92, 0x92, 0x92, 
-       0x92, 0x92, 0x92, 0x92, 0x93, 0x93, 0x93, 0x93, 0x93, 0x93, 0x93, 0x93, 0x93, 0x94, 0x94, 0x94, 
-       0x94, 0x94, 0x94, 0x94, 0x94, 0x94, 0x95, 0x95, 0x95, 0x95, 0x95, 0x95, 0x95, 0x95, 0x95, 0x95, 
-       0x96, 0x96, 0x96, 0x96, 0x96, 0x96, 0x96, 0x96, 0x96, 0x97, 0x97, 0x97, 0x97, 0x97, 0x97, 0x97, 
-       0x97, 0x97, 0x98, 0x98, 0x98, 0x98, 0x98, 0x98, 0x98, 0x98, 0x98, 0x98, 0x99, 0x99, 0x99, 0x99, 
-       0x99, 0x99, 0x99, 0x99, 0x99, 0x99, 0x9A, 0x9A, 0x9A, 0x9A, 0x9A, 0x9A, 0x9A, 0x9A, 0x9A, 0x9B, 
-       0x9B, 0x9B, 0x9B, 0x9B, 0x9B, 0x9B, 0x9B, 0x9B, 0x9B, 0x9C, 0x9C, 0x9C, 0x9C, 0x9C, 0x9C, 0x9C, 
-       0x9C, 0x9C, 0x9C, 0x9D, 0x9D, 0x9D, 0x9D, 0x9D, 0x9D, 0x9D, 0x9D, 0x9D, 0x9D, 0x9E, 0x9E, 0x9E, 
-       0x9E, 0x9E, 0x9E, 0x9E, 0x9E, 0x9E, 0x9E, 0x9F, 0x9F, 0x9F, 0x9F, 0x9F, 0x9F, 0x9F, 0x9F, 0x9F, 
-       0xA0, 0xA0, 0xA0, 0xA0, 0xA0, 0xA0, 0xA0, 0xA0, 0xA0, 0xA0, 0xA0, 0xA1, 0xA1, 0xA1, 0xA1, 0xA1, 
-       0xA1, 0xA1, 0xA1, 0xA1, 0xA1, 0xA2, 0xA2, 0xA2, 0xA2, 0xA2, 0xA2, 0xA2, 0xA2, 0xA2, 0xA2, 0xA3, 
-       0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA4, 0xA4, 0xA4, 0xA4, 0xA4, 0xA4, 0xA4, 
-       0xA4, 0xA4, 0xA4, 0xA5, 0xA5, 0xA5, 0xA5, 0xA5, 0xA5, 0xA5, 0xA5, 0xA5, 0xA5, 0xA5, 0xA6, 0xA6, 
-       0xA6, 0xA6, 0xA6, 0xA6, 0xA6, 0xA6, 0xA6, 0xA6, 0xA7, 0xA7, 0xA7, 0xA7, 0xA7, 0xA7, 0xA7, 0xA7, 
-       0xA7, 0xA7, 0xA8, 0xA8, 0xA8, 0xA8, 0xA8, 0xA8, 0xA8, 0xA8, 0xA8, 0xA8, 0xA8, 0xA9, 0xA9, 0xA9, 
-       0xA9, 0xA9, 0xA9, 0xA9, 0xA9, 0xA9, 0xA9, 0xA9, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 
-       0xAA, 0xAA, 0xAB, 0xAB, 0xAB, 0xAB, 0xAB, 0xAB, 0xAB, 0xAB, 0xAB, 0xAB, 0xAB, 0xAC, 0xAC, 0xAC, 
-       0xAC, 0xAC, 0xAC, 0xAC, 0xAC, 0xAC, 0xAC, 0xAC, 0xAD, 0xAD, 0xAD, 0xAD, 0xAD, 0xAD, 0xAD, 0xAD, 
-       0xAD, 0xAD, 0xAD, 0xAE, 0xAE, 0xAE, 0xAE, 0xAE, 0xAE, 0xAE, 0xAE, 0xAE, 0xAE, 0xAE, 0xAF, 0xAF, 
-       0xAF, 0xAF, 0xAF, 0xAF, 0xAF, 0xAF, 0xAF, 0xAF, 0xB0, 0xB0, 0xB0, 0xB0, 0xB0, 0xB0, 0xB0, 0xB0, 
-       0xB0, 0xB0, 0xB0, 0xB0, 0xB1, 0xB1, 0xB1, 0xB1, 0xB1, 0xB1, 0xB1, 0xB1, 0xB1, 0xB1, 0xB1, 0xB2, 
-       0xB2, 0xB2, 0xB2, 0xB2, 0xB2, 0xB2, 0xB2, 0xB2, 0xB2, 0xB2, 0xB3, 0xB3, 0xB3, 0xB3, 0xB3, 0xB3, 
-       0xB3, 0xB3, 0xB3, 0xB3, 0xB3, 0xB4, 0xB4, 0xB4, 0xB4, 0xB4, 0xB4, 0xB4, 0xB4, 0xB4, 0xB4, 0xB4, 
-       0xB5, 0xB5, 0xB5, 0xB5, 0xB5, 0xB5, 0xB5, 0xB5, 0xB5, 0xB5, 0xB5, 0xB5, 0xB6, 0xB6, 0xB6, 0xB6, 
-       0xB6, 0xB6, 0xB6, 0xB6, 0xB6, 0xB6, 0xB6, 0xB7, 0xB7, 0xB7, 0xB7, 0xB7, 0xB7, 0xB7, 0xB7, 0xB7, 
-       0xB7, 0xB7, 0xB8, 0xB8, 0xB8, 0xB8, 0xB8, 0xB8, 0xB8, 0xB8, 0xB8, 0xB8, 0xB8, 0xB8, 0xB9, 0xB9, 
-       0xB9, 0xB9, 0xB9, 0xB9, 0xB9, 0xB9, 0xB9, 0xB9, 0xB9, 0xB9, 0xBA, 0xBA, 0xBA, 0xBA, 0xBA, 0xBA, 
-       0xBA, 0xBA, 0xBA, 0xBA, 0xBA, 0xBB, 0xBB, 0xBB, 0xBB, 0xBB, 0xBB, 0xBB, 0xBB, 0xBB, 0xBB, 0xBB, 
-       0xBB, 0xBC, 0xBC, 0xBC, 0xBC, 0xBC, 0xBC, 0xBC, 0xBC, 0xBC, 0xBC, 0xBC, 0xBC, 0xBD, 0xBD, 0xBD, 
-       0xBD, 0xBD, 0xBD, 0xBD, 0xBD, 0xBD, 0xBD, 0xBD, 0xBD, 0xBE, 0xBE, 0xBE, 0xBE, 0xBE, 0xBE, 0xBE, 
-       0xBE, 0xBE, 0xBE, 0xBE, 0xBE, 0xBF, 0xBF, 0xBF, 0xBF, 0xBF, 0xBF, 0xBF, 0xBF, 0xBF, 0xBF, 0xBF, 
-       0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC1, 0xC1, 0xC1, 
-       0xC1, 0xC1, 0xC1, 0xC1, 0xC1, 0xC1, 0xC1, 0xC1, 0xC1, 0xC2, 0xC2, 0xC2, 0xC2, 0xC2, 0xC2, 0xC2, 
-       0xC2, 0xC2, 0xC2, 0xC2, 0xC2, 0xC3, 0xC3, 0xC3, 0xC3, 0xC3, 0xC3, 0xC3, 0xC3, 0xC3, 0xC3, 0xC3, 
-       0xC3, 0xC4, 0xC4, 0xC4, 0xC4, 0xC4, 0xC4, 0xC4, 0xC4, 0xC4, 0xC4, 0xC4, 0xC4, 0xC5, 0xC5, 0xC5, 
-       0xC5, 0xC5, 0xC5, 0xC5, 0xC5, 0xC5, 0xC5, 0xC5, 0xC5, 0xC5, 0xC6, 0xC6, 0xC6, 0xC6, 0xC6, 0xC6, 
-       0xC6, 0xC6, 0xC6, 0xC6, 0xC6, 0xC6, 0xC7, 0xC7, 0xC7, 0xC7, 0xC7, 0xC7, 0xC7, 0xC7, 0xC7, 0xC7, 
-       0xC7, 0xC7, 0xC8, 0xC8, 0xC8, 0xC8, 0xC8, 0xC8, 0xC8, 0xC8, 0xC8, 0xC8, 0xC8, 0xC8, 0xC8, 0xC9, 
-       0xC9, 0xC9, 0xC9, 0xC9, 0xC9, 0xC9, 0xC9, 0xC9, 0xC9, 0xC9, 0xC9, 0xC9, 0xCA, 0xCA, 0xCA, 0xCA, 
-       0xCA, 0xCA, 0xCA, 0xCA, 0xCA, 0xCA, 0xCA, 0xCA, 0xCB, 0xCB, 0xCB, 0xCB, 0xCB, 0xCB, 0xCB, 0xCB, 
-       0xCB, 0xCB, 0xCB, 0xCB, 0xCB, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 
-       0xCC, 0xCC, 0xCD, 0xCD, 0xCD, 0xCD, 0xCD, 0xCD, 0xCD, 0xCD, 0xCD, 0xCD, 0xCD, 0xCD, 0xCD, 0xCE, 
-       0xCE, 0xCE, 0xCE, 0xCE, 0xCE, 0xCE, 0xCE, 0xCE, 0xCE, 0xCE, 0xCE, 0xCE, 0xCF, 0xCF, 0xCF, 0xCF, 
-       0xCF, 0xCF, 0xCF, 0xCF, 0xCF, 0xCF, 0xCF, 0xCF, 0xD0, 0xD0, 0xD0, 0xD0, 0xD0, 0xD0, 0xD0, 0xD0, 
-       0xD0, 0xD0, 0xD0, 0xD0, 0xD0, 0xD0, 0xD1, 0xD1, 0xD1, 0xD1, 0xD1, 0xD1, 0xD1, 0xD1, 0xD1, 0xD1, 
-       0xD1, 0xD1, 0xD1, 0xD2, 0xD2, 0xD2, 0xD2, 0xD2, 0xD2, 0xD2, 0xD2, 0xD2, 0xD2, 0xD2, 0xD2, 0xD2, 
-       0xD3, 0xD3, 0xD3, 0xD3, 0xD3, 0xD3, 0xD3, 0xD3, 0xD3, 0xD3, 0xD3, 0xD3, 0xD3, 0xD4, 0xD4, 0xD4, 
-       0xD4, 0xD4, 0xD4, 0xD4, 0xD4, 0xD4, 0xD4, 0xD4, 0xD4, 0xD4, 0xD5, 0xD5, 0xD5, 0xD5, 0xD5, 0xD5, 
-       0xD5, 0xD5, 0xD5, 0xD5, 0xD5, 0xD5, 0xD5, 0xD5, 0xD6, 0xD6, 0xD6, 0xD6, 0xD6, 0xD6, 0xD6, 0xD6, 
-       0xD6, 0xD6, 0xD6, 0xD6, 0xD6, 0xD7, 0xD7, 0xD7, 0xD7, 0xD7, 0xD7, 0xD7, 0xD7, 0xD7, 0xD7, 0xD7, 
-       0xD7, 0xD7, 0xD8, 0xD8, 0xD8, 0xD8, 0xD8, 0xD8, 0xD8, 0xD8, 0xD8, 0xD8, 0xD8, 0xD8, 0xD8, 0xD8, 
-       0xD9, 0xD9, 0xD9, 0xD9, 0xD9, 0xD9, 0xD9, 0xD9, 0xD9, 0xD9, 0xD9, 0xD9, 0xD9, 0xD9, 0xDA, 0xDA, 
-       0xDA, 0xDA, 0xDA, 0xDA, 0xDA, 0xDA, 0xDA, 0xDA, 0xDA, 0xDA, 0xDA, 0xDB, 0xDB, 0xDB, 0xDB, 0xDB, 
-       0xDB, 0xDB, 0xDB, 0xDB, 0xDB, 0xDB, 0xDB, 0xDB, 0xDB, 0xDC, 0xDC, 0xDC, 0xDC, 0xDC, 0xDC, 0xDC, 
-       0xDC, 0xDC, 0xDC, 0xDC, 0xDC, 0xDC, 0xDC, 0xDD, 0xDD, 0xDD, 0xDD, 0xDD, 0xDD, 0xDD, 0xDD, 0xDD, 
-       0xDD, 0xDD, 0xDD, 0xDD, 0xDD, 0xDE, 0xDE, 0xDE, 0xDE, 0xDE, 0xDE, 0xDE, 0xDE, 0xDE, 0xDE, 0xDE, 
-       0xDE, 0xDE, 0xDE, 0xDF, 0xDF, 0xDF, 0xDF, 0xDF, 0xDF, 0xDF, 0xDF, 0xDF, 0xDF, 0xDF, 0xDF, 0xDF, 
-       0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE1, 
-       0xE1, 0xE1, 0xE1, 0xE1, 0xE1, 0xE1, 0xE1, 0xE1, 0xE1, 0xE1, 0xE1, 0xE1, 0xE1, 0xE2, 0xE2, 0xE2, 
-       0xE2, 0xE2, 0xE2, 0xE2, 0xE2, 0xE2, 0xE2, 0xE2, 0xE2, 0xE2, 0xE2, 0xE3, 0xE3, 0xE3, 0xE3, 0xE3, 
-       0xE3, 0xE3, 0xE3, 0xE3, 0xE3, 0xE3, 0xE3, 0xE3, 0xE3, 0xE4, 0xE4, 0xE4, 0xE4, 0xE4, 0xE4, 0xE4, 
-       0xE4, 0xE4, 0xE4, 0xE4, 0xE4, 0xE4, 0xE4, 0xE5, 0xE5, 0xE5, 0xE5, 0xE5, 0xE5, 0xE5, 0xE5, 0xE5, 
-       0xE5, 0xE5, 0xE5, 0xE5, 0xE5, 0xE5, 0xE6, 0xE6, 0xE6, 0xE6, 0xE6, 0xE6, 0xE6, 0xE6, 0xE6, 0xE6, 
-       0xE6, 0xE6, 0xE6, 0xE6, 0xE7, 0xE7, 0xE7, 0xE7, 0xE7, 0xE7, 0xE7, 0xE7, 0xE7, 0xE7, 0xE7, 0xE7, 
-       0xE7, 0xE7, 0xE8, 0xE8, 0xE8, 0xE8, 0xE8, 0xE8, 0xE8, 0xE8, 0xE8, 0xE8, 0xE8, 0xE8, 0xE8, 0xE8, 
-       0xE8, 0xE9, 0xE9, 0xE9, 0xE9, 0xE9, 0xE9, 0xE9, 0xE9, 0xE9, 0xE9, 0xE9, 0xE9, 0xE9, 0xE9, 0xE9, 
-       0xEA, 0xEA, 0xEA, 0xEA, 0xEA, 0xEA, 0xEA, 0xEA, 0xEA, 0xEA, 0xEA, 0xEA, 0xEA, 0xEA, 0xEB, 0xEB, 
-       0xEB, 0xEB, 0xEB, 0xEB, 0xEB, 0xEB, 0xEB, 0xEB, 0xEB, 0xEB, 0xEB, 0xEB, 0xEB, 0xEC, 0xEC, 0xEC, 
-       0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xED, 0xED, 0xED, 0xED, 
-       0xED, 0xED, 0xED, 0xED, 0xED, 0xED, 0xED, 0xED, 0xED, 0xED, 0xED, 0xEE, 0xEE, 0xEE, 0xEE, 0xEE, 
-       0xEE, 0xEE, 0xEE, 0xEE, 0xEE, 0xEE, 0xEE, 0xEE, 0xEE, 0xEE, 0xEF, 0xEF, 0xEF, 0xEF, 0xEF, 0xEF, 
-       0xEF, 0xEF, 0xEF, 0xEF, 0xEF, 0xEF, 0xEF, 0xEF, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 
-       0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF1, 0xF1, 0xF1, 0xF1, 0xF1, 0xF1, 0xF1, 0xF1, 
-       0xF1, 0xF1, 0xF1, 0xF1, 0xF1, 0xF1, 0xF1, 0xF2, 0xF2, 0xF2, 0xF2, 0xF2, 0xF2, 0xF2, 0xF2, 0xF2, 
-       0xF2, 0xF2, 0xF2, 0xF2, 0xF2, 0xF2, 0xF3, 0xF3, 0xF3, 0xF3, 0xF3, 0xF3, 0xF3, 0xF3, 0xF3, 0xF3, 
-       0xF3, 0xF3, 0xF3, 0xF3, 0xF3, 0xF4, 0xF4, 0xF4, 0xF4, 0xF4, 0xF4, 0xF4, 0xF4, 0xF4, 0xF4, 0xF4, 
-       0xF4, 0xF4, 0xF4, 0xF4, 0xF5, 0xF5, 0xF5, 0xF5, 0xF5, 0xF5, 0xF5, 0xF5, 0xF5, 0xF5, 0xF5, 0xF5, 
-       0xF5, 0xF5, 0xF5, 0xF5, 0xF6, 0xF6, 0xF6, 0xF6, 0xF6, 0xF6, 0xF6, 0xF6, 0xF6, 0xF6, 0xF6, 0xF6, 
-       0xF6, 0xF6, 0xF6, 0xF7, 0xF7, 0xF7, 0xF7, 0xF7, 0xF7, 0xF7, 0xF7, 0xF7, 0xF7, 0xF7, 0xF7, 0xF7, 
-       0xF7, 0xF7, 0xF8, 0xF8, 0xF8, 0xF8, 0xF8, 0xF8, 0xF8, 0xF8, 0xF8, 0xF8, 0xF8, 0xF8, 0xF8, 0xF8, 
-       0xF8, 0xF8, 0xF9, 0xF9, 0xF9, 0xF9, 0xF9, 0xF9, 0xF9, 0xF9, 0xF9, 0xF9, 0xF9, 0xF9, 0xF9, 0xF9, 
-       0xF9, 0xF9, 0xFA, 0xFA, 0xFA, 0xFA, 0xFA, 0xFA, 0xFA, 0xFA, 0xFA, 0xFA, 0xFA, 0xFA, 0xFA, 0xFA, 
-       0xFA, 0xFB, 0xFB, 0xFB, 0xFB, 0xFB, 0xFB, 0xFB, 0xFB, 0xFB, 0xFB, 0xFB, 0xFB, 0xFB, 0xFB, 0xFB, 
-       0xFB, 0xFC, 0xFC, 0xFC, 0xFC, 0xFC, 0xFC, 0xFC, 0xFC, 0xFC, 0xFC, 0xFC, 0xFC, 0xFC, 0xFC, 0xFC, 
-       0xFC, 0xFD, 0xFD, 0xFD, 0xFD, 0xFD, 0xFD, 0xFD, 0xFD, 0xFD, 0xFD, 0xFD, 0xFD, 0xFD, 0xFD, 0xFD, 
-       0xFD, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 
-       0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF
+    0x00, 0x05, 0x08, 0x09, 0x0B, 0x0C, 0x0D, 0x0E, 0x10, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x15, 
+    0x16, 0x17, 0x18, 0x18, 0x19, 0x19, 0x1A, 0x1B, 0x1B, 0x1C, 0x1C, 0x1D, 0x1D, 0x1E, 0x1E, 0x1F, 
+    0x20, 0x20, 0x20, 0x21, 0x21, 0x22, 0x22, 0x23, 0x23, 0x24, 0x24, 0x25, 0x25, 0x25, 0x26, 0x26, 
+    0x27, 0x27, 0x28, 0x28, 0x28, 0x29, 0x29, 0x29, 0x2A, 0x2A, 0x2B, 0x2B, 0x2B, 0x2C, 0x2C, 0x2C, 
+    0x2D, 0x2D, 0x2D, 0x2E, 0x2E, 0x2E, 0x2F, 0x2F, 0x30, 0x30, 0x30, 0x30, 0x31, 0x31, 0x31, 0x32, 
+    0x32, 0x32, 0x33, 0x33, 0x33, 0x34, 0x34, 0x34, 0x35, 0x35, 0x35, 0x35, 0x36, 0x36, 0x36, 0x37, 
+    0x37, 0x37, 0x38, 0x38, 0x38, 0x38, 0x39, 0x39, 0x39, 0x39, 0x3A, 0x3A, 0x3A, 0x3B, 0x3B, 0x3B, 
+    0x3B, 0x3C, 0x3C, 0x3C, 0x3C, 0x3D, 0x3D, 0x3D, 0x3D, 0x3E, 0x3E, 0x3E, 0x3E, 0x3F, 0x3F, 0x3F, 
+    0x40, 0x40, 0x40, 0x40, 0x40, 0x41, 0x41, 0x41, 0x41, 0x42, 0x42, 0x42, 0x42, 0x43, 0x43, 0x43, 
+    0x43, 0x44, 0x44, 0x44, 0x44, 0x45, 0x45, 0x45, 0x45, 0x45, 0x46, 0x46, 0x46, 0x46, 0x47, 0x47, 
+    0x47, 0x47, 0x48, 0x48, 0x48, 0x48, 0x48, 0x49, 0x49, 0x49, 0x49, 0x49, 0x4A, 0x4A, 0x4A, 0x4A, 
+    0x4B, 0x4B, 0x4B, 0x4B, 0x4B, 0x4C, 0x4C, 0x4C, 0x4C, 0x4C, 0x4D, 0x4D, 0x4D, 0x4D, 0x4D, 0x4E, 
+    0x4E, 0x4E, 0x4E, 0x4E, 0x4F, 0x4F, 0x4F, 0x4F, 0x50, 0x50, 0x50, 0x50, 0x50, 0x50, 0x51, 0x51, 
+    0x51, 0x51, 0x51, 0x52, 0x52, 0x52, 0x52, 0x52, 0x53, 0x53, 0x53, 0x53, 0x53, 0x54, 0x54, 0x54, 
+    0x54, 0x54, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x56, 0x56, 0x56, 0x56, 0x56, 0x57, 0x57, 0x57, 
+    0x57, 0x57, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x5A, 0x5A, 
+    0x5A, 0x5A, 0x5A, 0x5B, 0x5B, 0x5B, 0x5B, 0x5B, 0x5B, 0x5C, 0x5C, 0x5C, 0x5C, 0x5C, 0x5C, 0x5D, 
+    0x5D, 0x5D, 0x5D, 0x5D, 0x5D, 0x5E, 0x5E, 0x5E, 0x5E, 0x5E, 0x5E, 0x5F, 0x5F, 0x5F, 0x5F, 0x5F, 
+    0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x61, 0x61, 0x61, 0x61, 0x61, 0x61, 0x62, 0x62, 0x62, 
+    0x62, 0x62, 0x62, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x64, 0x64, 0x64, 0x64, 0x64, 0x64, 0x65, 
+    0x65, 0x65, 0x65, 0x65, 0x65, 0x65, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x67, 0x67, 0x67, 0x67, 
+    0x67, 0x67, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x69, 0x69, 0x69, 0x69, 0x69, 0x69, 0x69, 
+    0x6A, 0x6A, 0x6A, 0x6A, 0x6A, 0x6A, 0x6B, 0x6B, 0x6B, 0x6B, 0x6B, 0x6B, 0x6B, 0x6C, 0x6C, 0x6C, 
+    0x6C, 0x6C, 0x6C, 0x6C, 0x6D, 0x6D, 0x6D, 0x6D, 0x6D, 0x6D, 0x6D, 0x6E, 0x6E, 0x6E, 0x6E, 0x6E, 
+    0x6E, 0x6E, 0x6F, 0x6F, 0x6F, 0x6F, 0x6F, 0x6F, 0x70, 0x70, 0x70, 0x70, 0x70, 0x70, 0x70, 0x70, 
+    0x71, 0x71, 0x71, 0x71, 0x71, 0x71, 0x71, 0x72, 0x72, 0x72, 0x72, 0x72, 0x72, 0x72, 0x73, 0x73, 
+    0x73, 0x73, 0x73, 0x73, 0x73, 0x74, 0x74, 0x74, 0x74, 0x74, 0x74, 0x74, 0x75, 0x75, 0x75, 0x75, 
+    0x75, 0x75, 0x75, 0x75, 0x76, 0x76, 0x76, 0x76, 0x76, 0x76, 0x76, 0x77, 0x77, 0x77, 0x77, 0x77, 
+    0x77, 0x77, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x78, 0x79, 0x79, 0x79, 0x79, 0x79, 0x79, 
+    0x79, 0x79, 0x7A, 0x7A, 0x7A, 0x7A, 0x7A, 0x7A, 0x7A, 0x7B, 0x7B, 0x7B, 0x7B, 0x7B, 0x7B, 0x7B, 
+    0x7B, 0x7C, 0x7C, 0x7C, 0x7C, 0x7C, 0x7C, 0x7C, 0x7C, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 
+    0x7D, 0x7E, 0x7E, 0x7E, 0x7E, 0x7E, 0x7E, 0x7E, 0x7E, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 
+    0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 
+    0x81, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 
+    0x83, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 
+    0x85, 0x85, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 
+    0x87, 0x87, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x89, 0x89, 0x89, 0x89, 0x89, 
+    0x89, 0x89, 0x89, 0x89, 0x8A, 0x8A, 0x8A, 0x8A, 0x8A, 0x8A, 0x8A, 0x8A, 0x8B, 0x8B, 0x8B, 0x8B, 
+    0x8B, 0x8B, 0x8B, 0x8B, 0x8B, 0x8C, 0x8C, 0x8C, 0x8C, 0x8C, 0x8C, 0x8C, 0x8C, 0x8C, 0x8D, 0x8D, 
+    0x8D, 0x8D, 0x8D, 0x8D, 0x8D, 0x8D, 0x8D, 0x8E, 0x8E, 0x8E, 0x8E, 0x8E, 0x8E, 0x8E, 0x8E, 0x8E, 
+    0x8F, 0x8F, 0x8F, 0x8F, 0x8F, 0x8F, 0x8F, 0x8F, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 
+    0x90, 0x90, 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 0x92, 0x92, 0x92, 0x92, 0x92, 
+    0x92, 0x92, 0x92, 0x92, 0x93, 0x93, 0x93, 0x93, 0x93, 0x93, 0x93, 0x93, 0x93, 0x94, 0x94, 0x94, 
+    0x94, 0x94, 0x94, 0x94, 0x94, 0x94, 0x95, 0x95, 0x95, 0x95, 0x95, 0x95, 0x95, 0x95, 0x95, 0x95, 
+    0x96, 0x96, 0x96, 0x96, 0x96, 0x96, 0x96, 0x96, 0x96, 0x97, 0x97, 0x97, 0x97, 0x97, 0x97, 0x97, 
+    0x97, 0x97, 0x98, 0x98, 0x98, 0x98, 0x98, 0x98, 0x98, 0x98, 0x98, 0x98, 0x99, 0x99, 0x99, 0x99, 
+    0x99, 0x99, 0x99, 0x99, 0x99, 0x99, 0x9A, 0x9A, 0x9A, 0x9A, 0x9A, 0x9A, 0x9A, 0x9A, 0x9A, 0x9B, 
+    0x9B, 0x9B, 0x9B, 0x9B, 0x9B, 0x9B, 0x9B, 0x9B, 0x9B, 0x9C, 0x9C, 0x9C, 0x9C, 0x9C, 0x9C, 0x9C, 
+    0x9C, 0x9C, 0x9C, 0x9D, 0x9D, 0x9D, 0x9D, 0x9D, 0x9D, 0x9D, 0x9D, 0x9D, 0x9D, 0x9E, 0x9E, 0x9E, 
+    0x9E, 0x9E, 0x9E, 0x9E, 0x9E, 0x9E, 0x9E, 0x9F, 0x9F, 0x9F, 0x9F, 0x9F, 0x9F, 0x9F, 0x9F, 0x9F, 
+    0xA0, 0xA0, 0xA0, 0xA0, 0xA0, 0xA0, 0xA0, 0xA0, 0xA0, 0xA0, 0xA0, 0xA1, 0xA1, 0xA1, 0xA1, 0xA1, 
+    0xA1, 0xA1, 0xA1, 0xA1, 0xA1, 0xA2, 0xA2, 0xA2, 0xA2, 0xA2, 0xA2, 0xA2, 0xA2, 0xA2, 0xA2, 0xA3, 
+    0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA4, 0xA4, 0xA4, 0xA4, 0xA4, 0xA4, 0xA4, 
+    0xA4, 0xA4, 0xA4, 0xA5, 0xA5, 0xA5, 0xA5, 0xA5, 0xA5, 0xA5, 0xA5, 0xA5, 0xA5, 0xA5, 0xA6, 0xA6, 
+    0xA6, 0xA6, 0xA6, 0xA6, 0xA6, 0xA6, 0xA6, 0xA6, 0xA7, 0xA7, 0xA7, 0xA7, 0xA7, 0xA7, 0xA7, 0xA7, 
+    0xA7, 0xA7, 0xA8, 0xA8, 0xA8, 0xA8, 0xA8, 0xA8, 0xA8, 0xA8, 0xA8, 0xA8, 0xA8, 0xA9, 0xA9, 0xA9, 
+    0xA9, 0xA9, 0xA9, 0xA9, 0xA9, 0xA9, 0xA9, 0xA9, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 
+    0xAA, 0xAA, 0xAB, 0xAB, 0xAB, 0xAB, 0xAB, 0xAB, 0xAB, 0xAB, 0xAB, 0xAB, 0xAB, 0xAC, 0xAC, 0xAC, 
+    0xAC, 0xAC, 0xAC, 0xAC, 0xAC, 0xAC, 0xAC, 0xAC, 0xAD, 0xAD, 0xAD, 0xAD, 0xAD, 0xAD, 0xAD, 0xAD, 
+    0xAD, 0xAD, 0xAD, 0xAE, 0xAE, 0xAE, 0xAE, 0xAE, 0xAE, 0xAE, 0xAE, 0xAE, 0xAE, 0xAE, 0xAF, 0xAF, 
+    0xAF, 0xAF, 0xAF, 0xAF, 0xAF, 0xAF, 0xAF, 0xAF, 0xB0, 0xB0, 0xB0, 0xB0, 0xB0, 0xB0, 0xB0, 0xB0, 
+    0xB0, 0xB0, 0xB0, 0xB0, 0xB1, 0xB1, 0xB1, 0xB1, 0xB1, 0xB1, 0xB1, 0xB1, 0xB1, 0xB1, 0xB1, 0xB2, 
+    0xB2, 0xB2, 0xB2, 0xB2, 0xB2, 0xB2, 0xB2, 0xB2, 0xB2, 0xB2, 0xB3, 0xB3, 0xB3, 0xB3, 0xB3, 0xB3, 
+    0xB3, 0xB3, 0xB3, 0xB3, 0xB3, 0xB4, 0xB4, 0xB4, 0xB4, 0xB4, 0xB4, 0xB4, 0xB4, 0xB4, 0xB4, 0xB4, 
+    0xB5, 0xB5, 0xB5, 0xB5, 0xB5, 0xB5, 0xB5, 0xB5, 0xB5, 0xB5, 0xB5, 0xB5, 0xB6, 0xB6, 0xB6, 0xB6, 
+    0xB6, 0xB6, 0xB6, 0xB6, 0xB6, 0xB6, 0xB6, 0xB7, 0xB7, 0xB7, 0xB7, 0xB7, 0xB7, 0xB7, 0xB7, 0xB7, 
+    0xB7, 0xB7, 0xB8, 0xB8, 0xB8, 0xB8, 0xB8, 0xB8, 0xB8, 0xB8, 0xB8, 0xB8, 0xB8, 0xB8, 0xB9, 0xB9, 
+    0xB9, 0xB9, 0xB9, 0xB9, 0xB9, 0xB9, 0xB9, 0xB9, 0xB9, 0xB9, 0xBA, 0xBA, 0xBA, 0xBA, 0xBA, 0xBA, 
+    0xBA, 0xBA, 0xBA, 0xBA, 0xBA, 0xBB, 0xBB, 0xBB, 0xBB, 0xBB, 0xBB, 0xBB, 0xBB, 0xBB, 0xBB, 0xBB, 
+    0xBB, 0xBC, 0xBC, 0xBC, 0xBC, 0xBC, 0xBC, 0xBC, 0xBC, 0xBC, 0xBC, 0xBC, 0xBC, 0xBD, 0xBD, 0xBD, 
+    0xBD, 0xBD, 0xBD, 0xBD, 0xBD, 0xBD, 0xBD, 0xBD, 0xBD, 0xBE, 0xBE, 0xBE, 0xBE, 0xBE, 0xBE, 0xBE, 
+    0xBE, 0xBE, 0xBE, 0xBE, 0xBE, 0xBF, 0xBF, 0xBF, 0xBF, 0xBF, 0xBF, 0xBF, 0xBF, 0xBF, 0xBF, 0xBF, 
+    0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC1, 0xC1, 0xC1, 
+    0xC1, 0xC1, 0xC1, 0xC1, 0xC1, 0xC1, 0xC1, 0xC1, 0xC1, 0xC2, 0xC2, 0xC2, 0xC2, 0xC2, 0xC2, 0xC2, 
+    0xC2, 0xC2, 0xC2, 0xC2, 0xC2, 0xC3, 0xC3, 0xC3, 0xC3, 0xC3, 0xC3, 0xC3, 0xC3, 0xC3, 0xC3, 0xC3, 
+    0xC3, 0xC4, 0xC4, 0xC4, 0xC4, 0xC4, 0xC4, 0xC4, 0xC4, 0xC4, 0xC4, 0xC4, 0xC4, 0xC5, 0xC5, 0xC5, 
+    0xC5, 0xC5, 0xC5, 0xC5, 0xC5, 0xC5, 0xC5, 0xC5, 0xC5, 0xC5, 0xC6, 0xC6, 0xC6, 0xC6, 0xC6, 0xC6, 
+    0xC6, 0xC6, 0xC6, 0xC6, 0xC6, 0xC6, 0xC7, 0xC7, 0xC7, 0xC7, 0xC7, 0xC7, 0xC7, 0xC7, 0xC7, 0xC7, 
+    0xC7, 0xC7, 0xC8, 0xC8, 0xC8, 0xC8, 0xC8, 0xC8, 0xC8, 0xC8, 0xC8, 0xC8, 0xC8, 0xC8, 0xC8, 0xC9, 
+    0xC9, 0xC9, 0xC9, 0xC9, 0xC9, 0xC9, 0xC9, 0xC9, 0xC9, 0xC9, 0xC9, 0xC9, 0xCA, 0xCA, 0xCA, 0xCA, 
+    0xCA, 0xCA, 0xCA, 0xCA, 0xCA, 0xCA, 0xCA, 0xCA, 0xCB, 0xCB, 0xCB, 0xCB, 0xCB, 0xCB, 0xCB, 0xCB, 
+    0xCB, 0xCB, 0xCB, 0xCB, 0xCB, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 
+    0xCC, 0xCC, 0xCD, 0xCD, 0xCD, 0xCD, 0xCD, 0xCD, 0xCD, 0xCD, 0xCD, 0xCD, 0xCD, 0xCD, 0xCD, 0xCE, 
+    0xCE, 0xCE, 0xCE, 0xCE, 0xCE, 0xCE, 0xCE, 0xCE, 0xCE, 0xCE, 0xCE, 0xCE, 0xCF, 0xCF, 0xCF, 0xCF, 
+    0xCF, 0xCF, 0xCF, 0xCF, 0xCF, 0xCF, 0xCF, 0xCF, 0xD0, 0xD0, 0xD0, 0xD0, 0xD0, 0xD0, 0xD0, 0xD0, 
+    0xD0, 0xD0, 0xD0, 0xD0, 0xD0, 0xD0, 0xD1, 0xD1, 0xD1, 0xD1, 0xD1, 0xD1, 0xD1, 0xD1, 0xD1, 0xD1, 
+    0xD1, 0xD1, 0xD1, 0xD2, 0xD2, 0xD2, 0xD2, 0xD2, 0xD2, 0xD2, 0xD2, 0xD2, 0xD2, 0xD2, 0xD2, 0xD2, 
+    0xD3, 0xD3, 0xD3, 0xD3, 0xD3, 0xD3, 0xD3, 0xD3, 0xD3, 0xD3, 0xD3, 0xD3, 0xD3, 0xD4, 0xD4, 0xD4, 
+    0xD4, 0xD4, 0xD4, 0xD4, 0xD4, 0xD4, 0xD4, 0xD4, 0xD4, 0xD4, 0xD5, 0xD5, 0xD5, 0xD5, 0xD5, 0xD5, 
+    0xD5, 0xD5, 0xD5, 0xD5, 0xD5, 0xD5, 0xD5, 0xD5, 0xD6, 0xD6, 0xD6, 0xD6, 0xD6, 0xD6, 0xD6, 0xD6, 
+    0xD6, 0xD6, 0xD6, 0xD6, 0xD6, 0xD7, 0xD7, 0xD7, 0xD7, 0xD7, 0xD7, 0xD7, 0xD7, 0xD7, 0xD7, 0xD7, 
+    0xD7, 0xD7, 0xD8, 0xD8, 0xD8, 0xD8, 0xD8, 0xD8, 0xD8, 0xD8, 0xD8, 0xD8, 0xD8, 0xD8, 0xD8, 0xD8, 
+    0xD9, 0xD9, 0xD9, 0xD9, 0xD9, 0xD9, 0xD9, 0xD9, 0xD9, 0xD9, 0xD9, 0xD9, 0xD9, 0xD9, 0xDA, 0xDA, 
+    0xDA, 0xDA, 0xDA, 0xDA, 0xDA, 0xDA, 0xDA, 0xDA, 0xDA, 0xDA, 0xDA, 0xDB, 0xDB, 0xDB, 0xDB, 0xDB, 
+    0xDB, 0xDB, 0xDB, 0xDB, 0xDB, 0xDB, 0xDB, 0xDB, 0xDB, 0xDC, 0xDC, 0xDC, 0xDC, 0xDC, 0xDC, 0xDC, 
+    0xDC, 0xDC, 0xDC, 0xDC, 0xDC, 0xDC, 0xDC, 0xDD, 0xDD, 0xDD, 0xDD, 0xDD, 0xDD, 0xDD, 0xDD, 0xDD, 
+    0xDD, 0xDD, 0xDD, 0xDD, 0xDD, 0xDE, 0xDE, 0xDE, 0xDE, 0xDE, 0xDE, 0xDE, 0xDE, 0xDE, 0xDE, 0xDE, 
+    0xDE, 0xDE, 0xDE, 0xDF, 0xDF, 0xDF, 0xDF, 0xDF, 0xDF, 0xDF, 0xDF, 0xDF, 0xDF, 0xDF, 0xDF, 0xDF, 
+    0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE1, 
+    0xE1, 0xE1, 0xE1, 0xE1, 0xE1, 0xE1, 0xE1, 0xE1, 0xE1, 0xE1, 0xE1, 0xE1, 0xE1, 0xE2, 0xE2, 0xE2, 
+    0xE2, 0xE2, 0xE2, 0xE2, 0xE2, 0xE2, 0xE2, 0xE2, 0xE2, 0xE2, 0xE2, 0xE3, 0xE3, 0xE3, 0xE3, 0xE3, 
+    0xE3, 0xE3, 0xE3, 0xE3, 0xE3, 0xE3, 0xE3, 0xE3, 0xE3, 0xE4, 0xE4, 0xE4, 0xE4, 0xE4, 0xE4, 0xE4, 
+    0xE4, 0xE4, 0xE4, 0xE4, 0xE4, 0xE4, 0xE4, 0xE5, 0xE5, 0xE5, 0xE5, 0xE5, 0xE5, 0xE5, 0xE5, 0xE5, 
+    0xE5, 0xE5, 0xE5, 0xE5, 0xE5, 0xE5, 0xE6, 0xE6, 0xE6, 0xE6, 0xE6, 0xE6, 0xE6, 0xE6, 0xE6, 0xE6, 
+    0xE6, 0xE6, 0xE6, 0xE6, 0xE7, 0xE7, 0xE7, 0xE7, 0xE7, 0xE7, 0xE7, 0xE7, 0xE7, 0xE7, 0xE7, 0xE7, 
+    0xE7, 0xE7, 0xE8, 0xE8, 0xE8, 0xE8, 0xE8, 0xE8, 0xE8, 0xE8, 0xE8, 0xE8, 0xE8, 0xE8, 0xE8, 0xE8, 
+    0xE8, 0xE9, 0xE9, 0xE9, 0xE9, 0xE9, 0xE9, 0xE9, 0xE9, 0xE9, 0xE9, 0xE9, 0xE9, 0xE9, 0xE9, 0xE9, 
+    0xEA, 0xEA, 0xEA, 0xEA, 0xEA, 0xEA, 0xEA, 0xEA, 0xEA, 0xEA, 0xEA, 0xEA, 0xEA, 0xEA, 0xEB, 0xEB, 
+    0xEB, 0xEB, 0xEB, 0xEB, 0xEB, 0xEB, 0xEB, 0xEB, 0xEB, 0xEB, 0xEB, 0xEB, 0xEB, 0xEC, 0xEC, 0xEC, 
+    0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xED, 0xED, 0xED, 0xED, 
+    0xED, 0xED, 0xED, 0xED, 0xED, 0xED, 0xED, 0xED, 0xED, 0xED, 0xED, 0xEE, 0xEE, 0xEE, 0xEE, 0xEE, 
+    0xEE, 0xEE, 0xEE, 0xEE, 0xEE, 0xEE, 0xEE, 0xEE, 0xEE, 0xEE, 0xEF, 0xEF, 0xEF, 0xEF, 0xEF, 0xEF, 
+    0xEF, 0xEF, 0xEF, 0xEF, 0xEF, 0xEF, 0xEF, 0xEF, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 
+    0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF1, 0xF1, 0xF1, 0xF1, 0xF1, 0xF1, 0xF1, 0xF1, 
+    0xF1, 0xF1, 0xF1, 0xF1, 0xF1, 0xF1, 0xF1, 0xF2, 0xF2, 0xF2, 0xF2, 0xF2, 0xF2, 0xF2, 0xF2, 0xF2, 
+    0xF2, 0xF2, 0xF2, 0xF2, 0xF2, 0xF2, 0xF3, 0xF3, 0xF3, 0xF3, 0xF3, 0xF3, 0xF3, 0xF3, 0xF3, 0xF3, 
+    0xF3, 0xF3, 0xF3, 0xF3, 0xF3, 0xF4, 0xF4, 0xF4, 0xF4, 0xF4, 0xF4, 0xF4, 0xF4, 0xF4, 0xF4, 0xF4, 
+    0xF4, 0xF4, 0xF4, 0xF4, 0xF5, 0xF5, 0xF5, 0xF5, 0xF5, 0xF5, 0xF5, 0xF5, 0xF5, 0xF5, 0xF5, 0xF5, 
+    0xF5, 0xF5, 0xF5, 0xF5, 0xF6, 0xF6, 0xF6, 0xF6, 0xF6, 0xF6, 0xF6, 0xF6, 0xF6, 0xF6, 0xF6, 0xF6, 
+    0xF6, 0xF6, 0xF6, 0xF7, 0xF7, 0xF7, 0xF7, 0xF7, 0xF7, 0xF7, 0xF7, 0xF7, 0xF7, 0xF7, 0xF7, 0xF7, 
+    0xF7, 0xF7, 0xF8, 0xF8, 0xF8, 0xF8, 0xF8, 0xF8, 0xF8, 0xF8, 0xF8, 0xF8, 0xF8, 0xF8, 0xF8, 0xF8, 
+    0xF8, 0xF8, 0xF9, 0xF9, 0xF9, 0xF9, 0xF9, 0xF9, 0xF9, 0xF9, 0xF9, 0xF9, 0xF9, 0xF9, 0xF9, 0xF9, 
+    0xF9, 0xF9, 0xFA, 0xFA, 0xFA, 0xFA, 0xFA, 0xFA, 0xFA, 0xFA, 0xFA, 0xFA, 0xFA, 0xFA, 0xFA, 0xFA, 
+    0xFA, 0xFB, 0xFB, 0xFB, 0xFB, 0xFB, 0xFB, 0xFB, 0xFB, 0xFB, 0xFB, 0xFB, 0xFB, 0xFB, 0xFB, 0xFB, 
+    0xFB, 0xFC, 0xFC, 0xFC, 0xFC, 0xFC, 0xFC, 0xFC, 0xFC, 0xFC, 0xFC, 0xFC, 0xFC, 0xFC, 0xFC, 0xFC, 
+    0xFC, 0xFD, 0xFD, 0xFD, 0xFD, 0xFD, 0xFD, 0xFD, 0xFD, 0xFD, 0xFD, 0xFD, 0xFD, 0xFD, 0xFD, 0xFD, 
+    0xFD, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 
+    0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF
 };
index cf8f047..5c9c73d 100644 (file)
@@ -1,19 +1,36 @@
+/* libs/graphics/effects/SkShaderExtras.cpp
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #include "SkShader.h"
 #include "SkColorFilter.h"
 #include "SkShaderExtras.h"
 
 //////////////////////////////////////////////////////////////////////////////////////
     
-SkComposeShader::SkComposeShader(SkShader* sA, SkShader* sB, SkColorCombine* combine)
+SkComposeShader::SkComposeShader(SkShader* sA, SkShader* sB, SkColorComposer* composer)
 {
-    fShaderA = sA;      sA->ref();
-    fShaderB = sB;      sB->ref();
-    fCombine = combine; combine->ref();
+    fShaderA = sA;          sA->ref();
+    fShaderB = sB;          sB->ref();
+    fComposer = composer;   composer->ref();
 }
 
 SkComposeShader::~SkComposeShader()
 {
-    fCombine->unref();
+    fComposer->unref();
     fShaderB->unref();
     fShaderA->unref();
 }
@@ -22,16 +39,33 @@ bool SkComposeShader::setContext(const SkBitmap& device,
                                  const SkPaint& paint,
                                  const SkMatrix& matrix)
 {
-    return  this->INHERITED::setContext(device, paint, matrix) &&
-            fShaderA->setContext(device, paint, matrix) &&
-            fShaderA->setContext(device, paint, matrix);
+    if (!this->INHERITED::setContext(device, paint, matrix))
+        return false;
+
+    // we preconcat our localMatrix (if any) with the device matrix
+    // before calling our sub-shaders
+
+    const SkMatrix* localM = this->getLocalMatrix();
+    SkMatrix        storage;
+    const SkMatrix* tmpM;
+    
+    if (NULL == localM)
+        tmpM = &matrix;
+    else
+    {
+        storage.setConcat(matrix, *localM);
+        tmpM = &storage;
+    }
+
+    return  fShaderA->setContext(device, paint, *tmpM) &&
+            fShaderB->setContext(device, paint, *tmpM);
 }
 
 void SkComposeShader::shadeSpan(int x, int y, SkPMColor result[], int count)
 {
     SkShader*       shaderA = fShaderA;
     SkShader*       shaderB = fShaderB;
-    SkColorCombine* combine = fCombine;
+    SkColorComposer* composer = fComposer;
     
     SkPMColor       tmp[COUNT];
     do {
@@ -41,7 +75,7 @@ void SkComposeShader::shadeSpan(int x, int y, SkPMColor result[], int count)
         
         shaderA->shadeSpan(x, y, tmp, n);
         shaderB->shadeSpan(x, y, result, n);
-        combine->combineSpan(tmp, result, n, result);
+        composer->composeSpan(tmp, result, n, result);
         
         result += n;
         x += n;
index a20c9a5..2474d2d 100644 (file)
+/* libs/graphics/effects/SkTransparentShader.cpp
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #include "SkTransparentShader.h"
 #include "SkColorPriv.h"
 
 bool SkTransparentShader::setContext(const SkBitmap& device,
-                                                                        const SkPaint& paint,
-                                                                        const SkMatrix& matrix)
+                                     const SkPaint& paint,
+                                     const SkMatrix& matrix)
 {
-       fDevice = device;
-       fAlpha = paint.getAlpha();
+    fDevice = device;
+    fAlpha = paint.getAlpha();
 
-       return this->INHERITED::setContext(device, paint, matrix);
+    return this->INHERITED::setContext(device, paint, matrix);
 }
 
-U32 SkTransparentShader::getFlags()
+uint32_t SkTransparentShader::getFlags()
 {
-       U32     flags = 0;
+    uint32_t flags = this->INHERITED::getFlags();
 
-       switch (fDevice.getConfig()) {
-       case SkBitmap::kRGB_565_Config:
-               flags |= kHasSpan16_Flag;
-               // fall through
-       case SkBitmap::kARGB_8888_Config:
-               flags |= (fAlpha == 255 ? kOpaqueAlpha_Flag : kConstAlpha_Flag);
-       default:
-               break;
-       }
-       return flags;
+    switch (fDevice.getConfig()) {
+    case SkBitmap::kRGB_565_Config:
+        flags |= kHasSpan16_Flag;
+        if (fAlpha == 255)
+            flags |= kOpaqueAlpha_Flag;
+        break;
+    case SkBitmap::kARGB_8888_Config:
+        if (fAlpha == 255 && fDevice.isOpaque())
+            flags |= kOpaqueAlpha_Flag;
+        break;
+    default:
+        break;
+    }
+    return flags;
 }
 
 void SkTransparentShader::shadeSpan(int x, int y, SkPMColor span[], int count)
 {
-       unsigned scale = SkAlpha255To256(fAlpha);
+    unsigned scale = SkAlpha255To256(fAlpha);
 
-       switch (fDevice.getConfig()) {
-       case SkBitmap::kARGB_8888_Config:
-               if (scale == 256)
-                       memcpy(span, fDevice.getAddr32(x, y), count * sizeof(SkPMColor));
-               else
-               {
-                       const SkPMColor* src = fDevice.getAddr32(x, y);
-                       for (int i = count - 1; i >= 0; --i)
-                               span[i] = SkAlphaMulQ(src[i], scale);
-               }
-               break;
-       case SkBitmap::kRGB_565_Config:
-               {
-                       const U16* src = fDevice.getAddr16(x, y);
-                       if (scale == 256)
-                       {
-                               for (int i = count - 1; i >= 0; --i)
-                                       span[i] = SkPixel16ToPixel32(src[i]);
-                       }
-                       else
-                       {
-                               unsigned alpha = fAlpha;
-                               for (int i = count - 1; i >= 0; --i)
-                               {
-                                       U16              c = src[i];
-                                       unsigned r = SkPacked16ToR32(c);
-                                       unsigned g = SkPacked16ToG32(c);
-                                       unsigned b = SkPacked16ToB32(c);
+    switch (fDevice.getConfig()) {
+    case SkBitmap::kARGB_8888_Config:
+        if (scale == 256)
+            memcpy(span, fDevice.getAddr32(x, y), count * sizeof(SkPMColor));
+        else
+        {
+            const SkPMColor* src = fDevice.getAddr32(x, y);
+            for (int i = count - 1; i >= 0; --i)
+                span[i] = SkAlphaMulQ(src[i], scale);
+        }
+        break;
+    case SkBitmap::kRGB_565_Config:
+        {
+            const U16* src = fDevice.getAddr16(x, y);
+            if (scale == 256)
+            {
+                for (int i = count - 1; i >= 0; --i)
+                    span[i] = SkPixel16ToPixel32(src[i]);
+            }
+            else
+            {
+                unsigned alpha = fAlpha;
+                for (int i = count - 1; i >= 0; --i)
+                {
+                    U16      c = src[i];
+                    unsigned r = SkPacked16ToR32(c);
+                    unsigned g = SkPacked16ToG32(c);
+                    unsigned b = SkPacked16ToB32(c);
 
-                                       span[i] = SkPackARGB32( alpha,
-                                                                                       SkAlphaMul(r, scale),
-                                                                                       SkAlphaMul(g, scale),
-                                                                                       SkAlphaMul(b, scale));
-                               }
-                       }
-               }
-               break;
-       case SkBitmap::kIndex8_Config:
-               SkASSERT(!"index8 not supported as a destination device");
-               break;
-       case SkBitmap::kA8_Config:
-               {
-                       const U8* src = fDevice.getAddr8(x, y);
-                       if (scale == 256)
-                       {
-                               for (int i = count - 1; i >= 0; --i)
-                                       span[i] = SkPackARGB32(src[i], 0, 0, 0);
-                       }
-                       else
-                       {
-                               for (int i = count - 1; i >= 0; --i)
-                                       span[i] = SkPackARGB32(SkAlphaMul(src[i], scale), 0, 0, 0);
-                       }
-               }
-               break;
-       case SkBitmap::kA1_Config:
-               SkASSERT(!"kA1_Config umimplemented at this time");
-               break;
-       default:        // to avoid warnings
-               break;
-       }
+                    span[i] = SkPackARGB32( alpha,
+                                            SkAlphaMul(r, scale),
+                                            SkAlphaMul(g, scale),
+                                            SkAlphaMul(b, scale));
+                }
+            }
+        }
+        break;
+    case SkBitmap::kIndex8_Config:
+        SkASSERT(!"index8 not supported as a destination device");
+        break;
+    case SkBitmap::kA8_Config:
+        {
+            const U8* src = fDevice.getAddr8(x, y);
+            if (scale == 256)
+            {
+                for (int i = count - 1; i >= 0; --i)
+                    span[i] = SkPackARGB32(src[i], 0, 0, 0);
+            }
+            else
+            {
+                for (int i = count - 1; i >= 0; --i)
+                    span[i] = SkPackARGB32(SkAlphaMul(src[i], scale), 0, 0, 0);
+            }
+        }
+        break;
+    case SkBitmap::kA1_Config:
+        SkASSERT(!"kA1_Config umimplemented at this time");
+        break;
+    default:    // to avoid warnings
+        break;
+    }
 }
 
-void SkTransparentShader::shadeSpanOpaque16(int x, int y, U16 span[], int count)
+void SkTransparentShader::shadeSpan16(int x, int y, uint16_t span[], int count)
 {
-       SkASSERT(fAlpha == 255);
-       SkASSERT(fDevice.getConfig() == SkBitmap::kRGB_565_Config);
+    SkASSERT(fDevice.getConfig() == SkBitmap::kRGB_565_Config);
 
-       memcpy(span, fDevice.getAddr16(x, y), count << 1);
+    memcpy(span, fDevice.getAddr16(x, y), count << 1);
 }
 
index 750a841..bda6865 100644 (file)
@@ -1,3 +1,20 @@
+/* libs/graphics/images/SkBitmapRef.cpp
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #include "SkBitmapRefPriv.h"
 #include "SkTemplates.h"
 #include "SkThread.h"
 
 SkGlobals::Rec* SkBitmapRef_Globals::Create()
 {
-       SkBitmapRef_Globals* rec = SkNEW(SkBitmapRef_Globals);
-       rec->fCache = nil;
-       return rec;
+    SkBitmapRef_Globals* rec = SkNEW(SkBitmapRef_Globals);
+    rec->fCache = nil;
+    return rec;
 }
 
 ///////////////////////////////////////////////////////////////////////////////////////////
 
 SkBitmapRef::SkBitmapRef(Rec* rec) : fRec(rec)
 {
-       SkASSERT(rec);
-       rec->fRefCnt += 1;
+    SkASSERT(rec);
+    rec->fRefCnt += 1;
 }
 
 SkBitmapRef::SkBitmapRef(const SkBitmap& src, bool transferOwnsPixels)
@@ -37,7 +54,7 @@ SkBitmapRef::~SkBitmapRef()
     {
         SkBitmapRef_Globals& globals = *(SkBitmapRef_Globals*)SkGlobals::Find(kBitmapRef_GlobalsTag,
                                                                               SkBitmapRef_Globals::Create);
-        SkAutoMutexAcquire     ac(globals.fMutex);
+        SkAutoMutexAcquire  ac(globals.fMutex);
 
         SkASSERT(fRec->fRefCnt > 0);
         fRec->fRefCnt -= 1;
@@ -51,7 +68,7 @@ SkBitmapRef::~SkBitmapRef()
 
 const SkBitmap& SkBitmapRef::bitmap()
 {
-       return fRec->fBM;
+    return fRec->fBM;
 }
 
 ///////////////////////////////////////////////////////////////////////////////////////////
@@ -63,59 +80,59 @@ SkBitmapRef* SkBitmapRef::create(const SkBitmap& src, bool transferOwnsPixels)
 
 void SkBitmapRef::PurgeCacheAll()
 {
-       SkBitmapRef_Globals* globals = (SkBitmapRef_Globals*)SkGlobals::Find(kBitmapRef_GlobalsTag, nil);
-       if (globals == nil)
-               return;
+    SkBitmapRef_Globals* globals = (SkBitmapRef_Globals*)SkGlobals::Find(kBitmapRef_GlobalsTag, nil);
+    if (globals == nil)
+        return;
 
-       SkAutoMutexAcquire      ac(globals->fMutex);
-       SkBitmapRef::Rec*       rec = globals->fCache;
+    SkAutoMutexAcquire  ac(globals->fMutex);
+    SkBitmapRef::Rec*   rec = globals->fCache;
     SkDEBUGCODE(int     count = 0;)
 
-       while (rec)
-       {
+    while (rec)
+    {
         SkDEBUGCODE(count += 1;)
-               SkASSERT(rec->fRefCnt == 0);
-               Rec* next = rec->fNext;
-               SkDELETE(rec);
-               rec = next;
-       }
-       globals->fCache = nil;
+        SkASSERT(rec->fRefCnt == 0);
+        Rec* next = rec->fNext;
+        SkDELETE(rec);
+        rec = next;
+    }
+    globals->fCache = nil;
     
     SkDEBUGF(("PurgeCacheAll freed %d bitmaps\n", count));
 }
 
 bool SkBitmapRef::PurgeCacheOne()
 {
-       SkBitmapRef_Globals* globals = (SkBitmapRef_Globals*)SkGlobals::Find(kBitmapRef_GlobalsTag, nil);
-       if (globals == nil)
-               return false;
+    SkBitmapRef_Globals* globals = (SkBitmapRef_Globals*)SkGlobals::Find(kBitmapRef_GlobalsTag, nil);
+    if (globals == nil)
+        return false;
 
-       SkAutoMutexAcquire      ac(globals->fMutex);
-       SkBitmapRef::Rec*       rec = globals->fCache;
-       SkBitmapRef::Rec*       prev = nil;
+    SkAutoMutexAcquire  ac(globals->fMutex);
+    SkBitmapRef::Rec*   rec = globals->fCache;
+    SkBitmapRef::Rec*   prev = nil;
     SkDEBUGCODE(int     count = 0;)
 
-       while (rec)
-       {
+    while (rec)
+    {
         SkDEBUGCODE(count += 1;)
 
-               SkBitmapRef::Rec* next = rec->fNext;
-               if (rec->fRefCnt == 0)
-               {
-                       if (prev)
-                               prev = next;
-                       else
-                               globals->fCache = next;
+        SkBitmapRef::Rec* next = rec->fNext;
+        if (rec->fRefCnt == 0)
+        {
+            if (prev)
+                prev = next;
+            else
+                globals->fCache = next;
 
             SkDEBUGF(("PurgeCacheOne for bitmap[%d %d]\n", rec->fBM.width(), rec->fBM.height()));
-                       SkDELETE(rec);
-                       return true;
-               }
-               prev = rec;
-               rec = next;
-       }
+            SkDELETE(rec);
+            return true;
+        }
+        prev = rec;
+        rec = next;
+    }
 
     SkDEBUGF(("PurgeCacheOne: nothing to purge from %d bitmaps\n", count));
-       return false;
+    return false;
 }
 
index 24c0a2c..74374a8 100644 (file)
@@ -1,3 +1,20 @@
+/* libs/graphics/images/SkBitmapRefPriv.h
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #ifndef SkBitmapRefPriv_DEFINED
 #define SkBitmapRefPriv_DEFINED
 
 #include "SkBitmap.h"
 #include "SkString.h"
 
-#define kBitmapRef_GlobalsTag  SkSetFourByteTag('s', 'k', 'b', 'r')
+#define kBitmapRef_GlobalsTag   SkSetFourByteTag('s', 'k', 'b', 'r')
 
 class SkBitmapRef_Globals : public SkGlobals::Rec {
 public:
-       SkMutex                         fMutex;
-       SkBitmapRef::Rec*       fCache;
+    SkMutex             fMutex;
+    SkBitmapRef::Rec*   fCache;
     
     static Rec* Create();
 };
@@ -21,10 +38,10 @@ struct SkBitmapRef::Rec {
     Rec(bool isCache): fIsCache(isCache) {}
     Rec(const SkBitmap& src): fBM(src) {}
     
-    Rec*               fNext;
-    int32_t            fRefCnt;
-    SkString   fPath;
-    SkBitmap   fBM;
+    Rec*        fNext;
+    int32_t     fRefCnt;
+    SkString    fPath;
+    SkBitmap    fBM;
     bool        fIsCache;
 };
 
index 7c76bc8..6952b41 100644 (file)
@@ -1,3 +1,20 @@
+/* libs/graphics/images/SkImageDecoder.cpp
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #include "SkImageDecoder.h"
 #include "SkStream.h"
 #include "SkTemplates.h"
@@ -6,62 +23,90 @@ static SkBitmap::Config gDeviceConfig = SkBitmap::kNo_Config;
 
 SkBitmap::Config SkImageDecoder::GetDeviceConfig()
 {
-       return gDeviceConfig;
+    return gDeviceConfig;
 }
 
 void SkImageDecoder::SetDeviceConfig(SkBitmap::Config config)
 {
-       gDeviceConfig = config;
+    gDeviceConfig = config;
 }
 
-SkImageDecoder::SkImageDecoder()
+///////////////////////////////////////////////////////////////////////////////////////////
+
+SkImageDecoder::SkImageDecoder() : fPeeker(NULL), fChooser(NULL)
 {
 }
 
 SkImageDecoder::~SkImageDecoder()
 {
+    fPeeker->safeUnref();
+    fChooser->safeUnref();
+}
+
+SkImageDecoder::Peeker* SkImageDecoder::setPeeker(Peeker* peeker)
+{
+    SkRefCnt_SafeAssign(fPeeker, peeker);
+    return peeker;
+}
+
+SkImageDecoder::Chooser* SkImageDecoder::setChooser(Chooser* chooser)
+{
+    SkRefCnt_SafeAssign(fChooser, chooser);
+    return chooser;
+}
+
+bool SkImageDecoder::chooseFromOneChoice(SkBitmap::Config config, int width, int height) const
+{
+    Chooser* chooser = fChooser;
+
+    if (NULL == chooser)    // no chooser, we just say YES to decoding :)
+        return true;
+
+    chooser->begin(1);
+    chooser->inspect(0, config, width, height);
+    return chooser->choose() == 0;
 }
 
 bool SkImageDecoder::DecodeFile(const char file[], SkBitmap* bm, SkBitmap::Config pref)
 {
-       SkASSERT(file);
-       SkASSERT(bm);
+    SkASSERT(file);
+    SkASSERT(bm);
 
-       SkFILEStream    stream(file);
-       return stream.isValid() && SkImageDecoder::DecodeStream(&stream, bm, pref);
+    SkFILEStream    stream(file);
+    return stream.isValid() && SkImageDecoder::DecodeStream(&stream, bm, pref);
 }
 
 bool SkImageDecoder::DecodeMemory(const void* buffer, size_t size, SkBitmap* bm, SkBitmap::Config pref)
 {
-       SkASSERT(buffer);
+    SkASSERT(buffer);
 
-       SkMemoryStream  stream(buffer, size);
-       return size && SkImageDecoder::DecodeStream(&stream, bm, pref);
+    SkMemoryStream  stream(buffer, size);
+    return size && SkImageDecoder::DecodeStream(&stream, bm, pref);
 }
 
 bool SkImageDecoder::DecodeURL(const char url[], SkBitmap* bm, SkBitmap::Config pref) 
 {
-       SkASSERT(url);
-       SkASSERT(bm);
+    SkASSERT(url);
+    SkASSERT(bm);
 
-       SkURLStream     stream(url);
-       return SkImageDecoder::DecodeStream(&stream, bm, pref);
+    SkURLStream stream(url);
+    return SkImageDecoder::DecodeStream(&stream, bm, pref);
 }
 
 bool SkImageDecoder::DecodeStream(SkStream* stream, SkBitmap* bm, SkBitmap::Config pref)
 {
-       SkASSERT(stream);
-       SkASSERT(bm);
+    SkASSERT(stream);
+    SkASSERT(bm);
 
-       SkImageDecoder* codec = SkImageDecoder::Factory(stream);
+    SkImageDecoder* codec = SkImageDecoder::Factory(stream);
     if (codec)
     {
-        SkAutoTDelete<SkImageDecoder>  ad(codec);
-        SkBitmap                                               tmp;
+        SkAutoTDelete<SkImageDecoder>   ad(codec);
+        SkBitmap                        tmp;
 
         if (codec->onDecode(stream, &tmp, pref))
         {
-            /* We operate on a tmp bitmap until we know we succeed. This way
+            /*  We operate on a tmp bitmap until we know we succeed. This way
                 we're sure we don't change the caller's bitmap and then later
                 return false. Returning false must mean that their parameter
                 is unchanged.
@@ -70,7 +115,7 @@ bool SkImageDecoder::DecodeStream(SkStream* stream, SkBitmap* bm, SkBitmap::Conf
             return true;
         }
     }
-       return false;
+    return false;
 }
 
 /////////////////////////////////////////////////////////////////////////////////
@@ -83,15 +128,15 @@ SkImageEncoder::~SkImageEncoder()
 
 bool SkImageEncoder::encodeStream(SkWStream* stream, const SkBitmap& bm, int quality)
 {
-       quality = SkMin32(100, SkMax32(0, quality));
-       return this->onEncode(stream, bm, quality);
+    quality = SkMin32(100, SkMax32(0, quality));
+    return this->onEncode(stream, bm, quality);
 }
 
 bool SkImageEncoder::encodeFile(const char file[], const SkBitmap& bm, int quality)
 {
-       quality = SkMin32(100, SkMax32(0, quality));
-       SkFILEWStream   stream(file);
-       return this->onEncode(&stream, bm, quality);
+    quality = SkMin32(100, SkMax32(0, quality));
+    SkFILEWStream   stream(file);
+    return this->onEncode(&stream, bm, quality);
 }
 
 extern SkImageEncoder* sk_create_jpeg_encoder();
@@ -114,59 +159,99 @@ SkImageEncoder* SkImageEncoder::Create(Type t)
 
 SkBitmapRef* SkBitmapRef::DecodeFile(const char path[], bool forceDecode)
 {
-       SkBitmapRef_Globals& globals = *(SkBitmapRef_Globals*)SkGlobals::Find(kBitmapRef_GlobalsTag,
+    SkBitmapRef_Globals& globals = *(SkBitmapRef_Globals*)SkGlobals::Find(kBitmapRef_GlobalsTag,
                                                                           SkBitmapRef_Globals::Create);
 
-       SkAutoMutexAcquire      ac(globals.fMutex);
-       SkBitmapRef::Rec*       rec = globals.fCache;
+    SkAutoMutexAcquire  ac(globals.fMutex);
+    SkBitmapRef::Rec*   rec = globals.fCache;
 
-       while (rec)
-       {
-               if (rec->fPath.equals(path))
-                       return SkNEW_ARGS(SkBitmapRef, (rec));
-               rec = rec->fNext;
-       }
+    while (rec)
+    {
+        if (rec->fPath.equals(path))
+            return SkNEW_ARGS(SkBitmapRef, (rec));
+        rec = rec->fNext;
+    }
 
-       if (forceDecode)
-       {
-               SkAutoTDelete<Rec>      autoRec(rec = SkNEW_ARGS(Rec, (true)));
-               
-               if (SkImageDecoder::DecodeFile(path, &rec->fBM))
-               {
-                       rec->fPath.set(path);
-                       rec->fRefCnt = 0;
-                       rec->fNext = globals.fCache;
-                       globals.fCache = rec;
+    if (forceDecode)
+    {
+        SkAutoTDelete<Rec>  autoRec(rec = SkNEW_ARGS(Rec, (true)));
+        
+        if (SkImageDecoder::DecodeFile(path, &rec->fBM))
+        {
+            rec->fPath.set(path);
+            rec->fRefCnt = 0;
+            rec->fNext = globals.fCache;
+            globals.fCache = rec;
 
-                       (void)autoRec.detach(); // detach from autoRec, so we don't delete it
-                       return SkNEW_ARGS(SkBitmapRef, (rec));
-               }
-       }
-       return nil;
+            (void)autoRec.detach(); // detach from autoRec, so we don't delete it
+            return SkNEW_ARGS(SkBitmapRef, (rec));
+        }
+    }
+    return nil;
 }
 
-SkBitmapRef* SkBitmapRef::DecodeMemory(const void* bytes, size_t len)
+SkBitmapRef* SkBitmapRef::DecodeMemory(const void* bytes, size_t len, const char* name)
 {
-    SkBitmapRef::Rec* rec;
-    SkAutoTDelete<Rec>  autoRec(rec = SkNEW_ARGS(Rec, (false)));
+    SkBitmapRef_Globals& globals = *(SkBitmapRef_Globals*)SkGlobals::Find(kBitmapRef_GlobalsTag,
+                                                                          SkBitmapRef_Globals::Create);
+
+    SkAutoMutexAcquire  ac(globals.fMutex);
+    SkBitmapRef::Rec*   rec = globals.fCache;
+
+    if (name)
+    {
+        while (rec)
+        {
+            if (rec->fPath.equals(name))
+                return SkNEW_ARGS(SkBitmapRef, (rec));
+            rec = rec->fNext;
+        }
+    }
+    
+    SkAutoTDelete<Rec>  autoRec(rec = SkNEW_ARGS(Rec, (true)));
 
     if (SkImageDecoder::DecodeMemory(bytes, len, &rec->fBM))
     {
+        if (name)
+            rec->fPath.set(name);
         rec->fRefCnt = 0;
+        rec->fNext = globals.fCache;
+        globals.fCache = rec;
+        
         (void)autoRec.detach();
         return SkNEW_ARGS(SkBitmapRef, (rec));
     }
     return nil;
 }
 
-SkBitmapRef* SkBitmapRef::DecodeStream(SkStream* stream)
+SkBitmapRef* SkBitmapRef::DecodeStream(SkStream* stream, const char* name)
 {
-    SkBitmapRef::Rec* rec;
-    SkAutoTDelete<Rec>  autoRec(rec = SkNEW_ARGS(Rec, (false)));
+    SkBitmapRef_Globals& globals = *(SkBitmapRef_Globals*)SkGlobals::Find(kBitmapRef_GlobalsTag,
+                                                                          SkBitmapRef_Globals::Create);
+
+    SkAutoMutexAcquire  ac(globals.fMutex);
+    SkBitmapRef::Rec*   rec = globals.fCache;
+
+    if (name)
+    {
+        while (rec)
+        {
+            if (rec->fPath.equals(name))
+                return SkNEW_ARGS(SkBitmapRef, (rec));
+            rec = rec->fNext;
+        }
+    }
+    
+    SkAutoTDelete<Rec>  autoRec(rec = SkNEW_ARGS(Rec, (true)));
 
     if (SkImageDecoder::DecodeStream(stream, &rec->fBM))
     {
+        if (name)
+            rec->fPath.set(name);
         rec->fRefCnt = 0;
+        rec->fNext = globals.fCache;
+        globals.fCache = rec;
+        
         (void)autoRec.detach();
         return SkNEW_ARGS(SkBitmapRef, (rec));
     }
index 621164d..5a6be42 100644 (file)
@@ -1,3 +1,20 @@
+/* libs/graphics/images/SkImageDecoder_libgif.cpp
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #include "SkImageDecoder.h"
 #include "SkColor.h"
 #include "SkColorPriv.h"
@@ -6,7 +23,7 @@
 
 class SkGIFImageDecoder : public SkImageDecoder {
 protected:
-       virtual bool onDecode(SkStream* stream, SkBitmap* bm, SkBitmap::Config pref);
+    virtual bool onDecode(SkStream* stream, SkBitmap* bm, SkBitmap::Config pref);
 };
 
 
@@ -14,13 +31,13 @@ extern "C" {
 #include "gif_lib.h"
 }
 
-#define GIF_STAMP              "GIF"    /* First chars in file - GIF stamp. */
-#define GIF_STAMP_LEN  (sizeof(GIF_STAMP) - 1)
+#define GIF_STAMP       "GIF"    /* First chars in file - GIF stamp. */
+#define GIF_STAMP_LEN   (sizeof(GIF_STAMP) - 1)
 
 SkImageDecoder* SkImageDecoder_GIF_Factory(SkStream* stream)
 {
-       char buf[GIF_STAMP_LEN];
-       if (stream->read(buf, GIF_STAMP_LEN) == GIF_STAMP_LEN &&
+    char buf[GIF_STAMP_LEN];
+    if (stream->read(buf, GIF_STAMP_LEN) == GIF_STAMP_LEN &&
         memcmp(GIF_STAMP, buf, GIF_STAMP_LEN) == 0)
     {
         stream->rewind();
@@ -31,32 +48,51 @@ SkImageDecoder* SkImageDecoder_GIF_Factory(SkStream* stream)
 
 static int Decode(GifFileType* fileType, GifByteType* out, int size)
 {
-       SkStream* stream = (SkStream*) fileType->UserData;
-       return (int) stream->read(out, size);
+    SkStream* stream = (SkStream*) fileType->UserData;
+    return (int) stream->read(out, size);
 }
 
+class AutoGifClose {
+public:
+    AutoGifClose(GifFileType* gif) : fGIF(gif) {}
+    ~AutoGifClose()
+    {
+        DGifCloseFile(fGIF);
+    }
+private:
+    GifFileType*    fGIF;
+};
+
 bool SkGIFImageDecoder::onDecode(SkStream* sk_stream, SkBitmap* bm, SkBitmap::Config prefConfig)
-{      
-       GifFileType* gif = DGifOpen( sk_stream, Decode );
-       if (gif == nil)
-               return false;
+{   
+    GifFileType* gif = DGifOpen( sk_stream, Decode );
+    if (gif == nil)
+        return false;
+
+    AutoGifClose    ac(gif);
+
     if (DGifSlurp(gif) != GIF_OK)
-               return false;
+        return false;
+
     ColorMapObject* cmap = gif->SColorMap;
     if (cmap == 0 ||
         gif->ImageCount < 1 ||
         cmap->ColorCount != (1 << cmap->BitsPerPixel))
-                       return false;
+            return false;
+
     SavedImage* gif_image = gif->SavedImages + 0;
     const int width = gif->SWidth;
     const int height = gif->SHeight;
-       SkBitmap::Config        config = SkBitmap::kIndex8_Config;
-       bm->setConfig(config, width, height, 0);
-       bm->allocPixels();
-       
-       SkColorTable* colorTable = SkNEW(SkColorTable);
-       colorTable->setColors(cmap->ColorCount);
-       bm->setColorTable(colorTable)->unref();
+    SkBitmap::Config    config = SkBitmap::kIndex8_Config;
+    if (!this->chooseFromOneChoice(config, width, height))
+        return false;
+
+    bm->setConfig(config, width, height, 0);
+    bm->allocPixels();
+
+    SkColorTable* colorTable = SkNEW(SkColorTable);
+    colorTable->setColors(cmap->ColorCount);
+    bm->setColorTable(colorTable)->unref();
 
     int transparent = -1;
     for (int i = 0; i < gif_image->ExtensionBlockCount; ++i) {
@@ -70,27 +106,27 @@ bool SkGIFImageDecoder::onDecode(SkStream* sk_stream, SkBitmap* bm, SkBitmap::Co
       }
     }
 
-       SkPMColor* colorPtr = colorTable->lockColors();
+    SkPMColor* colorPtr = colorTable->lockColors();
 
-       if (transparent >= 0)
-               memset(colorPtr, 0, cmap->ColorCount * 4);
-       else
-               colorTable->setFlags(colorTable->getFlags() | SkColorTable::kColorsAreOpaque_Flag);
+    if (transparent >= 0)
+        memset(colorPtr, 0, cmap->ColorCount * 4);
+    else
+        colorTable->setFlags(colorTable->getFlags() | SkColorTable::kColorsAreOpaque_Flag);
 
-       for (int index = 0; index < cmap->ColorCount; index++)
-       {
-               if (transparent != index)
-                       colorPtr[index] = SkColorSetRGB(cmap->Colors[index].Red, 
-                               cmap->Colors[index].Green, cmap->Colors[index].Blue);
-       }
-       colorTable->unlockColors(true);
+    for (int index = 0; index < cmap->ColorCount; index++)
+    {
+        if (transparent != index)
+            colorPtr[index] = SkColorSetRGB(cmap->Colors[index].Red, 
+                cmap->Colors[index].Green, cmap->Colors[index].Blue);
+    }
+    colorTable->unlockColors(true);
 
     unsigned char* in = (unsigned char*)gif_image->RasterBits;
     unsigned char* out = bm->getAddr8(0, 0);
     if (gif->Image.Interlace) {
 
       // deinterlace
-               int row;
+        int row;
       // group 1 - every 8th row, starting with row 0
       for (row = 0; row < height; row += 8) {
         memcpy(out + width * row, in, width);
@@ -117,7 +153,5 @@ bool SkGIFImageDecoder::onDecode(SkStream* sk_stream, SkBitmap* bm, SkBitmap::Co
     } else {
       memcpy(out, in, width * height);
     }
-
-    DGifCloseFile(gif);
-       return true;
+    return true;
 }
diff --git a/libs/graphics/images/SkImageDecoder_libico.cpp b/libs/graphics/images/SkImageDecoder_libico.cpp
new file mode 100644 (file)
index 0000000..d38d1fb
--- /dev/null
@@ -0,0 +1,336 @@
+/* libs/graphics/images/SkImageDecoder_libico.cpp
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
+#include "SkImageDecoder.h"
+#include "SkStream.h"
+#include "SkColorPriv.h"
+#include "SkTypes.h"
+
+class SkICOImageDecoder : public SkImageDecoder {
+public:
+    SkICOImageDecoder();
+    
+//protected:    //i think mike wants this to be protected and only called by the base class
+    virtual bool onDecode(SkStream* stream, SkBitmap* bm, SkBitmap::Config pref);
+};
+
+/////////////////////////////////////////////////////////////////////////////////////////
+
+//read bytes starting from the begin-th index in the buffer
+//read in Intel order, and return an integer
+
+#define readByte(buffer,begin) buffer[begin]
+#define read2Bytes(buffer,begin) buffer[begin]+(buffer[begin+1]<<8)
+#define read4Bytes(buffer,begin) buffer[begin]+(buffer[begin+1]<<8)+(buffer[begin+2]<<16)+(buffer[begin+3]<<24)
+
+/////////////////////////////////////////////////////////////////////////////////////////
+
+SkImageDecoder* SkImageDecoder_ICO_Factory(SkStream*);
+SkImageDecoder* SkImageDecoder_ICO_Factory(SkStream* stream)
+{
+    //i'm going to check if we basically have 0,0,1,0 (reserved = 0, type = 1)
+    //is that required and sufficient?
+    SkAutoMalloc autoMal(4);
+    unsigned char* buf = (unsigned char*)autoMal.get();
+    stream->read((void*)buf, 4);
+    int reserved = read2Bytes(buf, 0);
+    int type = read2Bytes(buf, 2);
+    if (reserved != 0 || type != 1) //it's not an ico
+        return NULL;
+    stream->rewind();
+    return SkNEW(SkICOImageDecoder);
+}
+
+/////////////////////////////////////////////////////////////////////////////////////////
+
+SkICOImageDecoder::SkICOImageDecoder()
+{
+}
+
+//helpers - my function pointer will call one of these, depending on the bitCount, each time through the inner loop
+static void editPixelBit4(const int pixelNo, const unsigned char* buf, 
+            const int xorOffset, int& x, int y, const int w, 
+            SkBitmap* bm, int alphaByte, int m, int shift, SkPMColor* colors);
+static void editPixelBit8(const int pixelNo, const unsigned char* buf, 
+            const int xorOffset, int& x, int y, const int w, 
+            SkBitmap* bm, int alphaByte, int m, int shift, SkPMColor* colors);
+static void editPixelBit24(const int pixelNo, const unsigned char* buf, 
+            const int xorOffset, int& x, int y, const int w, 
+            SkBitmap* bm, int alphaByte, int m, int shift, SkPMColor* colors);
+static void editPixelBit32(const int pixelNo, const unsigned char* buf, 
+            const int xorOffset, int& x, int y, const int w, 
+            SkBitmap* bm, int alphaByte, int m, int shift, SkPMColor* colors);
+            
+bool SkICOImageDecoder::onDecode(SkStream* stream, SkBitmap* bm, SkBitmap::Config pref)
+{
+    //FIXME: would only like to buffer in what we need
+    //problem: need to look at much of the file to inspect the bitCount of each individual file
+    //but maybe we don't care, and we are just concerned with the height and width, in which case
+    //we can simply iterate through the icon list to find the heights and widths, then only look at the 
+    //infoheader and file of the one we need
+    
+    //FIXME!!: check to make sure we don't read past the end of the buffer
+    //what if a buffer with length of one is provided?
+    //do i need to check for some minimum length?
+    //each time i read, do i need to make sure i'm not off the edge?
+    //or maybe i should just check the last field, and make sure it's not past the end of the array
+    size_t length = stream->read(NULL, 0);
+    SkAutoMalloc autoMal(length);
+    unsigned char* buf = (unsigned char*)autoMal.get();
+    stream->read((void*)buf, length);            //this returns length - should i make sure they're the same?
+    
+    //these should always be the same - should i use for error checking? - what about files that have some
+    //incorrect values, but still decode properly?
+    int reserved = read2Bytes(buf, 0);    // 0
+    int type = read2Bytes(buf, 2);        // 1
+    if (reserved != 0 || type != 1)
+        return false;
+    int count = read2Bytes(buf, 4);
+    
+    //need to at least have enough space to hold the initial table of info
+    if (length < (size_t)(6 + count*16))
+        return false;
+        
+    int choice;
+    Chooser* chooser = this->getChooser();
+    //FIXME:if no chooser, consider providing the largest color image
+    //what are the odds that the largest image would be monochrome?
+    if (NULL == chooser)    //this doesn't get instantiated to NULL, does it?
+        choice = 0;
+    else
+    {
+        chooser->begin(count);
+        for (int i = 0; i < count; i++)
+        {
+            //need to find out the config, width, and height from the stream
+            int width = readByte(buf, 6 + i*16);
+            int height = readByte(buf, 7 + i*16);
+            int offset = read4Bytes(buf, 18 + i*16);
+            int bitCount = read2Bytes(buf, offset+14);
+            SkBitmap::Config c;
+            //currently only provide ARGB_8888_, but maybe we want kIndex8_Config for 1 and 4, and possibly 8?
+            //or maybe we'll determine this based on the provided config
+            switch (bitCount)
+            {
+                case 1:
+                case 4:
+                case 8:
+                    //c = SkBitmap::kIndex8_Config;
+                    //break;
+                case 24:
+                case 32:
+                    c = SkBitmap::kARGB_8888_Config;
+                    break;
+                default:
+                    SkDEBUGF(("Image with %ibpp not supported\n", bitCount));
+                    continue;
+            }
+            chooser->inspect(i, c, width, height);
+        }
+        choice = chooser->choose();
+    }
+    
+    //you never know what the chooser is going to supply
+    if (choice >= count || choice < 0)       
+        return false;
+    
+    //skip ahead to the correct header
+    //commented out lines are not used, but if i switch to other read method, need to know how many to skip
+    //otherwise, they could be used for error checking
+    int w = readByte(buf, 6 + choice*16);
+    int h = readByte(buf, 7 + choice*16);
+    int colorCount = readByte(buf, 8 + choice*16);
+    //int reservedToo = readByte(buf, 9 + choice*16);   //0
+    //int planes = read2Bytes(buf, 10 + choice*16);       //1 - but often 0
+    //int fakeBitCount = read2Bytes(buf, 12 + choice*16); //should be real - usually 0
+    int size = read4Bytes(buf, 14 + choice*16);           //matters?
+    int offset = read4Bytes(buf, 18 + choice*16);
+    if ((size_t)(offset + size) > length)
+        return false;
+    //int infoSize = read4Bytes(buf, offset);             //40
+    //int width = read4Bytes(buf, offset+4);              //should == w
+    //int height = read4Bytes(buf, offset+8);             //should == 2*h
+    //int planesToo = read2Bytes(buf, offset+12);         //should == 1 (does it?)
+    int bitCount = read2Bytes(buf, offset+14);
+    //FIXME: haven't implemented the 1bpp case - need to have 1 bit icons to test
+    if (1 == bitCount) {
+        SkDEBUGF(("1bpp not supported yet\n"));
+        return false;
+    }
+    
+    if (0 == colorCount && 8 == bitCount)
+        colorCount = 256;   //for 24bpp and 32bpp, colorCount stays 0
+        
+    //these should all be zero, but perhaps are not - need to check
+    //int compression = read4Bytes(buf, offset+16);       //0
+    //int imageSize = read4Bytes(buf, offset+20);         //0 - sometimes has a value
+    //int xPixels = read4Bytes(buf, offset+24);           //0
+    //int yPixels = read4Bytes(buf, offset+28);           //0
+    //int colorsUsed = read4Bytes(buf, offset+32)         //0 - might have an actual value though
+    //int colorsImportant = read4Bytes(buf, offset+36);   //0
+        
+    int begin = offset + 40;
+    //this array represents the colortable
+    //if i allow other types of bitmaps, it may actually be used as a part of the bitmap
+    SkPMColor* colors = NULL;
+    int blue, green, red;
+    if (colorCount) 
+    {
+        colors = new SkPMColor[colorCount];
+        for (int j = 0; j < colorCount; j++)
+        {
+            //should this be a function - maybe a #define?
+            blue = readByte(buf, begin + 4*j);
+            green = readByte(buf, begin + 4*j + 1);
+            red = readByte(buf, begin + 4*j + 2);
+            colors[j] = SkPackARGB32(0xFF, red & 0xFF, green & 0xFF, blue & 0xFF);
+        }
+    }
+    int bitWidth = w*bitCount;
+    int test = bitWidth & 0x1F;
+    int mask = -(((test >> 4) | (test >> 3) | (test >> 2) | (test >> 1) | test) & 0x1);    //either 0xFFFFFFFF or 0
+    int lineBitWidth = (bitWidth & 0xFFFFFFE0) + (0x20 & mask);
+    int lineWidth = lineBitWidth/bitCount;
+    
+    int xorOffset = begin + colorCount*4;   //beginning of the color bitmap
+                                            //other read method means we will just be here already
+    int andOffset = xorOffset + ((lineWidth*h*bitCount) >> 3);
+    
+    /*int */test = w & 0x1F;   //the low 5 bits - we are rounding up to the next 32 (2^5)
+    /*int */mask = -(((test >> 4) | (test >> 3) | (test >> 2) | (test >> 1) | test) & 0x1);    //either 0xFFFFFFFF or 0
+    int andLineWidth = (w & 0xFFFFFFE0) + (0x20 & mask);
+    //if we allow different Configs, everything is the same til here
+    //change the config, and use different address getter, and place index vs color, and add the color table
+    //FIXME: what is the tradeoff in size?
+    //if the andbitmap (mask) is all zeroes, then we can easily do an index bitmap
+    //however, with small images with large colortables, maybe it's better to still do argb_8888
+    //default rowBytes is w << 2 for kARGB_8888
+    //i'm adding one - it's only truly necessary in the case that w is odd and we are four bit
+    //so we can go off the end of the drawn bitmap
+    //FIXME: need to test with an odd width bitmap that is 4bit
+    bm->setConfig(SkBitmap::kARGB_8888_Config, w, h, (w << 2) + (0x1 & w & (bitCount >> 2)));
+    bm->allocPixels();
+    void (*placePixel)(const int pixelNo, const unsigned char* buf, 
+            const int xorOffset, int& x, int y, const int w, 
+            SkBitmap* bm, int alphaByte, int m, int shift, SkPMColor* colors) = NULL;
+    switch (bitCount)
+    {
+        case 1:
+            //assert?
+            break;  //have this for the future, but should have returned false before now
+        case 4:
+            placePixel = &editPixelBit4;
+            break;
+        case 8:
+            placePixel = &editPixelBit8;
+            break;
+        case 24:
+            placePixel = &editPixelBit24;
+            break;
+        case 32:
+            placePixel = &editPixelBit32;
+            break;
+        default:
+            //assert
+            //don't have any other bitCounts ready yet (are there any others besides 1?)
+            SkDEBUGF(("Decoding %ibpp is unimplemented\n", bitCount));
+    }
+    
+    for (int y = 0; y < h; y++)
+        for (int x = 0; x < w; x++)
+        {
+            //U32* address = bm->getAddr32(x, y);
+            
+            //check the alpha bit first, but pass it along to the function to figure out how to deal with it
+            int andPixelNo = andLineWidth*(h-y-1)+x;
+            //only need to get a new alphaByte when x %8 == 0
+            //but that introduces an if and a mod - probably much slower
+            //that's ok, it's just a read of an array, not a stream
+            int alphaByte = readByte(buf, andOffset + (andPixelNo >> 3));
+            int shift = 7 - (andPixelNo & 0x7);
+            int m = 1 << shift;
+            
+            int pixelNo = lineWidth*(h-y-1)+x;
+            placePixel(pixelNo, buf, xorOffset, x, y, w, bm, alphaByte, m, shift, colors);
+
+        }   //for
+        if (colors)
+            delete colors;
+        //ensure we haven't read off the end?
+        //of course this doesn't help us if the andOffset was a lie...
+        //return andOffset + (andLineWidth >> 3) <= length;
+        return true;
+}   //onDecode
+
+//function to place the pixel, determined by the bitCount
+static void editPixelBit4(const int pixelNo, const unsigned char* buf, 
+            const int xorOffset, int& x, int y, const int w, 
+            SkBitmap* bm, int alphaByte, int m, int shift, SkPMColor* colors)
+{
+    U32* address = bm->getAddr32(x, y);
+    int byte = readByte(buf, xorOffset + (pixelNo >> 1));
+    int pixel = (byte >> 4) & 0xF;
+    int alphaBit = (alphaByte & m) >> shift;
+    *address = (alphaBit-1)&(colors[pixel]);
+    x++;
+    //if w is odd, x may be the same as w, which means we are writing to an unused portion of the bitmap
+    //but that's okay, since i've added an extra rowByte for just this purpose
+    address = address + 1;
+    pixel = byte & 0xF;
+    m = m >> 1;
+    alphaBit = (alphaByte & m) >> (shift-1);
+    //speed up trick here
+    *address = (alphaBit-1)&(colors[pixel]);
+}
+
+static void editPixelBit8(const int pixelNo, const unsigned char* buf, 
+            const int xorOffset, int& x, int y, const int w, 
+            SkBitmap* bm, int alphaByte, int m, int shift, SkPMColor* colors)
+{
+    U32* address = bm->getAddr32(x, y);
+    int pixel = readByte(buf, xorOffset + pixelNo);
+    int alphaBit = (alphaByte & m) >> shift;
+    *address = (alphaBit-1)&(colors[pixel]);
+}            
+
+static void editPixelBit24(const int pixelNo, const unsigned char* buf, 
+            const int xorOffset, int& x, int y, const int w, 
+            SkBitmap* bm, int alphaByte, int m, int shift, SkPMColor* colors)
+{
+    U32* address = bm->getAddr32(x, y);
+    int blue = readByte(buf, xorOffset + 3*pixelNo);
+    int green = readByte(buf, xorOffset + 3*pixelNo + 1);
+    int red = readByte(buf, xorOffset + 3*pixelNo + 2);
+    int alphaBit = (alphaByte & m) >> shift;
+    //alphaBit == 1 => alpha = 0
+    int alpha = (alphaBit-1) & 0xFF;
+    *address = SkPackARGB32(alpha, red & alpha, green & alpha, blue & alpha);    
+}
+
+static void editPixelBit32(const int pixelNo, const unsigned char* buf, 
+            const int xorOffset, int& x, int y, const int w, 
+            SkBitmap* bm, int alphaByte, int m, int shift, SkPMColor* colors)
+{
+    U32* address = bm->getAddr32(x, y);
+    int blue = readByte(buf, xorOffset + 4*pixelNo);
+    int green = readByte(buf, xorOffset + 4*pixelNo + 1);
+    int red = readByte(buf, xorOffset + 4*pixelNo + 2);
+    int alphaBit = (alphaByte & m) >> shift;
+    int alpha = readByte(buf, xorOffset + 4*pixelNo + 3) & ((alphaBit-1)&0xFF);
+    *address = SkPackARGB32(alpha, red & alpha, green & alpha, blue & alpha);
+}
+
index 91f019e..2c5d781 100644 (file)
@@ -1,3 +1,20 @@
+/* libs/graphics/images/SkImageDecoder_libjpeg.cpp
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #include "SkImageDecoder.h"
 #include "SkColorPriv.h"
 #include "SkStream.h"
 
 #include <stdio.h>
 extern "C" {
-       #include "jpeglib.h"
+    #include "jpeglib.h"
 }
 
 class SkJPEGImageDecoder : public SkImageDecoder {
 protected:
-       virtual bool onDecode(SkStream* stream, SkBitmap* bm, SkBitmap::Config pref);
+    virtual bool onDecode(SkStream* stream, SkBitmap* bm, SkBitmap::Config pref);
 };
 
 SkImageDecoder* SkImageDecoder_JPEG_Factory(SkStream* stream) { 
-       // !!! unimplemented; rely on PNG test first for now
-       return SkNEW(SkJPEGImageDecoder);
+    // !!! unimplemented; rely on PNG test first for now
+    return SkNEW(SkJPEGImageDecoder);
 }
 
 //////////////////////////////////////////////////////////////////////////
@@ -23,140 +40,210 @@ SkImageDecoder* SkImageDecoder_JPEG_Factory(SkStream* stream) {
 /* our source struct for directing jpeg to our stream object
 */
 struct sk_source_mgr : jpeg_source_mgr {
-       sk_source_mgr(SkStream* stream);
+    sk_source_mgr(SkStream* stream);
 
-       SkStream*       fStream;
+    SkStream*   fStream;
 
-       enum {
-               kBufferSize = 1024
-       };
-       char    fBuffer[kBufferSize];
+    enum {
+        kBufferSize = 1024
+    };
+    char    fBuffer[kBufferSize];
 };
 
 /* Automatically clean up after throwing an exception */
 struct JPEGAutoClean
 {
-       JPEGAutoClean(jpeg_decompress_struct* info): cinfo_ptr(info) {}
-       ~JPEGAutoClean()
-       {
-               jpeg_destroy_decompress(cinfo_ptr);
-       }
+    JPEGAutoClean(jpeg_decompress_struct* info): cinfo_ptr(info) {}
+    ~JPEGAutoClean()
+    {
+        jpeg_destroy_decompress(cinfo_ptr);
+    }
 private:
-       jpeg_decompress_struct* cinfo_ptr;
+    jpeg_decompress_struct* cinfo_ptr;
 };
 
 static void sk_init_source(j_decompress_ptr cinfo)
 {
-       sk_source_mgr*  src = (sk_source_mgr*)cinfo->src;
+    sk_source_mgr*  src = (sk_source_mgr*)cinfo->src;
 
-       src->next_input_byte = (const JOCTET*)src->fBuffer;
-       src->bytes_in_buffer = 0;
+    src->next_input_byte = (const JOCTET*)src->fBuffer;
+    src->bytes_in_buffer = 0;
 }
 
 static boolean sk_fill_input_buffer(j_decompress_ptr cinfo)
 {
-       sk_source_mgr*  src = (sk_source_mgr*)cinfo->src;
-       size_t                  bytes = src->fStream->read(src->fBuffer, sk_source_mgr::kBufferSize);
-       // note that JPEG is happy with less than the full read, as long as the result is non-zero
-       if (bytes == 0)
-               cinfo->err->error_exit((j_common_ptr)cinfo);
-
-       src->next_input_byte = (const JOCTET*)src->fBuffer;
-       src->bytes_in_buffer = bytes;
-       return TRUE;
+    sk_source_mgr*  src = (sk_source_mgr*)cinfo->src;
+    size_t          bytes = src->fStream->read(src->fBuffer, sk_source_mgr::kBufferSize);
+    // note that JPEG is happy with less than the full read, as long as the result is non-zero
+    if (bytes == 0)
+        cinfo->err->error_exit((j_common_ptr)cinfo);
+
+    src->next_input_byte = (const JOCTET*)src->fBuffer;
+    src->bytes_in_buffer = bytes;
+    return TRUE;
 }
 
 static void sk_skip_input_data(j_decompress_ptr cinfo, long num_bytes)
 {
-       SkASSERT(num_bytes > 0);
-
-       sk_source_mgr*  src = (sk_source_mgr*)cinfo->src;
-
-       long skip = num_bytes - src->bytes_in_buffer;
-
-       if (skip > 0)
-       {
-               size_t bytes = src->fStream->read(nil, skip);
-               if (bytes != (size_t)skip)
-                       cinfo->err->error_exit((j_common_ptr)cinfo);
-
-               src->next_input_byte = (const JOCTET*)src->fBuffer;
-               src->bytes_in_buffer = 0;
-       }
-       else
-       {
-               src->next_input_byte += num_bytes;
-               src->bytes_in_buffer -= num_bytes;
-       }
+    SkASSERT(num_bytes > 0);
+
+    sk_source_mgr*  src = (sk_source_mgr*)cinfo->src;
+
+    long skip = num_bytes - src->bytes_in_buffer;
+
+    if (skip > 0)
+    {
+        size_t bytes = src->fStream->read(nil, skip);
+        if (bytes != (size_t)skip)
+            cinfo->err->error_exit((j_common_ptr)cinfo);
+
+        src->next_input_byte = (const JOCTET*)src->fBuffer;
+        src->bytes_in_buffer = 0;
+    }
+    else
+    {
+        src->next_input_byte += num_bytes;
+        src->bytes_in_buffer -= num_bytes;
+    }
 }
 
 static boolean sk_resync_to_restart(j_decompress_ptr cinfo, int desired)
 {
-       sk_source_mgr*  src = (sk_source_mgr*)cinfo->src;
+    sk_source_mgr*  src = (sk_source_mgr*)cinfo->src;
 
-       // what is the desired param for???
+    // what is the desired param for???
 
-       if (!src->fStream->rewind())
-               cinfo->err->error_exit((j_common_ptr)cinfo);
+    if (!src->fStream->rewind())
+        cinfo->err->error_exit((j_common_ptr)cinfo);
 
-       return TRUE;
+    return TRUE;
 }
 
 static void sk_term_source(j_decompress_ptr /*cinfo*/)
 {
-       // nothing to do
+    // nothing to do
 }
 
 sk_source_mgr::sk_source_mgr(SkStream* stream)
-       : fStream(stream)
+    : fStream(stream)
 {
-       init_source = sk_init_source;
-       fill_input_buffer = sk_fill_input_buffer;
-       skip_input_data = sk_skip_input_data;
-       resync_to_restart = sk_resync_to_restart;
-       term_source = sk_term_source;
+    init_source = sk_init_source;
+    fill_input_buffer = sk_fill_input_buffer;
+    skip_input_data = sk_skip_input_data;
+    resync_to_restart = sk_resync_to_restart;
+    term_source = sk_term_source;
 }
 
 #include <setjmp.h>
 
 struct sk_error_mgr : jpeg_error_mgr {
-       jmp_buf fJmpBuf;
+    jmp_buf fJmpBuf;
 };
 
 static void sk_error_exit(j_common_ptr cinfo)
 {
-       sk_error_mgr* error = (sk_error_mgr*)cinfo->err;
+    sk_error_mgr* error = (sk_error_mgr*)cinfo->err;
 
-       /* Always display the message */
-       (*error->output_message) (cinfo);
+    /* Always display the message */
+    (*error->output_message) (cinfo);
 
-       /* Let the memory manager delete any temp files before we die */
-       jpeg_destroy(cinfo);
+    /* Let the memory manager delete any temp files before we die */
+    jpeg_destroy(cinfo);
 
-       longjmp(error->fJmpBuf, -1);
+    longjmp(error->fJmpBuf, -1);
+}
+
+typedef void (*ConvertTo16Proc)(int y, int width, const uint8_t rgbTriple[], uint16_t dst[]);
+
+#define DITHER_TO_16
+
+static void ConvertTo16_Gray(int y, int width, const uint8_t rgbTriple[], uint16_t dst[])
+{
+#ifndef DITHER_TO_16
+    uint16_t* stop = dst + width;
+
+    while (dst < stop) {
+        *dst++ = SkPack888ToRGB16(rgbTriple[0], rgbTriple[0], rgbTriple[0]);
+        rgbTriple += 1;
+    }
+#else   // dither
+    SkASSERT(width > 0);
+
+    // do the first pixel (if we're out of phase)
+    if (SkShouldDitherXY(0, y)) {
+        *dst++ = SkDitherPack888ToRGB16(rgbTriple[0], rgbTriple[0], rgbTriple[0]);
+        rgbTriple += 1;
+        width -= 1;
+    }
+    
+    int dcount = width >> 1;
+    for (int i = 0; i < dcount; i++) {
+        *dst++ = SkPack888ToRGB16(rgbTriple[0], rgbTriple[0], rgbTriple[0]);
+        *dst++ = SkDitherPack888ToRGB16(rgbTriple[1], rgbTriple[1], rgbTriple[1]);
+        rgbTriple += 2;
+    }
+    
+    // now do the last pixel (if any)
+    if (width & 1) {
+        *dst++ = SkPack888ToRGB16(rgbTriple[0], rgbTriple[0], rgbTriple[0]);
+    }
+#endif
+}
+
+static void ConvertTo16_Color(int y, int width, const uint8_t rgbTriple[], uint16_t dst[])
+{
+#ifndef DITHER_TO_16
+    uint16_t* stop = dst + width;
+
+    while (dst < stop) {
+        *dst++ = SkPack888ToRGB16(rgbTriple[0], rgbTriple[1], rgbTriple[2]);
+        rgbTriple += 3;
+    }
+#else   // dither
+    SkASSERT(width > 0);
+
+    // do the first pixel (if we're out of phase)
+    if (SkShouldDitherXY(0, y)) {
+        *dst++ = SkDitherPack888ToRGB16(rgbTriple[0], rgbTriple[1], rgbTriple[2]);
+        rgbTriple += 3;
+        width -= 1;
+    }
+    
+    int dcount = width >> 1;
+    for (int i = 0; i < dcount; i++) {
+        *dst++ = SkPack888ToRGB16(rgbTriple[0], rgbTriple[1], rgbTriple[2]);
+        *dst++ = SkDitherPack888ToRGB16(rgbTriple[3], rgbTriple[4], rgbTriple[5]);
+        rgbTriple += 6;
+    }
+    
+    // now do the last pixel (if any)
+    if (width & 1) {
+        *dst = SkPack888ToRGB16(rgbTriple[0], rgbTriple[1], rgbTriple[2]);
+    }
+#endif
 }
 
 bool SkJPEGImageDecoder::onDecode(SkStream* stream, SkBitmap* bm, SkBitmap::Config prefConfig)
 {
-       jpeg_decompress_struct  cinfo;
-       sk_error_mgr                    sk_err;
-       sk_source_mgr                   sk_stream(stream);
+    jpeg_decompress_struct  cinfo;
+    sk_error_mgr            sk_err;
+    sk_source_mgr           sk_stream(stream);
 
-       cinfo.err = jpeg_std_error(&sk_err);
-       sk_err.error_exit = sk_error_exit;
+    cinfo.err = jpeg_std_error(&sk_err);
+    sk_err.error_exit = sk_error_exit;
 
-       if (setjmp(sk_err.fJmpBuf))
-               return false;
+    if (setjmp(sk_err.fJmpBuf))
+        return false;
 
-       jpeg_create_decompress(&cinfo);
-       JPEGAutoClean autoClean(&cinfo);
+    jpeg_create_decompress(&cinfo);
+    JPEGAutoClean autoClean(&cinfo);
 
-       //jpeg_stdio_src(&cinfo, file);
-       cinfo.src = &sk_stream;
+    //jpeg_stdio_src(&cinfo, file);
+    cinfo.src = &sk_stream;
 
-       jpeg_read_header(&cinfo, true);
+    jpeg_read_header(&cinfo, true);
 
-       // now we know the dimensions. can call jpeg_destroy() if we wish
+    // now we know the dimensions. can call jpeg_destroy() if we wish
 
     // check for supported formats
     bool isRGB; // as opposed to gray8
@@ -170,42 +257,46 @@ bool SkJPEGImageDecoder::onDecode(SkStream* stream, SkBitmap* bm, SkBitmap::Conf
         return false;
     }
     
-       SkBitmap::Config config = prefConfig;
-       // if no user preference, see what the device recommends
-       if (config == SkBitmap::kNo_Config)
-               config = SkImageDecoder::GetDeviceConfig();
+    SkBitmap::Config config = prefConfig;
+    // if no user preference, see what the device recommends
+    if (config == SkBitmap::kNo_Config)
+        config = SkImageDecoder::GetDeviceConfig();
 
-       // only one of these two makes sense for jpegs
-       if (config != SkBitmap::kARGB_8888_Config && config != SkBitmap::kRGB_565_Config)
-               config = SkBitmap::kARGB_8888_Config;
+    // only one of these two makes sense for jpegs
+    if (config != SkBitmap::kARGB_8888_Config && config != SkBitmap::kRGB_565_Config)
+        config = SkBitmap::kARGB_8888_Config;
 
-       bm->setConfig(config, cinfo.image_width, cinfo.image_height, 0);
-       bm->allocPixels();
+    // <reed> should we allow the Chooser (if present) to pick a config for us???
+    if (!this->chooseFromOneChoice(config, cinfo.image_width, cinfo.image_height))
+        return false;
+
+    bm->setConfig(config, cinfo.image_width, cinfo.image_height, 0);
+    bm->allocPixels();
     bm->setIsOpaque(true);
 
-       jpeg_start_decompress(&cinfo);
+    jpeg_start_decompress(&cinfo);
 
-       SkASSERT(cinfo.output_width == bm->width());
-       SkASSERT(cinfo.output_height == bm->height());
+    SkASSERT(cinfo.output_width == (unsigned)bm->width());
+    SkASSERT(cinfo.output_height == (unsigned)bm->height());
 
-       int width = bm->width();
+    int width = bm->width();
 
-       if (config == SkBitmap::kARGB_8888_Config)
-       {
-               for (unsigned y = 0; y < cinfo.output_height; y++)
-               {
-                       uint32_t* bmRow = bm->getAddr32(0, y);
-                       JSAMPLE* rowptr = (JSAMPLE*)bmRow;
-                       int              row_count = jpeg_read_scanlines(&cinfo, &rowptr, 1);
-                       SkASSERT(row_count == 1);
+    if (config == SkBitmap::kARGB_8888_Config)
+    {
+        for (unsigned y = 0; y < cinfo.output_height; y++)
+        {
+            uint32_t* bmRow = bm->getAddr32(0, y);
+            JSAMPLE* rowptr = (JSAMPLE*)bmRow;
+            int      row_count = jpeg_read_scanlines(&cinfo, &rowptr, 1);
+            SkASSERT(row_count == 1);
 
-                       // since we want to reuse bmRow for the RGB triples and the final ARGB quads
-                       // we need to expand backwards, so we don't overwrite our src
+            // since we want to reuse bmRow for the RGB triples and the final ARGB quads
+            // we need to expand backwards, so we don't overwrite our src
 
-                       uint32_t*       dst = bmRow + width;
+            uint32_t* dst = bmRow + width;
 
             if (isRGB) {
-                const uint8_t* src = rowptr + width * 3;
+                const uint8_t*  src = rowptr + width * 3;
                 while (dst > bmRow)
                 {
                     src -= 3;
@@ -213,53 +304,32 @@ bool SkJPEGImageDecoder::onDecode(SkStream* stream, SkBitmap* bm, SkBitmap::Conf
                 }
             }
             else {  // grayscale
-                const uint8_t* src = rowptr + width;
+                const uint8_t*  src = rowptr + width;
                 while (dst > bmRow)
                 {
                     src -= 1;
                     *--dst = SkPackARGB32(0xFF, src[0], src[0], src[0]);
                 }
             }
-               }
-       }
-       else    // convert to 16bit
-       {
-               SkAutoMalloc    srcStorage(width * 3);
-               U8*                             srcRow = (U8*)srcStorage.get();
-
-               for (unsigned y = 0; y < cinfo.output_height; y++)
-               {
-                       U16*     dstRow = bm->getAddr16(0, y);
-                       int              row_count = jpeg_read_scanlines(&cinfo, &srcRow, 1);
-                       SkASSERT(row_count == 1);
-
-                       const U8*       src = srcRow;
-                       U16*            dstStop = dstRow + width;
-
-            if (isRGB) {
-                while (dstRow < dstStop)
-                {
-                    *dstRow++ = SkPackRGB16(src[0] >> (8 - SK_R16_BITS),
-                                            src[1] >> (8 - SK_G16_BITS),
-                                            src[2] >> (8 - SK_B16_BITS));
-                    src += 3;
-                }
-            }
-            else {  // grayscale
-                while (dstRow < dstStop)
-                {
-                    *dstRow++ = SkPackRGB16(src[0] >> (8 - SK_R16_BITS),
-                                            src[0] >> (8 - SK_G16_BITS),
-                                            src[0] >> (8 - SK_B16_BITS));
-                    src += 1;
-                }
-            }
-               }
-       }
+        }
+    }
+    else    // convert to 16bit
+    {
+        SkAutoMalloc    srcStorage(width * 3);
+        uint8_t*        srcRow = (uint8_t*)srcStorage.get();
+        ConvertTo16Proc convert_row = isRGB ? ConvertTo16_Color : ConvertTo16_Gray;
+
+        for (unsigned y = 0; y < cinfo.output_height; y++)
+        {
+            int row_count = jpeg_read_scanlines(&cinfo, &srcRow, 1);
+            SkASSERT(row_count == 1);
+            convert_row(y, width, srcRow, bm->getAddr16(0, y));
+        }
+    }
 
-       jpeg_finish_decompress(&cinfo);
+    jpeg_finish_decompress(&cinfo);
 
-       return true;
+    return true;
 }
 
 ////////////////////////////////////////////////////////////////////////////////////
@@ -269,139 +339,139 @@ bool SkJPEGImageDecoder::onDecode(SkStream* stream, SkBitmap* bm, SkBitmap::Conf
 
 #include "SkColorPriv.h"
 
-static void convert_to_rgb24(U8 dst[], const SkBitmap& bm, int y)
+static void convert_to_rgb24(uint8_t dst[], const SkBitmap& bm, int y)
 {
-       int     width = bm.width();
-
-       switch (bm.getConfig()) {
-       case SkBitmap::kARGB_8888_Config:
-               {
-                       const uint32_t* src = bm.getAddr32(0, y);
-                       while (--width >= 0)
-                       {
-                               uint32_t c = *src++;
-                               dst[0] = SkGetPackedR32(c);
-                               dst[1] = SkGetPackedG32(c);
-                               dst[2] = SkGetPackedB32(c);
-                               dst += 3;
-                       }
-               }
-               break;
-       case SkBitmap::kRGB_565_Config: // hmmm, I should encode 16bit jpegs, not expand to 24 bit (doh!)
-               {
-                       const U16* src = bm.getAddr16(0, y);
-                       while (--width >= 0)
-                       {
-                               U16 c = *src++;
-                               dst[0] = SkPacked16ToR32(c);
-                               dst[1] = SkPacked16ToG32(c);
-                               dst[1] = SkPacked16ToB32(c);
-                               dst += 3;
-                       }
-               }
-               break;
-       default:
-               SkASSERT(!"unknown bitmap format for jpeg encode");
-       }
+    int width = bm.width();
+
+    switch (bm.getConfig()) {
+    case SkBitmap::kARGB_8888_Config:
+        {
+            const uint32_t* src = bm.getAddr32(0, y);
+            while (--width >= 0)
+            {
+                uint32_t c = *src++;
+                dst[0] = SkGetPackedR32(c);
+                dst[1] = SkGetPackedG32(c);
+                dst[2] = SkGetPackedB32(c);
+                dst += 3;
+            }
+        }
+        break;
+    case SkBitmap::kRGB_565_Config: // hmmm, I should encode 16bit jpegs, not expand to 24 bit (doh!)
+        {
+            const uint16_t* src = bm.getAddr16(0, y);
+            while (--width >= 0)
+            {
+                uint16_t c = *src++;
+                dst[0] = SkPacked16ToR32(c);
+                dst[1] = SkPacked16ToG32(c);
+                dst[2] = SkPacked16ToB32(c);
+                dst += 3;
+            }
+        }
+        break;
+    default:
+        SkASSERT(!"unknown bitmap format for jpeg encode");
+    }
 }
 
 struct sk_destination_mgr : jpeg_destination_mgr
 {
-       sk_destination_mgr(SkWStream* stream);
+    sk_destination_mgr(SkWStream* stream);
 
-       SkWStream*      fStream;
+    SkWStream*  fStream;
 
-       enum {
-               kBufferSize = 1024
-       };
-       U8      fBuffer[kBufferSize];
+    enum {
+        kBufferSize = 1024
+    };
+    uint8_t fBuffer[kBufferSize];
 };
 
 static void sk_init_destination(j_compress_ptr cinfo)
 {
-       sk_destination_mgr* dest = (sk_destination_mgr*)cinfo->dest;
+    sk_destination_mgr* dest = (sk_destination_mgr*)cinfo->dest;
 
-       dest->next_output_byte = dest->fBuffer;
-       dest->free_in_buffer = sk_destination_mgr::kBufferSize;
+    dest->next_output_byte = dest->fBuffer;
+    dest->free_in_buffer = sk_destination_mgr::kBufferSize;
 }
 
 static boolean sk_empty_output_buffer(j_compress_ptr cinfo)
 {
-       sk_destination_mgr* dest = (sk_destination_mgr*)cinfo->dest;
+    sk_destination_mgr* dest = (sk_destination_mgr*)cinfo->dest;
 
-//     if (!dest->fStream->write(dest->fBuffer, sk_destination_mgr::kBufferSize - dest->free_in_buffer))
-       if (!dest->fStream->write(dest->fBuffer, sk_destination_mgr::kBufferSize))
-               sk_throw();
-       //      ERREXIT(cinfo, JERR_FILE_WRITE);
+//  if (!dest->fStream->write(dest->fBuffer, sk_destination_mgr::kBufferSize - dest->free_in_buffer))
+    if (!dest->fStream->write(dest->fBuffer, sk_destination_mgr::kBufferSize))
+        sk_throw();
+    //  ERREXIT(cinfo, JERR_FILE_WRITE);
 
-       dest->next_output_byte = dest->fBuffer;
-       dest->free_in_buffer = sk_destination_mgr::kBufferSize;
-       return TRUE;
+    dest->next_output_byte = dest->fBuffer;
+    dest->free_in_buffer = sk_destination_mgr::kBufferSize;
+    return TRUE;
 }
 
 static void sk_term_destination (j_compress_ptr cinfo)
 {
-       sk_destination_mgr* dest = (sk_destination_mgr*)cinfo->dest;
-
-       size_t size = sk_destination_mgr::kBufferSize - dest->free_in_buffer;
-       if (size > 0)
-       {
-               if (!dest->fStream->write(dest->fBuffer, size))
-                       sk_throw();
-       }
-       dest->fStream->flush();
+    sk_destination_mgr* dest = (sk_destination_mgr*)cinfo->dest;
+
+    size_t size = sk_destination_mgr::kBufferSize - dest->free_in_buffer;
+    if (size > 0)
+    {
+        if (!dest->fStream->write(dest->fBuffer, size))
+            sk_throw();
+    }
+    dest->fStream->flush();
 }
 
 sk_destination_mgr::sk_destination_mgr(SkWStream* stream)
-       : fStream(stream)
+    : fStream(stream)
 {
-       this->init_destination = sk_init_destination;
-       this->empty_output_buffer = sk_empty_output_buffer;
-       this->term_destination = sk_term_destination;
+    this->init_destination = sk_init_destination;
+    this->empty_output_buffer = sk_empty_output_buffer;
+    this->term_destination = sk_term_destination;
 }
 
 
 class SkJPEGImageEncoder : public SkImageEncoder {
 protected:
-       virtual bool onEncode(SkWStream* stream, const SkBitmap& bm, int quality)
-       {
-               jpeg_compress_struct    cinfo;
-               sk_error_mgr                    sk_err;
-               sk_destination_mgr              sk_wstream(stream);
-
-               cinfo.err = jpeg_std_error(&sk_err);
-               sk_err.error_exit = sk_error_exit;
-               if (setjmp(sk_err.fJmpBuf))
-                       return false;
-
-               jpeg_create_compress(&cinfo);
-
-               cinfo.dest = &sk_wstream;
-               cinfo.image_width = bm.width();
-               cinfo.image_height = bm.height();
-               cinfo.input_components = 3;
-               cinfo.in_color_space = JCS_RGB;
-
-               jpeg_set_defaults(&cinfo);
-               jpeg_set_quality(&cinfo, quality, TRUE /* limit to baseline-JPEG values */);
-               jpeg_start_compress(&cinfo, TRUE);
-
-               SkAutoMalloc    oneRow(bm.width() * 3);
-               U8*                             oneRowP = (U8*)oneRow.get();
-
-               while (cinfo.next_scanline < cinfo.image_height)
-               {
-                       JSAMPROW row_pointer[1];        /* pointer to JSAMPLE row[s] */
-
-                       convert_to_rgb24(oneRowP, bm, cinfo.next_scanline);
-                       row_pointer[0] = oneRowP;
-                       (void) jpeg_write_scanlines(&cinfo, row_pointer, 1);
-               }
-
-               jpeg_finish_compress(&cinfo);
-               jpeg_destroy_compress(&cinfo);
-               return true;
-       }
+    virtual bool onEncode(SkWStream* stream, const SkBitmap& bm, int quality)
+    {
+        jpeg_compress_struct    cinfo;
+        sk_error_mgr            sk_err;
+        sk_destination_mgr      sk_wstream(stream);
+
+        cinfo.err = jpeg_std_error(&sk_err);
+        sk_err.error_exit = sk_error_exit;
+        if (setjmp(sk_err.fJmpBuf))
+            return false;
+
+        jpeg_create_compress(&cinfo);
+
+        cinfo.dest = &sk_wstream;
+        cinfo.image_width = bm.width();
+        cinfo.image_height = bm.height();
+        cinfo.input_components = 3;
+        cinfo.in_color_space = JCS_RGB;
+
+        jpeg_set_defaults(&cinfo);
+        jpeg_set_quality(&cinfo, quality, TRUE /* limit to baseline-JPEG values */);
+        jpeg_start_compress(&cinfo, TRUE);
+
+        SkAutoMalloc    oneRow(bm.width() * 3);
+        uint8_t*        oneRowP = (uint8_t*)oneRow.get();
+
+        while (cinfo.next_scanline < cinfo.image_height)
+        {
+            JSAMPROW row_pointer[1];    /* pointer to JSAMPLE row[s] */
+
+            convert_to_rgb24(oneRowP, bm, cinfo.next_scanline);
+            row_pointer[0] = oneRowP;
+            (void) jpeg_write_scanlines(&cinfo, row_pointer, 1);
+        }
+
+        jpeg_finish_compress(&cinfo);
+        jpeg_destroy_compress(&cinfo);
+        return true;
+    }
 };
 
 SkImageEncoder* sk_create_jpeg_encoder();
@@ -419,9 +489,9 @@ SkImageEncoder* sk_create_jpeg_encoder()
 
 void SkImageDecoder::UnitTest()
 {
-       SkBitmap        bm;
+    SkBitmap    bm;
 
-       (void)SkImageDecoder::DecodeFile("logo.jpg", &bm);
+    (void)SkImageDecoder::DecodeFile("logo.jpg", &bm);
 }
 
 #endif
index 2dae48c..3bf4bbd 100644 (file)
@@ -1,3 +1,20 @@
+/* libs/graphics/images/SkImageDecoder_libpng.cpp
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #include "SkImageDecoder.h"
 #include "SkColor.h"
 #include "SkColorPriv.h"
@@ -7,7 +24,7 @@
 
 class SkPNGImageDecoder : public SkImageDecoder {
 protected:
-       virtual bool onDecode(SkStream* stream, SkBitmap* bm, SkBitmap::Config pref);
+    virtual bool onDecode(SkStream* stream, SkBitmap* bm, SkBitmap::Config pref);
 };
 
 #define TEST_DITHER
@@ -16,7 +33,6 @@ extern "C" {
 #include "png.h"
 }
 
-
 static void convert_from_32_to_16(SkBitmap* bm)
 {
     SkBitmap    tmp;
@@ -45,20 +61,20 @@ static void convert_from_32_to_16(SkBitmap* bm)
 /* Automatically clean up after throwing an exception */
 struct PNGAutoClean
 {
-       PNGAutoClean(png_structp p, png_infop i): png_ptr(p), info_ptr(i) {}
-       ~PNGAutoClean()
-       {
-               png_destroy_read_struct(&png_ptr, &info_ptr, png_infopp_NULL);
-       }
+    PNGAutoClean(png_structp p, png_infop i): png_ptr(p), info_ptr(i) {}
+    ~PNGAutoClean()
+    {
+        png_destroy_read_struct(&png_ptr, &info_ptr, png_infopp_NULL);
+    }
 private:
-       png_structp png_ptr;
-       png_infop info_ptr;
+    png_structp png_ptr;
+    png_infop info_ptr;
 };
 
 SkImageDecoder* SkImageDecoder_PNG_Factory(SkStream* stream)
 {
-       char buf[PNG_BYTES_TO_CHECK];
-       if (stream->read(buf, PNG_BYTES_TO_CHECK) == PNG_BYTES_TO_CHECK &&
+    char buf[PNG_BYTES_TO_CHECK];
+    if (stream->read(buf, PNG_BYTES_TO_CHECK) == PNG_BYTES_TO_CHECK &&
         !png_sig_cmp((png_bytep) buf, (png_size_t)0, PNG_BYTES_TO_CHECK))
     {
         stream->rewind();
@@ -68,71 +84,153 @@ SkImageDecoder* SkImageDecoder_PNG_Factory(SkStream* stream)
 }
 
 static void sk_read_fn(png_structp png_ptr, png_bytep data, png_size_t length) {
-       SkStream* sk_stream = (SkStream*) png_ptr->io_ptr;
-       size_t bytes = sk_stream->read(data, length);
-       if (bytes != length)
-               png_error(png_ptr, "Read Error!");
+    SkStream* sk_stream = (SkStream*) png_ptr->io_ptr;
+    size_t bytes = sk_stream->read(data, length);
+    if (bytes != length)
+        png_error(png_ptr, "Read Error!");
+}
+
+static int sk_read_user_chunk(png_structp png_ptr, png_unknown_chunkp chunk)
+{
+    SkImageDecoder::Peeker* peeker = (SkImageDecoder::Peeker*)png_get_user_chunk_ptr(png_ptr);
+    // peek() returning true means continue decoding
+    return peeker->peek((const char*)chunk->name, chunk->data, chunk->size) ? 1 : -1;
+}
+
+// return true if the scanline has at least one alpha != 0xFF
+typedef bool (*ConvertProc)(int y, int width, const uint8_t rgba[], SkBitmap* bm);
+
+static bool Convert_RGB_To32(int y, int width, const uint8_t rgba[], SkBitmap* bm)
+{
+    uint32_t* dst = bm->getAddr32(0, y);
+    uint32_t* stop = dst + width;
+
+    while (dst < stop) {
+        *dst++ = SkPackARGB32(0xFF, rgba[0], rgba[1], rgba[2]);
+        rgba += 4;
+    }
+    return false;
+}
+
+static bool Convert_ARGB_To32(int y, int width, const uint8_t rgba[], SkBitmap* bm)
+{
+    uint32_t* dst = bm->getAddr32(0, y);
+    uint32_t* stop = dst + width;
+    bool      reallyHasAlpha = false;
+
+    while (dst < stop) {
+        unsigned alpha = rgba[3];
+        *dst++ = SkPreMultiplyARGB(alpha, rgba[0], rgba[1], rgba[2]);
+        rgba += 4;
+        reallyHasAlpha |= (alpha != 0xFF);
+    }
+    return reallyHasAlpha;
+}
+
+static bool Convert_RGB_To16(int y, int width, const uint8_t rgba[], SkBitmap* bm)
+{
+    SkASSERT(width > 0);
+    
+    uint16_t* dst = bm->getAddr16(0, y);
+
+    // do the first pixel (if we're out of phase)
+    if (SkShouldDitherXY(0, y)) {
+        *dst++ = SkDitherPack888ToRGB16(rgba[0], rgba[1], rgba[2]);
+        rgba += 4;
+        width -= 1;
+    }
+    
+    int dcount = width >> 1;
+    for (int i = 0; i < dcount; i++) {
+        *dst++ = SkPack888ToRGB16(rgba[0], rgba[1], rgba[2]);
+        *dst++ = SkDitherPack888ToRGB16(rgba[4], rgba[5], rgba[6]);
+        rgba += 8;
+    }
+    
+    // now do the last pixel (if any)
+    if (width & 1) {
+        *dst++ = SkPack888ToRGB16(rgba[0], rgba[1], rgba[2]);
+    }
+    return false;
+}
+
+static ConvertProc ChooseProc(SkBitmap::Config config, bool srcHasAlpha)
+{
+    if (SkBitmap::kARGB_8888_Config == config)
+        return srcHasAlpha ? Convert_ARGB_To32 : Convert_RGB_To32;
+    else if (SkBitmap::kRGB_565_Config == config) {
+        SkASSERT(srcHasAlpha == false);
+        return Convert_RGB_To16;
+    }
+    return NULL;
 }
 
 bool SkPNGImageDecoder::onDecode(SkStream* sk_stream, SkBitmap* bm, SkBitmap::Config prefConfig)
 {
-       /* Create and initialize the png_struct with the desired error handler
-       * functions.  If you want to use the default stderr and longjump method,
-       * you can supply NULL for the last three parameters.  We also supply the
-       * the compiler header file version, so that we know if the application
-       * was compiled with a compatible version of the library.  */
-       png_structp png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING,
-               NULL, NULL, NULL);
-       //   png_voidp user_error_ptr, user_error_fn, user_warning_fn);
-       if (png_ptr == NULL)
-               return false; // error
-       /* Allocate/initialize the memory for image information. */
-       png_infop info_ptr = png_create_info_struct(png_ptr);
-
-       if (info_ptr == NULL)
-       {
-               png_destroy_read_struct(&png_ptr, png_infopp_NULL, png_infopp_NULL);
-               return false; // error
-       }
-       PNGAutoClean autoClean(png_ptr, info_ptr);
-       /* Set error handling if you are using the setjmp/longjmp method (this is
-       * the normal method of doing things with libpng).  REQUIRED unless you
-       * set up your own error handlers in the png_create_read_struct() earlier.
-       */
-       if (setjmp(png_jmpbuf(png_ptr)))
-       {
-               /* If we get here, we had a problem reading the file */
-               return false; // error
-       }
-       /* If you are using replacement read functions, instead of calling
-       * png_init_io() here you would call:
-       */
-       png_set_read_fn(png_ptr, (void *)sk_stream, sk_read_fn);
-       /* where user_io_ptr is a structure you want available to the callbacks */
-       /* If we have already read some of the signature */
-//     png_set_sig_bytes(png_ptr, 0 /* sig_read */ );
-       /* The call to png_read_info() gives us all of the information from the
-       * PNG file before the first IDAT (image data chunk). */
-       png_read_info(png_ptr, info_ptr);
-       png_uint_32 width, height;
-       int bit_depth, color_type, interlace_type;
-       png_get_IHDR(png_ptr, info_ptr, &width, &height, &bit_depth, &color_type,
-               &interlace_type, int_p_NULL, int_p_NULL);
-
-       /* tell libpng to strip 16 bit/color files down to 8 bits/color */
-       if (bit_depth == 16)
-               png_set_strip_16(png_ptr);
-
-       /* Extract multiple pixels with bit depths of 1, 2, and 4 from a single
-       * byte into separate bytes (useful for paletted and grayscale images). */
-       if (bit_depth < 8)
-               png_set_packing(png_ptr);
-
-       /* Expand grayscale images to the full 8 bits from 1, 2, or 4 bits/pixel */
-       if (color_type == PNG_COLOR_TYPE_GRAY && bit_depth < 8)
-               png_set_gray_1_2_4_to_8(png_ptr);
-
-       /* Make a grayscale image into RGB. */
+    /* Create and initialize the png_struct with the desired error handler
+    * functions.  If you want to use the default stderr and longjump method,
+    * you can supply NULL for the last three parameters.  We also supply the
+    * the compiler header file version, so that we know if the application
+    * was compiled with a compatible version of the library.  */
+    png_structp png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING,
+        NULL, NULL, NULL);
+    //   png_voidp user_error_ptr, user_error_fn, user_warning_fn);
+    if (png_ptr == NULL)
+        return false; // error
+    /* Allocate/initialize the memory for image information. */
+    png_infop info_ptr = png_create_info_struct(png_ptr);
+
+    if (info_ptr == NULL)
+    {
+        png_destroy_read_struct(&png_ptr, png_infopp_NULL, png_infopp_NULL);
+        return false; // error
+    }
+    PNGAutoClean autoClean(png_ptr, info_ptr);
+    /* Set error handling if you are using the setjmp/longjmp method (this is
+    * the normal method of doing things with libpng).  REQUIRED unless you
+    * set up your own error handlers in the png_create_read_struct() earlier.
+    */
+    if (setjmp(png_jmpbuf(png_ptr)))
+    {
+        /* If we get here, we had a problem reading the file */
+        return false; // error
+    }
+    /* If you are using replacement read functions, instead of calling
+    * png_init_io() here you would call:
+    */
+    png_set_read_fn(png_ptr, (void *)sk_stream, sk_read_fn);
+    /* where user_io_ptr is a structure you want available to the callbacks */
+    /* If we have already read some of the signature */
+//  png_set_sig_bytes(png_ptr, 0 /* sig_read */ );
+
+    // hookup our peeker so we can see any user-chunks the caller may be interested in
+    png_set_keep_unknown_chunks(png_ptr, PNG_HANDLE_CHUNK_ALWAYS, (png_byte*)"", 0);
+    if (this->getPeeker()) {
+        png_set_read_user_chunk_fn(png_ptr, (png_voidp)this->getPeeker(), sk_read_user_chunk);
+    }
+
+    /* The call to png_read_info() gives us all of the information from the
+    * PNG file before the first IDAT (image data chunk). */
+    png_read_info(png_ptr, info_ptr);
+    png_uint_32 width, height;
+    int bit_depth, color_type, interlace_type;
+    png_get_IHDR(png_ptr, info_ptr, &width, &height, &bit_depth, &color_type,
+        &interlace_type, int_p_NULL, int_p_NULL);
+
+    /* tell libpng to strip 16 bit/color files down to 8 bits/color */
+    if (bit_depth == 16)
+        png_set_strip_16(png_ptr);
+
+    /* Extract multiple pixels with bit depths of 1, 2, and 4 from a single
+    * byte into separate bytes (useful for paletted and grayscale images). */
+    if (bit_depth < 8)
+        png_set_packing(png_ptr);
+
+    /* Expand grayscale images to the full 8 bits from 1, 2, or 4 bits/pixel */
+    if (color_type == PNG_COLOR_TYPE_GRAY && bit_depth < 8)
+        png_set_gray_1_2_4_to_8(png_ptr);
+
+    /* Make a grayscale image into RGB. */
     if (color_type == PNG_COLOR_TYPE_GRAY || color_type == PNG_COLOR_TYPE_GRAY_ALPHA)
           png_set_gray_to_rgb(png_ptr);
 
@@ -143,30 +241,30 @@ bool SkPNGImageDecoder::onDecode(SkStream* sk_stream, SkBitmap* bm, SkBitmap::Co
     // draw lots faster if we can flag the bitmap has being opaque
     bool    reallyHasAlpha = false;
 
-       if (color_type == PNG_COLOR_TYPE_PALETTE)
-       {
-               int num_palette;
-               png_colorp palette;
-               png_bytep trans;
-               int num_trans;
+    if (color_type == PNG_COLOR_TYPE_PALETTE)
+    {
+        int num_palette;
+        png_colorp palette;
+        png_bytep trans;
+        int num_trans;
 
-               SkColorTable* colorTable = SkNEW(SkColorTable);
-               SkAutoTDelete<SkColorTable> autoDel(colorTable);
+        SkColorTable* colorTable = SkNEW(SkColorTable);
+        SkAutoTDelete<SkColorTable> autoDel(colorTable);
 
-               png_get_PLTE(png_ptr, info_ptr, &palette, &num_palette);
+        png_get_PLTE(png_ptr, info_ptr, &palette, &num_palette);
 
-               /*      BUGGY IMAGE WORKAROUND
+        /*  BUGGY IMAGE WORKAROUND
 
-                       We hit some images (e.g. fruit_.png) who contain bytes that are == colortable_count
-                       which is a problem since we use the byte as an index. To work around this we grow
-                       the colortable by 1 (if its < 256) and duplicate the last color into that slot.
-               */
-               colorTable->setColors(num_palette + (num_palette < 256));
+            We hit some images (e.g. fruit_.png) who contain bytes that are == colortable_count
+            which is a problem since we use the byte as an index. To work around this we grow
+            the colortable by 1 (if its < 256) and duplicate the last color into that slot.
+        */
+        colorTable->setColors(num_palette + (num_palette < 256));
 
-               SkPMColor* colorPtr = colorTable->lockColors();
+        SkPMColor* colorPtr = colorTable->lockColors();
         if (png_get_valid(png_ptr, info_ptr, PNG_INFO_tRNS))
         {
-                       png_get_tRNS(png_ptr, info_ptr, &trans, &num_trans, NULL);
+            png_get_tRNS(png_ptr, info_ptr, &trans, &num_trans, NULL);
             hasAlpha = (num_trans > 0);
         }
         else
@@ -183,42 +281,42 @@ bool SkPNGImageDecoder::onDecode(SkStream* sk_stream, SkBitmap* bm, SkBitmap::Co
         for (; index < num_trans; index++)
         {
             transLessThanFF |= (int)*trans - 0xFF;
-                       *colorPtr++ = SkPreMultiplyARGB(*trans++, palette->red, palette->green, palette->blue);
+            *colorPtr++ = SkPreMultiplyARGB(*trans++, palette->red, palette->green, palette->blue);
             palette++;
         }
         reallyHasAlpha |= (transLessThanFF < 0);
 
         for (; index < num_palette; index++)
         {
-                       *colorPtr++ = SkPackARGB32(0xFF, palette->red, palette->green, palette->blue);
+            *colorPtr++ = SkPackARGB32(0xFF, palette->red, palette->green, palette->blue);
             palette++;
         }
 
-               // see BUGGY IMAGE WORKAROUND comment above
-               if (num_palette < 256)
-                       colorPtr[num_palette] = colorPtr[num_palette - 1];
+        // see BUGGY IMAGE WORKAROUND comment above
+        if (num_palette < 256)
+            *colorPtr = colorPtr[-1];
 
-               colorTable->unlockColors(true);
-               bm->setColorTable(colorTable)->unref();
-               (void)autoDel.detach();
-       }
+        colorTable->unlockColors(true);
+        bm->setColorTable(colorTable)->unref();
+        (void)autoDel.detach();
+    }
 
-       SkBitmap::Config        config;
+    SkBitmap::Config    config;
 
-       if (color_type == PNG_COLOR_TYPE_PALETTE)
-               config = SkBitmap::kIndex8_Config;
-       else
+    if (color_type == PNG_COLOR_TYPE_PALETTE)
+        config = SkBitmap::kIndex8_Config;
+    else
     {
         png_color_16p   transColor;
         
-               if (png_get_tRNS(png_ptr, info_ptr, NULL, NULL, &transColor))
+        if (png_get_tRNS(png_ptr, info_ptr, NULL, NULL, &transColor))
         {
             SkDEBUGF(("********************* png_get_tRNS [%d %d %d]\n", transColor->red, transColor->green, transColor->blue));
         }
 
         if (png_get_valid(png_ptr, info_ptr, PNG_INFO_tRNS) ||  color_type == PNG_COLOR_TYPE_RGB_ALPHA)
         {
-                       hasAlpha = true;
+            hasAlpha = true;
             config = SkBitmap::kARGB_8888_Config;
         }
         else    // we get to choose the config
@@ -232,145 +330,70 @@ bool SkPNGImageDecoder::onDecode(SkStream* sk_stream, SkBitmap* bm, SkBitmap::Co
         }
     }
 
-       bm->setConfig(config, width, height, 0);
-       bm->allocPixels();
+    if (!this->chooseFromOneChoice(config, width, height))
+        return false;
+
+    bm->setConfig(config, width, height, 0);
+    bm->allocPixels();
+
+    /* swap the RGBA or GA data to ARGB or AG (or BGRA to ABGR) */
+//  if (color_type == PNG_COLOR_TYPE_RGB_ALPHA)
+//      ; // png_set_swap_alpha(png_ptr);
 
-       /* swap the RGBA or GA data to ARGB or AG (or BGRA to ABGR) */
-//     if (color_type == PNG_COLOR_TYPE_RGB_ALPHA)
-//             ; // png_set_swap_alpha(png_ptr);
+    /* swap bytes of 16 bit files to least significant byte first */
+    //   png_set_swap(png_ptr);
 
-       /* swap bytes of 16 bit files to least significant byte first */
-       //   png_set_swap(png_ptr);
+    /* Add filler (or alpha) byte (before/after each RGB triplet) */
+    if (color_type == PNG_COLOR_TYPE_RGB || color_type == PNG_COLOR_TYPE_GRAY)
+        png_set_filler(png_ptr, 0xff, PNG_FILLER_AFTER);
 
-       /* Add filler (or alpha) byte (before/after each RGB triplet) */
-       if (color_type == PNG_COLOR_TYPE_RGB || color_type == PNG_COLOR_TYPE_GRAY)
-               png_set_filler(png_ptr, 0xff, PNG_FILLER_AFTER);
+    /* Turn on interlace handling.  REQUIRED if you are not using
+    * png_read_image().  To see how to handle interlacing passes,
+    * see the png_read_row() method below:
+    */
+    int number_passes = interlace_type != PNG_INTERLACE_NONE ? 
+        png_set_interlace_handling(png_ptr) : 1;
 
-       /* Turn on interlace handling.  REQUIRED if you are not using
-       * png_read_image().  To see how to handle interlacing passes,
-       * see the png_read_row() method below:
-       */
-       int number_passes = interlace_type != PNG_INTERLACE_NONE ? 
-               png_set_interlace_handling(png_ptr) : 1;
+    /* Optional call to gamma correct and add the background to the palette
+    * and update info structure.  REQUIRED if you are expecting libpng to
+    * update the palette for you (ie you selected such a transform above).
+    */
+    png_read_update_info(png_ptr, info_ptr);
 
-       /* Optional call to gamma correct and add the background to the palette
-       * and update info structure.  REQUIRED if you are expecting libpng to
-       * update the palette for you (ie you selected such a transform above).
-       */
-       png_read_update_info(png_ptr, info_ptr);
+    uint8_t* tmpStorage = NULL;
+    uint8_t* storage = NULL;
 
-    uint32_t* tmpStorage = nil;
-    if (config == SkBitmap::kRGB_565_Config)
+    if (SkBitmap::kRGB_565_Config == config)
     {
         SkASSERT(!hasAlpha);
-        tmpStorage = (uint32_t*)sk_malloc_throw(bm->rowBytes() * 2);
+        tmpStorage = (uint8_t*)sk_malloc_throw(width * 4);
+        storage = tmpStorage;
     }
+    else if (SkBitmap::kARGB_8888_Config == config)
+        storage = (uint8_t*)bm->getAddr32(0, height - 1);
 
-       /* The other way to read images - deal with interlacing: */
-       for (int pass = 0; pass < number_passes; pass++)
-       {
-               /* Read the image a single row at a time */
-               for (png_uint_32 y = 0; y < height; y++)
-               {
-                       switch (config) {
-            case SkBitmap::kRGB_565_Config: // good place to consider cary's even/odd dither
-                               {
-                                       uint32_t* tmp = tmpStorage;
-                    uint16_t* dstRow = bm->getAddr16(0, y);
-                                       png_read_rows(png_ptr, (uint8_t**)&tmp, png_bytepp_NULL, 1);
-
-                    /*  PNG's argb now needs to be set to the correct byte order for us, and match our alpha-byte
-                        convention of either 0xFF for opaque, or premul the rgb components
-                    */
-                    for (png_uint_32 x = 0; x < width; x++) {
-                        uint32_t color = tmpStorage[x];
-#ifdef TEST_DITHER
-                        if (SkShouldDitherXY(x, y)) {
-        #ifdef SK_CPU_BENDIAN
-                            unsigned r = (color >> 24) & 0xFF;
-                            unsigned g = (color >> 16) & 0xFF;
-                            unsigned b = (color >>  8) & 0xFF;
-        #else          
-                            unsigned r = (color >>  0) & 0xFF;
-                            unsigned g = (color >>  8) & 0xFF;
-                            unsigned b = (color >> 16) & 0xFF;
-        #endif
-                            dstRow[x] = SkDitherPack888ToRGB16(r, g, b);
-                        }
-                        else {  // fall through to non TEST_DITHER code
-#endif
-    #ifdef SK_CPU_BENDIAN
-                        unsigned r = (color >> 27) & 0x1F;
-                        unsigned g = (color >> 18) & 0x3F;
-                        unsigned b = (color >> 11) & 0x1F;
-    #else      
-                        unsigned r = (color >>  3) & 0x1F;
-                        unsigned g = (color >> 10) & 0x3F;
-                        unsigned b = (color >> 19) & 0x1F;
-    #endif
-                        dstRow[x] = SkPackRGB16(r, g, b);
-#ifdef TEST_DITHER
-                    }   // else clause for shouldditherxy
-#endif
-                    }   // for-loop
-                               }
-                               break;
-                       case SkBitmap::kARGB_8888_Config:
-                               {
-                                       uint32_t* bmRow = bm->getAddr32(0, y);
-                    uint32_t* origRow = bmRow;
-                                       png_read_rows(png_ptr, (uint8_t**)&bmRow, png_bytepp_NULL, 1);
-
-                    /*  PNG's argb now needs to be set to the correct byte order for us, and match our alpha-byte
-                        convention of either 0xFF for opaque, or premul the rgb components
-                    */
-
-                    if (hasAlpha) {   // premul the RGB components
-                        for (png_uint_32 x = 0; x < width; x++) {
-                            uint32_t color = origRow[x];
-                            unsigned a = (color >> 24) & 0xFF;
-                            unsigned b = (color >> 16) & 0xFF;
-                            unsigned c = (color >>  8) & 0xFF;
-                            unsigned d = (color >>  0) & 0xFF;
-                            
-#ifdef SK_CPU_BENDIAN
-                            origRow[x] = SkPreMultiplyARGB(d, a, b, c);
-                            reallyHasAlpha |= (d != 0xFF);
-#else          
-                            origRow[x] = SkPreMultiplyARGB(a, d, c, b);
-                            reallyHasAlpha |= (a != 0xFF);
-#endif
-                        }
-                    }
-                    else {  // jam in 0xFF for the alpha values
-                        for (png_uint_32 x = 0; x < width; x++) {
-                            uint32_t color = origRow[x];
-#ifdef SK_CPU_BENDIAN
-                            unsigned a = (color >> 24) & 0xFF;
-                            unsigned b = (color >> 16) & 0xFF;
-                            unsigned c = (color >>  8) & 0xFF;
-                            origRow[x] = SkPackARGB32(0xFF, a, b, c);
-#else          
-                            unsigned b = (color >> 16) & 0xFF;
-                            unsigned c = (color >>  8) & 0xFF;
-                            unsigned d = (color >>  0) & 0xFF;
-                            origRow[x] = SkPackARGB32(0xFF, d, c, b);
-#endif
-                        }
-                    }
-                               }
-                               break;
-                       case SkBitmap::kIndex8_Config:
-                               {
-                                       uint8_t*         bmRow = bm->getAddr8(0, y);
-                                       png_read_rows(png_ptr, (uint8_t**) &bmRow, png_bytepp_NULL, 1);
-                               }
-                               break;
-                       default:        // to avoid warnings
-                               break;
-                       }
-               }
-       }
+    ConvertProc convert_proc = ChooseProc(config, hasAlpha);
+
+    /* The other way to read images - deal with interlacing: */
+    for (int pass = 0; pass < number_passes; pass++)
+    {
+        if (SkBitmap::kIndex8_Config == config) {
+            for (png_uint_32 y = 0; y < height; y++)
+            {
+                uint8_t* bmRow = bm->getAddr8(0, y);
+                png_read_rows(png_ptr, &bmRow, png_bytepp_NULL, 1);
+            }
+        }
+        else {
+            SkASSERT(convert_proc != NULL);
+            for (png_uint_32 y = 0; y < height; y++)
+            {
+                uint8_t* tmp = storage;
+                png_read_rows(png_ptr, &tmp, png_bytepp_NULL, 1);
+                reallyHasAlpha |= convert_proc(y, width, storage, bm);
+            }
+        }
+    }
     
     if (hasAlpha && !reallyHasAlpha) {
         SkDEBUGF(("Image doesn't really have alpha [%d %d]\n", width, height));
@@ -381,10 +404,10 @@ bool SkPNGImageDecoder::onDecode(SkStream* sk_stream, SkBitmap* bm, SkBitmap::Co
 
     sk_free(tmpStorage);
 
-       /* read rest of file, and get additional chunks in info_ptr - REQUIRED */
-       png_read_end(png_ptr, info_ptr);
+    /* read rest of file, and get additional chunks in info_ptr - REQUIRED */
+    png_read_end(png_ptr, info_ptr);
 
-       return true;
+    return true;
 }
 
 ////////////////////////////////////////////////////////////////////////////////////////////////
@@ -400,8 +423,8 @@ static void sk_error_fn(png_structp png_ptr, png_const_charp msg)
 
 static void sk_write_fn(png_structp png_ptr, png_bytep data, png_size_t length)
 {
-       SkWStream* sk_stream = (SkWStream*)png_ptr->io_ptr;
-       if (!sk_stream->write(data, length))
+    SkWStream* sk_stream = (SkWStream*)png_ptr->io_ptr;
+    if (!sk_stream->write(data, length))
         png_error(png_ptr, "sk_write_fn Error!");
 }
 
@@ -479,7 +502,7 @@ static transform_scanline_proc choose_proc(SkBitmap::Config config, bool hasAlph
 
 class SkPNGImageEncoder : public SkImageEncoder {
 protected:
-       virtual bool onEncode(SkWStream* stream, const SkBitmap& bm, int quality);
+    virtual bool onEncode(SkWStream* stream, const SkBitmap& bm, int quality);
 };
 
 bool SkPNGImageEncoder::onEncode(SkWStream* stream, const SkBitmap& bitmap, int /*quality*/)
@@ -569,7 +592,7 @@ bool SkPNGImageEncoder::onEncode(SkWStream* stream, const SkBitmap& bitmap, int
     char*                   storage = (char*)sk_malloc_throw(bitmap.width() << 2);
     transform_scanline_proc proc = choose_proc(config, hasAlpha);
 
-    for (unsigned y = 0; y < bitmap.height(); y++)
+    for (int y = 0; y < bitmap.height(); y++)
     {
         png_bytep row_ptr = (png_bytep)storage;
         proc(srcImage, bitmap.width(), storage);
diff --git a/libs/graphics/images/SkImageDecoder_zbm.cpp b/libs/graphics/images/SkImageDecoder_zbm.cpp
new file mode 100644 (file)
index 0000000..3852bdd
--- /dev/null
@@ -0,0 +1,263 @@
+/* libs/graphics/images/SkImageDecoder_zbm.cpp
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
+#include "SkImageDecoder.h"
+#include "SkColor.h"
+#include "SkColorPriv.h"
+#include "SkEndian.h"
+#include "SkMath.h"
+#include "SkStream.h"
+#include "SkTemplates.h"
+#include "SkEndian.h"
+
+extern "C" {
+    #include "zlib.h"
+}
+#define DEF_MEM_LEVEL 8                // normally in zutil.h?
+
+static uint16_t* endian_swap16(uint16_t dst[], const uint16_t src[], int count)
+{
+    for (int i = 0; i < count; i++)
+        dst[i] = SkEndianSwap16(src[i]);
+    return dst;
+}
+
+static void endian_swap16(uint16_t data[], int count)
+{
+    (void)endian_swap16(data, data, count);
+}
+
+class SkZBMImageDecoder : public SkImageDecoder {
+protected:
+    virtual bool onDecode(SkStream* stream, SkBitmap* bm, SkBitmap::Config pref);
+};
+
+#define SIGNATURE   "ZlibImag"
+
+#define VERSION 0
+
+enum Format {
+    k565_LEndian
+};
+
+enum Compression {
+    kNone_Compression,
+    kZLib_Compression
+};
+
+struct Header {
+    uint8_t     fSignature[8];
+
+    uint32_t    fCompressedSize;
+    uint16_t    fWidth, fHeight;
+    uint8_t     fVersion;
+    uint8_t     fFormat;
+    uint8_t     fCompression;
+    uint8_t     fPad;
+    // [] compressed data
+};
+    
+SkImageDecoder* SkImageDecoder_ZBM_Factory(SkStream* stream)
+{
+    uint8_t sig[8];
+    
+    if (stream->read(sig, sizeof(sig)) == sizeof(sig) &&
+        memcmp(sig, SIGNATURE, sizeof(sig)) == 0)
+    {
+        return SkNEW(SkZBMImageDecoder);
+    }
+    return NULL;
+}
+
+bool SkZBMImageDecoder::onDecode(SkStream* stream, SkBitmap* bm, SkBitmap::Config prefConfig)
+{
+    Header  head;
+    
+    if (stream->read(&head, sizeof(head)) != sizeof(head))
+    {
+        printf("--------------- SkZBMImageDecoder: cannot read header\n");
+        return false;
+    }
+
+    //  Now convert (as necessary) the endianness of our fields (they are stored in BEndian)
+    size_t   compressedSize = SkEndian_SwapBE32(head.fCompressedSize);
+    unsigned width          = SkEndian_SwapBE16(head.fWidth);
+    unsigned height         = SkEndian_SwapBE16(head.fHeight);
+
+    if (0 == width || 0 == height ||
+        VERSION != head.fVersion ||
+        k565_LEndian != head.fFormat ||
+        kZLib_Compression != head.fCompression)
+    {
+        printf("--------------- SkZBMImageDecoder: bad header\n");
+        return false;
+    }
+
+    SkAutoMalloc    storage(compressedSize, SK_MALLOC_TEMP);
+    void*           src = storage.get();
+    
+    if (NULL == src || stream->read(src, compressedSize) != compressedSize)
+    {
+        printf("--------------- SkZBMImageDecoder: cannot read stream\n");
+        return false;
+    }
+
+    z_stream    z;
+
+    memset(&z, 0, sizeof(z));
+    z.next_in = (Bytef*)src;
+    z.avail_in = compressedSize;
+    z.data_type = Z_UNKNOWN;
+    if (inflateInit2(&z, -MAX_WBITS) != 0)
+    {
+        printf("--------------- SkZBMImageDecoder: inflateInit2 failed\n");
+        return false;
+    }
+
+    bool        success = false;
+    SkBitmap    tmp;
+    tmp.setConfig(SkBitmap::kRGB_565_Config, width, height, width << 1);
+    tmp.allocPixels();
+
+    for (unsigned y = 0; y < height; y++)
+    {
+        z.next_out = (Bytef*)tmp.getAddr16(0, y);
+        z.avail_out = width << 1;
+        int result = inflate(&z, Z_NO_FLUSH);
+        if (Z_STREAM_END == result)
+        {
+            if (y < height - 1) // we terminated early
+                goto DONE;
+            break;
+        }
+        if (Z_OK != result)
+            goto DONE;
+    }
+    success = true;
+
+#ifdef SK_CPU_BENDIAN
+    endian_swap16(tmp.getAddr16(0, 0), height * tmp.rowBytes() >> 1);
+#endif
+    bm->swap(tmp);
+
+DONE:
+    inflateEnd(&z);
+    return success;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////
+
+#ifdef SK_SUPPORT_IMAGE_ENCODE
+
+class SkZBMImageEncoder : public SkImageEncoder {
+protected:
+    virtual bool onEncode(SkWStream* stream, const SkBitmap& bm, int quality);
+};
+
+bool SkZBMImageEncoder::onEncode(SkWStream* stream, const SkBitmap& bm, int /*quality*/)
+{
+    SkBitmap::Config config = bm.getConfig();
+    
+    if (config != SkBitmap::kRGB_565_Config)
+    {
+        SkDEBUGF(("SkZLibImageEncoder::onEncode can't encode %d config\n", config));
+        return false;
+    }
+    
+    //////////// Compress the bitmap image
+    
+    int             width = bm.width();
+    int             height = bm.height();
+    size_t          dstSize = width * height << 1;  // worst case for compression
+    SkAutoMalloc    storage(dstSize, SK_MALLOC_TEMP);
+    void*           dst = storage.get();
+    
+    if (NULL == dst)
+        return false;
+
+    z_stream    z;
+    
+    memset(&z, 0, sizeof(z));
+    if (deflateInit2(&z, Z_BEST_COMPRESSION, Z_DEFLATED, -MAX_WBITS,
+                     DEF_MEM_LEVEL, Z_DEFAULT_STRATEGY) != Z_OK)
+        return false;
+
+// we want to always create LEndian images for now
+#ifdef SK_CPU_BENDIAN
+    SkAutoTMalloc<uint16_t> scanline(width);
+    uint16_t*               scan = scanline.get();
+#endif
+
+    z.avail_out = dstSize;
+    z.next_out  = (Bytef*)dst;
+    for (int y = 0; y < height - 1; y++)
+    {
+        z.avail_in  = width << 1;
+#ifdef SK_CPU_BENDIAN
+        z.next_in   = (Bytef*)endian_swap16(scan, bm.getAddr16(0, y), width);
+#else
+        z.next_in   = (Bytef*)bm.getAddr16(0, y);
+#endif
+        if (deflate(&z, Z_NO_FLUSH) != Z_OK)
+        {
+            deflateEnd(&z);
+            return false;
+        }
+    }
+
+    // compress the last scanline
+    z.avail_in  = width << 1;
+#ifdef SK_CPU_BENDIAN
+    z.next_in   = (Bytef*)endian_swap16(scan, bm.getAddr16(0, height - 1), width);
+#else
+    z.next_in   = (Bytef*)bm.getAddr16(0, height - 1);
+#endif
+    if (deflate(&z, Z_FINISH) != Z_STREAM_END)
+    {
+        deflateEnd(&z);
+        return false;
+    }
+
+    size_t  compressedSize = z.total_out;
+    deflateEnd(&z);
+
+    //////////// Now write the data to the stream
+    
+    Header head;
+    
+    memcpy(head.fSignature, SIGNATURE, sizeof(head.fSignature));
+    head.fCompressedSize = SkEndian_SwapBE32(compressedSize);
+    head.fWidth = SkEndian_SwapBE16(bm.width());
+    head.fHeight = SkEndian_SwapBE16(bm.height());
+    head.fVersion = VERSION;
+    head.fFormat = k565_LEndian;
+    head.fCompression = kZLib_Compression;
+    head.fPad = 0;
+
+    return stream->write(&head, sizeof(head)) &&
+           stream->write(dst, compressedSize);
+}
+
+SkImageEncoder* SkImageEncoder_ZBM_Factory();
+SkImageEncoder* SkImageEncoder_ZBM_Factory()
+{
+    return SkNEW(SkZBMImageEncoder);
+}
+
+#endif /* SK_SUPPORT_IMAGE_ENCODE */
+
+
index 49984d1..a10405b 100644 (file)
@@ -1,3 +1,20 @@
+/* libs/graphics/images/SkStream.cpp
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #include "SkStream.h"
 #include "SkFixed.h"
 #include "SkString.h"
 
 const char* SkStream::getFileName()
 {
-       // override in subclass if you represent a file
-       return NULL;
+    // override in subclass if you represent a file
+    return NULL;
 }
 
 static const char gPrefix[] = "file:\0" "http:\0" "https:\0" "ftp:\0"  ;
 
 bool SkStream::IsAbsoluteURI(const char path[])
 {
-       int prefix = SkStrStartsWithOneOf(path, gPrefix);
-       if (prefix >= 0)
-               return true;
-       return path[0] != '.';
+    int prefix = SkStrStartsWithOneOf(path, gPrefix);
+    if (prefix >= 0)
+        return true;
+    return path[0] != '.';
 }
 
 SkStream* SkStream::GetURIStream(const char prefix[], const char path[])
 {
-       int index = SkStrStartsWithOneOf(path, gPrefix);
-       if (prefix && prefix[0] && index < 0)
-       {
-               SkString fullPath(prefix);
-               fullPath.append(path);
-               return GetURIStream(NULL, fullPath.c_str());
-       }
-       if (index > 0)
-         return SkNEW_ARGS(SkURLStream, (path));
-       if (index == 0)
-               path += 5;
-    return SkNEW_ARGS(SkFILEStream, (path));   
+    int index = SkStrStartsWithOneOf(path, gPrefix);
+    if (prefix && prefix[0] && index < 0)
+    {
+        SkString fullPath(prefix);
+        fullPath.append(path);
+        return GetURIStream(NULL, fullPath.c_str());
+    }
+    if (index > 0)
+      return SkNEW_ARGS(SkURLStream, (path));
+    if (index == 0)
+        path += 5;
+    return SkNEW_ARGS(SkFILEStream, (path));    
 }
 
 SkWStream::~SkWStream()
@@ -41,7 +58,7 @@ SkWStream::~SkWStream()
 
 void SkWStream::newline()
 {
-       this->write("\n", 1);
+    this->write("\n", 1);
 }
 
 void SkWStream::flush()
@@ -50,29 +67,29 @@ void SkWStream::flush()
 
 bool SkWStream::writeText(const char text[])
 {
-       SkASSERT(text);
-       return this->write(text, strlen(text));
+    SkASSERT(text);
+    return this->write(text, strlen(text));
 }
 
 bool SkWStream::writeDecAsText(S32 dec)
 {
-       SkString        tmp;
-       tmp.appendS32(dec);
-       return this->write(tmp.c_str(), tmp.size());
+    SkString    tmp;
+    tmp.appendS32(dec);
+    return this->write(tmp.c_str(), tmp.size());
 }
 
 bool SkWStream::writeHexAsText(U32 hex, int digits)
 {
-       SkString        tmp;
-       tmp.appendHex(hex, digits);
-       return this->write(tmp.c_str(), tmp.size());
+    SkString    tmp;
+    tmp.appendHex(hex, digits);
+    return this->write(tmp.c_str(), tmp.size());
 }
 
 bool SkWStream::writeScalarAsText(SkScalar value)
 {
-       SkString        tmp;
-       tmp.appendScalar(value);
-       return this->write(tmp.c_str(), tmp.size());
+    SkString    tmp;
+    tmp.appendScalar(value);
+    return this->write(tmp.c_str(), tmp.size());
 }
 
 ////////////////////////////////////////////////////////////////////////////
@@ -80,240 +97,240 @@ bool SkWStream::writeScalarAsText(SkScalar value)
 SkFILEStream::SkFILEStream(const char file[]) : fName(file)
 {
 #ifdef SK_BUILD_FOR_BREW
-       if (SkStrEndsWith(fName.c_str(), ".xml"))
-               fName.writable_str()[fName.size()-3] = 'b';
+    if (SkStrEndsWith(fName.c_str(), ".xml"))
+        fName.writable_str()[fName.size()-3] = 'b';
 #endif
 
-       fFILE = file ? sk_fopen(fName.c_str(), kRead_SkFILE_Flag) : NULL;
+    fFILE = file ? sk_fopen(fName.c_str(), kRead_SkFILE_Flag) : NULL;
 }
 
 SkFILEStream::~SkFILEStream()
 {
-       if (fFILE)
-               sk_fclose(fFILE);
+    if (fFILE)
+        sk_fclose(fFILE);
 }
 
 void SkFILEStream::setPath(const char path[])
 {
-       fName.set(path);
+    fName.set(path);
 #ifdef SK_BUILD_FOR_BREW
-       if (SkStrEndsWith(fName.c_str(), ".xml"))
-               fName.writable_str()[fName.size()-3] = 'b';
+    if (SkStrEndsWith(fName.c_str(), ".xml"))
+        fName.writable_str()[fName.size()-3] = 'b';
 #endif
 
-       if (fFILE)
-       {
-               sk_fclose(fFILE);
-               fFILE = NULL;
-       }
-       if (path)
-               fFILE = sk_fopen(fName.c_str(), kRead_SkFILE_Flag);
+    if (fFILE)
+    {
+        sk_fclose(fFILE);
+        fFILE = NULL;
+    }
+    if (path)
+        fFILE = sk_fopen(fName.c_str(), kRead_SkFILE_Flag);
 }
 
 const char* SkFILEStream::getFileName()
 {
-       return fName.c_str();
+    return fName.c_str();
 }
 
 bool SkFILEStream::rewind()
 {
-       if (fFILE)
-       {
-               if (sk_frewind(fFILE))
-                       return true;
-               // we hit an error
-               sk_fclose(fFILE);
-               fFILE = NULL;
-       }
-       return false;
+    if (fFILE)
+    {
+        if (sk_frewind(fFILE))
+            return true;
+        // we hit an error
+        sk_fclose(fFILE);
+        fFILE = NULL;
+    }
+    return false;
 }
 
 size_t SkFILEStream::read(void* buffer, size_t size)
 {
-       if (fFILE)
-       {
+    if (fFILE)
+    {
 #if 1
-               if (buffer == NULL && size == 0)        // funny, they want the size I think
-                       return sk_fgetsize(fFILE);
-               return sk_fread(buffer, size, fFILE);
+        if (buffer == NULL && size == 0)    // funny, they want the size I think
+            return sk_fgetsize(fFILE);
+        return sk_fread(buffer, size, fFILE);
 #else
-               if (buffer)
-               {
-                       size_t bytes = sk_fread(buffer, size, fFILE);
-                       if (ferror(fFILE) == 0)
-                               return bytes;
-               }
-               else
-               {
-                       if (size == 0 && ::fseek(fFILE, 0, SEEK_END) == 0) 
-                       {
-                               size = ::ftell(fFILE);
-                               ::fseek(fFILE, 0, SEEK_SET);
-                               return size;
-                       
-                       else if (::fseek(fFILE, (long)size, SEEK_CUR) == 0)
-                               return size;
-               }
+        if (buffer)
+        {
+            size_t bytes = sk_fread(buffer, size, fFILE);
+            if (ferror(fFILE) == 0)
+                return bytes;
+        }
+        else
+        {
+            if (size == 0 && ::fseek(fFILE, 0, SEEK_END) == 0) 
+            {
+                size = ::ftell(fFILE);
+                ::fseek(fFILE, 0, SEEK_SET);
+                return size;
+            } 
+            else if (::fseek(fFILE, (long)size, SEEK_CUR) == 0)
+                return size;
+        }
 #endif
-       }
-       return 0;
+    }
+    return 0;
 }
 
 ////////////////////////////////////////////////////////////////////////
 
 SkMemoryStream::SkMemoryStream(const void* src, size_t size)
-       : fSrc(src), fSize(size)
+    : fSrc(src), fSize(size)
 {
-       fOffset = 0;
+    fOffset = 0;
 }
 
 bool SkMemoryStream::rewind()
 {
-       fOffset = 0;
-       return true;
+    fOffset = 0;
+    return true;
 }
 
 size_t SkMemoryStream::read(void* buffer, size_t size)
 {
     // if buffer is NULL, seek ahead by size
 
-       if (size == 0)
-               return 0;
-       if (size > fSize - fOffset)
-               size = fSize - fOffset;
-       if (buffer) {
+    if (size == 0)
+        return 0;
+    if (size > fSize - fOffset)
+        size = fSize - fOffset;
+    if (buffer) {
         memcpy(buffer, (const char*)fSrc + fOffset, size);
     }
-       fOffset += size;
-       return size;
+    fOffset += size;
+    return size;
 }
 
 /////////////////////////////////////////////////////////////////////////////////////////////////////////
 
 SkBufferStream::SkBufferStream(SkStream& proxy, size_t bufferSize)
-       : fProxy(proxy)
+    : fProxy(proxy)
 {
-       SkASSERT(&proxy != NULL);
-       this->init(NULL, bufferSize);
+    SkASSERT(&proxy != NULL);
+    this->init(NULL, bufferSize);
 }
 
 SkBufferStream::SkBufferStream(SkStream& proxy, void* buffer, size_t bufferSize)
-       : fProxy(proxy)
+    : fProxy(proxy)
 {
-       SkASSERT(&proxy != NULL);
-       SkASSERT(buffer == NULL || bufferSize != 0);    // init(addr, 0) makes no sense, we must know how big their buffer is
+    SkASSERT(&proxy != NULL);
+    SkASSERT(buffer == NULL || bufferSize != 0);    // init(addr, 0) makes no sense, we must know how big their buffer is
 
-       this->init(buffer, bufferSize);
+    this->init(buffer, bufferSize);
 }
 
 void SkBufferStream::init(void* buffer, size_t bufferSize)
 {
-       if (bufferSize == 0)
-               bufferSize = kDefaultBufferSize;
+    if (bufferSize == 0)
+        bufferSize = kDefaultBufferSize;
 
-       fOrigBufferSize = bufferSize;
-       fBufferSize = bufferSize;
-       fBufferOffset = bufferSize;     // to trigger a reload on the first read()
+    fOrigBufferSize = bufferSize;
+    fBufferSize = bufferSize;
+    fBufferOffset = bufferSize; // to trigger a reload on the first read()
 
-       if (buffer == NULL)
-       {
-               fBuffer = (char*)sk_malloc_throw(fBufferSize);
-               fWeOwnTheBuffer = true;
-       }
-       else
-       {
-               fBuffer = (char*)buffer;
-               fWeOwnTheBuffer = false;
-       }
+    if (buffer == NULL)
+    {
+        fBuffer = (char*)sk_malloc_throw(fBufferSize);
+        fWeOwnTheBuffer = true;
+    }
+    else
+    {
+        fBuffer = (char*)buffer;
+        fWeOwnTheBuffer = false;
+    }
 }
 
 SkBufferStream::~SkBufferStream()
 {
-       if (fWeOwnTheBuffer)
-               sk_free(fBuffer);
+    if (fWeOwnTheBuffer)
+        sk_free(fBuffer);
 }
 
 bool SkBufferStream::rewind()
 {
-       fBufferOffset = fBufferSize = fOrigBufferSize;
-       return fProxy.rewind();
+    fBufferOffset = fBufferSize = fOrigBufferSize;
+    return fProxy.rewind();
 }
 
 const char* SkBufferStream::getFileName()
 {
-       return fProxy.getFileName();
+    return fProxy.getFileName();
 }
 
 #ifdef SK_DEBUG
-//     #define SK_TRACE_BUFFERSTREAM
+//  #define SK_TRACE_BUFFERSTREAM
 #endif
 
 size_t SkBufferStream::read(void* buffer, size_t size)
 {
 #ifdef SK_TRACE_BUFFERSTREAM
-       SkDebugf("Request %d", size);
+    SkDebugf("Request %d", size);
 #endif
-       if (buffer == NULL || size == 0)
-       {
-               fBufferOffset += size;
-               return fProxy.read(buffer, size);
-       }
-
-       size_t s = size;
-       size_t actuallyRead = 0;
-
-       // flush what we can from our fBuffer
-       if (fBufferOffset < fBufferSize)
-       {
-               if (s > fBufferSize - fBufferOffset)
-                       s = fBufferSize - fBufferOffset;
-               memcpy(buffer, fBuffer + fBufferOffset, s);
+    if (buffer == NULL || size == 0)
+    {
+        fBufferOffset += size;
+        return fProxy.read(buffer, size);
+    }
+
+    size_t s = size;
+    size_t actuallyRead = 0;
+
+    // flush what we can from our fBuffer
+    if (fBufferOffset < fBufferSize)
+    {
+        if (s > fBufferSize - fBufferOffset)
+            s = fBufferSize - fBufferOffset;
+        memcpy(buffer, fBuffer + fBufferOffset, s);
 #ifdef SK_TRACE_BUFFERSTREAM
-               SkDebugf(" flush %d", s);
+        SkDebugf(" flush %d", s);
 #endif
-               size -= s;
-               fBufferOffset += s;
-               buffer = (char*)buffer + s;
-               actuallyRead = s;
-       }
-
-       // check if there is more to read
-       if (size)
-       {
-               SkASSERT(fBufferOffset >= fBufferSize); // need to refill our fBuffer
-
-               if (size < fBufferSize) // lets try to read more than the request
-               {
-                       s = fProxy.read(fBuffer, fBufferSize);
+        size -= s;
+        fBufferOffset += s;
+        buffer = (char*)buffer + s;
+        actuallyRead = s;
+    }
+
+    // check if there is more to read
+    if (size)
+    {
+        SkASSERT(fBufferOffset >= fBufferSize); // need to refill our fBuffer
+
+        if (size < fBufferSize) // lets try to read more than the request
+        {
+            s = fProxy.read(fBuffer, fBufferSize);
 #ifdef SK_TRACE_BUFFERSTREAM
-                       SkDebugf(" read %d into fBuffer", s);
+            SkDebugf(" read %d into fBuffer", s);
 #endif
-                       if (size > s)   // they asked for too much
-                               size = s;
-                       if (size)
-                       {
-                               memcpy(buffer, fBuffer, size);
-                               actuallyRead += size;
+            if (size > s)   // they asked for too much
+                size = s;
+            if (size)
+            {
+                memcpy(buffer, fBuffer, size);
+                actuallyRead += size;
 #ifdef SK_TRACE_BUFFERSTREAM
-                               SkDebugf(" memcpy %d into dst", size);
+                SkDebugf(" memcpy %d into dst", size);
 #endif
-                       }
-
-                       fBufferOffset = size;
-                       fBufferSize = s;                // record the (possibly smaller) size for the buffer
-               }
-               else    // just do a direct read
-               {
-                       actuallyRead += fProxy.read(buffer, size);
+            }
+
+            fBufferOffset = size;
+            fBufferSize = s;        // record the (possibly smaller) size for the buffer
+        }
+        else    // just do a direct read
+        {
+            actuallyRead += fProxy.read(buffer, size);
 #ifdef SK_TRACE_BUFFERSTREAM
-                       SkDebugf(" direct read %d", size);
+            SkDebugf(" direct read %d", size);
 #endif
-               }
-       }
+        }
+    }
 #ifdef SK_TRACE_BUFFERSTREAM
-       SkDebugf("\n");
+    SkDebugf("\n");
 #endif
-       return actuallyRead;
+    return actuallyRead;
 }
 
 /////////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -321,34 +338,34 @@ size_t SkBufferStream::read(void* buffer, size_t size)
 
 SkFILEWStream::SkFILEWStream(const char path[])
 {
-       fFILE = sk_fopen(path, kWrite_SkFILE_Flag);
+    fFILE = sk_fopen(path, kWrite_SkFILE_Flag);
 }
 
 SkFILEWStream::~SkFILEWStream()
 {
-       if (fFILE)
-               sk_fclose(fFILE);
+    if (fFILE)
+        sk_fclose(fFILE);
 }
 
 bool SkFILEWStream::write(const void* buffer, size_t size)
 {
-       if (fFILE == NULL)
-               return false;
+    if (fFILE == NULL)
+        return false;
 
-       if (sk_fwrite(buffer, size, fFILE) != size)
-       {
-               SkDEBUGCODE(SkDebugf("SkFILEWStream failed writing %d bytes\n", size);)
-               sk_fclose(fFILE);
-               fFILE = NULL;
-               return false;
-       }
-       return true;
+    if (sk_fwrite(buffer, size, fFILE) != size)
+    {
+        SkDEBUGCODE(SkDebugf("SkFILEWStream failed writing %d bytes\n", size);)
+        sk_fclose(fFILE);
+        fFILE = NULL;
+        return false;
+    }
+    return true;
 }
 
 void SkFILEWStream::flush()
 {
-       if (fFILE)
-               sk_fflush(fFILE);
+    if (fFILE)
+        sk_fflush(fFILE);
 }
 
 ////////////////////////////////////////////////////////////////////////
@@ -449,7 +466,7 @@ bool SkDynamicMemoryWStream::write(const void* buffer, size_t count)
             fHead = fTail = block;
         fTail = block;
     }
-       return true;
+    return true;
 }
 
 bool SkDynamicMemoryWStream::write(const void* buffer, size_t offset, size_t count)
@@ -499,20 +516,20 @@ const char* SkDynamicMemoryWStream::getStream() const
 void SkDebugWStream::newline()
 {
 #ifdef SK_DEBUG
-       SkDebugf("\n");
+    SkDebugf("\n");
 #endif
 }
 
 bool SkDebugWStream::write(const void* buffer, size_t size)
 {
 #ifdef SK_DEBUG
-       char* s = new char[size+1];
-       memcpy(s, buffer, size);
-       s[size] = 0;
-       SkDebugf("%s", s);
-       delete[] s;
+    char* s = new char[size+1];
+    memcpy(s, buffer, size);
+    s[size] = 0;
+    SkDebugf("%s", s);
+    delete[] s;
 #endif
-       return true;
+    return true;
 }
 
 /////////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -525,40 +542,40 @@ bool SkDebugWStream::write(const void* buffer, size_t size)
 void SkWStream::UnitTest()
 {
 #ifdef SK_SUPPORT_UNITTEST
-       {
-               static const char s[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
-               char                    copy[sizeof(s)];
-               SkRandom                rand;
-
-               for (int i = 0; i < 65; i++)
-               {
-                       char*                   copyPtr = copy;
-                       SkMemoryStream  mem(s, sizeof(s));
-                       SkBufferStream  buff(mem, i);
-
-                       do {
-                               copyPtr += buff.read(copyPtr, rand.nextU() & 15);
-                       } while (copyPtr < copy + sizeof(s));
-                       SkASSERT(copyPtr == copy + sizeof(s));
-                       SkASSERT(memcmp(s, copy, sizeof(s)) == 0);
-               }
-       }
-       {
-               SkDebugWStream  s;
-
-               s.writeText("testing wstream helpers\n");
-               s.writeText("compare: 0 ");                     s.writeDecAsText(0);    s.newline();
-               s.writeText("compare: 591 ");           s.writeDecAsText(591);  s.newline();
-               s.writeText("compare: -9125 ");         s.writeDecAsText(-9125);        s.newline();
-               s.writeText("compare: 0 ");                     s.writeHexAsText(0, 0); s.newline();
-               s.writeText("compare: 03FA ");          s.writeHexAsText(0x3FA, 4);     s.newline();
-               s.writeText("compare: DEADBEEF ");      s.writeHexAsText(0xDEADBEEF, 4);        s.newline();
-               s.writeText("compare: 0 ");                     s.writeScalarAsText(SkIntToScalar(0));  s.newline();
-               s.writeText("compare: 27 ");            s.writeScalarAsText(SkIntToScalar(27)); s.newline();
-               s.writeText("compare: -119 ");          s.writeScalarAsText(SkIntToScalar(-119));       s.newline();
-               s.writeText("compare: 851.3333 ");      s.writeScalarAsText(SkIntToScalar(851) + SK_Scalar1/3); s.newline();
-               s.writeText("compare: -0.08 ");         s.writeScalarAsText(-SK_Scalar1*8/100); s.newline();
-       }
+    {
+        static const char s[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
+        char            copy[sizeof(s)];
+        SkRandom        rand;
+
+        for (int i = 0; i < 65; i++)
+        {
+            char*           copyPtr = copy;
+            SkMemoryStream  mem(s, sizeof(s));
+            SkBufferStream  buff(mem, i);
+
+            do {
+                copyPtr += buff.read(copyPtr, rand.nextU() & 15);
+            } while (copyPtr < copy + sizeof(s));
+            SkASSERT(copyPtr == copy + sizeof(s));
+            SkASSERT(memcmp(s, copy, sizeof(s)) == 0);
+        }
+    }
+    {
+        SkDebugWStream  s;
+
+        s.writeText("testing wstream helpers\n");
+        s.writeText("compare: 0 ");         s.writeDecAsText(0);    s.newline();
+        s.writeText("compare: 591 ");       s.writeDecAsText(591);  s.newline();
+        s.writeText("compare: -9125 ");     s.writeDecAsText(-9125);    s.newline();
+        s.writeText("compare: 0 ");         s.writeHexAsText(0, 0); s.newline();
+        s.writeText("compare: 03FA ");      s.writeHexAsText(0x3FA, 4); s.newline();
+        s.writeText("compare: DEADBEEF ");  s.writeHexAsText(0xDEADBEEF, 4);    s.newline();
+        s.writeText("compare: 0 ");         s.writeScalarAsText(SkIntToScalar(0));  s.newline();
+        s.writeText("compare: 27 ");        s.writeScalarAsText(SkIntToScalar(27)); s.newline();
+        s.writeText("compare: -119 ");      s.writeScalarAsText(SkIntToScalar(-119));   s.newline();
+        s.writeText("compare: 851.3333 ");  s.writeScalarAsText(SkIntToScalar(851) + SK_Scalar1/3); s.newline();
+        s.writeText("compare: -0.08 ");     s.writeScalarAsText(-SK_Scalar1*8/100); s.newline();
+    }
 
     {
         SkDynamicMemoryWStream  ds;
index b8a8c5c..c04e1ae 100644 (file)
@@ -1,3 +1,20 @@
+/* libs/graphics/ports/SkFontHost_FONTPATH.cpp
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #include "SkFontHost.h"
 #include "SkString.h"
 #include <stdio.h>
index 418dcd9..7f6aafa 100644 (file)
@@ -1,9 +1,27 @@
+/* libs/graphics/ports/SkFontHost_FreeType.cpp
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #include "SkScalerContext.h"
 #include "SkBitmap.h"
 #include "SkCanvas.h"
 #include "SkDescriptor.h"
 #include "SkFDot6.h"
 #include "SkFontHost.h"
+#include "SkMask.h"
 #include "SkString.h"
 #include "SkThread.h"
 #include "SkTemplates.h"
 
 struct SkFaceRec;
 
-static SkMutex         gFTMutex;
-static int                     gFTCount;
-static FT_Library      gFTLibrary;
-static SkFaceRec*      gFaceRecHead;
+static SkMutex      gFTMutex;
+static int          gFTCount;
+static FT_Library   gFTLibrary;
+static SkFaceRec*   gFaceRecHead;
 
 /////////////////////////////////////////////////////////////////////////
 
 class SkScalerContext_FreeType : public SkScalerContext {
 public:
-       SkScalerContext_FreeType(const SkDescriptor* desc);
-       virtual ~SkScalerContext_FreeType();
+    SkScalerContext_FreeType(const SkDescriptor* desc);
+    virtual ~SkScalerContext_FreeType();
 
 protected:
-       virtual void generateMetrics(SkGlyph* glyph);
-       virtual void generateImage(const SkGlyph& glyph);
-       virtual void generatePath(const SkGlyph& glyph, SkPath* path);
-       virtual void generateLineHeight(SkPoint* ascent, SkPoint* descent);
+    virtual unsigned generateGlyphCount() const;
+    virtual uint16_t generateCharToGlyph(SkUnichar uni);
+    virtual void generateMetrics(SkGlyph* glyph);
+    virtual void generateImage(const SkGlyph& glyph);
+    virtual void generatePath(const SkGlyph& glyph, SkPath* path);
+    virtual void generateLineHeight(SkPoint* ascent, SkPoint* descent);
 
 private:
     SkFaceRec*  fFaceRec;
-       FT_Face     fFace;              // reference to shared face in gFaceRecHead
+    FT_Face     fFace;              // reference to shared face in gFaceRecHead
     FT_Size     fFTSize;            // our own copy
-       SkFixed     fScaleX, fScaleY;
-       SkFixed     fMatrix22[2][2];
+    SkFixed     fScaleX, fScaleY;
+    FT_Matrix   fMatrix22;
     uint32_t    fLoadGlyphFlags;
 
-       FT_Error setupSize();
+    FT_Error setupSize();
 };
 
 ///////////////////////////////////////////////////////////////////////////
@@ -64,14 +84,14 @@ private:
 #include "SkStream.h"
 
 struct SkFaceRec {
-       SkFaceRec*      fNext;
-       FT_Face         fFace;
-       FT_StreamRec    fFTStream;
-       SkFILEStream    fSkStream;
-       uint32_t        fRefCnt;
-       SkString        fFileName;
-
-       SkFaceRec(const char filename[]);    
+    SkFaceRec*      fNext;
+    FT_Face         fFace;
+    FT_StreamRec    fFTStream;
+    SkFILEStream    fSkStream;
+    uint32_t        fRefCnt;
+    SkString        fFileName;
+
+    SkFaceRec(const char filename[]);    
     ~SkFaceRec()
     {
 //        SkDEBUGF(("~SkFaceRec: closing %s\n", fFileName.c_str()));
@@ -92,7 +112,7 @@ extern "C" {
             if (!str->rewind())
             {
                 SkDEBUGF(("sk_stream_read(file:%s offset:%ld count:%ld): rewind failed\n",
-                               rec->fFileName.c_str(), offset, count));
+                rec->fFileName.c_str(), offset, count));
                 return 0;
             }
             else
@@ -133,76 +153,76 @@ SkFaceRec::SkFaceRec(const char filename[]) : fSkStream(filename)
     memset(&fFTStream, 0, sizeof(fFTStream));
     fFTStream.size = fSkStream.read(nil, 0);   // find out how big the file is
     fFTStream.descriptor.pointer = this;
-    fFTStream.read     = sk_stream_read;
+    fFTStream.read  = sk_stream_read;
     fFTStream.close = sk_stream_close;
 }
 
 static SkFaceRec* ref_ft_face(const char filename[], size_t filenameLen)
 {
-       SkFaceRec* rec = gFaceRecHead;
-       while (rec)
-       {
-               if (rec->fFileName.equals(filename, filenameLen))
-               {
-                       SkASSERT(rec->fFace);
-                       rec->fRefCnt += 1;
-                       return rec;
-               }
-               rec = rec->fNext;
-       }
-
-       rec = SkNEW_ARGS(SkFaceRec, (filename));
-
-    FT_Open_Args       args;
+    SkFaceRec* rec = gFaceRecHead;
+    while (rec)
+    {
+        if (rec->fFileName.equals(filename, filenameLen))
+        {
+            SkASSERT(rec->fFace);
+            rec->fRefCnt += 1;
+            return rec;
+        }
+        rec = rec->fNext;
+    }
+
+    rec = SkNEW_ARGS(SkFaceRec, (filename));
+
+    FT_Open_Args    args;
     memset(&args, 0, sizeof(args));
     args.flags = FT_OPEN_STREAM;
     args.stream = &rec->fFTStream;
 
-       FT_Error err = FT_Open_Face(gFTLibrary, &args, 0, &rec->fFace);
-
-       if (err)        // bad filename, try the default font
-       {
-               fprintf(stderr, "ERROR: unable to open font '%s'\n", filename);
-               SkDELETE(rec);
-               sk_throw();
-               return 0;
-       }
-       else
-       {
-               SkASSERT(rec->fFace);
-               //fprintf(stderr, "Opened font '%s'\n", filename.c_str());
-               rec->fNext = gFaceRecHead;
-               gFaceRecHead = rec;
-               rec->fRefCnt = 1;
-               return rec;
-       }
+    FT_Error err = FT_Open_Face(gFTLibrary, &args, 0, &rec->fFace);
+
+    if (err)    // bad filename, try the default font
+    {
+        fprintf(stderr, "ERROR: unable to open font '%s'\n", filename);
+        SkDELETE(rec);
+        sk_throw();
+        return 0;
+    }
+    else
+    {
+        SkASSERT(rec->fFace);
+        //fprintf(stderr, "Opened font '%s'\n", filename.c_str());
+        rec->fNext = gFaceRecHead;
+        gFaceRecHead = rec;
+        rec->fRefCnt = 1;
+        return rec;
+    }
 }
 
 static void unref_ft_face(FT_Face face)
 {
-       SkFaceRec*      rec = gFaceRecHead;
-       SkFaceRec*      prev = nil;
-       while (rec)
-       {
-               SkFaceRec* next = rec->fNext;
-               if (rec->fFace == face)
-               {
-                       if (--rec->fRefCnt == 0)
-                       {
-                               if (prev)
-                                       prev->fNext = next;
-                               else
-                                       gFaceRecHead = next;
-
-                               FT_Done_Face(face);
-                               SkDELETE(rec);
-                       }
-                       return;
-               }
-               prev = rec;
-               rec = next;
-       }
-       SkASSERT("shouldn't get here, face not in list");
+    SkFaceRec*  rec = gFaceRecHead;
+    SkFaceRec*  prev = nil;
+    while (rec)
+    {
+        SkFaceRec* next = rec->fNext;
+        if (rec->fFace == face)
+        {
+            if (--rec->fRefCnt == 0)
+            {
+                if (prev)
+                    prev->fNext = next;
+                else
+                    gFaceRecHead = next;
+
+                FT_Done_Face(face);
+                SkDELETE(rec);
+            }
+            return;
+        }
+        prev = rec;
+        rec = next;
+    }
+    SkASSERT("shouldn't get here, face not in list");
 }
 
 ///////////////////////////////////////////////////////////////////////////
@@ -211,11 +231,11 @@ struct FontFaceRec;
 extern void FontFaceRec_getFileName(const FontFaceRec*, SkString*);
 
 SkScalerContext_FreeType::SkScalerContext_FreeType(const SkDescriptor* desc)
-       : SkScalerContext(desc), fFTSize(nil)
+    : SkScalerContext(desc), fFTSize(nil)
 {
-    SkAutoMutexAcquire ac(gFTMutex);
+    SkAutoMutexAcquire  ac(gFTMutex);
 
-       FT_Error        err;
+    FT_Error    err;
 
     if (gFTCount == 0)
     {
@@ -234,56 +254,60 @@ SkScalerContext_FreeType::SkScalerContext_FreeType(const SkDescriptor* desc)
         fFace = fFaceRec ? fFaceRec->fFace : nil;
     }
 
-       // compute our factors from the record
+    // compute our factors from the record
 
-       SkMatrix        m;
+    SkMatrix    m;
 
-       fRec.getSingleMatrix(&m);
+    fRec.getSingleMatrix(&m);
 
-       //      now compute our scale factors
-       SkScalar        sx = m.getScaleX();
-       SkScalar        sy = m.getScaleY();
+    //  now compute our scale factors
+    SkScalar    sx = m.getScaleX();
+    SkScalar    sy = m.getScaleY();
 
-       if (m.getSkewX() || m.getSkewY() || sx < 0 || sy < 0)   // sort of give up on hinting
-       {
-               sx = SkMaxScalar(SkScalarAbs(sx), SkScalarAbs(m.getSkewX()));
-               sy = SkMaxScalar(SkScalarAbs(m.getSkewY()), SkScalarAbs(sy));
-               sx = sy = SkScalarAve(sx, sy);
+    if (m.getSkewX() || m.getSkewY() || sx < 0 || sy < 0)   // sort of give up on hinting
+    {
+        sx = SkMaxScalar(SkScalarAbs(sx), SkScalarAbs(m.getSkewX()));
+        sy = SkMaxScalar(SkScalarAbs(m.getSkewY()), SkScalarAbs(sy));
+        sx = sy = SkScalarAve(sx, sy);
 
-               SkScalar inv = SkScalarInvert(sx);
+        SkScalar inv = SkScalarInvert(sx);
 
-               // flip the skew elements to go from our Y-down system to FreeType's
-               fMatrix22[0][0] = SkScalarToFixed(SkScalarMul(m.getScaleX(), inv));
-               fMatrix22[0][1] = -SkScalarToFixed(SkScalarMul(m.getSkewX(), inv));
-               fMatrix22[1][0] = -SkScalarToFixed(SkScalarMul(m.getSkewY(), inv));
-               fMatrix22[1][1] = SkScalarToFixed(SkScalarMul(m.getScaleY(), inv));
-       }
-       else
-       {
-               fMatrix22[0][0] = fMatrix22[1][1] = SK_Fixed1;
-               fMatrix22[0][1] = fMatrix22[1][0] = 0;
-       }
+        // flip the skew elements to go from our Y-down system to FreeType's
+        fMatrix22.xx = SkScalarToFixed(SkScalarMul(m.getScaleX(), inv));
+        fMatrix22.xy = -SkScalarToFixed(SkScalarMul(m.getSkewX(), inv));
+        fMatrix22.yx = -SkScalarToFixed(SkScalarMul(m.getSkewY(), inv));
+        fMatrix22.yy = SkScalarToFixed(SkScalarMul(m.getScaleY(), inv));
+    }
+    else
+    {
+        fMatrix22.xx = fMatrix22.yy = SK_Fixed1;
+        fMatrix22.xy = fMatrix22.yx = 0;
+    }
 
-       fScaleX = SkScalarToFixed(sx);
-       fScaleY = SkScalarToFixed(sy);
+    fScaleX = SkScalarToFixed(sx);
+    fScaleY = SkScalarToFixed(sy);
 
     // compute the flags we send to Load_Glyph
     {
-        uint32_t flags = 0;
+        uint32_t flags = FT_LOAD_FORCE_AUTOHINT;
 
-        if (!fRec.fUseHints) {
+        if (kNo_Hints == fRec.fHints)
             flags |= FT_LOAD_NO_HINTING;
-        }
-        if (!fRec.fDoAA) {
+        else if (kNative_Hints == fRec.fHints)
+            flags |= FT_LOAD_NO_AUTOHINT;
+
+        if (SkMask::kBW_Format == fRec.fMaskFormat)
             flags |= FT_LOAD_TARGET_MONO;
-        }
+        else if (SkMask::kLCD_Format == fRec.fMaskFormat)
+            flags |= FT_LOAD_TARGET_LCD;
+
         fLoadGlyphFlags = flags;
     }
-    
+
     // now create the FT_Size
 
     {    
-        FT_Error       err;
+        FT_Error    err;
 
         err = FT_New_Size(fFace, &fFTSize);
         if (err != 0) {
@@ -300,7 +324,7 @@ SkScalerContext_FreeType::SkScalerContext_FreeType(const SkDescriptor* desc)
             fFTSize = nil;
         }
 
-        err = FT_Set_Char_Size(        fFace,
+        err = FT_Set_Char_Size( fFace,
                                 SkFixedToFDot6(fScaleX), SkFixedToFDot6(fScaleY),
                                 72, 72);
         if (err != 0) {
@@ -310,10 +334,7 @@ SkScalerContext_FreeType::SkScalerContext_FreeType(const SkDescriptor* desc)
             return;
         }
 
-//        SkDEBUGF(("FT_Set_Transform %p %p %p [%x %x %x %x]\n", this, fFace, fFTSize,
-//                    fMatrix22[0][0], fMatrix22[0][1], fMatrix22[1][0], fMatrix22[1][1]));
-        // not sure if I need this here, given that I redo it in setup()
-        FT_Set_Transform( fFace, (FT_Matrix*)&fMatrix22, nil);
+        FT_Set_Transform( fFace, &fMatrix22, nil);
     }
 }
 
@@ -322,25 +343,25 @@ SkScalerContext_FreeType::~SkScalerContext_FreeType()
     if (fFTSize != nil)
         FT_Done_Size(fFTSize);
 
-       SkAutoMutexAcquire      ac(gFTMutex);
+    SkAutoMutexAcquire  ac(gFTMutex);
 
     if (fFace != nil)
         unref_ft_face(fFace);
 
-       if (--gFTCount == 0)
-       {
+    if (--gFTCount == 0)
+    {
 //        SkDEBUGF(("FT_Done_FreeType\n"));
-               FT_Done_FreeType(gFTLibrary);
-               SkDEBUGCODE(gFTLibrary = nil;)
-       }
+        FT_Done_FreeType(gFTLibrary);
+        SkDEBUGCODE(gFTLibrary = nil;)
+    }
 }
 
-/*     We call this before each use of the fFace, since we may be sharing
-       this face with other context (at different sizes).
+/*  We call this before each use of the fFace, since we may be sharing
+    this face with other context (at different sizes).
 */
 FT_Error SkScalerContext_FreeType::setupSize()
 {
-       FT_Error        err = FT_Activate_Size(fFTSize);
+    FT_Error    err = FT_Activate_Size(fFTSize);
 
     if (err != 0) {
         SkDEBUGF(("SkScalerContext_FreeType::FT_Activate_Size(%s, 0x%x, 0x%x) returned 0x%x\n",
@@ -351,51 +372,57 @@ FT_Error SkScalerContext_FreeType::setupSize()
     {
         // seems we need to reset this every time (not sure why, but without it
         // I get random italics from some other fFTSize)
-        FT_Set_Transform( fFace, (FT_Matrix*)&fMatrix22, nil);
+        FT_Set_Transform( fFace, &fMatrix22, nil);
     }
     return err;
 }
 
-void SkScalerContext_FreeType::generateMetrics(SkGlyph* glyph)
+unsigned SkScalerContext_FreeType::generateGlyphCount() const
 {
-#if 0
-    {
-        static bool gOnce = true;
-        if (gOnce) {
-            gOnce = false;
-            for (int i = 403; i < fFace->num_glyphs; i++) {
-                FT_Error err = FT_Load_Glyph( fFace, i, fLoadGlyphFlags );
-                if (err != 0) {
-                    printf("FT_Load_Glyph[%d] returned %d\n", i, err);
-                }
-            }
-        }
+    return fFace->num_glyphs;
+}
+
+uint16_t SkScalerContext_FreeType::generateCharToGlyph(SkUnichar uni)
+{
+    return SkToU16(FT_Get_Char_Index( fFace, uni ));
+}
+
+static FT_Pixel_Mode compute_pixel_mode(SkMask::Format format)
+{
+    switch (format) {
+    case SkMask::kBW_Format:
+        return FT_PIXEL_MODE_MONO;
+    case SkMask::kLCD_Format:
+        return FT_PIXEL_MODE_LCD;
+    case SkMask::kA8_Format:
+    default:
+        return FT_PIXEL_MODE_GRAY;
     }
-#endif
+}
 
-    SkAutoMutexAcquire ac(gFTMutex);
+void SkScalerContext_FreeType::generateMetrics(SkGlyph* glyph)
+{
+    SkAutoMutexAcquire  ac(gFTMutex);
 
-       FT_Error        err;
+    FT_Error    err;
 
-       if (this->setupSize())
+    if (this->setupSize())
         goto ERROR;
 
-       glyph->fGlyphID = SkToU16(FT_Get_Char_Index( fFace, glyph->fCharCode ));
-
-       err = FT_Load_Glyph( fFace, glyph->fGlyphID, fLoadGlyphFlags );
-       if (err != 0)
-       {
-        SkDEBUGF(("SkScalerContext_FreeType::generateMetrics(%s): FT_Load_Glyph(char:%d glyph:%d flags:%d) returned 0x%x\n",
-                    fFaceRec->fFileName.c_str(), glyph->fCharCode, glyph->fGlyphID, fLoadGlyphFlags, err));
+    err = FT_Load_Glyph( fFace, glyph->getGlyphID(fBaseGlyphCount), fLoadGlyphFlags );
+    if (err != 0)
+    {
+        SkDEBUGF(("SkScalerContext_FreeType::generateMetrics(%s): FT_Load_Glyph(glyph:%d flags:%d) returned 0x%x\n",
+                    fFaceRec->fFileName.c_str(), glyph->getGlyphID(fBaseGlyphCount), fLoadGlyphFlags, err));
     ERROR:
-               glyph->fWidth   = 0;
-               glyph->fHeight  = 0;
-               glyph->fTop             = 0;
-               glyph->fLeft    = 0;
-               glyph->fAdvanceX = 0;
-               glyph->fAdvanceY = 0;
+        glyph->fWidth   = 0;
+        glyph->fHeight  = 0;
+        glyph->fTop     = 0;
+        glyph->fLeft    = 0;
+        glyph->fAdvanceX = 0;
+        glyph->fAdvanceY = 0;
         return;
-       }
+    }
     
     switch ( fFace->glyph->format )
     {
@@ -408,17 +435,17 @@ void SkScalerContext_FreeType::generateMetrics(SkGlyph* glyph)
         bbox.xMax  = (bbox.xMax + 63) & ~63;
         bbox.yMax  = (bbox.yMax + 63) & ~63;
 
-        glyph->fWidth  = SkToU16((bbox.xMax - bbox.xMin) >> 6);
-        glyph->fHeight = SkToU16((bbox.yMax - bbox.yMin) >> 6);
-        glyph->fTop            = -SkToS16(bbox.yMax >> 6);
-        glyph->fLeft   = SkToS16(bbox.xMin >> 6);
+        glyph->fWidth   = SkToU16((bbox.xMax - bbox.xMin) >> 6);
+        glyph->fHeight  = SkToU16((bbox.yMax - bbox.yMin) >> 6);
+        glyph->fTop     = -SkToS16(bbox.yMax >> 6);
+        glyph->fLeft    = SkToS16(bbox.xMin >> 6);
         break;
         
       case FT_GLYPH_FORMAT_BITMAP:
-        glyph->fWidth  = SkToU16(fFace->glyph->bitmap.width);
-        glyph->fHeight = SkToU16(fFace->glyph->bitmap.rows);
-        glyph->fTop            = -SkToS16(fFace->glyph->bitmap_top);
-        glyph->fLeft   = SkToS16(fFace->glyph->bitmap_left);
+        glyph->fWidth   = SkToU16(fFace->glyph->bitmap.width);
+        glyph->fHeight  = SkToU16(fFace->glyph->bitmap.rows);
+        glyph->fTop     = -SkToS16(fFace->glyph->bitmap_top);
+        glyph->fLeft    = SkToS16(fFace->glyph->bitmap_left);
         break;
 
       default:
@@ -426,36 +453,36 @@ void SkScalerContext_FreeType::generateMetrics(SkGlyph* glyph)
         goto ERROR;      
     }
     
-       if (fRec.fUseHints)
-       {
-               glyph->fAdvanceX = SkFDot6ToFixed(fFace->glyph->advance.x);
-               glyph->fAdvanceY = -SkFDot6ToFixed(fFace->glyph->advance.y);
-       }
-       else
-       {
-               glyph->fAdvanceX = SkFixedMul(fMatrix22[0][0], fFace->glyph->linearHoriAdvance);
-               glyph->fAdvanceY = -SkFixedMul(fMatrix22[1][0], fFace->glyph->linearHoriAdvance);
-       }
+    if (kNo_Hints == fRec.fHints)
+    {
+        glyph->fAdvanceX = SkFixedMul(fMatrix22.xx, fFace->glyph->linearHoriAdvance);
+        glyph->fAdvanceY = -SkFixedMul(fMatrix22.yx, fFace->glyph->linearHoriAdvance);
+    }
+    else
+    {
+        glyph->fAdvanceX = SkFDot6ToFixed(fFace->glyph->advance.x);
+        glyph->fAdvanceY = -SkFDot6ToFixed(fFace->glyph->advance.y);
+    }
 
 #ifdef ENABLE_GLYPH_SPEW
     SkDEBUGF(("FT_Set_Char_Size(this:%p sx:%x sy:%x ", this, fScaleX, fScaleY));
-    SkDEBUGF(("Metrics(glyph:%d flags:0x%x) w:%d\n", glyph->fGlyphID, fLoadGlyphFlags, glyph->fWidth));
+    SkDEBUGF(("Metrics(glyph:%d flags:0x%x) w:%d\n", glyph->getGlyphID(fBaseGlyphCount), fLoadGlyphFlags, glyph->fWidth));
 #endif
 }
 
 void SkScalerContext_FreeType::generateImage(const SkGlyph& glyph)
 {
-    SkAutoMutexAcquire ac(gFTMutex);
+    SkAutoMutexAcquire  ac(gFTMutex);
 
-       FT_Error        err;
+    FT_Error    err;
 
-       if (this->setupSize())
+    if (this->setupSize())
         goto ERROR;
 
-       err = FT_Load_Glyph( fFace, glyph.fGlyphID, fLoadGlyphFlags);
+    err = FT_Load_Glyph( fFace, glyph.getGlyphID(fBaseGlyphCount), fLoadGlyphFlags);
     if (err != 0) {
-        SkDEBUGF(("SkScalerContext_FreeType::generateImage: FT_Load_Glyph(char:%d glyph:%d width:%d height:%d rb:%d flags:%d) returned 0x%x\n",
-                    glyph.fCharCode, glyph.fGlyphID, glyph.fWidth, glyph.fHeight, glyph.fRowBytes, fLoadGlyphFlags, err));
+        SkDEBUGF(("SkScalerContext_FreeType::generateImage: FT_Load_Glyph(glyph:%d width:%d height:%d rb:%d flags:%d) returned 0x%x\n",
+                    glyph.getGlyphID(fBaseGlyphCount), glyph.fWidth, glyph.fHeight, glyph.fRowBytes, fLoadGlyphFlags, err));
     ERROR:
         memset(glyph.fImage, 0, glyph.fRowBytes * glyph.fHeight);
         return;
@@ -475,7 +502,7 @@ void SkScalerContext_FreeType::generateImage(const SkGlyph& glyph)
             target.rows = glyph.fHeight;
             target.pitch = glyph.fRowBytes;
             target.buffer = reinterpret_cast<uint8_t*>(glyph.fImage);
-            target.pixel_mode = fRec.fDoAA ? FT_PIXEL_MODE_GRAY : FT_PIXEL_MODE_MONO;
+            target.pixel_mode = compute_pixel_mode((SkMask::Format)fRec.fMaskFormat);
             target.num_grays = 256;
             
             memset(glyph.fImage, 0, glyph.fRowBytes * glyph.fHeight);
@@ -490,10 +517,10 @@ void SkScalerContext_FreeType::generateImage(const SkGlyph& glyph)
         SkASSERT_CONTINUE(glyph.fLeft == fFace->glyph->bitmap_left);
 
         {
-            const U8*  src = (const U8*)fFace->glyph->bitmap.buffer;
-            U8*                        dst = (U8*)glyph.fImage;
-            unsigned   srcRowBytes = fFace->glyph->bitmap.pitch;
-            unsigned   dstRowBytes = glyph.fRowBytes;
+            const U8*   src = (const U8*)fFace->glyph->bitmap.buffer;
+            U8*         dst = (U8*)glyph.fImage;
+            unsigned    srcRowBytes = fFace->glyph->bitmap.pitch;
+            unsigned    dstRowBytes = glyph.fRowBytes;
             unsigned    minRowBytes = SkMin32(srcRowBytes, dstRowBytes);
             unsigned    extraRowBytes = dstRowBytes - minRowBytes;
 
@@ -515,95 +542,95 @@ void SkScalerContext_FreeType::generateImage(const SkGlyph& glyph)
 
 ///////////////////////////////////////////////////////////////////////////////////////////
 
-#define ft2sk(x)       SkFixedToScalar((x) << 10)
+#define ft2sk(x)    SkFixedToScalar((x) << 10)
 
 static int move_proc(FT_Vector* pt, void* ctx)
 {
-       SkPath* path = (SkPath*)ctx;
-       path->close();  // to close the previous contour (if any)
-       path->moveTo(ft2sk(pt->x), -ft2sk(pt->y));
-       return 0;
+    SkPath* path = (SkPath*)ctx;
+    path->close();  // to close the previous contour (if any)
+    path->moveTo(ft2sk(pt->x), -ft2sk(pt->y));
+    return 0;
 }
 
 static int line_proc(FT_Vector* pt, void* ctx)
 {
-       SkPath* path = (SkPath*)ctx;
-       path->lineTo(ft2sk(pt->x), -ft2sk(pt->y));
-       return 0;
+    SkPath* path = (SkPath*)ctx;
+    path->lineTo(ft2sk(pt->x), -ft2sk(pt->y));
+    return 0;
 }
 
 static int quad_proc(FT_Vector* pt0, FT_Vector* pt1, void* ctx)
 {
-       SkPath* path = (SkPath*)ctx;
-       path->quadTo(ft2sk(pt0->x), -ft2sk(pt0->y), ft2sk(pt1->x), -ft2sk(pt1->y));
-       return 0;
+    SkPath* path = (SkPath*)ctx;
+    path->quadTo(ft2sk(pt0->x), -ft2sk(pt0->y), ft2sk(pt1->x), -ft2sk(pt1->y));
+    return 0;
 }
 
 static int cubic_proc(FT_Vector* pt0, FT_Vector* pt1, FT_Vector* pt2, void* ctx)
 {
-       SkPath* path = (SkPath*)ctx;
-       path->cubicTo(ft2sk(pt0->x), -ft2sk(pt0->y), ft2sk(pt1->x), -ft2sk(pt1->y), ft2sk(pt2->x), -ft2sk(pt2->y));
-       return 0;
+    SkPath* path = (SkPath*)ctx;
+    path->cubicTo(ft2sk(pt0->x), -ft2sk(pt0->y), ft2sk(pt1->x), -ft2sk(pt1->y), ft2sk(pt2->x), -ft2sk(pt2->y));
+    return 0;
 }
 
 void SkScalerContext_FreeType::generatePath(const SkGlyph& glyph, SkPath* path)
 {
-    SkAutoMutexAcquire ac(gFTMutex);
+    SkAutoMutexAcquire  ac(gFTMutex);
 
-       SkASSERT(&glyph && path);
+    SkASSERT(&glyph && path);
 
-       if (this->setupSize()) {
+    if (this->setupSize()) {
         path->reset();
         return;
     }
 
-       U32 flags = fLoadGlyphFlags;
+    U32 flags = fLoadGlyphFlags;
     flags |= FT_LOAD_NO_BITMAP; // ignore embedded bitmaps so we're sure to get the outline
     flags &= ~FT_LOAD_RENDER;   // don't scan convert (we just want the outline)
 
-       FT_Error err = FT_Load_Glyph( fFace, glyph.fGlyphID, flags);
+    FT_Error err = FT_Load_Glyph( fFace, glyph.getGlyphID(fBaseGlyphCount), flags);
 
     if (err != 0) {
-        SkDEBUGF(("SkScalerContext_FreeType::generatePath: FT_Load_Glyph(char:%d glyph:%d flags:%d) returned 0x%x\n",
-                    glyph.fCharCode, glyph.fGlyphID, flags, err));
+        SkDEBUGF(("SkScalerContext_FreeType::generatePath: FT_Load_Glyph(glyph:%d flags:%d) returned 0x%x\n",
+                    glyph.getGlyphID(fBaseGlyphCount), flags, err));
         path->reset();
         return;
     }
 
-       FT_Outline_Funcs        funcs;
+    FT_Outline_Funcs    funcs;
 
-       funcs.move_to   = move_proc;
-       funcs.line_to   = line_proc;
-       funcs.conic_to  = quad_proc;
-       funcs.cubic_to  = cubic_proc;
-       funcs.shift             = 0;
-       funcs.delta             = 0;
+    funcs.move_to   = move_proc;
+    funcs.line_to   = line_proc;
+    funcs.conic_to  = quad_proc;
+    funcs.cubic_to  = cubic_proc;
+    funcs.shift     = 0;
+    funcs.delta     = 0;
 
-       err = FT_Outline_Decompose(&fFace->glyph->outline, &funcs, path);
+    err = FT_Outline_Decompose(&fFace->glyph->outline, &funcs, path);
 
     if (err != 0) {
-        SkDEBUGF(("SkScalerContext_FreeType::generatePath: FT_Load_Glyph(char:%d glyph:%d flags:%d) returned 0x%x\n",
-                    glyph.fCharCode, glyph.fGlyphID, flags, err));
+        SkDEBUGF(("SkScalerContext_FreeType::generatePath: FT_Load_Glyph(glyph:%d flags:%d) returned 0x%x\n",
+                    glyph.getGlyphID(fBaseGlyphCount), flags, err));
         path->reset();
         return;
     }
 
-       path->close();
+    path->close();
 }
 
 static void map_y_to_pt(const FT_Matrix& mat, SkFixed y, SkPoint* pt)
 {
-       SkFixed x = SkFixedMul(mat.xy, y);
-       y = SkFixedMul(mat.yy, y);
+    SkFixed x = SkFixedMul(mat.xy, y);
+    y = SkFixedMul(mat.yy, y);
 
-       pt->set(SkFixedToScalar(x), SkFixedToScalar(y));
+    pt->set(SkFixedToScalar(x), SkFixedToScalar(y));
 }
 
 void SkScalerContext_FreeType::generateLineHeight(SkPoint* ascent, SkPoint* descent)
 {
-    SkAutoMutexAcquire ac(gFTMutex);
+    SkAutoMutexAcquire  ac(gFTMutex);
 
-       if (this->setupSize()) {
+    if (this->setupSize()) {
         if (ascent)
             ascent->set(0, 0);
         if (descent)
@@ -611,16 +638,16 @@ void SkScalerContext_FreeType::generateLineHeight(SkPoint* ascent, SkPoint* desc
         return;
     }
 
-       if (ascent)
-       {
-               SkFixed a = SkMulDiv(fScaleY, -fFace->ascender, fFace->units_per_EM);
-               map_y_to_pt(*(FT_Matrix*)fMatrix22, a, ascent);
-       }
-       if (descent)
-       {
-               SkFixed d = SkMulDiv(fScaleY, -fFace->descender, fFace->units_per_EM);
-               map_y_to_pt(*(FT_Matrix*)fMatrix22, d, descent);
-       }
+    if (ascent)
+    {
+        SkFixed a = SkMulDiv(fScaleY, -fFace->ascender, fFace->units_per_EM);
+        map_y_to_pt(fMatrix22, a, ascent);
+    }
+    if (descent)
+    {
+        SkFixed d = SkMulDiv(fScaleY, -fFace->descender, fFace->units_per_EM);
+        map_y_to_pt(fMatrix22, d, descent);
+    }
 }
 
 ////////////////////////////////////////////////////////////////////////
@@ -628,6 +655,6 @@ void SkScalerContext_FreeType::generateLineHeight(SkPoint* ascent, SkPoint* desc
 
 SkScalerContext* SkFontHost::CreateScalerContext(const SkDescriptor* desc)
 {
-       return SkNEW_ARGS(SkScalerContext_FreeType, (desc));
+    return SkNEW_ARGS(SkScalerContext_FreeType, (desc));
 }
 
similarity index 78%
rename from libs/graphics/ports/SkFontHost.cpp
rename to libs/graphics/ports/SkFontHost_android.cpp
index 3a7998a..0d5d531 100644 (file)
@@ -1,3 +1,20 @@
+/* libs/graphics/ports/SkFontHost_android.cpp
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #include "SkFontHost.h"
 #include "SkDescriptor.h"
 #include "SkString.h"
@@ -63,19 +80,16 @@ enum {
     CJK_FAMILY_INDEX,
     MONO_FAMILY_INDEX,
     SERIF_FAMILY_INDEX,
-    DROID_FAMILY_INDEX,
-       DROID_MORE_FAMILY_INDEX,
-       
+    MORE_FAMILY_INDEX,
+    
     FAMILY_INDEX_COUNT
 };
 
 
 
 static const FontFaceRec gSansFaces[] = {
-//    { "DejaVuSansCondensed.ttf",        SANS_FAMILY_INDEX, 0,  0 },
-//    { "DejaVuSansCondensed-Bold.ttf",   SANS_FAMILY_INDEX, 1,  0 }
-    { "DroidSans_bd100.ttf",        SANS_FAMILY_INDEX, 0,  0 },
-    { "DroidSans-Bold_bd100.ttf",   SANS_FAMILY_INDEX, 1,  0 }
+    { "DroidSans.ttf",        SANS_FAMILY_INDEX, 0,  0 },
+    { "DroidSans-Bold.ttf",   SANS_FAMILY_INDEX, 1,  0 }
 };
 
 static const FontFaceRec gCJKFaces[] = {
@@ -93,27 +107,18 @@ static const FontFaceRec gMonoFaces[] = {
     { "DejaVuSansMono.ttf", MONO_FAMILY_INDEX, 0,  0 }
 };
 
-static const FontFaceRec gDroidFaces[] = {
-       { "DroidSansLight.ttf",  DROID_FAMILY_INDEX, 0,  0 },
-    { "DroidSans.ttf",        DROID_FAMILY_INDEX, 1,  0 },
-    { "DroidSansDemiBold.ttf",  DROID_FAMILY_INDEX, 0,  1 },
-       { "DroidSans-SemiBold.ttf",   DROID_FAMILY_INDEX, 1,  1 }
-};
-
-static const FontFaceRec gDroidMoreFaces[] = {
-    { "DroidSans-Bold.ttf",   DROID_MORE_FAMILY_INDEX, 0,  0 },
-       { "DroidSansBlack.ttf",  DROID_MORE_FAMILY_INDEX, 1,  0 },
-       { "DroidSerifScotch.ttf", DROID_MORE_FAMILY_INDEX, 0,  1 }
+static const FontFaceRec gMoreFaces[] = {
+    { "DroidSansBlack.ttf",  MORE_FAMILY_INDEX, 1,  0 },
+    { "DroidSerifScotch.ttf", MORE_FAMILY_INDEX, 0,  1 }
 };
 
 // This table must be in the same order as the ..._FAMILY_INDEX enum specifies
 static const FontFamilyRec gFamilies[] = {
-    { gSansFaces,     SK_ARRAY_COUNT(gSansFaces)  },
-    { gCJKFaces,      SK_ARRAY_COUNT(gCJKFaces)   },
-    { gMonoFaces,     SK_ARRAY_COUNT(gMonoFaces)  },
-    { gSerifFaces,    SK_ARRAY_COUNT(gSerifFaces) },
-       { gDroidFaces,    SK_ARRAY_COUNT(gDroidFaces) },
-       { gDroidMoreFaces,    SK_ARRAY_COUNT(gDroidMoreFaces) }
+    { gSansFaces,   SK_ARRAY_COUNT(gSansFaces)  },
+    { gCJKFaces,    SK_ARRAY_COUNT(gCJKFaces)   },
+    { gMonoFaces,   SK_ARRAY_COUNT(gMonoFaces)  },
+    { gSerifFaces,  SK_ARRAY_COUNT(gSerifFaces) },
+    { gMoreFaces,   SK_ARRAY_COUNT(gMoreFaces)  }
 };
 
 #define DEFAULT_FAMILY_INDEX            SANS_FAMILY_INDEX
@@ -139,11 +144,7 @@ static const FontFamilyMatchRec gMatches[] = {
     { "courier",            MONO_FAMILY_INDEX },
     { "courier new",        MONO_FAMILY_INDEX },
     { "cursive",            SERIF_FAMILY_INDEX },
-    { "dejavu mono",        MONO_FAMILY_INDEX },
-    { "dejavu sans",        SANS_FAMILY_INDEX },
-    { "dejavu serif",       SANS_FAMILY_INDEX },
-       { "droid more",         DROID_MORE_FAMILY_INDEX },
-       { "droid sans",         SANS_FAMILY_INDEX },
+    { "droid more",         MORE_FAMILY_INDEX },
     { "fantasy",            SERIF_FAMILY_INDEX },
     { "goudy",              SERIF_FAMILY_INDEX },
     { "helvetica",          SANS_FAMILY_INDEX },
@@ -244,6 +245,7 @@ uint32_t SkFontHost::FlattenTypeface(const SkTypeface* tface, void* buffer)
     return size;
 }
 
+#if 0
 SkFontHost::ScalerContextID SkFontHost::FindScalerContextIDForUnichar(int32_t unichar)
 {
     // when we have more than one fall-back font, will have to do a search based on unichar
@@ -259,13 +261,29 @@ SkScalerContext* SkFontHost::CreateScalerContextFromID(ScalerContextID id, const
 
     const FontFaceRec* face = &gFamilies[(int)id - 1].fFaces[0];
 
-       SkAutoDescriptor        ad(sizeof(rec) + sizeof(face) + SkDescriptor::ComputeOverhead(2));
-       SkDescriptor*           desc = ad.getDesc();
+    SkAutoDescriptor    ad(sizeof(rec) + sizeof(face) + SkDescriptor::ComputeOverhead(2));
+    SkDescriptor*       desc = ad.getDesc();
+
+    desc->init();
+    desc->addEntry(kRec_SkDescriptorTag, sizeof(rec), &rec);
+    desc->addEntry(kTypeface_SkDescriptorTag, sizeof(face), &face);
+    desc->computeChecksum();
+
+    return SkFontHost::CreateScalerContext(desc);
+}
+#endif
+
+SkScalerContext* SkFontHost::CreateFallbackScalerContext(const SkScalerContext::Rec& rec)
+{
+    const FontFaceRec* face = &gFamilies[CJK_FAMILY_INDEX].fFaces[0];
+
+    SkAutoDescriptor    ad(sizeof(rec) + sizeof(face) + SkDescriptor::ComputeOverhead(2));
+    SkDescriptor*       desc = ad.getDesc();
 
-       desc->init();
-       desc->addEntry(kRec_SkDescriptorTag, sizeof(rec), &rec);
+    desc->init();
+    desc->addEntry(kRec_SkDescriptorTag, sizeof(rec), &rec);
     desc->addEntry(kTypeface_SkDescriptorTag, sizeof(face), &face);
-       desc->computeChecksum();
+    desc->computeChecksum();
 
     return SkFontHost::CreateScalerContext(desc);
 }
index c9231cf..9682414 100644 (file)
@@ -1,3 +1,20 @@
+/* libs/graphics/ports/SkFontHost_none.cpp
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #include "SkFontHost.h"
 
 SkTypeface* SkFontHost::CreateTypeface( const SkTypeface* familyFace,
index 2143b59..f5f48ef 100644 (file)
@@ -1,11 +1,28 @@
+/* libs/graphics/ports/SkGlobals_global.cpp
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #include "SkGlobals.h"
 #include "SkThread.h"
 
-static SkGlobals::BootStrap    gBootStrap;
+static SkGlobals::BootStrap gBootStrap;
 
 SkGlobals::BootStrap& SkGlobals::GetBootStrap()
 {
-       return gBootStrap;
+    return gBootStrap;
 }
 
 
index 3cec85a..4dca9b9 100644 (file)
@@ -1,17 +1,38 @@
+/* libs/graphics/ports/SkImageDecoder_Factory.cpp
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #include "SkImageDecoder.h"
 #include "SkStream.h"
 
 /*  Each of these is in their respective SkImageDecoder_libXXX.cpp file
 */
 extern SkImageDecoder* SkImageDecoder_GIF_Factory(SkStream*);
+extern SkImageDecoder* SkImageDecoder_ICO_Factory(SkStream*);
 extern SkImageDecoder* SkImageDecoder_JPEG_Factory(SkStream*);
 extern SkImageDecoder* SkImageDecoder_PNG_Factory(SkStream*);
+extern SkImageDecoder* SkImageDecoder_ZBM_Factory(SkStream*);
 
 typedef SkImageDecoder* (*SkImageDecoderFactoryProc)(SkStream*);
 
 static const SkImageDecoderFactoryProc gProc[] = {
+    SkImageDecoder_ZBM_Factory,
     SkImageDecoder_GIF_Factory,
     SkImageDecoder_PNG_Factory,
+    SkImageDecoder_ICO_Factory,
     SkImageDecoder_JPEG_Factory // JPEG must be last, as it doesn't have a sniffer/detector yet
 };
 
@@ -19,10 +40,10 @@ SkImageDecoder* SkImageDecoder::Factory(SkStream* stream)
 {
     for (unsigned i = 0; i < SK_ARRAY_COUNT(gProc); i++) {
         SkImageDecoder* codec = gProc[i](stream);
+        stream->rewind();
         if (codec)
             return codec;
-        stream->rewind();
     }
-       return NULL;
+    return NULL;
 }
 
index 9c7360f..06bff77 100644 (file)
@@ -1,3 +1,20 @@
+/* libs/graphics/ports/SkOSEvent_android.cpp
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #include "SkEvent.h"
 #include "utils/threads.h"
 #include <stdio.h>
@@ -9,7 +26,7 @@ Condition gEventQCondition;
 
 void SkEvent::SignalNonEmptyQueue()
 {
-       gEventQCondition.broadcast();
+    gEventQCondition.broadcast();
 }
 
 ///////////////////////////////////////////////////////////////////
@@ -35,104 +52,104 @@ void SkEvent_stop_timer_thread()
 #include <pthread.h>
 #include <errno.h>
 
-static pthread_t               gTimerThread;
-static pthread_mutex_t gTimerMutex;
-static pthread_cond_t  gTimerCond;
-static timespec                        gTimeSpec;
+static pthread_t        gTimerThread;
+static pthread_mutex_t  gTimerMutex;
+static pthread_cond_t   gTimerCond;
+static timespec         gTimeSpec;
 
 static void* timer_event_thread_proc(void*)
 {
-       for (;;)
-       {
-               int status;
-               
-               pthread_mutex_lock(&gTimerMutex);
-
-               timespec spec = gTimeSpec;
-               // mark our global to be zero
-               // so we don't call timedwait again on a stale value
-               gTimeSpec.tv_sec = 0;
-               gTimeSpec.tv_nsec = 0;
-
-               if (spec.tv_sec == 0 && spec.tv_nsec == 0)
-                       status = pthread_cond_wait(&gTimerCond, &gTimerMutex);
-               else
-                       status = pthread_cond_timedwait(&gTimerCond, &gTimerMutex, &spec);
-               
-               if (status == 0)        // someone signaled us with a new time
-               {
-                       pthread_mutex_unlock(&gTimerMutex);
-               }
-               else
-               {
-                       SkASSERT(status == ETIMEDOUT);  // no need to unlock the mutex (its unlocked)
-                       // this is the payoff. Signal the event queue to wake up
-                       // and also check the delay-queue
-                       gEventQCondition.broadcast();
-               }
-       }
-       return 0;
+    for (;;)
+    {
+        int status;
+        
+        pthread_mutex_lock(&gTimerMutex);
+
+        timespec spec = gTimeSpec;
+        // mark our global to be zero
+        // so we don't call timedwait again on a stale value
+        gTimeSpec.tv_sec = 0;
+        gTimeSpec.tv_nsec = 0;
+
+        if (spec.tv_sec == 0 && spec.tv_nsec == 0)
+            status = pthread_cond_wait(&gTimerCond, &gTimerMutex);
+        else
+            status = pthread_cond_timedwait(&gTimerCond, &gTimerMutex, &spec);
+        
+        if (status == 0)    // someone signaled us with a new time
+        {
+            pthread_mutex_unlock(&gTimerMutex);
+        }
+        else
+        {
+            SkASSERT(status == ETIMEDOUT);  // no need to unlock the mutex (its unlocked)
+            // this is the payoff. Signal the event queue to wake up
+            // and also check the delay-queue
+            gEventQCondition.broadcast();
+        }
+    }
+    return 0;
 }
 
-#define kThousand      (1000)
-#define kMillion       (kThousand * kThousand)
-#define kBillion       (kThousand * kThousand * kThousand)
+#define kThousand   (1000)
+#define kMillion    (kThousand * kThousand)
+#define kBillion    (kThousand * kThousand * kThousand)
 
 void SkEvent::SignalQueueTimer(SkMSec delay)
 {
-       pthread_mutex_lock(&gTimerMutex);
-
-       if (delay)
-       {
-               struct timeval tv;
-               gettimeofday(&tv, nil);
-
-               // normalize tv
-               if (tv.tv_usec >= kMillion)
-               {
-                       tv.tv_sec += tv.tv_usec / kMillion;
-                       tv.tv_usec %= kMillion;
-               }
-
-               // add tv + delay, scale each up to land on nanoseconds
-               gTimeSpec.tv_nsec       = (tv.tv_usec + (delay % kThousand) * kThousand) * kThousand;
-               gTimeSpec.tv_sec        = (tv.tv_sec + (delay / kThousand) * kThousand) * kThousand;
-               
-               // check for overflow in nsec
-               if ((unsigned long)gTimeSpec.tv_nsec >= kBillion)
-               {
-                       gTimeSpec.tv_nsec -= kBillion;
-                       gTimeSpec.tv_sec += 1;
-                       SkASSERT((unsigned long)gTimeSpec.tv_nsec < kBillion);
-               }
-
-       //      printf("SignalQueueTimer(%d) timespec(%d %d)\n", delay, gTimeSpec.tv_sec, gTimeSpec.tv_nsec);
-       }
-       else    // cancel the timer
-       {
-               gTimeSpec.tv_nsec = 0;
-               gTimeSpec.tv_sec = 0;
-       }
-
-       pthread_mutex_unlock(&gTimerMutex);
-       pthread_cond_signal(&gTimerCond);
+    pthread_mutex_lock(&gTimerMutex);
+
+    if (delay)
+    {
+        struct timeval tv;
+        gettimeofday(&tv, nil);
+
+        // normalize tv
+        if (tv.tv_usec >= kMillion)
+        {
+            tv.tv_sec += tv.tv_usec / kMillion;
+            tv.tv_usec %= kMillion;
+        }
+
+        // add tv + delay, scale each up to land on nanoseconds
+        gTimeSpec.tv_nsec   = (tv.tv_usec + (delay % kThousand) * kThousand) * kThousand;
+        gTimeSpec.tv_sec    = (tv.tv_sec + (delay / kThousand) * kThousand) * kThousand;
+        
+        // check for overflow in nsec
+        if ((unsigned long)gTimeSpec.tv_nsec >= kBillion)
+        {
+            gTimeSpec.tv_nsec -= kBillion;
+            gTimeSpec.tv_sec += 1;
+            SkASSERT((unsigned long)gTimeSpec.tv_nsec < kBillion);
+        }
+
+    //  printf("SignalQueueTimer(%d) timespec(%d %d)\n", delay, gTimeSpec.tv_sec, gTimeSpec.tv_nsec);
+    }
+    else    // cancel the timer
+    {
+        gTimeSpec.tv_nsec = 0;
+        gTimeSpec.tv_sec = 0;
+    }
+
+    pthread_mutex_unlock(&gTimerMutex);
+    pthread_cond_signal(&gTimerCond);
 }
 
 void SkEvent_start_timer_thread()
 {
-       int                             status;
-       pthread_attr_t  attr;
-       
-       status = pthread_attr_init(&attr);
-       SkASSERT(status == 0);
-       status = pthread_create(&gTimerThread, &attr, timer_event_thread_proc, 0);
-       SkASSERT(status == 0);
+    int             status;
+    pthread_attr_t  attr;
+    
+    status = pthread_attr_init(&attr);
+    SkASSERT(status == 0);
+    status = pthread_create(&gTimerThread, &attr, timer_event_thread_proc, 0);
+    SkASSERT(status == 0);
 }
 
 void SkEvent_stop_timer_thread()
 {
-       int status = pthread_cancel(gTimerThread);
-       SkASSERT(status == 0);
+    int status = pthread_cancel(gTimerThread);
+    SkASSERT(status == 0);
 }
 
 #endif
index 1c6e188..c83995e 100644 (file)
@@ -1,3 +1,20 @@
+/* libs/graphics/ports/SkOSEvent_dummy.cpp
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #include "SkEvent.h"
 
 void SkEvent::SignalNonEmptyQueue()
index 686ae52..40d1142 100644 (file)
@@ -1,3 +1,20 @@
+/* libs/graphics/ports/SkOSFile_stdio.cpp
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #include "SkOSFile.h"
 
 #ifndef SK_BUILD_FOR_BREW
 
 SkFILE* sk_fopen(const char path[], SkFILE_Flags flags)
 {
-       char    perm[4];
-       char*   p = perm;
+    char    perm[4];
+    char*   p = perm;
 
-       if (flags & kRead_SkFILE_Flag)
-               *p++ = 'r';
-       if (flags & kWrite_SkFILE_Flag)
-               *p++ = 'w';
-       *p++ = 'b';
-       *p = 0;
+    if (flags & kRead_SkFILE_Flag)
+        *p++ = 'r';
+    if (flags & kWrite_SkFILE_Flag)
+        *p++ = 'w';
+    *p++ = 'b';
+    *p = 0;
 
-       return (SkFILE*)::fopen(path, perm);
+    return (SkFILE*)::fopen(path, perm);
 }
 
 size_t sk_fgetsize(SkFILE* f)
 {
-       SkASSERT(f);
+    SkASSERT(f);
 
-       size_t  curr = ::ftell((FILE*)f);               // remember where we are
-       ::fseek((FILE*)f, 0, SEEK_END);                 // go to the end
-       size_t size = ::ftell((FILE*)f);                // record the size
-       ::fseek((FILE*)f, (long)curr, SEEK_SET);                // go back to our prev loc
-       return size;
+    size_t  curr = ::ftell((FILE*)f);       // remember where we are
+    ::fseek((FILE*)f, 0, SEEK_END);         // go to the end
+    size_t size = ::ftell((FILE*)f);        // record the size
+    ::fseek((FILE*)f, (long)curr, SEEK_SET);        // go back to our prev loc
+    return size;
 }
 
 bool sk_frewind(SkFILE* f)
 {
-       SkASSERT(f);
+    SkASSERT(f);
     ::rewind((FILE*)f);
-//     ::fseek((FILE*)f, 0, SEEK_SET);
-       return true;
+//  ::fseek((FILE*)f, 0, SEEK_SET);
+    return true;
 }
 
 size_t sk_fread(void* buffer, size_t byteCount, SkFILE* f)
 {
-       SkASSERT(f);
-       if (buffer == nil)
-       {
-               size_t curr = ::ftell((FILE*)f);
+    SkASSERT(f);
+    if (buffer == nil)
+    {
+        size_t curr = ::ftell((FILE*)f);
         if ((long)curr == -1) {
             SkDEBUGF(("sk_fread: ftell(%p) returned -1 feof:%d ferror:%d\n", f, ::feof((FILE*)f), ::ferror((FILE*)f)));
             return 0;
         }
-       //      ::fseek((FILE*)f, (long)(curr + byteCount), SEEK_SET);
+    //  ::fseek((FILE*)f, (long)(curr + byteCount), SEEK_SET);
         int err = ::fseek((FILE*)f, (long)byteCount, SEEK_CUR);
         if (err != 0) {
             SkDEBUGF(("sk_fread: fseek(%d) tell:%d failed with feof:%d ferror:%d returned:%d\n",
                         byteCount, curr, ::feof((FILE*)f), ::ferror((FILE*)f), err));
             return 0;
         }
-               return byteCount;
-       }
-       else
-               return ::fread(buffer, 1, byteCount, (FILE*)f);
+        return byteCount;
+    }
+    else
+        return ::fread(buffer, 1, byteCount, (FILE*)f);
 }
 
 size_t sk_fwrite(const void* buffer, size_t byteCount, SkFILE* f)
 {
-       SkASSERT(f);
-       return ::fwrite(buffer, 1, byteCount, (FILE*)f);
+    SkASSERT(f);
+    return ::fwrite(buffer, 1, byteCount, (FILE*)f);
 }
 
 void sk_fflush(SkFILE* f)
 {
-       SkASSERT(f);
-       ::fflush((FILE*)f);
+    SkASSERT(f);
+    ::fflush((FILE*)f);
 }
 
 void sk_fclose(SkFILE* f)
 {
-       SkASSERT(f);
-       ::fclose((FILE*)f);
+    SkASSERT(f);
+    ::fclose((FILE*)f);
 }
 
 #endif
index 39ce355..79f72b5 100644 (file)
@@ -1,3 +1,20 @@
+/* libs/graphics/ports/SkThread_none.cpp
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #include "SkThread.h"
 
 int32_t sk_atomic_inc(int32_t* addr)
index 6a0dda1..571866b 100644 (file)
@@ -1,3 +1,20 @@
+/* libs/graphics/ports/SkTime_Unix.cpp
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #include "SkTime.h"
 
 #if defined(SK_BUILD_FOR_UNIX) || defined(SK_BUILD_FOR_MAC)
 
 void SkTime::GetDateTime(DateTime* dt)
 {
-       if (dt)
-       {
+    if (dt)
+    {
     time_t m_time;
     time(&m_time);
     struct tm* tstruct;
     tstruct = localtime(&m_time);
 
-               dt->fYear               = tstruct->tm_year;
-               dt->fMonth              = SkToU8(tstruct->tm_mon + 1);
-               dt->fDayOfWeek  = SkToU8(tstruct->tm_wday);
-               dt->fDay                = SkToU8(tstruct->tm_mday);
-               dt->fHour               = SkToU8(tstruct->tm_hour);
-               dt->fMinute             = SkToU8(tstruct->tm_min);
-               dt->fSecond             = SkToU8(tstruct->tm_sec);
-       }
+        dt->fYear       = tstruct->tm_year;
+        dt->fMonth      = SkToU8(tstruct->tm_mon + 1);
+        dt->fDayOfWeek  = SkToU8(tstruct->tm_wday);
+        dt->fDay        = SkToU8(tstruct->tm_mday);
+        dt->fHour       = SkToU8(tstruct->tm_hour);
+        dt->fMinute     = SkToU8(tstruct->tm_min);
+        dt->fSecond     = SkToU8(tstruct->tm_sec);
+    }
 }
 
 SkMSec SkTime::GetMSecs()
index b808b49..a316dba 100644 (file)
@@ -1,15 +1,32 @@
+/* libs/graphics/ports/SkXMLParser_empty.cpp
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 // Copyright Skia Inc. 2004 - 2005
 // 
 #include "SkXMLParser.h"
 
 bool SkXMLParser::parse(SkStream& docStream)
 {
-       return false;
+    return false;
 }
 
 bool SkXMLParser::parse(const char doc[], size_t len)
 {
-       return false;
+    return false;
 }
 
 void SkXMLParser::GetNativeErrorString(int error, SkString* str)
index 7e31947..b8e9e75 100644 (file)
@@ -1,3 +1,20 @@
+/* libs/graphics/ports/SkXMLParser_expat.cpp
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #include "SkXMLParser.h"
 #include "SkString.h"
 #include "SkStream.h"
 
 #if defined CHAR_16_TO_9
 inline size_t sk_wcslen(const short* char16) {
-       const short* start = char16;
-       while (*char16)
-               char16++;
-       return char16 - start;
+    const short* start = char16;
+    while (*char16)
+        char16++;
+    return char16 - start;
 }
 
 inline const char* ConvertUnicodeToChar(const short* ch16, size_t len, SkAutoMalloc& ch8Malloc) {
-       char* ch8 = (char*) ch8Malloc.get();
-       int index;
-       for (index = 0; index < len; index++) 
-               ch8[index] = (char) ch16[index];
-       ch8[index] = '\0';
-       return ch8;
+    char* ch8 = (char*) ch8Malloc.get();
+    int index;
+    for (index = 0; index < len; index++) 
+        ch8[index] = (char) ch16[index];
+    ch8[index] = '\0';
+    return ch8;
 }
 #endif
 
 static void XMLCALL start_proc(void *data, const char *el, const char **attr)
 {
 #if defined CHAR_16_TO_9
-       size_t len = sk_wcslen((const short*) el);
-       SkAutoMalloc    el8(len + 1);
-       el = ConvertUnicodeToChar((const short*) el, len, el8);
+    size_t len = sk_wcslen((const short*) el);
+    SkAutoMalloc    el8(len + 1);
+    el = ConvertUnicodeToChar((const short*) el, len, el8);
 #endif
-       if (((SkXMLParser*)data)->startElement(el)) {
-               XML_StopParser((XML_Parser) ((SkXMLParser*)data)->fParser, false);
-               return;
-       }
-       while (*attr)
-       {
-               const char* attr0 = attr[0];
-               const char* attr1 = attr[1];
+    if (((SkXMLParser*)data)->startElement(el)) {
+        XML_StopParser((XML_Parser) ((SkXMLParser*)data)->fParser, false);
+        return;
+    }
+    while (*attr)
+    {
+        const char* attr0 = attr[0];
+        const char* attr1 = attr[1];
 #if defined CHAR_16_TO_9
-               size_t len0 = sk_wcslen((const short*) attr0);
-               SkAutoMalloc    attr0_8(len0 + 1);
-               attr0 = ConvertUnicodeToChar((const short*) attr0, len0, attr0_8);
-               size_t len1 = sk_wcslen((const short*) attr1);
-               SkAutoMalloc    attr1_8(len1 + 1);
-               attr1 = ConvertUnicodeToChar((const short*) attr1, len1, attr1_8);
+        size_t len0 = sk_wcslen((const short*) attr0);
+        SkAutoMalloc    attr0_8(len0 + 1);
+        attr0 = ConvertUnicodeToChar((const short*) attr0, len0, attr0_8);
+        size_t len1 = sk_wcslen((const short*) attr1);
+        SkAutoMalloc    attr1_8(len1 + 1);
+        attr1 = ConvertUnicodeToChar((const short*) attr1, len1, attr1_8);
 #endif
-               if (((SkXMLParser*)data)->addAttribute(attr0, attr1)) {
-                       XML_StopParser((XML_Parser) ((SkXMLParser*)data)->fParser, false);
-                       return;
-               }
-               attr += 2;
-       }
+        if (((SkXMLParser*)data)->addAttribute(attr0, attr1)) {
+            XML_StopParser((XML_Parser) ((SkXMLParser*)data)->fParser, false);
+            return;
+        }
+        attr += 2;
+    }
 }
 
 static void XMLCALL end_proc(void *data, const char *el)
 {
 #if defined CHAR_16_TO_9
-       size_t len = sk_wcslen((const short*) el);
-       SkAutoMalloc    el8(len + 1);
-       el = ConvertUnicodeToChar((const short*) el, len, el8);
+    size_t len = sk_wcslen((const short*) el);
+    SkAutoMalloc    el8(len + 1);
+    el = ConvertUnicodeToChar((const short*) el, len, el8);
 #endif
-       if (((SkXMLParser*)data)->endElement(el))
-               XML_StopParser((XML_Parser) ((SkXMLParser*)data)->fParser, false);
+    if (((SkXMLParser*)data)->endElement(el))
+        XML_StopParser((XML_Parser) ((SkXMLParser*)data)->fParser, false);
 }
 
 static void XMLCALL text_proc(void* data, const char* text, int len)
 {
 #if defined CHAR_16_TO_9
-       SkAutoMalloc    text8(len + 1);
-       text = ConvertUnicodeToChar((const short*) text, len, text8);
+    SkAutoMalloc    text8(len + 1);
+    text = ConvertUnicodeToChar((const short*) text, len, text8);
 #endif
-       if (((SkXMLParser*)data)->text(text, len))
-               XML_StopParser((XML_Parser) ((SkXMLParser*)data)->fParser, false);
+    if (((SkXMLParser*)data)->text(text, len))
+        XML_StopParser((XML_Parser) ((SkXMLParser*)data)->fParser, false);
 }
 
 bool SkXMLParser::parse(const char doc[], size_t len)
 {
-       if (len == 0) {
-               fError->fCode = SkXMLParserError::kEmptyFile;
-               reportError(nil);
-               return false;
-       }
-       XML_Parser p = XML_ParserCreate(NULL);
-       SkASSERT(p);
-       fParser = p;
-       XML_SetElementHandler(p, start_proc, end_proc);
-       XML_SetCharacterDataHandler(p, text_proc);
-       XML_SetUserData(p, this);
-
-       bool success = true;
-       int error = XML_Parse(p, doc, len, true);
-       if (error == XML_STATUS_ERROR) {
-               reportError(p);
-               success = false;
-       }
-       XML_ParserFree(p);
-       return success;
+    if (len == 0) {
+        fError->fCode = SkXMLParserError::kEmptyFile;
+        reportError(nil);
+        return false;
+    }
+    XML_Parser p = XML_ParserCreate(NULL);
+    SkASSERT(p);
+    fParser = p;
+    XML_SetElementHandler(p, start_proc, end_proc);
+    XML_SetCharacterDataHandler(p, text_proc);
+    XML_SetUserData(p, this);
+
+    bool success = true;
+    int error = XML_Parse(p, doc, len, true);
+    if (error == XML_STATUS_ERROR) {
+        reportError(p);
+        success = false;
+    }
+    XML_ParserFree(p);
+    return success;
 }
 
 bool SkXMLParser::parse(SkStream& input)
 {
-       size_t                  len = input.read(nil, 0);
-       SkAutoMalloc    am(len);
-       char*                   doc = (char*)am.get();
+    size_t          len = input.read(nil, 0);
+    SkAutoMalloc    am(len);
+    char*           doc = (char*)am.get();
 
-       input.rewind();
-       size_t  len2 = input.read(doc, len);
-       SkASSERT(len2 == len);
+    input.rewind();
+    size_t  len2 = input.read(doc, len);
+    SkASSERT(len2 == len);
 
-       return this->parse(doc, len2);
+    return this->parse(doc, len2);
 }
 
 void SkXMLParser::reportError(void* p)
 {
-       XML_Parser parser = (XML_Parser) p;
-       if (fError && parser) {
-               fError->fNativeCode = XML_GetErrorCode(parser);
-               fError->fLineNumber = XML_GetCurrentLineNumber(parser);
-       }
+    XML_Parser parser = (XML_Parser) p;
+    if (fError && parser) {
+        fError->fNativeCode = XML_GetErrorCode(parser);
+        fError->fLineNumber = XML_GetCurrentLineNumber(parser);
+    }
 }
 
 void SkXMLParser::GetNativeErrorString(int error, SkString* str)
 {
-       if (str)
-               str->set(XML_ErrorString((XML_Error) error));
+    if (str)
+        str->set(XML_ErrorString((XML_Error) error));
 }
 
index bbea8e2..67fb327 100644 (file)
@@ -1,3 +1,20 @@
+/* libs/graphics/ports/SkXMLParser_tinyxml.cpp
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #include "SkXMLParser.h"
 #include "SkStream.h"
 #include "SkTemplates.h"
 
 static void walk_elem(SkXMLParser* parser, const TiXmlElement* elem)
 {
-       //printf("walk_elem(%s) ", elem->Value());
+    //printf("walk_elem(%s) ", elem->Value());
 
-       parser->startElement(elem->Value());
+    parser->startElement(elem->Value());
 
-       const TiXmlAttribute* attr = elem->FirstAttribute();
-       while (attr)
-       {
-               //printf("walk_elem_attr(%s=\"%s\") ", attr->Name(), attr->Value());
-       
-               parser->addAttribute(attr->Name(), attr->Value());
-               attr = attr->Next();
-       }
-       //printf("\n");
-       
-       const TiXmlNode* node = elem->FirstChild();
-       while (node)
-       {
-               if (node->ToElement())
-                       walk_elem(parser, node->ToElement());
-               else if (node->ToText())
-                       parser->text(node->Value(), strlen(node->Value()));
-               node = node->NextSibling();
-       }
-       
-       parser->endElement(elem->Value());
+    const TiXmlAttribute* attr = elem->FirstAttribute();
+    while (attr)
+    {
+        //printf("walk_elem_attr(%s=\"%s\") ", attr->Name(), attr->Value());
+    
+        parser->addAttribute(attr->Name(), attr->Value());
+        attr = attr->Next();
+    }
+    //printf("\n");
+    
+    const TiXmlNode* node = elem->FirstChild();
+    while (node)
+    {
+        if (node->ToElement())
+            walk_elem(parser, node->ToElement());
+        else if (node->ToText())
+            parser->text(node->Value(), strlen(node->Value()));
+        node = node->NextSibling();
+    }
+    
+    parser->endElement(elem->Value());
 }
 
 static bool load_buf(SkXMLParser* parser, const char buf[])
 {
-       TiXmlDocument                                   doc;
+    TiXmlDocument                   doc;
 
-       (void)doc.Parse(buf);
-       if (doc.Error())
-       {
-               printf("tinyxml error: <%s> row[%d] col[%d]\n", doc.ErrorDesc(), doc.ErrorRow(), doc.ErrorCol());
-               return false;
-       }
-       
-       walk_elem(parser, doc.RootElement());
-       return true;
+    (void)doc.Parse(buf);
+    if (doc.Error())
+    {
+        printf("tinyxml error: <%s> row[%d] col[%d]\n", doc.ErrorDesc(), doc.ErrorRow(), doc.ErrorCol());
+        return false;
+    }
+    
+    walk_elem(parser, doc.RootElement());
+    return true;
 }
 
 bool SkXMLParser::parse(SkStream& stream)
 {
-       size_t size = stream.read(nil, 0);
-       
-       SkAutoMalloc    buffer(size + 1);
-       char*                   buf = (char*)buffer.get();
-       
-       stream.read(buf, size);
-       buf[size] = 0;
-       
-       return load_buf(this, buf);
+    size_t size = stream.read(nil, 0);
+    
+    SkAutoMalloc    buffer(size + 1);
+    char*           buf = (char*)buffer.get();
+    
+    stream.read(buf, size);
+    buf[size] = 0;
+    
+    return load_buf(this, buf);
 }
 
 bool SkXMLParser::parse(const char doc[], size_t len)
 {
-       SkAutoMalloc    buffer(len + 1);
-       char*                   buf = (char*)buffer.get();
-       
-       memcpy(buf, doc, len);
-       buf[len] = 0;
-       
-       return load_buf(this, buf);
+    SkAutoMalloc    buffer(len + 1);
+    char*           buf = (char*)buffer.get();
+    
+    memcpy(buf, doc, len);
+    buf[len] = 0;
+    
+    return load_buf(this, buf);
 }
 
 void SkXMLParser::GetNativeErrorString(int error, SkString* str)
 {
-       if (str)
-               str->set("GetNativeErrorString not implemented for TinyXml");
+    if (str)
+        str->set("GetNativeErrorString not implemented for TinyXml");
 }
 
diff --git a/libs/graphics/sgl/ARGB32_Clamp_Bilinear_BitmapShader.cpp b/libs/graphics/sgl/ARGB32_Clamp_Bilinear_BitmapShader.cpp
new file mode 100644 (file)
index 0000000..8097a33
--- /dev/null
@@ -0,0 +1,182 @@
+
+class ARGB32_Clamp_Bilinear_BitmapShader : public SkBitmapShader {
+public:
+    ARGB32_Clamp_Bilinear_BitmapShader(const SkBitmap& src, bool transferOwnership)
+        : SkBitmapShader(src, transferOwnership, SkPaint::kBilinear_FilterType,
+                         SkShader::kClamp_TileMode, SkShader::kClamp_TileMode)
+    {}
+
+    virtual void shadeSpan(int x, int y, SkPMColor dstC[], int count);
+};
+
+SkPMColor sample_bilerp(SkFixed fx, SkFixed fy, int srcMaxX, int srcMaxY,
+                        const SkPMColor* srcPixels, int srcRB, const SkFilterPtrProc* proc_table);
+SkPMColor sample_bilerp(SkFixed fx, SkFixed fy, int srcMaxX, int srcMaxY,
+                        const SkPMColor* srcPixels, int srcRB, const SkFilterPtrProc* proc_table)
+{
+    int x = fx >> 16;
+    int y = fy >> 16;
+    
+    if (x < 0) x = 0;
+    if (x > srcMaxX) x = srcMaxX;
+    if (y < 0) y = 0;
+    if (y > srcMaxY) y = srcMaxY;
+
+    SkASSERT(x <= srcMaxX);
+    SkASSERT(y <= srcMaxY);
+
+    const SkPMColor *p00, *p01, *p10, *p11;
+
+    p00 = p01 = ((const SkPMColor*)((const char*)srcPixels + y * srcRB)) + x;
+    if (x < srcMaxX)
+        p01 += 1;
+    p10 = p00;
+    p11 = p01;
+    if (y < srcMaxY)
+    {
+        p10 = (const SkPMColor*)((const char*)p10 + srcRB);
+        p11 = (const SkPMColor*)((const char*)p11 + srcRB);
+    }
+
+    SkFilterPtrProc proc = SkGetBilinearFilterPtrProc(proc_table, fx, fy);
+    return proc(p00, p01, p10, p11);
+}
+
+static inline SkPMColor sample_bilerp(int x, int srcMaxX, const SkPMColor* srcPixels, int srcRB, SkFilterPtrProc proc)
+{
+    const SkPMColor *p00, *p01, *p10, *p11;
+    
+    // sure wish I could pull this check out of the loop that calls this function
+    if ((unsigned)x < (unsigned)srcMaxX)
+    {
+        p00 = srcPixels + x;
+        p01 = p00 + 1;
+        p10 = (const SkPMColor*)((const char*)p00 + srcRB);
+        p11 = p10 + 1;
+        return proc(p00, p01, p10, p11);
+    }
+
+    if (x < 0) x = 0;
+    if (x > srcMaxX) x = srcMaxX;
+
+    p00 = p01 = srcPixels + x;
+    p10 = p11 = (const SkPMColor*)((const char*)p00 + srcRB);
+    if (x < srcMaxX)
+    {
+        p01 += 1;
+        p11 += 1;
+    }
+    return proc(p00, p01, p10, p11);
+}
+
+void ARGB32_Clamp_Bilinear_BitmapShader::shadeSpan(int x, int y, SkPMColor dstC[], int count)
+{
+    SkASSERT(count > 0);
+    
+    unsigned srcScale = SkAlpha255To256(this->getPaintAlpha());
+
+    const SkMatrix& inv = this->getTotalInverse();
+    const SkBitmap& srcBitmap = this->getSrcBitmap();
+    unsigned        srcMaxX = srcBitmap.width() - 1;
+    unsigned        srcMaxY = srcBitmap.height() - 1;
+    unsigned        srcRB = srcBitmap.rowBytes();
+
+    const SkFilterPtrProc* proc_table = SkGetBilinearFilterPtrProcTable();
+    const SkPMColor* srcPixels = (const SkPMColor*)srcBitmap.getPixels();
+
+    if (this->getInverseClass() == kPerspective_MatrixClass)
+    {
+        SkPerspIter   iter(inv, SkIntToScalar(x), SkIntToScalar(y), count);
+
+        if (256 == srcScale)
+        {
+            while ((count = iter.next()) != 0)
+            {
+                const SkFixed* srcXY = iter.getXY();
+                while (--count >= 0)
+                {
+                    SkFixed fx = *srcXY++;
+                    SkFixed fy = *srcXY++;
+                    *dstC++ = sample_bilerp(fx, fy, srcMaxX, srcMaxY, srcPixels, srcRB, proc_table);
+                }
+            }
+        }
+        else    // scale by srcScale
+        {
+            while ((count = iter.next()) != 0)
+            {
+                const SkFixed* srcXY = iter.getXY();
+                while (--count >= 0)
+                {
+                    SkFixed fx = *srcXY++;
+                    SkFixed fy = *srcXY++;
+                    SkPMColor c = sample_bilerp(fx, fy, srcMaxX, srcMaxY, srcPixels, srcRB, proc_table);
+                    *dstC++ = SkAlphaMulQ(c, srcScale);
+                }
+            }
+        }
+    }
+    else    // linear case
+    {
+        SkFixed fx, fy, dx, dy;
+
+        // now init fx, fy, dx, dy
+        {
+            SkPoint srcPt;
+            this->getInverseMapPtProc()(inv, SkIntToScalar(x), SkIntToScalar(y), &srcPt);
+
+            fx = SkScalarToFixed(srcPt.fX);
+            fy = SkScalarToFixed(srcPt.fY);
+
+            if (this->getInverseClass() == kFixedStepInX_MatrixClass)
+                (void)inv.fixedStepInX(SkIntToScalar(y), &dx, &dy);
+            else
+            {
+                dx = SkScalarToFixed(inv.getScaleX());
+                dy = SkScalarToFixed(inv.getSkewY());
+            }
+        }
+
+        if (dy == 0 && (unsigned)(fy >> 16) < srcMaxY)
+        {
+            srcPixels = (const SkPMColor*)((const char*)srcPixels + (fy >> 16) * srcRB);
+            proc_table = SkGetBilinearFilterPtrProcYTable(proc_table, fy);
+            if (256 == srcScale)
+            {
+                do {
+                    *dstC++ = sample_bilerp(fx >> 16, srcMaxX, srcPixels, srcRB, SkGetBilinearFilterPtrXProc(proc_table, fx));
+                    fx += dx;
+                } while (--count != 0);
+            }
+            else
+            {
+                do {
+                    SkPMColor c = sample_bilerp(fx >> 16, srcMaxX, srcPixels, srcRB, SkGetBilinearFilterPtrXProc(proc_table, fx));
+                    *dstC++ = SkAlphaMulQ(c, srcScale);
+                    fx += dx;
+                } while (--count != 0);
+            }
+        }
+        else    // dy is != 0
+        {
+            if (256 == srcScale)
+            {
+                do {
+                    *dstC++ = sample_bilerp(fx, fy, srcMaxX, srcMaxY, srcPixels, srcRB, proc_table);
+                    fx += dx;
+                    fy += dy;
+                } while (--count != 0);
+            }
+            else
+            {
+                do {
+                    SkPMColor c = sample_bilerp(fx, fy, srcMaxX, srcMaxY, srcPixels, srcRB, proc_table);
+                    *dstC++ = SkAlphaMulQ(c, srcScale);
+                    fx += dx;
+                    fy += dy;
+                } while (--count != 0);
+            }
+        }
+    }
+}
+
index 891774f..10d2630 100644 (file)
+/* libs/graphics/sgl/SkAlphaRuns.cpp
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #include "SkAntiRun.h"
 
 void SkAlphaRuns::reset(int width)
 {
-       SkASSERT(width > 0);
+    SkASSERT(width > 0);
 
-       fRuns[0] = SkToS16(width);
-       fRuns[width] = 0;
-       fAlpha[0] = 0;
+    fRuns[0] = SkToS16(width);
+    fRuns[width] = 0;
+    fAlpha[0] = 0;
 
-       SkDEBUGCODE(fWidth = width;)
-       SkDEBUGCODE(this->validate();)
+    SkDEBUGCODE(fWidth = width;)
+    SkDEBUGCODE(this->validate();)
 }
 
 void SkAlphaRuns::Break(S16 runs[], U8 alpha[], int x, int count)
 {
-       SkASSERT(count > 0 && x >= 0);
-
-//     SkAlphaRuns::BreakAt(runs, alpha, x);
-//     SkAlphaRuns::BreakAt(&runs[x], &alpha[x], count);
-
-       S16* next_runs = runs + x;
-       U8*      next_alpha = alpha + x;
-
-       while (x > 0)
-       {
-               int     n = runs[0];
-               SkASSERT(n > 0);
-
-               if (x < n)
-               {
-                       alpha[x] = alpha[0];
-                       runs[0] = SkToS16(x);
-                       runs[x] = SkToS16(n - x);
-                       break;
-               }
-               runs += n;
-               alpha += n;
-               x -= n;
-       }
-
-       runs = next_runs;
-       alpha = next_alpha;
-       x = count;
-
-       for (;;)
-       {
-               int     n = runs[0];
-               SkASSERT(n > 0);
-
-               if (x < n)
-               {
-                       alpha[x] = alpha[0];
-                       runs[0] = SkToS16(x);
-                       runs[x] = SkToS16(n - x);
-                       break;
-               }
-               x -= n;
-               if (x <= 0)
-                       break;
-
-               runs += n;
-               alpha += n;
-       }
+    SkASSERT(count > 0 && x >= 0);
+
+//  SkAlphaRuns::BreakAt(runs, alpha, x);
+//  SkAlphaRuns::BreakAt(&runs[x], &alpha[x], count);
+
+    S16* next_runs = runs + x;
+    U8*  next_alpha = alpha + x;
+
+    while (x > 0)
+    {
+        int n = runs[0];
+        SkASSERT(n > 0);
+
+        if (x < n)
+        {
+            alpha[x] = alpha[0];
+            runs[0] = SkToS16(x);
+            runs[x] = SkToS16(n - x);
+            break;
+        }
+        runs += n;
+        alpha += n;
+        x -= n;
+    }
+
+    runs = next_runs;
+    alpha = next_alpha;
+    x = count;
+
+    for (;;)
+    {
+        int n = runs[0];
+        SkASSERT(n > 0);
+
+        if (x < n)
+        {
+            alpha[x] = alpha[0];
+            runs[0] = SkToS16(x);
+            runs[x] = SkToS16(n - x);
+            break;
+        }
+        x -= n;
+        if (x <= 0)
+            break;
+
+        runs += n;
+        alpha += n;
+    }
 }
 
 void SkAlphaRuns::add(int x, U8CPU startAlpha, int middleCount, U8CPU stopAlpha, U8CPU maxValue)
 {
-       SkASSERT(middleCount >= 0);
-       SkASSERT(x >= 0 && x + (startAlpha != 0) + middleCount + (stopAlpha != 0) <= fWidth);
-
-       S16*    runs = fRuns;
-       U8*             alpha = fAlpha;
-
-       if (startAlpha)
-       {
-               SkAlphaRuns::Break(runs, alpha, x, 1);
-               /*      I should be able to just add alpha[x] + startAlpha.
-                       However, if the trailing edge of the previous span and the leading
-                       edge of the current span round to the same super-sampled x value,
-                       I might overflow to 256 with this add, hence the funny subtract (crud).
-               */
-               unsigned tmp = alpha[x] + startAlpha;
-               SkASSERT(tmp <= 256);
-               alpha[x] = SkToU8(tmp - (tmp >> 8));    // was (tmp >> 7), but that seems wrong if we're trying to catch 256
-
-               runs += x + 1;
-               alpha += x + 1;
-               x = 0;
-               SkDEBUGCODE(this->validate();)
-       }
-       if (middleCount)
-       {
-               SkAlphaRuns::Break(runs, alpha, x, middleCount);
-               alpha += x;
-               runs += x;
-               x = 0;
-               do {
-                       alpha[0] = SkToU8(alpha[0] + maxValue);
-                       int n = runs[0];
-                       SkASSERT(n <= middleCount);
-                       alpha += n;
-                       runs += n;
-                       middleCount -= n;
-               } while (middleCount > 0);
-               SkDEBUGCODE(this->validate();)
-       }
-       if (stopAlpha)
-       {
-               SkAlphaRuns::Break(runs, alpha, x, 1);
-               alpha[x] = SkToU8(alpha[x] + stopAlpha);
-               SkDEBUGCODE(this->validate();)
-       }
+    SkASSERT(middleCount >= 0);
+    SkASSERT(x >= 0 && x + (startAlpha != 0) + middleCount + (stopAlpha != 0) <= fWidth);
+
+    S16*    runs = fRuns;
+    U8*     alpha = fAlpha;
+
+    if (startAlpha)
+    {
+        SkAlphaRuns::Break(runs, alpha, x, 1);
+        /*  I should be able to just add alpha[x] + startAlpha.
+            However, if the trailing edge of the previous span and the leading
+            edge of the current span round to the same super-sampled x value,
+            I might overflow to 256 with this add, hence the funny subtract (crud).
+        */
+        unsigned tmp = alpha[x] + startAlpha;
+        SkASSERT(tmp <= 256);
+        alpha[x] = SkToU8(tmp - (tmp >> 8));    // was (tmp >> 7), but that seems wrong if we're trying to catch 256
+
+        runs += x + 1;
+        alpha += x + 1;
+        x = 0;
+        SkDEBUGCODE(this->validate();)
+    }
+    if (middleCount)
+    {
+        SkAlphaRuns::Break(runs, alpha, x, middleCount);
+        alpha += x;
+        runs += x;
+        x = 0;
+        do {
+            alpha[0] = SkToU8(alpha[0] + maxValue);
+            int n = runs[0];
+            SkASSERT(n <= middleCount);
+            alpha += n;
+            runs += n;
+            middleCount -= n;
+        } while (middleCount > 0);
+        SkDEBUGCODE(this->validate();)
+    }
+    if (stopAlpha)
+    {
+        SkAlphaRuns::Break(runs, alpha, x, 1);
+        alpha[x] = SkToU8(alpha[x] + stopAlpha);
+        SkDEBUGCODE(this->validate();)
+    }
 }
 
 #ifdef SK_DEBUG
-       void SkAlphaRuns::assertValid(int y, int maxStep) const
-       {
-               int max = (y + 1) * maxStep - (y == maxStep - 1);
-
-               const S16* runs = fRuns;
-               const U8*       alpha = fAlpha;
-
-               while (*runs)
-               {
-                       SkASSERT(*alpha <= max);
-                       alpha += *runs;
-                       runs += *runs;
-               }
-       }
-
-       void SkAlphaRuns::dump() const
-       {
-               const S16* runs = fRuns;
-               const U8* alpha = fAlpha;
-
-               SkDebugf("Runs");
-               while (*runs)
-               {
-                       int n = *runs;
-
-                       SkDebugf(" %02x", *alpha);
-                       if (n > 1)
-                               SkDebugf(",%d", n);
-                       alpha += n;
-                       runs += n;
-               }
-               SkDebugf("\n");
-       }
-
-       void SkAlphaRuns::validate() const
-       {
-               SkASSERT(fWidth > 0);
-
-               int                     count = 0;
-               const S16*      runs = fRuns;
-
-               while (*runs)
-               {
-                       SkASSERT(*runs > 0);
-                       count += *runs;
-                       SkASSERT(count <= fWidth);
-                       runs += *runs;
-               }
-               SkASSERT(count == fWidth);
-       }
+    void SkAlphaRuns::assertValid(int y, int maxStep) const
+    {
+        int max = (y + 1) * maxStep - (y == maxStep - 1);
+
+        const S16* runs = fRuns;
+        const U8*   alpha = fAlpha;
+
+        while (*runs)
+        {
+            SkASSERT(*alpha <= max);
+            alpha += *runs;
+            runs += *runs;
+        }
+    }
+
+    void SkAlphaRuns::dump() const
+    {
+        const S16* runs = fRuns;
+        const U8* alpha = fAlpha;
+
+        SkDebugf("Runs");
+        while (*runs)
+        {
+            int n = *runs;
+
+            SkDebugf(" %02x", *alpha);
+            if (n > 1)
+                SkDebugf(",%d", n);
+            alpha += n;
+            runs += n;
+        }
+        SkDebugf("\n");
+    }
+
+    void SkAlphaRuns::validate() const
+    {
+        SkASSERT(fWidth > 0);
+
+        int         count = 0;
+        const S16*  runs = fRuns;
+
+        while (*runs)
+        {
+            SkASSERT(*runs > 0);
+            count += *runs;
+            SkASSERT(count <= fWidth);
+            runs += *runs;
+        }
+        SkASSERT(count == fWidth);
+    }
 #endif
 
index 43d502f..54afc20 100644 (file)
@@ -1,3 +1,20 @@
+/* libs/graphics/sgl/SkAntiRun.h
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #ifndef SkAntiRun_DEFINED
 #define SkAntiRun_DEFINED
 
 
 inline int sk_make_nonzero_neg_one(int x)
 {
-       return (x | -x) >> 31;
+    return (x | -x) >> 31;
 }
 
 #if 0
 template <int kShift> class SkAntiRun {
-       static U8 coverage_to_alpha(int aa)
-       {
-               aa <<= 8 - 2*kShift;
-               aa -= aa >> (8 - kShift - 1);
-               return SkToU8(aa);
-       }
+    static U8 coverage_to_alpha(int aa)
+    {
+        aa <<= 8 - 2*kShift;
+        aa -= aa >> (8 - kShift - 1);
+        return SkToU8(aa);
+    }
 public:
-       void set(int start, int stop)
-       {
-               SkASSERT(start >= 0 && stop > start);
+    void set(int start, int stop)
+    {
+        SkASSERT(start >= 0 && stop > start);
 
 #if 1
-               int     fb = start & kMask;
-               int fe = stop & kMask;
-               int     n = (stop >> kShift) - (start >> kShift) - 1;
-
-               if (n < 0)
-               {
-                       fb = fe - fb;
-                       n = 0;
-                       fe = 0;
-               }
-               else
-               {
-                       if (fb == 0)
-                               n += 1;
-                       else
-                               fb = (1 << kShift) - fb;
-               }
-
-               fStartAlpha = coverage_to_alpha(fb);
-               fMiddleCount = n;
-               fStopAlpha = coverage_to_alpha(fe);
+        int fb = start & kMask;
+        int fe = stop & kMask;
+        int n = (stop >> kShift) - (start >> kShift) - 1;
+
+        if (n < 0)
+        {
+            fb = fe - fb;
+            n = 0;
+            fe = 0;
+        }
+        else
+        {
+            if (fb == 0)
+                n += 1;
+            else
+                fb = (1 << kShift) - fb;
+        }
+
+        fStartAlpha = coverage_to_alpha(fb);
+        fMiddleCount = n;
+        fStopAlpha = coverage_to_alpha(fe);
 #else
-               int     x0 = start >> kShift;
-               int x1 = (stop - 1) >> kShift;
-               int middle = x1 - x0;
-               int aa;
-
-               if (middle == 0)
-               {
-                       aa = stop - start;
-                       aa <<= 8 - 2*kShift;
-                       aa -= aa >> (8 - kShift - 1);
-                       SkASSERT(aa > 0 && aa < kMax);
-                       fStartAlpha = SkToU8(aa);
-                       fMiddleCount = 0;
-                       fStopAlpha = 0;
-               }
-               else
-               {
-                       int aa = start & kMask;
-                       aa <<= 8 - 2*kShift;
-                       aa -= aa >> (8 - kShift - 1);
-                       SkASSERT(aa >= 0 && aa < kMax);
-                       if (aa)
-                               fStartAlpha = SkToU8(kMax - aa);
-                       else
-                       {
-                               fStartAlpha = 0;
-                               middle += 1;
-                       }
-                       aa = stop & kMask;
-                       aa <<= 8 - 2*kShift;
-                       aa -= aa >> (8 - kShift - 1);
-                       SkASSERT(aa >= 0 && aa < kMax);
-                       middle += sk_make_nonzero_neg_one(aa);
-
-                       fStopAlpha = SkToU8(aa);
-                       fMiddleCount = middle;
-               }
-               SkASSERT(fStartAlpha < kMax);
-               SkASSERT(fStopAlpha < kMax);
+        int x0 = start >> kShift;
+        int x1 = (stop - 1) >> kShift;
+        int middle = x1 - x0;
+        int aa;
+
+        if (middle == 0)
+        {
+            aa = stop - start;
+            aa <<= 8 - 2*kShift;
+            aa -= aa >> (8 - kShift - 1);
+            SkASSERT(aa > 0 && aa < kMax);
+            fStartAlpha = SkToU8(aa);
+            fMiddleCount = 0;
+            fStopAlpha = 0;
+        }
+        else
+        {
+            int aa = start & kMask;
+            aa <<= 8 - 2*kShift;
+            aa -= aa >> (8 - kShift - 1);
+            SkASSERT(aa >= 0 && aa < kMax);
+            if (aa)
+                fStartAlpha = SkToU8(kMax - aa);
+            else
+            {
+                fStartAlpha = 0;
+                middle += 1;
+            }
+            aa = stop & kMask;
+            aa <<= 8 - 2*kShift;
+            aa -= aa >> (8 - kShift - 1);
+            SkASSERT(aa >= 0 && aa < kMax);
+            middle += sk_make_nonzero_neg_one(aa);
+
+            fStopAlpha = SkToU8(aa);
+            fMiddleCount = middle;
+        }
+        SkASSERT(fStartAlpha < kMax);
+        SkASSERT(fStopAlpha < kMax);
 #endif
-       }
-
-       void blit(int x, int y, SkBlitter* blitter)
-       {
-               S16     runs[2];
-               runs[0] = 1;
-               runs[1] = 0;
-
-               if (fStartAlpha)
-               {
-                       blitter->blitAntiH(x, y, &fStartAlpha, runs);
-                       x += 1;
-               }
-               if (fMiddleCount)
-               {
-                       blitter->blitH(x, y, fMiddleCount);
-                       x += fMiddleCount;
-               }
-               if (fStopAlpha)
-                       blitter->blitAntiH(x, y, &fStopAlpha, runs);
-       }
-
-       U8      getStartAlpha() const { return fStartAlpha; }
-       int     getMiddleCount() const { return fMiddleCount; }
-       U8      getStopAlpha() const { return fStopAlpha; }
+    }
+
+    void blit(int x, int y, SkBlitter* blitter)
+    {
+        S16 runs[2];
+        runs[0] = 1;
+        runs[1] = 0;
+
+        if (fStartAlpha)
+        {
+            blitter->blitAntiH(x, y, &fStartAlpha, runs);
+            x += 1;
+        }
+        if (fMiddleCount)
+        {
+            blitter->blitH(x, y, fMiddleCount);
+            x += fMiddleCount;
+        }
+        if (fStopAlpha)
+            blitter->blitAntiH(x, y, &fStopAlpha, runs);
+    }
+
+    U8  getStartAlpha() const { return fStartAlpha; }
+    int getMiddleCount() const { return fMiddleCount; }
+    U8  getStopAlpha() const { return fStopAlpha; }
 
 private:
-       U8      fStartAlpha, fStopAlpha;
-       int     fMiddleCount;
+    U8  fStartAlpha, fStopAlpha;
+    int fMiddleCount;
 
-       enum {
-               kMask = (1 << kShift) - 1,
-               kMax = (1 << (8 - kShift)) - 1
-       };
+    enum {
+        kMask = (1 << kShift) - 1,
+        kMax = (1 << (8 - kShift)) - 1
+    };
 };
 #endif
 
@@ -125,43 +142,43 @@ private:
 
 class SkAlphaRuns {
 public:
-       S16*    fRuns;
-       U8*             fAlpha;
-
-       bool    empty() const
-       {
-               SkASSERT(fRuns[0] > 0);
-               return fAlpha[0] == 0 && fRuns[fRuns[0]] == 0;
-       }
-       void    reset(int width);
-       void    add(int x, U8CPU startAlpha, int middleCount, U8CPU stopAlpha, U8CPU maxValue);
-       SkDEBUGCODE(void assertValid(int y, int maxStep) const;)
-       SkDEBUGCODE(void dump() const;)
-
-       static void Break(S16 runs[], U8 alpha[], int x, int count);
-       static void BreakAt(S16 runs[], U8 alpha[], int x)
-       {
-               while (x > 0)
-               {
-                       int     n = runs[0];
-                       SkASSERT(n > 0);
-
-                       if (x < n)
-                       {
-                               alpha[x] = alpha[0];
-                               runs[0] = SkToS16(x);
-                               runs[x] = SkToS16(n - x);
-                               break;
-                       }
-                       runs += n;
-                       alpha += n;
-                       x -= n;
-               }
-       }
+    S16*    fRuns;
+    U8*     fAlpha;
+
+    bool    empty() const
+    {
+        SkASSERT(fRuns[0] > 0);
+        return fAlpha[0] == 0 && fRuns[fRuns[0]] == 0;
+    }
+    void    reset(int width);
+    void    add(int x, U8CPU startAlpha, int middleCount, U8CPU stopAlpha, U8CPU maxValue);
+    SkDEBUGCODE(void assertValid(int y, int maxStep) const;)
+    SkDEBUGCODE(void dump() const;)
+
+    static void Break(S16 runs[], U8 alpha[], int x, int count);
+    static void BreakAt(S16 runs[], U8 alpha[], int x)
+    {
+        while (x > 0)
+        {
+            int n = runs[0];
+            SkASSERT(n > 0);
+
+            if (x < n)
+            {
+                alpha[x] = alpha[0];
+                runs[0] = SkToS16(x);
+                runs[x] = SkToS16(n - x);
+                break;
+            }
+            runs += n;
+            alpha += n;
+            x -= n;
+        }
+    }
 
 private:
-       SkDEBUGCODE(int fWidth;)
-       SkDEBUGCODE(void validate() const;)
+    SkDEBUGCODE(int fWidth;)
+    SkDEBUGCODE(void validate() const;)
 };
 
 #endif
index a2ea623..b86d733 100644 (file)
+/* libs/graphics/sgl/SkBitmap.cpp
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #include "SkBitmap.h"
 #include "SkColorPriv.h"
 #include "SkUtils.h"
 
 SkBitmap::SkBitmap()
 {
-       memset(this, 0, sizeof(*this));
+    memset(this, 0, sizeof(*this));
 }
 
 SkBitmap::SkBitmap(const SkBitmap& src)
 {
-       src.fColorTable->safeRef();
+    src.fColorTable->safeRef();
 
-       memcpy(this, &src, sizeof(src));
-       fFlags &= ~(kWeOwnThePixels_Flag | kWeOwnTheMipMap_Flag);
+    memcpy(this, &src, sizeof(src));
+    fFlags &= ~(kWeOwnThePixels_Flag | kWeOwnTheMipMap_Flag);
 }
 
 SkBitmap::~SkBitmap()
 {
-       fColorTable->safeUnref();
-       this->freePixels();
+    fColorTable->safeUnref();
+    this->freePixels();
 }
 
 SkBitmap& SkBitmap::operator=(const SkBitmap& src)
 {
-       src.fColorTable->safeRef();
-       fColorTable->safeUnref();
+    src.fColorTable->safeRef();
+    fColorTable->safeUnref();
 
-       this->freePixels();
-       memcpy(this, &src, sizeof(src));
-       fFlags &= ~(kWeOwnThePixels_Flag | kWeOwnTheMipMap_Flag);
+    this->freePixels();
+    memcpy(this, &src, sizeof(src));
+    fFlags &= ~(kWeOwnThePixels_Flag | kWeOwnTheMipMap_Flag);
 
-       return *this;
+    return *this;
 }
 
 void SkBitmap::swap(SkBitmap& other)
 {
-       SkTSwap<SkColorTable*>(fColorTable, other.fColorTable);
+    SkTSwap<SkColorTable*>(fColorTable, other.fColorTable);
 
 #ifdef SK_SUPPORT_MIPMAP
-       SkTSwap<MipMap*>(fMipMap, other.fMipMap);
+    SkTSwap<MipMap*>(fMipMap, other.fMipMap);
 #endif
 
-       SkTSwap<void*>(fPixels, other.fPixels);
-       SkTSwap<U16>(fWidth, other.fWidth);
-       SkTSwap<U16>(fHeight, other.fHeight);
-       SkTSwap<U16>(fRowBytes, other.fRowBytes);
-       SkTSwap<U8>(fConfig, other.fConfig);
-       SkTSwap<U8>(fFlags, other.fFlags);
+    SkTSwap<void*>(fPixels, other.fPixels);
+    SkTSwap<U16>(fWidth, other.fWidth);
+    SkTSwap<U16>(fHeight, other.fHeight);
+    SkTSwap<U16>(fRowBytes, other.fRowBytes);
+    SkTSwap<U8>(fConfig, other.fConfig);
+    SkTSwap<U8>(fFlags, other.fFlags);
 }
 
 void SkBitmap::reset()
 {
-       fColorTable->safeUnref();
-       this->freePixels();
-       memset(this, 0, sizeof(*this));
+    fColorTable->safeUnref();
+    this->freePixels();
+    memset(this, 0, sizeof(*this));
 }
 
 void SkBitmap::setConfig(Config c, U16CPU width, U16CPU height, U16CPU rowBytes)
 {
-       this->freePixels();
-
-       if (rowBytes == 0)
-       {
-               switch (c) {
-               case kA1_Config:
-                       rowBytes = (width + 7) >> 3;
-                       break;
-               case kA8_Config:
-               case kIndex8_Config:
-                       rowBytes = width;
-                       break;
-               case kRGB_565_Config:
-                       rowBytes = SkAlign4(width << 1);
-                       break;
-               case kARGB_8888_Config:
-                       rowBytes = width << 2;
-                       break;
-               default:
-                       SkASSERT(!"unknown config");
-                       break;
-               }
-       }
-
-       fConfig         = SkToU8(c);
-       fWidth          = SkToU16(width);
-       fHeight         = SkToU16(height);
-       fRowBytes       = SkToU16(rowBytes);
+    this->freePixels();
+
+    if (rowBytes == 0)
+    {
+        switch (c) {
+        case kA1_Config:
+            rowBytes = (width + 7) >> 3;
+            break;
+        case kA8_Config:
+        case kIndex8_Config:
+            rowBytes = width;
+            break;
+        case kRGB_565_Config:
+            rowBytes = SkAlign4(width << 1);
+            break;
+        case kARGB_8888_Config:
+            rowBytes = width << 2;
+            break;
+        default:
+            SkASSERT(!"unknown config");
+            break;
+        }
+    }
+
+    fConfig     = SkToU8(c);
+    fWidth      = SkToU16(width);
+    fHeight     = SkToU16(height);
+    fRowBytes   = SkToU16(rowBytes);
 }
 
 void SkBitmap::setPixels(void* p)
 {
-       this->freePixels();
+    this->freePixels();
 
-       fPixels = p;
-       fFlags &= ~(kWeOwnThePixels_Flag | kWeOwnTheMipMap_Flag);
+    fPixels = p;
+    fFlags &= ~(kWeOwnThePixels_Flag | kWeOwnTheMipMap_Flag);
 }
 
 void SkBitmap::allocPixels()
 {
-       this->freePixels();
+    this->freePixels();
 
-       fPixels = (U32*)sk_malloc_throw(fHeight * fRowBytes);
-       fFlags |= kWeOwnThePixels_Flag;
+    fPixels = (U32*)sk_malloc_throw(fHeight * fRowBytes);
+    fFlags |= kWeOwnThePixels_Flag;
 }
 
 void SkBitmap::freePixels()
 {
-       if (fFlags & kWeOwnThePixels_Flag)
-       {
-               SkASSERT(fPixels);
-               sk_free(fPixels);
-               fPixels = NULL;
-               fFlags &= ~kWeOwnThePixels_Flag;
-       }
+    if (fFlags & kWeOwnThePixels_Flag)
+    {
+        SkASSERT(fPixels);
+        sk_free(fPixels);
+        fPixels = NULL;
+        fFlags &= ~kWeOwnThePixels_Flag;
+    }
 #ifdef SK_SUPPORT_MIPMAP
-       if (fFlags & kWeOwnTheMipMap_Flag)
-       {
-               sk_free(fMipMap);
-               fMipMap = NULL;
-       }
+    if (fFlags & kWeOwnTheMipMap_Flag)
+    {
+        sk_free(fMipMap);
+        fMipMap = NULL;
+    }
 #endif
 }
 
 bool SkBitmap::getOwnsPixels() const
 {
-       return SkToBool(fFlags & kWeOwnThePixels_Flag);
+    return SkToBool(fFlags & kWeOwnThePixels_Flag);
 }
 
 void SkBitmap::setOwnsPixels(bool ownsPixels)
 {
-       if (ownsPixels)
-               fFlags |= kWeOwnThePixels_Flag;
-       else
-               fFlags &= ~kWeOwnThePixels_Flag;
+    if (ownsPixels)
+        fFlags |= kWeOwnThePixels_Flag;
+    else
+        fFlags &= ~kWeOwnThePixels_Flag;
 }
 
 SkColorTable* SkBitmap::setColorTable(SkColorTable* ct)
 {
-       SkRefCnt_SafeAssign(fColorTable, ct);
-       return ct;
+    SkRefCnt_SafeAssign(fColorTable, ct);
+    return ct;
 }
 
 bool SkBitmap::isOpaque() const
 {
     switch (fConfig) {
+    case kNo_Config:
+        return true;
+
     case kA1_Config:
     case kA8_Config:
     case kARGB_8888_Config:
@@ -177,235 +197,269 @@ void SkBitmap::setIsOpaque(bool isOpaque)
 
 void SkBitmap::eraseARGB(U8CPU a, U8CPU r, U8CPU g, U8CPU b)
 {
-       if (fPixels == NULL || fConfig == kNo_Config)
-               return;
+    if (fPixels == NULL || fConfig == kNo_Config)
+        return;
 
-       int height = fHeight;
+    int height = fHeight;
 
     this->setIsOpaque(a == 255);
 
-       // make rgb premultiplied
-       if (a != 255)
-       {
-               r = SkAlphaMul(r, a);
-               g = SkAlphaMul(g, a);
-               b = SkAlphaMul(b, a);
-       }
-
-       switch (fConfig) {
-       case kA1_Config:
-               {
-                       U8* p = (uint8_t*)fPixels;
-                       size_t count = (fWidth + 7) >> 3;
-                       a = (a >> 7) ? 0xFF : 0;
-                       SkASSERT(count <= fRowBytes);
-                       while (--height >= 0)
-                       {
-                               memset(p, a, count);
-                               p += fRowBytes;
-                       }
-               }
-               break;
-       case kA8_Config:
-               memset(fPixels, a, fRowBytes * fWidth);
-               break;
-       case kIndex8_Config:
-               SkASSERT(!"Don't support writing to Index8 bitmaps");
-               break;
-       case kRGB_565_Config:
-               // now erase the color-plane
-               {
-                       U16* p = (uint16_t*)fPixels;
-                       U16      v = SkPackRGB16(r >> (8 - SK_R16_BITS),
-                                                               g >> (8 - SK_G16_BITS),
-                                                               b >> (8 - SK_B16_BITS));
-
-                       while (--height >= 0)
-                       {
-                               sk_memset16(p, v, fWidth);
-                               p = (uint16_t*)((char*)p + fRowBytes);
-                       }
-               }
-               break;
-       case kARGB_8888_Config:
-               {
-                       uint32_t* p = (uint32_t*)fPixels;
-                       uint32_t  v = SkPackARGB32(a, r, g, b);
-
-                       while (--height >= 0)
-                       {
-                               sk_memset32(p, v, fWidth);
-                               p = (uint32_t*)((char*)p + fRowBytes);
-                       }
-               }
-               break;
-       }
+    // make rgb premultiplied
+    if (a != 255)
+    {
+        r = SkAlphaMul(r, a);
+        g = SkAlphaMul(g, a);
+        b = SkAlphaMul(b, a);
+    }
+
+    switch (fConfig) {
+    case kA1_Config:
+        {
+            U8* p = (uint8_t*)fPixels;
+            size_t count = (fWidth + 7) >> 3;
+            a = (a >> 7) ? 0xFF : 0;
+            SkASSERT(count <= fRowBytes);
+            while (--height >= 0)
+            {
+                memset(p, a, count);
+                p += fRowBytes;
+            }
+        }
+        break;
+    case kA8_Config:
+        memset(fPixels, a, fRowBytes * fWidth);
+        break;
+    case kIndex8_Config:
+        SkASSERT(!"Don't support writing to Index8 bitmaps");
+        break;
+    case kRGB_565_Config:
+        // now erase the color-plane
+        {
+            U16* p = (uint16_t*)fPixels;
+            U16  v = SkPackRGB16(r >> (8 - SK_R16_BITS),
+                                g >> (8 - SK_G16_BITS),
+                                b >> (8 - SK_B16_BITS));
+
+            while (--height >= 0)
+            {
+                sk_memset16(p, v, fWidth);
+                p = (uint16_t*)((char*)p + fRowBytes);
+            }
+        }
+        break;
+    case kARGB_8888_Config:
+        {
+            uint32_t* p = (uint32_t*)fPixels;
+            uint32_t  v = SkPackARGB32(a, r, g, b);
+
+            while (--height >= 0)
+            {
+                sk_memset32(p, v, fWidth);
+                p = (uint32_t*)((char*)p + fRowBytes);
+            }
+        }
+        break;
+    }
 }
 
 //////////////////////////////////////////////////////////////////////////////////////
 //////////////////////////////////////////////////////////////////////////////////////
 
-#ifdef SK_SUPPORT_MIPMAP
 static void downsampleby2_proc32(SkBitmap* dst, int x, int y, const SkBitmap& src)
 {
-       x <<= 1;
-       y <<= 1;
-       const U32* p = src.getAddr32(x, y);
-       U32     c, ag, rb;
-
-       c = *p; ag = (c >> 8) & 0xFF00FF; rb = c & 0xFF00FF;
-       if (x < (int)src.width() - 1)
-               p += 1;
-       c = *p; ag += (c >> 8) & 0xFF00FF; rb += c & 0xFF00FF;
-
-       if (y < (int)src.height() - 1)
-               p = src.getAddr32(x, y + 1);
-       c = *p; ag += (c >> 8) & 0xFF00FF; rb += c & 0xFF00FF;
-       if (x < (int)src.width() - 1)
-               p += 1;
-       c = *p; ag += (c >> 8) & 0xFF00FF; rb += c & 0xFF00FF;
-
-       *dst->getAddr32(x >> 1, y >> 1) = ((rb >> 2) & 0xFF00FF) | ((ag << 6) & 0xFF00FF00);
+    x <<= 1;
+    y <<= 1;
+    const U32* p = src.getAddr32(x, y);
+    U32 c, ag, rb;
+
+    c = *p; ag = (c >> 8) & 0xFF00FF; rb = c & 0xFF00FF;
+    if (x < (int)src.width() - 1)
+        p += 1;
+    c = *p; ag += (c >> 8) & 0xFF00FF; rb += c & 0xFF00FF;
+
+    if (y < (int)src.height() - 1)
+        p = src.getAddr32(x, y + 1);
+    c = *p; ag += (c >> 8) & 0xFF00FF; rb += c & 0xFF00FF;
+    if (x < (int)src.width() - 1)
+        p += 1;
+    c = *p; ag += (c >> 8) & 0xFF00FF; rb += c & 0xFF00FF;
+
+    *dst->getAddr32(x >> 1, y >> 1) = ((rb >> 2) & 0xFF00FF) | ((ag << 6) & 0xFF00FF00);
 }
 
 static inline uint32_t expand16(U16CPU c)
 {
-       return (c & SK_R16B16_MASK_IN_PLACE) | ((c & SK_G16_MASK_IN_PLACE) << 16);
+    return (c & SK_R16B16_MASK_IN_PLACE) | ((c & SK_G16_MASK_IN_PLACE) << 16);
 }
 
 static inline U16CPU pack16(uint32_t c)
 {
-       return (c & SK_R16B16_MASK_IN_PLACE) | ((c >> 16) & SK_G16_MASK_IN_PLACE);
+    return (c & SK_R16B16_MASK_IN_PLACE) | ((c >> 16) & SK_G16_MASK_IN_PLACE);
 }
 
 static void downsampleby2_proc16(SkBitmap* dst, int x, int y, const SkBitmap& src)
 {
-       x <<= 1;
-       y <<= 1;
-       const U16*      p = src.getAddr16(x, y);
-       U32                     c;
-
-       c = expand16(*p);
-       if (x < (int)src.width() - 1)
-               p += 1;
-       c += expand16(*p);
-
-       if (y < (int)src.height() - 1)
-               p = src.getAddr16(x, y + 1);
-       c += expand16(*p);
-       if (x < (int)src.width() - 1)
-               p += 1;
-       c += expand16(*p);
-
-       *dst->getAddr16(x >> 1, y >> 1) = SkToU16(pack16(c >> 2));
+    x <<= 1;
+    y <<= 1;
+    const U16*  p = src.getAddr16(x, y);
+    U32         c;
+
+    c = expand16(*p);
+    if (x < (int)src.width() - 1)
+        p += 1;
+    c += expand16(*p);
+
+    if (y < (int)src.height() - 1)
+        p = src.getAddr16(x, y + 1);
+    c += expand16(*p);
+    if (x < (int)src.width() - 1)
+        p += 1;
+    c += expand16(*p);
+
+    *dst->getAddr16(x >> 1, y >> 1) = SkToU16(pack16(c >> 2));
 }
 
+bool SkBitmap::quarterSizeFiltered(SkBitmap* dst) const
+{
+    int shift;
+    void (*proc)(SkBitmap* dst, int x, int y, const SkBitmap& src);
+    
+    switch (getConfig()) {
+        case SkBitmap::kARGB_8888_Config:
+            shift = 2;
+            proc = downsampleby2_proc32;
+            break;
+        case SkBitmap::kRGB_565_Config:
+            shift = 1;
+            proc = downsampleby2_proc16;
+            break;
+        default:
+            //other formats not supported
+            return false;
+    }
+    
+    unsigned width = (this->width() + 1) >> 1;
+    unsigned height = (this->height() + 1) >> 1;
+    unsigned rowBytes = width << shift;
+    
+    dst->setConfig(getConfig(), width, height, rowBytes);
+    dst->allocPixels();
+    
+    for (unsigned j = 0; j < height; j++)
+        for (unsigned i = 0; i < width; i++)
+            proc(dst, i, j, *this);
+
+    return true;
+}
+
+
 void SkBitmap::buildMipMap(bool forceRebuild)
 {
 #ifdef SK_SUPPORT_MIPMAP
     if (!forceRebuild && fMipMap)
         return;
 
-       if (fFlags & kWeOwnTheMipMap_Flag)
-       {
-               SkASSERT(fMipMap);
-               sk_free(fMipMap);
-               fMipMap = NULL;
-               fFlags &= ~kWeOwnTheMipMap_Flag;
-       }
-
-       int     shift;
-       void (*proc)(SkBitmap* dst, int x, int y, const SkBitmap& src);
-
-       switch (this->getConfig()) {
-       case kARGB_8888_Config:
-               shift = 2;
-               proc = downsampleby2_proc32;
-               break;
-       case kRGB_565_Config:
-               shift = 1;
-               proc = downsampleby2_proc16;
-               break;
-       case kIndex8_Config:
-       case kA8_Config:
-//             shift = 0; break;
-       default:
-               return; // don't build mipmaps for these configs
-       }
-
-       // whip through our loop to compute the exact size needed
-       size_t  size;
-       {
-               unsigned        width = this->width();
-               unsigned        height = this->height();
-               size = 0;
-               for (int i = 1; i < kMaxMipLevels; i++)
-               {
-                       width = (width + 1) >> 1;
-                       height = (height + 1) >> 1;
-                       size += width * height << shift;
-               }
-       }
-
-       MipMap* mm = (MipMap*)sk_malloc_throw(sizeof(MipMap) + size);
-       U8*             addr = (U8*)(mm + 1);
-
-       unsigned        width = this->width();
-       unsigned        height = this->height();
-       unsigned        rowBytes = this->rowBytes();
-       SkBitmap        srcBM(*this), dstBM;
-
-       mm->fLevel[0].fPixels   = this->getPixels();
-       mm->fLevel[0].fWidth    = SkToU16(width);
-       mm->fLevel[0].fHeight   = SkToU16(height);
-       mm->fLevel[0].fRowBytes = SkToU16(rowBytes);
-       mm->fLevel[0].fConfig   = SkToU8(this->getConfig());
-       mm->fLevel[0].fShift    = SkToU8(shift);
-
-       for (int i = 1; i < kMaxMipLevels; i++)
-       {
-               width = (width + 1) >> 1;
-               height = (height + 1) >> 1;
-               rowBytes = width << shift;
-
-               mm->fLevel[i].fPixels   = addr;
-               mm->fLevel[i].fWidth    = SkToU16(width);
-               mm->fLevel[i].fHeight   = SkToU16(height);
-               mm->fLevel[i].fRowBytes = SkToU16(rowBytes);
-               mm->fLevel[i].fConfig   = SkToU8(this->getConfig());
-               mm->fLevel[i].fShift    = SkToU8(shift);
-
-               dstBM.setConfig(this->getConfig(), width, height, rowBytes);
-               dstBM.setPixels(addr);
-       
-               for (unsigned y = 0; y < height; y++)
-                       for (unsigned x = 0; x < width; x++)
-                               proc(&dstBM, x, y, srcBM);
-
-               srcBM = dstBM;
-               addr += height * rowBytes;
-       }
-       SkASSERT(addr == (U8*)mm->fLevel[1].fPixels + size);
-
-       fMipMap = mm;
-       fFlags |= kWeOwnTheMipMap_Flag;
+    if (fFlags & kWeOwnTheMipMap_Flag)
+    {
+        SkASSERT(fMipMap);
+        sk_free(fMipMap);
+        fMipMap = NULL;
+        fFlags &= ~kWeOwnTheMipMap_Flag;
+    }
+
+    int shift;
+    void (*proc)(SkBitmap* dst, int x, int y, const SkBitmap& src);
+
+    switch (this->getConfig()) {
+    case kARGB_8888_Config:
+        shift = 2;
+        proc = downsampleby2_proc32;
+        break;
+    case kRGB_565_Config:
+        shift = 1;
+        proc = downsampleby2_proc16;
+        break;
+    case kIndex8_Config:
+    case kA8_Config:
+//      shift = 0; break;
+    default:
+        return; // don't build mipmaps for these configs
+    }
+
+    // whip through our loop to compute the exact size needed
+    size_t  size;
+    {
+        unsigned    width = this->width();
+        unsigned    height = this->height();
+        size = 0;
+        for (int i = 1; i < kMaxMipLevels; i++)
+        {
+            width = (width + 1) >> 1;
+            height = (height + 1) >> 1;
+            size += width * height << shift;
+        }
+    }
+
+    MipMap* mm = (MipMap*)sk_malloc_throw(sizeof(MipMap) + size);
+    U8*     addr = (U8*)(mm + 1);
+
+    unsigned    width = this->width();
+    unsigned    height = this->height();
+    unsigned    rowBytes = this->rowBytes();
+    SkBitmap    srcBM(*this), dstBM;
+
+    mm->fLevel[0].fPixels   = this->getPixels();
+    mm->fLevel[0].fWidth    = SkToU16(width);
+    mm->fLevel[0].fHeight   = SkToU16(height);
+    mm->fLevel[0].fRowBytes = SkToU16(rowBytes);
+    mm->fLevel[0].fConfig   = SkToU8(this->getConfig());
+    mm->fLevel[0].fShift    = SkToU8(shift);
+
+    for (int i = 1; i < kMaxMipLevels; i++)
+    {
+        width = (width + 1) >> 1;
+        height = (height + 1) >> 1;
+        rowBytes = width << shift;
+
+        mm->fLevel[i].fPixels   = addr;
+        mm->fLevel[i].fWidth    = SkToU16(width);
+        mm->fLevel[i].fHeight   = SkToU16(height);
+        mm->fLevel[i].fRowBytes = SkToU16(rowBytes);
+        mm->fLevel[i].fConfig   = SkToU8(this->getConfig());
+        mm->fLevel[i].fShift    = SkToU8(shift);
+
+        dstBM.setConfig(this->getConfig(), width, height, rowBytes);
+        dstBM.setPixels(addr);
+    
+        for (unsigned y = 0; y < height; y++)
+            for (unsigned x = 0; x < width; x++)
+                proc(&dstBM, x, y, srcBM);
+
+        srcBM = dstBM;
+        addr += height * rowBytes;
+    }
+    SkASSERT(addr == (U8*)mm->fLevel[1].fPixels + size);
+
+    fMipMap = mm;
+    fFlags |= kWeOwnTheMipMap_Flag;
 #endif
 }
 
 unsigned SkBitmap::countMipLevels() const
 {
 #ifdef SK_SUPPORT_MIPMAP
-       return fMipMap ? kMaxMipLevels : 0;
+    return fMipMap ? kMaxMipLevels : 0;
 #else
     return 0;
 #endif
 }
 
+#ifdef SK_SUPPORT_MIPMAP
 const SkBitmap::MipLevel* SkBitmap::getMipLevel(unsigned level) const
 {
-       SkASSERT(level < this->countMipLevels());
+    SkASSERT(level < this->countMipLevels());
 
-       return &fMipMap->fLevel[level];
+    return &fMipMap->fLevel[level];
 }
 #endif
 
index 28b83f0..4d40596 100644 (file)
@@ -1,3 +1,20 @@
+/* libs/graphics/sgl/SkBitmapSampler.cpp
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #include "SkBitmapSampler.h"
 
 static SkTileModeProc get_tilemode_proc(SkShader::TileMode mode)
@@ -17,12 +34,12 @@ static SkTileModeProc get_tilemode_proc(SkShader::TileMode mode)
 
 SkBitmapSampler::SkBitmapSampler(const SkBitmap& bm, SkPaint::FilterType ftype,
                                  SkShader::TileMode tmx, SkShader::TileMode tmy)
-       : fBitmap(bm), fFilterType(ftype), fTileModeX(tmx), fTileModeY(tmy)
+    : fBitmap(bm), fFilterType(ftype), fTileModeX(tmx), fTileModeY(tmy)
 {
-       SkASSERT(bm.width() > 0 && bm.height() > 0);
+    SkASSERT(bm.width() > 0 && bm.height() > 0);
 
-       fMaxX = SkToU16(bm.width() - 1);
-       fMaxY = SkToU16(bm.height() - 1);
+    fMaxX = SkToU16(bm.width() - 1);
+    fMaxY = SkToU16(bm.height() - 1);
     
     fTileProcX = get_tilemode_proc(tmx);
     fTileProcY = get_tilemode_proc(tmy);
@@ -30,152 +47,117 @@ SkBitmapSampler::SkBitmapSampler(const SkBitmap& bm, SkPaint::FilterType ftype,
 
 class SkNullBitmapSampler : public SkBitmapSampler {
 public:
-       SkNullBitmapSampler(const SkBitmap& bm, SkPaint::FilterType ft,
+    SkNullBitmapSampler(const SkBitmap& bm, SkPaint::FilterType ft,
                         SkShader::TileMode tmx, SkShader::TileMode tmy)
-               : SkBitmapSampler(bm, ft, tmx, tmy) {}
+        : SkBitmapSampler(bm, ft, tmx, tmy) {}
 
-       virtual SkPMColor sample(SkFixed x, SkFixed y) const { return 0; }
+    virtual SkPMColor sample(SkFixed x, SkFixed y) const { return 0; }
 };
 
 /////////////////////////////////////////////////////////////////////////////////
 /////////////////////////////////////////////////////////////////////////////////
 
-#define BITMAP_CLASSNAME_PREFIX(name)                  ARGB32##name
-#define BITMAP_PIXEL_TO_PMCOLOR(bitmap, x, y)  *bitmap.getAddr32(x, y)
+#define BITMAP_CLASSNAME_PREFIX(name)           ARGB32##name
+#define BITMAP_PIXEL_TO_PMCOLOR(bitmap, x, y)   *bitmap.getAddr32(x, y)
 #include "SkBitmapSamplerTemplate.h"
 
 #include "SkColorPriv.h"
 
-#define BITMAP_CLASSNAME_PREFIX(name)                  RGB16##name
-#define BITMAP_PIXEL_TO_PMCOLOR(bitmap, x, y)  SkPixel16ToPixel32(*bitmap.getAddr16(x, y))
+#define BITMAP_CLASSNAME_PREFIX(name)           RGB16##name
+#define BITMAP_PIXEL_TO_PMCOLOR(bitmap, x, y)   SkPixel16ToPixel32(*bitmap.getAddr16(x, y))
 #include "SkBitmapSamplerTemplate.h"
 
-#define BITMAP_CLASSNAME_PREFIX(name)                  Index8##name
-#define BITMAP_PIXEL_TO_PMCOLOR(bitmap, x, y)  bitmap.getIndex8Color(x, y)
+#define BITMAP_CLASSNAME_PREFIX(name)           Index8##name
+#define BITMAP_PIXEL_TO_PMCOLOR(bitmap, x, y)   bitmap.getIndex8Color(x, y)
 #include "SkBitmapSamplerTemplate.h"
 
 /////////////////////////////////////////////////////////////////////////////////
 /////////////////////////////////////////////////////////////////////////////////
 ///////////////// The Bilinear versions
 
-static void assert_valid_pmcolor(uint32_t c)
-{
-       SkASSERT(SkGetPackedA32(c) >= SkGetPackedR32(c));
-       SkASSERT(SkGetPackedA32(c) >= SkGetPackedG32(c));
-       SkASSERT(SkGetPackedA32(c) >= SkGetPackedB32(c));
-}
-
 #include "SkFilterProc.h"
 
 class ARGB32_Bilinear_Sampler : public SkBitmapSampler {
 public:
-       ARGB32_Bilinear_Sampler(const SkBitmap& bm, SkShader::TileMode tmx, SkShader::TileMode tmy)
-               : SkBitmapSampler(bm, SkPaint::kBilinear_FilterType, tmx, tmy)
-       {
-               fProcTable = SkGetBilinearFilterProcTable();
-       }
+    ARGB32_Bilinear_Sampler(const SkBitmap& bm, SkShader::TileMode tmx, SkShader::TileMode tmy)
+        : SkBitmapSampler(bm, SkPaint::kBilinear_FilterType, tmx, tmy)
+    {
+        fPtrProcTable = SkGetBilinearFilterPtrProcTable();
+    }
 
-       virtual SkPMColor sample(SkFixed x, SkFixed y) const
-       {
-               int     ix = x >> 16;
-               int iy = y >> 16;
+    virtual SkPMColor sample(SkFixed x, SkFixed y) const
+    {
+        int ix = x >> 16;
+        int iy = y >> 16;
 
         ix = fTileProcX(ix, fMaxX);
         iy = fTileProcY(iy, fMaxY);
 
-               const uint32_t *p00, *p01, *p10, *p11;
-
-               p00 = p01 = fBitmap.getAddr32(ix, iy);
-               if (ix < fMaxX)
-                       p01 += 1;
-               p10 = p00;
-               p11 = p01;
-               if (iy < fMaxY)
-               {
-                       p10 = (const uint32_t*)((const char*)p10 + fBitmap.rowBytes());
-                       p11 = (const uint32_t*)((const char*)p11 + fBitmap.rowBytes());
-               }
-
-               uint32_t c00 = *p00;
-               uint32_t c01 = *p01;
-               uint32_t c10 = *p10;
-               uint32_t c11 = *p11;
-
-               assert_valid_pmcolor(c00);
-               assert_valid_pmcolor(c01);
-               assert_valid_pmcolor(c01);
-               assert_valid_pmcolor(c11);
-
-               SkFilterProc proc = SkGetBilinearFilterProc(fProcTable, x, y);
-               uint32_t c = SkPackARGB32(      proc(SkGetPackedA32(c00), SkGetPackedA32(c01), SkGetPackedA32(c10), SkGetPackedA32(c11)),
-                                                               proc(SkGetPackedR32(c00), SkGetPackedR32(c01), SkGetPackedR32(c10), SkGetPackedR32(c11)),
-                                                               proc(SkGetPackedG32(c00), SkGetPackedG32(c01), SkGetPackedG32(c10), SkGetPackedG32(c11)),
-                                                               proc(SkGetPackedB32(c00), SkGetPackedB32(c01), SkGetPackedB32(c10), SkGetPackedB32(c11)));
-
-               assert_valid_pmcolor(c);
-               return c;
-       }
-       
+        const uint32_t *p00, *p01, *p10, *p11;
+
+        p00 = p01 = fBitmap.getAddr32(ix, iy);
+        if (ix < fMaxX)
+            p01 += 1;
+        p10 = p00;
+        p11 = p01;
+        if (iy < fMaxY)
+        {
+            p10 = (const uint32_t*)((const char*)p10 + fBitmap.rowBytes());
+            p11 = (const uint32_t*)((const char*)p11 + fBitmap.rowBytes());
+        }
+
+        SkFilterPtrProc proc = SkGetBilinearFilterPtrProc(fPtrProcTable, x, y);
+        return proc(p00, p01, p10, p11);
+    }
+    
 private:
-       const SkFilterProc*   fProcTable;
+    const SkFilterPtrProc* fPtrProcTable;
 };
 
+// If we had a init/term method on sampler, we could avoid the per-pixel
+// call to lockColors/unlockColors
+
 class Index8_Bilinear_Sampler : public SkBitmapSampler {
 public:
-       Index8_Bilinear_Sampler(const SkBitmap& bm, SkShader::TileMode tmx, SkShader::TileMode tmy)
-               : SkBitmapSampler(bm, SkPaint::kBilinear_FilterType, tmx, tmy)
-       {
-               fProcTable = SkGetBilinearFilterProcTable();
-       }
+    Index8_Bilinear_Sampler(const SkBitmap& bm, SkShader::TileMode tmx, SkShader::TileMode tmy)
+        : SkBitmapSampler(bm, SkPaint::kBilinear_FilterType, tmx, tmy)
+    {
+        fPtrProcTable = SkGetBilinearFilterPtrProcTable();
+    }
 
-       virtual SkPMColor sample(SkFixed x, SkFixed y) const
-       {
-               int     ix = x >> 16;
-               int iy = y >> 16;
+    virtual SkPMColor sample(SkFixed x, SkFixed y) const
+    {
+        int ix = x >> 16;
+        int iy = y >> 16;
 
         ix = fTileProcX(ix, fMaxX);
         iy = fTileProcY(iy, fMaxY);
 
-               const U8 *p00, *p01, *p10, *p11;
-
-               p00 = p01 = fBitmap.getAddr8(ix, iy);
-               if (ix < fMaxX)
-                       p01 += 1;
-               p10 = p00;
-               p11 = p01;
-               if (iy < fMaxY)
-               {
-                       p10 = (const U8*)((const char*)p10 + fBitmap.rowBytes());
-                       p11 = (const U8*)((const char*)p11 + fBitmap.rowBytes());
-               }
-
-               const SkPMColor* colors = fBitmap.getColorTable()->lockColors();
-
-               uint32_t c00 = colors[*p00];
-               uint32_t c01 = colors[*p01];
-               uint32_t c10 = colors[*p10];
-               uint32_t c11 = colors[*p11];
-
-               assert_valid_pmcolor(c00);
-               assert_valid_pmcolor(c01);
-               assert_valid_pmcolor(c01);
-               assert_valid_pmcolor(c11);
+        const U8 *p00, *p01, *p10, *p11;
+
+        p00 = p01 = fBitmap.getAddr8(ix, iy);
+        if (ix < fMaxX)
+            p01 += 1;
+        p10 = p00;
+        p11 = p01;
+        if (iy < fMaxY)
+        {
+            p10 = (const U8*)((const char*)p10 + fBitmap.rowBytes());
+            p11 = (const U8*)((const char*)p11 + fBitmap.rowBytes());
+        }
 
-               SkFilterProc proc = SkGetBilinearFilterProc(fProcTable, x, y);
-               uint32_t c = SkPackARGB32(      proc(SkGetPackedA32(c00), SkGetPackedA32(c01), SkGetPackedA32(c10), SkGetPackedA32(c11)),
-                                                               proc(SkGetPackedR32(c00), SkGetPackedR32(c01), SkGetPackedR32(c10), SkGetPackedR32(c11)),
-                                                               proc(SkGetPackedG32(c00), SkGetPackedG32(c01), SkGetPackedG32(c10), SkGetPackedG32(c11)),
-                                                               proc(SkGetPackedB32(c00), SkGetPackedB32(c01), SkGetPackedB32(c10), SkGetPackedB32(c11)));
+        const SkPMColor* colors = fBitmap.getColorTable()->lockColors();
 
-               assert_valid_pmcolor(c);
+        SkFilterPtrProc proc = SkGetBilinearFilterPtrProc(fPtrProcTable, x, y);
+        uint32_t c = proc(&colors[*p00], &colors[*p01], &colors[*p10], &colors[*p11]);
 
-               fBitmap.getColorTable()->unlockColors(false);
+        fBitmap.getColorTable()->unlockColors(false);
 
-               return c;
-       }
-       
+        return c;
+    }
+    
 private:
-       const SkFilterProc*   fProcTable;
+    const SkFilterPtrProc* fPtrProcTable;
 };
 
 /////////////////////////////////////////////////////////////////////////////////
@@ -184,10 +166,10 @@ private:
 SkBitmapSampler* SkBitmapSampler::Create(const SkBitmap& bm, SkPaint::FilterType ftype,
                                          SkShader::TileMode tmx, SkShader::TileMode tmy)
 {
-       switch (bm.getConfig()) {
-       case SkBitmap::kARGB_8888_Config:
-               switch (ftype) {
-               case SkPaint::kNo_FilterType:
+    switch (bm.getConfig()) {
+    case SkBitmap::kARGB_8888_Config:
+        switch (ftype) {
+        case SkPaint::kNo_FilterType:
             if (tmx == tmy) {
                 switch (tmx) {
                 case SkShader::kClamp_TileMode:
@@ -211,14 +193,14 @@ SkBitmapSampler* SkBitmapSampler::Create(const SkBitmap& bm, SkPaint::FilterType
             }
             break;
 
-               case SkPaint::kBilinear_FilterType:
-                       return SkNEW_ARGS(ARGB32_Bilinear_Sampler, (bm, tmx, tmy));
+        case SkPaint::kBilinear_FilterType:
+            return SkNEW_ARGS(ARGB32_Bilinear_Sampler, (bm, tmx, tmy));
 
-               default:
-                       SkASSERT(!"unknown filter type");
-               }
-               break;
-       case SkBitmap::kRGB_565_Config:
+        default:
+            SkASSERT(!"unknown filter type");
+        }
+        break;
+    case SkBitmap::kRGB_565_Config:
         // we ignore ftype, since we haven't implemented bilinear for 16bit bitmaps yet
         if (tmx == tmy) {
             switch (tmx) {
@@ -241,10 +223,10 @@ SkBitmapSampler* SkBitmapSampler::Create(const SkBitmap& bm, SkPaint::FilterType
         else {  // tmx != tmy
             return SkNEW_ARGS(RGB16_Point_Sampler, (bm, tmx, tmy));
         }
-               break;
-       case SkBitmap::kIndex8_Config:
-               switch (ftype) {
-               case SkPaint::kNo_FilterType:
+        break;
+    case SkBitmap::kIndex8_Config:
+        switch (ftype) {
+        case SkPaint::kNo_FilterType:
             if (tmx == tmy) {
                 switch (tmx) {
                 case SkShader::kClamp_TileMode:
@@ -266,16 +248,16 @@ SkBitmapSampler* SkBitmapSampler::Create(const SkBitmap& bm, SkPaint::FilterType
             else {  // tmx != tmy
                 return SkNEW_ARGS(Index8_Point_Sampler, (bm, tmx, tmy));
             }
-                       break;
-               case SkPaint::kBilinear_FilterType:
-                       return SkNEW_ARGS(Index8_Bilinear_Sampler, (bm, tmx, tmy));
-               default:        // to avoid warnings
-                       break;
-               }
-               break;
-       default:
-               SkASSERT(!"unknown device");
-       }
-       return SkNEW_ARGS(SkNullBitmapSampler, (bm, ftype, tmx, tmy));
+            break;
+        case SkPaint::kBilinear_FilterType:
+            return SkNEW_ARGS(Index8_Bilinear_Sampler, (bm, tmx, tmy));
+        default:    // to avoid warnings
+            break;
+        }
+        break;
+    default:
+        SkASSERT(!"unknown device");
+    }
+    return SkNEW_ARGS(SkNullBitmapSampler, (bm, ftype, tmx, tmy));
 }
 
index 27a1855..31ec5ad 100644 (file)
@@ -1,3 +1,20 @@
+/* libs/graphics/sgl/SkBitmapSampler.h
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #ifndef SkBitmapSampler_DEFINED
 #define SkBitmapSampler_DEFINED
 
@@ -9,49 +26,49 @@ typedef int (*SkTileModeProc)(int value, unsigned max);
 
 class SkBitmapSampler {
 public:
-       SkBitmapSampler(const SkBitmap&, SkPaint::FilterType, SkShader::TileMode tmx, SkShader::TileMode tmy);
-       virtual ~SkBitmapSampler() {}
+    SkBitmapSampler(const SkBitmap&, SkPaint::FilterType, SkShader::TileMode tmx, SkShader::TileMode tmy);
+    virtual ~SkBitmapSampler() {}
 
-       const SkBitmap&         getBitmap() const { return fBitmap; }
-       SkPaint::FilterType     getFilterType() const { return fFilterType; }
-       SkShader::TileMode      getTileModeX() const { return fTileModeX; }
-       SkShader::TileMode      getTileModeY() const { return fTileModeY; }
+    const SkBitmap&     getBitmap() const { return fBitmap; }
+    SkPaint::FilterType getFilterType() const { return fFilterType; }
+    SkShader::TileMode  getTileModeX() const { return fTileModeX; }
+    SkShader::TileMode  getTileModeY() const { return fTileModeY; }
 
-       // override this in your subclass
-       virtual SkPMColor sample(SkFixed x, SkFixed y) const = 0;
+    // override this in your subclass
+    virtual SkPMColor sample(SkFixed x, SkFixed y) const = 0;
 
-       // This is the factory for finding an optimal subclass
-       static SkBitmapSampler* Create(const SkBitmap&, SkPaint::FilterType,
+    // This is the factory for finding an optimal subclass
+    static SkBitmapSampler* Create(const SkBitmap&, SkPaint::FilterType,
                                    SkShader::TileMode tmx, SkShader::TileMode tmy);
 
 protected:
-       const SkBitmap&         fBitmap;
-       uint16_t                        fMaxX, fMaxY;
-       SkPaint::FilterType     fFilterType;
-       SkShader::TileMode      fTileModeX;
-       SkShader::TileMode      fTileModeY;
+    const SkBitmap&     fBitmap;
+    uint16_t            fMaxX, fMaxY;
+    SkPaint::FilterType fFilterType;
+    SkShader::TileMode  fTileModeX;
+    SkShader::TileMode  fTileModeY;
     SkTileModeProc      fTileProcX;
     SkTileModeProc      fTileProcY;
 
-       // illegal
-       SkBitmapSampler& operator=(const SkBitmapSampler&);
+    // illegal
+    SkBitmapSampler& operator=(const SkBitmapSampler&);
 };
 
 static inline int fixed_clamp(SkFixed x)
 {
 #ifdef SK_CPU_HAS_CONDITIONAL_INSTR
-       if (x >> 16)
-               x = 0xFFFF;
-       if (x < 0)
-               x = 0;
+    if (x >> 16)
+        x = 0xFFFF;
+    if (x < 0)
+        x = 0;
 #else
-       if (x >> 16)
-       {
-               if (x < 0)
-                       x = 0;
-               else
-                       x = 0xFFFF;
-       }
+    if (x >> 16)
+    {
+        if (x < 0)
+            x = 0;
+        else
+            x = 0xFFFF;
+    }
 #endif
     return x;
 }
@@ -65,86 +82,86 @@ static inline int fixed_repeat(SkFixed x)
 
 static inline int fixed_mirror(SkFixed x)
 {
-       SkFixed s = x << 15 >> 31;
-       // s is FFFFFFFF if we're on an odd interval, or 0 if an even interval
-       return (x ^ s) & 0xFFFF;
+    SkFixed s = x << 15 >> 31;
+    // s is FFFFFFFF if we're on an odd interval, or 0 if an even interval
+    return (x ^ s) & 0xFFFF;
 }
 
 static inline bool is_pow2(int count)
 {
-       SkASSERT(count > 0);
-       return (count & (count - 1)) == 0;
+    SkASSERT(count > 0);
+    return (count & (count - 1)) == 0;
 }
 
 static inline int do_clamp(int index, unsigned max)
 {
-       SkASSERT((int)max >= 0);
+    SkASSERT((int)max >= 0);
 
 #ifdef SK_CPU_HAS_CONDITIONAL_INSTR
-       if (index > (int)max)
-               index = max;
-       if (index < 0)
-               index = 0;
+    if (index > (int)max)
+        index = max;
+    if (index < 0)
+        index = 0;
 #else
-       if ((unsigned)index > max)
-       {
-               if (index < 0)
-                       index = 0;
-               else
-                       index = max;
-       }
+    if ((unsigned)index > max)
+    {
+        if (index < 0)
+            index = 0;
+        else
+            index = max;
+    }
 #endif
-       return index;
+    return index;
 }
 
 static inline int do_repeat_mod(int index, unsigned max)
 {
-       SkASSERT((int)max >= 0);
-
-       if ((unsigned)index > max)
-       {
-               if (index < 0)
-                       index = max - (~index % (max + 1));
-               else
-                       index = index % (max + 1);
-       }
-       return index;
+    SkASSERT((int)max >= 0);
+
+    if ((unsigned)index > max)
+    {
+        if (index < 0)
+            index = max - (~index % (max + 1));
+        else
+            index = index % (max + 1);
+    }
+    return index;
 }
 
 static inline int do_repeat_pow2(int index, unsigned max)
 {
-       SkASSERT((int)max >= 0 && is_pow2(max + 1));
+    SkASSERT((int)max >= 0 && is_pow2(max + 1));
 
-       return index & max;
+    return index & max;
 }
 
 static inline int do_mirror_mod(int index, unsigned max)
 {
-       SkASSERT((int)max >= 0);
-
-       // have to handle negatives so that
-       // -1 -> 0, -2 -> 1, -3 -> 2, etc.
-       // so we can't just cal abs
-       index ^= index >> 31;
-
-       if ((unsigned)index > max)
-       {
-               int mod = (max + 1) << 1;
-               index = index % mod;
-               if ((unsigned)index > max)
-                       index = mod - index - 1;
-       }
-       return index;
+    SkASSERT((int)max >= 0);
+
+    // have to handle negatives so that
+    // -1 -> 0, -2 -> 1, -3 -> 2, etc.
+    // so we can't just cal abs
+    index ^= index >> 31;
+
+    if ((unsigned)index > max)
+    {
+        int mod = (max + 1) << 1;
+        index = index % mod;
+        if ((unsigned)index > max)
+            index = mod - index - 1;
+    }
+    return index;
 }
 
 static inline int do_mirror_pow2(int index, unsigned max)
 {
-       SkASSERT((int)max >= 0 && is_pow2(max + 1));
+    SkASSERT((int)max >= 0 && is_pow2(max + 1));
 
-       int s = (index & (max + 1)) - 1;
-       s = ~(s >> 31);
-       // at this stage, s is FFFFFFFF if we're on an odd interval, or 0 if an even interval
-       return (index ^ s) & max;
+    int s = (index & (max + 1)) - 1;
+    s = ~(s >> 31);
+    // at this stage, s is FFFFFFFF if we're on an odd interval, or 0 if an even interval
+    return (index ^ s) & max;
 }
 
 #endif
index 19530a0..6b8ff63 100644 (file)
-/*     this guy is pulled in multiple times, with the following symbols defined each time:
+/* libs/graphics/sgl/SkBitmapSamplerTemplate.h
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
+/*  this guy is pulled in multiple times, with the following symbols defined each time:
 
-       #define BITMAP_CLASSNAME_PREFIX(name)                   ARGB32##name
-       #defube BITMAP_PIXEL_TO_PMCOLOR(bitmap, x, y)   *bitmap.getAddr32(x, y)
+    #define BITMAP_CLASSNAME_PREFIX(name)           ARGB32##name
+    #defube BITMAP_PIXEL_TO_PMCOLOR(bitmap, x, y)   *bitmap.getAddr32(x, y)
 */
 
 class BITMAP_CLASSNAME_PREFIX(_Point_Sampler) : public SkBitmapSampler {
 public:
-       BITMAP_CLASSNAME_PREFIX(_Point_Sampler)(const SkBitmap& bm, SkShader::TileMode tmx, SkShader::TileMode tmy)
-               : SkBitmapSampler(bm, SkPaint::kNo_FilterType, tmx, tmy)
-       {
-       }
+    BITMAP_CLASSNAME_PREFIX(_Point_Sampler)(const SkBitmap& bm, SkShader::TileMode tmx, SkShader::TileMode tmy)
+        : SkBitmapSampler(bm, SkPaint::kNo_FilterType, tmx, tmy)
+    {
+    }
 
-       virtual SkPMColor sample(SkFixed x, SkFixed y) const
-       {
+    virtual SkPMColor sample(SkFixed x, SkFixed y) const
+    {
         x = fTileProcX(SkFixedRound(x), fMaxX);
         y = fTileProcY(SkFixedRound(y), fMaxY);
-               return BITMAP_PIXEL_TO_PMCOLOR(fBitmap, x, y);
-       }
+        return BITMAP_PIXEL_TO_PMCOLOR(fBitmap, x, y);
+    }
 };
 
 
 class BITMAP_CLASSNAME_PREFIX(_Point_Clamp_Sampler) : public SkBitmapSampler {
 public:
-       BITMAP_CLASSNAME_PREFIX(_Point_Clamp_Sampler)(const SkBitmap& bm)
-               : SkBitmapSampler(bm, SkPaint::kNo_FilterType, SkShader::kClamp_TileMode, SkShader::kClamp_TileMode)
-       {
-       }
-
-       virtual SkPMColor sample(SkFixed x, SkFixed y) const
-       {
-               x = do_clamp(SkFixedRound(x), fMaxX);
-               y = do_clamp(SkFixedRound(y), fMaxY);
-               return BITMAP_PIXEL_TO_PMCOLOR(fBitmap, x, y);
-       }
+    BITMAP_CLASSNAME_PREFIX(_Point_Clamp_Sampler)(const SkBitmap& bm)
+        : SkBitmapSampler(bm, SkPaint::kNo_FilterType, SkShader::kClamp_TileMode, SkShader::kClamp_TileMode)
+    {
+    }
+
+    virtual SkPMColor sample(SkFixed x, SkFixed y) const
+    {
+        x = do_clamp(SkFixedRound(x), fMaxX);
+        y = do_clamp(SkFixedRound(y), fMaxY);
+        return BITMAP_PIXEL_TO_PMCOLOR(fBitmap, x, y);
+    }
 };
 
 class BITMAP_CLASSNAME_PREFIX(_Point_Repeat_Pow2_Sampler) : public SkBitmapSampler {
 public:
-       BITMAP_CLASSNAME_PREFIX(_Point_Repeat_Pow2_Sampler)(const SkBitmap& bm)
-               : SkBitmapSampler(bm, SkPaint::kNo_FilterType, SkShader::kRepeat_TileMode, SkShader::kRepeat_TileMode)
-       {
-       }
-
-       virtual SkPMColor sample(SkFixed x, SkFixed y) const
-       {
-               x = do_repeat_pow2(SkFixedRound(x), fMaxX);
-               y = do_repeat_pow2(SkFixedRound(y), fMaxY);
-               return BITMAP_PIXEL_TO_PMCOLOR(fBitmap, x, y);
-       }
+    BITMAP_CLASSNAME_PREFIX(_Point_Repeat_Pow2_Sampler)(const SkBitmap& bm)
+        : SkBitmapSampler(bm, SkPaint::kNo_FilterType, SkShader::kRepeat_TileMode, SkShader::kRepeat_TileMode)
+    {
+    }
+
+    virtual SkPMColor sample(SkFixed x, SkFixed y) const
+    {
+        x = do_repeat_pow2(SkFixedRound(x), fMaxX);
+        y = do_repeat_pow2(SkFixedRound(y), fMaxY);
+        return BITMAP_PIXEL_TO_PMCOLOR(fBitmap, x, y);
+    }
 };
 
 class BITMAP_CLASSNAME_PREFIX(_Point_Repeat_Mod_Sampler) : public SkBitmapSampler {
 public:
-       BITMAP_CLASSNAME_PREFIX(_Point_Repeat_Mod_Sampler)(const SkBitmap& bm)
-               : SkBitmapSampler(bm, SkPaint::kNo_FilterType, SkShader::kRepeat_TileMode, SkShader::kRepeat_TileMode)
-       {
-       }
-
-       virtual SkPMColor sample(SkFixed x, SkFixed y) const
-       {
-               x = do_repeat_mod(SkFixedRound(x), fMaxX);
-               y = do_repeat_mod(SkFixedRound(y), fMaxY);
-               return BITMAP_PIXEL_TO_PMCOLOR(fBitmap, x, y);
-       }
+    BITMAP_CLASSNAME_PREFIX(_Point_Repeat_Mod_Sampler)(const SkBitmap& bm)
+        : SkBitmapSampler(bm, SkPaint::kNo_FilterType, SkShader::kRepeat_TileMode, SkShader::kRepeat_TileMode)
+    {
+    }
+
+    virtual SkPMColor sample(SkFixed x, SkFixed y) const
+    {
+        x = do_repeat_mod(SkFixedRound(x), fMaxX);
+        y = do_repeat_mod(SkFixedRound(y), fMaxY);
+        return BITMAP_PIXEL_TO_PMCOLOR(fBitmap, x, y);
+    }
 };
 
 class BITMAP_CLASSNAME_PREFIX(_Point_Mirror_Pow2_Sampler) : public SkBitmapSampler {
 public:
-       BITMAP_CLASSNAME_PREFIX(_Point_Mirror_Pow2_Sampler)(const SkBitmap& bm)
-               : SkBitmapSampler(bm, SkPaint::kNo_FilterType, SkShader::kMirror_TileMode, SkShader::kMirror_TileMode)
-       {
-       }
-
-       virtual SkPMColor sample(SkFixed x, SkFixed y) const
-       {
-               x = do_mirror_pow2(SkFixedRound(x), fMaxX);
-               y = do_mirror_pow2(SkFixedRound(y), fMaxY);
-               return BITMAP_PIXEL_TO_PMCOLOR(fBitmap, x, y);
-       }
+    BITMAP_CLASSNAME_PREFIX(_Point_Mirror_Pow2_Sampler)(const SkBitmap& bm)
+        : SkBitmapSampler(bm, SkPaint::kNo_FilterType, SkShader::kMirror_TileMode, SkShader::kMirror_TileMode)
+    {
+    }
+
+    virtual SkPMColor sample(SkFixed x, SkFixed y) const
+    {
+        x = do_mirror_pow2(SkFixedRound(x), fMaxX);
+        y = do_mirror_pow2(SkFixedRound(y), fMaxY);
+        return BITMAP_PIXEL_TO_PMCOLOR(fBitmap, x, y);
+    }
 };
 
 class BITMAP_CLASSNAME_PREFIX(_Point_Mirror_Mod_Sampler) : public SkBitmapSampler {
 public:
-       BITMAP_CLASSNAME_PREFIX(_Point_Mirror_Mod_Sampler)(const SkBitmap& bm)
-               : SkBitmapSampler(bm, SkPaint::kNo_FilterType, SkShader::kMirror_TileMode, SkShader::kMirror_TileMode)
-       {
-       }
-
-       virtual SkPMColor sample(SkFixed x, SkFixed y) const
-       {
-               x = do_mirror_mod(SkFixedRound(x), fMaxX);
-               y = do_mirror_mod(SkFixedRound(y), fMaxY);
-               return BITMAP_PIXEL_TO_PMCOLOR(fBitmap, x, y);
-       }
+    BITMAP_CLASSNAME_PREFIX(_Point_Mirror_Mod_Sampler)(const SkBitmap& bm)
+        : SkBitmapSampler(bm, SkPaint::kNo_FilterType, SkShader::kMirror_TileMode, SkShader::kMirror_TileMode)
+    {
+    }
+
+    virtual SkPMColor sample(SkFixed x, SkFixed y) const
+    {
+        x = do_mirror_mod(SkFixedRound(x), fMaxX);
+        y = do_mirror_mod(SkFixedRound(y), fMaxY);
+        return BITMAP_PIXEL_TO_PMCOLOR(fBitmap, x, y);
+    }
 };
 
 #undef BITMAP_CLASSNAME_PREFIX
index b70f8bb..8b5048e 100644 (file)
@@ -1,27 +1,44 @@
+/* libs/graphics/sgl/SkBitmapShader.cpp
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #include "SkBitmapShader.h"
 #include "SkBitmapSampler.h"
 
 #ifdef SK_SUPPORT_MIPMAP
 static SkFixed find_mip_level(SkFixed dx, SkFixed dy)
 {
-       dx = SkAbs32(dx);
-       dy = SkAbs32(dy);
-       if (dx < dy)
-               dx = dy;
-       
-       if (dx < SK_Fixed1)
-               return 0;
-       
-       int clz = SkCLZ(dx);
-       SkASSERT(clz >= 1 && clz <= 15);
-       return SkIntToFixed(15 - clz) + ((unsigned)(dx << (clz + 1)) >> 16);
+    dx = SkAbs32(dx);
+    dy = SkAbs32(dy);
+    if (dx < dy)
+        dx = dy;
+    
+    if (dx < SK_Fixed1)
+        return 0;
+    
+    int clz = SkCLZ(dx);
+    SkASSERT(clz >= 1 && clz <= 15);
+    return SkIntToFixed(15 - clz) + ((unsigned)(dx << (clz + 1)) >> 16);
 }
 #endif
 
 SkBitmapShader::SkBitmapShader(const SkBitmap& src,
-                                                          bool transferOwnershipOfPixels,
-                                                          SkPaint::FilterType filterType,
-                                                          TileMode tmx, TileMode tmy)
+                               bool transferOwnershipOfPixels,
+                               SkPaint::FilterType filterType,
+                               TileMode tmx, TileMode tmy)
     :
 #ifdef SK_SUPPORT_MIPMAP
     fMipLevel(0), fMipSrcBitmap(src),
@@ -29,38 +46,38 @@ SkBitmapShader::SkBitmapShader(const SkBitmap& src,
     fOrigSrcBitmap(src)
     
 {
-       if (transferOwnershipOfPixels)
-       {
-               fOrigSrcBitmap.setOwnsPixels(src.getOwnsPixels());
-               ((SkBitmap*)&src)->setOwnsPixels(false);
-               // do the same for mipmap ownership???
-       }
-       fFilterType = SkToU8(filterType);
-       fTileModeX = SkToU8(tmx);
-       fTileModeY = SkToU8(tmy);
+    if (transferOwnershipOfPixels)
+    {
+        fOrigSrcBitmap.setOwnsPixels(src.getOwnsPixels());
+        ((SkBitmap*)&src)->setOwnsPixels(false);
+        // do the same for mipmap ownership???
+    }
+    fFilterType = SkToU8(filterType);
+    fTileModeX = SkToU8(tmx);
+    fTileModeY = SkToU8(tmy);
 }
 
 bool SkBitmapShader::setContext(const SkBitmap& device, const SkPaint& paint, const SkMatrix& matrix)
 {
-       // do this first, so we have a correct inverse matrix
-       if (!this->INHERITED::setContext(device, paint, matrix))
-               return false;
+    // do this first, so we have a correct inverse matrix
+    if (!this->INHERITED::setContext(device, paint, matrix))
+        return false;
 
-       uint32_t flags = fOrigSrcBitmap.isOpaque() ? kOpaqueAlpha_Flag : 0;
+    if (fOrigSrcBitmap.getConfig() == SkBitmap::kNo_Config ||
+        fOrigSrcBitmap.width() == 0 ||
+        fOrigSrcBitmap.height() == 0)
+        return false;
 
-       if (flags == kOpaqueAlpha_Flag && paint.getAlpha() != 0xFF)
-               flags = kConstAlpha_Flag;
-       
-       fFlags = SkToU8(flags);
+    SkBitmap& bm = fOrigSrcBitmap;
 
 #ifdef SK_SUPPORT_MIPMAP
-       if (fOrigSrcBitmap.countMipLevels())
-       {
-               const SkMatrix& inv = this->getTotalInverse();
+    if (fOrigSrcBitmap.countMipLevels())
+    {
+        const SkMatrix& inv = this->getTotalInverse();
 
-               fMipLevel = SkMin32(find_mip_level(     SkScalarToFixed(inv.getScaleX()),
-                                                                                       SkScalarToFixed(inv.getSkewY())),
-                                                       SkIntToFixed(fOrigSrcBitmap.countMipLevels() - 1));
+        fMipLevel = SkMin32(find_mip_level( SkScalarToFixed(inv.getScaleX()),
+                                            SkScalarToFixed(inv.getSkewY())),
+                            SkIntToFixed(fOrigSrcBitmap.countMipLevels() - 1));
 
 //        SkDEBUGF(("BitmapShader miplevel=%x\n", fMipLevel));
 
@@ -71,6 +88,7 @@ bool SkBitmapShader::setContext(const SkBitmap& device, const SkPaint& paint, co
                                 mm->fHeight,
                                 mm->fRowBytes);
         fMipSrcBitmap.setPixels(mm->fPixels);
+        bm = fMipSrcBitmap;
     }
     else
     {
@@ -78,31 +96,37 @@ bool SkBitmapShader::setContext(const SkBitmap& device, const SkPaint& paint, co
         fMipSrcBitmap = fOrigSrcBitmap;
     }
 #endif
-       return true;
+
+    fFlags = 0;
+    if (paint.getAlpha() == 255 && bm.isOpaque())
+        fFlags |= kOpaqueAlpha_Flag;
+
+    return true;
 }
 
 ///////////////////////////////////////////////////////////////////////////
 
 #include "SkColorPriv.h"
 #include "SkBitmapSampler.h"
+#include "SkPerspIter.h"
 
 class Sampler_BitmapShader : public SkBitmapShader {
 public:
-       Sampler_BitmapShader(const SkBitmap& src,
-                                                bool transferOwnershipOfPixels,
-                                                SkPaint::FilterType ftype,
-                                                TileMode tmx, TileMode tmy)
-               : SkBitmapShader(src, transferOwnershipOfPixels, ftype, tmx, tmy)
-       {
-               // make sure to pass our copy of the src bitmap to the sampler, and not the
-               // original parameter (which might go away).
-               fSampler = NULL;
-       }
-
-       virtual ~Sampler_BitmapShader()
-       {
-               SkDELETE(fSampler);
-       }
+    Sampler_BitmapShader(const SkBitmap& src,
+                         bool transferOwnershipOfPixels,
+                         SkPaint::FilterType ftype,
+                         TileMode tmx, TileMode tmy)
+        : SkBitmapShader(src, transferOwnershipOfPixels, ftype, tmx, tmy)
+    {
+        // make sure to pass our copy of the src bitmap to the sampler, and not the
+        // original parameter (which might go away).
+        fSampler = NULL;
+    }
+
+    virtual ~Sampler_BitmapShader()
+    {
+        SkDELETE(fSampler);
+    }
     
     virtual bool setContext(const SkBitmap& device, const SkPaint& paint, const SkMatrix& matrix)
     {
@@ -115,101 +139,118 @@ public:
         }
         return false;
     }
+    
+    enum {
+        kMaxPointStorageCount = 32
+    };
 
-       virtual void shadeSpan(int x, int y, SkPMColor dstC[], int count)
-       {
-               unsigned                        scale = SkAlpha255To256(this->getPaintAlpha());
-               const SkMatrix&         inv = this->getTotalInverse();
-               SkMatrix::MapPtProc     proc = this->getInverseMapPtProc();
-               SkBitmapSampler*         sampler = fSampler;
-               MatrixClass                     mc = this->getInverseClass();
+    virtual void shadeSpan(int x, int y, SkPMColor dstC[], int count)
+    {
+        unsigned            scale = SkAlpha255To256(this->getPaintAlpha());
+        const SkMatrix&     inv = this->getTotalInverse();
+        SkMatrix::MapPtProc proc = this->getInverseMapPtProc();
+        SkBitmapSampler*     sampler = fSampler;
+        MatrixClass         mc = this->getInverseClass();
 
-               SkPoint srcPt;
+        SkPoint srcPt;
 
-               if (mc != kPerspective_MatrixClass)
-               {
-                       proc(inv, SkIntToScalar(x), SkIntToScalar(y), &srcPt);
+        if (mc != kPerspective_MatrixClass)
+        {
+            proc(inv, SkIntToScalar(x), SkIntToScalar(y), &srcPt);
 
-                       SkFixed fx = SkScalarToFixed(srcPt.fX);
-                       SkFixed fy = SkScalarToFixed(srcPt.fY);
-                       SkFixed dx, dy;
+            SkFixed fx = SkScalarToFixed(srcPt.fX);
+            SkFixed fy = SkScalarToFixed(srcPt.fY);
+            SkFixed dx, dy;
 
-                       if (mc == kLinear_MatrixClass)
-                       {
-                               dx = SkScalarToFixed(inv.getScaleX());
-                               dy = SkScalarToFixed(inv.getSkewY());
-                       }
-                       else
-                               (void)inv.fixedStepInX(SkIntToScalar(y), &dx, &dy);
+            if (mc == kLinear_MatrixClass)
+            {
+                dx = SkScalarToFixed(inv.getScaleX());
+                dy = SkScalarToFixed(inv.getSkewY());
+            }
+            else
+                (void)inv.fixedStepInX(SkIntToScalar(y), &dx, &dy);
 
 #if defined(SK_SUPPORT_MIPMAP)
-        {   int level = this->getMipLevel() >> 16;
-            fx >>= level;
-            fy >>= level;
-            dx >>= level;
-            dy >>= level;
-               }
+            {   int level = this->getMipLevel() >> 16;
+                fx >>= level;
+                fy >>= level;
+                dx >>= level;
+                dy >>= level;
+            }
 #endif
-                       if (scale == 256)
-                       {
-                               for (int i = 0; i < count; i++)
-                               {
-                                       dstC[i] = sampler->sample(fx, fy);
-                                       fx += dx;
-                                       fy += dy;
-                               }
-                       }
-                       else
-                       {
-                               for (int i = 0; i < count; i++)
-                               {
-                                       uint32_t        c = sampler->sample(fx, fy);
-                                       dstC[i] = SkAlphaMulQ(c, scale);
-                                       fx += dx;
-                                       fy += dy;
-                               }
-                       }
-               }
-               else
-               {
-                       SkScalar        dstX = SkIntToScalar(x);
-                       SkScalar        dstY = SkIntToScalar(y);
-
-                       for (int i = 0; i < count; i++)
-                       {
-                               proc(inv, dstX, dstY, &srcPt);
-                               uint32_t        c = sampler->sample(SkScalarToFixed(srcPt.fX), SkScalarToFixed(srcPt.fY));
-
-                               if (scale != 256)
-                                       c = SkAlphaMulQ(c, scale);
-                               dstC[i] = c;
-                               dstX += SK_Scalar1;
-                       }
-               }
-       }
+            if (scale == 256)
+            {
+                for (int i = 0; i < count; i++)
+                {
+                    dstC[i] = sampler->sample(fx, fy);
+                    fx += dx;
+                    fy += dy;
+                }
+            }
+            else
+            {
+                for (int i = 0; i < count; i++)
+                {
+                    uint32_t    c = sampler->sample(fx, fy);
+                    dstC[i] = SkAlphaMulQ(c, scale);
+                    fx += dx;
+                    fy += dy;
+                }
+            }
+        }
+        else
+        {
+            SkPerspIter   iter(inv, SkIntToScalar(x), SkIntToScalar(y), count);
+            if (scale == 256)
+            {
+                while ((count = iter.next()) != 0)
+                {
+                    const SkFixed* src = iter.getXY();
+                    for (int i = 0; i < count; i++)
+                    {
+                        *dstC++ = sampler->sample(src[0], src[1]);
+                        src += 2;
+                    }
+                }
+            }
+            else
+            {
+                while ((count = iter.next()) != 0)
+                {
+                    const SkFixed* src = iter.getXY();
+                    for (int i = 0; i < count; i++)
+                    {
+                        uint32_t c = sampler->sample(src[0], src[1]);
+                        *dstC++ = SkAlphaMulQ(c, scale);
+                        src += 2;
+                    }
+                }
+            }
+        }
+    }
 
 protected:
 
     const SkMatrix& getUnitInverse() const { return fUnitInverse; }
     SkMatrix::MapPtProc getUnitInverseProc() const { return fUnitInverseProc; }
 
-       /* takes computed inverse (from setContext) and computes fUnitInverse,
-               taking srcBitmap width/height into account, so that fUnitInverse
-               walks 0...1, allowing the tile modes to all operate in a fast 16bit
-               space (no need for mod). The resulting coords need to be scaled by
-               width/height to get back into src space (coord * width >> 16).
-       */
-       void computeUnitInverse()
-       {
-               const SkBitmap& src = getSrcBitmap();
-               fUnitInverse = this->getTotalInverse();
-               fUnitInverse.postScale(SK_Scalar1 / src.width(), SK_Scalar1 / src.height(), 0, 0);
+    /* takes computed inverse (from setContext) and computes fUnitInverse,
+        taking srcBitmap width/height into account, so that fUnitInverse
+        walks 0...1, allowing the tile modes to all operate in a fast 16bit
+        space (no need for mod). The resulting coords need to be scaled by
+        width/height to get back into src space (coord * width >> 16).
+    */
+    void computeUnitInverse()
+    {
+        const SkBitmap& src = getSrcBitmap();
+        fUnitInverse = this->getTotalInverse();
+        fUnitInverse.postIDiv(src.width(), src.height());
         fUnitInverseProc = fUnitInverse.getMapPtProc();
-       }
+    }
 
 private:
-       SkBitmapSampler*        fSampler;
-       SkMatrix            fUnitInverse;
+    SkBitmapSampler*    fSampler;
+    SkMatrix            fUnitInverse;
     SkMatrix::MapPtProc fUnitInverseProc;
     
     typedef SkBitmapShader INHERITED;
@@ -219,190 +260,217 @@ private:
 
 class HasSpan16_Sampler_BitmapShader : public Sampler_BitmapShader {
 public:
-       HasSpan16_Sampler_BitmapShader(const SkBitmap& src, bool transferOwnershipOfPixels,
-                                                                       SkPaint::FilterType ft, TileMode tmx, TileMode tmy)
-               : Sampler_BitmapShader(src, transferOwnershipOfPixels, ft, tmx, tmy)
-       {
-       }
-
-       virtual uint32_t getFlags()
-       {
-               uint32_t flags = this->INHERITED::getFlags();
-
-               if (this->getPaintAlpha() == 0xFF && this->getInverseClass() != kPerspective_MatrixClass)
-                       flags |= SkShader::kHasSpan16_Flag;
-               else
-                       flags &= ~SkShader::kHasSpan16_Flag;
-
-               return flags;
-       }
+    HasSpan16_Sampler_BitmapShader(const SkBitmap& src, bool transferOwnershipOfPixels,
+                                    SkPaint::FilterType ft, TileMode tmx, TileMode tmy)
+        : Sampler_BitmapShader(src, transferOwnershipOfPixels, ft, tmx, tmy)
+    {
+    }
+
+    virtual uint32_t getFlags()
+    {
+        uint32_t flags = this->INHERITED::getFlags();
+        
+        switch (this->getSrcBitmap().getConfig()) {
+        case SkBitmap::kRGB_565_Config:
+            flags |= kHasSpan16_Flag;
+            break;
+        case SkBitmap::kIndex8_Config:
+            if (this->getSrcBitmap().isOpaque())
+                flags |= kHasSpan16_Flag;
+            break;
+        default:
+            break;
+        }
+        return flags;
+    }
+    
+    const SkBitmap& revealSrcBitmap() const { return this->getSrcBitmap(); }
+    uint8_t         revealPaintAlpha() const { return this->getPaintAlpha(); }
+    const SkMatrix& revealTotalInverse() const { return this->getTotalInverse(); }
+
 private:
-       typedef Sampler_BitmapShader INHERITED;
+    typedef Sampler_BitmapShader INHERITED;
 };
 
 ///////////////////////////////////////////////////////////////////////////
 
-#define NOFILTER_BITMAP_SHADER_CLASS                                   Index8_NoFilter_ClampTile_BitmapShader
-#define NOFILTER_BITMAP_SHADER_TILEMODE                                        SkShader::kClamp_TileMode
-#define NOFILTER_BITMAP_SHADER_TILEPROC(x, max)                        SkClampMax((x >> 16), max)
-#define NOFILTER_BITMAP_SHADER_TYPE                                            uint8_t
-#define NOFILTER_BITMAP_SHADER_SAMPLE_X(p, x)                  colors32[p[x]]
-#define NOFILTER_BITMAP_SHADER_SAMPLE_XY(p, x, y, rb)  colors32[p[x + y * rb]]
-#define NOFILTER_BITMAP_SHADER_PREAMBLE(bitmap, rb)            const SkPMColor* colors32 = bitmap.getColorTable()->lockColors()
-#define NOFILTER_BITMAP_SHADER_POSTAMBLE(bitmap)               bitmap.getColorTable()->unlockColors(false)
-#define NOFILTER_BITMAP_SHADER_SAMPLE_X16(p, x)                        colors16[p[x]]
-#define NOFILTER_BITMAP_SHADER_SAMPLE_XY16(p, x, y, rb)        colors16[p[x + y * rb]]
-#define NOFILTER_BITMAP_SHADER_PREAMBLE16(bitmap, rb)  const uint16_t* colors16 = bitmap.getColorTable()->lock16BitCache()
-#define NOFILTER_BITMAP_SHADER_POSTAMBLE16(bitmap)             bitmap.getColorTable()->unlock16BitCache()
+static void Index8_RepeatTile_Sprite16(HasSpan16_Sampler_BitmapShader* shader,
+                                       int x, int y, uint16_t dstC[], int count)
+{
+    const SkMatrix& inv = shader->revealTotalInverse();
+    const SkBitmap& srcBitmap = shader->revealSrcBitmap();
+    int             width = srcBitmap.width();
+    int             height = srcBitmap.height();
+
+    SkColorTable* ctable = srcBitmap.getColorTable();
+    const uint16_t* colors = ctable->lock16BitCache();
+
+    x += SkScalarRound(inv[SkMatrix::kMTransX]);
+    y += SkScalarRound(inv[SkMatrix::kMTransY]);
+    
+    x = do_repeat_mod(x, width - 1);
+    y = do_repeat_mod(y, height - 1);
+    const uint8_t* src = srcBitmap.getAddr8(x, y);
+    const uint8_t* row = src;
+
+    // do the first partial run
+    int n = width - x;
+    if (n > count) n = count;
+    count -= n;
+    SkASSERT(n > 0);
+    do {
+        *dstC++ = colors[*src++];
+    } while (--n > 0);
+
+    // do 1 complete run
+    if (count >= width)
+    {
+        uint16_t* baseDstC = dstC;  // remember the first complete run start
+        n = width;
+        count -= width;
+        src = row;
+        do {
+            *dstC++ = colors[*src++];
+        } while (--n > 0);
+
+        // do the rest of the complete runs
+        while (count >= width)
+        {
+            count -= width;
+            memcpy(dstC, baseDstC, width << 1);
+            dstC += width;
+        }
+        // do final partial run
+        if (count > 0)
+            memcpy(dstC, baseDstC, count << 1);
+    }
+    else // do final partial
+    {
+        if (count > 0)
+        {
+            src = row;
+            do {
+                *dstC++ = colors[*src++];
+            } while (--count > 0);
+        }
+    }
+    
+    ctable->unlock16BitCache();
+}
+
+///////////////////////////////////////////////////////////////////////////
+
+#define NOFILTER_BITMAP_SHADER_CLASS                    Index8_NoFilter_ClampTile_BitmapShader
+#define NOFILTER_BITMAP_SHADER_TILEMODE                 SkShader::kClamp_TileMode
+#define NOFILTER_BITMAP_SHADER_TILEPROC(x, max)         SkClampMax((x >> 16), max)
+#define NOFILTER_BITMAP_SHADER_TYPE                     uint8_t
+#define NOFILTER_BITMAP_SHADER_SAMPLE_X(p, x)           colors32[p[x]]
+#define NOFILTER_BITMAP_SHADER_SAMPLE_XY(p, x, y, rb)   colors32[p[x + y * rb]]
+#define NOFILTER_BITMAP_SHADER_PREAMBLE(bitmap, rb)     const SkPMColor* colors32 = bitmap.getColorTable()->lockColors()
+#define NOFILTER_BITMAP_SHADER_POSTAMBLE(bitmap)        bitmap.getColorTable()->unlockColors(false)
+#define NOFILTER_BITMAP_SHADER_SAMPLE_X16(p, x)         colors16[p[x]]
+#define NOFILTER_BITMAP_SHADER_SAMPLE_XY16(p, x, y, rb) colors16[p[x + y * rb]]
+#define NOFILTER_BITMAP_SHADER_PREAMBLE16(bitmap, rb)   const uint16_t* colors16 = bitmap.getColorTable()->lock16BitCache()
+#define NOFILTER_BITMAP_SHADER_POSTAMBLE16(bitmap)      bitmap.getColorTable()->unlock16BitCache()
 #include "SkBitmapShaderTemplate.h"
 
-#define NOFILTER_BITMAP_SHADER_CLASS                                   Index8_NoFilter_RepeatTile_BitmapShader
-#define NOFILTER_BITMAP_SHADER_TILEMODE                                        SkShader::kRepeat_TileMode
-#define NOFILTER_BITMAP_SHADER_TILEPROC(x, max)                        (fixed_repeat(x) * (max + 1) >> 16)
-#define NOFILTER_BITMAP_SHADER_TYPE                                            uint8_t
-#define NOFILTER_BITMAP_SHADER_SAMPLE_X(p, x)                  colors32[p[x]]
-#define NOFILTER_BITMAP_SHADER_SAMPLE_XY(p, x, y, rb)  colors32[p[x + y * rb]]
-#define NOFILTER_BITMAP_SHADER_PREAMBLE(bitmap, rb)            const SkPMColor* colors32 = bitmap.getColorTable()->lockColors()
-#define NOFILTER_BITMAP_SHADER_POSTAMBLE(bitmap)               bitmap.getColorTable()->unlockColors(false)
-#define NOFILTER_BITMAP_SHADER_SAMPLE_X16(p, x)                        colors16[p[x]]
-#define NOFILTER_BITMAP_SHADER_SAMPLE_XY16(p, x, y, rb)        colors16[p[x + y * rb]]
-#define NOFILTER_BITMAP_SHADER_PREAMBLE16(bitmap, rb)  const uint16_t* colors16 = bitmap.getColorTable()->lock16BitCache()
-#define NOFILTER_BITMAP_SHADER_POSTAMBLE16(bitmap)             bitmap.getColorTable()->unlock16BitCache()
+#define NOFILTER_BITMAP_SHADER_CLASS                    Index8_NoFilter_RepeatTile_BitmapShader
+#define NOFILTER_BITMAP_SHADER_TILEMODE                 SkShader::kRepeat_TileMode
+#define NOFILTER_BITMAP_SHADER_TILEPROC(x, max)         (fixed_repeat(x) * (max + 1) >> 16)
+#define NOFILTER_BITMAP_SHADER_TYPE                     uint8_t
+#define NOFILTER_BITMAP_SHADER_SAMPLE_X(p, x)           colors32[p[x]]
+#define NOFILTER_BITMAP_SHADER_SAMPLE_XY(p, x, y, rb)   colors32[p[x + y * rb]]
+#define NOFILTER_BITMAP_SHADER_PREAMBLE(bitmap, rb)     const SkPMColor* colors32 = bitmap.getColorTable()->lockColors()
+#define NOFILTER_BITMAP_SHADER_POSTAMBLE(bitmap)        bitmap.getColorTable()->unlockColors(false)
+#define NOFILTER_BITMAP_SHADER_SAMPLE_X16(p, x)         colors16[p[x]]
+#define NOFILTER_BITMAP_SHADER_SAMPLE_XY16(p, x, y, rb) colors16[p[x + y * rb]]
+#define NOFILTER_BITMAP_SHADER_PREAMBLE16(bitmap, rb)   const uint16_t* colors16 = bitmap.getColorTable()->lock16BitCache()
+#define NOFILTER_BITMAP_SHADER_POSTAMBLE16(bitmap)      bitmap.getColorTable()->unlock16BitCache()
 #define NOFILTER_BITMAP_SHADER_USE_UNITINVERSE
+#define NOFILTER_BITMAP_SHADER_SPRITEPROC16             Index8_RepeatTile_Sprite16
 #include "SkBitmapShaderTemplate.h"
 
-#define NOFILTER_BITMAP_SHADER_CLASS                                   U16_NoFilter_ClampTile_BitmapShader
-#define NOFILTER_BITMAP_SHADER_TILEMODE                                        SkShader::kClamp_TileMode
-#define NOFILTER_BITMAP_SHADER_TILEPROC(x, max)                        SkClampMax((x >> 16), max)
-#define NOFILTER_BITMAP_SHADER_TYPE                                            uint16_t
-#define NOFILTER_BITMAP_SHADER_SAMPLE_X(p, x)                  SkPixel16ToPixel32(p[x])
-#define NOFILTER_BITMAP_SHADER_SAMPLE_XY(p, x, y, rb)  SkPixel16ToPixel32(*(const uint16_t*)((const char*)p + y * rb + (x << 1)))
-#define NOFILTER_BITMAP_SHADER_SAMPLE_X16(p, x)                        p[x]
-#define NOFILTER_BITMAP_SHADER_SAMPLE_XY16(p, x, y, rb)        *(const uint16_t*)((const char*)p + y * rb + (x << 1))
+#define NOFILTER_BITMAP_SHADER_CLASS                    U16_NoFilter_ClampTile_BitmapShader
+#define NOFILTER_BITMAP_SHADER_TILEMODE                 SkShader::kClamp_TileMode
+#define NOFILTER_BITMAP_SHADER_TILEPROC(x, max)         SkClampMax((x >> 16), max)
+#define NOFILTER_BITMAP_SHADER_TYPE                     uint16_t
+#define NOFILTER_BITMAP_SHADER_SAMPLE_X(p, x)           SkPixel16ToPixel32(p[x])
+#define NOFILTER_BITMAP_SHADER_SAMPLE_XY(p, x, y, rb)   SkPixel16ToPixel32(*(const uint16_t*)((const char*)p + y * rb + (x << 1)))
+#define NOFILTER_BITMAP_SHADER_SAMPLE_X16(p, x)         p[x]
+#define NOFILTER_BITMAP_SHADER_SAMPLE_XY16(p, x, y, rb) *(const uint16_t*)((const char*)p + y * rb + (x << 1))
 #include "SkBitmapShaderTemplate.h"
 
-#define NOFILTER_BITMAP_SHADER_CLASS                                   U16_NoFilter_RepeatTile_BitmapShader
-#define NOFILTER_BITMAP_SHADER_TILEMODE                                        SkShader::kRepeat_TileMode
-#define NOFILTER_BITMAP_SHADER_TILEPROC(x, max)                        (fixed_repeat(x) * (max + 1) >> 16)
-#define NOFILTER_BITMAP_SHADER_TYPE                                            uint16_t
-#define NOFILTER_BITMAP_SHADER_SAMPLE_X(p, x)                  SkPixel16ToPixel32(p[x])
-#define NOFILTER_BITMAP_SHADER_SAMPLE_XY(p, x, y, rb)  SkPixel16ToPixel32(*(const uint16_t*)((const char*)p + y * rb + (x << 1)))
-#define NOFILTER_BITMAP_SHADER_SAMPLE_X16(p, x)                        p[x]
-#define NOFILTER_BITMAP_SHADER_SAMPLE_XY16(p, x, y, rb)        *(const uint16_t*)((const char*)p + y * rb + (x << 1))
+#define NOFILTER_BITMAP_SHADER_CLASS                    U16_NoFilter_RepeatTile_BitmapShader
+#define NOFILTER_BITMAP_SHADER_TILEMODE                 SkShader::kRepeat_TileMode
+#define NOFILTER_BITMAP_SHADER_TILEPROC(x, max)         (fixed_repeat(x) * (max + 1) >> 16)
+#define NOFILTER_BITMAP_SHADER_TYPE                     uint16_t
+#define NOFILTER_BITMAP_SHADER_SAMPLE_X(p, x)           SkPixel16ToPixel32(p[x])
+#define NOFILTER_BITMAP_SHADER_SAMPLE_XY(p, x, y, rb)   SkPixel16ToPixel32(*(const uint16_t*)((const char*)p + y * rb + (x << 1)))
+#define NOFILTER_BITMAP_SHADER_SAMPLE_X16(p, x)         p[x]
+#define NOFILTER_BITMAP_SHADER_SAMPLE_XY16(p, x, y, rb) *(const uint16_t*)((const char*)p + y * rb + (x << 1))
 #define NOFILTER_BITMAP_SHADER_USE_UNITINVERSE
 #include "SkBitmapShaderTemplate.h"
 
-#define NOFILTER_BITMAP_SHADER_CLASS                                   U32_NoFilter_ClampTile_BitmapShader
-#define NOFILTER_BITMAP_SHADER_TILEMODE                                        SkShader::kClamp_TileMode
-#define NOFILTER_BITMAP_SHADER_TILEPROC(x, max)                        SkClampMax((x >> 16), max)
-#define NOFILTER_BITMAP_SHADER_TYPE                                            uint32_t
-#define NOFILTER_BITMAP_SHADER_SAMPLE_X(p, x)                  p[x]
-#define NOFILTER_BITMAP_SHADER_SAMPLE_XY(p, x, y, rb)  *(const uint32_t*)((const char*)p + y * rb + (x << 2))
-#define NOFILTER_BITMAP_SHADER_SAMPLE_X16(p, x)                        SkPixel32ToPixel16_ToU16(p[x])
-#define NOFILTER_BITMAP_SHADER_SAMPLE_XY16(p, x, y, rb)        SkPixel32ToPixel16_ToU16(*(const uint32_t*)((const char*)p + y * rb + (x << 2)))
+#define NOFILTER_BITMAP_SHADER_CLASS                    U32_NoFilter_ClampTile_BitmapShader
+#define NOFILTER_BITMAP_SHADER_TILEMODE                 SkShader::kClamp_TileMode
+#define NOFILTER_BITMAP_SHADER_TILEPROC(x, max)         SkClampMax((x >> 16), max)
+#define NOFILTER_BITMAP_SHADER_TYPE                     uint32_t
+#define NOFILTER_BITMAP_SHADER_SAMPLE_X(p, x)           p[x]
+#define NOFILTER_BITMAP_SHADER_SAMPLE_XY(p, x, y, rb)   *(const uint32_t*)((const char*)p + y * rb + (x << 2))
+#define NOFILTER_BITMAP_SHADER_SAMPLE_X16(p, x)         SkPixel32ToPixel16_ToU16(p[x])
+#define NOFILTER_BITMAP_SHADER_SAMPLE_XY16(p, x, y, rb) SkPixel32ToPixel16_ToU16(*(const uint32_t*)((const char*)p + y * rb + (x << 2)))
 #include "SkBitmapShaderTemplate.h"
 
-#define NOFILTER_BITMAP_SHADER_CLASS                                   U32_NoFilter_RepeatTile_BitmapShader
-#define NOFILTER_BITMAP_SHADER_TILEMODE                                        SkShader::kRepeat_TileMode
-#define NOFILTER_BITMAP_SHADER_TILEPROC(x, max)                        (fixed_repeat(x) * (max + 1) >> 16)
-#define NOFILTER_BITMAP_SHADER_TYPE                                            uint32_t
-#define NOFILTER_BITMAP_SHADER_SAMPLE_X(p, x)                  p[x]
-#define NOFILTER_BITMAP_SHADER_SAMPLE_XY(p, x, y, rb)  *(const uint32_t*)((const char*)p + y * rb + (x << 2))
-#define NOFILTER_BITMAP_SHADER_SAMPLE_X16(p, x)                        SkPixel32ToPixel16_ToU16(p[x])
-#define NOFILTER_BITMAP_SHADER_SAMPLE_XY16(p, x, y, rb)        SkPixel32ToPixel16_ToU16(*(const uint32_t*)((const char*)p + y * rb + (x << 2)))
+#define NOFILTER_BITMAP_SHADER_CLASS                    U32_NoFilter_RepeatTile_BitmapShader
+#define NOFILTER_BITMAP_SHADER_TILEMODE                 SkShader::kRepeat_TileMode
+#define NOFILTER_BITMAP_SHADER_TILEPROC(x, max)         (fixed_repeat(x) * (max + 1) >> 16)
+#define NOFILTER_BITMAP_SHADER_TYPE                     uint32_t
+#define NOFILTER_BITMAP_SHADER_SAMPLE_X(p, x)           p[x]
+#define NOFILTER_BITMAP_SHADER_SAMPLE_XY(p, x, y, rb)   *(const uint32_t*)((const char*)p + y * rb + (x << 2))
+#define NOFILTER_BITMAP_SHADER_SAMPLE_X16(p, x)         SkPixel32ToPixel16_ToU16(p[x])
+#define NOFILTER_BITMAP_SHADER_SAMPLE_XY16(p, x, y, rb) SkPixel32ToPixel16_ToU16(*(const uint32_t*)((const char*)p + y * rb + (x << 2)))
 #define NOFILTER_BITMAP_SHADER_USE_UNITINVERSE
 #include "SkBitmapShaderTemplate.h"
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////////
 
-#define Pack4Bytes(c00, c01, c10, c11) (((c00) << 24) | ((c01) << 16) | ((c10) << 8) | (c11))
-/*     Each long stores 4 coefficients, each in a byte.
-       coeff >> 24     -> [0][0]
-       coeff >> 16     -> [0][1]
-       coeff >>  8     -> [1][0]
-       coeff >>  0     -> [1][1]
-*/
-static const uint32_t gBilerpPackedCoeff[] = {
-       /* y == 0 */
-       Pack4Bytes(16,  0,  0,  0),     // x == 0
-       Pack4Bytes(12,  4,  0,  0),     // x == 1/4
-       Pack4Bytes( 8,  8,  0,  0),     // x == 1/2
-       Pack4Bytes( 4, 12,  0,  0),     // x == 3/4
-
-       /* y == 1/4 */
-       Pack4Bytes(12,  0,  4,  0),
-       Pack4Bytes( 9,  3,  3,  1),
-       Pack4Bytes( 6,  6,  2,  2),
-       Pack4Bytes( 3,  9,  1,  3),
-
-       /* y == 1/2 */
-       Pack4Bytes( 8,  0,  8,  0),
-       Pack4Bytes( 6,  2,  6,  2),
-       Pack4Bytes( 4,  4,  4,  4),
-       Pack4Bytes( 2,  6,  2,  6),
-
-       /* y == 3/4 */
-       Pack4Bytes( 4,  0, 12,  0),
-       Pack4Bytes( 3,  1,  9,  3),
-       Pack4Bytes( 2,  2,  6,  6),
-       Pack4Bytes( 1,  3,  3,  9)
-};
-
-// extract the high two bits in the fractional part of the fixed
-#define SK_BILERP_GET_BITS(x)  (((x) >> 14) & 3)
-
-static inline uint32_t sk_find_bilerp_coeff(const uint32_t coeff[], SkFixed fx, SkFixed fy)
+static inline SkPMColor expanded_rgb16_to_8888(uint32_t c, U8CPU alpha)
 {
-#ifdef SK_DEBUG
-       uint32_t c = coeff[(SK_BILERP_GET_BITS(fy) << 2) | SK_BILERP_GET_BITS(fx)];
-       SkASSERT((c >> 24) + ((c >> 16) & 0xFF) + ((c >> 8) & 0xFF) + (c & 0xFF) == 16);
+//    GGGG Gggg gggR RRRR rrrr r|BB BBBb bbbb
+    SkASSERT(alpha <= 255);
+
+#if 1
+    int scale = SkAlpha255To256(alpha);
+    int r = (c & 0xF800) * scale >> 16;
+    int g = ((c >> 21) & 0x3F) * scale >> 6;
+    int b = (c & 0x1F) * scale >> 5;
+    return SkPackARGB32(alpha, r, g, b);
+#else
+    int scale = SkAlpha255To256(alpha) >> 3;
+    c &= 0x07E0F81F;
+    c = c * scale;
+    int r = (c >> 13) & 0xFF;
+    int g = (c >> 24) & 0xFF;
+    int b = (c >> 2) & 0xFF;
+    return SkPackARGB32(alpha, r, g, b);
 #endif
-       return coeff[(SK_BILERP_GET_BITS(fy) << 2) | SK_BILERP_GET_BITS(fx)];
-}
-
-static inline uint32_t expand_rgb_16(U16CPU c, U16CPU rbMask)
-{
-       return ((c & SK_G16_MASK_IN_PLACE) << 16) | (c & rbMask);
-}
-
-static inline U16CPU compact_rgb_16(uint32_t c, U16CPU rbMask)
-{
-       return ((c >> 16) & SK_G16_MASK_IN_PLACE) | (c & rbMask);
-}
-
-static inline U16CPU sk_bilerp16(U16CPU c00, U16CPU c01, U16CPU c10, U16CPU c11, uint32_t coeff, U16CPU rbMask)
-{
-//     U16CPU rbMask = SK_R16B16_MASK_IN_PLACE;
-
-       c00 =   expand_rgb_16(c00, rbMask) * (coeff >> 24) +
-                       expand_rgb_16(c01, rbMask) * ((coeff >> 16) & 0xFF) +
-                       expand_rgb_16(c10, rbMask) * ((coeff >> 8) & 0xFF) +
-                       expand_rgb_16(c11, rbMask) * (coeff & 0xFF);
-
-       return compact_rgb_16(c00 >> 4, rbMask);
 }
 
-// this wacky line is to force the compiler to put this contant into a register
-// rather than try to construct it each time it is referenced in the inner-loop
-extern const uint16_t gRBMask_Bilerp_BitmapShader;
-
-#define BILERP_BITMAP16_SHADER_CLASS                   U16_Bilerp_BitmapShader
-#define BILERP_BITMAP16_SHADER_TYPE                            uint16_t
+#define BILERP_BITMAP16_SHADER_CLASS            U16_Bilerp_BitmapShader
+#define BILERP_BITMAP16_SHADER_TYPE             uint16_t
 #define BILERP_BITMAP16_SHADER_PREAMBLE(bm)
-#define BILERP_BITMAP16_SHADER_PIXEL(c)                        (c)
+#define BILERP_BITMAP16_SHADER_PIXEL(c)         (c)
 #define BILERP_BITMAP16_SHADER_POSTAMBLE(bm)
 #include "SkBitmapShader16BilerpTemplate.h"
 
-#define BILERP_BITMAP16_SHADER_CLASS                   Index8_Bilerp_BitmapShader
-#define BILERP_BITMAP16_SHADER_TYPE                            uint8_t
-#define BILERP_BITMAP16_SHADER_PREAMBLE(bm)            SkColorTable* ctable = (bm).getColorTable(); const uint16_t* colors16 = ctable->lock16BitCache()
-#define BILERP_BITMAP16_SHADER_PIXEL(c)                        colors16[c]
-#define BILERP_BITMAP16_SHADER_POSTAMBLE(bm)   ctable->unlock16BitCache()
+#define BILERP_BITMAP16_SHADER_CLASS            Index8_Bilerp_BitmapShader
+#define BILERP_BITMAP16_SHADER_TYPE             uint8_t
+#define BILERP_BITMAP16_SHADER_PREAMBLE(bm)     SkColorTable* ctable = (bm).getColorTable(); const uint16_t* colors16 = ctable->lock16BitCache()
+#define BILERP_BITMAP16_SHADER_PIXEL(c)         colors16[c]
+#define BILERP_BITMAP16_SHADER_POSTAMBLE(bm)    ctable->unlock16BitCache()
 #include "SkBitmapShader16BilerpTemplate.h"
 
-// we define it below all the includes, so they won't try to inline the value
-// (which doesn't fit in an immediate register load)
-const uint16_t gRBMask_Bilerp_BitmapShader = SK_R16B16_MASK_IN_PLACE;
+#include "ARGB32_Clamp_Bilinear_BitmapShader.cpp"
 
 ///////////////////////////////////////////////////////////////////////////
 ///////////////////////////////////////////////////////////////////////////
@@ -410,67 +478,71 @@ const uint16_t gRBMask_Bilerp_BitmapShader = SK_R16B16_MASK_IN_PLACE;
 #include "SkTemplatesPriv.h"
 
 SkShader* SkShader::CreateBitmapShader(const SkBitmap& src,
-                                                                          bool transferOwnershipOfPixels,
-                                                                          SkPaint::FilterType filterType,
-                                                                          TileMode tmx, TileMode tmy,
-                                                                          void* storage, size_t storageSize)
+                                       bool transferOwnershipOfPixels,
+                                       SkPaint::FilterType filterType,
+                                       TileMode tmx, TileMode tmy,
+                                       void* storage, size_t storageSize)
 {
-       SkShader* shader = NULL;
-
-       if (filterType == SkPaint::kNo_FilterType)
-       {
-               switch (src.getConfig()) {
-               case SkBitmap::kIndex8_Config:
-                       if (kClamp_TileMode == tmx && kClamp_TileMode == tmy)
-                               SK_PLACEMENT_NEW_ARGS(shader, Index8_NoFilter_ClampTile_BitmapShader, storage, storageSize, (src, transferOwnershipOfPixels));
+    SkShader* shader = NULL;
+
+    if (filterType == SkPaint::kNo_FilterType)
+    {
+        switch (src.getConfig()) {
+        case SkBitmap::kIndex8_Config:
+            if (kClamp_TileMode == tmx && kClamp_TileMode == tmy)
+                SK_PLACEMENT_NEW_ARGS(shader, Index8_NoFilter_ClampTile_BitmapShader, storage, storageSize, (src, transferOwnershipOfPixels));
             else if (kRepeat_TileMode == tmx && kRepeat_TileMode == tmy)
-                               SK_PLACEMENT_NEW_ARGS(shader, Index8_NoFilter_RepeatTile_BitmapShader, storage, storageSize, (src, transferOwnershipOfPixels));
-                       break;
-               case SkBitmap::kRGB_565_Config:
+                SK_PLACEMENT_NEW_ARGS(shader, Index8_NoFilter_RepeatTile_BitmapShader, storage, storageSize, (src, transferOwnershipOfPixels));
+            break;
+        case SkBitmap::kRGB_565_Config:
             if (kClamp_TileMode == tmx && kClamp_TileMode == tmy)
                 SK_PLACEMENT_NEW_ARGS(shader, U16_NoFilter_ClampTile_BitmapShader, storage, storageSize, (src, transferOwnershipOfPixels));
             else if (kRepeat_TileMode == tmx && kRepeat_TileMode == tmy)
                 SK_PLACEMENT_NEW_ARGS(shader, U16_NoFilter_RepeatTile_BitmapShader, storage, storageSize, (src, transferOwnershipOfPixels));
-                       break;
-               case SkBitmap::kARGB_8888_Config:
-                       if (kClamp_TileMode == tmx && kClamp_TileMode == tmy)
-                               SK_PLACEMENT_NEW_ARGS(shader, U32_NoFilter_ClampTile_BitmapShader, storage, storageSize, (src, transferOwnershipOfPixels));
+            break;
+        case SkBitmap::kARGB_8888_Config:
+            if (kClamp_TileMode == tmx && kClamp_TileMode == tmy)
+                SK_PLACEMENT_NEW_ARGS(shader, U32_NoFilter_ClampTile_BitmapShader, storage, storageSize, (src, transferOwnershipOfPixels));
             else if (kRepeat_TileMode == tmx && kRepeat_TileMode == tmy)
-                               SK_PLACEMENT_NEW_ARGS(shader, U32_NoFilter_RepeatTile_BitmapShader, storage, storageSize, (src, transferOwnershipOfPixels));
-                       break;
-               default:
-                       break;
-               }
-       }
-       else if (filterType == SkPaint::kBilinear_FilterType
+                SK_PLACEMENT_NEW_ARGS(shader, U32_NoFilter_RepeatTile_BitmapShader, storage, storageSize, (src, transferOwnershipOfPixels));
+            break;
+        default:
+            break;
+        }
+    }
+    else if (filterType == SkPaint::kBilinear_FilterType
              && kClamp_TileMode == tmx
              && kClamp_TileMode == tmy)
-       {
-               switch (src.getConfig()) {
-               case SkBitmap::kIndex8_Config:
-                       SK_PLACEMENT_NEW_ARGS(shader, Index8_Bilerp_BitmapShader, storage, storageSize, (src, transferOwnershipOfPixels));
-                       break;
-               case SkBitmap::kRGB_565_Config:
-                       SK_PLACEMENT_NEW_ARGS(shader, U16_Bilerp_BitmapShader, storage, storageSize, (src, transferOwnershipOfPixels));
-                       break;
+    {
+        switch (src.getConfig()) {
+        case SkBitmap::kIndex8_Config:
+            if (src.isOpaque())
+                SK_PLACEMENT_NEW_ARGS(shader, Index8_Bilerp_BitmapShader, storage, storageSize, (src, transferOwnershipOfPixels));
+            break;
+        case SkBitmap::kRGB_565_Config:
+            SK_PLACEMENT_NEW_ARGS(shader, U16_Bilerp_BitmapShader, storage, storageSize, (src, transferOwnershipOfPixels));
+            break;
+        case SkBitmap::kARGB_8888_Config:
+            SK_PLACEMENT_NEW_ARGS(shader, ARGB32_Clamp_Bilinear_BitmapShader, storage, storageSize, (src, transferOwnershipOfPixels));
+            break;
         default:
             break;
-               }
-       }
+        }
+    }
     
     // if shader is null, then none of the special cases could handle the request
     // so fall through to our slow-general case
-       if (shader == NULL)
-               SK_PLACEMENT_NEW_ARGS(shader, Sampler_BitmapShader, storage, storageSize,
+    if (shader == NULL)
+        SK_PLACEMENT_NEW_ARGS(shader, Sampler_BitmapShader, storage, storageSize,
                               (src, transferOwnershipOfPixels, filterType, tmx, tmy));
-       return shader;
+    return shader;
 }
 
 SkShader* SkShader::CreateBitmapShader(const SkBitmap& src,
-                                                                          bool transferOwnershipOfPixels,
-                                                                          SkPaint::FilterType filterType,
-                                                                          TileMode tmx, TileMode tmy)
+                                       bool transferOwnershipOfPixels,
+                                       SkPaint::FilterType filterType,
+                                       TileMode tmx, TileMode tmy)
 {
-       return SkShader::CreateBitmapShader(src, transferOwnershipOfPixels, filterType, tmx, tmy, NULL, 0);
+    return SkShader::CreateBitmapShader(src, transferOwnershipOfPixels, filterType, tmx, tmy, NULL, 0);
 }
 
index 6727ec4..d005843 100644 (file)
@@ -1,3 +1,20 @@
+/* libs/graphics/sgl/SkBitmapShader.h
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #ifndef SkBitmapShader_DEFINED
 #define SkBitmapShader_DEFINED
 
 
 class SkBitmapShader : public SkShader {
 public:
-       SkBitmapShader( const SkBitmap& src, bool transferOwnershipOfPixels,
-                                       SkPaint::FilterType, TileMode tx, TileMode ty);
+    SkBitmapShader( const SkBitmap& src, bool transferOwnershipOfPixels,
+                    SkPaint::FilterType, TileMode tx, TileMode ty);
 
-       virtual bool        setContext(const SkBitmap&, const SkPaint& paint, const SkMatrix&);
-       virtual uint32_t        getFlags() { return fFlags; }
+    virtual bool        setContext(const SkBitmap&, const SkPaint& paint, const SkMatrix&);
+    virtual uint32_t    getFlags() { return fFlags; }
 
 protected:
-       const SkBitmap&         getSrcBitmap() const
+    const SkBitmap&     getSrcBitmap() const
     {
 #ifdef SK_SUPPORT_MIPMAP
         return fMipSrcBitmap;
@@ -22,10 +39,10 @@ protected:
         return fOrigSrcBitmap;
 #endif
     }
-       SkPaint::FilterType     getFilterType() const { return (SkPaint::FilterType)fFilterType; }
-       TileMode            getTileModeX() const { return (TileMode)fTileModeX; }
-       TileMode            getTileModeY() const { return (TileMode)fTileModeY; }
-       SkFixed                         getMipLevel() const 
+    SkPaint::FilterType getFilterType() const { return (SkPaint::FilterType)fFilterType; }
+    TileMode            getTileModeX() const { return (TileMode)fTileModeX; }
+    TileMode            getTileModeY() const { return (TileMode)fTileModeY; }
+    SkFixed             getMipLevel() const 
     {
 #ifdef SK_SUPPORT_MIPMAP
         return fMipLevel;
@@ -36,16 +53,16 @@ protected:
 
 private:
 #ifdef SK_SUPPORT_MIPMAP
-       SkFixed         fMipLevel;
+    SkFixed     fMipLevel;
     SkBitmap    fMipSrcBitmap; // the chosen level (in setContext)
 #endif
-       SkBitmap        fOrigSrcBitmap;
-       U8                      fFilterType;
-       U8                      fTileModeX;
+    SkBitmap    fOrigSrcBitmap;
+    U8          fFilterType;
+    U8          fTileModeX;
     U8          fTileModeY;
-       U8                      fFlags;
+    U8          fFlags;
 
-       typedef SkShader INHERITED;
+    typedef SkShader INHERITED;
 };
 
 #endif
index fa64a61..708da2a 100644 (file)
-
+/* libs/graphics/sgl/SkBitmapShader16BilerpTemplate.h
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
+#include "SkFilterProc.h"
 
 class BILERP_BITMAP16_SHADER_CLASS : public HasSpan16_Sampler_BitmapShader {
 public:
-       BILERP_BITMAP16_SHADER_CLASS(const SkBitmap& src, bool transferOwnershipOfPixels)
-               : HasSpan16_Sampler_BitmapShader(src, transferOwnershipOfPixels, SkPaint::kBilinear_FilterType,
+    BILERP_BITMAP16_SHADER_CLASS(const SkBitmap& src, bool transferOwnershipOfPixels)
+        : HasSpan16_Sampler_BitmapShader(src, transferOwnershipOfPixels, SkPaint::kBilinear_FilterType,
                                          SkShader::kClamp_TileMode, SkShader::kClamp_TileMode)
-       {
-       }
-
-       virtual void shadeSpanOpaque16(int x, int y, U16 dstC[], int count)
-       {
-               SkASSERT(count > 0);
-               SkASSERT(this->getInverseClass() != kPerspective_MatrixClass);
-               SkASSERT(this->getPaintAlpha() == 0xFF);
-
-               const SkMatrix& inv = this->getTotalInverse();
-               const SkBitmap& srcBitmap = this->getSrcBitmap();
-               unsigned                srcMaxX = srcBitmap.width() - 1;
-               unsigned                srcMaxY = srcBitmap.height() - 1;
-               unsigned                srcRB = srcBitmap.rowBytes();
-               SkFixed                 fx, fy, dx, dy;
-
-               // now init fx, fy, dx, dy
-               {
-                       SkPoint srcPt;
-                       this->getInverseMapPtProc()(inv, SkIntToScalar(x), SkIntToScalar(y), &srcPt);
-
-                       fx = SkScalarToFixed(srcPt.fX);
-                       fy = SkScalarToFixed(srcPt.fY);
-
-                       if (this->getInverseClass() == kFixedStepInX_MatrixClass)
-                               (void)inv.fixedStepInX(SkIntToScalar(y), &dx, &dy);
-                       else
-                       {
-                               dx = SkScalarToFixed(inv.getScaleX());
-                               dy = SkScalarToFixed(inv.getSkewY());
-                       }
-               }
-
-               BILERP_BITMAP16_SHADER_PREAMBLE(srcBitmap);
-
-               const U32* coeff_table = gBilerpPackedCoeff;
-               const BILERP_BITMAP16_SHADER_TYPE* srcPixels = (const BILERP_BITMAP16_SHADER_TYPE*)srcBitmap.getPixels();
-               U16CPU rbMask = gRBMask_Bilerp_BitmapShader;
-
-               if (dy == 0)
-               {
-                       fy = SkClampMax(fy, srcMaxY << 16);
-                       coeff_table += SK_BILERP_GET_BITS(fy) << 2;     // jump the table to the correct section (so we can just use fx to index it)
-
-                       unsigned y = fy >> 16;
-                       SkASSERT((int)y >= 0 && y <= srcMaxY);
-                       // pre-bias srcPixels since y won't change
-                       srcPixels = (const BILERP_BITMAP16_SHADER_TYPE*)((const char*)srcPixels + y * srcRB);
-                       // now make y the step from one row to the next
-                       y = srcRB;
-                       if (y == srcMaxY)
-                               y = 0;
-
-                       do {
-                               unsigned fx_clamped = SkClampMax(fx, srcMaxX << 16);
-                               unsigned x = fx_clamped >> 16;
-                               SkASSERT((int)x >= 0 && x <= srcMaxX);
-
-                               const BILERP_BITMAP16_SHADER_TYPE *p00, *p01, *p10, *p11;
-
-                               p00 = p01 = srcPixels + x;
-                               if (x < srcMaxX)
-                                       p01 += 1;
-                               p10 = (const BILERP_BITMAP16_SHADER_TYPE*)((const char*)p00 + y);
-                               p11 = (const BILERP_BITMAP16_SHADER_TYPE*)((const char*)p01 + y);
-
-                               *dstC++ = SkToU16(sk_bilerp16(  BILERP_BITMAP16_SHADER_PIXEL(*p00),
-                                                                                               BILERP_BITMAP16_SHADER_PIXEL(*p01),
-                                                                                               BILERP_BITMAP16_SHADER_PIXEL(*p10),
-                                                                                               BILERP_BITMAP16_SHADER_PIXEL(*p11),
-                                                                                               coeff_table[SK_BILERP_GET_BITS(fx_clamped)],
-                                                                                               rbMask));
-
-                               fx += dx;
-                       } while (--count != 0);
-               }
-               else
-               {
-                       do {
-                               unsigned x = SkClampMax(fx, srcMaxX << 16) >> 16;
-                               unsigned y = SkClampMax(fy, srcMaxY << 16) >> 16;
-
-                               SkASSERT((int)x >= 0 && x <= srcMaxX);
-                               SkASSERT((int)y >= 0 && y <= srcMaxY);
-
-                               const BILERP_BITMAP16_SHADER_TYPE *p00, *p01, *p10, *p11;
-
-                               p00 = p01 = ((const BILERP_BITMAP16_SHADER_TYPE*)((const char*)srcPixels + y * srcRB)) + x;
-                               if (x < srcMaxX)
-                                       p01 += 1;
-                               p10 = p00;
-                               p11 = p01;
-                               if (y < srcMaxY)
-                               {
-                                       p10 = (const BILERP_BITMAP16_SHADER_TYPE*)((const char*)p10 + srcRB);
-                                       p11 = (const BILERP_BITMAP16_SHADER_TYPE*)((const char*)p11 + srcRB);
-                               }
-
-                               *dstC++ = SkToU16(sk_bilerp16(  BILERP_BITMAP16_SHADER_PIXEL(*p00),
-                                                                                               BILERP_BITMAP16_SHADER_PIXEL(*p01),
-                                                                                               BILERP_BITMAP16_SHADER_PIXEL(*p10),
-                                                                                               BILERP_BITMAP16_SHADER_PIXEL(*p11),
-                                                                                               sk_find_bilerp_coeff(coeff_table, fx, fy),
-                                                                                               rbMask));
-
-                               fx += dx;
-                               fy += dy;
-                       } while (--count != 0);
-               }
-
-               BILERP_BITMAP16_SHADER_POSTAMBLE(srcBitmap);
-       }
+    {
+    }
+
+    virtual void shadeSpan(int x, int y, SkPMColor dstC[], int count)
+    {
+        SkASSERT(count > 0);
+        
+        U8CPU alpha = this->getPaintAlpha();
+
+        const SkMatrix& inv = this->getTotalInverse();
+        const SkBitmap& srcBitmap = this->getSrcBitmap();
+        unsigned        srcMaxX = srcBitmap.width() - 1;
+        unsigned        srcMaxY = srcBitmap.height() - 1;
+        unsigned        srcRB = srcBitmap.rowBytes();
+
+        BILERP_BITMAP16_SHADER_PREAMBLE(srcBitmap);
+
+        const SkFilterProc* proc_table = SkGetBilinearFilterProcTable();
+        const BILERP_BITMAP16_SHADER_TYPE* srcPixels = (const BILERP_BITMAP16_SHADER_TYPE*)srcBitmap.getPixels();
+
+        if (this->getInverseClass() == kPerspective_MatrixClass)
+        {
+            SkPerspIter   iter(inv, SkIntToScalar(x), SkIntToScalar(y), count);
+            while ((count = iter.next()) != 0)
+            {
+                const SkFixed* srcXY = iter.getXY();
+                while (--count >= 0)
+                {
+                    SkFixed fx = *srcXY++;
+                    SkFixed fy = *srcXY++;
+                    unsigned x = SkClampMax(fx, srcMaxX << 16) >> 16;
+                    unsigned y = SkClampMax(fy, srcMaxY << 16) >> 16;
+
+                    SkASSERT(x <= srcMaxX);
+                    SkASSERT(y <= srcMaxY);
+
+                    const BILERP_BITMAP16_SHADER_TYPE *p00, *p01, *p10, *p11;
+
+                    p00 = p01 = ((const BILERP_BITMAP16_SHADER_TYPE*)((const char*)srcPixels + y * srcRB)) + x;
+                    if (x < srcMaxX)
+                        p01 += 1;
+                    p10 = p00;
+                    p11 = p01;
+                    if (y < srcMaxY)
+                    {
+                        p10 = (const BILERP_BITMAP16_SHADER_TYPE*)((const char*)p10 + srcRB);
+                        p11 = (const BILERP_BITMAP16_SHADER_TYPE*)((const char*)p11 + srcRB);
+                    }
+
+                    SkFilterProc proc = SkGetBilinearFilterProc(proc_table, fx, fy);
+                    uint32_t c = proc(SkExpand_rgb_16(BILERP_BITMAP16_SHADER_PIXEL(*p00)),
+                                      SkExpand_rgb_16(BILERP_BITMAP16_SHADER_PIXEL(*p01)),
+                                      SkExpand_rgb_16(BILERP_BITMAP16_SHADER_PIXEL(*p10)),
+                                      SkExpand_rgb_16(BILERP_BITMAP16_SHADER_PIXEL(*p11)));
+
+                    *dstC++ = expanded_rgb16_to_8888(c, alpha);
+                }
+            }
+        }
+        else    // linear case
+        {
+            SkFixed fx, fy, dx, dy;
+
+            // now init fx, fy, dx, dy
+            {
+                SkPoint srcPt;
+                this->getInverseMapPtProc()(inv, SkIntToScalar(x), SkIntToScalar(y), &srcPt);
+
+                fx = SkScalarToFixed(srcPt.fX);
+                fy = SkScalarToFixed(srcPt.fY);
+
+                if (this->getInverseClass() == kFixedStepInX_MatrixClass)
+                    (void)inv.fixedStepInX(SkIntToScalar(y), &dx, &dy);
+                else
+                {
+                    dx = SkScalarToFixed(inv.getScaleX());
+                    dy = SkScalarToFixed(inv.getSkewY());
+                }
+            }
+
+            do {
+                unsigned x = SkClampMax(fx, srcMaxX << 16) >> 16;
+                unsigned y = SkClampMax(fy, srcMaxY << 16) >> 16;
+
+                SkASSERT((int)x >= 0 && x <= srcMaxX);
+                SkASSERT((int)y >= 0 && y <= srcMaxY);
+
+                const BILERP_BITMAP16_SHADER_TYPE *p00, *p01, *p10, *p11;
+
+                p00 = p01 = ((const BILERP_BITMAP16_SHADER_TYPE*)((const char*)srcPixels + y * srcRB)) + x;
+                if (x < srcMaxX)
+                    p01 += 1;
+                p10 = p00;
+                p11 = p01;
+                if (y < srcMaxY)
+                {
+                    p10 = (const BILERP_BITMAP16_SHADER_TYPE*)((const char*)p10 + srcRB);
+                    p11 = (const BILERP_BITMAP16_SHADER_TYPE*)((const char*)p11 + srcRB);
+                }
+
+                SkFilterProc proc = SkGetBilinearFilterProc(proc_table, fx, fy);
+                uint32_t c = proc(SkExpand_rgb_16(BILERP_BITMAP16_SHADER_PIXEL(*p00)),
+                                  SkExpand_rgb_16(BILERP_BITMAP16_SHADER_PIXEL(*p01)),
+                                  SkExpand_rgb_16(BILERP_BITMAP16_SHADER_PIXEL(*p10)),
+                                  SkExpand_rgb_16(BILERP_BITMAP16_SHADER_PIXEL(*p11)));
+                *dstC++ = expanded_rgb16_to_8888(c, alpha);
+
+                fx += dx;
+                fy += dy;
+            } while (--count != 0);
+        }
+        BILERP_BITMAP16_SHADER_POSTAMBLE(srcBitmap);
+    }
+
+    virtual void shadeSpan16(int x, int y, U16 dstC[], int count)
+    {
+        SkASSERT(count > 0);
+
+        const SkMatrix& inv = this->getTotalInverse();
+        const SkBitmap& srcBitmap = this->getSrcBitmap();
+        unsigned        srcMaxX = srcBitmap.width() - 1;
+        unsigned        srcMaxY = srcBitmap.height() - 1;
+        unsigned        srcRB = srcBitmap.rowBytes();
+
+        BILERP_BITMAP16_SHADER_PREAMBLE(srcBitmap);
+
+        const SkFilterProc* proc_table = SkGetBilinearFilterProcTable();
+        const BILERP_BITMAP16_SHADER_TYPE* srcPixels = (const BILERP_BITMAP16_SHADER_TYPE*)srcBitmap.getPixels();
+
+        if (this->getInverseClass() == kPerspective_MatrixClass)
+        {
+            SkPerspIter   iter(inv, SkIntToScalar(x), SkIntToScalar(y), count);
+            while ((count = iter.next()) != 0)
+            {
+                const SkFixed* srcXY = iter.getXY();
+                while (--count >= 0)
+                {
+                    SkFixed fx = *srcXY++;
+                    SkFixed fy = *srcXY++;
+                    unsigned x = SkClampMax(fx, srcMaxX << 16) >> 16;
+                    unsigned y = SkClampMax(fy, srcMaxY << 16) >> 16;
+
+                    SkASSERT(x <= srcMaxX);
+                    SkASSERT(y <= srcMaxY);
+
+                    const BILERP_BITMAP16_SHADER_TYPE *p00, *p01, *p10, *p11;
+
+                    p00 = p01 = ((const BILERP_BITMAP16_SHADER_TYPE*)((const char*)srcPixels + y * srcRB)) + x;
+                    if (x < srcMaxX)
+                        p01 += 1;
+                    p10 = p00;
+                    p11 = p01;
+                    if (y < srcMaxY)
+                    {
+                        p10 = (const BILERP_BITMAP16_SHADER_TYPE*)((const char*)p10 + srcRB);
+                        p11 = (const BILERP_BITMAP16_SHADER_TYPE*)((const char*)p11 + srcRB);
+                    }
+
+                    SkFilterProc proc = SkGetBilinearFilterProc(proc_table, fx, fy);
+                    uint32_t c = proc(SkExpand_rgb_16(BILERP_BITMAP16_SHADER_PIXEL(*p00)),
+                                      SkExpand_rgb_16(BILERP_BITMAP16_SHADER_PIXEL(*p01)),
+                                      SkExpand_rgb_16(BILERP_BITMAP16_SHADER_PIXEL(*p10)),
+                                      SkExpand_rgb_16(BILERP_BITMAP16_SHADER_PIXEL(*p11)));
+                    *dstC++ = SkCompact_rgb_16(c);
+                }
+            }
+        }
+        else    // linear case
+        {
+            SkFixed fx, fy, dx, dy;
+
+            // now init fx, fy, dx, dy
+            {
+                SkPoint srcPt;
+                this->getInverseMapPtProc()(inv, SkIntToScalar(x), SkIntToScalar(y), &srcPt);
+
+                fx = SkScalarToFixed(srcPt.fX);
+                fy = SkScalarToFixed(srcPt.fY);
+
+                if (this->getInverseClass() == kFixedStepInX_MatrixClass)
+                    (void)inv.fixedStepInX(SkIntToScalar(y), &dx, &dy);
+                else
+                {
+                    dx = SkScalarToFixed(inv.getScaleX());
+                    dy = SkScalarToFixed(inv.getSkewY());
+                }
+            }
+
+            do {
+                unsigned x = SkClampMax(fx, srcMaxX << 16) >> 16;
+                unsigned y = SkClampMax(fy, srcMaxY << 16) >> 16;
+
+                SkASSERT((int)x >= 0 && x <= srcMaxX);
+                SkASSERT((int)y >= 0 && y <= srcMaxY);
+
+                const BILERP_BITMAP16_SHADER_TYPE *p00, *p01, *p10, *p11;
+
+                p00 = p01 = ((const BILERP_BITMAP16_SHADER_TYPE*)((const char*)srcPixels + y * srcRB)) + x;
+                if (x < srcMaxX)
+                    p01 += 1;
+                p10 = p00;
+                p11 = p01;
+                if (y < srcMaxY)
+                {
+                    p10 = (const BILERP_BITMAP16_SHADER_TYPE*)((const char*)p10 + srcRB);
+                    p11 = (const BILERP_BITMAP16_SHADER_TYPE*)((const char*)p11 + srcRB);
+                }
+
+                SkFilterProc proc = SkGetBilinearFilterProc(proc_table, fx, fy);
+                uint32_t c = proc(SkExpand_rgb_16(BILERP_BITMAP16_SHADER_PIXEL(*p00)),
+                                  SkExpand_rgb_16(BILERP_BITMAP16_SHADER_PIXEL(*p01)),
+                                  SkExpand_rgb_16(BILERP_BITMAP16_SHADER_PIXEL(*p10)),
+                                  SkExpand_rgb_16(BILERP_BITMAP16_SHADER_PIXEL(*p11)));
+                *dstC++ = SkCompact_rgb_16(c);
+
+                fx += dx;
+                fy += dy;
+            } while (--count != 0);
+        }
+        BILERP_BITMAP16_SHADER_POSTAMBLE(srcBitmap);
+    }
 };
 
 #undef BILERP_BITMAP16_SHADER_CLASS
index 2e90b84..b77ad2c 100644 (file)
@@ -1,24 +1,41 @@
+/* libs/graphics/sgl/SkBitmapShaderTemplate.h
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 
 #ifndef NOFILTER_BITMAP_SHADER_PREAMBLE
-       #define NOFILTER_BITMAP_SHADER_PREAMBLE(bitmap, rb)
+    #define NOFILTER_BITMAP_SHADER_PREAMBLE(bitmap, rb)
 #endif
 #ifndef NOFILTER_BITMAP_SHADER_POSTAMBLE
-       #define NOFILTER_BITMAP_SHADER_POSTAMBLE(bitmap)
+    #define NOFILTER_BITMAP_SHADER_POSTAMBLE(bitmap)
 #endif
 #ifndef NOFILTER_BITMAP_SHADER_PREAMBLE16
-       #define NOFILTER_BITMAP_SHADER_PREAMBLE16(bitmap, rb)
+    #define NOFILTER_BITMAP_SHADER_PREAMBLE16(bitmap, rb)
 #endif
 #ifndef NOFILTER_BITMAP_SHADER_POSTAMBLE16
-       #define NOFILTER_BITMAP_SHADER_POSTAMBLE16(bitmap)
+    #define NOFILTER_BITMAP_SHADER_POSTAMBLE16(bitmap)
 #endif
 
 class NOFILTER_BITMAP_SHADER_CLASS : public HasSpan16_Sampler_BitmapShader {
 public:
-       NOFILTER_BITMAP_SHADER_CLASS(const SkBitmap& src, bool transferOwnershipOfPixels)
-               : HasSpan16_Sampler_BitmapShader(src, transferOwnershipOfPixels, SkPaint::kNo_FilterType,
+    NOFILTER_BITMAP_SHADER_CLASS(const SkBitmap& src, bool transferOwnershipOfPixels)
+        : HasSpan16_Sampler_BitmapShader(src, transferOwnershipOfPixels, SkPaint::kNo_FilterType,
                                          NOFILTER_BITMAP_SHADER_TILEMODE, NOFILTER_BITMAP_SHADER_TILEMODE)
-       {
-       }
+    {
+    }
     
 #ifdef NOFILTER_BITMAP_SHADER_USE_UNITINVERSE
     virtual bool setContext(const SkBitmap& device, const SkPaint& paint, const SkMatrix& matrix)
@@ -31,51 +48,85 @@ public:
     }
 #endif
 
-       virtual void shadeSpan(int x, int y, SkPMColor dstC[], int count)
-       {
-               if (this->getInverseClass() == kPerspective_MatrixClass)
-               {
-                       this->INHERITED::shadeSpan(x, y, dstC, count);
-                       return;
-               }
-
-               unsigned                scale = SkAlpha255To256(this->getPaintAlpha());
+    virtual void shadeSpan(int x, int y, SkPMColor dstC[], int count)
+    {
+        unsigned        scale = SkAlpha255To256(this->getPaintAlpha());
 #ifdef NOFILTER_BITMAP_SHADER_USE_UNITINVERSE
         const SkMatrix& inv = this->getUnitInverse();
         SkMatrix::MapPtProc invProc = this->getUnitInverseProc();
 #else
-               const SkMatrix& inv = this->getTotalInverse();
+        const SkMatrix& inv = this->getTotalInverse();
         SkMatrix::MapPtProc invProc = this->getInverseMapPtProc();
 #endif
-               const SkBitmap& srcBitmap = this->getSrcBitmap();
-               unsigned                srcMaxX = srcBitmap.width() - 1;
-               unsigned                srcMaxY = srcBitmap.height() - 1;
-               unsigned                srcRB = srcBitmap.rowBytes();
-               SkFixed                 fx, fy, dx, dy;
-
-               // now init fx, fy, dx, dy
-               {
-                       SkPoint srcPt;
-                       invProc(inv, SkIntToScalar(x), SkIntToScalar(y), &srcPt);
-
-                       fx = SkScalarToFixed(srcPt.fX);
-                       fy = SkScalarToFixed(srcPt.fY);
+        const SkBitmap& srcBitmap = this->getSrcBitmap();
+        unsigned        srcMaxX = srcBitmap.width() - 1;
+        unsigned        srcMaxY = srcBitmap.height() - 1;
+        unsigned        srcRB = srcBitmap.rowBytes();
+        SkFixed         fx, fy, dx, dy;
+
+        const NOFILTER_BITMAP_SHADER_TYPE* srcPixels = (const NOFILTER_BITMAP_SHADER_TYPE*)srcBitmap.getPixels();
+        NOFILTER_BITMAP_SHADER_PREAMBLE(srcBitmap, srcRB);
+
+        if (this->getInverseClass() == kPerspective_MatrixClass)
+        {
+            SkPerspIter   iter(inv, SkIntToScalar(x), SkIntToScalar(y), count);
+            while ((count = iter.next()) != 0)
+            {
+                const SkFixed* srcXY = iter.getXY();
+
+/*  Do I need this?
+#ifndef NOFILTER_BITMAP_SHADER_USE_UNITINVERSE
+            fx >>= level;
+            fy >>= level;
+#endif
+*/
+                if (256 == scale)
+                {
+                    while (--count >= 0)
+                    {
+                        fx = *srcXY++;
+                        fy = *srcXY++;
+                        unsigned x = NOFILTER_BITMAP_SHADER_TILEPROC(fx, srcMaxX);
+                        unsigned y = NOFILTER_BITMAP_SHADER_TILEPROC(fy, srcMaxY);
+                        *dstC++ = NOFILTER_BITMAP_SHADER_SAMPLE_XY(srcPixels, x, y, srcRB);
+                    }
+                }
+                else
+                {
+                    while (--count >= 0)
+                    {
+                        fx = *srcXY++;
+                        fy = *srcXY++;
+                        unsigned x = NOFILTER_BITMAP_SHADER_TILEPROC(fx, srcMaxX);
+                        unsigned y = NOFILTER_BITMAP_SHADER_TILEPROC(fy, srcMaxY);
+                        uint32_t c = NOFILTER_BITMAP_SHADER_SAMPLE_XY(srcPixels, x, y, srcRB);
+                        *dstC++ = SkAlphaMulQ(c, scale);
+                    }
+                }
+            }
+            return;
+        }
+
+        // now init fx, fy, dx, dy
+        {
+            SkPoint srcPt;
+            invProc(inv, SkIntToScalar(x), SkIntToScalar(y), &srcPt);
+
+            fx = SkScalarToFixed(srcPt.fX);
+            fy = SkScalarToFixed(srcPt.fY);
 #ifndef NOFILTER_BITMAP_SHADER_USE_UNITINVERSE
             fx += SK_Fixed1/2;
             fy += SK_Fixed1/2;
 #endif
 
-                       if (this->getInverseClass() == kFixedStepInX_MatrixClass)
-                               (void)inv.fixedStepInX(SkIntToScalar(y), &dx, &dy);
-                       else
-                       {
-                               dx = SkScalarToFixed(inv.getScaleX());
-                               dy = SkScalarToFixed(inv.getSkewY());
-                       }
-               }
-
-               const NOFILTER_BITMAP_SHADER_TYPE* srcPixels = (const NOFILTER_BITMAP_SHADER_TYPE*)srcBitmap.getPixels();
-               NOFILTER_BITMAP_SHADER_PREAMBLE(srcBitmap, srcRB);
+            if (this->getInverseClass() == kFixedStepInX_MatrixClass)
+                (void)inv.fixedStepInX(SkIntToScalar(y), &dx, &dy);
+            else
+            {
+                dx = SkScalarToFixed(inv.getScaleX());
+                dy = SkScalarToFixed(inv.getSkewY());
+            }
+        }
 
 #if defined(SK_SUPPORT_MIPMAP) && !defined(NOFILTER_BITMAP_SHADER_USE_UNITINVERSE)
         {   int level = this->getMipLevel() >> 16;
@@ -83,99 +134,124 @@ public:
             fy >>= level;
             dx >>= level;
             dy >>= level;
-               }
+        }
 #endif
 
-               if (dy == 0)
-               {
-                       int y_index = NOFILTER_BITMAP_SHADER_TILEPROC(fy, srcMaxY);
-//                     SkDEBUGF(("fy = %g, srcMaxY = %d, y_index = %d\n", SkFixedToFloat(fy), srcMaxY, y_index));
-                       srcPixels = (const NOFILTER_BITMAP_SHADER_TYPE*)((const char*)srcPixels + y_index * srcRB);
-                       if (scale == 256)
-                               while (--count >= 0)
-                               {
-                                       unsigned x = NOFILTER_BITMAP_SHADER_TILEPROC(fx, srcMaxX);
-                                       fx += dx;
-                                       *dstC++ = NOFILTER_BITMAP_SHADER_SAMPLE_X(srcPixels, x);
-                               }
-                       else
-                               while (--count >= 0)
-                               {
-                                       unsigned x = NOFILTER_BITMAP_SHADER_TILEPROC(fx, srcMaxX);
-                                       U32 c = NOFILTER_BITMAP_SHADER_SAMPLE_X(srcPixels, x);
-                                       fx += dx;
-                                       *dstC++ = SkAlphaMulQ(c, scale);
-                               }
-               }
-               else    // dy != 0
-               {
-                       if (scale == 256)
-                               while (--count >= 0)
-                               {
-                                       unsigned x = NOFILTER_BITMAP_SHADER_TILEPROC(fx, srcMaxX);
-                                       unsigned y = NOFILTER_BITMAP_SHADER_TILEPROC(fy, srcMaxY);
-                                       fx += dx;
-                                       fy += dy;
-                                       *dstC++ = NOFILTER_BITMAP_SHADER_SAMPLE_XY(srcPixels, x, y, srcRB);
-                               }
-                       else
-                               while (--count >= 0)
-                               {
-                                       unsigned x = NOFILTER_BITMAP_SHADER_TILEPROC(fx, srcMaxX);
-                                       unsigned y = NOFILTER_BITMAP_SHADER_TILEPROC(fy, srcMaxY);
-                                       U32 c = NOFILTER_BITMAP_SHADER_SAMPLE_XY(srcPixels, x, y, srcRB);
-                                       fx += dx;
-                                       fy += dy;
-                                       *dstC++ = SkAlphaMulQ(c, scale);
-                               }
-               }
-
-               NOFILTER_BITMAP_SHADER_POSTAMBLE(srcBitmap);
-       }
-
-       virtual void shadeSpanOpaque16(int x, int y, U16 dstC[], int count)
-       {
-               SkASSERT(count > 0);
-               SkASSERT(this->getInverseClass() != kPerspective_MatrixClass);
-               SkASSERT(this->getFlags() & SkShader::kHasSpan16_Flag);
-               SkASSERT(this->getFlags() & (SkShader::kOpaqueAlpha_Flag | SkShader::kConstAlpha_Flag));
+        if (dy == 0)
+        {
+            int y_index = NOFILTER_BITMAP_SHADER_TILEPROC(fy, srcMaxY);
+//          SkDEBUGF(("fy = %g, srcMaxY = %d, y_index = %d\n", SkFixedToFloat(fy), srcMaxY, y_index));
+            srcPixels = (const NOFILTER_BITMAP_SHADER_TYPE*)((const char*)srcPixels + y_index * srcRB);
+            if (scale == 256)
+                while (--count >= 0)
+                {
+                    unsigned x = NOFILTER_BITMAP_SHADER_TILEPROC(fx, srcMaxX);
+                    fx += dx;
+                    *dstC++ = NOFILTER_BITMAP_SHADER_SAMPLE_X(srcPixels, x);
+                }
+            else
+                while (--count >= 0)
+                {
+                    unsigned x = NOFILTER_BITMAP_SHADER_TILEPROC(fx, srcMaxX);
+                    U32 c = NOFILTER_BITMAP_SHADER_SAMPLE_X(srcPixels, x);
+                    fx += dx;
+                    *dstC++ = SkAlphaMulQ(c, scale);
+                }
+        }
+        else    // dy != 0
+        {
+            if (scale == 256)
+                while (--count >= 0)
+                {
+                    unsigned x = NOFILTER_BITMAP_SHADER_TILEPROC(fx, srcMaxX);
+                    unsigned y = NOFILTER_BITMAP_SHADER_TILEPROC(fy, srcMaxY);
+                    fx += dx;
+                    fy += dy;
+                    *dstC++ = NOFILTER_BITMAP_SHADER_SAMPLE_XY(srcPixels, x, y, srcRB);
+                }
+            else
+                while (--count >= 0)
+                {
+                    unsigned x = NOFILTER_BITMAP_SHADER_TILEPROC(fx, srcMaxX);
+                    unsigned y = NOFILTER_BITMAP_SHADER_TILEPROC(fy, srcMaxY);
+                    U32 c = NOFILTER_BITMAP_SHADER_SAMPLE_XY(srcPixels, x, y, srcRB);
+                    fx += dx;
+                    fy += dy;
+                    *dstC++ = SkAlphaMulQ(c, scale);
+                }
+        }
+
+        NOFILTER_BITMAP_SHADER_POSTAMBLE(srcBitmap);
+    }
+
+    virtual void shadeSpan16(int x, int y, uint16_t dstC[], int count)
+    {
+        SkASSERT(count > 0);
+        SkASSERT(this->getFlags() & SkShader::kHasSpan16_Flag);
+
+#ifdef NOFILTER_BITMAP_SHADER_SPRITEPROC16
+        if ((this->getTotalInverse().getType() & ~SkMatrix::kTranslate_Mask) == 0)
+        {
+            NOFILTER_BITMAP_SHADER_SPRITEPROC16(this, x, y, dstC, count);
+            return;
+        }
+#endif
 
 #ifdef NOFILTER_BITMAP_SHADER_USE_UNITINVERSE
         const SkMatrix& inv = this->getUnitInverse();
         SkMatrix::MapPtProc invProc = this->getUnitInverseProc();
 #else
-               const SkMatrix& inv = this->getTotalInverse();
+        const SkMatrix& inv = this->getTotalInverse();
         SkMatrix::MapPtProc invProc = this->getInverseMapPtProc();
 #endif
-               const SkBitmap& srcBitmap = this->getSrcBitmap();
-               unsigned                srcMaxX = srcBitmap.width() - 1;
-               unsigned                srcMaxY = srcBitmap.height() - 1;
-               unsigned                srcRB = srcBitmap.rowBytes();
-               SkFixed                 fx, fy, dx, dy;
-
-               // now init fx, fy, dx, dy
-               {
-                       SkPoint srcPt;
-                       invProc(inv, SkIntToScalar(x), SkIntToScalar(y), &srcPt);
-
-                       fx = SkScalarToFixed(srcPt.fX);
-                       fy = SkScalarToFixed(srcPt.fY);
+        const SkBitmap& srcBitmap = this->getSrcBitmap();
+        unsigned        srcMaxX = srcBitmap.width() - 1;
+        unsigned        srcMaxY = srcBitmap.height() - 1;
+        unsigned        srcRB = srcBitmap.rowBytes();
+        SkFixed         fx, fy, dx, dy;
+
+        const NOFILTER_BITMAP_SHADER_TYPE* srcPixels = (const NOFILTER_BITMAP_SHADER_TYPE*)srcBitmap.getPixels();
+        NOFILTER_BITMAP_SHADER_PREAMBLE16(srcBitmap, srcRB);
+
+        if (this->getInverseClass() == kPerspective_MatrixClass)
+        {
+            SkPerspIter   iter(inv, SkIntToScalar(x), SkIntToScalar(y), count);
+            while ((count = iter.next()) != 0)
+            {
+                const SkFixed* srcXY = iter.getXY();
+
+                while (--count >= 0)
+                {
+                    fx = *srcXY++;
+                    fy = *srcXY++;
+                    unsigned x = NOFILTER_BITMAP_SHADER_TILEPROC(fx, srcMaxX);
+                    unsigned y = NOFILTER_BITMAP_SHADER_TILEPROC(fy, srcMaxY);
+                    *dstC++ = NOFILTER_BITMAP_SHADER_SAMPLE_XY16(srcPixels, x, y, srcRB);
+                }
+            }
+            return;
+        }
+
+        // now init fx, fy, dx, dy
+        {
+            SkPoint srcPt;
+            invProc(inv, SkIntToScalar(x), SkIntToScalar(y), &srcPt);
+
+            fx = SkScalarToFixed(srcPt.fX);
+            fy = SkScalarToFixed(srcPt.fY);
 #ifndef NOFILTER_BITMAP_SHADER_USE_UNITINVERSE
             fx += SK_Fixed1/2;
             fy += SK_Fixed1/2;
 #endif
 
-                       if (this->getInverseClass() == kFixedStepInX_MatrixClass)
-                               (void)inv.fixedStepInX(SkIntToScalar(y), &dx, &dy);
-                       else
-                       {
-                               dx = SkScalarToFixed(inv.getScaleX());
-                               dy = SkScalarToFixed(inv.getSkewY());
-                       }
-               }
-
-               const NOFILTER_BITMAP_SHADER_TYPE* srcPixels = (const NOFILTER_BITMAP_SHADER_TYPE*)srcBitmap.getPixels();
-               NOFILTER_BITMAP_SHADER_PREAMBLE16(srcBitmap, srcRB);
+            if (this->getInverseClass() == kFixedStepInX_MatrixClass)
+                (void)inv.fixedStepInX(SkIntToScalar(y), &dx, &dy);
+            else
+            {
+                dx = SkScalarToFixed(inv.getScaleX());
+                dy = SkScalarToFixed(inv.getSkewY());
+            }
+        }
 
 #if defined(SK_SUPPORT_MIPMAP) && !defined(NOFILTER_BITMAP_SHADER_USE_UNITINVERSE)
         {   int level = this->getMipLevel() >> 16;
@@ -183,49 +259,50 @@ public:
             fy >>= level;
             dx >>= level;
             dy >>= level;
-               }
+        }
 #endif
 
-               if (dy == 0)
-               {
-                       srcPixels = (const NOFILTER_BITMAP_SHADER_TYPE*)((const char*)srcPixels + NOFILTER_BITMAP_SHADER_TILEPROC(fy, srcMaxY) * srcRB);
-                       do {
-                               unsigned x = NOFILTER_BITMAP_SHADER_TILEPROC(fx, srcMaxX);
-                               fx += dx;
-                               *dstC++ = NOFILTER_BITMAP_SHADER_SAMPLE_X16(srcPixels, x);
-                       } while (--count != 0);
-               }
-               else    // dy != 0
-               {
-                       do {
-                               int ix = fx >> 16;
-                               unsigned x = NOFILTER_BITMAP_SHADER_TILEPROC(ix, srcMaxX);
-                               ix = fy >> 16;
-                               unsigned y = NOFILTER_BITMAP_SHADER_TILEPROC(ix, srcMaxY);
-                               fx += dx;
-                               fy += dy;
-                               *dstC++ = NOFILTER_BITMAP_SHADER_SAMPLE_XY16(srcPixels, x, y, srcRB);
-                       } while (--count != 0);
-               }
-
-               NOFILTER_BITMAP_SHADER_POSTAMBLE16(srcBitmap);
-       }
+        if (dy == 0)
+        {
+            srcPixels = (const NOFILTER_BITMAP_SHADER_TYPE*)((const char*)srcPixels + NOFILTER_BITMAP_SHADER_TILEPROC(fy, srcMaxY) * srcRB);
+            do {
+                unsigned x = NOFILTER_BITMAP_SHADER_TILEPROC(fx, srcMaxX);
+                fx += dx;
+                *dstC++ = NOFILTER_BITMAP_SHADER_SAMPLE_X16(srcPixels, x);
+            } while (--count != 0);
+        }
+        else    // dy != 0
+        {
+            do {
+                int ix = fx >> 16;
+                unsigned x = NOFILTER_BITMAP_SHADER_TILEPROC(ix, srcMaxX);
+                ix = fy >> 16;
+                unsigned y = NOFILTER_BITMAP_SHADER_TILEPROC(ix, srcMaxY);
+                fx += dx;
+                fy += dy;
+                *dstC++ = NOFILTER_BITMAP_SHADER_SAMPLE_XY16(srcPixels, x, y, srcRB);
+            } while (--count != 0);
+        }
+
+        NOFILTER_BITMAP_SHADER_POSTAMBLE16(srcBitmap);
+    }
 private:
-       typedef HasSpan16_Sampler_BitmapShader INHERITED;
+    typedef HasSpan16_Sampler_BitmapShader INHERITED;
 };
 
 #undef NOFILTER_BITMAP_SHADER_CLASS
 #undef NOFILTER_BITMAP_SHADER_TYPE
 #undef NOFILTER_BITMAP_SHADER_PREAMBLE
 #undef NOFILTER_BITMAP_SHADER_POSTAMBLE
-#undef NOFILTER_BITMAP_SHADER_SAMPLE_X         //(x)
-#undef NOFILTER_BITMAP_SHADER_SAMPLE_XY                //(x, y, rowBytes)
+#undef NOFILTER_BITMAP_SHADER_SAMPLE_X      //(x)
+#undef NOFILTER_BITMAP_SHADER_SAMPLE_XY     //(x, y, rowBytes)
 #undef NOFILTER_BITMAP_SHADER_TILEMODE
 #undef NOFILTER_BITMAP_SHADER_TILEPROC
 
 #undef NOFILTER_BITMAP_SHADER_PREAMBLE16
 #undef NOFILTER_BITMAP_SHADER_POSTAMBLE16
-#undef NOFILTER_BITMAP_SHADER_SAMPLE_X16               //(x)
-#undef NOFILTER_BITMAP_SHADER_SAMPLE_XY16              //(x, y, rowBytes)
+#undef NOFILTER_BITMAP_SHADER_SAMPLE_X16        //(x)
+#undef NOFILTER_BITMAP_SHADER_SAMPLE_XY16       //(x, y, rowBytes)
 
 #undef NOFILTER_BITMAP_SHADER_USE_UNITINVERSE
+#undef NOFILTER_BITMAP_SHADER_SPRITEPROC16
index 70530f1..786bc1c 100644 (file)
+/* libs/graphics/sgl/SkBlitBWMaskTemplate.h
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #include "SkBitmap.h"
 #include "SkMask.h"
 
 #ifndef ClearLow3Bits_DEFINED
 #define ClearLow3Bits_DEFINED
-       #define ClearLow3Bits(x)        ((unsigned)(x) >> 3 << 3)
+    #define ClearLow3Bits(x)    ((unsigned)(x) >> 3 << 3)
 #endif
 
 /*
-       SK_BLITBWMASK_NAME                      name of function(const SkBitmap& bitmap, const SkMask& mask, const SkRect16& clip, SK_BLITBWMASK_ARGS)
-       SK_BLITBWMASK_ARGS                      list of additional arguments to SK_BLITBWMASK_NAME, beginning with a comma
-       SK_BLITBWMASK_BLIT8                     name of function(U8CPU byteMask, SK_BLITBWMASK_DEVTYPE* dst, int x, int y)
-       SK_BLITBWMASK_GETADDR           either getAddr32 or getAddr16 or getAddr8
-       SK_BLITBWMASK_DEVTYPE           either U32 or U16 or U8
+    SK_BLITBWMASK_NAME          name of function(const SkBitmap& bitmap, const SkMask& mask, const SkRect16& clip, SK_BLITBWMASK_ARGS)
+    SK_BLITBWMASK_ARGS          list of additional arguments to SK_BLITBWMASK_NAME, beginning with a comma
+    SK_BLITBWMASK_BLIT8         name of function(U8CPU byteMask, SK_BLITBWMASK_DEVTYPE* dst, int x, int y)
+    SK_BLITBWMASK_GETADDR       either getAddr32 or getAddr16 or getAddr8
+    SK_BLITBWMASK_DEVTYPE       either U32 or U16 or U8
 */
 
 static void SK_BLITBWMASK_NAME(const SkBitmap& bitmap, const SkMask& srcMask, const SkRect16& clip SK_BLITBWMASK_ARGS)
 {
-       SkASSERT(clip.fRight <= srcMask.fBounds.fRight);
-
-       int cx = clip.fLeft;
-       int cy = clip.fTop;
-       int maskLeft = srcMask.fBounds.fLeft;
-       unsigned mask_rowBytes = srcMask.fRowBytes;
-       unsigned bitmap_rowBytes = bitmap.rowBytes();
-       unsigned height = clip.height();
-
-       SkASSERT(mask_rowBytes != 0);
-       SkASSERT(bitmap_rowBytes != 0);
-       SkASSERT(height != 0);
-
-       const U8* bits = srcMask.getAddr1(cx, cy);
-       SK_BLITBWMASK_DEVTYPE* device = bitmap.SK_BLITBWMASK_GETADDR(cx, cy);
-
-       if (cx == maskLeft && clip.fRight == srcMask.fBounds.fRight)
-       {
-               do {
-                       SK_BLITBWMASK_DEVTYPE* dst = device;
-                       unsigned rb = mask_rowBytes;
-                       do {
-                               U8CPU mask = *bits++;
-                               SK_BLITBWMASK_BLIT8(mask, dst);
-                               dst += 8;
-                       } while (--rb != 0);
-                       device = (SK_BLITBWMASK_DEVTYPE*)((char*)device + bitmap_rowBytes);
-               } while (--height != 0);
-       }
-       else
-       {
-               int left_edge = cx - maskLeft;
-               SkASSERT(left_edge >= 0);
-               int rite_edge = clip.fRight - maskLeft;
-               SkASSERT(rite_edge > left_edge);
-
-               int left_mask = 0xFF >> (left_edge & 7);
-               int rite_mask = 0xFF << (8 - (rite_edge & 7));
-               int full_runs = (rite_edge >> 3) - ((left_edge + 7) >> 3);
-
-               // check for empty right mask, so we don't read off the end (or go slower than we need to)
-               if (rite_mask == 0)
-               {
-                       SkASSERT(full_runs >= 0);
-                       full_runs -= 1;
-                       rite_mask = 0xFF;
-               }
-               if (left_mask == 0xFF)
-                       full_runs -= 1;
-
-               // back up manually so we can keep in sync with our byte-aligned src
-               // and not trigger an assert from the getAddr## function
-               device -= left_edge & 7;
-               // have cx reflect our actual starting x-coord
-               cx -= left_edge & 7;
-
-               if (full_runs < 0)
-               {
-                       left_mask &= rite_mask;
-                       SkASSERT(left_mask != 0);
-                       do {
-                               U8CPU mask = *bits & left_mask;
-                               SK_BLITBWMASK_BLIT8(mask, device);
-                               bits += mask_rowBytes;
-                               device = (SK_BLITBWMASK_DEVTYPE*)((char*)device + bitmap_rowBytes);
-                       } while (--height != 0);
-               }
-               else
-               {
-                       do {
-                               int runs = full_runs;
-                               SK_BLITBWMASK_DEVTYPE* dst = device;
-                               const U8* b = bits;
-                               U8CPU   mask;
-
-                               mask = *b++ & left_mask;
-                               SK_BLITBWMASK_BLIT8(mask, dst);
-                               dst += 8;
-
-                               while (--runs >= 0)
-                               {
-                                       mask = *b++;
-                                       SK_BLITBWMASK_BLIT8(mask, dst);
-                                       dst += 8;
-                               }
-
-                               mask = *b & rite_mask;
-                               SK_BLITBWMASK_BLIT8(mask, dst);
-
-                               bits += mask_rowBytes;
-                               device = (SK_BLITBWMASK_DEVTYPE*)((char*)device + bitmap_rowBytes);
-                       } while (--height != 0);
-               }
-       }
-}      
+    SkASSERT(clip.fRight <= srcMask.fBounds.fRight);
+
+    int cx = clip.fLeft;
+    int cy = clip.fTop;
+    int maskLeft = srcMask.fBounds.fLeft;
+    unsigned mask_rowBytes = srcMask.fRowBytes;
+    unsigned bitmap_rowBytes = bitmap.rowBytes();
+    unsigned height = clip.height();
+
+    SkASSERT(mask_rowBytes != 0);
+    SkASSERT(bitmap_rowBytes != 0);
+    SkASSERT(height != 0);
+
+    const U8* bits = srcMask.getAddr1(cx, cy);
+    SK_BLITBWMASK_DEVTYPE* device = bitmap.SK_BLITBWMASK_GETADDR(cx, cy);
+
+    if (cx == maskLeft && clip.fRight == srcMask.fBounds.fRight)
+    {
+        do {
+            SK_BLITBWMASK_DEVTYPE* dst = device;
+            unsigned rb = mask_rowBytes;
+            do {
+                U8CPU mask = *bits++;
+                SK_BLITBWMASK_BLIT8(mask, dst);
+                dst += 8;
+            } while (--rb != 0);
+            device = (SK_BLITBWMASK_DEVTYPE*)((char*)device + bitmap_rowBytes);
+        } while (--height != 0);
+    }
+    else
+    {
+        int left_edge = cx - maskLeft;
+        SkASSERT(left_edge >= 0);
+        int rite_edge = clip.fRight - maskLeft;
+        SkASSERT(rite_edge > left_edge);
+
+        int left_mask = 0xFF >> (left_edge & 7);
+        int rite_mask = 0xFF << (8 - (rite_edge & 7));
+        int full_runs = (rite_edge >> 3) - ((left_edge + 7) >> 3);
+
+        // check for empty right mask, so we don't read off the end (or go slower than we need to)
+        if (rite_mask == 0)
+        {
+            SkASSERT(full_runs >= 0);
+            full_runs -= 1;
+            rite_mask = 0xFF;
+        }
+        if (left_mask == 0xFF)
+            full_runs -= 1;
+
+        // back up manually so we can keep in sync with our byte-aligned src
+        // and not trigger an assert from the getAddr## function
+        device -= left_edge & 7;
+        // have cx reflect our actual starting x-coord
+        cx -= left_edge & 7;
+
+        if (full_runs < 0)
+        {
+            left_mask &= rite_mask;
+            SkASSERT(left_mask != 0);
+            do {
+                U8CPU mask = *bits & left_mask;
+                SK_BLITBWMASK_BLIT8(mask, device);
+                bits += mask_rowBytes;
+                device = (SK_BLITBWMASK_DEVTYPE*)((char*)device + bitmap_rowBytes);
+            } while (--height != 0);
+        }
+        else
+        {
+            do {
+                int runs = full_runs;
+                SK_BLITBWMASK_DEVTYPE* dst = device;
+                const U8* b = bits;
+                U8CPU   mask;
+
+                mask = *b++ & left_mask;
+                SK_BLITBWMASK_BLIT8(mask, dst);
+                dst += 8;
+
+                while (--runs >= 0)
+                {
+                    mask = *b++;
+                    SK_BLITBWMASK_BLIT8(mask, dst);
+                    dst += 8;
+                }
+
+                mask = *b & rite_mask;
+                SK_BLITBWMASK_BLIT8(mask, dst);
+
+                bits += mask_rowBytes;
+                device = (SK_BLITBWMASK_DEVTYPE*)((char*)device + bitmap_rowBytes);
+            } while (--height != 0);
+        }
+    }
+}   
 
 #undef SK_BLITBWMASK_NAME
 #undef SK_BLITBWMASK_ARGS
index 5dcac42..cd036d7 100644 (file)
@@ -1,3 +1,20 @@
+/* libs/graphics/sgl/SkBlitter.cpp
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #include "SkBlitter.h"
 #include "SkAntiRun.h"
 #include "SkColor.h"
@@ -14,164 +31,165 @@ SkBlitter::~SkBlitter()
 
 void SkBlitter::blitH(int x, int y, int width)
 {
-       SkASSERT(!"unimplemented");
+    SkASSERT(!"unimplemented");
 }
 
 void SkBlitter::blitAntiH(int x, int y, const SkAlpha antialias[], const int16_t runs[])
 {
-       SkASSERT(!"unimplemented");
+    SkASSERT(!"unimplemented");
 }
 
 void SkBlitter::blitV(int x, int y, int height, SkAlpha alpha)
 {
-       if (alpha == 255)
-               this->blitRect(x, y, 1, height);
-       else
-       {
-               int16_t runs[2];
-               runs[0] = 1;
-               runs[1] = 0;
-
-               while (--height >= 0)
-                       this->blitAntiH(x, y++, &alpha, runs);
-       }
+    if (alpha == 255)
+        this->blitRect(x, y, 1, height);
+    else
+    {
+        int16_t runs[2];
+        runs[0] = 1;
+        runs[1] = 0;
+
+        while (--height >= 0)
+            this->blitAntiH(x, y++, &alpha, runs);
+    }
 }
 
 void SkBlitter::blitRect(int x, int y, int width, int height)
 {
-       while (--height >= 0)
-               this->blitH(x, y++, width);
+    while (--height >= 0)
+        this->blitH(x, y++, width);
 }
 
 //////////////////////////////////////////////////////////////////////////////
 
-static inline void bits_to_runs(SkBlitter* blitter, int x, int y, const uint8_t bits[], U8CPU left_mask, int rowBytes, U8CPU right_mask)
+static inline void bits_to_runs(SkBlitter* blitter, int x, int y, const uint8_t bits[],
+                                U8CPU left_mask, int rowBytes, U8CPU right_mask)
 {
-       int     inFill = 0;
-       int pos = 0;
-
-       while (--rowBytes >= 0)
-       {
-               unsigned b = *bits++ & left_mask;
-               if (rowBytes == 0)
-                       b &= right_mask;
-
-               for (unsigned test = 0x80; test != 0; test >>= 1)
-               {
-                       if (b & test)
-                       {
-                               if (!inFill)
-                               {
-                                       pos = x;
-                                       inFill = true;
-                               }
-                       }
-                       else
-                       {
-                               if (inFill)
-                               {
-                                       blitter->blitH(pos, y, x - pos);
-                                       inFill = false;
-                               }
-                       }
-                       x += 1;
-               }
-               left_mask = 0xFF;
-       }
-
-       // final cleanup
-       if (inFill)
-               blitter->blitH(pos, y, x - pos);
+    int inFill = 0;
+    int pos = 0;
+
+    while (--rowBytes >= 0)
+    {
+        unsigned b = *bits++ & left_mask;
+        if (rowBytes == 0)
+            b &= right_mask;
+
+        for (unsigned test = 0x80; test != 0; test >>= 1)
+        {
+            if (b & test)
+            {
+                if (!inFill)
+                {
+                    pos = x;
+                    inFill = true;
+                }
+            }
+            else
+            {
+                if (inFill)
+                {
+                    blitter->blitH(pos, y, x - pos);
+                    inFill = false;
+                }
+            }
+            x += 1;
+        }
+        left_mask = 0xFF;
+    }
+
+    // final cleanup
+    if (inFill)
+        blitter->blitH(pos, y, x - pos);
 }
 
 void SkBlitter::blitMask(const SkMask& mask, const SkRect16& clip)
 {
-       SkASSERT(mask.fBounds.contains(clip));
-
-       if (mask.fFormat == SkMask::kBW_Format)
-       {
-               int cx = clip.fLeft;
-               int cy = clip.fTop;
-               int maskLeft = mask.fBounds.fLeft;
-               int mask_rowBytes = mask.fRowBytes;
-               int     height = clip.height();
-
-               const uint8_t* bits = mask.getAddr1(cx, cy);
-
-               if (cx == maskLeft && clip.fRight == mask.fBounds.fRight)
-               {
-                       while (--height >= 0)
-                       {
-                               bits_to_runs(this, cx, cy, bits, 0xFF, mask_rowBytes, 0xFF);
-                               bits += mask_rowBytes;
-                               cy += 1;
-                       }
-               }
-               else
-               {
-                       int left_edge = cx - maskLeft;
-                       SkASSERT(left_edge >= 0);
-                       int rite_edge = clip.fRight - maskLeft;
-                       SkASSERT(rite_edge > left_edge);
-
-                       int left_mask = 0xFF >> (left_edge & 7);
-                       int rite_mask = 0xFF << (8 - (rite_edge & 7));
-                       int full_runs = (rite_edge >> 3) - ((left_edge + 7) >> 3);
-
-                       // check for empty right mask, so we don't read off the end (or go slower than we need to)
-                       if (rite_mask == 0)
-                       {
-                               SkASSERT(full_runs >= 0);
-                               full_runs -= 1;
-                               rite_mask = 0xFF;
-                       }
-                       if (left_mask == 0xFF)
-                               full_runs -= 1;
-
-                       // back up manually so we can keep in sync with our byte-aligned src
-                       // have cx reflect our actual starting x-coord
-                       cx -= left_edge & 7;
-
-                       if (full_runs < 0)
-                       {
-                               SkASSERT((left_mask & rite_mask) != 0);
-                               while (--height >= 0)
-                               {
-                                       bits_to_runs(this, cx, cy, bits, left_mask, 1, rite_mask);
-                                       bits += mask_rowBytes;
-                                       cy += 1;
-                               }
-                       }
-                       else
-                       {
-                               while (--height >= 0)
-                               {
-                                       bits_to_runs(this, cx, cy, bits, left_mask, full_runs + 2, rite_mask);
-                                       bits += mask_rowBytes;
-                                       cy += 1;
-                               }
-                       }
-               }
-       }
-       else
-       {
-               int                         width =     clip.width();
-               SkAutoSTMalloc<64, int16_t>     runStorage(width + 1);
-               int16_t*                    runs = runStorage.get();
-               const uint8_t*              aa = mask.getAddr(clip.fLeft, clip.fTop);
-
-               sk_memset16((U16*)runs, 1, width);
-               runs[width] = 0;
-
-               int height = clip.height();
-               int y = clip.fTop;
-               while (--height >= 0)
-               {
-                       this->blitAntiH(clip.fLeft, y, aa, runs);
-                       aa += mask.fRowBytes;
-                       y += 1;
-               }
-       }
+    SkASSERT(mask.fBounds.contains(clip));
+
+    if (mask.fFormat == SkMask::kBW_Format)
+    {
+        int cx = clip.fLeft;
+        int cy = clip.fTop;
+        int maskLeft = mask.fBounds.fLeft;
+        int mask_rowBytes = mask.fRowBytes;
+        int height = clip.height();
+
+        const uint8_t* bits = mask.getAddr1(cx, cy);
+
+        if (cx == maskLeft && clip.fRight == mask.fBounds.fRight)
+        {
+            while (--height >= 0)
+            {
+                bits_to_runs(this, cx, cy, bits, 0xFF, mask_rowBytes, 0xFF);
+                bits += mask_rowBytes;
+                cy += 1;
+            }
+        }
+        else
+        {
+            int left_edge = cx - maskLeft;
+            SkASSERT(left_edge >= 0);
+            int rite_edge = clip.fRight - maskLeft;
+            SkASSERT(rite_edge > left_edge);
+
+            int left_mask = 0xFF >> (left_edge & 7);
+            int rite_mask = 0xFF << (8 - (rite_edge & 7));
+            int full_runs = (rite_edge >> 3) - ((left_edge + 7) >> 3);
+
+            // check for empty right mask, so we don't read off the end (or go slower than we need to)
+            if (rite_mask == 0)
+            {
+                SkASSERT(full_runs >= 0);
+                full_runs -= 1;
+                rite_mask = 0xFF;
+            }
+            if (left_mask == 0xFF)
+                full_runs -= 1;
+
+            // back up manually so we can keep in sync with our byte-aligned src
+            // have cx reflect our actual starting x-coord
+            cx -= left_edge & 7;
+
+            if (full_runs < 0)
+            {
+                SkASSERT((left_mask & rite_mask) != 0);
+                while (--height >= 0)
+                {
+                    bits_to_runs(this, cx, cy, bits, left_mask, 1, rite_mask);
+                    bits += mask_rowBytes;
+                    cy += 1;
+                }
+            }
+            else
+            {
+                while (--height >= 0)
+                {
+                    bits_to_runs(this, cx, cy, bits, left_mask, full_runs + 2, rite_mask);
+                    bits += mask_rowBytes;
+                    cy += 1;
+                }
+            }
+        }
+    }
+    else
+    {
+        int                         width = clip.width();
+        SkAutoSTMalloc<64, int16_t> runStorage(width + 1);
+        int16_t*                    runs = runStorage.get();
+        const uint8_t*              aa = mask.getAddr(clip.fLeft, clip.fTop);
+
+        sk_memset16((uint16_t*)runs, 1, width);
+        runs[width] = 0;
+
+        int height = clip.height();
+        int y = clip.fTop;
+        while (--height >= 0)
+        {
+            this->blitAntiH(clip.fLeft, y, aa, runs);
+            aa += mask.fRowBytes;
+            y += 1;
+        }
+    }
 }
 
 ///////////////////////////////////////////////////////////////////////////////////////
@@ -186,7 +204,7 @@ void SkBlitter::blitMaskRegion(const SkMask& mask, const SkRegion& clip)
 
     if (!clipper.done())
     {
-        const SkRect16&        cr = clipper.rect();
+        const SkRect16& cr = clipper.rect();
         do {
             this->blitMask(mask, cr);
             clipper.next();
@@ -198,21 +216,21 @@ void SkBlitter::blitMaskRegion(const SkMask& mask, const SkRegion& clip)
 
 static int compute_anti_width(const int16_t runs[])
 {
-       int     width = 0;
+    int width = 0;
 
-       for (;;)
-       {
-               int count = runs[0];
+    for (;;)
+    {
+        int count = runs[0];
 
-               SkASSERT(count >= 0);
-               if (count == 0)
-                       break;
-               width += count;
-               runs += count;
+        SkASSERT(count >= 0);
+        if (count == 0)
+            break;
+        width += count;
+        runs += count;
 
-               SkASSERT(width < 20000);
-       }
-       return width;
+        SkASSERT(width < 20000);
+    }
+    return width;
 }
 
 ///////////////////////////////////////////////////////////////////////////////////////
@@ -239,94 +257,94 @@ void SkNullBlitter::blitRect(int x, int y, int width, int height)
 
 static inline bool y_in_rect(int y, const SkRect16& rect)
 {
-       return (unsigned)(y - rect.fTop) < (unsigned)rect.height();
+    return (unsigned)(y - rect.fTop) < (unsigned)rect.height();
 }
 
 static inline bool x_in_rect(int x, const SkRect16& rect)
 {
-       return (unsigned)(x - rect.fLeft) < (unsigned)rect.width();
+    return (unsigned)(x - rect.fLeft) < (unsigned)rect.width();
 }
 
 void SkRectClipBlitter::blitH(int left, int y, int width)
 {
-       SkASSERT(width > 0);
+    SkASSERT(width > 0);
 
-       if (!y_in_rect(y, fClipRect))
-               return;
+    if (!y_in_rect(y, fClipRect))
+        return;
 
-       int     right = left + width;
+    int right = left + width;
 
-       if (left < fClipRect.fLeft)
-               left = fClipRect.fLeft;
-       if (right > fClipRect.fRight)
-               right = fClipRect.fRight;
+    if (left < fClipRect.fLeft)
+        left = fClipRect.fLeft;
+    if (right > fClipRect.fRight)
+        right = fClipRect.fRight;
 
-       width = right - left;
-       if (width > 0)
-               fBlitter->blitH(left, y, width);
+    width = right - left;
+    if (width > 0)
+        fBlitter->blitH(left, y, width);
 }
 
 void SkRectClipBlitter::blitAntiH(int left, int y, const SkAlpha aa[], const int16_t runs[])
 {
-       if (!y_in_rect(y, fClipRect) || left >= fClipRect.fRight)
-               return;
-
-       int x0 = left;
-       int     x1 = left + compute_anti_width(runs);
-
-       if (x1 <= fClipRect.fLeft)
-               return;
-
-       SkASSERT(x0 < x1);
-       if (x0 < fClipRect.fLeft)
-       {
-               int dx = fClipRect.fLeft - x0;
-               SkAlphaRuns::BreakAt((int16_t*)runs, (U8*)aa, dx);
-               runs += dx;
-               aa += dx;
-               x0 = fClipRect.fLeft;
-       }
-
-       SkASSERT(x0 < x1 && runs[x1 - x0] == 0);
-       if (x1 > fClipRect.fRight)
-       {
-               x1 = fClipRect.fRight;
-               SkAlphaRuns::BreakAt((int16_t*)runs, (U8*)aa, x1 - x0);
-               ((int16_t*)runs)[x1 - x0] = 0;
-       }
-
-       SkASSERT(x0 < x1 && runs[x1 - x0] == 0);
-       SkASSERT(compute_anti_width(runs) == x1 - x0);
-
-       fBlitter->blitAntiH(x0, y, aa, runs);
+    if (!y_in_rect(y, fClipRect) || left >= fClipRect.fRight)
+        return;
+
+    int x0 = left;
+    int x1 = left + compute_anti_width(runs);
+
+    if (x1 <= fClipRect.fLeft)
+        return;
+
+    SkASSERT(x0 < x1);
+    if (x0 < fClipRect.fLeft)
+    {
+        int dx = fClipRect.fLeft - x0;
+        SkAlphaRuns::BreakAt((int16_t*)runs, (uint8_t*)aa, dx);
+        runs += dx;
+        aa += dx;
+        x0 = fClipRect.fLeft;
+    }
+
+    SkASSERT(x0 < x1 && runs[x1 - x0] == 0);
+    if (x1 > fClipRect.fRight)
+    {
+        x1 = fClipRect.fRight;
+        SkAlphaRuns::BreakAt((int16_t*)runs, (uint8_t*)aa, x1 - x0);
+        ((int16_t*)runs)[x1 - x0] = 0;
+    }
+
+    SkASSERT(x0 < x1 && runs[x1 - x0] == 0);
+    SkASSERT(compute_anti_width(runs) == x1 - x0);
+
+    fBlitter->blitAntiH(x0, y, aa, runs);
 }
 
 void SkRectClipBlitter::blitV(int x, int y, int height, SkAlpha alpha)
 {
-       SkASSERT(height > 0);
+    SkASSERT(height > 0);
 
-       if (!x_in_rect(x, fClipRect))
-               return;
+    if (!x_in_rect(x, fClipRect))
+        return;
 
-       int     y0 = y;
-       int y1 = y + height;
+    int y0 = y;
+    int y1 = y + height;
 
-       if (y0 < fClipRect.fTop)
-               y0 = fClipRect.fTop;
-       if (y1 > fClipRect.fBottom)
-               y1 = fClipRect.fBottom;
+    if (y0 < fClipRect.fTop)
+        y0 = fClipRect.fTop;
+    if (y1 > fClipRect.fBottom)
+        y1 = fClipRect.fBottom;
 
-       if (y0 < y1)
-               fBlitter->blitV(x, y0, y1 - y0, alpha);
+    if (y0 < y1)
+        fBlitter->blitV(x, y0, y1 - y0, alpha);
 }
 
 void SkRectClipBlitter::blitRect(int left, int y, int width, int height)
 {
-       SkRect16        r;
+    SkRect16    r;
 
-       r.set(left, y, left + width, y + height);
-       if (r.intersect(fClipRect))
-               fBlitter->blitRect(r.fLeft, r.fTop, r.width(), r.height());
+    r.set(left, y, left + width, y + height);
+    if (r.intersect(fClipRect))
+        fBlitter->blitRect(r.fLeft, r.fTop, r.width(), r.height());
 }
 
 ///////////////////////////////////////////////////////////////////////////////////////
@@ -334,85 +352,85 @@ void SkRectClipBlitter::blitRect(int left, int y, int width, int height)
 
 void SkRgnClipBlitter::blitH(int x, int y, int width)
 {
-       SkRegion::Spanerator span(*fRgn, y, x, x + width);
-       int     left, right;
-
-       while (span.next(&left, &right))
-       {
-               SkASSERT(left < right);
-               fBlitter->blitH(left, y, right - left);
-       }
+    SkRegion::Spanerator span(*fRgn, y, x, x + width);
+    int left, right;
+
+    while (span.next(&left, &right))
+    {
+        SkASSERT(left < right);
+        fBlitter->blitH(left, y, right - left);
+    }
 }
 
 void SkRgnClipBlitter::blitAntiH(int x, int y, const SkAlpha aa[], const int16_t runs[])
 {
-       int width = compute_anti_width(runs);
-       SkRegion::Spanerator span(*fRgn, y, x, x + width);
-       int     left, right;
-       bool firstTime = true;
-       SkDEBUGCODE(const SkRect16& bounds = fRgn->getBounds();)
+    int width = compute_anti_width(runs);
+    SkRegion::Spanerator span(*fRgn, y, x, x + width);
+    int left, right;
+    bool firstTime = true;
+    SkDEBUGCODE(const SkRect16& bounds = fRgn->getBounds();)
 
 //SkDebugf("rgnClip: x=%d y=%d: ", x, y);
 
-       while (span.next(&left, &right))
-       {
-               SkASSERT(left < right);
-               SkASSERT(left >= bounds.fLeft && right <= bounds.fRight);
-               
-               if (firstTime && x < left)
-               {
+    while (span.next(&left, &right))
+    {
+        SkASSERT(left < right);
+        SkASSERT(left >= bounds.fLeft && right <= bounds.fRight);
+        
+        if (firstTime && x < left)
+        {
 //SkDebugf("zap[%d %d] ", x, left);
-                       SkAlphaRuns::Break((int16_t*)runs, (U8*)aa, 0, left - x);
-                       ((U8*)aa)[0] = 0;       // skip runs before the first left
-                       ((int16_t*)runs)[0] = SkToS16(left - x);
-               }
-               firstTime = false;
-
-               SkAlphaRuns::Break((int16_t*)runs, (U8*)aa, left - x, right - left);
-               ((U8*)aa)[right - x] = 0;       // skip runs after right
-               ((int16_t*)runs)[right - x] = SkToS16(right - left);
-               
+            SkAlphaRuns::Break((int16_t*)runs, (uint8_t*)aa, 0, left - x);
+            ((uint8_t*)aa)[0] = 0;   // skip runs before the first left
+            ((int16_t*)runs)[0] = SkToS16(left - x);
+        }
+        firstTime = false;
+
+        SkAlphaRuns::Break((int16_t*)runs, (uint8_t*)aa, left - x, right - left);
+        ((uint8_t*)aa)[right - x] = 0;   // skip runs after right
+        ((int16_t*)runs)[right - x] = SkToS16(right - left);
+        
 //SkDebugf("[%d %d] ", left, right);
-       }
-       ((int16_t*)runs)[right - x] = 0;
+    }
+    ((int16_t*)runs)[right - x] = 0;
 
 //dump_runs(runs, aa);
 
-       fBlitter->blitAntiH(x, y, aa, runs);
+    fBlitter->blitAntiH(x, y, aa, runs);
 }
 
 void SkRgnClipBlitter::blitV(int x, int y, int height, SkAlpha alpha)
 {
-       SkRect16        bounds;
-       bounds.set(x, y, x + 1, y + height);
+    SkRect16    bounds;
+    bounds.set(x, y, x + 1, y + height);
 
-       SkRegion::Cliperator    iter(*fRgn, bounds);
+    SkRegion::Cliperator    iter(*fRgn, bounds);
 
-       while (!iter.done())
-       {
-               const SkRect16& r = iter.rect();
-               SkASSERT(bounds.contains(r));
+    while (!iter.done())
+    {
+        const SkRect16& r = iter.rect();
+        SkASSERT(bounds.contains(r));
 
-               fBlitter->blitV(x, r.fTop, r.height(), alpha);
-               iter.next();
-       }
+        fBlitter->blitV(x, r.fTop, r.height(), alpha);
+        iter.next();
+    }
 }
 
 void SkRgnClipBlitter::blitRect(int x, int y, int width, int height)
 {
-       SkRect16        bounds;
-       bounds.set(x, y, x + width, y + height);
+    SkRect16    bounds;
+    bounds.set(x, y, x + width, y + height);
 
-       SkRegion::Cliperator    iter(*fRgn, bounds);
+    SkRegion::Cliperator    iter(*fRgn, bounds);
 
-       while (!iter.done())
-       {
-               const SkRect16& r = iter.rect();
-               SkASSERT(bounds.contains(r));
+    while (!iter.done())
+    {
+        const SkRect16& r = iter.rect();
+        SkASSERT(bounds.contains(r));
 
-               fBlitter->blitRect(r.fLeft, r.fTop, r.width(), r.height());
-               iter.next();
-       }
+        fBlitter->blitRect(r.fLeft, r.fTop, r.width(), r.height());
+        iter.next();
+    }
 }
 
 ///////////////////////////////////////////////////////////////////////////////////////
@@ -420,27 +438,27 @@ void SkRgnClipBlitter::blitRect(int x, int y, int width, int height)
 
 SkBlitter* SkBlitterClipper::apply(SkBlitter* blitter, const SkRegion* clip, const SkRect16* ir)
 {
-       if (clip)
-       {
-               const SkRect16& clipR = clip->getBounds();
-
-               if (clip->isEmpty() || ir && !SkRect16::Intersects(clipR, *ir))
-                       blitter = &fNullBlitter;
-               else if (clip->isRect())
-               {
-                       if (ir == nil || !clipR.contains(*ir))
-                       {
-                               fRectBlitter.init(blitter, clipR);
-                               blitter = &fRectBlitter;
-                       }
-               }
-               else
-               {
-                       fRgnBlitter.init(blitter, clip);
-                       blitter = &fRgnBlitter;
-               }
-       }
-       return blitter;
+    if (clip)
+    {
+        const SkRect16& clipR = clip->getBounds();
+
+        if (clip->isEmpty() || ir && !SkRect16::Intersects(clipR, *ir))
+            blitter = &fNullBlitter;
+        else if (clip->isRect())
+        {
+            if (ir == NULL || !clipR.contains(*ir))
+            {
+                fRectBlitter.init(blitter, clipR);
+                blitter = &fRectBlitter;
+            }
+        }
+        else
+        {
+            fRgnBlitter.init(blitter, clip);
+            blitter = &fRgnBlitter;
+        }
+    }
+    return blitter;
 }
 
 ///////////////////////////////////////////////////////////////////////////////////////
@@ -451,199 +469,204 @@ SkBlitter* SkBlitterClipper::apply(SkBlitter* blitter, const SkRegion* clip, con
 
 class SkColorShader : public SkShader {
 public:
-       virtual U32 getFlags()
-       {
-        // should I claim hasspan16 if my color isn't opaque?
-               return (SkGetPackedA32(fPMColor) == 255 ? kOpaqueAlpha_Flag : kConstAlpha_Flag) | kHasSpan16_Flag;
-       }
-       virtual bool setContext(const SkBitmap& device, const SkPaint& paint, const SkMatrix& matrix)
-       {
-               if (!this->INHERITED::setContext(device, paint, matrix))
-                       return false;
-
-               SkColor c = paint.getColor();
-               unsigned a = SkColorGetA(c);
-               unsigned r = SkColorGetR(c);
-               unsigned g = SkColorGetG(c);
-               unsigned b = SkColorGetB(c);
-
-               if (a != 255)
-               {
-                       a = SkAlpha255To256(a);
-                       r = SkAlphaMul(r, a);
-                       g = SkAlphaMul(g, a);
-                       b = SkAlphaMul(b, a);
-               }
-               fPMColor = SkPackARGB32(a, r, g, b);
-               fColor16 = SkPixel32ToPixel16_ToU16(fPMColor);  // only meaning full if a == 255
-               return true;
-       }
-       virtual void shadeSpan(int x, int y, SkPMColor span[], int count)
-       {
-               sk_memset32(span, fPMColor, count);
-       }
-       virtual void shadeSpanOpaque16(int x, int y, U16 span[], int count)
-       {
-               SkASSERT(SkGetPackedA32(fPMColor) == 255);
-               sk_memset16(span, fColor16, count);
-       }
+    virtual uint32_t getFlags()
+    {
+        return (SkGetPackedA32(fPMColor) == 255 ? kOpaqueAlpha_Flag : 0) | kHasSpan16_Flag;
+    }
+    virtual uint8_t getSpan16Alpha() const
+    {
+        return SkGetPackedA32(fPMColor);
+    }
+    virtual bool setContext(const SkBitmap& device, const SkPaint& paint, const SkMatrix& matrix)
+    {
+        if (!this->INHERITED::setContext(device, paint, matrix))
+            return false;
+
+        SkColor c = paint.getColor();
+        unsigned a = SkColorGetA(c);
+        unsigned r = SkColorGetR(c);
+        unsigned g = SkColorGetG(c);
+        unsigned b = SkColorGetB(c);
+
+        // we want this before we apply any alpha
+        fColor16 = SkPack888ToRGB16(r, g, b);
+
+        if (a != 255)
+        {
+            a = SkAlpha255To256(a);
+            r = SkAlphaMul(r, a);
+            g = SkAlphaMul(g, a);
+            b = SkAlphaMul(b, a);
+        }
+        fPMColor = SkPackARGB32(a, r, g, b);
+
+        return true;
+    }
+    virtual void shadeSpan(int x, int y, SkPMColor span[], int count)
+    {
+        sk_memset32(span, fPMColor, count);
+    }
+    virtual void shadeSpan16(int x, int y, uint16_t span[], int count)
+    {
+        sk_memset16(span, fColor16, count);
+    }
 private:
-       SkPMColor       fPMColor;
-       U16                     fColor16;
+    SkPMColor   fPMColor;
+    uint16_t    fColor16;
 
-       typedef SkShader INHERITED;
+    typedef SkShader INHERITED;
 };
 
 class Sk3DShader : public SkShader {
 public:
-       Sk3DShader(SkShader* proxy) : fProxy(proxy)
-       {
-               proxy->safeRef();
-               fMask = nil;
-       }
-       virtual ~Sk3DShader()
-       {
-               fProxy->safeUnref();
-       }
-       void setMask(const SkMask* mask) { fMask = mask; }
-
-       virtual bool setContext(const SkBitmap& device, const SkPaint& paint, const SkMatrix& matrix)
-       {
-               if (fProxy)
-                       return fProxy->setContext(device, paint, matrix);
-               else
-               {
-                       fPMColor = SkPreMultiplyColor(paint.getColor());
-                       return this->INHERITED::setContext(device, paint, matrix);
-               }
-       }
-       virtual void shadeSpan(int x, int y, SkPMColor span[], int count)
-       {
-               if (fProxy)
-                       fProxy->shadeSpan(x, y, span, count);
-
-               if (fMask == nil)
-               {
-                       if (fProxy == nil)
-                               sk_memset32(span, fPMColor, count);
-                       return;
-               }
-
-               SkASSERT(fMask->fBounds.contains(x, y));
-               SkASSERT(fMask->fBounds.contains(x + count - 1, y));
-
-               size_t          size = fMask->computeImageSize();
-               const U8*       alpha = fMask->getAddr(x, y);
-               const U8*       mulp = alpha + size;
-               const U8*       addp = mulp + size;
-
-               if (fProxy)
-               {
-                       for (int i = 0; i < count; i++)
-                       {
-                               if (alpha[i])
-                               {
-                                       U32     c = span[i];
-                                       if (c)
-                                       {
-                                               unsigned a = SkGetPackedA32(c);
-                                               unsigned r = SkGetPackedR32(c);
-                                               unsigned g = SkGetPackedG32(c);
-                                               unsigned b = SkGetPackedB32(c);
-
-                                               unsigned mul = SkAlpha255To256(mulp[i]);
-                                               unsigned add = addp[i];
-
-                                               r = SkFastMin32(SkAlphaMul(r, mul) + add, a);
-                                               g = SkFastMin32(SkAlphaMul(g, mul) + add, a);
-                                               b = SkFastMin32(SkAlphaMul(b, mul) + add, a);
-
-                                               span[i] = SkPackARGB32(a, r, g, b);
-                                       }
-                               }
-                               else
-                                       span[i] = 0;
-                       }
-               }
-               else    // color
-               {
-                       unsigned a = SkGetPackedA32(fPMColor);
-                       unsigned r = SkGetPackedR32(fPMColor);
-                       unsigned g = SkGetPackedG32(fPMColor);
-                       unsigned b = SkGetPackedB32(fPMColor);
-                       for (int i = 0; i < count; i++)
-                       {
-                               if (alpha[i])
-                               {
-                                       unsigned mul = SkAlpha255To256(mulp[i]);
-                                       unsigned add = addp[i];
-
-                                       span[i] = SkPackARGB32( a,
-                                                                                       SkFastMin32(SkAlphaMul(r, mul) + add, a),
-                                                                                       SkFastMin32(SkAlphaMul(g, mul) + add, a),
-                                                                                       SkFastMin32(SkAlphaMul(b, mul) + add, a));
-                               }
-                               else
-                                       span[i] = 0;
-                       }
-               }
-       }
+    Sk3DShader(SkShader* proxy) : fProxy(proxy)
+    {
+        proxy->safeRef();
+        fMask = NULL;
+    }
+    virtual ~Sk3DShader()
+    {
+        fProxy->safeUnref();
+    }
+    void setMask(const SkMask* mask) { fMask = mask; }
+
+    virtual bool setContext(const SkBitmap& device, const SkPaint& paint, const SkMatrix& matrix)
+    {
+        if (fProxy)
+            return fProxy->setContext(device, paint, matrix);
+        else
+        {
+            fPMColor = SkPreMultiplyColor(paint.getColor());
+            return this->INHERITED::setContext(device, paint, matrix);
+        }
+    }
+    virtual void shadeSpan(int x, int y, SkPMColor span[], int count)
+    {
+        if (fProxy)
+            fProxy->shadeSpan(x, y, span, count);
+
+        if (fMask == NULL)
+        {
+            if (fProxy == NULL)
+                sk_memset32(span, fPMColor, count);
+            return;
+        }
+
+        SkASSERT(fMask->fBounds.contains(x, y));
+        SkASSERT(fMask->fBounds.contains(x + count - 1, y));
+
+        size_t          size = fMask->computeImageSize();
+        const uint8_t*  alpha = fMask->getAddr(x, y);
+        const uint8_t*  mulp = alpha + size;
+        const uint8_t*  addp = mulp + size;
+
+        if (fProxy)
+        {
+            for (int i = 0; i < count; i++)
+            {
+                if (alpha[i])
+                {
+                    SkPMColor c = span[i];
+                    if (c)
+                    {
+                        unsigned a = SkGetPackedA32(c);
+                        unsigned r = SkGetPackedR32(c);
+                        unsigned g = SkGetPackedG32(c);
+                        unsigned b = SkGetPackedB32(c);
+
+                        unsigned mul = SkAlpha255To256(mulp[i]);
+                        unsigned add = addp[i];
+
+                        r = SkFastMin32(SkAlphaMul(r, mul) + add, a);
+                        g = SkFastMin32(SkAlphaMul(g, mul) + add, a);
+                        b = SkFastMin32(SkAlphaMul(b, mul) + add, a);
+
+                        span[i] = SkPackARGB32(a, r, g, b);
+                    }
+                }
+                else
+                    span[i] = 0;
+            }
+        }
+        else    // color
+        {
+            unsigned a = SkGetPackedA32(fPMColor);
+            unsigned r = SkGetPackedR32(fPMColor);
+            unsigned g = SkGetPackedG32(fPMColor);
+            unsigned b = SkGetPackedB32(fPMColor);
+            for (int i = 0; i < count; i++)
+            {
+                if (alpha[i])
+                {
+                    unsigned mul = SkAlpha255To256(mulp[i]);
+                    unsigned add = addp[i];
+
+                    span[i] = SkPackARGB32( a,
+                                            SkFastMin32(SkAlphaMul(r, mul) + add, a),
+                                            SkFastMin32(SkAlphaMul(g, mul) + add, a),
+                                            SkFastMin32(SkAlphaMul(b, mul) + add, a));
+                }
+                else
+                    span[i] = 0;
+            }
+        }
+    }
 private:
-       SkShader*               fProxy;
-       SkPMColor               fPMColor;
-       const SkMask*   fMask;
+    SkShader*       fProxy;
+    SkPMColor       fPMColor;
+    const SkMask*   fMask;
 
-       typedef SkShader INHERITED;
+    typedef SkShader INHERITED;
 };
 
 class Sk3DBlitter : public SkBlitter {
 public:
-       Sk3DBlitter(SkBlitter* proxy, Sk3DShader* shader, void (*killProc)(void*))
-               : fProxy(proxy), f3DShader(shader), fKillProc(killProc)
-       {
-               shader->ref();
-       }
-       virtual ~Sk3DBlitter()
-       {
-               f3DShader->unref();
-               fKillProc(fProxy);
-       }
-
-       virtual void blitH(int x, int y, int width)
-       {
-               fProxy->blitH(x, y, width);
-       }
-       virtual void blitAntiH(int x, int y, const SkAlpha antialias[], const int16_t runs[])
-       {
-               fProxy->blitAntiH(x, y, antialias, runs);
-       }
-       virtual void blitV(int x, int y, int height, SkAlpha alpha)
-       {
-               fProxy->blitV(x, y, height, alpha);
-       }
-       virtual void blitRect(int x, int y, int width, int height)
-       {
-               fProxy->blitRect(x, y, width, height);
-       }
-       virtual void blitMask(const SkMask& mask, const SkRect16& clip)
-       {
-               if (mask.fFormat == SkMask::k3D_Format)
-               {
-                       f3DShader->setMask(&mask);
-
-                       ((SkMask*)&mask)->fFormat = SkMask::kA8_Format;
-                       fProxy->blitMask(mask, clip);
-                       ((SkMask*)&mask)->fFormat = SkMask::k3D_Format;
-
-                       f3DShader->setMask(nil);
-               }
-               else
-                       fProxy->blitMask(mask, clip);
-       }
+    Sk3DBlitter(SkBlitter* proxy, Sk3DShader* shader, void (*killProc)(void*))
+        : fProxy(proxy), f3DShader(shader), fKillProc(killProc)
+    {
+        shader->ref();
+    }
+    virtual ~Sk3DBlitter()
+    {
+        f3DShader->unref();
+        fKillProc(fProxy);
+    }
+
+    virtual void blitH(int x, int y, int width)
+    {
+        fProxy->blitH(x, y, width);
+    }
+    virtual void blitAntiH(int x, int y, const SkAlpha antialias[], const int16_t runs[])
+    {
+        fProxy->blitAntiH(x, y, antialias, runs);
+    }
+    virtual void blitV(int x, int y, int height, SkAlpha alpha)
+    {
+        fProxy->blitV(x, y, height, alpha);
+    }
+    virtual void blitRect(int x, int y, int width, int height)
+    {
+        fProxy->blitRect(x, y, width, height);
+    }
+    virtual void blitMask(const SkMask& mask, const SkRect16& clip)
+    {
+        if (mask.fFormat == SkMask::k3D_Format)
+        {
+            f3DShader->setMask(&mask);
+
+            ((SkMask*)&mask)->fFormat = SkMask::kA8_Format;
+            fProxy->blitMask(mask, clip);
+            ((SkMask*)&mask)->fFormat = SkMask::k3D_Format;
+
+            f3DShader->setMask(NULL);
+        }
+        else
+            fProxy->blitMask(mask, clip);
+    }
 private:
-       SkBlitter*      fProxy;
-       Sk3DShader* f3DShader;
-       void            (*fKillProc)(void*);
+    SkBlitter*  fProxy;
+    Sk3DShader* f3DShader;
+    void        (*fKillProc)(void*);
 };
 
 ///////////////////////////////////////////////////////////////////////////////////////
@@ -653,81 +676,81 @@ private:
 
 class SkAutoRestoreShader {
 public:
-       SkAutoRestoreShader(const SkPaint& p) : fPaint((SkPaint*)&p)
-       {
-               fShader = fPaint->getShader();
-               fShader->safeRef();
-       }
-       ~SkAutoRestoreShader()
-       {
-               fPaint->setShader(fShader);
-               fShader->safeUnref();
-       }
+    SkAutoRestoreShader(const SkPaint& p) : fPaint((SkPaint*)&p)
+    {
+        fShader = fPaint->getShader();
+        fShader->safeRef();
+    }
+    ~SkAutoRestoreShader()
+    {
+        fPaint->setShader(fShader);
+        fShader->safeUnref();
+    }
 private:
-       SkPaint*        fPaint;
-       SkShader*       fShader;
+    SkPaint*    fPaint;
+    SkShader*   fShader;
 };
 
 class SkAutoCallProc {
 public:
-       typedef void (*Proc)(void*);
-       SkAutoCallProc(void* obj, Proc proc)
-               : fObj(obj), fProc(proc)
-       {
-       }
-       ~SkAutoCallProc()
-       {
-               if (fObj && fProc)
-                       fProc(fObj);
-       }
-       void* get() const { return fObj; }
-       void* detach()
-       {
-               void* obj = fObj;
-               fObj = nil;
-               return obj;
-       }
+    typedef void (*Proc)(void*);
+    SkAutoCallProc(void* obj, Proc proc)
+        : fObj(obj), fProc(proc)
+    {
+    }
+    ~SkAutoCallProc()
+    {
+        if (fObj && fProc)
+            fProc(fObj);
+    }
+    void* get() const { return fObj; }
+    void* detach()
+    {
+        void* obj = fObj;
+        fObj = NULL;
+        return obj;
+    }
 private:
-       void*   fObj;
-       Proc    fProc;
+    void*   fObj;
+    Proc    fProc;
 };
 
 static void destroy_blitter(void* blitter)
 {
-       ((SkBlitter*)blitter)->~SkBlitter();
+    ((SkBlitter*)blitter)->~SkBlitter();
 }
 
 static void delete_blitter(void* blitter)
 {
-       SkDELETE((SkBlitter*)blitter);
+    SkDELETE((SkBlitter*)blitter);
 }
 
 SkBlitter* SkBlitter::Choose(const SkBitmap& device,
-                                                        const SkMatrix& matrix,
-                                                        const SkPaint& paint,
-                                                        void* storage, size_t storageSize)
+                             const SkMatrix& matrix,
+                             const SkPaint& paint,
+                             void* storage, size_t storageSize)
 {
-       SkASSERT(storageSize == 0 || storage != nil);
-
-       SkBlitter*      blitter = nil;
-       SkAutoRestoreShader     restore(paint);
-       SkShader* shader = paint.getShader();
-
-       Sk3DShader* shader3D = nil;
-       if (paint.getMaskFilter() != nil && paint.getMaskFilter()->getFormat() == SkMask::k3D_Format)
-       {
-               shader3D = SkNEW_ARGS(Sk3DShader, (shader));
-               ((SkPaint*)&paint)->setShader(shader3D)->unref();
-               shader = shader3D;
-       }
-
-       SkXfermode* mode = paint.getXfermode();
-       if (NULL == shader && (NULL != mode || paint.getColorFilter() != NULL))
-       {
-               // xfermodes require shaders for our current set of blitters
-               shader = SkNEW(SkColorShader);
-               ((SkPaint*)&paint)->setShader(shader)->unref();
-       }
+    SkASSERT(storageSize == 0 || storage != NULL);
+
+    SkBlitter*  blitter = NULL;
+    SkAutoRestoreShader restore(paint);
+    SkShader* shader = paint.getShader();
+
+    Sk3DShader* shader3D = NULL;
+    if (paint.getMaskFilter() != NULL && paint.getMaskFilter()->getFormat() == SkMask::k3D_Format)
+    {
+        shader3D = SkNEW_ARGS(Sk3DShader, (shader));
+        ((SkPaint*)&paint)->setShader(shader3D)->unref();
+        shader = shader3D;
+    }
+
+    SkXfermode* mode = paint.getXfermode();
+    if (NULL == shader && (NULL != mode || paint.getColorFilter() != NULL))
+    {
+        // xfermodes require shaders for our current set of blitters
+        shader = SkNEW(SkColorShader);
+        ((SkPaint*)&paint)->setShader(shader)->unref();
+    }
     
     if (paint.getColorFilter() != NULL)
     {
@@ -736,60 +759,60 @@ SkBlitter* SkBlitter::Choose(const SkBitmap& device,
         ((SkPaint*)&paint)->setShader(shader)->unref();
     }
 
-       if (shader)
-       {
-               if (!shader->setContext(device, paint, matrix))
-                       return SkNEW(SkNullBlitter);
-       }
-
-       switch (device.getConfig()) {
-       case SkBitmap::kA1_Config:
-               SK_PLACEMENT_NEW_ARGS(blitter, SkA1_Blitter, storage, storageSize, (device, paint));
-               break;
-
-       case SkBitmap::kA8_Config:
-               if (shader)
-                       SK_PLACEMENT_NEW_ARGS(blitter, SkA8_Shader_Blitter, storage, storageSize, (device, paint));
-               else
-                       SK_PLACEMENT_NEW_ARGS(blitter, SkA8_Blitter, storage, storageSize, (device, paint));
-               break;
-
-       case SkBitmap::kRGB_565_Config:
-               if (shader)
-               {
-                       if (mode)
-                               SK_PLACEMENT_NEW_ARGS(blitter, SkRGB16_Shader_Xfermode_Blitter, storage, storageSize, (device, paint));
-                       else
-                               SK_PLACEMENT_NEW_ARGS(blitter, SkRGB16_Shader_Blitter, storage, storageSize, (device, paint));
-               }
-               else if (paint.getColor() == SK_ColorBLACK)
-                       SK_PLACEMENT_NEW_ARGS(blitter, SkRGB16_Black_Blitter, storage, storageSize, (device, paint));
-               else
-                       SK_PLACEMENT_NEW_ARGS(blitter, SkRGB16_Blitter, storage, storageSize, (device, paint));
-               break;
-
-       case SkBitmap::kARGB_8888_Config:
-               if (shader)
-                       SK_PLACEMENT_NEW_ARGS(blitter, SkARGB32_Shader_Blitter, storage, storageSize, (device, paint));
-               else if (paint.getColor() == SK_ColorBLACK)
-                       SK_PLACEMENT_NEW_ARGS(blitter, SkARGB32_Black_Blitter, storage, storageSize, (device, paint));
+    if (shader)
+    {
+        if (!shader->setContext(device, paint, matrix))
+            return SkNEW(SkNullBlitter);
+    }
+
+    switch (device.getConfig()) {
+    case SkBitmap::kA1_Config:
+        SK_PLACEMENT_NEW_ARGS(blitter, SkA1_Blitter, storage, storageSize, (device, paint));
+        break;
+
+    case SkBitmap::kA8_Config:
+        if (shader)
+            SK_PLACEMENT_NEW_ARGS(blitter, SkA8_Shader_Blitter, storage, storageSize, (device, paint));
+        else
+            SK_PLACEMENT_NEW_ARGS(blitter, SkA8_Blitter, storage, storageSize, (device, paint));
+        break;
+
+    case SkBitmap::kRGB_565_Config:
+        if (shader)
+        {
+            if (mode)
+                SK_PLACEMENT_NEW_ARGS(blitter, SkRGB16_Shader_Xfermode_Blitter, storage, storageSize, (device, paint));
+            else
+                SK_PLACEMENT_NEW_ARGS(blitter, SkRGB16_Shader_Blitter, storage, storageSize, (device, paint));
+        }
+        else if (paint.getColor() == SK_ColorBLACK)
+            SK_PLACEMENT_NEW_ARGS(blitter, SkRGB16_Black_Blitter, storage, storageSize, (device, paint));
+        else
+            SK_PLACEMENT_NEW_ARGS(blitter, SkRGB16_Blitter, storage, storageSize, (device, paint));
+        break;
+
+    case SkBitmap::kARGB_8888_Config:
+        if (shader)
+            SK_PLACEMENT_NEW_ARGS(blitter, SkARGB32_Shader_Blitter, storage, storageSize, (device, paint));
+        else if (paint.getColor() == SK_ColorBLACK)
+            SK_PLACEMENT_NEW_ARGS(blitter, SkARGB32_Black_Blitter, storage, storageSize, (device, paint));
         else
-                       SK_PLACEMENT_NEW_ARGS(blitter, SkARGB32_Blitter, storage, storageSize, (device, paint));
-               break;
-
-       default:
-               SkASSERT(!"unsupported device config");
-               SK_PLACEMENT_NEW(blitter, SkNullBlitter, storage, storageSize);
-       }
-
-       if (shader3D)
-       {
-               void (*proc)(void*) = ((void*)storage == (void*)blitter) ? destroy_blitter : delete_blitter;
-               SkAutoCallProc  tmp(blitter, proc);
-
-               blitter = SkNEW_ARGS(Sk3DBlitter, (blitter, shader3D, proc));
-               (void)tmp.detach();
-       }
-       return blitter;
+            SK_PLACEMENT_NEW_ARGS(blitter, SkARGB32_Blitter, storage, storageSize, (device, paint));
+        break;
+
+    default:
+        SkASSERT(!"unsupported device config");
+        SK_PLACEMENT_NEW(blitter, SkNullBlitter, storage, storageSize);
+    }
+
+    if (shader3D)
+    {
+        void (*proc)(void*) = ((void*)storage == (void*)blitter) ? destroy_blitter : delete_blitter;
+        SkAutoCallProc  tmp(blitter, proc);
+
+        blitter = SkNEW_ARGS(Sk3DBlitter, (blitter, shader3D, proc));
+        (void)tmp.detach();
+    }
+    return blitter;
 }
 
index 2031efa..091400c 100644 (file)
@@ -1,3 +1,20 @@
+/* libs/graphics/sgl/SkBlitter.h
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #ifndef SkBlitter_DEFINED
 #define SkBlitter_DEFINED
 
 
 class SkBlitter {
 public:
-       virtual ~SkBlitter();
-       virtual void    blitH(int x, int y, int width);
-       virtual void    blitAntiH(int x, int y, const SkAlpha antialias[], const S16 runs[]);
-       virtual void    blitV(int x, int y, int height, SkAlpha alpha);
-       virtual void    blitRect(int x, int y, int width, int height);
-       virtual void    blitMask(const SkMask&, const SkRect16& clip);
+    virtual ~SkBlitter();
+    virtual void    blitH(int x, int y, int width);
+    virtual void    blitAntiH(int x, int y, const SkAlpha antialias[], const S16 runs[]);
+    virtual void    blitV(int x, int y, int height, SkAlpha alpha);
+    virtual void    blitRect(int x, int y, int width, int height);
+    virtual void    blitMask(const SkMask&, const SkRect16& clip);
 
     // not virtual, just a helper
     void blitMaskRegion(const SkMask& mask, const SkRegion& clip);
 
-       static SkBlitter* Choose(const SkBitmap& device,
-                                                        const SkMatrix& matrix,
-                                                        const SkPaint& paint)
-       {
-               return Choose(device, matrix, paint, nil, 0);
-       }
+    static SkBlitter* Choose(const SkBitmap& device,
+                             const SkMatrix& matrix,
+                             const SkPaint& paint)
+    {
+        return Choose(device, matrix, paint, nil, 0);
+    }
 
-       static SkBlitter* Choose(const SkBitmap& device,
-                                                        const SkMatrix& matrix,
-                                                        const SkPaint& paint,
-                                                        void* storage, size_t storageSize);
+    static SkBlitter* Choose(const SkBitmap& device,
+                             const SkMatrix& matrix,
+                             const SkPaint& paint,
+                             void* storage, size_t storageSize);
 
-       static SkBlitter* ChooseSprite(const SkBitmap& device,
-                                                        const SkPaint&,
-                                                        const SkBitmap& src,
-                                                        int left, int top,
-                                                        void* storage, size_t storageSize);
+    static SkBlitter* ChooseSprite(const SkBitmap& device,
+                             const SkPaint&,
+                             const SkBitmap& src,
+                             int left, int top,
+                             void* storage, size_t storageSize);
 
 private:
 };
 
 class SkNullBlitter : public SkBlitter {
 public:
-       virtual void    blitH(int x, int y, int width);
-       virtual void    blitAntiH(int x, int y, const SkAlpha antialias[], const S16 runs[]);
-       virtual void    blitV(int x, int y, int height, SkAlpha alpha);
-       virtual void    blitRect(int x, int y, int width, int height);
+    virtual void    blitH(int x, int y, int width);
+    virtual void    blitAntiH(int x, int y, const SkAlpha antialias[], const S16 runs[]);
+    virtual void    blitV(int x, int y, int height, SkAlpha alpha);
+    virtual void    blitRect(int x, int y, int width, int height);
 };
 
 class SkRectClipBlitter : public SkBlitter {
 public:
-       void init(SkBlitter* blitter, const SkRect16& clipRect)
-       {
-               SkASSERT(!clipRect.isEmpty());
-               fBlitter = blitter;
-               fClipRect = clipRect;
-       }
-
-       // overrides
-       virtual void    blitH(int x, int y, int width);
-       virtual void    blitAntiH(int x, int y, const SkAlpha antialias[], const S16 runs[]);
-       virtual void    blitV(int x, int y, int height, SkAlpha alpha);
-       virtual void    blitRect(int x, int y, int width, int height);
+    void init(SkBlitter* blitter, const SkRect16& clipRect)
+    {
+        SkASSERT(!clipRect.isEmpty());
+        fBlitter = blitter;
+        fClipRect = clipRect;
+    }
+
+    // overrides
+    virtual void    blitH(int x, int y, int width);
+    virtual void    blitAntiH(int x, int y, const SkAlpha antialias[], const S16 runs[]);
+    virtual void    blitV(int x, int y, int height, SkAlpha alpha);
+    virtual void    blitRect(int x, int y, int width, int height);
 
 private:
-       SkBlitter*      fBlitter;
-       SkRect16        fClipRect;
+    SkBlitter*  fBlitter;
+    SkRect16    fClipRect;
 };
 
 class SkRgnClipBlitter : public SkBlitter {
 public:
-       void init(SkBlitter* blitter, const SkRegion* rgn)
-       {
-               SkASSERT(rgn && !rgn->isEmpty());
-               fBlitter = blitter;
-               fRgn = rgn;
-       }
-
-       // overrides
-       virtual void    blitH(int x, int y, int width);
-       virtual void    blitAntiH(int x, int y, const SkAlpha antialias[], const S16 runs[]);
-       virtual void    blitV(int x, int y, int height, SkAlpha alpha);
-       virtual void    blitRect(int x, int y, int width, int height);
+    void init(SkBlitter* blitter, const SkRegion* rgn)
+    {
+        SkASSERT(rgn && !rgn->isEmpty());
+        fBlitter = blitter;
+        fRgn = rgn;
+    }
+
+    // overrides
+    virtual void    blitH(int x, int y, int width);
+    virtual void    blitAntiH(int x, int y, const SkAlpha antialias[], const S16 runs[]);
+    virtual void    blitV(int x, int y, int height, SkAlpha alpha);
+    virtual void    blitRect(int x, int y, int width, int height);
 
 private:
-       SkBlitter*              fBlitter;
-       const SkRegion* fRgn;
+    SkBlitter*      fBlitter;
+    const SkRegion* fRgn;
 };
 
 class SkBlitterClipper {
 public:
-       SkBlitter*      apply(SkBlitter* blitter, const SkRegion* clip, const SkRect16* bounds = nil);
+    SkBlitter*  apply(SkBlitter* blitter, const SkRegion* clip, const SkRect16* bounds = nil);
 
 private:
-       SkNullBlitter           fNullBlitter;
-       SkRectClipBlitter       fRectBlitter;
-       SkRgnClipBlitter        fRgnBlitter;
+    SkNullBlitter       fNullBlitter;
+    SkRectClipBlitter   fRectBlitter;
+    SkRgnClipBlitter    fRgnBlitter;
 };
 
 #endif
index 38e0e4f..3724e36 100644 (file)
@@ -1,46 +1,63 @@
+/* libs/graphics/sgl/SkBlitter_A1.cpp
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #include "SkCoreBlitters.h"
 
 SkA1_Blitter::SkA1_Blitter(const SkBitmap& device, const SkPaint& paint)
-       : fDevice(device)
+    : fDevice(device)
 {
-       fSrcA = SkToU8(SkColorGetA(paint.getColor()));
+    fSrcA = SkToU8(SkColorGetA(paint.getColor()));
 }
 
 void SkA1_Blitter::blitH(int x, int y, int width)
 {
-       SkASSERT(x >= 0 && y >= 0 && (unsigned)(x + width) <= fDevice.width());
-
-       if (fSrcA <= 0x7F)
-               return;
-
-       U8* dst = fDevice.getAddr1(x, y);
-       int     right = x + width;
-
-       int left_mask = 0xFF >> (x & 7);
-       int rite_mask = 0xFF << (8 - (right & 7));
-       int full_runs = (right >> 3) - ((x + 7) >> 3);
-
-       // check for empty right mask, so we don't read off the end (or go slower than we need to)
-       if (rite_mask == 0)
-       {
-               SkASSERT(full_runs >= 0);
-               full_runs -= 1;
-               rite_mask = 0xFF;
-       }
-       if (left_mask == 0xFF)
-               full_runs -= 1;
-
-       if (full_runs < 0)
-       {
-               SkASSERT((left_mask & rite_mask) != 0);
-               *dst |= (left_mask & rite_mask);
-       }
-       else
-       {
-               *dst++ |= left_mask;
-               memset(dst, 0xFF, full_runs);
-               dst += full_runs;
-               *dst |= rite_mask;
-       }
+    SkASSERT(x >= 0 && y >= 0 && (unsigned)(x + width) <= (unsigned)fDevice.width());
+
+    if (fSrcA <= 0x7F)
+        return;
+
+    U8* dst = fDevice.getAddr1(x, y);
+    int right = x + width;
+
+    int left_mask = 0xFF >> (x & 7);
+    int rite_mask = 0xFF << (8 - (right & 7));
+    int full_runs = (right >> 3) - ((x + 7) >> 3);
+
+    // check for empty right mask, so we don't read off the end (or go slower than we need to)
+    if (rite_mask == 0)
+    {
+        SkASSERT(full_runs >= 0);
+        full_runs -= 1;
+        rite_mask = 0xFF;
+    }
+    if (left_mask == 0xFF)
+        full_runs -= 1;
+
+    if (full_runs < 0)
+    {
+        SkASSERT((left_mask & rite_mask) != 0);
+        *dst |= (left_mask & rite_mask);
+    }
+    else
+    {
+        *dst++ |= left_mask;
+        memset(dst, 0xFF, full_runs);
+        dst += full_runs;
+        *dst |= rite_mask;
+    }
 }
 
index bb94050..47d8a3e 100644 (file)
@@ -1,3 +1,20 @@
+/* libs/graphics/sgl/SkBlitter_A8.cpp
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #include "SkCoreBlitters.h"
 #include "SkColorPriv.h"
 #include "SkShader.h"
 
 SkA8_Blitter::SkA8_Blitter(const SkBitmap& device, const SkPaint& paint) : fDevice(device)
 {
-       fSrcA = SkColorGetA(paint.getColor());
+    fSrcA = SkColorGetA(paint.getColor());
 }
 
 void SkA8_Blitter::blitH(int x, int y, int width)
 {
-       SkASSERT(x >= 0 && y >= 0 && (unsigned)(x + width) <= fDevice.width());
-
-       if (fSrcA == 0)
-               return;
-
-       uint8_t* device = fDevice.getAddr8(x, y);
-
-       if (fSrcA == 255)
-       {
-               memset(device, 0xFF, width);
-       }
-       else
-       {
-               unsigned scale = 256 - SkAlpha255To256(fSrcA);
-               unsigned srcA = fSrcA;
-
-               for (int i = 0; i < width; i++)
-               {
-                       device[i] = SkToU8(srcA + SkAlphaMul(device[i], scale));
-               }
-       }
+    SkASSERT(x >= 0 && y >= 0 && (unsigned)(x + width) <= (unsigned)fDevice.width());
+
+    if (fSrcA == 0)
+        return;
+
+    uint8_t* device = fDevice.getAddr8(x, y);
+
+    if (fSrcA == 255)
+    {
+        memset(device, 0xFF, width);
+    }
+    else
+    {
+        unsigned scale = 256 - SkAlpha255To256(fSrcA);
+        unsigned srcA = fSrcA;
+
+        for (int i = 0; i < width; i++)
+        {
+            device[i] = SkToU8(srcA + SkAlphaMul(device[i], scale));
+        }
+    }
 }
 
 void SkA8_Blitter::blitAntiH(int x, int y, const SkAlpha antialias[], const S16 runs[])
 {
-       if (fSrcA == 0)
-               return;
-
-       uint8_t*        device = fDevice.getAddr8(x, y);
-       unsigned        srcA = fSrcA;
-
-       for (;;)
-       {
-               int count = runs[0];
-               SkASSERT(count >= 0);
-               if (count == 0)
-                       return;
-               unsigned aa = antialias[0];
-
-               if (aa == 255 && srcA == 255)
-                       memset(device, 0xFF, count);
-               else
-               {
-                       unsigned sa = SkAlphaMul(srcA, SkAlpha255To256(aa));
-                       unsigned scale = 256 - sa;
-
-                       for (int i = 0; i < count; i++)
-                       {
-                               device[i] = SkToU8(sa + SkAlphaMul(device[i], scale));
-                       }
-               }
-               runs += count;
-               antialias += count;
-               device += count;
-       }
+    if (fSrcA == 0)
+        return;
+
+    uint8_t*    device = fDevice.getAddr8(x, y);
+    unsigned    srcA = fSrcA;
+
+    for (;;)
+    {
+        int count = runs[0];
+        SkASSERT(count >= 0);
+        if (count == 0)
+            return;
+        unsigned aa = antialias[0];
+
+        if (aa == 255 && srcA == 255)
+            memset(device, 0xFF, count);
+        else
+        {
+            unsigned sa = SkAlphaMul(srcA, SkAlpha255To256(aa));
+            unsigned scale = 256 - sa;
+
+            for (int i = 0; i < count; i++)
+            {
+                device[i] = SkToU8(sa + SkAlphaMul(device[i], scale));
+            }
+        }
+        runs += count;
+        antialias += count;
+        device += count;
+    }
 }
 
 /////////////////////////////////////////////////////////////////////////////////////
 
-#define solid_8_pixels(mask, dst)                      \
-       do {                                                                    \
-               if (mask & 0x80) dst[0] = 0xFF;         \
-               if (mask & 0x40) dst[1] = 0xFF;         \
-               if (mask & 0x20) dst[2] = 0xFF;         \
-               if (mask & 0x10) dst[3] = 0xFF;         \
-               if (mask & 0x08) dst[4] = 0xFF;         \
-               if (mask & 0x04) dst[5] = 0xFF;         \
-               if (mask & 0x02) dst[6] = 0xFF;         \
-               if (mask & 0x01) dst[7] = 0xFF;         \
-       } while (0)
-
-#define        SK_BLITBWMASK_NAME                                      SkA8_BlitBW
-#define SK_BLITBWMASK_ARGS                                     
-#define SK_BLITBWMASK_BLIT8(mask, dst)         solid_8_pixels(mask, dst)
-#define SK_BLITBWMASK_GETADDR                          getAddr8
-#define SK_BLITBWMASK_DEVTYPE                          uint8_t
+#define solid_8_pixels(mask, dst)           \
+    do {                                    \
+        if (mask & 0x80) dst[0] = 0xFF;     \
+        if (mask & 0x40) dst[1] = 0xFF;     \
+        if (mask & 0x20) dst[2] = 0xFF;     \
+        if (mask & 0x10) dst[3] = 0xFF;     \
+        if (mask & 0x08) dst[4] = 0xFF;     \
+        if (mask & 0x04) dst[5] = 0xFF;     \
+        if (mask & 0x02) dst[6] = 0xFF;     \
+        if (mask & 0x01) dst[7] = 0xFF;     \
+    } while (0)
+
+#define SK_BLITBWMASK_NAME                  SkA8_BlitBW
+#define SK_BLITBWMASK_ARGS                  
+#define SK_BLITBWMASK_BLIT8(mask, dst)      solid_8_pixels(mask, dst)
+#define SK_BLITBWMASK_GETADDR               getAddr8
+#define SK_BLITBWMASK_DEVTYPE               uint8_t
 #include "SkBlitBWMaskTemplate.h"
 
 static inline void blend_8_pixels(U8CPU bw, uint8_t dst[], U8CPU sa, unsigned dst_scale)
 {
-       if (bw & 0x80) dst[0] = SkToU8(sa + SkAlphaMul(dst[0], dst_scale));
-       if (bw & 0x40) dst[1] = SkToU8(sa + SkAlphaMul(dst[1], dst_scale));
-       if (bw & 0x20) dst[2] = SkToU8(sa + SkAlphaMul(dst[2], dst_scale));
-       if (bw & 0x10) dst[3] = SkToU8(sa + SkAlphaMul(dst[3], dst_scale));
-       if (bw & 0x08) dst[4] = SkToU8(sa + SkAlphaMul(dst[4], dst_scale));
-       if (bw & 0x04) dst[5] = SkToU8(sa + SkAlphaMul(dst[5], dst_scale));
-       if (bw & 0x02) dst[6] = SkToU8(sa + SkAlphaMul(dst[6], dst_scale));
-       if (bw & 0x01) dst[7] = SkToU8(sa + SkAlphaMul(dst[7], dst_scale));
+    if (bw & 0x80) dst[0] = SkToU8(sa + SkAlphaMul(dst[0], dst_scale));
+    if (bw & 0x40) dst[1] = SkToU8(sa + SkAlphaMul(dst[1], dst_scale));
+    if (bw & 0x20) dst[2] = SkToU8(sa + SkAlphaMul(dst[2], dst_scale));
+    if (bw & 0x10) dst[3] = SkToU8(sa + SkAlphaMul(dst[3], dst_scale));
+    if (bw & 0x08) dst[4] = SkToU8(sa + SkAlphaMul(dst[4], dst_scale));
+    if (bw & 0x04) dst[5] = SkToU8(sa + SkAlphaMul(dst[5], dst_scale));
+    if (bw & 0x02) dst[6] = SkToU8(sa + SkAlphaMul(dst[6], dst_scale));
+    if (bw & 0x01) dst[7] = SkToU8(sa + SkAlphaMul(dst[7], dst_scale));
 }
 
-#define        SK_BLITBWMASK_NAME                                      SkA8_BlendBW
-#define SK_BLITBWMASK_ARGS                                     , U8CPU sa, unsigned dst_scale
-#define SK_BLITBWMASK_BLIT8(mask, dst)         blend_8_pixels(mask, dst, sa, dst_scale)
-#define SK_BLITBWMASK_GETADDR                          getAddr8
-#define SK_BLITBWMASK_DEVTYPE                          uint8_t
+#define SK_BLITBWMASK_NAME                  SkA8_BlendBW
+#define SK_BLITBWMASK_ARGS                  , U8CPU sa, unsigned dst_scale
+#define SK_BLITBWMASK_BLIT8(mask, dst)      blend_8_pixels(mask, dst, sa, dst_scale)
+#define SK_BLITBWMASK_GETADDR               getAddr8
+#define SK_BLITBWMASK_DEVTYPE               uint8_t
 #include "SkBlitBWMaskTemplate.h"
 
 void SkA8_Blitter::blitMask(const SkMask& mask, const SkRect16& clip)
 {
-       if (fSrcA == 0)
-               return;
-
-       if (mask.fFormat == SkMask::kBW_Format)
-       {
-               if (fSrcA == 0xFF)
-                       SkA8_BlitBW(fDevice, mask, clip);
-               else
-                       SkA8_BlendBW(fDevice, mask, clip, fSrcA, SkAlpha255To256(255 - fSrcA));
-               return;
-       }
-
-       int     x = clip.fLeft;
-       int y = clip.fTop;
-       int width = clip.width();
-       int height = clip.height();
-       uint8_t* device = fDevice.getAddr8(x, y);
-       const uint8_t* alpha = mask.getAddr(x, y);
-       unsigned        srcA = fSrcA;
-
-       while (--height >= 0)
-       {
-               for (int i = width - 1; i >= 0; --i)
-               {
-                       unsigned sa;
-                       // scale our src by the alpha value
-                       {
-                               int aa = alpha[i];
-                               if (aa == 0)
-                                       continue;
-
-                               if (aa == 255)
-                               {
-                                       if (srcA == 255)
-                                       {
-                                               device[i] = 0xFF;
-                                               continue;
-                                       }
-                                       sa = srcA;
-                               }
-                               else
-                                       sa = SkAlphaMul(srcA, SkAlpha255To256(aa));
-                       }
-
-                       int scale = 256 - SkAlpha255To256(sa);
-                       device[i] = SkToU8(sa + SkAlphaMul(device[i], scale));
-               }
-               device += fDevice.rowBytes();
-               alpha += mask.fRowBytes;
-       }
+    if (fSrcA == 0)
+        return;
+
+    if (mask.fFormat == SkMask::kBW_Format)
+    {
+        if (fSrcA == 0xFF)
+            SkA8_BlitBW(fDevice, mask, clip);
+        else
+            SkA8_BlendBW(fDevice, mask, clip, fSrcA, SkAlpha255To256(255 - fSrcA));
+        return;
+    }
+
+    int x = clip.fLeft;
+    int y = clip.fTop;
+    int width = clip.width();
+    int height = clip.height();
+    uint8_t* device = fDevice.getAddr8(x, y);
+    const uint8_t* alpha = mask.getAddr(x, y);
+    unsigned    srcA = fSrcA;
+
+    while (--height >= 0)
+    {
+        for (int i = width - 1; i >= 0; --i)
+        {
+            unsigned sa;
+            // scale our src by the alpha value
+            {
+                int aa = alpha[i];
+                if (aa == 0)
+                    continue;
+
+                if (aa == 255)
+                {
+                    if (srcA == 255)
+                    {
+                        device[i] = 0xFF;
+                        continue;
+                    }
+                    sa = srcA;
+                }
+                else
+                    sa = SkAlphaMul(srcA, SkAlpha255To256(aa));
+            }
+
+            int scale = 256 - SkAlpha255To256(sa);
+            device[i] = SkToU8(sa + SkAlphaMul(device[i], scale));
+        }
+        device += fDevice.rowBytes();
+        alpha += mask.fRowBytes;
+    }
 }
 
 ///////////////////////////////////////////////////////////////////////////////////////
 
 void SkA8_Blitter::blitV(int x, int y, int height, SkAlpha alpha)
 {
-       if (fSrcA == 0)
-               return;
-
-       unsigned sa = SkAlphaMul(fSrcA, SkAlpha255To256(alpha));
-       uint8_t* device = fDevice.getAddr8(x, y);
-       int              rowBytes = fDevice.rowBytes();
-
-       if (sa == 0xFF)
-       {
-               for (int i = 0; i < height; i++)
-               {
-                       *device = SkToU8(sa);
-                       device += rowBytes;
-               }
-       }
-       else
-       {
-               unsigned scale = 256 - SkAlpha255To256(sa);
-
-               for (int i = 0; i < height; i++)
-               {
-                       *device = SkToU8(sa + SkAlphaMul(*device, scale));
-                       device += rowBytes;
-               }
-       }
+    if (fSrcA == 0)
+        return;
+
+    unsigned sa = SkAlphaMul(fSrcA, SkAlpha255To256(alpha));
+    uint8_t* device = fDevice.getAddr8(x, y);
+    int      rowBytes = fDevice.rowBytes();
+
+    if (sa == 0xFF)
+    {
+        for (int i = 0; i < height; i++)
+        {
+            *device = SkToU8(sa);
+            device += rowBytes;
+        }
+    }
+    else
+    {
+        unsigned scale = 256 - SkAlpha255To256(sa);
+
+        for (int i = 0; i < height; i++)
+        {
+            *device = SkToU8(sa + SkAlphaMul(*device, scale));
+            device += rowBytes;
+        }
+    }
 }
 
 void SkA8_Blitter::blitRect(int x, int y, int width, int height)
 {
-       SkASSERT(x >= 0 && y >= 0 && (unsigned)(x + width) <= fDevice.width() && (unsigned)(y + height) <= fDevice.height());
-
-       if (fSrcA == 0)
-               return;
-
-       uint8_t*        device = fDevice.getAddr8(x, y);
-       unsigned        srcA = fSrcA;
-
-       if (srcA == 255)
-       {
-               while (--height >= 0)
-               {
-                       memset(device, 0xFF, width);
-                       device += fDevice.rowBytes();
-               }
-       }
-       else
-       {
-               unsigned scale = 256 - SkAlpha255To256(srcA);
-
-               while (--height >= 0)
-               {
-                       for (int i = 0; i < width; i++)
-                       {
-                               device[i] = SkToU8(srcA + SkAlphaMul(device[i], scale));
-                       }
-                       device += fDevice.rowBytes();
-               }
-       }
+    SkASSERT(x >= 0 && y >= 0 && (unsigned)(x + width) <= (unsigned)fDevice.width() && (unsigned)(y + height) <= (unsigned)fDevice.height());
+
+    if (fSrcA == 0)
+        return;
+
+    uint8_t*    device = fDevice.getAddr8(x, y);
+    unsigned    srcA = fSrcA;
+
+    if (srcA == 255)
+    {
+        while (--height >= 0)
+        {
+            memset(device, 0xFF, width);
+            device += fDevice.rowBytes();
+        }
+    }
+    else
+    {
+        unsigned scale = 256 - SkAlpha255To256(srcA);
+
+        while (--height >= 0)
+        {
+            for (int i = 0; i < width; i++)
+            {
+                device[i] = SkToU8(srcA + SkAlphaMul(device[i], scale));
+            }
+            device += fDevice.rowBytes();
+        }
+    }
 }
 
 ///////////////////////////////////////////////////////////////////////
 
 SkA8_Shader_Blitter::SkA8_Shader_Blitter(const SkBitmap& device, const SkPaint& paint) : fDevice(device)
 {
-       fShader = paint.getShader();
-       SkASSERT(fShader);
-       fShader->ref();
-
-       if ((fXfermode = paint.getXfermode()) != NULL)
-       {
-               fXfermode->ref();
-               SkASSERT(fShader);
-       }
-
-       int width = device.width();
-       fBuffer = (SkPMColor*)sk_malloc_throw(sizeof(SkPMColor) * (width + (SkAlign4(width) >> 2)));
-       fAAExpand = (uint8_t*)(fBuffer + width);
+    fShader = paint.getShader();
+    SkASSERT(fShader);
+    fShader->ref();
+
+    if ((fXfermode = paint.getXfermode()) != NULL)
+    {
+        fXfermode->ref();
+        SkASSERT(fShader);
+    }
+
+    int width = device.width();
+    fBuffer = (SkPMColor*)sk_malloc_throw(sizeof(SkPMColor) * (width + (SkAlign4(width) >> 2)));
+    fAAExpand = (uint8_t*)(fBuffer + width);
 }
 
 SkA8_Shader_Blitter::~SkA8_Shader_Blitter()
 {
-       fXfermode->safeUnref();
-       fShader->unref();
-       sk_free(fBuffer);
+    fXfermode->safeUnref();
+    fShader->unref();
+    sk_free(fBuffer);
 }
 
 void SkA8_Shader_Blitter::blitH(int x, int y, int width)
 {
-       SkASSERT(x >= 0 && y >= 0 && (unsigned)(x + width) <= fDevice.width());
-
-       uint8_t* device = fDevice.getAddr8(x, y);
-
-       if ((fShader->getFlags() & SkShader::kOpaqueAlpha_Flag) && fXfermode == NULL)
-       {
-               memset(device, 0xFF, width);
-       }
-       else
-       {
-               SkPMColor*      span = fBuffer;
-
-               fShader->shadeSpan(x, y, span, width);
-               if (fXfermode)
-                       fXfermode->xferA8(device, span, width, NULL);
-               else
-               {
-                       for (int i = width - 1; i >= 0; --i)
-                       {
-                               unsigned        srcA = SkGetPackedA32(span[i]);
-                               unsigned        scale = 256 - SkAlpha255To256(srcA);
-
-                               device[i] = SkToU8(srcA + SkAlphaMul(device[i], scale));
-                       }
-               }
-       }
+    SkASSERT(x >= 0 && y >= 0 && (unsigned)(x + width) <= (unsigned)fDevice.width());
+
+    uint8_t* device = fDevice.getAddr8(x, y);
+
+    if ((fShader->getFlags() & SkShader::kOpaqueAlpha_Flag) && fXfermode == NULL)
+    {
+        memset(device, 0xFF, width);
+    }
+    else
+    {
+        SkPMColor*  span = fBuffer;
+
+        fShader->shadeSpan(x, y, span, width);
+        if (fXfermode)
+            fXfermode->xferA8(device, span, width, NULL);
+        else
+        {
+            for (int i = width - 1; i >= 0; --i)
+            {
+                unsigned    srcA = SkGetPackedA32(span[i]);
+                unsigned    scale = 256 - SkAlpha255To256(srcA);
+
+                device[i] = SkToU8(srcA + SkAlphaMul(device[i], scale));
+            }
+        }
+    }
 }
 
 static inline uint8_t aa_blend8(U32 src, U8CPU da, int aa)
 {
-       SkASSERT((unsigned)aa <= 255);
+    SkASSERT((unsigned)aa <= 255);
 
-       int src_scale = SkAlpha255To256(aa);
-       int     sa = SkGetPackedA32(src);
-       int dst_scale = 256 - SkAlphaMul(sa, src_scale);
+    int src_scale = SkAlpha255To256(aa);
+    int sa = SkGetPackedA32(src);
+    int dst_scale = 256 - SkAlphaMul(sa, src_scale);
 
-       return SkToU8((sa * src_scale + da * dst_scale) >> 8);
+    return SkToU8((sa * src_scale + da * dst_scale) >> 8);
 }
 
 void SkA8_Shader_Blitter::blitAntiH(int x, int y, const SkAlpha antialias[], const S16 runs[])
 {
-       SkASSERT(x >= 0 && y >= 0 && x < (int)fDevice.width() && y < (int)fDevice.height());
-
-       SkShader*       shader = fShader;
-       SkXfermode*     mode = fXfermode;
-       uint8_t*        aaExpand = fAAExpand;
-       SkPMColor*      span = fBuffer;
-       uint8_t*        device = fDevice.getAddr8(x, y);
-       int                     opaque = fShader->getFlags() & SkShader::kOpaqueAlpha_Flag;
-
-       for (;;)
-       {
-               int     count = *runs;
-               if (count == 0)
-                       break;
-               int     aa = *antialias;
-               if (aa)
-               {
-                       if (opaque && aa == 255 && mode == NULL)
-                               memset(device, 0xFF, count);
-                       else
-                       {
-                               shader->shadeSpan(x, y, span, count);
-                               if (mode)
-                               {
-                                       memset(aaExpand, aa, count);
-                                       mode->xferA8(device, span, count, aaExpand);
-                               }
-                               else
-                               {
-                                       for (int i = count - 1; i >= 0; --i)
-                                               device[i] = aa_blend8(span[i], device[i], aa);
-                               }
-                       }
-               }
-               device += count;
-               runs += count;
-               antialias += count;
-               x += count;
-       } 
+    SkShader*   shader = fShader;
+    SkXfermode* mode = fXfermode;
+    uint8_t*    aaExpand = fAAExpand;
+    SkPMColor*  span = fBuffer;
+    uint8_t*    device = fDevice.getAddr8(x, y);
+    int         opaque = fShader->getFlags() & SkShader::kOpaqueAlpha_Flag;
+
+    for (;;)
+    {
+        int count = *runs;
+        if (count == 0)
+            break;
+        int aa = *antialias;
+        if (aa)
+        {
+            if (opaque && aa == 255 && mode == NULL)
+                memset(device, 0xFF, count);
+            else
+            {
+                shader->shadeSpan(x, y, span, count);
+                if (mode)
+                {
+                    memset(aaExpand, aa, count);
+                    mode->xferA8(device, span, count, aaExpand);
+                }
+                else
+                {
+                    for (int i = count - 1; i >= 0; --i)
+                        device[i] = aa_blend8(span[i], device[i], aa);
+                }
+            }
+        }
+        device += count;
+        runs += count;
+        antialias += count;
+        x += count;
+    } 
 }
 
 void SkA8_Shader_Blitter::blitMask(const SkMask& mask, const SkRect16& clip)
@@ -343,23 +358,23 @@ void SkA8_Shader_Blitter::blitMask(const SkMask& mask, const SkRect16& clip)
         return;
     }
     
-       int     x = clip.fLeft;
-       int y = clip.fTop;
-       int width = clip.width();
-       int height = clip.height();
-       uint8_t* device = fDevice.getAddr8(x, y);
-       const uint8_t* alpha = mask.getAddr(x, y);
+    int x = clip.fLeft;
+    int y = clip.fTop;
+    int width = clip.width();
+    int height = clip.height();
+    uint8_t* device = fDevice.getAddr8(x, y);
+    const uint8_t* alpha = mask.getAddr(x, y);
 
-       SkPMColor*      span = fBuffer;
+    SkPMColor*  span = fBuffer;
 
-       while (--height >= 0)
-       {
+    while (--height >= 0)
+    {
         fShader->shadeSpan(x, y, span, width);
         fXfermode->xferA8(device, span, width, alpha);
         
         y += 1;
-               device += fDevice.rowBytes();
-               alpha += mask.fRowBytes;
-       }
+        device += fDevice.rowBytes();
+        alpha += mask.fRowBytes;
+    }
 }
 
index 66ff505..38e1144 100644 (file)
@@ -1,3 +1,20 @@
+/* libs/graphics/sgl/SkBlitter_ARGB32.cpp
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #include "SkCoreBlitters.h"
 #include "SkColorPriv.h"
 #include "SkShader.h"
 
 SkARGB32_Blitter::SkARGB32_Blitter(const SkBitmap& device, const SkPaint& paint) : fDevice(device)
 {
-       uint32_t color = paint.getColor();
+    uint32_t color = paint.getColor();
 
-       fSrcA = SkColorGetA(color);
-       unsigned scale = SkAlpha255To256(fSrcA);
-       fSrcR = SkAlphaMul(SkColorGetR(color), scale);
-       fSrcG = SkAlphaMul(SkColorGetG(color), scale);
-       fSrcB = SkAlphaMul(SkColorGetB(color), scale);
+    fSrcA = SkColorGetA(color);
+    unsigned scale = SkAlpha255To256(fSrcA);
+    fSrcR = SkAlphaMul(SkColorGetR(color), scale);
+    fSrcG = SkAlphaMul(SkColorGetG(color), scale);
+    fSrcB = SkAlphaMul(SkColorGetB(color), scale);
 
-       fPMColor = SkPackARGB32(fSrcA, fSrcR, fSrcG, fSrcB);
+    fPMColor = SkPackARGB32(fSrcA, fSrcR, fSrcG, fSrcB);
 }
 
-#if defined _WIN32 && _MSC_VER >= 1300 // disable warning : local variable used without having been initialized
+#if defined _WIN32 && _MSC_VER >= 1300  // disable warning : local variable used without having been initialized
 #pragma warning ( push )
 #pragma warning ( disable : 4701 )
 #endif
 
 void SkARGB32_Blitter::blitH(int x, int y, int width)
 {
-       SkASSERT(x >= 0 && y >= 0 && (unsigned)(x + width) <= fDevice.width());
-
-       if (fSrcA == 0)
-               return;
-
-       uint32_t* device = fDevice.getAddr32(x, y);
-
-       if (fSrcA == 255)
-       {
-               sk_memset32(device, fPMColor, width);
-       }
-       else
-       {
-               uint32_t color = fPMColor;
-               unsigned dst_scale = SkAlpha255To256(255 - fSrcA);
-               uint32_t prevDst = ~device[0];  // so we always fail the test the first time
-               uint32_t result SK_INIT_TO_AVOID_WARNING;
-
-               for (int i = 0; i < width; i++)
-               {
-                       uint32_t currDst = device[i];
-                       if (currDst != prevDst)
-                       {
-                               result = color + SkAlphaMulQ(currDst, dst_scale);
-                               prevDst = currDst;
-                       }
-                       device[i] = result;
-               }
-       }
+    SkASSERT(x >= 0 && y >= 0 && x + width <= fDevice.width());
+
+    if (fSrcA == 0)
+        return;
+
+    uint32_t* device = fDevice.getAddr32(x, y);
+
+    if (fSrcA == 255)
+    {
+        sk_memset32(device, fPMColor, width);
+    }
+    else
+    {
+        uint32_t color = fPMColor;
+        unsigned dst_scale = SkAlpha255To256(255 - fSrcA);
+        uint32_t prevDst = ~device[0];  // so we always fail the test the first time
+        uint32_t result SK_INIT_TO_AVOID_WARNING;
+
+        for (int i = 0; i < width; i++)
+        {
+            uint32_t currDst = device[i];
+            if (currDst != prevDst)
+            {
+                result = color + SkAlphaMulQ(currDst, dst_scale);
+                prevDst = currDst;
+            }
+            device[i] = result;
+        }
+    }
 }
 
 void SkARGB32_Blitter::blitAntiH(int x, int y, const SkAlpha antialias[], const S16 runs[])
 {
-       if (fSrcA == 0)
-               return;
+    if (fSrcA == 0)
+        return;
 
-       uint32_t        color = fPMColor;
-       uint32_t*       device = fDevice.getAddr32(x, y);
+    uint32_t    color = fPMColor;
+    uint32_t*   device = fDevice.getAddr32(x, y);
     unsigned    opaqueMask = fSrcA; // if fSrcA is 0xFF, then we will catch the fast opaque case
 
     for (;;)
@@ -93,170 +110,170 @@ void SkARGB32_Blitter::blitAntiH(int x, int y, const SkAlpha antialias[], const
 
 //////////////////////////////////////////////////////////////////////////////////////
 
-#define solid_8_pixels(mask, dst, color)       \
-       do {                                                                    \
-               if (mask & 0x80) dst[0] = color;        \
-               if (mask & 0x40) dst[1] = color;        \
-               if (mask & 0x20) dst[2] = color;        \
-               if (mask & 0x10) dst[3] = color;        \
-               if (mask & 0x08) dst[4] = color;        \
-               if (mask & 0x04) dst[5] = color;        \
-               if (mask & 0x02) dst[6] = color;        \
-               if (mask & 0x01) dst[7] = color;        \
-       } while (0)
-
-#define        SK_BLITBWMASK_NAME                                      SkARGB32_BlitBW
-#define SK_BLITBWMASK_ARGS                                     , SkPMColor color
-#define SK_BLITBWMASK_BLIT8(mask, dst)         solid_8_pixels(mask, dst, color)
-#define SK_BLITBWMASK_GETADDR                          getAddr32
-#define SK_BLITBWMASK_DEVTYPE                          uint32_t
+#define solid_8_pixels(mask, dst, color)    \
+    do {                                    \
+        if (mask & 0x80) dst[0] = color;    \
+        if (mask & 0x40) dst[1] = color;    \
+        if (mask & 0x20) dst[2] = color;    \
+        if (mask & 0x10) dst[3] = color;    \
+        if (mask & 0x08) dst[4] = color;    \
+        if (mask & 0x04) dst[5] = color;    \
+        if (mask & 0x02) dst[6] = color;    \
+        if (mask & 0x01) dst[7] = color;    \
+    } while (0)
+
+#define SK_BLITBWMASK_NAME                  SkARGB32_BlitBW
+#define SK_BLITBWMASK_ARGS                  , SkPMColor color
+#define SK_BLITBWMASK_BLIT8(mask, dst)      solid_8_pixels(mask, dst, color)
+#define SK_BLITBWMASK_GETADDR               getAddr32
+#define SK_BLITBWMASK_DEVTYPE               uint32_t
 #include "SkBlitBWMaskTemplate.h"
 
-#define blend_8_pixels(mask, dst, sc, dst_scale)                                                       \
-       do {                                                                                                                                    \
-               if (mask & 0x80) { dst[0] = sc + SkAlphaMulQ(dst[0], dst_scale); }      \
-               if (mask & 0x40) { dst[1] = sc + SkAlphaMulQ(dst[1], dst_scale); }      \
-               if (mask & 0x20) { dst[2] = sc + SkAlphaMulQ(dst[2], dst_scale); }      \
-               if (mask & 0x10) { dst[3] = sc + SkAlphaMulQ(dst[3], dst_scale); }      \
-               if (mask & 0x08) { dst[4] = sc + SkAlphaMulQ(dst[4], dst_scale); }      \
-               if (mask & 0x04) { dst[5] = sc + SkAlphaMulQ(dst[5], dst_scale); }      \
-               if (mask & 0x02) { dst[6] = sc + SkAlphaMulQ(dst[6], dst_scale); }      \
-               if (mask & 0x01) { dst[7] = sc + SkAlphaMulQ(dst[7], dst_scale); }      \
-       } while (0)
-
-#define        SK_BLITBWMASK_NAME                                      SkARGB32_BlendBW
-#define SK_BLITBWMASK_ARGS                                     , uint32_t sc, unsigned dst_scale
-#define SK_BLITBWMASK_BLIT8(mask, dst)         blend_8_pixels(mask, dst, sc, dst_scale)
-#define SK_BLITBWMASK_GETADDR                          getAddr32
-#define SK_BLITBWMASK_DEVTYPE                          uint32_t
+#define blend_8_pixels(mask, dst, sc, dst_scale)                            \
+    do {                                                                    \
+        if (mask & 0x80) { dst[0] = sc + SkAlphaMulQ(dst[0], dst_scale); }  \
+        if (mask & 0x40) { dst[1] = sc + SkAlphaMulQ(dst[1], dst_scale); }  \
+        if (mask & 0x20) { dst[2] = sc + SkAlphaMulQ(dst[2], dst_scale); }  \
+        if (mask & 0x10) { dst[3] = sc + SkAlphaMulQ(dst[3], dst_scale); }  \
+        if (mask & 0x08) { dst[4] = sc + SkAlphaMulQ(dst[4], dst_scale); }  \
+        if (mask & 0x04) { dst[5] = sc + SkAlphaMulQ(dst[5], dst_scale); }  \
+        if (mask & 0x02) { dst[6] = sc + SkAlphaMulQ(dst[6], dst_scale); }  \
+        if (mask & 0x01) { dst[7] = sc + SkAlphaMulQ(dst[7], dst_scale); }  \
+    } while (0)
+
+#define SK_BLITBWMASK_NAME                  SkARGB32_BlendBW
+#define SK_BLITBWMASK_ARGS                  , uint32_t sc, unsigned dst_scale
+#define SK_BLITBWMASK_BLIT8(mask, dst)      blend_8_pixels(mask, dst, sc, dst_scale)
+#define SK_BLITBWMASK_GETADDR               getAddr32
+#define SK_BLITBWMASK_DEVTYPE               uint32_t
 #include "SkBlitBWMaskTemplate.h"
 
 void SkARGB32_Blitter::blitMask(const SkMask& mask, const SkRect16& clip)
 {
-       SkASSERT(mask.fBounds.contains(clip));
-
-       if (fSrcA == 0)
-               return;
-
-       if (mask.fFormat == SkMask::kBW_Format)
-       {
-               if (fSrcA == 0xFF)
-                       SkARGB32_BlitBW(fDevice, mask, clip, fPMColor);
-               else
-                       SkARGB32_BlendBW(fDevice, mask, clip, fPMColor, SkAlpha255To256(255 - fSrcA));
-               return;
-       }
-
-       int     x = clip.fLeft;
-       int y = clip.fTop;
-       int width = clip.width();
-       int height = clip.height();
-
-       uint32_t*       device = fDevice.getAddr32(x, y);
-       const uint8_t*  alpha = mask.getAddr(x, y);
-       uint32_t        srcColor = fPMColor;
-
-       while (--height >= 0)
-       {
-               for (int i = width - 1; i >= 0; --i)
-               {
-                       uint32_t color = srcColor;
-
-                       // scale our src by the alpha value
-                       {
-                               int aa = alpha[i];
-                               if (aa == 0)
-                                       continue;
-
-                               if (aa == 255)
-                               {
-                                       if (fSrcA == 255)
-                                       {
-                                               device[i] = color;
-                                               continue;
-                                       }
-                               }
-                               else
-                                       color = SkAlphaMulQ(color, SkAlpha255To256(aa));
-                       }
-                       device[i] = SkPMSrcOver(color, device[i]);
-               }
-               device = (uint32_t*)((char*)device + fDevice.rowBytes());
-               alpha += mask.fRowBytes;
-       }
+    SkASSERT(mask.fBounds.contains(clip));
+
+    if (fSrcA == 0)
+        return;
+
+    if (mask.fFormat == SkMask::kBW_Format)
+    {
+        if (fSrcA == 0xFF)
+            SkARGB32_BlitBW(fDevice, mask, clip, fPMColor);
+        else
+            SkARGB32_BlendBW(fDevice, mask, clip, fPMColor, SkAlpha255To256(255 - fSrcA));
+        return;
+    }
+
+    int x = clip.fLeft;
+    int y = clip.fTop;
+    int width = clip.width();
+    int height = clip.height();
+
+    uint32_t*       device = fDevice.getAddr32(x, y);
+    const uint8_t*  alpha = mask.getAddr(x, y);
+    uint32_t        srcColor = fPMColor;
+
+    while (--height >= 0)
+    {
+        for (int i = width - 1; i >= 0; --i)
+        {
+            uint32_t color = srcColor;
+
+            // scale our src by the alpha value
+            {
+                int aa = alpha[i];
+                if (aa == 0)
+                    continue;
+
+                if (aa == 255)
+                {
+                    if (fSrcA == 255)
+                    {
+                        device[i] = color;
+                        continue;
+                    }
+                }
+                else
+                    color = SkAlphaMulQ(color, SkAlpha255To256(aa));
+            }
+            device[i] = SkPMSrcOver(color, device[i]);
+        }
+        device = (uint32_t*)((char*)device + fDevice.rowBytes());
+        alpha += mask.fRowBytes;
+    }
 }
 
 //////////////////////////////////////////////////////////////////////////////////////
 
 void SkARGB32_Blitter::blitV(int x, int y, int height, SkAlpha alpha)
 {
-       if (alpha == 0 || fSrcA == 0)
-               return;
-
-       uint32_t* device = fDevice.getAddr32(x, y);
-       uint32_t  color = fPMColor;
-
-       if (alpha != 255)
-               color = SkAlphaMulQ(color, SkAlpha255To256(alpha));
-
-       unsigned dst_scale = 255 - SkGetPackedA32(color);
-       uint32_t prevDst = ~device[0];
-       uint32_t result  SK_INIT_TO_AVOID_WARNING;
-       uint32_t rowBytes = fDevice.rowBytes();
-
-       while (--height >= 0)
-       {
-               uint32_t dst = device[0];
-               if (dst != prevDst)
-               {
-                       result = color + SkAlphaMulQ(dst, dst_scale);
-                       prevDst = dst;
-               }
-               device[0] = result;
-               device = (uint32_t*)((char*)device + rowBytes);
-       }
+    if (alpha == 0 || fSrcA == 0)
+        return;
+
+    uint32_t* device = fDevice.getAddr32(x, y);
+    uint32_t  color = fPMColor;
+
+    if (alpha != 255)
+        color = SkAlphaMulQ(color, SkAlpha255To256(alpha));
+
+    unsigned dst_scale = 255 - SkGetPackedA32(color);
+    uint32_t prevDst = ~device[0];
+    uint32_t result  SK_INIT_TO_AVOID_WARNING;
+    uint32_t rowBytes = fDevice.rowBytes();
+
+    while (--height >= 0)
+    {
+        uint32_t dst = device[0];
+        if (dst != prevDst)
+        {
+            result = color + SkAlphaMulQ(dst, dst_scale);
+            prevDst = dst;
+        }
+        device[0] = result;
+        device = (uint32_t*)((char*)device + rowBytes);
+    }
 }
 
 void SkARGB32_Blitter::blitRect(int x, int y, int width, int height)
 {
-       SkASSERT(x >= 0 && y >= 0 && (unsigned)(x + width) <= fDevice.width() && (unsigned)(y + height) <= fDevice.height());
-
-       if (fSrcA == 0)
-               return;
-
-       uint32_t*       device = fDevice.getAddr32(x, y);
-       uint32_t        color = fPMColor;
-
-       if (fSrcA == 255)
-       {
-               while (--height >= 0)
-               {
-                       sk_memset32(device, color, width);
-                       device = (uint32_t*)((char*)device + fDevice.rowBytes());
-               }
-       }
-       else
-       {
-               unsigned dst_scale = SkAlpha255To256(255 - fSrcA);
-
-               while (--height >= 0)
-               {
-                       uint32_t prevDst = ~device[0];
-                       uint32_t result SK_INIT_TO_AVOID_WARNING;
-
-                       for (int i = 0; i < width; i++)
-                       {
-                               uint32_t dst = device[i];
-                               if (dst != prevDst)
-                               {
-                                       result = color + SkAlphaMulQ(dst, dst_scale);
-                                       prevDst = dst;
-                               }
-                               device[i] = result;
-                       }
-                       device = (uint32_t*)((char*)device + fDevice.rowBytes());
-               }
-       }
+    SkASSERT(x >= 0 && y >= 0 && x + width <= fDevice.width() && y + height <= fDevice.height());
+
+    if (fSrcA == 0)
+        return;
+
+    uint32_t*   device = fDevice.getAddr32(x, y);
+    uint32_t    color = fPMColor;
+
+    if (fSrcA == 255)
+    {
+        while (--height >= 0)
+        {
+            sk_memset32(device, color, width);
+            device = (uint32_t*)((char*)device + fDevice.rowBytes());
+        }
+    }
+    else
+    {
+        unsigned dst_scale = SkAlpha255To256(255 - fSrcA);
+
+        while (--height >= 0)
+        {
+            uint32_t prevDst = ~device[0];
+            uint32_t result SK_INIT_TO_AVOID_WARNING;
+
+            for (int i = 0; i < width; i++)
+            {
+                uint32_t dst = device[i];
+                if (dst != prevDst)
+                {
+                    result = color + SkAlphaMulQ(dst, dst_scale);
+                    prevDst = dst;
+                }
+                device[i] = result;
+            }
+            device = (uint32_t*)((char*)device + fDevice.rowBytes());
+        }
+    }
 }
 
 #if defined _WIN32 && _MSC_VER >= 1300
@@ -267,108 +284,106 @@ void SkARGB32_Blitter::blitRect(int x, int y, int width, int height)
 
 void SkARGB32_Black_Blitter::blitMask(const SkMask& mask, const SkRect16& clip)
 {
-       SkASSERT(mask.fBounds.contains(clip));
+    SkASSERT(mask.fBounds.contains(clip));
 
     SkPMColor   black = (SkPMColor)(SK_A32_MASK << SK_A32_SHIFT);
 
-       if (mask.fFormat == SkMask::kBW_Format)
-       {
-               SkARGB32_BlitBW(fDevice, mask, clip, black);
-       }
-       else
-       {
-               uint32_t*   device = fDevice.getAddr32(clip.fLeft, clip.fTop);
-               const U8*   alpha = mask.getAddr(clip.fLeft, clip.fTop);
-               unsigned    width = clip.width();
-               unsigned    height = clip.height();
-               unsigned    deviceRB = fDevice.rowBytes() - (width << 2);
-               unsigned    maskRB = mask.fRowBytes - width;
-
-               SkASSERT((int)height > 0);
-               SkASSERT((int)width > 0);
-               SkASSERT((int)deviceRB >= 0);
-               SkASSERT((int)maskRB >= 0);
-
-               do {
-                       unsigned w = width;
-                       do {
-                               unsigned aa = *alpha++;
-                               if (aa)
-                               {
-                                       if (aa == 255)
-                                               *device = black;
-                                       else
-                                               *device = (aa << SK_A32_SHIFT) + SkAlphaMulQ(*device, SkAlpha255To256(255 - aa));
-                               }
-                               device += 1;
-                       } while (--w != 0);
-                       device = (uint32_t*)((char*)device + deviceRB);
-                       alpha += maskRB;
-               } while (--height != 0);
-       }
+    if (mask.fFormat == SkMask::kBW_Format)
+    {
+        SkARGB32_BlitBW(fDevice, mask, clip, black);
+    }
+    else
+    {
+        uint32_t*   device = fDevice.getAddr32(clip.fLeft, clip.fTop);
+        const U8*   alpha = mask.getAddr(clip.fLeft, clip.fTop);
+        unsigned    width = clip.width();
+        unsigned    height = clip.height();
+        unsigned    deviceRB = fDevice.rowBytes() - (width << 2);
+        unsigned    maskRB = mask.fRowBytes - width;
+
+        SkASSERT((int)height > 0);
+        SkASSERT((int)width > 0);
+        SkASSERT((int)deviceRB >= 0);
+        SkASSERT((int)maskRB >= 0);
+
+        do {
+            unsigned w = width;
+            do {
+                unsigned aa = *alpha++;
+                if (aa)
+                {
+                    if (aa == 255)
+                        *device = black;
+                    else
+                        *device = (aa << SK_A32_SHIFT) + SkAlphaMulQ(*device, SkAlpha255To256(255 - aa));
+                }
+                device += 1;
+            } while (--w != 0);
+            device = (uint32_t*)((char*)device + deviceRB);
+            alpha += maskRB;
+        } while (--height != 0);
+    }
 }
 
 //////////////////////////////////////////////////////////////////////////////////////////
 
 SkARGB32_Shader_Blitter::SkARGB32_Shader_Blitter(const SkBitmap& device, const SkPaint& paint) : fDevice(device)
 {
-       fBuffer = (SkPMColor*)sk_malloc_throw(device.width() * (sizeof(SkPMColor)));
+    fBuffer = (SkPMColor*)sk_malloc_throw(device.width() * (sizeof(SkPMColor)));
 
-       fShader = paint.getShader();
-       SkASSERT(fShader);
-       fShader->ref();
+    fShader = paint.getShader();
+    SkASSERT(fShader);
+    fShader->ref();
 
-       (fXfermode = paint.getXfermode())->safeRef();
+    (fXfermode = paint.getXfermode())->safeRef();
 }
 
 SkARGB32_Shader_Blitter::~SkARGB32_Shader_Blitter()
 {
-       fXfermode->safeUnref();
-       fShader->unref();
-       sk_free(fBuffer);
+    fXfermode->safeUnref();
+    fShader->unref();
+    sk_free(fBuffer);
 }
 
 void SkARGB32_Shader_Blitter::blitH(int x, int y, int width)
 {
-       SkASSERT(x >= 0 && y >= 0 && (unsigned)(x + width) <= fDevice.width());
-
-       uint32_t*       device = fDevice.getAddr32(x, y);
-
-       if (fXfermode == NULL && (fShader->getFlags() & SkShader::kOpaqueAlpha_Flag))
-       {
-               fShader->shadeSpan(x, y, device, width);
-       }
-       else
-       {
-        SkPMColor*     span = fBuffer;
-               fShader->shadeSpan(x, y, span, width);
-               if (fXfermode)
-                       fXfermode->xfer32(device, span, width, NULL);
-               else
-               {
-                       for (int i = 0; i < width; i++)
-                       {
-                               uint32_t src = span[i];
-                               if (src)
-                               {
-                                       unsigned srcA = SkGetPackedA32(src);
-                                       if (srcA != 0xFF)
-                                               src += SkAlphaMulQ(device[i], SkAlpha255To256(255 - srcA));
-                                       device[i] = src;
-                               }
-                       }
-               }
-       }
+    SkASSERT(x >= 0 && y >= 0 && x + width <= fDevice.width());
+
+    uint32_t*   device = fDevice.getAddr32(x, y);
+
+    if (fXfermode == NULL && (fShader->getFlags() & SkShader::kOpaqueAlpha_Flag))
+    {
+        fShader->shadeSpan(x, y, device, width);
+    }
+    else
+    {
+        SkPMColor*  span = fBuffer;
+        fShader->shadeSpan(x, y, span, width);
+        if (fXfermode)
+            fXfermode->xfer32(device, span, width, NULL);
+        else
+        {
+            for (int i = 0; i < width; i++)
+            {
+                uint32_t src = span[i];
+                if (src)
+                {
+                    unsigned srcA = SkGetPackedA32(src);
+                    if (srcA != 0xFF)
+                        src += SkAlphaMulQ(device[i], SkAlpha255To256(255 - srcA));
+                    device[i] = src;
+                }
+            }
+        }
+    }
 }
 
 ///////////////////////////////////////////////////////////////////////////////////////////////
 
 void SkARGB32_Shader_Blitter::blitAntiH(int x, int y, const SkAlpha antialias[], const S16 runs[])
 {
-       SkASSERT(x >= 0 && y >= 0 && x < (int)fDevice.width() && y < (int)fDevice.height());
-
-       SkPMColor*      span = fBuffer;
-       uint32_t*       device = fDevice.getAddr32(x, y);
+    SkPMColor*  span = fBuffer;
+    uint32_t*   device = fDevice.getAddr32(x, y);
     SkShader*   shader = fShader;
 
     if (fXfermode)
@@ -377,10 +392,10 @@ void SkARGB32_Shader_Blitter::blitAntiH(int x, int y, const SkAlpha antialias[],
         {
             SkXfermode* xfer = fXfermode;
 
-            int        count = *runs;
+            int count = *runs;
             if (count == 0)
                 break;
-            int        aa = *antialias;
+            int aa = *antialias;
             if (aa)
             {
                 shader->shadeSpan(x, y, span, count);
@@ -403,10 +418,10 @@ void SkARGB32_Shader_Blitter::blitAntiH(int x, int y, const SkAlpha antialias[],
     {
         for (;;)
         {
-            int        count = *runs;
+            int count = *runs;
             if (count == 0)
                 break;
-            int        aa = *antialias;
+            int aa = *antialias;
             if (aa)
             {
                 if (aa == 255)  // cool, have the shader draw right into the device
@@ -431,10 +446,10 @@ void SkARGB32_Shader_Blitter::blitAntiH(int x, int y, const SkAlpha antialias[],
     {
         for (;;)
         {
-            int        count = *runs;
+            int count = *runs;
             if (count == 0)
                 break;
-            int        aa = *antialias;
+            int aa = *antialias;
             if (aa)
             {
                 fShader->shadeSpan(x, y, span, count);
index 56b2b41..8b1a8cc 100644 (file)
@@ -1,3 +1,20 @@
+/* libs/graphics/sgl/SkBlitter_RGB16.cpp
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #include "SkCoreBlitters.h"
 #include "SkColorPriv.h"
 #include "SkShader.h"
 #include "SkXfermode.h"
 
 #ifdef SK_DEBUG
-       static unsigned RGB16Add(U16CPU a, U16CPU b)
-       {
-               SkASSERT(SkGetPackedR16(a) + SkGetPackedR16(b) <= SK_R16_MASK);
-               SkASSERT(SkGetPackedG16(a) + SkGetPackedG16(b) <= SK_G16_MASK);
-               SkASSERT(SkGetPackedB16(a) + SkGetPackedB16(b) <= SK_B16_MASK);
-
-               return a + b;
-       }
+    static unsigned RGB16Add(U16CPU a, U16CPU b)
+    {
+        SkASSERT(SkGetPackedR16(a) + SkGetPackedR16(b) <= SK_R16_MASK);
+        SkASSERT(SkGetPackedG16(a) + SkGetPackedG16(b) <= SK_G16_MASK);
+        SkASSERT(SkGetPackedB16(a) + SkGetPackedB16(b) <= SK_B16_MASK);
+
+        return a + b;
+    }
 #else
-       #define RGB16Add(a, b)  (a + b)
+    #define RGB16Add(a, b)  (a + b)
 #endif
 
 #if 1
-#define black_8_pixels(mask, dst)              \
-       do {                                                            \
-               if (mask & 0x80) dst[0] = 0;    \
-               if (mask & 0x40) dst[1] = 0;    \
-               if (mask & 0x20) dst[2] = 0;    \
-               if (mask & 0x10) dst[3] = 0;    \
-               if (mask & 0x08) dst[4] = 0;    \
-               if (mask & 0x04) dst[5] = 0;    \
-               if (mask & 0x02) dst[6] = 0;    \
-               if (mask & 0x01) dst[7] = 0;    \
-       } while (0)
+#define black_8_pixels(mask, dst)       \
+    do {                                \
+        if (mask & 0x80) dst[0] = 0;    \
+        if (mask & 0x40) dst[1] = 0;    \
+        if (mask & 0x20) dst[2] = 0;    \
+        if (mask & 0x10) dst[3] = 0;    \
+        if (mask & 0x08) dst[4] = 0;    \
+        if (mask & 0x04) dst[5] = 0;    \
+        if (mask & 0x02) dst[6] = 0;    \
+        if (mask & 0x01) dst[7] = 0;    \
+    } while (0)
 #else
-static inline black_8_pixels(U8CPU mask, U16 dst[])
+static inline black_8_pixels(U8CPU mask, uint16_t dst[])
 {
-       if (mask & 0x80) dst[0] = 0;
-       if (mask & 0x40) dst[1] = 0;
-       if (mask & 0x20) dst[2] = 0;
-       if (mask & 0x10) dst[3] = 0;
-       if (mask & 0x08) dst[4] = 0;
-       if (mask & 0x04) dst[5] = 0;
-       if (mask & 0x02) dst[6] = 0;
-       if (mask & 0x01) dst[7] = 0;
+    if (mask & 0x80) dst[0] = 0;
+    if (mask & 0x40) dst[1] = 0;
+    if (mask & 0x20) dst[2] = 0;
+    if (mask & 0x10) dst[3] = 0;
+    if (mask & 0x08) dst[4] = 0;
+    if (mask & 0x04) dst[5] = 0;
+    if (mask & 0x02) dst[6] = 0;
+    if (mask & 0x01) dst[7] = 0;
 }
 #endif
 
-#define        SK_BLITBWMASK_NAME                                      SkRGB16_Black_BlitBW
+#define SK_BLITBWMASK_NAME                  SkRGB16_Black_BlitBW
 #define SK_BLITBWMASK_ARGS
-#define SK_BLITBWMASK_BLIT8(mask, dst)         black_8_pixels(mask, dst)
-#define SK_BLITBWMASK_GETADDR                          getAddr16
-#define SK_BLITBWMASK_DEVTYPE                          U16
+#define SK_BLITBWMASK_BLIT8(mask, dst)      black_8_pixels(mask, dst)
+#define SK_BLITBWMASK_GETADDR               getAddr16
+#define SK_BLITBWMASK_DEVTYPE               uint16_t
 #include "SkBlitBWMaskTemplate.h"
 
 void SkRGB16_Black_Blitter::blitMask(const SkMask& mask, const SkRect16& clip)
 {
-       if (mask.fFormat == SkMask::kBW_Format)
-       {
-               SkRGB16_Black_BlitBW(fDevice, mask, clip);
-       }
-       else
-       {
-               U16* device = fDevice.getAddr16(clip.fLeft, clip.fTop);
-               const U8* alpha = mask.getAddr(clip.fLeft, clip.fTop);
-               unsigned width = clip.width();
-               unsigned height = clip.height();
-               unsigned deviceRB = fDevice.rowBytes() - (width << 1);
-               unsigned maskRB = mask.fRowBytes - width;
-
-               SkASSERT((int)height > 0);
-               SkASSERT((int)width > 0);
-               SkASSERT((int)deviceRB >= 0);
-               SkASSERT((int)maskRB >= 0);
-
-               do {
-                       unsigned w = width;
-                       do {
-                               unsigned aa = *alpha++;
-                               if (aa)
-                               {
-                                       if (aa == 255)
-                                               *device = 0;
-                                       else
-                                               *device = SkToU16(SkAlphaMulRGB16(*device, SkAlpha255To256(255 - aa)));
-                               }
-                               device += 1;
-                       } while (--w != 0);
-                       device = (U16*)((char*)device + deviceRB);
-                       alpha += maskRB;
-               } while (--height != 0);
-       }
+    if (mask.fFormat == SkMask::kBW_Format)
+    {
+        SkRGB16_Black_BlitBW(fDevice, mask, clip);
+    }
+    else
+    {
+        uint16_t* device = fDevice.getAddr16(clip.fLeft, clip.fTop);
+        const uint8_t* alpha = mask.getAddr(clip.fLeft, clip.fTop);
+        unsigned width = clip.width();
+        unsigned height = clip.height();
+        unsigned deviceRB = fDevice.rowBytes() - (width << 1);
+        unsigned maskRB = mask.fRowBytes - width;
+
+        SkASSERT((int)height > 0);
+        SkASSERT((int)width > 0);
+        SkASSERT((int)deviceRB >= 0);
+        SkASSERT((int)maskRB >= 0);
+
+        do {
+            unsigned w = width;
+            do {
+                unsigned aa = *alpha++;
+                if (aa)
+                {
+                    if (aa == 255)
+                        *device = 0;
+                    else
+                        *device = SkToU16(SkAlphaMulRGB16(*device, SkAlpha255To256(255 - aa)));
+                }
+                device += 1;
+            } while (--w != 0);
+            device = (uint16_t*)((char*)device + deviceRB);
+            alpha += maskRB;
+        } while (--height != 0);
+    }
 }
 
 //////////////////////////////////////////////////////////////////////////////////////////////////
@@ -94,581 +111,609 @@ void SkRGB16_Black_Blitter::blitMask(const SkMask& mask, const SkRect16& clip)
 
 SkRGB16_Blitter::SkRGB16_Blitter(const SkBitmap& device, const SkPaint& paint) : fDevice(device)
 {
-       U32 color = paint.getColor();
+    uint32_t color = paint.getColor();
 
-       fScale = SkAlpha255To256(SkColorGetA(color));
+    fScale = SkAlpha255To256(SkColorGetA(color));
 
-       fRawColor16 = SkPackRGB16(      SkColorGetR(color) >> (8 - SK_R16_BITS),
-                                                               SkColorGetG(color) >> (8 - SK_G16_BITS),
-                                                               SkColorGetB(color) >> (8 - SK_B16_BITS));
+    fRawColor16 = SkPackRGB16(  SkColorGetR(color) >> (8 - SK_R16_BITS),
+                                SkColorGetG(color) >> (8 - SK_G16_BITS),
+                                SkColorGetB(color) >> (8 - SK_B16_BITS));
 
-       fColor16 = SkPackRGB16( SkAlphaMul(SkColorGetR(color), fScale) >> (8 - SK_R16_BITS),
-                                                       SkAlphaMul(SkColorGetG(color), fScale) >> (8 - SK_G16_BITS),
-                                                       SkAlphaMul(SkColorGetB(color), fScale) >> (8 - SK_B16_BITS));
+    fColor16 = SkPackRGB16( SkAlphaMul(SkColorGetR(color), fScale) >> (8 - SK_R16_BITS),
+                            SkAlphaMul(SkColorGetG(color), fScale) >> (8 - SK_G16_BITS),
+                            SkAlphaMul(SkColorGetB(color), fScale) >> (8 - SK_B16_BITS));
 }
 
 void SkRGB16_Blitter::blitH(int x, int y, int width)
 {
-       SkASSERT(width > 0);
-       SkASSERT(x >= 0 && y >= 0 && (unsigned)(x + width) <= fDevice.width());
-
-       if (fScale == 0)
-               return;
-
-       U16*            device = fDevice.getAddr16(x, y);
-       unsigned        srcColor = fColor16;
-
-       if (fScale == 256)
-       {
-               sk_memset16(device, srcColor, width);
-       }
-       else
-       {
-               unsigned scale = 256 - fScale;
-               do {
-                       *device = (U16)RGB16Add(srcColor, SkAlphaMulRGB16(*device, scale));
-                       device += 1;
-               } while (--width != 0);
-       }
+    SkASSERT(width > 0);
+    SkASSERT(x + width <= fDevice.width());
+
+    if (fScale == 0)
+        return;
+
+    uint16_t*   device = fDevice.getAddr16(x, y);
+    unsigned    srcColor = fColor16;
+
+    if (fScale == 256)
+    {
+        sk_memset16(device, srcColor, width);
+    }
+    else
+    {
+        unsigned scale = 256 - fScale;
+        do {
+            *device = (uint16_t)RGB16Add(srcColor, SkAlphaMulRGB16(*device, scale));
+            device += 1;
+        } while (--width != 0);
+    }
 }
 
 void SkRGB16_Blitter::blitAntiH(int x, int y, const SkAlpha antialias[], const S16 runs[])
 {
-       if (fScale == 0)
-               return;
-
-       U16*            device = fDevice.getAddr16(x, y);
-       U16                     srcColor = fColor16;
-       unsigned        scale = fScale;
-
-       if (scale == 256)
-       {
-               for (;;)
-               {
-                       int count = runs[0];
-                       SkASSERT(count >= 0);
-                       if (count == 0)
-                               return;
-                       runs += count;
-
-                       unsigned aa = antialias[0];
-                       antialias += count;
-                       if (aa)
-                       {
-                               if (aa == 255)
-                               {
-                                       sk_memset16(device, srcColor, count);
-                               }
-                               else
-                               {
-                                       unsigned src = SkAlphaMulRGB16(srcColor, SkAlpha255To256(aa));
-                                       unsigned dst_scale = SkAlpha255To256(255 - aa);
-                                       do {
-                                               *device = (U16)RGB16Add(src, SkAlphaMulRGB16(*device, dst_scale));
-                                               device += 1;
-                                       } while (--count != 0);
-                                       continue;
-                               }
-                       }
-                       device += count;
-               }
-       }
-       else
-       {
-               for (;;)
-               {
-                       int count = runs[0];
-                       SkASSERT(count >= 0);
-                       if (count == 0)
-                               return;
-                       runs += count;
-
-                       unsigned aa = antialias[0];
-                       antialias += count;
-                       if (aa)
-                       {
-                               unsigned src = SkAlphaMulRGB16(srcColor, SkAlpha255To256(aa));
-                               unsigned dst_scale = SkAlpha255To256(255 - SkAlphaMul(aa, scale));
-                               do {
-                                       *device = (U16)RGB16Add(src, SkAlphaMulRGB16(*device, dst_scale));
-                                       device += 1;
-                               } while (--count != 0);
-                               continue;
-                       }
-                       device += count;
-               }
-       }
+    if (fScale == 0)
+        return;
+
+    uint16_t*   device = fDevice.getAddr16(x, y);
+    uint16_t    srcColor = fColor16;
+    unsigned    scale = fScale;
+
+    if (scale == 256)
+    {
+        for (;;)
+        {
+            int count = runs[0];
+            SkASSERT(count >= 0);
+            if (count == 0)
+                return;
+            runs += count;
+
+            unsigned aa = antialias[0];
+            antialias += count;
+            if (aa)
+            {
+                if (aa == 255)
+                {
+                    sk_memset16(device, srcColor, count);
+                }
+                else
+                {
+                    unsigned src = SkAlphaMulRGB16(srcColor, SkAlpha255To256(aa));
+                    unsigned dst_scale = SkAlpha255To256(255 - aa);
+                    do {
+                        *device = (uint16_t)RGB16Add(src, SkAlphaMulRGB16(*device, dst_scale));
+                        device += 1;
+                    } while (--count != 0);
+                    continue;
+                }
+            }
+            device += count;
+        }
+    }
+    else
+    {
+        for (;;)
+        {
+            int count = runs[0];
+            SkASSERT(count >= 0);
+            if (count == 0)
+                return;
+            runs += count;
+
+            unsigned aa = antialias[0];
+            antialias += count;
+            if (aa)
+            {
+                unsigned src = SkAlphaMulRGB16(srcColor, SkAlpha255To256(aa));
+                unsigned dst_scale = SkAlpha255To256(255 - SkAlphaMul(aa, scale));
+                do {
+                    *device = (uint16_t)RGB16Add(src, SkAlphaMulRGB16(*device, dst_scale));
+                    device += 1;
+                } while (--count != 0);
+                continue;
+            }
+            device += count;
+        }
+    }
 }
 
 //////////////////////////////////////////////////////////////////////////////////////
 
-#define solid_8_pixels(mask, dst, color)       \
-       do {                                                                    \
-               if (mask & 0x80) dst[0] = color;        \
-               if (mask & 0x40) dst[1] = color;        \
-               if (mask & 0x20) dst[2] = color;        \
-               if (mask & 0x10) dst[3] = color;        \
-               if (mask & 0x08) dst[4] = color;        \
-               if (mask & 0x04) dst[5] = color;        \
-               if (mask & 0x02) dst[6] = color;        \
-               if (mask & 0x01) dst[7] = color;        \
-       } while (0)
-
-#define        SK_BLITBWMASK_NAME                                      SkRGB16_BlitBW
-#define SK_BLITBWMASK_ARGS                                     , U16 color
-#define SK_BLITBWMASK_BLIT8(mask, dst)         solid_8_pixels(mask, dst, color)
-#define SK_BLITBWMASK_GETADDR                          getAddr16
-#define SK_BLITBWMASK_DEVTYPE                          U16
+#define solid_8_pixels(mask, dst, color)    \
+    do {                                    \
+        if (mask & 0x80) dst[0] = color;    \
+        if (mask & 0x40) dst[1] = color;    \
+        if (mask & 0x20) dst[2] = color;    \
+        if (mask & 0x10) dst[3] = color;    \
+        if (mask & 0x08) dst[4] = color;    \
+        if (mask & 0x04) dst[5] = color;    \
+        if (mask & 0x02) dst[6] = color;    \
+        if (mask & 0x01) dst[7] = color;    \
+    } while (0)
+
+#define SK_BLITBWMASK_NAME                  SkRGB16_BlitBW
+#define SK_BLITBWMASK_ARGS                  , uint16_t color
+#define SK_BLITBWMASK_BLIT8(mask, dst)      solid_8_pixels(mask, dst, color)
+#define SK_BLITBWMASK_GETADDR               getAddr16
+#define SK_BLITBWMASK_DEVTYPE               uint16_t
 #include "SkBlitBWMaskTemplate.h"
 
-static inline void blend_8_pixels(U8CPU bw, U16 dst[], unsigned dst_scale, U16CPU srcColor)
+static inline void blend_8_pixels(U8CPU bw, uint16_t dst[], unsigned dst_scale, U16CPU srcColor)
 {
-       if (bw & 0x80) dst[0] = SkToU16(srcColor + SkAlphaMulRGB16(dst[0], dst_scale));
-       if (bw & 0x40) dst[1] = SkToU16(srcColor + SkAlphaMulRGB16(dst[1], dst_scale));
-       if (bw & 0x20) dst[2] = SkToU16(srcColor + SkAlphaMulRGB16(dst[2], dst_scale));
-       if (bw & 0x10) dst[3] = SkToU16(srcColor + SkAlphaMulRGB16(dst[3], dst_scale));
-       if (bw & 0x08) dst[4] = SkToU16(srcColor + SkAlphaMulRGB16(dst[4], dst_scale));
-       if (bw & 0x04) dst[5] = SkToU16(srcColor + SkAlphaMulRGB16(dst[5], dst_scale));
-       if (bw & 0x02) dst[6] = SkToU16(srcColor + SkAlphaMulRGB16(dst[6], dst_scale));
-       if (bw & 0x01) dst[7] = SkToU16(srcColor + SkAlphaMulRGB16(dst[7], dst_scale));
+    if (bw & 0x80) dst[0] = SkToU16(srcColor + SkAlphaMulRGB16(dst[0], dst_scale));
+    if (bw & 0x40) dst[1] = SkToU16(srcColor + SkAlphaMulRGB16(dst[1], dst_scale));
+    if (bw & 0x20) dst[2] = SkToU16(srcColor + SkAlphaMulRGB16(dst[2], dst_scale));
+    if (bw & 0x10) dst[3] = SkToU16(srcColor + SkAlphaMulRGB16(dst[3], dst_scale));
+    if (bw & 0x08) dst[4] = SkToU16(srcColor + SkAlphaMulRGB16(dst[4], dst_scale));
+    if (bw & 0x04) dst[5] = SkToU16(srcColor + SkAlphaMulRGB16(dst[5], dst_scale));
+    if (bw & 0x02) dst[6] = SkToU16(srcColor + SkAlphaMulRGB16(dst[6], dst_scale));
+    if (bw & 0x01) dst[7] = SkToU16(srcColor + SkAlphaMulRGB16(dst[7], dst_scale));
 }
 
-#define        SK_BLITBWMASK_NAME                                      SkRGB16_BlendBW
-#define SK_BLITBWMASK_ARGS                                     , unsigned dst_scale, U16CPU src_color
-#define SK_BLITBWMASK_BLIT8(mask, dst)         blend_8_pixels(mask, dst, dst_scale, src_color)
-#define SK_BLITBWMASK_GETADDR                          getAddr16
-#define SK_BLITBWMASK_DEVTYPE                          U16
+#define SK_BLITBWMASK_NAME                  SkRGB16_BlendBW
+#define SK_BLITBWMASK_ARGS                  , unsigned dst_scale, U16CPU src_color
+#define SK_BLITBWMASK_BLIT8(mask, dst)      blend_8_pixels(mask, dst, dst_scale, src_color)
+#define SK_BLITBWMASK_GETADDR               getAddr16
+#define SK_BLITBWMASK_DEVTYPE               uint16_t
 #include "SkBlitBWMaskTemplate.h"
 
 void SkRGB16_Blitter::blitMask(const SkMask& mask, const SkRect16& clip)
 {
-       if (fScale == 0)
-               return;
-
-       if (mask.fFormat == SkMask::kBW_Format)
-       {
-               if (fScale == 256)
-                       SkRGB16_BlitBW(fDevice, mask, clip, fColor16);
-               else
-                       SkRGB16_BlendBW(fDevice, mask, clip, 256 - fScale, fColor16);
-               return;
-       }
-
-       U16* device = fDevice.getAddr16(clip.fLeft, clip.fTop);
-       const U8* alpha = mask.getAddr(clip.fLeft, clip.fTop);
-       int width = clip.width();
-       int height = clip.height();
-       unsigned        maskRB = mask.fRowBytes;
-       U16                     color16 = fRawColor16;
-       unsigned        scale = fScale;
-       unsigned        deviceRB = fDevice.rowBytes();
-
-       if (scale == 256)
-       {
-               while (--height >= 0)
-               {
-                       for (int i = width - 1; i >= 0; --i)
-                       {
-                               unsigned aa = alpha[i];
-                               if (aa)
-                               {
-                                       if (aa == 255)
-                                               device[i] = color16;
-                                       else
-                                       {
-                                               unsigned src_scale = SkAlpha255To256(aa);
-                                               unsigned dst_scale = SkAlpha255To256(255 - aa);
-                                               device[i] = (U16)RGB16Add(SkAlphaMulRGB16(color16, src_scale), SkAlphaMulRGB16(device[i], dst_scale));
-                                       }
-                               }
-                       }
-                       device = (U16*)((char*)device + deviceRB);
-                       alpha += maskRB;
-               }
-       }
-       else    // scale < 256
-       {
-               while (--height >= 0)
-               {
-                       for (int i = width - 1; i >= 0; --i)
-                       {
-                               unsigned aa = alpha[i];
-                               if (aa)
-                               {
-                                       aa = SkAlphaMul(aa, scale);
-                                       unsigned src_scale = SkAlpha255To256(aa);
-                                       unsigned dst_scale = SkAlpha255To256(255 - aa);
-                                       device[i] = (U16)RGB16Add(SkAlphaMulRGB16(color16, src_scale), SkAlphaMulRGB16(device[i], dst_scale));
-                               }
-                       }
-                       device = (U16*)((char*)device + deviceRB);
-                       alpha += maskRB;
-               }
-       }
+    if (fScale == 0)
+        return;
+
+    if (mask.fFormat == SkMask::kBW_Format)
+    {
+        if (fScale == 256)
+            SkRGB16_BlitBW(fDevice, mask, clip, fColor16);
+        else
+            SkRGB16_BlendBW(fDevice, mask, clip, 256 - fScale, fColor16);
+        return;
+    }
+
+    uint16_t* device = fDevice.getAddr16(clip.fLeft, clip.fTop);
+    const uint8_t* alpha = mask.getAddr(clip.fLeft, clip.fTop);
+    int width = clip.width();
+    int height = clip.height();
+    unsigned    maskRB = mask.fRowBytes;
+    uint16_t    color16 = fRawColor16;
+    unsigned    scale = fScale;
+    unsigned    deviceRB = fDevice.rowBytes();
+
+    if (scale == 256)
+    {
+        while (--height >= 0)
+        {
+            for (int i = width - 1; i >= 0; --i)
+            {
+                unsigned aa = alpha[i];
+                if (aa)
+                {
+                    if (aa == 255)
+                        device[i] = color16;
+                    else
+                    {
+                        unsigned src_scale = SkAlpha255To256(aa);
+                        unsigned dst_scale = SkAlpha255To256(255 - aa);
+                        device[i] = (uint16_t)RGB16Add(SkAlphaMulRGB16(color16, src_scale), SkAlphaMulRGB16(device[i], dst_scale));
+                    }
+                }
+            }
+            device = (uint16_t*)((char*)device + deviceRB);
+            alpha += maskRB;
+        }
+    }
+    else    // scale < 256
+    {
+        while (--height >= 0)
+        {
+            for (int i = width - 1; i >= 0; --i)
+            {
+                unsigned aa = alpha[i];
+                if (aa)
+                {
+                    aa = SkAlphaMul(aa, scale);
+                    unsigned src_scale = SkAlpha255To256(aa);
+                    unsigned dst_scale = SkAlpha255To256(255 - aa);
+                    device[i] = (uint16_t)RGB16Add(SkAlphaMulRGB16(color16, src_scale), SkAlphaMulRGB16(device[i], dst_scale));
+                }
+            }
+            device = (uint16_t*)((char*)device + deviceRB);
+            alpha += maskRB;
+        }
+    }
 }
 
 void SkRGB16_Blitter::blitV(int x, int y, int height, SkAlpha alpha)
 {
-       if (fScale == 0)
-               return;
-
-       U16*    device = fDevice.getAddr16(x, y);
-       U16             color16 = fColor16;
-       unsigned deviceRB = fDevice.rowBytes();
-
-       if (alpha + fScale == (255 + 256))
-       {
-               do {
-                       device[0] = color16;
-                       device = (U16*)((char*)device + deviceRB);
-               } while (--height != 0);
-       }
-       else
-       {
-               unsigned scale = fScale;
-
-               if (alpha < 255)
-               {
-                       scale = SkAlphaMul(alpha, scale);
-                       color16 = SkToU16(SkAlphaMulRGB16(fRawColor16, scale));
-               }
-               scale = 256 - scale;
-               do {
-                       *device = (U16)RGB16Add(color16, SkAlphaMulRGB16(device[0], scale));
-                       device = (U16*)((char*)device + deviceRB);
-               } while (--height != 0);
-       }
+    if (fScale == 0)
+        return;
+
+    uint16_t*   device = fDevice.getAddr16(x, y);
+    uint16_t    color16 = fColor16;
+    unsigned    deviceRB = fDevice.rowBytes();
+
+    if (alpha + fScale == (255 + 256))
+    {
+        do {
+            device[0] = color16;
+            device = (uint16_t*)((char*)device + deviceRB);
+        } while (--height != 0);
+    }
+    else
+    {
+        unsigned scale = fScale;
+
+        if (alpha < 255)
+        {
+            scale = SkAlphaMul(alpha, scale);
+            color16 = SkToU16(SkAlphaMulRGB16(fRawColor16, scale));
+        }
+        scale = 256 - scale;
+        do {
+            *device = (uint16_t)RGB16Add(color16, SkAlphaMulRGB16(device[0], scale));
+            device = (uint16_t*)((char*)device + deviceRB);
+        } while (--height != 0);
+    }
 }
 
 void SkRGB16_Blitter::blitRect(int x, int y, int width, int height)
 {
-       SkASSERT(x >= 0 && y >= 0 && (unsigned)(x + width) <= fDevice.width() && (unsigned)(y + height) <= fDevice.height());
-
-       if (fScale == 0)
-               return;
-
-       U16*            device = fDevice.getAddr16(x, y);
-       unsigned        deviceRB = fDevice.rowBytes();
-       U16                     color16 = fColor16;
-
-       if (fScale == 256)
-       {
-               while (--height >= 0)
-               {
-                       sk_memset16(device, color16, width);
-                       device = (U16*)((char*)device + deviceRB);
-               }
-       }
-       else
-       {
-               unsigned dst_scale = 256 - fScale;      // apply it to the dst
-
-               while (--height >= 0)
-               {
-                       for (int i = width - 1; i >= 0; --i)
-                               device[i] = SkToU16(color16 + SkAlphaMulRGB16(device[i], dst_scale));
-                       device = (U16*)((char*)device + deviceRB);
-               }
-       }
+    SkASSERT(x + width <= fDevice.width() && y + height <= fDevice.height());
+
+    if (fScale == 0)
+        return;
+
+    uint16_t*   device = fDevice.getAddr16(x, y);
+    unsigned    deviceRB = fDevice.rowBytes();
+    uint16_t    color16 = fColor16;
+
+    if (fScale == 256)
+    {
+        while (--height >= 0)
+        {
+            sk_memset16(device, color16, width);
+            device = (uint16_t*)((char*)device + deviceRB);
+        }
+    }
+    else
+    {
+        unsigned dst_scale = 256 - fScale;  // apply it to the dst
+
+        while (--height >= 0)
+        {
+            for (int i = width - 1; i >= 0; --i)
+                device[i] = SkToU16(color16 + SkAlphaMulRGB16(device[i], dst_scale));
+            device = (uint16_t*)((char*)device + deviceRB);
+        }
+    }
 }
 
 ///////////////////////////////////////////////////////////////////////
 
-#define BLEND_32_TO_16(srcA, src, dst)  \
-    SkToU16(SkPixel32ToPixel16(src) + SkAlphaMulRGB16(dst, 256 - SkAlpha255To256(srcA)))
-
 SkRGB16_Shader_Blitter::SkRGB16_Shader_Blitter(const SkBitmap& device, const SkPaint& paint) : fDevice(device)
 {
-       SkASSERT(paint.getXfermode() == NULL);
+    SkASSERT(paint.getXfermode() == NULL);
 
-       fShader = paint.getShader();
-       SkASSERT(fShader);
-       fShader->ref();
+    fShader = paint.getShader();
+    SkASSERT(fShader);
+    fShader->ref();
 
-       SkAutoUnref autoUnref(fShader);
-       fBuffer = (SkPMColor*)sk_malloc_throw(device.width() * sizeof(SkPMColor));
-       (void)autoUnref.detach();
+    SkAutoUnref autoUnref(fShader);
+    fBuffer = (SkPMColor*)sk_malloc_throw(device.width() * sizeof(SkPMColor));
+    (void)autoUnref.detach();
 }
 
 SkRGB16_Shader_Blitter::~SkRGB16_Shader_Blitter()
 {
-       fShader->unref();
-       sk_free(fBuffer);
+    fShader->unref();
+    sk_free(fBuffer);
 }
 
+#define BLEND_32_TO_16(srcA, src, dst)  \
+    SkToU16(SkPixel32ToPixel16(src) + SkAlphaMulRGB16(dst, 256 - SkAlpha255To256(srcA)))
+
 void SkRGB16_Shader_Blitter::blitH(int x, int y, int width)
 {
-       SkASSERT(x >= 0 && y >= 0 && (unsigned)(x + width) <= fDevice.width());
-
-       U16*    device = fDevice.getAddr16(x, y);
-       U32             flags = fShader->getFlags();
-
-       if (SkShader::CanCallShadeSpanOpaque16(flags))
-       {
-               fShader->shadeSpanOpaque16(x, y, device, width);
-               return;
-       }
-
-       //      If we get here, we know we need the 32bit answer from the shader
-
-       SkPMColor*      span = fBuffer;
-
-       fShader->shadeSpan(x, y, span, width);
-       if (flags & SkShader::kOpaqueAlpha_Flag)
-       {
-               for (int i = width - 1; i >= 0; --i)
-                       device[i] = SkPixel32ToPixel16_ToU16(span[i]);
-       }
-       else
-       {
-               for (int i = 0; i < width; i++)
-               {
-                       U32     src = span[i];
-                       if (src)
-                       {
-                               unsigned srcA = SkGetPackedA32(src);
-                               if (srcA == 0xFF)
-                                       device[i] = SkPixel32ToPixel16_ToU16(src);
-                               else
+    SkASSERT(x + width <= fDevice.width());
+
+    uint16_t*   device = fDevice.getAddr16(x, y);
+    SkShader*   shader = fShader;
+    uint32_t    flags = fShader->getFlags();
+
+    if (SkShader::CanCallShadeSpan16(flags))
+    {
+        int alpha = shader->getSpan16Alpha();
+        if (0xFF == alpha)
+            shader->shadeSpan16(x, y, device, width);
+        else
+        {
+            uint16_t* span16 = (uint16_t*)fBuffer;
+            shader->shadeSpan16(x, y, span16, width);
+            SkBlendRGB16(span16, device, SkAlpha255To256(alpha), width);
+        }
+        return;
+    }
+
+    //  If we get here, we know we need the 32bit answer from the shader
+
+    SkPMColor*  span = fBuffer;
+
+    shader->shadeSpan(x, y, span, width);
+    if (flags & SkShader::kOpaqueAlpha_Flag)
+    {
+        for (int i = width - 1; i >= 0; --i)
+            device[i] = SkPixel32ToPixel16_ToU16(span[i]);
+    }
+    else
+    {
+        for (int i = 0; i < width; i++)
+        {
+            SkPMColor src = span[i];
+            if (src)
+            {
+                unsigned srcA = SkGetPackedA32(src);
+                if (srcA == 0xFF)
+                    device[i] = SkPixel32ToPixel16_ToU16(src);
+                else
                     device[i] = BLEND_32_TO_16(srcA, src, device[i]);
-                       }
-               }
-       }
+            }
+        }
+    }
 }
 
-static inline U16 aa_blendS32D16(U32 src, U16CPU dst, int aa)
+static inline uint16_t aa_blendS32D16(SkPMColor src, U16CPU dst, int aa)
 {
-       SkASSERT((unsigned)aa <= 255);
+    SkASSERT((unsigned)aa <= 255);
 
-       int src_scale = SkAlpha255To256(aa);
-       int     sa = SkGetPackedA32(src);
-       int dst_scale = SkAlpha255To256(255 - SkAlphaMul(sa, src_scale));
+    int src_scale = SkAlpha255To256(aa);
+    int sa = SkGetPackedA32(src);
+    int dst_scale = SkAlpha255To256(255 - SkAlphaMul(sa, src_scale));
 
-       int dr = (SkPacked32ToR16(src) * src_scale + SkGetPackedR16(dst) * dst_scale) >> 8;
-       int dg = (SkPacked32ToG16(src) * src_scale + SkGetPackedG16(dst) * dst_scale) >> 8;
-       int db = (SkPacked32ToB16(src) * src_scale + SkGetPackedB16(dst) * dst_scale) >> 8;
+    int dr = (SkPacked32ToR16(src) * src_scale + SkGetPackedR16(dst) * dst_scale) >> 8;
+    int dg = (SkPacked32ToG16(src) * src_scale + SkGetPackedG16(dst) * dst_scale) >> 8;
+    int db = (SkPacked32ToB16(src) * src_scale + SkGetPackedB16(dst) * dst_scale) >> 8;
 
-       return SkPackRGB16(dr, dg, db);
+    return SkPackRGB16(dr, dg, db);
 }
 
-static inline int count_nonzero_span(const S16 runs[], const SkAlpha aa[])
+static inline int count_nonzero_span(const int16_t runs[], const SkAlpha aa[])
 {
-       int     count = 0;
-       for (;;)
-       {
-               int n = *runs;
-               if (n == 0 || *aa == 0)
-                       break;
-               runs += n;
-               aa += n;
-               count += n;
-       }
-       return count;
+    int count = 0;
+    for (;;)
+    {
+        int n = *runs;
+        if (n == 0 || *aa == 0)
+            break;
+        runs += n;
+        aa += n;
+        count += n;
+    }
+    return count;
 }
 
-void SkRGB16_Shader_Blitter::blitAntiH(int x, int y, const SkAlpha antialias[], const S16 runs[])
+void SkRGB16_Shader_Blitter::blitAntiH(int x, int y, const SkAlpha antialias[], const int16_t runs[])
 {
-//    aa_blendS32D16(0xd4d4d49c, 65526, 238);
-
-       SkASSERT(x >= 0 && y >= 0 && x < (int)fDevice.width() && y < (int)fDevice.height());
-
-       SkShader*       shader = fShader;
-       SkPMColor*      span = fBuffer;
-       U16*            device = fDevice.getAddr16(x, y);
-       U32                     flags = fShader->getFlags();
-
-       if (SkShader::CanCallShadeSpanOpaque16(flags))
-       {
-               U16* span16 = (U16*)span;
-               for (;;)
-               {
-                       int     count = *runs;
-                       if (count == 0)
-                               break;
-
-                       int     aa = *antialias;
-                       if (aa == 255)
-                               shader->shadeSpanOpaque16(x, y, device, count);
-                       else if (aa)
-                       {
-                               unsigned scale = SkAlpha255To256(aa);
-                               shader->shadeSpanOpaque16(x, y, span16, count);
-                               for (int i = 0; i < count; i++)
-                                       device[i] = SkToU16(SkBlendRGB16(span16[i], device[i], scale));
-                       }
-                       device += count;
-                       runs += count;
-                       antialias += count;
-                       x += count;
-               }
-               return;
-       }
-
-       // If we get here, take the 32bit shadeSpan case
-
-       int     opaque = flags & SkShader::kOpaqueAlpha_Flag;
-
-       for (;;)
-       {
-               int     count = *runs;
-               if (count == 0)
-                       break;
-
-               int     aa = *antialias;
-               if (aa == 0)
-               {
-                       device += count;
-                       runs += count;
-                       antialias += count;
-                       x += count;
-                       continue;
-               }
-
-               int nonZeroCount = count + count_nonzero_span(runs + count, antialias + count);
-
-               shader->shadeSpan(x, y, span, nonZeroCount);
-               x += nonZeroCount;
-               SkPMColor* localSpan = span;
-               for (;;)
-               {
-                       if (aa == 255)  // no antialiasing
-                       {
-                               if (opaque)
-                               {
-                                       for (int i = 0; i < count; i++)
-                                               device[i] = SkPixel32ToPixel16_ToU16(localSpan[i]);
-                               }
-                               else
-                               {
-                                       for (int i = 0; i < count; i++)
-                                       {
-                                               U32     src = localSpan[i];
-                                               if (src)
-                                               {
-                                                       unsigned srcA = SkGetPackedA32(src);
-                                                       if (srcA == 0xFF)
-                                                               device[i] = SkPixel32ToPixel16_ToU16(src);
-                                                       else
+    SkShader*   shader = fShader;
+    SkPMColor*  span = fBuffer;
+    uint16_t*   device = fDevice.getAddr16(x, y);
+    uint32_t    flags = shader->getFlags();
+
+    if (SkShader::CanCallShadeSpan16(flags))
+    {
+        int alpha = shader->getSpan16Alpha();
+        uint16_t* span16 = (uint16_t*)span;
+
+        if (0xFF == alpha)
+        {
+            for (;;)
+            {
+                int count = *runs;
+                if (count == 0)
+                    break;
+
+                int aa = *antialias;
+                if (aa == 255)
+                    shader->shadeSpan16(x, y, device, count);   // go direct to the device!
+                else if (aa)
+                {
+                    shader->shadeSpan16(x, y, span16, count);
+                    SkBlendRGB16(span16, device, SkAlpha255To256(aa), count);
+                }
+                device += count;
+                runs += count;
+                antialias += count;
+                x += count;
+            }
+        }
+        else    // span alpha is < 255
+        {
+            alpha = SkAlpha255To256(alpha);
+            for (;;)
+            {
+                int count = *runs;
+                if (count == 0)
+                    break;
+
+                int aa = SkAlphaMul(*antialias, alpha);
+                if (aa)
+                {
+                    shader->shadeSpan16(x, y, span16, count);
+                    SkBlendRGB16(span16, device, SkAlpha255To256(aa), count);
+                }
+
+                device += count;
+                runs += count;
+                antialias += count;
+                x += count;
+            }
+        }
+        return;
+    }
+
+    // If we get here, take the 32bit shadeSpan case
+
+    int opaque = flags & SkShader::kOpaqueAlpha_Flag;
+
+    for (;;)
+    {
+        int count = *runs;
+        if (count == 0)
+            break;
+
+        int aa = *antialias;
+        if (aa == 0)
+        {
+            device += count;
+            runs += count;
+            antialias += count;
+            x += count;
+            continue;
+        }
+
+        int nonZeroCount = count + count_nonzero_span(runs + count, antialias + count);
+
+        shader->shadeSpan(x, y, span, nonZeroCount);
+        x += nonZeroCount;
+        SkPMColor* localSpan = span;
+        for (;;)
+        {
+            if (aa == 255)  // no antialiasing
+            {
+                if (opaque)
+                {
+                    for (int i = 0; i < count; i++)
+                        device[i] = SkPixel32ToPixel16_ToU16(localSpan[i]);
+                }
+                else
+                {
+                    for (int i = 0; i < count; i++)
+                    {
+                        SkPMColor src = localSpan[i];
+                        if (src)
+                        {
+                            unsigned srcA = SkGetPackedA32(src);
+                            if (srcA == 0xFF)
+                                device[i] = SkPixel32ToPixel16_ToU16(src);
+                            else
                                 device[i] = BLEND_32_TO_16(srcA, src, device[i]);
-                                               }
-                                       }
-                               }
-                       }
-                       else
-                       {
-                               for (int i = 0; i < count; i++)
-                               {
-                                       if (localSpan[i])
-                                               device[i] = aa_blendS32D16(localSpan[i], device[i], aa);
-                               }
-                       }
-
-                       device += count;
-                       runs += count;
-                       antialias += count;
-                       nonZeroCount -= count;
-                       if (nonZeroCount == 0)
-                               break;
-
-                       localSpan += count;
-                       SkASSERT(nonZeroCount > 0);
-                       count = *runs;
-                       SkASSERT(count > 0);
-                       aa = *antialias;
-               }
-       }
+                        }
+                    }
+                }
+            }
+            else
+            {
+                for (int i = 0; i < count; i++)
+                {
+                    if (localSpan[i])
+                        device[i] = aa_blendS32D16(localSpan[i], device[i], aa);
+                }
+            }
+
+            device += count;
+            runs += count;
+            antialias += count;
+            nonZeroCount -= count;
+            if (nonZeroCount == 0)
+                break;
+
+            localSpan += count;
+            SkASSERT(nonZeroCount > 0);
+            count = *runs;
+            SkASSERT(count > 0);
+            aa = *antialias;
+        }
+    }
 }
 
 ///////////////////////////////////////////////////////////////////////
 
 SkRGB16_Shader_Xfermode_Blitter::SkRGB16_Shader_Xfermode_Blitter(const SkBitmap& device, const SkPaint& paint) : fDevice(device)
 {
-       fShader = paint.getShader();
-       SkASSERT(fShader);
-       fShader->ref();
+    fShader = paint.getShader();
+    SkASSERT(fShader);
+    fShader->ref();
 
-       fXfermode = paint.getXfermode();
-       SkASSERT(fXfermode);
-       fXfermode->ref();
+    fXfermode = paint.getXfermode();
+    SkASSERT(fXfermode);
+    fXfermode->ref();
 
-       int width = device.width();
-       fBuffer = (SkPMColor*)sk_malloc_throw((width + (SkAlign4(width) >> 2)) * sizeof(SkPMColor));
-       fAAExpand = (U8*)(fBuffer + width);
+    int width = device.width();
+    fBuffer = (SkPMColor*)sk_malloc_throw((width + (SkAlign4(width) >> 2)) * sizeof(SkPMColor));
+    fAAExpand = (uint8_t*)(fBuffer + width);
 }
 
 SkRGB16_Shader_Xfermode_Blitter::~SkRGB16_Shader_Xfermode_Blitter()
 {
-       fXfermode->unref();
-       fShader->unref();
-       sk_free(fBuffer);
+    fXfermode->unref();
+    fShader->unref();
+    sk_free(fBuffer);
 }
 
 void SkRGB16_Shader_Xfermode_Blitter::blitH(int x, int y, int width)
 {
-       SkASSERT(x >= 0 && y >= 0 && (unsigned)(x + width) <= fDevice.width());
+    SkASSERT(x + width <= fDevice.width());
 
-       U16*            device = fDevice.getAddr16(x, y);
-       SkPMColor*      span = fBuffer;
+    uint16_t*   device = fDevice.getAddr16(x, y);
+    SkPMColor*  span = fBuffer;
 
-       fShader->shadeSpan(x, y, span, width);
-       fXfermode->xfer16(device, span, width, NULL);
+    fShader->shadeSpan(x, y, span, width);
+    fXfermode->xfer16(device, span, width, NULL);
 }
 
 void SkRGB16_Shader_Xfermode_Blitter::blitAntiH(int x, int y, const SkAlpha antialias[], const S16 runs[])
 {
-       SkASSERT(x >= 0 && y >= 0 && x < (int)fDevice.width() && y < (int)fDevice.height());
-
-       SkShader*       shader = fShader;
-       SkXfermode*     mode = fXfermode;
-       SkPMColor*      span = fBuffer;
-       U8*                     aaExpand = fAAExpand;
-       U16*            device = fDevice.getAddr16(x, y);
-
-       for (;;)
-       {
-               int     count = *runs;
-               if (count == 0)
-                       break;
-
-               int     aa = *antialias;
-               if (aa == 0)
-               {
-                       device += count;
-                       runs += count;
-                       antialias += count;
-                       x += count;
-                       continue;
-               }
-
-               int nonZeroCount = count + count_nonzero_span(runs + count, antialias + count);
-
-               shader->shadeSpan(x, y, span, nonZeroCount);
-               x += nonZeroCount;
-               SkPMColor* localSpan = span;
-               for (;;)
-               {
-                       if (aa == 0xFF)
-                               mode->xfer16(device, localSpan, count, NULL);
-                       else
-                       {
-                               SkASSERT(aa);
-                               memset(aaExpand, aa, count);
-                               mode->xfer16(device, localSpan, count, aaExpand);
-                       }
-                       device += count;
-                       runs += count;
-                       antialias += count;
-                       nonZeroCount -= count;
-                       if (nonZeroCount == 0)
-                               break;
-
-                       localSpan += count;
-                       SkASSERT(nonZeroCount > 0);
-                       count = *runs;
-                       SkASSERT(count > 0);
-                       aa = *antialias;
-               }
-       } 
+    SkShader*   shader = fShader;
+    SkXfermode* mode = fXfermode;
+    SkPMColor*  span = fBuffer;
+    uint8_t*    aaExpand = fAAExpand;
+    uint16_t*   device = fDevice.getAddr16(x, y);
+
+    for (;;)
+    {
+        int count = *runs;
+        if (count == 0)
+            break;
+
+        int aa = *antialias;
+        if (aa == 0)
+        {
+            device += count;
+            runs += count;
+            antialias += count;
+            x += count;
+            continue;
+        }
+
+        int nonZeroCount = count + count_nonzero_span(runs + count, antialias + count);
+
+        shader->shadeSpan(x, y, span, nonZeroCount);
+        x += nonZeroCount;
+        SkPMColor* localSpan = span;
+        for (;;)
+        {
+            if (aa == 0xFF)
+                mode->xfer16(device, localSpan, count, NULL);
+            else
+            {
+                SkASSERT(aa);
+                memset(aaExpand, aa, count);
+                mode->xfer16(device, localSpan, count, aaExpand);
+            }
+            device += count;
+            runs += count;
+            antialias += count;
+            nonZeroCount -= count;
+            if (nonZeroCount == 0)
+                break;
+
+            localSpan += count;
+            SkASSERT(nonZeroCount > 0);
+            count = *runs;
+            SkASSERT(count > 0);
+            aa = *antialias;
+        }
+    } 
 }
 
 
index a740e35..316c96d 100644 (file)
@@ -1,7 +1,24 @@
+/* libs/graphics/sgl/SkBlitter_Sprite.cpp
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #include "SkSpriteBlitter.h"
 
 SkSpriteBlitter::SkSpriteBlitter(const SkBitmap& source)
-       : fSource(&source)
+    : fSource(&source)
 {
 }
 
@@ -12,22 +29,22 @@ SkSpriteBlitter::~SkSpriteBlitter()
 #ifdef SK_DEBUG
 void SkSpriteBlitter::blitH(int x, int y, int width)
 {
-       SkASSERT(!"how did we get here?");
+    SkASSERT(!"how did we get here?");
 }
 
 void SkSpriteBlitter::blitAntiH(int x, int y, const SkAlpha antialias[], const S16 runs[])
 {
-       SkASSERT(!"how did we get here?");
+    SkASSERT(!"how did we get here?");
 }
 
 void SkSpriteBlitter::blitV(int x, int y, int height, SkAlpha alpha)
 {
-       SkASSERT(!"how did we get here?");
+    SkASSERT(!"how did we get here?");
 }
 
 void SkSpriteBlitter::blitMask(const SkMask&, const SkRect16& clip)
 {
-       SkASSERT(!"how did we get here?");
+    SkASSERT(!"how did we get here?");
 }
 #endif
 
@@ -36,38 +53,38 @@ void SkSpriteBlitter::blitMask(const SkMask&, const SkRect16& clip)
 
 // returning nil means the caller will call SkBlitter::Choose() and
 // have wrapped the source bitmap inside a shader
-SkBlitter* SkBlitter::ChooseSprite(    const SkBitmap& device,
-                                                                       const SkPaint& paint,
-                                                                       const SkBitmap& source,
-                                                                       int left, int top,
-                                                                       void* storage, size_t storageSize)
+SkBlitter* SkBlitter::ChooseSprite( const SkBitmap& device,
+                                    const SkPaint& paint,
+                                    const SkBitmap& source,
+                                    int left, int top,
+                                    void* storage, size_t storageSize)
 {
-       /*      We currently ignore antialiasing and filtertype, meaning we will take our
-               special blitters regardless of these settings. Ignoring filtertype seems fine
-               since by definition there is no scale in the matrix. Ignoring antialiasing is
-               a bit of a hack, since we "could" pass in the fractional left/top for the bitmap,
-               and respect that by blending the edges of the bitmap against the device. To support
-               this we could either add more special blitters here, or detect antialiasing in the
-               paint and return nil if it is set, forcing the client to take the slow shader case
-               (which does respect soft edges).
-       */
+    /*  We currently ignore antialiasing and filtertype, meaning we will take our
+        special blitters regardless of these settings. Ignoring filtertype seems fine
+        since by definition there is no scale in the matrix. Ignoring antialiasing is
+        a bit of a hack, since we "could" pass in the fractional left/top for the bitmap,
+        and respect that by blending the edges of the bitmap against the device. To support
+        this we could either add more special blitters here, or detect antialiasing in the
+        paint and return nil if it is set, forcing the client to take the slow shader case
+        (which does respect soft edges).
+    */
 
-       SkSpriteBlitter* blitter = nil;
-       SkXfermode*              mode = paint.getXfermode();
-       U8                               alpha = paint.getAlpha();
+    SkSpriteBlitter* blitter = nil;
+    SkXfermode*      mode = paint.getXfermode();
+    U8               alpha = paint.getAlpha();
 
-       switch (device.getConfig()) {
-       case SkBitmap::kRGB_565_Config:
-               blitter = SkSpriteBlitter::ChooseD16(source, mode, alpha, storage, storageSize);
+    switch (device.getConfig()) {
+    case SkBitmap::kRGB_565_Config:
+        blitter = SkSpriteBlitter::ChooseD16(source, mode, alpha, storage, storageSize);
+        break;
+    case SkBitmap::kARGB_8888_Config:
+        blitter = SkSpriteBlitter::ChooseD32(source, mode, alpha, storage, storageSize);
+    default:
         break;
-       case SkBitmap::kARGB_8888_Config:
-               blitter = SkSpriteBlitter::ChooseD32(source, mode, alpha, storage, storageSize);
-       default:
-               break;
-       }
+    }
 
-       if (blitter)
-               blitter->setup(device, left, top);
-       return blitter;
+    if (blitter)
+        blitter->setup(device, left, top);
+    return blitter;
 }
 
index 75cb7bd..fed80fa 100644 (file)
@@ -1,3 +1,20 @@
+/* libs/graphics/sgl/SkCanvas.cpp
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #include "SkCanvas.h"
 #include "SkDraw.h"
 #include "SkBounder.h"
@@ -15,13 +32,13 @@ struct SkCanvas::MCRec {
     MCRec*              fNext;
 
     SkMatrix            fMatrix;
-    SkMatrix::MapPtProc        fMapPtProc;
+    SkMatrix::MapPtProc fMapPtProc;
     SkRegion            fRegion;
 
     MCRecLayer*     fLayer;         // may be NULL
     const SkBitmap* fCurrBitmap;    // points to layer or prevLayer or pixels
 
-    uint8_t    fSetPaintBits;
+    uint8_t fSetPaintBits;
     uint8_t fClearPaintBits;
     
     MCRec() : fLayer(NULL)
@@ -44,30 +61,30 @@ struct SkCanvas::MCRec {
 
 class AutoPaintSetClear {
 public:
-       AutoPaintSetClear(const SkPaint& paint, U32 setBits, U32 clearBits) : fPaint(paint)
-       {
-               fFlags = paint.getFlags();
-               ((SkPaint*)&paint)->setFlags((fFlags | setBits) & ~clearBits);
-       }
-       ~AutoPaintSetClear()
-       {
-               ((SkPaint*)&fPaint)->setFlags(fFlags);
-       }
+    AutoPaintSetClear(const SkPaint& paint, U32 setBits, U32 clearBits) : fPaint(paint)
+    {
+        fFlags = paint.getFlags();
+        ((SkPaint*)&paint)->setFlags((fFlags | setBits) & ~clearBits);
+    }
+    ~AutoPaintSetClear()
+    {
+        ((SkPaint*)&fPaint)->setFlags(fFlags);
+    }
 private:
-       const SkPaint&  fPaint;
-       U32                             fFlags;
+    const SkPaint&  fPaint;
+    U32             fFlags;
 
-       // illegal
-       AutoPaintSetClear(const AutoPaintSetClear&);
-       AutoPaintSetClear& operator=(const AutoPaintSetClear&);
+    // illegal
+    AutoPaintSetClear(const AutoPaintSetClear&);
+    AutoPaintSetClear& operator=(const AutoPaintSetClear&);
 };
 
 class SkAutoBounderCommit {
 public:
-       SkAutoBounderCommit(SkBounder* bounder) : fBounder(bounder) {}
-       ~SkAutoBounderCommit() { if (fBounder) fBounder->commit(); }
+    SkAutoBounderCommit(SkBounder* bounder) : fBounder(bounder) {}
+    ~SkAutoBounderCommit() { if (fBounder) fBounder->commit(); }
 private:
-       SkBounder*      fBounder;
+    SkBounder*  fBounder;
 };
 
 ////////////////////////////////////////////////////////////////////////////
@@ -78,11 +95,11 @@ SkCanvas::SkCanvas()
     fMCRec = (MCRec*)fMCStack.push_back();
     new (fMCRec) MCRec;
 
-       fMCRec->fNext = NULL;
-       fMCRec->fMatrix.reset();
-       fMCRec->fSetPaintBits = 0;
-       fMCRec->fClearPaintBits = 0;
-       fMCRec->fMapPtProc = NULL;      // mark as dirty/unknown
+    fMCRec->fNext = NULL;
+    fMCRec->fMatrix.reset();
+    fMCRec->fSetPaintBits = 0;
+    fMCRec->fClearPaintBits = 0;
+    fMCRec->fMapPtProc = NULL;  // mark as dirty/unknown
 
     fMCRec->fLayer      = NULL;
     fMCRec->fCurrBitmap = &fBitmap;
@@ -94,11 +111,11 @@ SkCanvas::SkCanvas(const SkBitmap& bitmap)
     fMCRec = (MCRec*)fMCStack.push_back();
     new (fMCRec) MCRec;
     
-       fMCRec->fNext = NULL;
-       fMCRec->fMatrix.reset();
-       fMCRec->fSetPaintBits = 0;
-       fMCRec->fClearPaintBits = 0;
-       fMCRec->fMapPtProc = NULL;      // mark as dirty/unknown
+    fMCRec->fNext = NULL;
+    fMCRec->fMatrix.reset();
+    fMCRec->fSetPaintBits = 0;
+    fMCRec->fClearPaintBits = 0;
+    fMCRec->fMapPtProc = NULL;  // mark as dirty/unknown
     
     fMCRec->fRegion.setRect(0, 0, bitmap.width(), bitmap.height());
 
@@ -112,51 +129,51 @@ SkCanvas::~SkCanvas()
 
 SkBounder* SkCanvas::setBounder(SkBounder* bounder)
 {
-       SkRefCnt_SafeAssign(fBounder, bounder);
-       return bounder;
+    SkRefCnt_SafeAssign(fBounder, bounder);
+    return bounder;
 }
 
 void SkCanvas::getPixels(SkBitmap* bitmap) const
 {
-       if (bitmap)
-               *bitmap = fBitmap;
+    if (bitmap)
+        *bitmap = fBitmap;
 }
 
 void SkCanvas::setPixels(const SkBitmap& bitmap)
 {
-       unsigned        prevWidth = fBitmap.width();
-       unsigned        prevHeight = fBitmap.height();
+    int prevWidth = fBitmap.width();
+    int prevHeight = fBitmap.height();
 
-       fBitmap = bitmap;
+    fBitmap = bitmap;
 
-       /*      Now we update our initial region to have the bounds of the new bitmap,
-               and then intersect all of the clips in our stack with these bounds,
-               to ensure that we can't draw outside of the bitmap's bounds (and trash
-               memory).
+    /*  Now we update our initial region to have the bounds of the new bitmap,
+        and then intersect all of the clips in our stack with these bounds,
+        to ensure that we can't draw outside of the bitmap's bounds (and trash
+        memory).
 
-               NOTE: this is only a partial-fix, since if the new bitmap is larger than
-               the previous one, we don't know how to "enlarge" the clips in our stack,
-               so drawing may be artificially restricted. Without keeping a history of 
-               all calls to canvas->clipRect() and canvas->clipPath(), we can't exactly
-               reconstruct the correct clips, so this approximation will have to do.
-               The caller really needs to restore() back to the base if they want to
-               accurately take advantage of the new bitmap bounds.
-       */
+        NOTE: this is only a partial-fix, since if the new bitmap is larger than
+        the previous one, we don't know how to "enlarge" the clips in our stack,
+        so drawing may be artificially restricted. Without keeping a history of 
+        all calls to canvas->clipRect() and canvas->clipPath(), we can't exactly
+        reconstruct the correct clips, so this approximation will have to do.
+        The caller really needs to restore() back to the base if they want to
+        accurately take advantage of the new bitmap bounds.
+    */
 
-       if (prevWidth != bitmap.width() || prevHeight != bitmap.height())
-       {
-               SkRect16        r;
-               r.set(0, 0, bitmap.width(), bitmap.height());
+    if (prevWidth != bitmap.width() || prevHeight != bitmap.height())
+    {
+        SkRect16    r;
+        r.set(0, 0, bitmap.width(), bitmap.height());
 
         SkDeque::Iter   iter(fMCStack);
         MCRec*          rec = (MCRec*)iter.next();
         
         SkASSERT(rec);
-               rec->fRegion.setRect(r);
+        rec->fRegion.setRect(r);
 
         while ((rec = (MCRec*)iter.next()) != NULL)
-                       (void)rec->fRegion.op(r, SkRegion::kIntersect_Op);
-       }
+            (void)rec->fRegion.op(r, SkRegion::kIntersect_Op);
+    }
 }
 
 bool SkCanvas::isBitmapOpaque() const
@@ -170,24 +187,24 @@ bool SkCanvas::isBitmapOpaque() const
 
 U32 SkCanvas::getPaintSetBits() const
 {
-       return fMCRec->fSetPaintBits;
+    return fMCRec->fSetPaintBits;
 }
 
 U32 SkCanvas::getPaintClearBits() const
 {
-       return fMCRec->fClearPaintBits;
+    return fMCRec->fClearPaintBits;
 }
 
 void SkCanvas::setPaintSetClearBits(U32 setBits, U32 clearBits)
 {
-       fMCRec->fSetPaintBits = SkToU8(setBits & SkPaint::kAllFlagMasks);
-       fMCRec->fClearPaintBits = SkToU8(clearBits & SkPaint::kAllFlagMasks);
+    fMCRec->fSetPaintBits = SkToU8(setBits & SkPaint::kAllFlags);
+    fMCRec->fClearPaintBits = SkToU8(clearBits & SkPaint::kAllFlags);
 }
 
 void SkCanvas::orPaintSetClearBits(U32 setBits, U32 clearBits)
 {
-       fMCRec->fSetPaintBits |= setBits;
-       fMCRec->fClearPaintBits |= clearBits;
+    fMCRec->fSetPaintBits |= setBits;
+    fMCRec->fClearPaintBits |= clearBits;
 }
 
 /////////////////////////////////////////////////////////////////////////////
@@ -242,7 +259,7 @@ int SkCanvas::saveLayer(const SkRect& bounds, const SkPaint& paint)
 
 void SkCanvas::restore()
 {
-       SkASSERT(!fMCStack.empty());
+    SkASSERT(!fMCStack.empty());
 
     MCRecLayer*                 layer = fMCRec->fLayer;
     SkAutoTDelete<MCRecLayer>   ad(layer);
@@ -260,113 +277,131 @@ void SkCanvas::restore()
 
 int SkCanvas::getSaveCount() const
 {
-       return fMCStack.count();
+    return fMCStack.count();
 }
 
 void SkCanvas::restoreToCount(int count)
 {
-       SkASSERT(fMCStack.count() >= count);
+    SkASSERT(fMCStack.count() >= count);
 
-       while (fMCStack.count() > count)
-               this->restore();
-}
-
-void SkCanvas::clipDeviceRgn(const SkRegion& rgn)
-{
-       fMCRec->fRegion.op(rgn, SkRegion::kIntersect_Op);
+    while (fMCStack.count() > count)
+        this->restore();
 }
 
 /////////////////////////////////////////////////////////////////////////////
 
 bool SkCanvas::translate(SkScalar dx, SkScalar dy)
 {
-       fMCRec->fMapPtProc = NULL;      // mark as dirty/unknown
-       return fMCRec->fMatrix.preTranslate(dx, dy);
+    fMCRec->fMapPtProc = NULL;  // mark as dirty/unknown
+    return fMCRec->fMatrix.preTranslate(dx, dy);
 }
 
 bool SkCanvas::scale(SkScalar sx, SkScalar sy, SkScalar px, SkScalar py)
 {
-       fMCRec->fMapPtProc = NULL;      // mark as dirty/unknown
-       return fMCRec->fMatrix.preScale(sx, sy, px, py);
+    fMCRec->fMapPtProc = NULL;  // mark as dirty/unknown
+    return fMCRec->fMatrix.preScale(sx, sy, px, py);
+}
+
+bool SkCanvas::scale(SkScalar sx, SkScalar sy)
+{
+    fMCRec->fMapPtProc = NULL;  // mark as dirty/unknown
+    return fMCRec->fMatrix.preScale(sx, sy);
 }
 
 bool SkCanvas::rotate(SkScalar degrees, SkScalar px, SkScalar py)
 {
-       fMCRec->fMapPtProc = NULL;      // mark as dirty/unknown
-       return fMCRec->fMatrix.preRotate(degrees, px, py);
+    fMCRec->fMapPtProc = NULL;  // mark as dirty/unknown
+    return fMCRec->fMatrix.preRotate(degrees, px, py);
+}
+
+bool SkCanvas::rotate(SkScalar degrees)
+{
+    fMCRec->fMapPtProc = NULL;  // mark as dirty/unknown
+    return fMCRec->fMatrix.preRotate(degrees);
 }
 
 bool SkCanvas::skew(SkScalar sx, SkScalar sy, SkScalar px, SkScalar py)
 {
-       fMCRec->fMapPtProc = NULL;      // mark as dirty/unknown
-       return fMCRec->fMatrix.preSkew(sx, sy, px, py);
+    fMCRec->fMapPtProc = NULL;  // mark as dirty/unknown
+    return fMCRec->fMatrix.preSkew(sx, sy, px, py);
+}
+
+bool SkCanvas::skew(SkScalar sx, SkScalar sy)
+{
+    fMCRec->fMapPtProc = NULL;  // mark as dirty/unknown
+    return fMCRec->fMatrix.preSkew(sx, sy);
 }
 
 bool SkCanvas::concat(const SkMatrix& matrix)
 {
-       fMCRec->fMapPtProc = NULL;      // mark as dirty/unknown
-       return fMCRec->fMatrix.preConcat(matrix);
+    fMCRec->fMapPtProc = NULL;  // mark as dirty/unknown
+    return fMCRec->fMatrix.preConcat(matrix);
 }
 
 //////////////////////////////////////////////////////////////////////////////
 
-void SkCanvas::clipRect(const SkRect& rect)
+bool SkCanvas::clipRect(const SkRect& rect)
 {
-       if (fMCRec->fMatrix.rectStaysRect())
-       {
-               SkRect          r;
-               SkRect16        ir;
+    if (fMCRec->fMatrix.rectStaysRect())
+    {
+        SkRect      r;
+        SkRect16    ir;
 
-               fMCRec->fMatrix.mapRect(&r, rect);
-               r.round(&ir);
-               fMCRec->fRegion.op(ir, SkRegion::kIntersect_Op);
-       }
-       else
-       {
-               SkPath  path;
+        fMCRec->fMatrix.mapRect(&r, rect);
+        r.round(&ir);
+        return fMCRec->fRegion.op(ir, SkRegion::kIntersect_Op);
+    }
+    else
+    {
+        SkPath  path;
 
-               path.addRect(rect);
-               this->clipPath(path);
-       }
+        path.addRect(rect);
+        return this->clipPath(path);
+    }
 }
 
-void SkCanvas::clipRect(SkScalar left, SkScalar top, SkScalar right, SkScalar bottom)
+bool SkCanvas::clipRect(SkScalar left, SkScalar top, SkScalar right, SkScalar bottom)
 {
     SkRect  r;
     
     r.set(left, top, right, bottom);
-    this->clipRect(r);
+    return this->clipRect(r);
 }
 
-void SkCanvas::clipPath(const SkPath& path)
+bool SkCanvas::clipPath(const SkPath& path)
 {
-       SkPath  devPath;
+    SkPath  devPath;
 
-       path.transform(fMCRec->fMatrix, &devPath);
-       fMCRec->fRegion.setPath(devPath, &fMCRec->fRegion);
+    path.transform(fMCRec->fMatrix, &devPath);
+    return fMCRec->fRegion.setPath(devPath, &fMCRec->fRegion);
+}
+
+bool SkCanvas::clipDeviceRgn(const SkRegion& rgn)
+{
+    return fMCRec->fRegion.op(rgn, SkRegion::kIntersect_Op);
 }
 
 bool SkCanvas::quickReject(const SkRect& rect, bool antialiased) const
 {
-       if (fMCRec->fRegion.isEmpty() || rect.isEmpty())
-               return true;
+    if (fMCRec->fRegion.isEmpty() || rect.isEmpty())
+        return true;
 
-       SkRect          r;
-       SkRect16        ir;
+    SkRect      r;
+    SkRect16    ir;
 
-       fMCRec->fMatrix.mapRect(&r, rect);
+    fMCRec->fMatrix.mapRect(&r, rect);
     if (antialiased)
         r.roundOut(&ir);
     else
         r.round(&ir);
 
-       return fMCRec->fRegion.quickReject(ir);
+    return fMCRec->fRegion.quickReject(ir);
 }
 
 bool SkCanvas::quickReject(const SkPath& path, bool antialiased) const
 {
-       if (fMCRec->fRegion.isEmpty() || path.isEmpty())
-               return true;        
+    if (fMCRec->fRegion.isEmpty() || path.isEmpty())
+        return true;        
 
     if (fMCRec->fMatrix.rectStaysRect())
     {
@@ -376,8 +411,8 @@ bool SkCanvas::quickReject(const SkPath& path, bool antialiased) const
     }
 
     SkPath      dstPath;
-       SkRect          r;
-       SkRect16        ir;
+    SkRect      r;
+    SkRect16    ir;
 
     path.transform(fMCRec->fMatrix, &dstPath);
     dstPath.computeBounds(&r, SkPath::kExact_BoundsType);
@@ -386,83 +421,72 @@ bool SkCanvas::quickReject(const SkPath& path, bool antialiased) const
     else
         r.round(&ir);
 
-       return fMCRec->fRegion.quickReject(ir);
+    return fMCRec->fRegion.quickReject(ir);
 }
 
 //////////////////////////////////////////////////////////////////////////////
 
 void SkCanvas::drawRGB(U8CPU r, U8CPU g, U8CPU b)
 {
-       SkPaint paint;
+    SkPaint paint;
 
-       paint.setARGB(0xFF, r, g, b);
-       this->drawPaint(paint);
+    paint.setARGB(0xFF, r, g, b);
+    this->drawPaint(paint);
 }
 
 void SkCanvas::drawARGB(U8CPU a, U8CPU r, U8CPU g, U8CPU b)
 {
-       SkPaint paint;
+    SkPaint paint;
 
-       paint.setARGB(a, r, g, b);
-       this->drawPaint(paint);
+    paint.setARGB(a, r, g, b);
+    this->drawPaint(paint);
 }
 
 void SkCanvas::drawColor(SkColor c, SkPorterDuff::Mode mode)
 {
-       SkPaint paint;
+    SkPaint paint;
 
-       paint.setColor(c);
+    paint.setColor(c);
     paint.setPorterDuffXfermode(mode);
-       this->drawPaint(paint);
+    this->drawPaint(paint);
 }
 
 void SkCanvas::drawPaint(const SkPaint& paint)
 {
-       SkAutoBounderCommit     ac(fBounder);
-       SkDraw                          draw(*this);
+    SkAutoBounderCommit ac(fBounder);
+    SkDraw              draw(*this);
 
-       draw.drawPaint(paint);
+    draw.drawPaint(paint);
 }
 
 void SkCanvas::drawLine(const SkPoint& start, const SkPoint& stop, const SkPaint& paint)
 {
-       AutoPaintSetClear       force(paint, fMCRec->fSetPaintBits, fMCRec->fClearPaintBits);
-       SkAutoBounderCommit     ac(fBounder);
-       SkDraw                          draw(*this);
+    AutoPaintSetClear   force(paint, fMCRec->fSetPaintBits, fMCRec->fClearPaintBits);
+    SkAutoBounderCommit ac(fBounder);
+    SkDraw              draw(*this);
 
-       draw.drawLine(start, stop, paint);
+    draw.drawLine(start, stop, paint);
 }
 
 void SkCanvas::drawLine(SkScalar x0, SkScalar y0, SkScalar x1, SkScalar y1, const SkPaint& paint)
 {
-       AutoPaintSetClear       force(paint, fMCRec->fSetPaintBits, fMCRec->fClearPaintBits);
-       SkAutoBounderCommit     ac(fBounder);
-       SkDraw                          draw(*this);
+    AutoPaintSetClear   force(paint, fMCRec->fSetPaintBits, fMCRec->fClearPaintBits);
+    SkAutoBounderCommit ac(fBounder);
+    SkDraw              draw(*this);
 
-       SkPoint pts[2];
-       pts[0].set(x0, y0);
-       pts[1].set(x1, y1);
-       draw.drawLine(pts[0], pts[1], paint);
+    SkPoint pts[2];
+    pts[0].set(x0, y0);
+    pts[1].set(x1, y1);
+    draw.drawLine(pts[0], pts[1], paint);
 }
 
-//#include <stdio.h>
-
 void SkCanvas::drawRect(const SkRect& r, const SkPaint& paint)
 {
-       AutoPaintSetClear       force(paint, fMCRec->fSetPaintBits, fMCRec->fClearPaintBits);
-       SkAutoBounderCommit     ac(fBounder);
-       SkDraw                          draw(*this);
+    AutoPaintSetClear   force(paint, fMCRec->fSetPaintBits, fMCRec->fClearPaintBits);
+    SkAutoBounderCommit ac(fBounder);
+    SkDraw              draw(*this);
 
-#if 0
-    const SkScalar* m = (const SkScalar*)draw.fMatrix;
-printf("drawRect(%g %g %g %g) matrix(%g %g %g %g %g %g)\n",
-        SkScalarToFloat(r.fLeft), SkScalarToFloat(r.fTop), SkScalarToFloat(r.fRight), SkScalarToFloat(r.fBottom),
-        SkScalarToFloat(m[0]), SkScalarToFloat(m[1]), SkScalarToFloat(m[2]), 
-        SkScalarToFloat(m[3]), SkScalarToFloat(m[4]), SkScalarToFloat(m[5]),
-        SkScalarToFloat(m[6]), SkScalarToFloat(m[7]), SkScalarToFloat(m[8]));
-#endif
-
-       draw.drawRect(r, paint);
+    draw.drawRect(r, paint);
 }
 
 void SkCanvas::drawRect(SkScalar left, SkScalar top, SkScalar right, SkScalar bottom, const SkPaint& paint)
@@ -475,56 +499,68 @@ void SkCanvas::drawRect(SkScalar left, SkScalar top, SkScalar right, SkScalar bo
 
 void SkCanvas::drawOval(const SkRect& oval, const SkPaint& paint)
 {
-       AutoPaintSetClear       force(paint, fMCRec->fSetPaintBits, fMCRec->fClearPaintBits);
-       SkAutoBounderCommit     ac(fBounder);
-       SkDraw                          draw(*this);
+    AutoPaintSetClear   force(paint, fMCRec->fSetPaintBits, fMCRec->fClearPaintBits);
+    SkAutoBounderCommit ac(fBounder);
+    SkDraw              draw(*this);
 
-       SkPath  path;
+    SkPath  path;
 
-       path.addOval(oval);
-       draw.drawPath(path, paint, NULL, true);
+    path.addOval(oval);
+    draw.drawPath(path, paint, NULL, true);
 }
 
 void SkCanvas::drawCircle(SkScalar cx, SkScalar cy, SkScalar radius, const SkPaint& paint)
 {
-       AutoPaintSetClear       force(paint, fMCRec->fSetPaintBits, fMCRec->fClearPaintBits);
-       SkAutoBounderCommit     ac(fBounder);
-       SkDraw                          draw(*this);
+    AutoPaintSetClear   force(paint, fMCRec->fSetPaintBits, fMCRec->fClearPaintBits);
+    SkAutoBounderCommit ac(fBounder);
+    SkDraw              draw(*this);
 
-       SkPath  path;
+    SkPath  path;
 
-       path.addCircle(cx, cy, radius);
-       draw.drawPath(path, paint, NULL, true);
+    path.addCircle(cx, cy, radius);
+    draw.drawPath(path, paint, NULL, true);
+}
+
+void SkCanvas::drawArc(const SkRect& oval, SkScalar startAngle, SkScalar sweepAngle, const SkPaint& paint)
+{
+    AutoPaintSetClear   force(paint, fMCRec->fSetPaintBits, fMCRec->fClearPaintBits);
+    SkAutoBounderCommit ac(fBounder);
+    SkDraw              draw(*this);
+
+    SkPath  path;
+
+    path.addArc(oval, startAngle, sweepAngle);
+    draw.drawPath(path, paint, NULL, true);
 }
 
 void SkCanvas::drawRoundRect(const SkRect& r, SkScalar rx, SkScalar ry, const SkPaint& paint)
 {
-       AutoPaintSetClear       force(paint, fMCRec->fSetPaintBits, fMCRec->fClearPaintBits);
-       SkAutoBounderCommit     ac(fBounder);
-       SkDraw                          draw(*this);
+    AutoPaintSetClear   force(paint, fMCRec->fSetPaintBits, fMCRec->fClearPaintBits);
+    SkAutoBounderCommit ac(fBounder);
+    SkDraw              draw(*this);
 
-       SkPath  path;
+    SkPath  path;
 
-       path.addRoundRect(r, rx, ry, SkPath::kCW_Direction);
-       draw.drawPath(path, paint, NULL, true);
+    path.addRoundRect(r, rx, ry, SkPath::kCW_Direction);
+    draw.drawPath(path, paint, NULL, true);
 }
 
 void SkCanvas::drawPath(const SkPath& path, const SkPaint& paint)
 {
-       AutoPaintSetClear       force(paint, fMCRec->fSetPaintBits, fMCRec->fClearPaintBits);
-       SkAutoBounderCommit     ac(fBounder);
-       SkDraw                          draw(*this);
+    AutoPaintSetClear   force(paint, fMCRec->fSetPaintBits, fMCRec->fClearPaintBits);
+    SkAutoBounderCommit ac(fBounder);
+    SkDraw              draw(*this);
 
-       draw.drawPath(path, paint, NULL, false);
+    draw.drawPath(path, paint, NULL, false);
 }
 
 void SkCanvas::drawBitmap(const SkBitmap& bitmap, SkScalar x, SkScalar y, const SkPaint& paint)
 {
-       AutoPaintSetClear       force(paint, fMCRec->fSetPaintBits, fMCRec->fClearPaintBits);
-       SkAutoBounderCommit     ac(fBounder);
-       SkDraw                          draw(*this);
+    AutoPaintSetClear   force(paint, fMCRec->fSetPaintBits, fMCRec->fClearPaintBits);
+    SkAutoBounderCommit ac(fBounder);
+    SkDraw              draw(*this);
 
-       draw.drawBitmap(bitmap, x, y, paint);
+    draw.drawBitmap(bitmap, x, y, paint);
 }
 
 void SkCanvas::drawBitmap(const SkBitmap& bitmap, SkScalar x, SkScalar y)
@@ -535,65 +571,38 @@ void SkCanvas::drawBitmap(const SkBitmap& bitmap, SkScalar x, SkScalar y)
 
 void SkCanvas::drawSprite(const SkBitmap& bitmap, int x, int y, const SkPaint& paint)
 {
-       AutoPaintSetClear       force(paint, fMCRec->fSetPaintBits, fMCRec->fClearPaintBits);
-       SkAutoBounderCommit     ac(fBounder);
-       SkDraw                          draw(*this);
-
-       draw.drawSprite(bitmap, x, y, paint);
-}
-
-void SkCanvas::drawText(const char text[], size_t byteLength, SkScalar x, SkScalar y, const SkPaint& paint)
-{
-       AutoPaintSetClear       force(paint, fMCRec->fSetPaintBits, fMCRec->fClearPaintBits);
-       SkAutoBounderCommit     ac(fBounder);
-       SkDraw                          draw(*this);
-
-       draw.drawText((SkUnicodeWalkerProc)SkUTF8_NextUnichar, text, byteLength, x, y, paint);
-}
-
-void SkCanvas::drawText16(const U16 text[], size_t numberOf16BitValues, SkScalar x, SkScalar y, const SkPaint& paint)
-{
-       AutoPaintSetClear       force(paint, fMCRec->fSetPaintBits, fMCRec->fClearPaintBits);
-       SkAutoBounderCommit     ac(fBounder);
-       SkDraw                          draw(*this);
-
-       draw.drawText((SkUnicodeWalkerProc)SkUTF16_NextUnichar, (const char*)text, numberOf16BitValues << 1, x, y, paint);
-}
-
-void SkCanvas::drawPosText(const char text[], size_t byteLength, const SkPoint pos[], const SkPaint& paint)
-{
-       AutoPaintSetClear       force(paint, fMCRec->fSetPaintBits, fMCRec->fClearPaintBits);
-       SkAutoBounderCommit     ac(fBounder);
-       SkDraw                          draw(*this);
+    AutoPaintSetClear   force(paint, fMCRec->fSetPaintBits, fMCRec->fClearPaintBits);
+    SkAutoBounderCommit ac(fBounder);
+    SkDraw              draw(*this);
 
-       draw.drawPosText((SkUnicodeWalkerProc)SkUTF8_NextUnichar, text, byteLength, pos, paint);
+    draw.drawSprite(bitmap, x, y, paint);
 }
 
-void SkCanvas::drawPosText16(const U16 text[], size_t numberOf16BitValues, const SkPoint pos[], const SkPaint& paint)
+void SkCanvas::drawText(const void* text, size_t byteLength, SkScalar x, SkScalar y, const SkPaint& paint)
 {
-       AutoPaintSetClear       force(paint, fMCRec->fSetPaintBits, fMCRec->fClearPaintBits);
-       SkAutoBounderCommit     ac(fBounder);
-       SkDraw                          draw(*this);
+    AutoPaintSetClear   force(paint, fMCRec->fSetPaintBits, fMCRec->fClearPaintBits);
+    SkAutoBounderCommit ac(fBounder);
+    SkDraw              draw(*this);
 
-       draw.drawPosText((SkUnicodeWalkerProc)SkUTF16_NextUnichar, (const char*)text, numberOf16BitValues << 1, pos, paint);
+    draw.drawText((const char*)text, byteLength, x, y, paint);
 }
 
-void SkCanvas::drawTextOnPath(const char text[], size_t byteLength, const SkPath& path, SkScalar offset, const SkPaint& paint)
+void SkCanvas::drawPosText(const void* text, size_t byteLength, const SkPoint pos[], const SkPaint& paint)
 {
-       AutoPaintSetClear       force(paint, fMCRec->fSetPaintBits, fMCRec->fClearPaintBits);
-       SkAutoBounderCommit     ac(fBounder);
-       SkDraw                          draw(*this);
+    AutoPaintSetClear   force(paint, fMCRec->fSetPaintBits, fMCRec->fClearPaintBits);
+    SkAutoBounderCommit ac(fBounder);
+    SkDraw              draw(*this);
 
-       draw.drawTextOnPath((SkUnicodeWalkerProc)SkUTF8_NextUnichar, text, byteLength, path, offset, paint);
+    draw.drawPosText((const char*)text, byteLength, pos, paint);
 }
 
-void SkCanvas::drawText16OnPath(const U16 text[], size_t numberOf16BitValues, const SkPath& path, SkScalar offset, const SkPaint& paint)
+void SkCanvas::drawTextOnPath(const void* text, size_t byteLength, const SkPath& path, SkScalar offset, const SkPaint& paint)
 {
-       AutoPaintSetClear       force(paint, fMCRec->fSetPaintBits, fMCRec->fClearPaintBits);
-       SkAutoBounderCommit     ac(fBounder);
-       SkDraw                          draw(*this);
+    AutoPaintSetClear   force(paint, fMCRec->fSetPaintBits, fMCRec->fClearPaintBits);
+    SkAutoBounderCommit ac(fBounder);
+    SkDraw              draw(*this);
 
-       draw.drawTextOnPath((SkUnicodeWalkerProc)SkUTF16_NextUnichar, (const char*)text, numberOf16BitValues << 1, path, offset, paint);
+    draw.drawTextOnPath((const char*)text, byteLength, path, offset, paint);
 }
 
 //////////////////////////////////////////////////////////////////////////////////////////////////////////
index 3831c57..4f4c490 100644 (file)
@@ -1,26 +1,43 @@
+/* libs/graphics/sgl/SkColor.cpp
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #include "SkColor.h"
 #include "SkColorPriv.h"
 
 SkPMColor SkPreMultiplyARGB(U8CPU a, U8CPU r, U8CPU g, U8CPU b)
 {
-       if (a != 255)
-       {
-               unsigned scale = SkAlpha255To256(a);
-               r = SkAlphaMul(r, scale);
-               g = SkAlphaMul(g, scale);
-               b = SkAlphaMul(b, scale);
-       }
-       return SkPackARGB32(a, r, g, b);
+    if (a != 255)
+    {
+        unsigned scale = SkAlpha255To256(a);
+        r = SkAlphaMul(r, scale);
+        g = SkAlphaMul(g, scale);
+        b = SkAlphaMul(b, scale);
+    }
+    return SkPackARGB32(a, r, g, b);
 }
 
 SkPMColor SkPreMultiplyColor(SkColor c)
 {
-       unsigned a = SkColorGetA(c);
-       unsigned r = SkColorGetR(c);
-       unsigned g = SkColorGetG(c);
-       unsigned b = SkColorGetB(c);
+    unsigned a = SkColorGetA(c);
+    unsigned r = SkColorGetR(c);
+    unsigned g = SkColorGetG(c);
+    unsigned b = SkColorGetB(c);
 
-       return SkPreMultiplyARGB(a, r, g, b);
+    return SkPreMultiplyARGB(a, r, g, b);
 }
 
 //////////////////////////////////////////////////////////////////////////////////////////////
index dc89eb4..a569944 100644 (file)
@@ -1,9 +1,28 @@
+/* libs/graphics/sgl/SkColorFilter.cpp
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #include "SkColorFilter.h"
 #include "SkShader.h"
 
 void SkColorFilter::filterSpan(const SkPMColor src[], int count, SkPMColor result[])
 {
-    memcpy(result, src, count * sizeof(SkPMColor));
+    if (result != src) {
+        memcpy(result, src, count * sizeof(SkPMColor));
+    }
 }
 
 //////////////////////////////////////////////////////////////////////////////////////
index 2904a8f..a274a55 100644 (file)
+/* libs/graphics/sgl/SkColorTable.cpp
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #include "SkBitmap.h"
 #include "SkTemplates.h"
 
 SkColorTable::SkColorTable() : fColors(nil), f16BitCache(nil), fCount(0), fFlags(0)
 {
-       SkDEBUGCODE(fColorLockCount = 0;)
-       SkDEBUGCODE(f16BitCacheLockCount = 0;)
+    SkDEBUGCODE(fColorLockCount = 0;)
+    SkDEBUGCODE(f16BitCacheLockCount = 0;)
 }
 
 SkColorTable::~SkColorTable()
 {
-       SkASSERT(fColorLockCount == 0);
-       SkASSERT(f16BitCacheLockCount == 0);
+    SkASSERT(fColorLockCount == 0);
+    SkASSERT(f16BitCacheLockCount == 0);
 
-       sk_free(fColors);
-       sk_free(f16BitCache);
+    sk_free(fColors);
+    sk_free(f16BitCache);
 }
 
 void SkColorTable::setFlags(unsigned flags)
 {
-       fFlags = SkToU8(flags);
+    fFlags = SkToU8(flags);
 }
 
 void SkColorTable::setColors(const SkPMColor src[], int count)
 {
-       SkASSERT(fColorLockCount == 0);
-       SkASSERT((unsigned)count <= 256);
-
-       if (fCount != count)
-       {
-               if (count == 0)
-               {
-                       sk_free(fColors);
-                       fColors = nil;
-               }
-               else
-               {
-                       // allocate new array before freeing old, in case the alloc fails (throws)
-                       SkPMColor* table = (SkPMColor*)sk_malloc_throw(count * sizeof(SkPMColor));
-                       sk_free(fColors);
-                       fColors = table;
-
-                       if (src)
-                               memcpy(fColors, src, count * sizeof(SkPMColor));
-               }
-               fCount = SkToU16(count);
-       }
-       else
-       {
-               if (src)
-                       memcpy(fColors, src, count * sizeof(SkPMColor));
-       }
-
-       this->inval16BitCache();
+    SkASSERT(fColorLockCount == 0);
+    SkASSERT((unsigned)count <= 256);
+
+    if (fCount != count)
+    {
+        if (count == 0)
+        {
+            sk_free(fColors);
+            fColors = nil;
+        }
+        else
+        {
+            // allocate new array before freeing old, in case the alloc fails (throws)
+            SkPMColor* table = (SkPMColor*)sk_malloc_throw(count * sizeof(SkPMColor));
+            sk_free(fColors);
+            fColors = table;
+
+            if (src)
+                memcpy(fColors, src, count * sizeof(SkPMColor));
+        }
+        fCount = SkToU16(count);
+    }
+    else
+    {
+        if (src)
+            memcpy(fColors, src, count * sizeof(SkPMColor));
+    }
+
+    this->inval16BitCache();
 }
 
 void SkColorTable::inval16BitCache()
 {
-       SkASSERT(f16BitCacheLockCount == 0);
-       if (f16BitCache)
-       {
-               sk_free(f16BitCache);
-               f16BitCache = nil;
-       }
+    SkASSERT(f16BitCacheLockCount == 0);
+    if (f16BitCache)
+    {
+        sk_free(f16BitCache);
+        f16BitCache = nil;
+    }
 }
 
 #include "SkColorPriv.h"
 
 static inline void build_16bitcache(U16 dst[], const SkPMColor src[], int count)
 {
-       while (--count >= 0)
-               *dst++ = SkPixel32ToPixel16_ToU16(*src++);
+    while (--count >= 0)
+        *dst++ = SkPixel32ToPixel16_ToU16(*src++);
 }
 
 const U16* SkColorTable::lock16BitCache()
 {
-       if (fFlags & kColorsAreOpaque_Flag)
-       {
-               if (f16BitCache == nil) // build the cache
-               {
-                       f16BitCache = (U16*)sk_malloc_throw(fCount * sizeof(U16));
-                       build_16bitcache(f16BitCache, fColors, fCount);
-               }
-       }
-       else    // our colors have alpha, so no cache
-       {
-               this->inval16BitCache();
-               if (f16BitCache)
-               {
-                       sk_free(f16BitCache);
-                       f16BitCache = nil;
-               }
-       }
-
-       SkDEBUGCODE(f16BitCacheLockCount += 1);
-       return f16BitCache;
+    if (fFlags & kColorsAreOpaque_Flag)
+    {
+        if (f16BitCache == nil) // build the cache
+        {
+            f16BitCache = (U16*)sk_malloc_throw(fCount * sizeof(U16));
+            build_16bitcache(f16BitCache, fColors, fCount);
+        }
+    }
+    else    // our colors have alpha, so no cache
+    {
+        this->inval16BitCache();
+        if (f16BitCache)
+        {
+            sk_free(f16BitCache);
+            f16BitCache = nil;
+        }
+    }
+
+    SkDEBUGCODE(f16BitCacheLockCount += 1);
+    return f16BitCache;
 }
 
 
index ebf339a..e8a4af6 100644 (file)
@@ -1,3 +1,20 @@
+/* libs/graphics/sgl/SkCoreBlitters.h
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #ifndef SkCoreBlitters_DEFINED
 #define SkCoreBlitters_DEFINED
 
 
 class SkA8_Blitter : public SkBlitter {
 public:
-       SkA8_Blitter(const SkBitmap& device, const SkPaint& paint);
-       virtual void blitH(int x, int y, int width);
-       virtual void blitAntiH(int x, int y, const SkAlpha antialias[], const S16 runs[]);
-       virtual void blitV(int x, int y, int height, SkAlpha alpha);
-       virtual void blitRect(int x, int y, int width, int height);
-       virtual void blitMask(const SkMask&, const SkRect16&);
+    SkA8_Blitter(const SkBitmap& device, const SkPaint& paint);
+    virtual void blitH(int x, int y, int width);
+    virtual void blitAntiH(int x, int y, const SkAlpha antialias[], const S16 runs[]);
+    virtual void blitV(int x, int y, int height, SkAlpha alpha);
+    virtual void blitRect(int x, int y, int width, int height);
+    virtual void blitMask(const SkMask&, const SkRect16&);
 
 private:
-       const SkBitmap& fDevice;
-       unsigned                fSrcA;
+    const SkBitmap& fDevice;
+    unsigned        fSrcA;
 
-       // illegal
-       SkA8_Blitter& operator=(const SkA8_Blitter&);
+    // illegal
+    SkA8_Blitter& operator=(const SkA8_Blitter&);
 };
 
 class SkA8_Shader_Blitter : public SkBlitter {
 public:
-       SkA8_Shader_Blitter(const SkBitmap& device, const SkPaint& paint);
-       virtual ~SkA8_Shader_Blitter();
-       virtual void blitH(int x, int y, int width);
-       virtual void blitAntiH(int x, int y, const SkAlpha antialias[], const S16 runs[]);
-       virtual void blitMask(const SkMask&, const SkRect16&);
+    SkA8_Shader_Blitter(const SkBitmap& device, const SkPaint& paint);
+    virtual ~SkA8_Shader_Blitter();
+    virtual void blitH(int x, int y, int width);
+    virtual void blitAntiH(int x, int y, const SkAlpha antialias[], const S16 runs[]);
+    virtual void blitMask(const SkMask&, const SkRect16&);
 
 private:
-       const SkBitmap& fDevice;
-       SkShader*       fShader;
-       SkXfermode*     fXfermode;
-       SkPMColor*      fBuffer;
-       U8*                     fAAExpand;
+    const SkBitmap& fDevice;
+    SkShader*   fShader;
+    SkXfermode* fXfermode;
+    SkPMColor*  fBuffer;
+    uint8_t*    fAAExpand;
 
     typedef SkBlitter INHERITED;
 
-       // illegal
-       SkA8_Shader_Blitter& operator=(const SkA8_Shader_Blitter&);
+    // illegal
+    SkA8_Shader_Blitter& operator=(const SkA8_Shader_Blitter&);
 };
 
 ////////////////////////////////////////////////////////////////
 
 class SkARGB32_Blitter : public SkBlitter {
 public:
-       SkARGB32_Blitter(const SkBitmap& device, const SkPaint& paint);
-       virtual void blitH(int x, int y, int width);
-       virtual void blitAntiH(int x, int y, const SkAlpha antialias[], const S16 runs[]);
-       virtual void blitV(int x, int y, int height, SkAlpha alpha);
-       virtual void blitRect(int x, int y, int width, int height);
-       virtual void blitMask(const SkMask&, const SkRect16&);
+    SkARGB32_Blitter(const SkBitmap& device, const SkPaint& paint);
+    virtual void blitH(int x, int y, int width);
+    virtual void blitAntiH(int x, int y, const SkAlpha antialias[], const S16 runs[]);
+    virtual void blitV(int x, int y, int height, SkAlpha alpha);
+    virtual void blitRect(int x, int y, int width, int height);
+    virtual void blitMask(const SkMask&, const SkRect16&);
 
 protected:
-       const SkBitmap& fDevice;
+    const SkBitmap& fDevice;
 
 private:
-       SkColor         fPMColor;
-       unsigned        fSrcA, fSrcR, fSrcG, fSrcB;
+    SkColor     fPMColor;
+    unsigned    fSrcA, fSrcR, fSrcG, fSrcB;
 
-       // illegal
-       SkARGB32_Blitter& operator=(const SkARGB32_Blitter&);
+    // illegal
+    SkARGB32_Blitter& operator=(const SkARGB32_Blitter&);
 };
 
 class SkARGB32_Black_Blitter : public SkARGB32_Blitter {
 public:
-       SkARGB32_Black_Blitter(const SkBitmap& device, const SkPaint& paint)
-               : SkARGB32_Blitter(device, paint) {}
-       virtual void blitMask(const SkMask&, const SkRect16&);
+    SkARGB32_Black_Blitter(const SkBitmap& device, const SkPaint& paint)
+        : SkARGB32_Blitter(device, paint) {}
+    virtual void blitMask(const SkMask&, const SkRect16&);
 };
 
 class SkARGB32_Shader_Blitter : public SkBlitter {
 public:
-       SkARGB32_Shader_Blitter(const SkBitmap& device, const SkPaint& paint);
-       virtual ~SkARGB32_Shader_Blitter();
-       virtual void blitH(int x, int y, int width);
-       virtual void blitAntiH(int x, int y, const SkAlpha antialias[], const S16 runs[]);
+    SkARGB32_Shader_Blitter(const SkBitmap& device, const SkPaint& paint);
+    virtual ~SkARGB32_Shader_Blitter();
+    virtual void blitH(int x, int y, int width);
+    virtual void blitAntiH(int x, int y, const SkAlpha antialias[], const S16 runs[]);
 
 private:
-       const SkBitmap& fDevice;
-       SkShader*       fShader;
-       SkXfermode*     fXfermode;
-       SkPMColor*      fBuffer;
+    const SkBitmap& fDevice;
+    SkShader*   fShader;
+    SkXfermode* fXfermode;
+    SkPMColor*  fBuffer;
 
-       typedef SkBlitter INHERITED;
+    typedef SkBlitter INHERITED;
 
-       // illegal
-       SkARGB32_Shader_Blitter& operator=(const SkARGB32_Shader_Blitter&);
+    // illegal
+    SkARGB32_Shader_Blitter& operator=(const SkARGB32_Shader_Blitter&);
 };
 
 ////////////////////////////////////////////////////////////////
 
 class SkRGB16_Blitter : public SkBlitter {
 public:
-       SkRGB16_Blitter(const SkBitmap& device, const SkPaint& paint);
-       virtual void blitH(int x, int y, int width);
-       virtual void blitAntiH(int x, int y, const SkAlpha antialias[], const S16 runs[]);
-       virtual void blitV(int x, int y, int height, SkAlpha alpha);
-       virtual void blitRect(int x, int y, int width, int height);
-       virtual void blitMask(const SkMask&, const SkRect16&);
+    SkRGB16_Blitter(const SkBitmap& device, const SkPaint& paint);
+    virtual void blitH(int x, int y, int width);
+    virtual void blitAntiH(int x, int y, const SkAlpha antialias[], const S16 runs[]);
+    virtual void blitV(int x, int y, int height, SkAlpha alpha);
+    virtual void blitRect(int x, int y, int width, int height);
+    virtual void blitMask(const SkMask&, const SkRect16&);
 
 protected:
-       const SkBitmap& fDevice;
+    const SkBitmap& fDevice;
 
 private:
-       unsigned        fScale;
-       U16                     fColor16;
-       U16                     fRawColor16;
+    unsigned    fScale;
+    U16         fColor16;
+    U16         fRawColor16;
 
-       // illegal
-       SkRGB16_Blitter& operator=(const SkRGB16_Blitter&);
+    // illegal
+    SkRGB16_Blitter& operator=(const SkRGB16_Blitter&);
 };
 
 class SkRGB16_Black_Blitter : public SkRGB16_Blitter {
 public:
-       SkRGB16_Black_Blitter(const SkBitmap& device, const SkPaint& paint)
-               : SkRGB16_Blitter(device, paint) {}
-       virtual void blitMask(const SkMask&, const SkRect16&);
+    SkRGB16_Black_Blitter(const SkBitmap& device, const SkPaint& paint)
+        : SkRGB16_Blitter(device, paint) {}
+    virtual void blitMask(const SkMask&, const SkRect16&);
 };
 
 class SkRGB16_Shader_Blitter : public SkBlitter {
 public:
-       SkRGB16_Shader_Blitter(const SkBitmap& device, const SkPaint& paint);
-       virtual ~SkRGB16_Shader_Blitter();
-       virtual void blitH(int x, int y, int width);
-       virtual void blitAntiH(int x, int y, const SkAlpha antialias[], const S16 runs[]);
+    SkRGB16_Shader_Blitter(const SkBitmap& device, const SkPaint& paint);
+    virtual ~SkRGB16_Shader_Blitter();
+    virtual void blitH(int x, int y, int width);
+    virtual void blitAntiH(int x, int y, const SkAlpha antialias[], const S16 runs[]);
 
 private:
-       const SkBitmap& fDevice;
-       SkShader*       fShader;
-       SkPMColor*      fBuffer;
+    const SkBitmap& fDevice;
+    SkShader*   fShader;
+    SkPMColor*  fBuffer;
 
-       typedef SkBlitter INHERITED;
+    typedef SkBlitter INHERITED;
 
-       // illegal
-       SkRGB16_Shader_Blitter& operator=(const SkRGB16_Shader_Blitter&);
+    // illegal
+    SkRGB16_Shader_Blitter& operator=(const SkRGB16_Shader_Blitter&);
 };
 
 class SkRGB16_Shader_Xfermode_Blitter : public SkBlitter {
 public:
-       SkRGB16_Shader_Xfermode_Blitter(const SkBitmap& device, const SkPaint& paint);
-       virtual ~SkRGB16_Shader_Xfermode_Blitter();
-       virtual void blitH(int x, int y, int width);
-       virtual void blitAntiH(int x, int y, const SkAlpha antialias[], const S16 runs[]);
+    SkRGB16_Shader_Xfermode_Blitter(const SkBitmap& device, const SkPaint& paint);
+    virtual ~SkRGB16_Shader_Xfermode_Blitter();
+    virtual void blitH(int x, int y, int width);
+    virtual void blitAntiH(int x, int y, const SkAlpha antialias[], const S16 runs[]);
 
 private:
-       const SkBitmap& fDevice;
-       SkShader*       fShader;
-       SkXfermode*     fXfermode;
-       SkPMColor*      fBuffer;
-       U8*                     fAAExpand;
+    const SkBitmap& fDevice;
+    SkShader*   fShader;
+    SkXfermode* fXfermode;
+    SkPMColor*  fBuffer;
+    uint8_t*    fAAExpand;
 
-       typedef SkBlitter INHERITED;
+    typedef SkBlitter INHERITED;
 
-       // illegal
-       SkRGB16_Shader_Xfermode_Blitter& operator=(const SkRGB16_Shader_Xfermode_Blitter&);
+    // illegal
+    SkRGB16_Shader_Xfermode_Blitter& operator=(const SkRGB16_Shader_Xfermode_Blitter&);
 };
 
 /////////////////////////////////////////////////////////////////////////////
 
 class SkA1_Blitter : public SkBlitter {
 public:
-       SkA1_Blitter(const SkBitmap& device, const SkPaint& paint);
-       virtual void blitH(int x, int y, int width);
+    SkA1_Blitter(const SkBitmap& device, const SkPaint& paint);
+    virtual void blitH(int x, int y, int width);
 
 private:
-       const SkBitmap& fDevice;
-       U8                              fSrcA;
+    const SkBitmap& fDevice;
+    uint8_t         fSrcA;
 
-       // illegal
-       SkA1_Blitter& operator=(const SkA1_Blitter&);
+    // illegal
+    SkA1_Blitter& operator=(const SkA1_Blitter&);
 };
 
 
index d2ccfeb..ac10cff 100644 (file)
@@ -1,3 +1,20 @@
+/* libs/graphics/sgl/SkDeque.cpp
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #include "SkDeque.h"
 
 #define INIT_ELEM_COUNT 1  // should we let the caller set this in the constructor?
index 9b1ed98..e3034dd 100644 (file)
@@ -1,3 +1,20 @@
+/* libs/graphics/sgl/SkDraw.cpp
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #include "SkDraw.h"
 #include "SkBlitter.h"
 #include "SkBounder.h"
 #include "SkShader.h"
 #include "SkStroke.h"
 #include "SkTemplatesPriv.h"
-#include "SkTextLayout.h"
 
-/**    Helper for allocating small blitters on the stack.
+/** Helper for allocating small blitters on the stack.
 */
 
-#define kBlitterStorageLongCount       40
+#define kBlitterStorageLongCount    40
 
 class SkAutoBlitterChoose {
 public:
-       SkAutoBlitterChoose(const SkBitmap& device, const SkMatrix& matrix, const SkPaint& paint)
-       {
-               fBlitter = SkBlitter::Choose(device, matrix, paint, fStorage, sizeof(fStorage));
-       }
-       ~SkAutoBlitterChoose();
+    SkAutoBlitterChoose(const SkBitmap& device, const SkMatrix& matrix, const SkPaint& paint)
+    {
+        fBlitter = SkBlitter::Choose(device, matrix, paint, fStorage, sizeof(fStorage));
+    }
+    ~SkAutoBlitterChoose();
 
-       SkBlitter*      operator->() { return fBlitter; }
-       SkBlitter*      get() const { return fBlitter; }
+    SkBlitter*  operator->() { return fBlitter; }
+    SkBlitter*  get() const { return fBlitter; }
 
 private:
-       SkBlitter*      fBlitter;
-       uint32_t        fStorage[kBlitterStorageLongCount];
+    SkBlitter*  fBlitter;
+    uint32_t    fStorage[kBlitterStorageLongCount];
 };
 
 SkAutoBlitterChoose::~SkAutoBlitterChoose()
@@ -43,157 +59,175 @@ SkAutoBlitterChoose::~SkAutoBlitterChoose()
 
 class SkAutoBitmapShaderInstall {
 public:
-       SkAutoBitmapShaderInstall(const SkBitmap& src, const SkPaint* paint) : fPaint((SkPaint*)paint)
-       {
-               fPrevShader = paint->getShader();
-               fPrevShader->safeRef();
-               fPaint->setShader(SkShader::CreateBitmapShader( src, false, paint->getFilterType(),
+    SkAutoBitmapShaderInstall(const SkBitmap& src, const SkPaint* paint) : fPaint((SkPaint*)paint)
+    {
+        fPrevShader = paint->getShader();
+        fPrevShader->safeRef();
+        fPaint->setShader(SkShader::CreateBitmapShader( src, false, paint->getFilterType(),
                                                         SkShader::kClamp_TileMode, SkShader::kClamp_TileMode,
-                                                                                                               fStorage, sizeof(fStorage)));
-       }
-       ~SkAutoBitmapShaderInstall()
-       {
-               SkShader* shader = fPaint->getShader();
-
-               fPaint->setShader(fPrevShader);
-               fPrevShader->safeUnref();
-
-               if ((void*)shader == (void*)fStorage)
-                       shader->~SkShader();
-               else
-                       SkDELETE(shader);
-       }
+                                                        fStorage, sizeof(fStorage)));
+    }
+    ~SkAutoBitmapShaderInstall()
+    {
+        SkShader* shader = fPaint->getShader();
+
+        fPaint->setShader(fPrevShader);
+        fPrevShader->safeUnref();
+
+        if ((void*)shader == (void*)fStorage)
+            shader->~SkShader();
+        else
+            SkDELETE(shader);
+    }
 private:
-       SkPaint*        fPaint;
-       SkShader*       fPrevShader;
-       uint32_t        fStorage[kBlitterStorageLongCount];
+    SkPaint*    fPaint;
+    SkShader*   fPrevShader;
+    uint32_t    fStorage[kBlitterStorageLongCount];
 };
 
 class SkAutoPaintStyleRestore {
 public:
-       SkAutoPaintStyleRestore(const SkPaint& paint, SkPaint::Style style)
-               : fPaint((SkPaint&)paint)
-       {
-               fStyle = paint.getStyle();      // record the old
-               fPaint.setStyle(style);         // change it to the specified style
-       }
-       ~SkAutoPaintStyleRestore()
-       {
-               fPaint.setStyle(fStyle);        // restore the old
-       }
+    SkAutoPaintStyleRestore(const SkPaint& paint, SkPaint::Style style)
+        : fPaint((SkPaint&)paint)
+    {
+        fStyle = paint.getStyle();  // record the old
+        fPaint.setStyle(style);     // change it to the specified style
+    }
+    ~SkAutoPaintStyleRestore()
+    {
+        fPaint.setStyle(fStyle);    // restore the old
+    }
 private:
-       SkPaint&                fPaint;
-       SkPaint::Style  fStyle;
+    SkPaint&        fPaint;
+    SkPaint::Style  fStyle;
 
-       // illegal
-       SkAutoPaintStyleRestore(const SkAutoPaintStyleRestore&);
-       SkAutoPaintStyleRestore& operator=(const SkAutoPaintStyleRestore&);
+    // illegal
+    SkAutoPaintStyleRestore(const SkAutoPaintStyleRestore&);
+    SkAutoPaintStyleRestore& operator=(const SkAutoPaintStyleRestore&);
 };
 
 ///////////////////////////////////////////////////////////////////////////////
 
 SkDraw::SkDraw(const SkCanvas& canvas)
 {
-       fDevice         = &canvas.getCurrBitmap();
-       fMatrix         = &canvas.getTotalMatrix();
-       fClip           = &canvas.getTotalClip();
-       fBounder        = canvas.getBounder();
-       fMapPtProc      = canvas.getCurrMapPtProc();
+    fDevice     = &canvas.getCurrBitmap();
+    fMatrix     = &canvas.getTotalMatrix();
+    fClip       = &canvas.getTotalClip();
+    fBounder    = canvas.getBounder();
+    fMapPtProc  = canvas.getCurrMapPtProc();
 
-       SkDEBUGCODE(this->validate();)
+    SkDEBUGCODE(this->validate();)
 }
 
 void SkDraw::drawPaint(const SkPaint& paint)
 {
-       SkDEBUGCODE(this->validate();)
+    SkDEBUGCODE(this->validate();)
 
-       if (fClip->isEmpty())
+    if (fClip->isEmpty())
         return;
 
-    SkRect16   devRect;
+    SkRect16    devRect;
     devRect.set(0, 0, fDevice->width(), fDevice->height());
 
     if (fBounder && !fBounder->doIRect(devRect, *fClip))
         return;
 
-    SkAutoBlitterChoose        blitter(*fDevice, *fMatrix, paint);
+    SkAutoBlitterChoose blitter(*fDevice, *fMatrix, paint);
     SkScan::FillDevRect(devRect, fClip, blitter.get());
 }
 
 void SkDraw::drawLine(const SkPoint& start, const SkPoint& stop, const SkPaint& paint)
 {
-       SkDEBUGCODE(this->validate();)
+    SkDEBUGCODE(this->validate();)
 
-       if (fClip->isEmpty() ||
-        (paint.getAlpha() == 0 && paint.getXfermode() == NULL))        // nothing to draw
+    if (fClip->isEmpty() ||
+        (paint.getAlpha() == 0 && paint.getXfermode() == NULL)) // nothing to draw
         return;
 
-       if (!paint.getPathEffect() && !paint.getMaskFilter() &&
-        !paint.getRasterizer() && paint.getStrokeWidth() == 0) // hairline
-       {
-               SkPoint pts[2];
-               fMapPtProc(*fMatrix, start.fX, start.fY, &pts[0]);
-               fMapPtProc(*fMatrix, stop.fX, stop.fY, &pts[1]);
-
-               if (fBounder && !fBounder->doHairline(pts[0], pts[1], paint, *fClip))
-                       return;
-
-               SkAutoBlitterChoose     blitter(*fDevice, *fMatrix, paint);
-
-               if (paint.isAntiAliasOn())
-                       SkScan::AntiHairLine(pts[0], pts[1], fClip, blitter.get());
-               else
-                       SkScan::HairLine(pts[0], pts[1], fClip, blitter.get());
-       }
-       else
-       {
-               SkPath  path;
-               // temporarily mark the paint as framing
-               SkAutoPaintStyleRestore restore(paint, SkPaint::kStroke_Style);
-
-               path.moveTo(start.fX, start.fY);
-               path.lineTo(stop.fX, stop.fY);
-               this->drawPath(path, paint);
-       }
+    if (!paint.getPathEffect() && !paint.getMaskFilter() &&
+        !paint.getRasterizer() && paint.getStrokeWidth() == 0)  // hairline
+    {
+        SkPoint pts[2];
+        fMapPtProc(*fMatrix, start.fX, start.fY, &pts[0]);
+        fMapPtProc(*fMatrix, stop.fX, stop.fY, &pts[1]);
+
+        if (fBounder && !fBounder->doHairline(pts[0], pts[1], paint, *fClip))
+            return;
+
+        SkAutoBlitterChoose blitter(*fDevice, *fMatrix, paint);
+
+        if (paint.isAntiAliasOn())
+            SkScan::AntiHairLine(pts[0], pts[1], fClip, blitter.get());
+        else
+            SkScan::HairLine(pts[0], pts[1], fClip, blitter.get());
+    }
+    else
+    {
+        SkPath  path;
+        // temporarily mark the paint as framing
+        SkAutoPaintStyleRestore restore(paint, SkPaint::kStroke_Style);
+
+        path.moveTo(start.fX, start.fY);
+        path.lineTo(stop.fX, stop.fY);
+        this->drawPath(path, paint);
+    }
+}
+
+static inline SkPoint* as_lefttop(SkRect* r)
+{
+    return (SkPoint*)(void*)r;
+}
+
+static inline SkPoint* as_rightbottom(SkRect* r)
+{
+    return ((SkPoint*)(void*)r) + 1;
 }
 
 void SkDraw::drawRect(const SkRect& rect, const SkPaint& paint)
 {
-       SkDEBUGCODE(this->validate();)
+    SkDEBUGCODE(this->validate();)
 
-       if (fClip->isEmpty() ||
-        (paint.getAlpha() == 0 && paint.getXfermode() == NULL))        // nothing to draw
+    if (fClip->isEmpty() ||
+        (paint.getAlpha() == 0 && paint.getXfermode() == NULL)) // nothing to draw
         return;
 
-       if (paint.getPathEffect() || paint.getMaskFilter() || paint.getRasterizer() ||
-               !fMatrix->rectStaysRect() || (paint.getStyle() != SkPaint::kFill_Style && (paint.getStrokeWidth() / 2) > 0))
-       {
-               SkPath  tmp;
-               tmp.addRect(rect);
-               tmp.setFillType(SkPath::kWinding_FillType);
-               this->drawPath(tmp, paint);
-               return;
-       }
-
-       SkRect  devRect;
-       fMapPtProc(*fMatrix, rect.fLeft, rect.fTop, (SkPoint*)&devRect.fLeft);
-       fMapPtProc(*fMatrix, rect.fRight, rect.fBottom, (SkPoint*)&devRect.fRight);
-       devRect.sort();
-
-       if (fBounder && !fBounder->doRect(devRect, paint, *fClip))
-               return;
-
-       SkAutoBlitterChoose     blitter(*fDevice, *fMatrix, paint);
-
-       if (paint.getStyle() == SkPaint::kFill_Style)
-               SkScan::FillRect(devRect, fClip, blitter.get());
-       else
-       {
-               if (paint.isAntiAliasOn())
-                       SkScan::AntiHairRect(devRect, fClip, blitter.get());
-               else
-                       SkScan::HairRect(devRect, fClip, blitter.get());
-       }
+    if (paint.getPathEffect() || paint.getMaskFilter() || paint.getRasterizer() ||
+        !fMatrix->rectStaysRect() || (paint.getStyle() != SkPaint::kFill_Style && SkScalarHalf(paint.getStrokeWidth()) > 0))
+    {
+        SkPath  tmp;
+        tmp.addRect(rect);
+        tmp.setFillType(SkPath::kWinding_FillType);
+        this->drawPath(tmp, paint);
+        return;
+    }
+
+    const SkMatrix&     matrix = *fMatrix;
+    SkRect              devRect;
+
+    // transform rect into devRect
+    {
+        SkMatrix::MapPtProc proc = fMapPtProc;
+        proc(matrix, rect.fLeft, rect.fTop, &devRect.asPoints()[0]);
+        proc(matrix, rect.fRight, rect.fBottom, &devRect.asPoints()[1]);
+        devRect.sort();
+    }
+
+    if (fBounder && !fBounder->doRect(devRect, paint, *fClip))
+        return;
+
+    SkAutoBlitterChoose blitterStorage(*fDevice, matrix, paint);
+    SkBlitter*          blitter = blitterStorage.get();
+    const SkRegion*     clip = fClip;
+
+    if (paint.getStyle() == SkPaint::kFill_Style)
+        SkScan::FillRect(devRect, clip, blitter);
+    else
+    {
+        if (paint.isAntiAliasOn())
+            SkScan::AntiHairRect(devRect, clip, blitter);
+        else
+            SkScan::HairRect(devRect, clip, blitter);
+    }
 }
 
 void SkDraw::drawDevMask(const SkMask& srcM, const SkPaint& paint)
@@ -207,26 +241,26 @@ void SkDraw::drawDevMask(const SkMask& srcM, const SkPaint& paint)
     dstM.fImage = NULL;
     SkAutoMaskImage ami(&dstM, false);
 
-       if (paint.getMaskFilter() &&
-               paint.getMaskFilter()->filterMask(&dstM, srcM, *fMatrix, NULL))
-       {
+    if (paint.getMaskFilter() &&
+        paint.getMaskFilter()->filterMask(&dstM, srcM, *fMatrix, NULL))
+    {
         mask = &dstM;
-       }
+    }
 
-       if (fBounder && !fBounder->doIRect(mask->fBounds, *fClip))
-               return;
+    if (fBounder && !fBounder->doIRect(mask->fBounds, *fClip))
+        return;
 
-       SkAutoBlitterChoose     blitter(*fDevice, *fMatrix, paint);
+    SkAutoBlitterChoose blitter(*fDevice, *fMatrix, paint);
 
     blitter->blitMaskRegion(*mask, *fClip);
 }
 
 void SkDraw::drawPath(const SkPath& origSrcPath, const SkPaint& paint, const SkMatrix* prePathMatrix, bool srcPathIsMutable)
 {
-       SkDEBUGCODE(this->validate();)
+    SkDEBUGCODE(this->validate();)
 
-       if (fClip->isEmpty() ||
-        (paint.getAlpha() == 0 && paint.getXfermode() == NULL))        // nothing to draw
+    if (fClip->isEmpty() ||
+        (paint.getAlpha() == 0 && paint.getXfermode() == NULL)) // nothing to draw
         return;
 
     SkPath*         pathPtr = (SkPath*)&origSrcPath;
@@ -278,159 +312,159 @@ void SkDraw::drawPath(const SkPath& origSrcPath, const SkPaint& paint, const SkM
     }
 
     // avoid possibly allocating a new path in transform if we can
-       SkPath* devPathPtr = srcPathIsMutable ? pathPtr : &tmpPath;
+    SkPath* devPathPtr = srcPathIsMutable ? pathPtr : &tmpPath;
 
-       // transform the path into device space
+    // transform the path into device space
     if (!pathPtr->transform(*matrix, devPathPtr))
         return;
 
-       SkAutoBlitterChoose     blitter(*fDevice, *fMatrix, paint);
+    SkAutoBlitterChoose blitter(*fDevice, *fMatrix, paint);
 
     // how does filterPath() know to fill or hairline the path??? <mrr>
-       if (paint.getMaskFilter() &&
-               paint.getMaskFilter()->filterPath(*devPathPtr, *fMatrix, *fClip, fBounder, blitter.get()))
-       {
-               return; // filterPath() called the blitter, so we're done
-       }
-
-       if (fBounder && !fBounder->doPath(*devPathPtr, paint, *fClip, doFill))
-               return;
-
-       if (doFill)
-       {
-               if (paint.isAntiAliasOn())
-                       SkScan::AntiFillPath(*devPathPtr, fClip, blitter.get());
-               else
-                       SkScan::FillPath(*devPathPtr, fClip, blitter.get());
-       }
-       else    // hairline
-       {
-               if (paint.isAntiAliasOn())
-                       SkScan::AntiHairPath(*devPathPtr, fClip, blitter.get());
-               else
-                       SkScan::HairPath(*devPathPtr, fClip, blitter.get());
-       }
+    if (paint.getMaskFilter() &&
+        paint.getMaskFilter()->filterPath(*devPathPtr, *fMatrix, *fClip, fBounder, blitter.get()))
+    {
+        return; // filterPath() called the blitter, so we're done
+    }
+
+    if (fBounder && !fBounder->doPath(*devPathPtr, paint, *fClip, doFill))
+        return;
+
+    if (doFill)
+    {
+        if (paint.isAntiAliasOn())
+            SkScan::AntiFillPath(*devPathPtr, fClip, blitter.get());
+        else
+            SkScan::FillPath(*devPathPtr, fClip, blitter.get());
+    }
+    else    // hairline
+    {
+        if (paint.isAntiAliasOn())
+            SkScan::AntiHairPath(*devPathPtr, fClip, blitter.get());
+        else
+            SkScan::HairPath(*devPathPtr, fClip, blitter.get());
+    }
 }
 
 static inline bool just_translate(const SkMatrix& m)
 {
-       return (m.getType() & ~SkMatrix::kTranslate_Mask) == 0;
+    return (m.getType() & ~SkMatrix::kTranslate_Mask) == 0;
 }
 
 void SkDraw::drawBitmap(const SkBitmap& bitmap, SkScalar x, SkScalar y, const SkPaint& paint)
 {
-       SkDEBUGCODE(this->validate();)
+    SkDEBUGCODE(this->validate();)
 
-       if (fClip->isEmpty() ||
+    if (fClip->isEmpty() ||
         bitmap.width() == 0 || bitmap.height() == 0 || bitmap.getConfig() == SkBitmap::kNo_Config ||
-               (paint.getAlpha() == 0 && paint.getXfermode() == NULL)) // nothing to draw
-               return;
+        (paint.getAlpha() == 0 && paint.getXfermode() == NULL)) // nothing to draw
+        return;
 
-       SkAutoPaintStyleRestore restore(paint, SkPaint::kFill_Style);
+    SkAutoPaintStyleRestore restore(paint, SkPaint::kFill_Style);
 
-       SkMatrix matrix = *fMatrix;
-       matrix.preTranslate(x, y);
+    SkMatrix matrix = *fMatrix;
+    matrix.preTranslate(x, y);
 
-       if (NULL == paint.getColorFilter() && just_translate(matrix))
-       {
-               int                     ix = SkScalarRound(matrix.getTranslateX());
-               int                     iy = SkScalarRound(matrix.getTranslateY());
-               U32                     storage[kBlitterStorageLongCount];
-               SkBlitter*      blitter = SkBlitter::ChooseSprite(*fDevice, paint, bitmap, ix, iy, storage, sizeof(storage));
-               if (blitter)
-               {
-                       SkAutoTPlacementDelete<SkBlitter>       ad(blitter, storage);
+    if (NULL == paint.getColorFilter() && just_translate(matrix))
+    {
+        int         ix = SkScalarRound(matrix.getTranslateX());
+        int         iy = SkScalarRound(matrix.getTranslateY());
+        U32         storage[kBlitterStorageLongCount];
+        SkBlitter*  blitter = SkBlitter::ChooseSprite(*fDevice, paint, bitmap, ix, iy, storage, sizeof(storage));
+        if (blitter)
+        {
+            SkAutoTPlacementDelete<SkBlitter>   ad(blitter, storage);
 
-                       SkRect16        ir;
-                       ir.set(ix, iy, ix + bitmap.width(), iy + bitmap.height());
+            SkRect16    ir;
+            ir.set(ix, iy, ix + bitmap.width(), iy + bitmap.height());
 
-                       if (fBounder && !fBounder->doIRect(ir, *fClip))
-                               return;
+            if (fBounder && !fBounder->doIRect(ir, *fClip))
+                return;
 
-                       SkRegion::Cliperator iter(*fClip, ir);
-                       const SkRect16&          cr = iter.rect();
+            SkRegion::Cliperator iter(*fClip, ir);
+            const SkRect16&      cr = iter.rect();
 
-                       for (; !iter.done(); iter.next())
+            for (; !iter.done(); iter.next())
             {
                 SkASSERT(!cr.isEmpty());
             #if 0
                 LOGI("blitRect(%d %d %d %d) [%d %d %p]\n", cr.fLeft, cr.fTop, cr.width(), cr.height(),
                         bitmap.width(), bitmap.height(), bitmap.getPixels());
             #endif
-                               blitter->blitRect(cr.fLeft, cr.fTop, cr.width(), cr.height());
+                blitter->blitRect(cr.fLeft, cr.fTop, cr.width(), cr.height());
             }
-                       return;
-               }
-       }
+            return;
+        }
+    }
 
-       SkAutoBitmapShaderInstall       install(bitmap, &paint);
+    SkAutoBitmapShaderInstall   install(bitmap, &paint);
 
     // save our state
-       const SkMatrix*         saveMatrix = fMatrix;
-       SkMatrix::MapPtProc     saveProc = fMapPtProc;
+    const SkMatrix*     saveMatrix = fMatrix;
+    SkMatrix::MapPtProc saveProc = fMapPtProc;
 
     // jam in the new temp state
-       fMatrix = &matrix;
-       fMapPtProc = matrix.getMapPtProc();
+    fMatrix = &matrix;
+    fMapPtProc = matrix.getMapPtProc();
 
     // call ourself with a rect
     {
-        SkRect r;
+        SkRect  r;
         r.set(0, 0, SkIntToScalar(bitmap.width()), SkIntToScalar(bitmap.height()));
         // is this ok if paint has a rasterizer? <reed>
         this->drawRect(r, paint);
     }
     
     // restore our state
-       fMapPtProc = saveProc;
-       fMatrix = saveMatrix;
+    fMapPtProc = saveProc;
+    fMatrix = saveMatrix;
 }
 
 void SkDraw::drawSprite(const SkBitmap& bitmap, int x, int y, const SkPaint& paint)
 {
-       SkDEBUGCODE(this->validate();)
+    SkDEBUGCODE(this->validate();)
 
     SkRect16    bounds;
     bounds.set(x, y, x + bitmap.width(), y + bitmap.height());
 
-       if (fClip->quickReject(bounds) ||
+    if (fClip->quickReject(bounds) ||
         bitmap.getConfig() == SkBitmap::kNo_Config ||
-               (paint.getAlpha() == 0 && paint.getXfermode() == NULL))
+        (paint.getAlpha() == 0 && paint.getXfermode() == NULL))
     {
-               return; // nothing to draw
+        return; // nothing to draw
     }
 
-       SkAutoPaintStyleRestore restore(paint, SkPaint::kFill_Style);
+    SkAutoPaintStyleRestore restore(paint, SkPaint::kFill_Style);
 
-       if (NULL == paint.getColorFilter())
-       {
-               uint32_t        storage[kBlitterStorageLongCount];
-               SkBlitter*      blitter = SkBlitter::ChooseSprite(*fDevice, paint, bitmap, x, y, storage, sizeof(storage));
+    if (NULL == paint.getColorFilter())
+    {
+        uint32_t    storage[kBlitterStorageLongCount];
+        SkBlitter*  blitter = SkBlitter::ChooseSprite(*fDevice, paint, bitmap, x, y, storage, sizeof(storage));
 
-               if (blitter)
-               {
-                       SkAutoTPlacementDelete<SkBlitter>       ad(blitter, storage);
+        if (blitter)
+        {
+            SkAutoTPlacementDelete<SkBlitter>   ad(blitter, storage);
 
-                       if (fBounder && !fBounder->doIRect(bounds, *fClip))
-                               return;
+            if (fBounder && !fBounder->doIRect(bounds, *fClip))
+                return;
 
-                       SkRegion::Cliperator iter(*fClip, bounds);
-                       const SkRect16&          cr = iter.rect();
+            SkRegion::Cliperator iter(*fClip, bounds);
+            const SkRect16&      cr = iter.rect();
 
-                       for (; !iter.done(); iter.next())
+            for (; !iter.done(); iter.next())
             {
                 SkASSERT(!cr.isEmpty());
-                               blitter->blitRect(cr.fLeft, cr.fTop, cr.width(), cr.height());
+                blitter->blitRect(cr.fLeft, cr.fTop, cr.width(), cr.height());
             }
-                       return;
-               }
-       }
+            return;
+        }
+    }
 
-       SkAutoBitmapShaderInstall       install(bitmap, &paint);
+    SkAutoBitmapShaderInstall   install(bitmap, &paint);
 
     // save our state
-       const SkMatrix*         saveMatrix = fMatrix;
-       SkMatrix::MapPtProc     saveProc = fMapPtProc;
+    const SkMatrix*     saveMatrix = fMatrix;
+    SkMatrix::MapPtProc saveProc = fMapPtProc;
     SkMatrix            matrix;
     SkRect              r;
 
@@ -443,8 +477,8 @@ void SkDraw::drawSprite(const SkBitmap& bitmap, int x, int y, const SkPaint& pai
 
     // jam in the new temp state
     matrix.reset();
-       fMatrix = &matrix;
-       fMapPtProc = matrix.getMapPtProc();
+    fMatrix = &matrix;
+    fMapPtProc = matrix.getMapPtProc();
 
     // call ourself with a rect
     {
@@ -453,8 +487,8 @@ void SkDraw::drawSprite(const SkBitmap& bitmap, int x, int y, const SkPaint& pai
     }
     
     // restore our state
-       fMapPtProc = saveProc;
-       fMatrix = saveMatrix;
+    fMapPtProc = saveProc;
+    fMatrix = saveMatrix;
 }
 
 ///////////////////////////////////////////////////////////////////////////////////
@@ -463,109 +497,91 @@ void SkDraw::drawSprite(const SkBitmap& bitmap, int x, int y, const SkPaint& pai
 #include "SkGlyphCache.h"
 #include "SkUtils.h"
 
-static void measure_text(SkGlyphCache* cache, SkUnicodeWalkerProc textProc, const char text[],
-                         size_t byteLength, SkVector* stopVector)
+static void measure_text(SkGlyphCache* cache, SkGlyphCacheProc glyphCacheProc,
+                         const char text[], size_t byteLength, SkVector* stopVector)
 {
-       SkFixed         x = 0, y = 0;
-       const char*     stop = text + byteLength;
+    SkFixed     x = 0, y = 0;
+    const char* stop = text + byteLength;
 
     while (text < stop)
     {
-        const SkGlyph& glyph = cache->getMetrics(textProc(&text));
+        const SkGlyph& glyph = glyphCacheProc(cache, &text);
         x += glyph.fAdvanceX;
         y += glyph.fAdvanceY;
     }
-       stopVector->set(SkFixedToScalar(x), SkFixedToScalar(y));
+    stopVector->set(SkFixedToScalar(x), SkFixedToScalar(y));
 
-       SkASSERT(text == stop);
-}
-
-static void measure_layout(SkGlyphCache* cache, const SkTextLayout::Rec rec[], int count,
-                           const SkMatrix& matrix, SkVector* stopVector)
-{
-       SkFixed         x = 0, y = 0;
-
-    for (int i = 0; i < count; i++)
-    {
-        // should pass glyphID to the cache, when we have that
-        const SkGlyph& glyph = cache->getMetrics(rec[i].charCode());
-        SkVector    adv;
-        adv.set(rec[i].fDeltaAdvance, 0);
-        matrix.mapVectors(&adv, 1);
-        x += glyph.fAdvanceX + SkScalarToFixed(adv.fX);
-        y += glyph.fAdvanceY + SkScalarToFixed(adv.fY);
-    }
-       stopVector->set(SkFixedToScalar(x), SkFixedToScalar(y));
+    SkASSERT(text == stop);
 }
 
-void SkDraw::drawText_asPaths(SkUnicodeWalkerProc textProc, const char text[], size_t byteLength, SkScalar x, SkScalar y, const SkPaint& paint)
+void SkDraw::drawText_asPaths(const char text[], size_t byteLength, SkScalar x, SkScalar y, const SkPaint& paint)
 {
-       SkDEBUGCODE(this->validate();)
+    SkDEBUGCODE(this->validate();)
 
-       SkTextToPathIter        iter(textProc, text, byteLength, paint, true, true);
+    SkTextToPathIter    iter(text, byteLength, paint, true, true);
 
-       SkMatrix        matrix;
-       matrix.setScale(iter.getPathScale(), iter.getPathScale(), 0, 0);
-       matrix.postTranslate(x, y);
+    SkMatrix    matrix;
+    matrix.setScale(iter.getPathScale(), iter.getPathScale());
+    matrix.postTranslate(x, y);
 
-       const SkPath* iterPath;
-       SkScalar xpos, prevXPos = 0;
+    const SkPath* iterPath;
+    SkScalar xpos, prevXPos = 0;
 
-       while ((iterPath = iter.next(&xpos)) != NULL)
-       {
-               matrix.postTranslate(xpos - prevXPos, 0);
-               this->drawPath(*iterPath, iter.getPaint(), &matrix, false);
-               prevXPos = xpos;
-       }
+    while ((iterPath = iter.next(&xpos)) != NULL)
+    {
+        matrix.postTranslate(xpos - prevXPos, 0);
+        this->drawPath(*iterPath, iter.getPaint(), &matrix, false);
+        prevXPos = xpos;
+    }
 }
 
-#define kStdStrikeThru_Offset          (-SK_Scalar1 * 6 / 21)
-#define kStdUnderline_Offset           (SK_Scalar1 / 9)
-#define kStdUnderline_Thickness                (SK_Scalar1 / 18)
+#define kStdStrikeThru_Offset       (-SK_Scalar1 * 6 / 21)
+#define kStdUnderline_Offset        (SK_Scalar1 / 9)
+#define kStdUnderline_Thickness     (SK_Scalar1 / 18)
 
 static void draw_paint_rect(SkDraw* draw, const SkPaint& paint, const SkRect& r, SkScalar textSize)
 {
-       if (paint.getStyle() == SkPaint::kFill_Style)
-               draw->drawRect(r, paint);
-       else
-       {
-               SkPaint p(paint);
-               p.setStrokeWidth(SkScalarMul(textSize, paint.getStrokeWidth()));
-               draw->drawRect(r, p);
-       }
+    if (paint.getStyle() == SkPaint::kFill_Style)
+        draw->drawRect(r, paint);
+    else
+    {
+        SkPaint p(paint);
+        p.setStrokeWidth(SkScalarMul(textSize, paint.getStrokeWidth()));
+        draw->drawRect(r, p);
+    }
 }
 
 static void handle_aftertext(SkDraw* draw, const SkPaint& paint, SkScalar width, const SkPoint& start)
 {
-       U32 flags = paint.getFlags();
-
-       if (flags & (SkPaint::kUnderlineText_Mask | SkPaint::kStrikeThruText_Mask))
-       {
-               SkScalar textSize = paint.getTextSize();
-               SkScalar height = SkScalarMul(textSize, kStdUnderline_Thickness);
-               SkRect   r;
-
-               r.fLeft = start.fX;
-               r.fRight = start.fX + width;
-
-               if (flags & SkPaint::kUnderlineText_Mask)
-               {
-                       SkScalar offset = start.fY + SkScalarMul(textSize, kStdUnderline_Offset);
-                       r.fTop = offset;
-                       r.fBottom = offset + height;
-                       draw_paint_rect(draw, paint, r, textSize);
-               }
-               if (flags & SkPaint::kStrikeThruText_Mask)
-               {
-                       SkScalar offset = start.fY + SkScalarMul(textSize, kStdStrikeThru_Offset);
-                       r.fTop = offset;
-                       r.fBottom = offset + height;
-                       draw_paint_rect(draw, paint, r, textSize);
-               }
-       }
+    U32 flags = paint.getFlags();
+
+    if (flags & (SkPaint::kUnderlineText_Flag | SkPaint::kStrikeThruText_Flag))
+    {
+        SkScalar textSize = paint.getTextSize();
+        SkScalar height = SkScalarMul(textSize, kStdUnderline_Thickness);
+        SkRect   r;
+
+        r.fLeft = start.fX;
+        r.fRight = start.fX + width;
+
+        if (flags & SkPaint::kUnderlineText_Flag)
+        {
+            SkScalar offset = start.fY + SkScalarMul(textSize, kStdUnderline_Offset);
+            r.fTop = offset;
+            r.fBottom = offset + height;
+            draw_paint_rect(draw, paint, r, textSize);
+        }
+        if (flags & SkPaint::kStrikeThruText_Flag)
+        {
+            SkScalar offset = start.fY + SkScalarMul(textSize, kStdStrikeThru_Offset);
+            r.fTop = offset;
+            r.fBottom = offset + height;
+            draw_paint_rect(draw, paint, r, textSize);
+        }
+    }
 }
 
-#if defined _WIN32 && _MSC_VER >= 1300 // disable warning : local variable used without having been initialized
+#if defined _WIN32 && _MSC_VER >= 1300  // disable warning : local variable used without having been initialized
 #pragma warning ( push )
 #pragma warning ( disable : 4701 )
 #endif
@@ -573,18 +589,18 @@ static void handle_aftertext(SkDraw* draw, const SkPaint& paint, SkScalar width,
 static inline void draw_one_glyph(const SkGlyph& glyph, int left, int top, SkBounder* bounder,
                                   const SkRegion& clip, SkBlitter* blitter, SkGlyphCache* cache)
 {
-    SkMask     mask;
+    SkMask  mask;
 
-    int right  = left + glyph.fWidth;
-    int bottom = top + glyph.fHeight;
+    int right   = left + glyph.fWidth;
+    int bottom  = top + glyph.fHeight;
 
     mask.fBounds.set(left, top, right, bottom);
 
     if (bounder == NULL && clip.quickContains(left, top, right, bottom))
     {
-        uint8_t* aa = (uint8_t*)glyph.fImage;                          
+        uint8_t* aa = (uint8_t*)glyph.fImage;               
         if (aa == NULL)
-            aa = (uint8_t*)cache->findImage(glyph.fCharCode);
+            aa = (uint8_t*)cache->findImage(glyph);
 
         if (aa)
         {
@@ -599,10 +615,10 @@ static inline void draw_one_glyph(const SkGlyph& glyph, int left, int top, SkBou
         SkRegion::Cliperator clipper(clip, mask.fBounds);
         if (!clipper.done())
         {
-            const SkRect16&    cr = clipper.rect();
-            const uint8_t*     aa = (const uint8_t*)glyph.fImage;
+            const SkRect16& cr = clipper.rect();
+            const uint8_t*  aa = (const uint8_t*)glyph.fImage;
             if (NULL == aa)
-                aa = (const uint8_t*)cache->findImage(glyph.fCharCode);
+                aa = (const uint8_t*)cache->findImage(glyph);
 
             if (aa && (bounder == NULL || bounder->doIRect(cr, clip)))
             {
@@ -618,139 +634,100 @@ static inline void draw_one_glyph(const SkGlyph& glyph, int left, int top, SkBou
     }
 }
 
-void SkDraw::drawText(SkUnicodeWalkerProc textProc, const char text[], size_t byteLength, SkScalar x, SkScalar y, const SkPaint& paint)
+void SkDraw::drawText(const char text[], size_t byteLength, SkScalar x, SkScalar y, const SkPaint& paint)
 {
-       SkASSERT(byteLength == 0 || text != NULL);
+    SkASSERT(byteLength == 0 || text != NULL);
 
-       SkDEBUGCODE(this->validate();)
+    SkDEBUGCODE(this->validate();)
 
-       if (text == NULL || byteLength == 0 ||
+    if (text == NULL || byteLength == 0 ||
         fClip->isEmpty() ||
-        (paint.getAlpha() == 0 && paint.getXfermode() == NULL))        // nothing to draw
-               return;
-
-    SkASSERT(textProc);
-
-       SkScalar        underlineWidth = 0;
-       SkPoint         underlineStart;
-
-       if (paint.getFlags() & (SkPaint::kUnderlineText_Mask | SkPaint::kStrikeThruText_Mask))
-       {
-               underlineWidth = paint.privateMeasureText(textProc, text, byteLength, NULL, NULL);
-
-               SkScalar offsetX = 0;
-               if (paint.getTextAlign() == SkPaint::kCenter_Align)
-                       offsetX = SkScalarHalf(underlineWidth);
-               else if (paint.getTextAlign() == SkPaint::kRight_Align)
-                       offsetX = underlineWidth;
-
-               underlineStart.set(x - offsetX, y);
-       }
-
-       if (paint.isLinearTextOn() ||
-               (fMatrix->getType() & SkMatrix::kPerspective_Mask))
-       {
-               this->drawText_asPaths(textProc, text, byteLength, x, y, paint);
-               handle_aftertext(this, paint, underlineWidth, underlineStart);
-               return;
-       }
-
-       SkAutoGlyphCache        autoCache(paint, fMatrix);
-       SkGlyphCache*           cache = autoCache.getCache();
-       SkAutoBlitterChoose     blitter(*fDevice, *fMatrix, paint);
-    SkTextLayout*       layout = paint.getTextLayout();
+        (paint.getAlpha() == 0 && paint.getXfermode() == NULL)) // nothing to draw
+        return;
+
+    SkScalar    underlineWidth = 0;
+    SkPoint     underlineStart;
+
+    underlineStart.set(0, 0);    // to avoid warning
+    if (paint.getFlags() & (SkPaint::kUnderlineText_Flag | SkPaint::kStrikeThruText_Flag))
+    {
+        underlineWidth = paint.measureText(text, byteLength, NULL, NULL);
+
+        SkScalar offsetX = 0;
+        if (paint.getTextAlign() == SkPaint::kCenter_Align)
+            offsetX = SkScalarHalf(underlineWidth);
+        else if (paint.getTextAlign() == SkPaint::kRight_Align)
+            offsetX = underlineWidth;
+
+        underlineStart.set(x - offsetX, y);
+    }
+
+    if (paint.isLinearTextOn() ||
+        (fMatrix->getType() & SkMatrix::kPerspective_Mask))
+    {
+        this->drawText_asPaths(text, byteLength, x, y, paint);
+        handle_aftertext(this, paint, underlineWidth, underlineStart);
+        return;
+    }
+
+    SkGlyphCacheProc glyphCacheProc = paint.getGlyphCacheProc();
+
+    SkAutoGlyphCache    autoCache(paint, fMatrix);
+    SkGlyphCache*       cache = autoCache.getCache();
+    SkAutoBlitterChoose blitter(*fDevice, *fMatrix, paint);
     
-       // transform our starting point
-       {
-               SkPoint loc;
-               fMapPtProc(*fMatrix, x, y, &loc);
-               x = loc.fX;
-               y = loc.fY;
-       }
-
-       if (paint.getTextAlign() != SkPaint::kLeft_Align)       // need to measure first
-       {
-               SkVector        stop;
-
-        if (layout)
-        {
-            SkAutoSTMalloc<32, SkTextLayout::Rec>   storage(byteLength);
-            SkTextLayout::Rec*                      rec = storage.get();
+    // transform our starting point
+    {
+        SkPoint loc;
+        fMapPtProc(*fMatrix, x, y, &loc);
+        x = loc.fX;
+        y = loc.fY;
+    }
+
+    if (paint.getTextAlign() != SkPaint::kLeft_Align)   // need to measure first
+    {
+        SkVector    stop;
 
-            int count = layout->layout(paint, text, byteLength, textProc, rec);
-            measure_layout(cache, rec, count, *fMatrix, &stop);
+        measure_text(cache, glyphCacheProc, text, byteLength, &stop);
+
+        SkScalar    stopX = stop.fX;
+        SkScalar    stopY = stop.fY;
+
+        if (paint.getTextAlign() == SkPaint::kCenter_Align)
+        {
+            stopX = SkScalarHalf(stopX);
+            stopY = SkScalarHalf(stopY);
         }
-        else
-            measure_text(cache, textProc, text, byteLength, &stop);
-
-               SkScalar        stopX = stop.fX;
-               SkScalar        stopY = stop.fY;
-
-               if (paint.getTextAlign() == SkPaint::kCenter_Align)
-               {
-                       stopX = SkScalarHalf(stopX);
-                       stopY = SkScalarHalf(stopY);
-               }
-               x -= stopX;
-               y -= stopY;
-       }
+        x -= stopX;
+        y -= stopY;
+    }
     
-       // add a half now so we can trunc rather than round in the loop
-       SkFixed fx = SkScalarToFixed(x) + SK_FixedHalf;
-       SkFixed fy = SkScalarToFixed(y) + SK_FixedHalf;
-       const char*     stop = text + byteLength;
-       const SkRegion& clip = *fClip;
+    // add a half now so we can trunc rather than round in the loop
+    SkFixed fx = SkScalarToFixed(x) + SK_FixedHalf;
+    SkFixed fy = SkScalarToFixed(y) + SK_FixedHalf;
+    const char* stop = text + byteLength;
+    const SkRegion& clip = *fClip;
     SkBounder* bounder = fBounder;
     SkBlitter* blit = blitter.get();
 
-    if (layout)
+    while (text < stop)
     {
-        SkAutoSTMalloc<32, SkTextLayout::Rec>   storage(byteLength);
-        SkTextLayout::Rec*                      rec = storage.get();
+        const SkGlyph& glyph = glyphCacheProc(cache, &text);
 
-        int count = layout->layout(paint, text, byteLength, textProc, rec);
-        for (int i = 0; i < count; i++)
-        {
-            // should pass rec[i].glyphID when we have it
-            const SkGlyph&  glyph = cache->getMetrics(rec[i].charCode());
-            SkVector        advance;
-            
-            advance.set(rec[i].fDeltaAdvance, 0);
-            fMatrix->mapVectors(&advance, 1);
-            SkFixed dx = SkScalarToFixed(advance.fX);
-            SkFixed dy = SkScalarToFixed(advance.fY);
-            
-            if (glyph.fWidth) {
-                draw_one_glyph( glyph,
-                                SkFixedFloor(fx + (dx >> 1)) + glyph.fLeft,
-                                SkFixedFloor(fy + (dy >> 1)) + glyph.fTop,
-                                fBounder, *fClip, blit, cache);
-            }
-            fx += glyph.fAdvanceX + dx;
-            fy += glyph.fAdvanceY + dy;
+        if (glyph.fWidth) {
+            draw_one_glyph( glyph,
+                            SkFixedFloor(fx) + glyph.fLeft, SkFixedFloor(fy) + glyph.fTop,
+                            bounder, clip, blit, cache);
         }
+        fx += glyph.fAdvanceX;
+        fy += glyph.fAdvanceY;
     }
-    else    // no layout object
-    {        
-        while (text < stop)
-        {
-            const SkGlyph& glyph = cache->getMetrics(textProc(&text));
 
-            if (glyph.fWidth) {
-                draw_one_glyph( glyph,
-                                SkFixedFloor(fx) + glyph.fLeft, SkFixedFloor(fy) + glyph.fTop,
-                                bounder, clip, blit, cache);
-            }
-            fx += glyph.fAdvanceX;
-            fy += glyph.fAdvanceY;
-        }
-       }
-
-       if (underlineWidth)
-       {
-               autoCache.release();    // release this now to free up the RAM
-               handle_aftertext(this, paint, underlineWidth, underlineStart);
-       }
+    if (underlineWidth)
+    {
+        autoCache.release();    // release this now to free up the RAM
+        handle_aftertext(this, paint, underlineWidth, underlineStart);
+    }
 }
 
 typedef void (*AlignProc)(const SkPoint&, const SkGlyph&, SkPoint16*);
@@ -782,33 +759,33 @@ static AlignProc pick_align_proc(SkPaint::Align align)
     return gProcs[align];
 }
 
-void SkDraw::drawPosText(SkUnicodeWalkerProc textProc, const char text[], size_t byteLength,
+void SkDraw::drawPosText(const char text[], size_t byteLength,
                          const SkPoint pos[], const SkPaint& paint)
 {
-       SkASSERT(byteLength == 0 || text != NULL);
+    SkASSERT(byteLength == 0 || text != NULL);
 
-       SkDEBUGCODE(this->validate();)
+    SkDEBUGCODE(this->validate();)
 
-       if (text == NULL || byteLength == 0 ||
+    if (text == NULL || byteLength == 0 ||
         fClip->isEmpty() ||
-        (paint.getAlpha() == 0 && paint.getXfermode() == NULL))        // nothing to draw
-               return;
-
-    SkASSERT(textProc);
+        (paint.getAlpha() == 0 && paint.getXfermode() == NULL)) // nothing to draw
+        return;
 
-       if (paint.isLinearTextOn() ||
-               (fMatrix->getType() & SkMatrix::kPerspective_Mask))
-       {
-//             this->drawText_asPaths(textProc, text, byteLength, x, y, paint);
-               return;
-       }
+    if (paint.isLinearTextOn() ||
+        (fMatrix->getType() & SkMatrix::kPerspective_Mask))
+    {
+        // TODO !!!!
+//      this->drawText_asPaths(text, byteLength, x, y, paint);
+        return;
+    }
 
-       SkAutoGlyphCache        autoCache(paint, fMatrix);
-       SkGlyphCache*           cache = autoCache.getCache();
-       SkAutoBlitterChoose     blitter(*fDevice, *fMatrix, paint);
+    SkGlyphCacheProc    glyphCacheProc = paint.getGlyphCacheProc();
+    SkAutoGlyphCache    autoCache(paint, fMatrix);
+    SkGlyphCache*       cache = autoCache.getCache();
+    SkAutoBlitterChoose blitter(*fDevice, *fMatrix, paint);
     
-       const char*         stop = text + byteLength;
-       const SkRegion&     clip = *fClip;
+    const char*         stop = text + byteLength;
+    const SkRegion&     clip = *fClip;
     SkBounder*          bounder = fBounder;
     SkBlitter*          blit = blitter.get();
     SkMatrix::MapPtProc mapPtProc = fMapPtProc;
@@ -817,7 +794,7 @@ void SkDraw::drawPosText(SkUnicodeWalkerProc textProc, const char text[], size_t
 
     while (text < stop)
     {
-        const SkGlyph& glyph = cache->getMetrics(textProc(&text));
+        const SkGlyph& glyph = glyphCacheProc(cache, &text);
 
         if (glyph.fWidth)
         {
@@ -843,101 +820,101 @@ void SkDraw::drawPosText(SkUnicodeWalkerProc textProc, const char text[], size_t
 #include "SkPathMeasure.h"
 
 static void morphpoints(SkPoint dst[], const SkPoint src[], int count,
-                                               SkPathMeasure& meas, SkScalar offset, SkScalar scale)
+                        SkPathMeasure& meas, SkScalar offset, SkScalar scale)
 {
-       for (int i = 0; i < count; i++)
-       {
-               SkPoint pos;
-               SkVector tangent;
+    for (int i = 0; i < count; i++)
+    {
+        SkPoint pos;
+        SkVector tangent;
 
-               SkScalar sx = SkScalarMul(src[i].fX, scale) + offset;
-               SkScalar sy = SkScalarMul(src[i].fY, scale);
+        SkScalar sx = SkScalarMul(src[i].fX, scale) + offset;
+        SkScalar sy = SkScalarMul(src[i].fY, scale);
 
-               meas.getPosTan(sx, &pos, &tangent);
+        meas.getPosTan(sx, &pos, &tangent);
 
-               SkMatrix        matrix;
-               SkPoint         pt;
+        SkMatrix    matrix;
+        SkPoint     pt;
 
-               pt.set(sx, sy);
-               matrix.setSinCos(tangent.fY, tangent.fX, 0, 0);
-               matrix.preTranslate(-sx, 0);
-               matrix.postTranslate(pos.fX, pos.fY);
-               matrix.mapPoints(&dst[i], &pt, 1);
-       }
+        pt.set(sx, sy);
+        matrix.setSinCos(tangent.fY, tangent.fX);
+        matrix.preTranslate(-sx, 0);
+        matrix.postTranslate(pos.fX, pos.fY);
+        matrix.mapPoints(&dst[i], &pt, 1);
+    }
 }
 
-/*     TODO
+/*  TODO
 
-       Need differentially more subdivisions when the follow-path is curvy. Not sure how to
-       determine that, but we need it. I guess a cheap answer is let the caller tell us,
-       but that seems like a cop-out. Another answer is to get Rob Johnson to figure it out.
+    Need differentially more subdivisions when the follow-path is curvy. Not sure how to
+    determine that, but we need it. I guess a cheap answer is let the caller tell us,
+    but that seems like a cop-out. Another answer is to get Rob Johnson to figure it out.
 */
 static void morphpath(SkPath* dst, const SkPath& src, SkPathMeasure& meas,
-                                         SkScalar offset, SkScalar scale)
+                      SkScalar offset, SkScalar scale)
 {
-       SkPath::Iter    iter(src, false);
-       SkPoint                 srcP[4], dstP[3];
-       SkPath::Verb    verb;
-
-       while ((verb = iter.next(srcP)) != SkPath::kDone_Verb)
-       {
-               switch (verb) {
-               case SkPath::kMove_Verb:
-                       morphpoints(dstP, srcP, 1, meas, offset, scale);
-                       dst->moveTo(dstP[0]);
-                       break;
-               case SkPath::kLine_Verb:
-                       srcP[2] = srcP[1];
-                       srcP[1].set(SkScalarAve(srcP[0].fX, srcP[2].fX),
-                                               SkScalarAve(srcP[0].fY, srcP[2].fY));
-                       // fall through to quad
-               case SkPath::kQuad_Verb:
-                       morphpoints(dstP, &srcP[1], 2, meas, offset, scale);
-                       dst->quadTo(dstP[0], dstP[1]);
-                       break;
-               case SkPath::kCubic_Verb:
-                       morphpoints(dstP, &srcP[1], 3, meas, offset, scale);
-                       dst->cubicTo(dstP[0], dstP[1], dstP[2]);
-                       break;
-               case SkPath::kClose_Verb:
-                       dst->close();
-                       break;
-               default:
-                       SkASSERT(!"unknown verb");
-                       break;
-               }
-       }
+    SkPath::Iter    iter(src, false);
+    SkPoint         srcP[4], dstP[3];
+    SkPath::Verb    verb;
+
+    while ((verb = iter.next(srcP)) != SkPath::kDone_Verb)
+    {
+        switch (verb) {
+        case SkPath::kMove_Verb:
+            morphpoints(dstP, srcP, 1, meas, offset, scale);
+            dst->moveTo(dstP[0]);
+            break;
+        case SkPath::kLine_Verb:
+            srcP[2] = srcP[1];
+            srcP[1].set(SkScalarAve(srcP[0].fX, srcP[2].fX),
+                        SkScalarAve(srcP[0].fY, srcP[2].fY));
+            // fall through to quad
+        case SkPath::kQuad_Verb:
+            morphpoints(dstP, &srcP[1], 2, meas, offset, scale);
+            dst->quadTo(dstP[0], dstP[1]);
+            break;
+        case SkPath::kCubic_Verb:
+            morphpoints(dstP, &srcP[1], 3, meas, offset, scale);
+            dst->cubicTo(dstP[0], dstP[1], dstP[2]);
+            break;
+        case SkPath::kClose_Verb:
+            dst->close();
+            break;
+        default:
+            SkASSERT(!"unknown verb");
+            break;
+        }
+    }
 }
 
-void SkDraw::drawTextOnPath(SkUnicodeWalkerProc textProc, const char text[], size_t byteLength,
+void SkDraw::drawTextOnPath(const char text[], size_t byteLength,
                             const SkPath& follow, SkScalar offset, const SkPaint& paint)
 {
-       SkASSERT(byteLength == 0 || text != NULL);
+    SkASSERT(byteLength == 0 || text != NULL);
 
-       if (text == NULL || byteLength == 0 ||
+    if (text == NULL || byteLength == 0 ||
         fClip->getBounds().isEmpty() ||
-        (paint.getAlpha() == 0 && paint.getXfermode() == NULL))        // nothing to draw
-               return;
-
-       SkTextToPathIter        iter(textProc, text, byteLength, paint, true, true);
-       SkPathMeasure           meas(follow, false);
-
-       if (paint.getTextAlign() != SkPaint::kLeft_Align)       // need to measure first
-       {
-               SkScalar pathLen = meas.getLength();
-               if (paint.getTextAlign() == SkPaint::kCenter_Align)
-                       pathLen = SkScalarHalf(pathLen);
-               offset += pathLen;
-       }
-
-       const SkPath*   iterPath;
-       SkScalar                xpos;
-       while ((iterPath = iter.next(&xpos)) != NULL)
-       {
-               SkPath  tmp;
-               morphpath(&tmp, *iterPath, meas, offset + xpos, iter.getPathScale());
-               this->drawPath(tmp, iter.getPaint());
-       }
+        (paint.getAlpha() == 0 && paint.getXfermode() == NULL)) // nothing to draw
+        return;
+
+    SkTextToPathIter    iter(text, byteLength, paint, true, true);
+    SkPathMeasure       meas(follow, false);
+
+    if (paint.getTextAlign() != SkPaint::kLeft_Align)   // need to measure first
+    {
+        SkScalar pathLen = meas.getLength();
+        if (paint.getTextAlign() == SkPaint::kCenter_Align)
+            pathLen = SkScalarHalf(pathLen);
+        offset += pathLen;
+    }
+
+    const SkPath*   iterPath;
+    SkScalar        xpos;
+    while ((iterPath = iter.next(&xpos)) != NULL)
+    {
+        SkPath  tmp;
+        morphpath(&tmp, *iterPath, meas, offset + xpos, iter.getPathScale());
+        this->drawPath(tmp, iter.getPaint());
+    }
 }
 
 ////////////////////////////////////////////////////////////////////////////////////////
@@ -947,15 +924,15 @@ void SkDraw::drawTextOnPath(SkUnicodeWalkerProc textProc, const char text[], siz
 
 void SkDraw::validate() const
 {
-       SkASSERT(fDevice != NULL);
-       SkASSERT(fMatrix != NULL);
-       SkASSERT(fClip != NULL);
+    SkASSERT(fDevice != NULL);
+    SkASSERT(fMatrix != NULL);
+    SkASSERT(fClip != NULL);
 
-       const SkRect16& cr = fClip->getBounds();
-       SkRect16                br;
+    const SkRect16& cr = fClip->getBounds();
+    SkRect16        br;
 
-       br.set(0, 0, fDevice->width(), fDevice->height());
-       SkASSERT(br.contains(cr));
+    br.set(0, 0, fDevice->width(), fDevice->height());
+    SkASSERT(br.contains(cr));
 }
 
 #endif
@@ -964,73 +941,73 @@ void SkDraw::validate() const
 
 bool SkBounder::doIRect(const SkRect16& r, const SkRegion& clip)
 {
-       SkRect16        rr;
-       return rr.intersect(clip.getBounds(), r) && this->onIRect(rr);
+    SkRect16    rr;
+    return rr.intersect(clip.getBounds(), r) && this->onIRect(rr);
 }
 
 bool SkBounder::doHairline(const SkPoint& pt0, const SkPoint& pt1, const SkPaint& paint, const SkRegion& clip)
 {
-       SkRect16        r;
-       SkScalar        v0, v1;
-
-       v0 = pt0.fX;
-       v1 = pt1.fX;
-       if (v0 > v1)
-               SkTSwap<SkScalar>(v0, v1);
-       r.fLeft         = SkToS16(SkScalarFloor(v0));
-       r.fRight        = SkToS16(SkScalarCeil(v1));
-
-       v0 = pt0.fY;
-       v1 = pt1.fY;
-       if (v0 > v1)
-               SkTSwap<SkScalar>(v0, v1);
-       r.fTop          = SkToS16(SkScalarFloor(v0));
-       r.fBottom       = SkToS16(SkScalarCeil(v1));
-
-       if (paint.isAntiAliasOn())
-               r.inset(-1, -1);
-
-       return this->doIRect(r, clip);
+    SkRect16    r;
+    SkScalar    v0, v1;
+
+    v0 = pt0.fX;
+    v1 = pt1.fX;
+    if (v0 > v1)
+        SkTSwap<SkScalar>(v0, v1);
+    r.fLeft     = SkToS16(SkScalarFloor(v0));
+    r.fRight    = SkToS16(SkScalarCeil(v1));
+
+    v0 = pt0.fY;
+    v1 = pt1.fY;
+    if (v0 > v1)
+        SkTSwap<SkScalar>(v0, v1);
+    r.fTop      = SkToS16(SkScalarFloor(v0));
+    r.fBottom   = SkToS16(SkScalarCeil(v1));
+
+    if (paint.isAntiAliasOn())
+        r.inset(-1, -1);
+
+    return this->doIRect(r, clip);
 }
 
 bool SkBounder::doRect(const SkRect& rect, const SkPaint& paint, const SkRegion& clip)
 {
-       SkRect16        r;
-
-       if (paint.getStyle() == SkPaint::kFill_Style)
-               rect.round(&r);
-       else
-       {
-               int     rad = -1;
-               rect.roundOut(&r);
-               if (paint.isAntiAliasOn())
-                       rad = -2;
-               r.inset(rad, rad);
-       }
-       return this->doIRect(r, clip);
+    SkRect16    r;
+
+    if (paint.getStyle() == SkPaint::kFill_Style)
+        rect.round(&r);
+    else
+    {
+        int rad = -1;
+        rect.roundOut(&r);
+        if (paint.isAntiAliasOn())
+            rad = -2;
+        r.inset(rad, rad);
+    }
+    return this->doIRect(r, clip);
 }
 
 bool SkBounder::doPath(const SkPath& path, const SkPaint& paint, const SkRegion& clip, bool doFill)
 {
-       SkRect          bounds;
-       SkRect16        r;
+    SkRect      bounds;
+    SkRect16    r;
 
-       path.computeBounds(&bounds, SkPath::kFast_BoundsType);
+    path.computeBounds(&bounds, SkPath::kFast_BoundsType);
 
-       if (doFill)
-               bounds.round(&r);
-       else    // hairline
-               bounds.roundOut(&r);
+    if (doFill)
+        bounds.round(&r);
+    else    // hairline
+        bounds.roundOut(&r);
 
-       if (paint.isAntiAliasOn())
-               r.inset(-1, -1);
+    if (paint.isAntiAliasOn())
+        r.inset(-1, -1);
 
-       return this->doIRect(r, clip);
+    return this->doIRect(r, clip);
 }
 
 void SkBounder::commit()
 {
-       // override in subclass
+    // override in subclass
 }
 
 ////////////////////////////////////////////////////////////////////////////////////////////////
@@ -1058,7 +1035,7 @@ static bool compute_bounds(const SkPath& devPath, const SkRect16* clipBounds,
         pathBounds.roundOut(bounds);
     }
     
-       if (filter)
+    if (filter)
     {
         SkASSERT(filterMatrix);
         
@@ -1076,26 +1053,26 @@ static bool compute_bounds(const SkPath& devPath, const SkRect16* clipBounds,
     if (clipBounds && !SkRect16::Intersects(*clipBounds, *bounds))
         return false;
     
-       // (possibly) trim the srcM bounds to reflect the clip
-       // (plus whatever slop the filter needs)
-       if (clipBounds && !clipBounds->contains(*bounds))
-       {
+    // (possibly) trim the srcM bounds to reflect the clip
+    // (plus whatever slop the filter needs)
+    if (clipBounds && !clipBounds->contains(*bounds))
+    {
         SkRect16 tmp = *bounds;
-               (void)tmp.intersect(*clipBounds);
-               tmp.inset(-margin.fX, -margin.fY);
-               (void)bounds->intersect(tmp);
-       }
+        (void)tmp.intersect(*clipBounds);
+        tmp.inset(-margin.fX, -margin.fY);
+        (void)bounds->intersect(tmp);
+    }
 
     return true;
 }
 
 static void draw_into_mask(const SkMask& mask, const SkPath& devPath)
 {
-    SkBitmap   bm;
-    SkDraw             draw;
-    SkRegion   clipRgn;
-    SkMatrix   matrix;
-    SkPaint            paint;
+    SkBitmap    bm;
+    SkDraw      draw;
+    SkRegion    clipRgn;
+    SkMatrix    matrix;
+    SkPaint     paint;
 
     bm.setConfig(SkBitmap::kA8_Config, mask.fBounds.width(), mask.fBounds.height(), mask.fRowBytes);
     bm.setPixels(mask.fImage);
index 488fa79..57c2eed 100644 (file)
@@ -1,3 +1,20 @@
+/* libs/graphics/sgl/SkDraw.h
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #ifndef SkDraw_DEFINED
 #define SkDraw_DEFINED
 
@@ -14,24 +31,24 @@ class SkRegion;
 
 class SkDraw {
 public:
-       SkDraw() {}
-       SkDraw(const SkCanvas&);
-
-       void    drawPaint(const SkPaint&);
-       void    drawLine(const SkPoint& start, const SkPoint& stop, const SkPaint&);
-       void    drawRect(const SkRect&, const SkPaint&);
-       /*      To save on mallocs, we allow a flag that tells us that srcPath is mutable, so that we don't have to
-               make copies of it as we transform it.
-       */
-       void    drawPath(const SkPath& srcPath, const SkPaint&, const SkMatrix* prePathMatrix, bool srcPathIsMutable);
-       void    drawBitmap(const SkBitmap&, SkScalar x, SkScalar y, const SkPaint&);
+    SkDraw() {}
+    SkDraw(const SkCanvas&);
+
+    void    drawPaint(const SkPaint&);
+    void    drawLine(const SkPoint& start, const SkPoint& stop, const SkPaint&);
+    void    drawRect(const SkRect&, const SkPaint&);
+    /*  To save on mallocs, we allow a flag that tells us that srcPath is mutable, so that we don't have to
+        make copies of it as we transform it.
+    */
+    void    drawPath(const SkPath& srcPath, const SkPaint&, const SkMatrix* prePathMatrix, bool srcPathIsMutable);
+    void    drawBitmap(const SkBitmap&, SkScalar x, SkScalar y, const SkPaint&);
     void    drawSprite(const SkBitmap& bitmap, int x, int y, const SkPaint& paint);
-       void    drawText(SkUnicodeWalkerProc, const char text[], size_t byteLength, SkScalar x, SkScalar y, const SkPaint& paint);
-       void    drawPosText(SkUnicodeWalkerProc, const char text[], size_t byteLength, const SkPoint pos[], const SkPaint& paint);
-       void    drawTextOnPath(SkUnicodeWalkerProc, const char text[], size_t byteLength, const SkPath& follow,
-                                                       SkScalar offset, const SkPaint& paint);
+    void    drawText(const char text[], size_t byteLength, SkScalar x, SkScalar y, const SkPaint& paint);
+    void    drawPosText(const char text[], size_t byteLength, const SkPoint pos[], const SkPaint& paint);
+    void    drawTextOnPath(const char text[], size_t byteLength, const SkPath& follow,
+                            SkScalar offset, const SkPaint& paint);
 
-       void    drawPath(const SkPath& src, const SkPaint& paint)
+    void    drawPath(const SkPath& src, const SkPaint& paint)
     {
         this->drawPath(src, paint, NULL, false);
     }
@@ -46,42 +63,44 @@ public:
                            SkMask* mask, SkMask::CreateMode mode);
 
 private:
-       void    drawText_asPaths(SkUnicodeWalkerProc, const char text[], size_t byteLength, SkScalar x, SkScalar y, const SkPaint&);
-       void    drawDevMask(const SkMask& mask, const SkPaint&);
+    void    drawText_asPaths(const char text[], size_t byteLength, SkScalar x, SkScalar y, const SkPaint&);
+    void    drawDevMask(const SkMask& mask, const SkPaint&);
 
 #ifdef SK_DEBUG
-       void    validate() const;
+    void    validate() const;
 #endif
 
 public:
-       const SkBitmap* fDevice;                // required
-       const SkMatrix* fMatrix;                // required
-       const SkRegion* fClip;                  // required
-       SkMatrix::MapPtProc     fMapPtProc;     // required
-       SkBounder*              fBounder;               // optional
+    const SkBitmap* fDevice;        // required
+    const SkMatrix* fMatrix;        // required
+    const SkRegion* fClip;          // required
+    SkMatrix::MapPtProc fMapPtProc; // required
+    SkBounder*      fBounder;       // optional
 };
 
+#include "SkGlyphCache.h"
+
 class SkTextToPathIter {
 public:
-       SkTextToPathIter(SkUnicodeWalkerProc, const char text[], size_t length, const SkPaint&,
-                                        bool applyStrokeAndPathEffects, bool forceLinearTextOn);
-       ~SkTextToPathIter();
+    SkTextToPathIter(const char text[], size_t length, const SkPaint&,
+                     bool applyStrokeAndPathEffects, bool forceLinearTextOn);
+    ~SkTextToPathIter();
 
-       const SkPaint&  getPaint() const { return fPaint; }
-       SkScalar                getPathScale() const { return fScale; }
+    const SkPaint&  getPaint() const { return fPaint; }
+    SkScalar        getPathScale() const { return fScale; }
 
-       const SkPath*   next(SkScalar* xpos);   //!< returns nil when there are no more paths
+    const SkPath*   next(SkScalar* xpos);   //!< returns nil when there are no more paths
 
 private:
-       SkGlyphCache*   fCache;
-       SkPaint                 fPaint;
-       SkScalar                fScale, fPrevAdvance;
-       const char*             fText;
-       const char*             fStop;
-    SkUnicodeWalkerProc fTextProc;
-
-       const SkPath*   fPath;          // returned in next
-       SkScalar                fXPos;          // accumulated xpos, returned in next
+    SkGlyphCache*   fCache;
+    SkPaint         fPaint;
+    SkScalar        fScale, fPrevAdvance;
+    const char*     fText;
+    const char*     fStop;
+    SkGlyphCacheProc fGlyphCacheProc;
+
+    const SkPath*   fPath;      // returned in next
+    SkScalar        fXPos;      // accumulated xpos, returned in next
 };
 
 #endif
index d5e5590..b1f4a22 100644 (file)
+/* libs/graphics/sgl/SkEdge.cpp
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #include "SkEdge.h"
 #include "SkFDot6.h"
 
 /*
-       In setLine, setQuadratic, setCubic, the first thing we do is to convert
-       the points into FDot6. This is modulated by the shift parameter, which
-       will either be 0, or something like 2 for antialiasing.
+    In setLine, setQuadratic, setCubic, the first thing we do is to convert
+    the points into FDot6. This is modulated by the shift parameter, which
+    will either be 0, or something like 2 for antialiasing.
 
-       In the float case, we want to turn the float into .6 by saying pt * 64,
-       or pt * 256 for antialiasing. This is implemented as 1 << (shift + 6).
+    In the float case, we want to turn the float into .6 by saying pt * 64,
+    or pt * 256 for antialiasing. This is implemented as 1 << (shift + 6).
 
-       In the fixed case, we want to turn the fixed into .6 by saying pt >> 10,
-       or pt >> 8 for antialiasing. This is implemented as pt >> (10 - shift).
+    In the fixed case, we want to turn the fixed into .6 by saying pt >> 10,
+    or pt >> 8 for antialiasing. This is implemented as pt >> (10 - shift).
 */
 
 /////////////////////////////////////////////////////////////////////////
 
 int SkEdge::setLine(const SkPoint pts[2], const SkRect16* clip, int shift)
 {
-       SkFDot6 x0, y0, x1, y1;
+    SkFDot6 x0, y0, x1, y1;
 
-       {
+    {
 #ifdef SK_SCALAR_IS_FLOAT
-               float scale = float(1 << (shift + 6));
-               x0 = int(pts[0].fX * scale);
-               y0 = int(pts[0].fY * scale);
-               x1 = int(pts[1].fX * scale);
-               y1 = int(pts[1].fY * scale);
+        float scale = float(1 << (shift + 6));
+        x0 = int(pts[0].fX * scale);
+        y0 = int(pts[0].fY * scale);
+        x1 = int(pts[1].fX * scale);
+        y1 = int(pts[1].fY * scale);
 #else
-               shift = 10 - shift;
-               x0 = pts[0].fX >> shift;
-               y0 = pts[0].fY >> shift;
-               x1 = pts[1].fX >> shift;
-               y1 = pts[1].fY >> shift;
+        shift = 10 - shift;
+        x0 = pts[0].fX >> shift;
+        y0 = pts[0].fY >> shift;
+        x1 = pts[1].fX >> shift;
+        y1 = pts[1].fY >> shift;
 #endif
-       }
+    }
 
-       int             winding = 1;
+    int     winding = 1;
 
-       if (y0 > y1)
-       {
-               SkTSwap(x0, x1);
-               SkTSwap(y0, y1);
-               winding = -1;
-       }
+    if (y0 > y1)
+    {
+        SkTSwap(x0, x1);
+        SkTSwap(y0, y1);
+        winding = -1;
+    }
 
-       int     top = SkFDot6Round(y0);
-       int     bot = SkFDot6Round(y1);
+    int top = SkFDot6Round(y0);
+    int bot = SkFDot6Round(y1);
 
-       // are we a zero-height line?
-       if (top == bot)
-               return 0;
+    // are we a zero-height line?
+    if (top == bot)
+        return 0;
 
-       // are we completely above or below the clip?
-       if (clip && (top >= clip->fBottom || bot <= clip->fTop))
-               return 0;
+    // are we completely above or below the clip?
+    if (clip && (top >= clip->fBottom || bot <= clip->fTop))
+        return 0;
 
-       SkFixed slope = SkFDot6Div(x1 - x0, y1 - y0);
+    SkFixed slope = SkFDot6Div(x1 - x0, y1 - y0);
 
-       fX                      = SkFDot6ToFixed(x0 + SkFixedMul(slope, (32 - y0) & 63));       // + SK_Fixed1/2
-       fDX                     = slope;
-       fFirstY         = SkToS16(top);
-       fLastY          = SkToS16(bot - 1);
-       fCurveCount     = 0;
-       fWinding        = SkToS8(winding);
-       fCurveShift     = 0;
+    fX          = SkFDot6ToFixed(x0 + SkFixedMul(slope, (32 - y0) & 63));   // + SK_Fixed1/2
+    fDX         = slope;
+    fFirstY     = SkToS16(top);
+    fLastY      = SkToS16(bot - 1);
+    fCurveCount = 0;
+    fWinding    = SkToS8(winding);
+    fCurveShift = 0;
 
-       if (clip)
-               this->chopLineWithClip(*clip);
-       return 1;
+    if (clip)
+        this->chopLineWithClip(*clip);
+    return 1;
 }
 
 // called from a curve subclass
 int SkEdge::updateLine(SkFixed x0, SkFixed y0, SkFixed x1, SkFixed y1)
 {
-       SkASSERT(fWinding == 1 || fWinding == -1);
-       SkASSERT(fCurveCount != 0);
-       SkASSERT(fCurveShift != 0);
+    SkASSERT(fWinding == 1 || fWinding == -1);
+    SkASSERT(fCurveCount != 0);
+    SkASSERT(fCurveShift != 0);
 
-       y0 >>= 10;
-       y1 >>= 10;
+    y0 >>= 10;
+    y1 >>= 10;
 
-       SkASSERT(y0 <= y1);
+    SkASSERT(y0 <= y1);
 
-       int     top = SkFDot6Round(y0);
-       int     bot = SkFDot6Round(y1);
+    int top = SkFDot6Round(y0);
+    int bot = SkFDot6Round(y1);
 
-//     SkASSERT(top >= fFirstY);
+//  SkASSERT(top >= fFirstY);
 
-       // are we a zero-height line?
-       if (top == bot)
-               return 0;
+    // are we a zero-height line?
+    if (top == bot)
+        return 0;
 
-       x0 >>= 10;
-       x1 >>= 10;
+    x0 >>= 10;
+    x1 >>= 10;
 
-       SkFixed slope = SkFDot6Div(x1 - x0, y1 - y0);
+    SkFixed slope = SkFDot6Div(x1 - x0, y1 - y0);
 
-       fX                      = SkFDot6ToFixed(x0 + SkFixedMul(slope, (32 - y0) & 63));       // + SK_Fixed1/2
-       fDX                     = slope;
-       fFirstY         = SkToS16(top);
-       fLastY          = SkToS16(bot - 1);
+    fX          = SkFDot6ToFixed(x0 + SkFixedMul(slope, (32 - y0) & 63));   // + SK_Fixed1/2
+    fDX         = slope;
+    fFirstY     = SkToS16(top);
+    fLastY      = SkToS16(bot - 1);
 
-       return 1;
+    return 1;
 }
 
 void SkEdge::chopLineWithClip(const SkRect16& clip)
 {
-       int     top = fFirstY;
+    int top = fFirstY;
 
-       SkASSERT(top < clip.fBottom);
+    SkASSERT(top < clip.fBottom);
 
-       // clip the line to the top
-       if (top < clip.fTop)
-       {
-               SkASSERT(fLastY >= clip.fTop);
-               fX += fDX * (clip.fTop - top);
-               fFirstY = clip.fTop;
-       }
+    // clip the line to the top
+    if (top < clip.fTop)
+    {
+        SkASSERT(fLastY >= clip.fTop);
+        fX += fDX * (clip.fTop - top);
+        fFirstY = clip.fTop;
+    }
 }
 
 /////////////////////////////////////////////////////////////////////////
 
 static inline SkFDot6 cheap_distance(SkFDot6 dx, SkFDot6 dy)
 {
-       dx = SkAbs32(dx);
-       dy = SkAbs32(dy);
-       // return max + min/2
-       if (dx > dy)
-               dx += dy >> 1;
-       else
-               dx = dy + (dx >> 1);
-       return dx;
+    dx = SkAbs32(dx);
+    dy = SkAbs32(dy);
+    // return max + min/2
+    if (dx > dy)
+        dx += dy >> 1;
+    else
+        dx = dy + (dx >> 1);
+    return dx;
 }
 
 static inline int diff_to_shift(SkFDot6 dx, SkFDot6 dy)
 {
-       // cheap calc of distance from center of p0-p2 to the center of the curve
-       SkFDot6 dist = cheap_distance(dx, dy);
+    // cheap calc of distance from center of p0-p2 to the center of the curve
+    SkFDot6 dist = cheap_distance(dx, dy);
 
-       // shift down dist (it is currently in dot6)
-       // down by 5 should give us 1/2 pixel accuracy (assuming our dist is accurate...)
-       // this is chosen by heuristic: make it as big as possible (to minimize segments)
-       // ... but small enough so that our curves still look smooth
-       dist >>= 5;
+    // shift down dist (it is currently in dot6)
+    // down by 5 should give us 1/2 pixel accuracy (assuming our dist is accurate...)
+    // this is chosen by heuristic: make it as big as possible (to minimize segments)
+    // ... but small enough so that our curves still look smooth
+    dist >>= 5;
 
-       // each subdivision (shift value) cuts this dist (error) by 1/4
-       return (32 - SkCLZ(dist)) >> 1;
+    // each subdivision (shift value) cuts this dist (error) by 1/4
+    return (32 - SkCLZ(dist)) >> 1;
 }
 
 int SkQuadraticEdge::setQuadratic(const SkPoint pts[3], const SkRect16* clip, int shift)
 {
-       SkFDot6 x0, y0, x1, y1, x2, y2;
+    SkFDot6 x0, y0, x1, y1, x2, y2;
 
-       {
+    {
 #ifdef SK_SCALAR_IS_FLOAT
-               float scale = float(1 << (shift + 6));
-               x0 = int(pts[0].fX * scale);
-               y0 = int(pts[0].fY * scale);
-               x1 = int(pts[1].fX * scale);
-               y1 = int(pts[1].fY * scale);
-               x2 = int(pts[2].fX * scale);
-               y2 = int(pts[2].fY * scale);
+        float scale = float(1 << (shift + 6));
+        x0 = int(pts[0].fX * scale);
+        y0 = int(pts[0].fY * scale);
+        x1 = int(pts[1].fX * scale);
+        y1 = int(pts[1].fY * scale);
+        x2 = int(pts[2].fX * scale);
+        y2 = int(pts[2].fY * scale);
 #else
-               shift = 10 - shift;
-               x0 = pts[0].fX >> shift;
-               y0 = pts[0].fY >> shift;
-               x1 = pts[1].fX >> shift;
-               y1 = pts[1].fY >> shift;
-               x2 = pts[2].fX >> shift;
-               y2 = pts[2].fY >> shift;
+        shift = 10 - shift;
+        x0 = pts[0].fX >> shift;
+        y0 = pts[0].fY >> shift;
+        x1 = pts[1].fX >> shift;
+        y1 = pts[1].fY >> shift;
+        x2 = pts[2].fX >> shift;
+        y2 = pts[2].fY >> shift;
 #endif
-       }
-
-       int     winding = 1;
-       if (y0 > y2)
-       {
-               SkTSwap(x0, x2);
-               SkTSwap(y0, y2);
-               winding = -1;
-       }
-       SkASSERT(y0 <= y1 && y1 <= y2);
-
-       int     top = SkFDot6Round(y0);
-       int     bot = SkFDot6Round(y2);
-
-       // are we a zero-height quad (line)?
-       if (top == bot)
-               return 0;
-       // are we completely above or below the clip?
-       if (clip && (top >= clip->fBottom || bot <= clip->fTop))
-               return 0;
-
-       // compute number of steps needed (1 << shift)
-       {
-               SkFDot6 dx = ((x1 << 1) - x0 - x2) >> 2;
-               SkFDot6 dy = ((y1 << 1) - y0 - y2) >> 2;
-               shift = diff_to_shift(dx, dy);
-       }
-       // need at least 1 subdivision for our bias trick
-       if (shift == 0)
-               shift = 1;
-
-       fWinding        = SkToS8(winding);
-       fCurveShift     = SkToU8(shift);
-       fCurveCount     = SkToS16(1 << shift);
-
-       SkFixed A = SkFDot6ToFixed(x0 - x1 - x1 + x2);
-       SkFixed B = SkFDot6ToFixed(x1 - x0 + x1 - x0);
-
-       fQx             = SkFDot6ToFixed(x0);
-       fQDx    = B + (A >> shift);             // biased by shift
-       fQDDx   = A >> (shift - 1);             // biased by shift
-
-       A = SkFDot6ToFixed(y0 - y1 - y1 + y2);
-       B = SkFDot6ToFixed(y1 - y0 + y1 - y0);
-
-       fQy             = SkFDot6ToFixed(y0);
-       fQDy    = B + (A >> shift);             // biased by shift
-       fQDDy   = A >> (shift - 1);             // biased by shift
-
-       fQLastX = SkFDot6ToFixed(x2);
-       fQLastY = SkFDot6ToFixed(y2);
-
-       if (clip)
-       {
-               do {
-                       for (;!this->updateQuadratic();)
-                               ;
-               } while (!this->intersectsClip(*clip));
-               this->chopLineWithClip(*clip);
-               return 1;
-       }
-       return this->updateQuadratic();
+    }
+
+    int winding = 1;
+    if (y0 > y2)
+    {
+        SkTSwap(x0, x2);
+        SkTSwap(y0, y2);
+        winding = -1;
+    }
+    SkASSERT(y0 <= y1 && y1 <= y2);
+
+    int top = SkFDot6Round(y0);
+    int bot = SkFDot6Round(y2);
+
+    // are we a zero-height quad (line)?
+    if (top == bot)
+        return 0;
+    // are we completely above or below the clip?
+    if (clip && (top >= clip->fBottom || bot <= clip->fTop))
+        return 0;
+
+    // compute number of steps needed (1 << shift)
+    {
+        SkFDot6 dx = ((x1 << 1) - x0 - x2) >> 2;
+        SkFDot6 dy = ((y1 << 1) - y0 - y2) >> 2;
+        shift = diff_to_shift(dx, dy);
+    }
+    // need at least 1 subdivision for our bias trick
+    if (shift == 0)
+        shift = 1;
+
+    fWinding    = SkToS8(winding);
+    fCurveShift = SkToU8(shift);
+    fCurveCount = SkToS16(1 << shift);
+
+    SkFixed A = SkFDot6ToFixed(x0 - x1 - x1 + x2);
+    SkFixed B = SkFDot6ToFixed(x1 - x0 + x1 - x0);
+
+    fQx     = SkFDot6ToFixed(x0);
+    fQDx    = B + (A >> shift);     // biased by shift
+    fQDDx   = A >> (shift - 1);     // biased by shift
+
+    A = SkFDot6ToFixed(y0 - y1 - y1 + y2);
+    B = SkFDot6ToFixed(y1 - y0 + y1 - y0);
+
+    fQy     = SkFDot6ToFixed(y0);
+    fQDy    = B + (A >> shift);     // biased by shift
+    fQDDy   = A >> (shift - 1);     // biased by shift
+
+    fQLastX = SkFDot6ToFixed(x2);
+    fQLastY = SkFDot6ToFixed(y2);
+
+    if (clip)
+    {
+        do {
+            for (;!this->updateQuadratic();)
+                ;
+        } while (!this->intersectsClip(*clip));
+        this->chopLineWithClip(*clip);
+        return 1;
+    }
+    return this->updateQuadratic();
 }
 
 int SkQuadraticEdge::updateQuadratic()
 {
-       int             success;
-       int             count = fCurveCount;
-       SkFixed oldx = fQx;
-       SkFixed oldy = fQy;
-       SkFixed newx, newy;
-       int             shift = fCurveShift;
-
-       SkASSERT(count > 0);
-
-       do {
-               if (--count > 0)
-               {
-                       newx    = oldx + (fQDx >> shift);
-                       fQDx    += fQDDx;
-                       newy    = oldy + (fQDy >> shift);
-                       fQDy    += fQDDy;
-               }
-               else    // last segment
-               {
-                       newx    = fQLastX;
-                       newy    = fQLastY;
-               }
-               success = this->updateLine(oldx, oldy, newx, newy);
-               oldx = newx;
-               oldy = newy;
-       } while (count > 0 && !success);
-
-       fQx                     = newx;
-       fQy                     = newy;
-       fCurveCount = SkToS16(count);
-       return success;
+    int     success;
+    int     count = fCurveCount;
+    SkFixed oldx = fQx;
+    SkFixed oldy = fQy;
+    SkFixed newx, newy;
+    int     shift = fCurveShift;
+
+    SkASSERT(count > 0);
+
+    do {
+        if (--count > 0)
+        {
+            newx    = oldx + (fQDx >> shift);
+            fQDx    += fQDDx;
+            newy    = oldy + (fQDy >> shift);
+            fQDy    += fQDDy;
+        }
+        else    // last segment
+        {
+            newx    = fQLastX;
+            newy    = fQLastY;
+        }
+        success = this->updateLine(oldx, oldy, newx, newy);
+        oldx = newx;
+        oldy = newy;
+    } while (count > 0 && !success);
+
+    fQx         = newx;
+    fQy         = newy;
+    fCurveCount = SkToS16(count);
+    return success;
 }
 
 /////////////////////////////////////////////////////////////////////////
 
-/*     f(1/3) = (8a + 12b + 6c + d) / 27
-       f(2/3) = (a + 6b + 12c + 8d) / 27
+/*  f(1/3) = (8a + 12b + 6c + d) / 27
+    f(2/3) = (a + 6b + 12c + 8d) / 27
 
-       f(1/3)-b = (8a - 15b + 6c + d) / 27
-       f(2/3)-c = (a + 6b - 15c + 8d) / 27
+    f(1/3)-b = (8a - 15b + 6c + d) / 27
+    f(2/3)-c = (a + 6b - 15c + 8d) / 27
 
-       use 16/512 to approximate 1/27
+    use 16/512 to approximate 1/27
 */
 static SkFDot6 cubic_delta_from_line(SkFDot6 a, SkFDot6 b, SkFDot6 c, SkFDot6 d)
 {
-       SkFDot6 oneThird = ((a << 3) - ((b << 4) - b) + 6*c + d) * 19 >> 9;
-       SkFDot6 twoThird = (a + 6*b - ((c << 4) - c) + (d << 3)) * 19 >> 9;
+    SkFDot6 oneThird = ((a << 3) - ((b << 4) - b) + 6*c + d) * 19 >> 9;
+    SkFDot6 twoThird = (a + 6*b - ((c << 4) - c) + (d << 3)) * 19 >> 9;
 
-       return SkMax32(SkAbs32(oneThird), SkAbs32(twoThird));
+    return SkMax32(SkAbs32(oneThird), SkAbs32(twoThird));
 }
 
 int SkCubicEdge::setCubic(const SkPoint pts[4], const SkRect16* clip, int shift)
 {
-       SkFDot6 x0, y0, x1, y1, x2, y2, x3, y3;
+    SkFDot6 x0, y0, x1, y1, x2, y2, x3, y3;
 
-       {
+    {
 #ifdef SK_SCALAR_IS_FLOAT
-               float scale = float(1 << (shift + 6));
-               x0 = int(pts[0].fX * scale);
-               y0 = int(pts[0].fY * scale);
-               x1 = int(pts[1].fX * scale);
-               y1 = int(pts[1].fY * scale);
-               x2 = int(pts[2].fX * scale);
-               y2 = int(pts[2].fY * scale);
-               x3 = int(pts[3].fX * scale);
-               y3 = int(pts[3].fY * scale);
+        float scale = float(1 << (shift + 6));
+        x0 = int(pts[0].fX * scale);
+        y0 = int(pts[0].fY * scale);
+        x1 = int(pts[1].fX * scale);
+        y1 = int(pts[1].fY * scale);
+        x2 = int(pts[2].fX * scale);
+        y2 = int(pts[2].fY * scale);
+        x3 = int(pts[3].fX * scale);
+        y3 = int(pts[3].fY * scale);
 #else
-               shift = 10 - shift;
-               x0 = pts[0].fX >> shift;
-               y0 = pts[0].fY >> shift;
-               x1 = pts[1].fX >> shift;
-               y1 = pts[1].fY >> shift;
-               x2 = pts[2].fX >> shift;
-               y2 = pts[2].fY >> shift;
-               x3 = pts[3].fX >> shift;
-               y3 = pts[3].fY >> shift;
+        shift = 10 - shift;
+        x0 = pts[0].fX >> shift;
+        y0 = pts[0].fY >> shift;
+        x1 = pts[1].fX >> shift;
+        y1 = pts[1].fY >> shift;
+        x2 = pts[2].fX >> shift;
+        y2 = pts[2].fY >> shift;
+        x3 = pts[3].fX >> shift;
+        y3 = pts[3].fY >> shift;
 #endif
-       }
-
-       int     winding = 1;
-       if (y0 > y3)
-       {
-               SkTSwap(x0, x3);
-               SkTSwap(x1, x2);
-               SkTSwap(y0, y3);
-               SkTSwap(y1, y2);
-               winding = -1;
-       }
-
-       int     top = SkFDot6Round(y0);
-       int     bot = SkFDot6Round(y3);
-
-       // are we a zero-height cubic (line)?
-       if (top == bot)
-               return 0;
-
-       // are we completely above or below the clip?
-       if (clip && (top >= clip->fBottom || bot <= clip->fTop))
-               return 0;
-
-       // compute number of steps needed (1 << shift)
-       {
-               // Can't use (center of curve - center of baseline), since center-of-curve
-               // need not be the max delta from the baseline (it could even be coincident)
-               // so we try just looking at the two off-curve points
-               SkFDot6 dx = cubic_delta_from_line(x0, x1, x2, x3);
-               SkFDot6 dy = cubic_delta_from_line(y0, y1, y2, y3);
-               // add 1 (by observation)
-               shift = diff_to_shift(dx, dy) + 1;
-       }
-       // need at least 1 subdivision for our bias trick
-       SkASSERT(shift > 0);
-
-       fWinding        = SkToS8(winding);
-       fCurveShift     = SkToU8(shift);
-       fCurveCount     = SkToS16(-1 << shift);
-
-       SkFixed B = SkFDot6ToFixed(3 * (x1 - x0));
-       SkFixed C = SkFDot6ToFixed(3 * (x0 - x1 - x1 + x2));
-       SkFixed D = SkFDot6ToFixed(x3 + 3 * (x1 - x2) - x0);
-
-       fCx             = SkFDot6ToFixed(x0);
-       fCDx    = B + (C >> shift) + (D >> 2*shift);    // biased by shift
-       fCDDx   = 2*C + (3*D >> (shift - 1));                   // biased by 2*shift
-       fCDDDx  = 3*D >> (shift - 1);                                   // biased by 2*shift
-
-       B = SkFDot6ToFixed(3 * (y1 - y0));
-       C = SkFDot6ToFixed(3 * (y0 - y1 - y1 + y2));
-       D = SkFDot6ToFixed(y3 + 3 * (y1 - y2) - y0);
-
-       fCy             = SkFDot6ToFixed(y0);
-       fCDy    = B + (C >> shift) + (D >> 2*shift);    // biased by shift
-       fCDDy   = 2*C + (3*D >> (shift - 1));                   // biased by 2*shift
-       fCDDDy  = 3*D >> (shift - 1);                                   // biased by 2*shift
-
-       fCLastX = SkFDot6ToFixed(x3);
-       fCLastY = SkFDot6ToFixed(y3);
-
-       if (clip)
-       {
-               do {
-                       for (;!this->updateCubic();)
-                               ;
-               } while (!this->intersectsClip(*clip));
-               this->chopLineWithClip(*clip);
-               return 1;
-       }
-       return this->updateCubic();
+    }
+
+    int winding = 1;
+    if (y0 > y3)
+    {
+        SkTSwap(x0, x3);
+        SkTSwap(x1, x2);
+        SkTSwap(y0, y3);
+        SkTSwap(y1, y2);
+        winding = -1;
+    }
+
+    int top = SkFDot6Round(y0);
+    int bot = SkFDot6Round(y3);
+
+    // are we a zero-height cubic (line)?
+    if (top == bot)
+        return 0;
+
+    // are we completely above or below the clip?
+    if (clip && (top >= clip->fBottom || bot <= clip->fTop))
+        return 0;
+
+    // compute number of steps needed (1 << shift)
+    {
+        // Can't use (center of curve - center of baseline), since center-of-curve
+        // need not be the max delta from the baseline (it could even be coincident)
+        // so we try just looking at the two off-curve points
+        SkFDot6 dx = cubic_delta_from_line(x0, x1, x2, x3);
+        SkFDot6 dy = cubic_delta_from_line(y0, y1, y2, y3);
+        // add 1 (by observation)
+        shift = diff_to_shift(dx, dy) + 1;
+    }
+    // need at least 1 subdivision for our bias trick
+    SkASSERT(shift > 0);
+
+    fWinding    = SkToS8(winding);
+    fCurveShift = SkToU8(shift);
+    fCurveCount = SkToS16(-1 << shift);
+
+    SkFixed B = SkFDot6ToFixed(3 * (x1 - x0));
+    SkFixed C = SkFDot6ToFixed(3 * (x0 - x1 - x1 + x2));
+    SkFixed D = SkFDot6ToFixed(x3 + 3 * (x1 - x2) - x0);
+
+    fCx     = SkFDot6ToFixed(x0);
+    fCDx    = B + (C >> shift) + (D >> 2*shift);    // biased by shift
+    fCDDx   = 2*C + (3*D >> (shift - 1));           // biased by 2*shift
+    fCDDDx  = 3*D >> (shift - 1);                   // biased by 2*shift
+
+    B = SkFDot6ToFixed(3 * (y1 - y0));
+    C = SkFDot6ToFixed(3 * (y0 - y1 - y1 + y2));
+    D = SkFDot6ToFixed(y3 + 3 * (y1 - y2) - y0);
+
+    fCy     = SkFDot6ToFixed(y0);
+    fCDy    = B + (C >> shift) + (D >> 2*shift);    // biased by shift
+    fCDDy   = 2*C + (3*D >> (shift - 1));           // biased by 2*shift
+    fCDDDy  = 3*D >> (shift - 1);                   // biased by 2*shift
+
+    fCLastX = SkFDot6ToFixed(x3);
+    fCLastY = SkFDot6ToFixed(y3);
+
+    if (clip)
+    {
+        do {
+            for (;!this->updateCubic();)
+                ;
+        } while (!this->intersectsClip(*clip));
+        this->chopLineWithClip(*clip);
+        return 1;
+    }
+    return this->updateCubic();
 }
 
 int SkCubicEdge::updateCubic()
 {
-       int             success;
-       int             count = fCurveCount;
-       SkFixed oldx = fCx;
-       SkFixed oldy = fCy;
-       SkFixed newx, newy;
-       int             shift = fCurveShift;
-
-       SkASSERT(count < 0);
-
-       do {
-               if (++count < 0)
-               {
-                       newx    = oldx + (fCDx >> shift);
-                       fCDx    += fCDDx >> shift;
-                       fCDDx   += fCDDDx;
-
-                       newy    = oldy + (fCDy >> shift);
-                       fCDy    += fCDDy >> shift;
-                       fCDDy   += fCDDDy;
-               }
-               else    // last segment
-               {
-               //      SkDebugf("LastX err=%d, LastY err=%d\n", (oldx + (fCDx >> shift) - fLastX), (oldy + (fCDy >> shift) - fLastY));
-                       newx    = fCLastX;
-                       newy    = fCLastY;
-               }
-               success = this->updateLine(oldx, oldy, newx, newy);
-               oldx = newx;
-               oldy = newy;
-       } while (count < 0 && !success);
-
-       fCx                     = newx;
-       fCy                     = newy;
-       fCurveCount = SkToS16(count);
-       return success;
+    int     success;
+    int     count = fCurveCount;
+    SkFixed oldx = fCx;
+    SkFixed oldy = fCy;
+    SkFixed newx, newy;
+    int     shift = fCurveShift;
+
+    SkASSERT(count < 0);
+
+    do {
+        if (++count < 0)
+        {
+            newx    = oldx + (fCDx >> shift);
+            fCDx    += fCDDx >> shift;
+            fCDDx   += fCDDDx;
+
+            newy    = oldy + (fCDy >> shift);
+            fCDy    += fCDDy >> shift;
+            fCDDy   += fCDDDy;
+        }
+        else    // last segment
+        {
+        //  SkDebugf("LastX err=%d, LastY err=%d\n", (oldx + (fCDx >> shift) - fLastX), (oldy + (fCDy >> shift) - fLastY));
+            newx    = fCLastX;
+            newy    = fCLastY;
+        }
+        success = this->updateLine(oldx, oldy, newx, newy);
+        oldx = newx;
+        oldy = newy;
+    } while (count < 0 && !success);
+
+    fCx         = newx;
+    fCy         = newy;
+    fCurveCount = SkToS16(count);
+    return success;
 }
 
 
index 73add2a..ef058a5 100644 (file)
@@ -1,77 +1,94 @@
+/* libs/graphics/sgl/SkEdge.h
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #ifndef SkEdge_DEFINED
 #define SkEdge_DEFINED
 
 #include "SkRect.h"
 
 struct SkEdge {
-       enum Type {
-               kLine_Type,
-               kQuad_Type,
-               kCubic_Type
-       };
+    enum Type {
+        kLine_Type,
+        kQuad_Type,
+        kCubic_Type
+    };
 
-       SkEdge* fNext;
-       SkEdge* fPrev;
+    SkEdge* fNext;
+    SkEdge* fPrev;
 
-       SkFixed fX;
-       SkFixed fDX;
-       S16             fFirstY;
-       S16             fLastY;
-       S16             fCurveCount;    // only used by kQuad(+) and kCubic(-)
-       U8              fCurveShift;
-       S8              fWinding;               // 1 or -1
+    SkFixed fX;
+    SkFixed fDX;
+    S16     fFirstY;
+    S16     fLastY;
+    S16     fCurveCount;    // only used by kQuad(+) and kCubic(-)
+    U8      fCurveShift;
+    S8      fWinding;       // 1 or -1
 
-       int             setLine(const SkPoint pts[2], const SkRect16* clip, int shiftUp);
-       inline int      updateLine(SkFixed ax, SkFixed ay, SkFixed bx, SkFixed by);
-       void    chopLineWithClip(const SkRect16& clip);
+    int     setLine(const SkPoint pts[2], const SkRect16* clip, int shiftUp);
+    inline int  updateLine(SkFixed ax, SkFixed ay, SkFixed bx, SkFixed by);
+    void    chopLineWithClip(const SkRect16& clip);
 
-       inline bool intersectsClip(const SkRect16& clip) const
-       {
-               SkASSERT(fFirstY < clip.fBottom);
-               return fLastY >= clip.fTop;
-       }
+    inline bool intersectsClip(const SkRect16& clip) const
+    {
+        SkASSERT(fFirstY < clip.fBottom);
+        return fLastY >= clip.fTop;
+    }
 
 #ifdef SK_DEBUG
-       void dump() const
-       {
+    void dump() const
+    {
     #ifdef SK_CAN_USE_FLOAT
-               SkDebugf("edge: firstY:%d lastY:%d x:%g dx:%g w:%d\n", fFirstY, fLastY, SkFixedToFloat(fX), SkFixedToFloat(fDX), fWinding);
+        SkDebugf("edge: firstY:%d lastY:%d x:%g dx:%g w:%d\n", fFirstY, fLastY, SkFixedToFloat(fX), SkFixedToFloat(fDX), fWinding);
     #else
-               SkDebugf("edge: firstY:%d lastY:%d x:%x dx:%x w:%d\n", fFirstY, fLastY, fX, fDX, fWinding);
+        SkDebugf("edge: firstY:%d lastY:%d x:%x dx:%x w:%d\n", fFirstY, fLastY, fX, fDX, fWinding);
     #endif
-       }
+    }
 
-       void validate() const
-       {
-               SkASSERT(fPrev && fNext);
-               SkASSERT(fPrev->fNext == this);
-               SkASSERT(fNext->fPrev == this);
+    void validate() const
+    {
+        SkASSERT(fPrev && fNext);
+        SkASSERT(fPrev->fNext == this);
+        SkASSERT(fNext->fPrev == this);
 
-               SkASSERT(fFirstY <= fLastY);
-               SkASSERT(SkAbs32(fWinding) == 1);
-       }
+        SkASSERT(fFirstY <= fLastY);
+        SkASSERT(SkAbs32(fWinding) == 1);
+    }
 #endif
 };
 
 struct SkQuadraticEdge : public SkEdge {
-       SkFixed fQx, fQy;
-       SkFixed fQDx, fQDy;
-       SkFixed fQDDx, fQDDy;
-       SkFixed fQLastX, fQLastY;
+    SkFixed fQx, fQy;
+    SkFixed fQDx, fQDy;
+    SkFixed fQDDx, fQDDy;
+    SkFixed fQLastX, fQLastY;
 
-       int setQuadratic(const SkPoint pts[3], const SkRect16* clip, int shiftUp);
-       int updateQuadratic();
+    int setQuadratic(const SkPoint pts[3], const SkRect16* clip, int shiftUp);
+    int updateQuadratic();
 };
 
 struct SkCubicEdge : public SkEdge {
-       SkFixed fCx, fCy;
-       SkFixed fCDx, fCDy;
-       SkFixed fCDDx, fCDDy;
-       SkFixed fCDDDx, fCDDDy;
-       SkFixed fCLastX, fCLastY;
+    SkFixed fCx, fCy;
+    SkFixed fCDx, fCDy;
+    SkFixed fCDDx, fCDDy;
+    SkFixed fCDDDx, fCDDDy;
+    SkFixed fCLastX, fCLastY;
 
-       int setCubic(const SkPoint pts[4], const SkRect16* clip, int shiftUp);
-       int     updateCubic();
+    int setCubic(const SkPoint pts[4], const SkRect16* clip, int shiftUp);
+    int updateCubic();
 };
 
 #endif
index eb311b8..b8e1d2f 100644 (file)
@@ -1,3 +1,20 @@
+/* libs/graphics/sgl/SkFP.h
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #ifndef SkFP_DEFINED
 #define SkFP_DEFINED
 
 
 #ifdef SK_SCALAR_IS_FLOAT
 
-       typedef float SkFP;
-
-       #define SkScalarToFP(n)             (n)
-       #define SkFPToScalar(n)             (n)
-       #define SkIntToFP(n)                    SkIntToScalar(n)
-       #define SkFPRound(x)                    SkScalarRound(n)
-       #define SkFPCeil(x)             SkScalarCeil(n)
-       #define SkFPFloor(x)                    SkScalarFloor(n)
-
-       #define SkFPNeg(x)              (-(x))
-       #define SkFPAbs(x)              SkScalarAbs(x)
-       #define SkFPAdd(a, b)           ((a) + (b))
-       #define SkFPSub(a, b)           ((a) - (b))
-       #define SkFPMul(a, b)           ((a) * (b))
-       #define SkFPMulInt(a, n)                ((a) * (n))
-       #define SkFPDiv(a, b)           ((a) / (b))
-       #define SkFPDivInt(a, n)                ((a) / (n))
-       #define SkFPInvert(x)           SkScalarInvert(x)
-       #define SkFPSqrt(x)             SkScalarSqrt(x)
-       #define SkFPCubeRoot(x)         pow(x, 1.0f/3)
-
-       #define SkFPLT(a, b)                    ((a) < (b))
-       #define SkFPLE(a, b)                    ((a) <= (b))
-       #define SkFPGT(a, b)                    ((a) > (b))
-       #define SkFPGE(a, b)                    ((a) >= (b))
-
-#else  // scalar is fixed
-
-       #include "SkFloat.h"
-
-       typedef S32     SkFP;
-
-       #define SkScalarToFP(n)             SkFloat::SetShift(n, -16)
-       #define SkFPToScalar(n)             SkFloat::GetShift(n, -16)
-       #define SkIntToFP(n)                    SkFloat::SetShift(n, 0)
-       #define SkFPRound(x)                    SkFloat::Round(x);
-       #define SkFPCeil(x)             SkFloat::Ceil();
-       #define SkFPFloor(x)                    SkFloat::Floor();
-
-       #define SkFPNeg(x)              SkFloat::Neg(x)
-       #define SkFPAbs(x)              SkFloat::Abs(x)
-       #define SkFPAdd(a, b)           SkFloat::Add(a, b)
-       #define SkFPSub(a, b)           SkFloat::Add(a, SkFloat::Neg(b))
-       #define SkFPMul(a, b)           SkFloat::Mul(a, b)
-       #define SkFPMulInt(a, n)                SkFloat::MulInt(a, n)
-       #define SkFPDiv(a, b)           SkFloat::Div(a, b)
-       #define SkFPDivInt(a, n)                SkFloat::DivInt(a, n)
-       #define SkFPInvert(x)           SkFloat::Invert(x)
-       #define SkFPSqrt(x)             SkFloat::Sqrt(x)
-       #define SkFPCubeRoot(x)         SkFloat::CubeRoot(x)
-
-       #define SkFPLT(a, b)                    (SkFloat::Cmp(a, b) < 0)
-       #define SkFPLE(a, b)                    (SkFloat::Cmp(a, b) <= 0)
-       #define SkFPGT(a, b)                    (SkFloat::Cmp(a, b) > 0)
-       #define SkFPGE(a, b)                    (SkFloat::Cmp(a, b) >= 0)
+    typedef float SkFP;
+
+    #define SkScalarToFP(n)         (n)
+    #define SkFPToScalar(n)         (n)
+    #define SkIntToFP(n)            SkIntToScalar(n)
+    #define SkFPRound(x)            SkScalarRound(n)
+    #define SkFPCeil(x)             SkScalarCeil(n)
+    #define SkFPFloor(x)            SkScalarFloor(n)
+
+    #define SkFPNeg(x)              (-(x))
+    #define SkFPAbs(x)              SkScalarAbs(x)
+    #define SkFPAdd(a, b)           ((a) + (b))
+    #define SkFPSub(a, b)           ((a) - (b))
+    #define SkFPMul(a, b)           ((a) * (b))
+    #define SkFPMulInt(a, n)        ((a) * (n))
+    #define SkFPDiv(a, b)           ((a) / (b))
+    #define SkFPDivInt(a, n)        ((a) / (n))
+    #define SkFPInvert(x)           SkScalarInvert(x)
+    #define SkFPSqrt(x)             SkScalarSqrt(x)
+    #define SkFPCubeRoot(x)         pow(x, 1.0f/3)
+
+    #define SkFPLT(a, b)            ((a) < (b))
+    #define SkFPLE(a, b)            ((a) <= (b))
+    #define SkFPGT(a, b)            ((a) > (b))
+    #define SkFPGE(a, b)            ((a) >= (b))
+
+#else   // scalar is fixed
+
+    #include "SkFloat.h"
+
+    typedef S32 SkFP;
+
+    #define SkScalarToFP(n)         SkFloat::SetShift(n, -16)
+    #define SkFPToScalar(n)         SkFloat::GetShift(n, -16)
+    #define SkIntToFP(n)            SkFloat::SetShift(n, 0)
+    #define SkFPRound(x)            SkFloat::Round(x);
+    #define SkFPCeil(x)             SkFloat::Ceil();
+    #define SkFPFloor(x)            SkFloat::Floor();
+
+    #define SkFPNeg(x)              SkFloat::Neg(x)
+    #define SkFPAbs(x)              SkFloat::Abs(x)
+    #define SkFPAdd(a, b)           SkFloat::Add(a, b)
+    #define SkFPSub(a, b)           SkFloat::Add(a, SkFloat::Neg(b))
+    #define SkFPMul(a, b)           SkFloat::Mul(a, b)
+    #define SkFPMulInt(a, n)        SkFloat::MulInt(a, n)
+    #define SkFPDiv(a, b)           SkFloat::Div(a, b)
+    #define SkFPDivInt(a, n)        SkFloat::DivInt(a, n)
+    #define SkFPInvert(x)           SkFloat::Invert(x)
+    #define SkFPSqrt(x)             SkFloat::Sqrt(x)
+    #define SkFPCubeRoot(x)         SkFloat::CubeRoot(x)
+
+    #define SkFPLT(a, b)            (SkFloat::Cmp(a, b) < 0)
+    #define SkFPLE(a, b)            (SkFloat::Cmp(a, b) <= 0)
+    #define SkFPGT(a, b)            (SkFloat::Cmp(a, b) > 0)
+    #define SkFPGE(a, b)            (SkFloat::Cmp(a, b) >= 0)
 
 #endif
 
 #ifdef SK_DEBUG
-       void SkFP_UnitTest();
+    void SkFP_UnitTest();
 #endif
 
 #endif
index b51fa93..741517c 100644 (file)
@@ -1,7 +1,24 @@
+/* libs/graphics/sgl/SkFilterProc.cpp
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #include "SkFilterProc.h"
 
-/*     [1-x 1-y] [x 1-y]
-       [1-x   y] [x   y]
+/*  [1-x 1-y] [x 1-y]
+    [1-x   y] [x   y]
 */
 
 static unsigned bilerp00(unsigned a00, unsigned a01, unsigned a10, unsigned a11) { return a00; }
@@ -25,14 +42,161 @@ static unsigned bilerp32(unsigned a00, unsigned a01, unsigned a10, unsigned a11)
 static unsigned bilerp33(unsigned a00, unsigned a01, unsigned a10, unsigned a11) { return (9 * a11 + 3 * (a01 + a10) + a00) >> 4; }
 
 static const SkFilterProc gBilerpProcs[4 * 4] = {
-       bilerp00, bilerp01, bilerp02, bilerp03,
-       bilerp10, bilerp11, bilerp12, bilerp13,
-       bilerp20, bilerp21, bilerp22, bilerp23,
-       bilerp30, bilerp31, bilerp32, bilerp33
+    bilerp00, bilerp01, bilerp02, bilerp03,
+    bilerp10, bilerp11, bilerp12, bilerp13,
+    bilerp20, bilerp21, bilerp22, bilerp23,
+    bilerp30, bilerp31, bilerp32, bilerp33
 };
 
 const SkFilterProc* SkGetBilinearFilterProcTable()
 {
-       return gBilerpProcs;
+    return gBilerpProcs;
+}
+
+#define MASK            0xFF00FF
+#define LO_PAIR(x)      ((x) & MASK)
+#define HI_PAIR(x)      (((x) >> 8) & MASK)
+#define COMBINE(lo, hi) (((lo) & ~0xFF00) | (((hi) & ~0xFF00) << 8))
+
+static unsigned bilerptr00(const uint32_t* a00, const uint32_t* a01, const uint32_t* a10, const uint32_t* a11) {
+    return *a00;
+}
+static unsigned bilerptr01(const uint32_t* a00, const uint32_t* a01, const uint32_t* a10, const uint32_t* a11) {
+    uint32_t c00 = *a00;
+    uint32_t c01 = *a01;   
+    uint32_t lo = (3 * LO_PAIR(c00) + LO_PAIR(c01)) >> 2;
+    uint32_t hi = (3 * HI_PAIR(c00) + HI_PAIR(c01)) >> 2;
+    return COMBINE(lo, hi);
+}
+static unsigned bilerptr02(const uint32_t* a00, const uint32_t* a01, const uint32_t* a10, const uint32_t* a11) {
+    uint32_t c00 = *a00;
+    uint32_t c01 = *a01;   
+    uint32_t lo = (LO_PAIR(c00) + LO_PAIR(c01)) >> 1;
+    uint32_t hi = (HI_PAIR(c00) + HI_PAIR(c01)) >> 1;
+    return COMBINE(lo, hi);
+}
+static unsigned bilerptr03(const uint32_t* a00, const uint32_t* a01, const uint32_t* a10, const uint32_t* a11) {
+    uint32_t c00 = *a00;
+    uint32_t c01 = *a01;
+    uint32_t lo = (LO_PAIR(c00) + 3 * LO_PAIR(c01)) >> 2;
+    uint32_t hi = (HI_PAIR(c00) + 3 * HI_PAIR(c01)) >> 2;
+    return COMBINE(lo, hi);
+}
+
+static unsigned bilerptr10(const uint32_t* a00, const uint32_t* a01, const uint32_t* a10, const uint32_t* a11) {
+    uint32_t c00 = *a00;
+    uint32_t c10 = *a10;
+    uint32_t lo = (3 * LO_PAIR(c00) + LO_PAIR(c10)) >> 2;
+    uint32_t hi = (3 * HI_PAIR(c00) + HI_PAIR(c10)) >> 2;
+    return COMBINE(lo, hi);
+}
+static unsigned bilerptr11(const uint32_t* a00, const uint32_t* a01, const uint32_t* a10, const uint32_t* a11) {
+    uint32_t c00 = *a00;
+    uint32_t c01 = *a01;
+    uint32_t c10 = *a10;
+    uint32_t c11 = *a11;
+    uint32_t lo = (9 * LO_PAIR(c00) + 3 * (LO_PAIR(c01) + LO_PAIR(c10)) + LO_PAIR(c11)) >> 4;
+    uint32_t hi = (9 * HI_PAIR(c00) + 3 * (HI_PAIR(c01) + HI_PAIR(c10)) + HI_PAIR(c11)) >> 4;
+    return COMBINE(lo, hi);
+}
+static unsigned bilerptr12(const uint32_t* a00, const uint32_t* a01, const uint32_t* a10, const uint32_t* a11) {
+    uint32_t c00 = *a00;
+    uint32_t c01 = *a01;
+    uint32_t c10 = *a10;
+    uint32_t c11 = *a11;
+    uint32_t lo = (3 * (LO_PAIR(c00) + LO_PAIR(c01)) + LO_PAIR(c10) + LO_PAIR(c11)) >> 3;
+    uint32_t hi = (3 * (HI_PAIR(c00) + HI_PAIR(c01)) + HI_PAIR(c10) + HI_PAIR(c11)) >> 3;
+    return COMBINE(lo, hi);
+}
+static unsigned bilerptr13(const uint32_t* a00, const uint32_t* a01, const uint32_t* a10, const uint32_t* a11) {
+    uint32_t c00 = *a00;
+    uint32_t c01 = *a01;
+    uint32_t c10 = *a10;
+    uint32_t c11 = *a11;
+    uint32_t lo = (9 * LO_PAIR(c01) + 3 * (LO_PAIR(c00) + LO_PAIR(c11)) + LO_PAIR(c10)) >> 4;
+    uint32_t hi = (9 * HI_PAIR(c01) + 3 * (HI_PAIR(c00) + HI_PAIR(c11)) + HI_PAIR(c10)) >> 4;
+    return COMBINE(lo, hi);
+}
+
+static unsigned bilerptr20(const uint32_t* a00, const uint32_t* a01, const uint32_t* a10, const uint32_t* a11) {
+    uint32_t c00 = *a00;
+    uint32_t c10 = *a10;
+    uint32_t lo = (LO_PAIR(c00) + LO_PAIR(c10)) >> 1;
+    uint32_t hi = (HI_PAIR(c00) + HI_PAIR(c10)) >> 1;
+    return COMBINE(lo, hi);
+}
+static unsigned bilerptr21(const uint32_t* a00, const uint32_t* a01, const uint32_t* a10, const uint32_t* a11) {
+    uint32_t c00 = *a00;
+    uint32_t c01 = *a01;
+    uint32_t c10 = *a10;
+    uint32_t c11 = *a11;
+    uint32_t lo = (3 * (LO_PAIR(c00) + LO_PAIR(c10)) + LO_PAIR(c01) + LO_PAIR(c11)) >> 3;
+    uint32_t hi = (3 * (HI_PAIR(c00) + HI_PAIR(c10)) + HI_PAIR(c01) + HI_PAIR(c11)) >> 3;
+    return COMBINE(lo, hi);
+}
+static unsigned bilerptr22(const uint32_t* a00, const uint32_t* a01, const uint32_t* a10, const uint32_t* a11) {
+    uint32_t c00 = *a00;
+    uint32_t c01 = *a01;
+    uint32_t c10 = *a10;
+    uint32_t c11 = *a11;
+    uint32_t lo = (LO_PAIR(c00) + LO_PAIR(c01) + LO_PAIR(c10) + LO_PAIR(c11)) >> 2;
+    uint32_t hi = (HI_PAIR(c00) + HI_PAIR(c01) + HI_PAIR(c10) + HI_PAIR(c11)) >> 2;
+    return COMBINE(lo, hi);
+}
+static unsigned bilerptr23(const uint32_t* a00, const uint32_t* a01, const uint32_t* a10, const uint32_t* a11) {
+    uint32_t c00 = *a00;
+    uint32_t c01 = *a01;
+    uint32_t c10 = *a10;
+    uint32_t c11 = *a11;
+    uint32_t lo = (3 * (LO_PAIR(c01) + LO_PAIR(c11)) + LO_PAIR(c00) + LO_PAIR(c10)) >> 3;
+    uint32_t hi = (3 * (HI_PAIR(c01) + HI_PAIR(c11)) + HI_PAIR(c00) + HI_PAIR(c10)) >> 3;
+    return COMBINE(lo, hi);
+}
+
+static unsigned bilerptr30(const uint32_t* a00, const uint32_t* a01, const uint32_t* a10, const uint32_t* a11) {
+    uint32_t c00 = *a00;
+    uint32_t c10 = *a10;
+    uint32_t lo = (LO_PAIR(c00) + 3 * LO_PAIR(c10)) >> 2;
+    uint32_t hi = (HI_PAIR(c00) + 3 * HI_PAIR(c10)) >> 2;
+    return COMBINE(lo, hi);
+}
+static unsigned bilerptr31(const uint32_t* a00, const uint32_t* a01, const uint32_t* a10, const uint32_t* a11) {
+    uint32_t c00 = *a00;
+    uint32_t c01 = *a01;
+    uint32_t c10 = *a10;
+    uint32_t c11 = *a11;
+    uint32_t lo = (9 * LO_PAIR(c10) + 3 * (LO_PAIR(c00) + LO_PAIR(c11)) + LO_PAIR(c01)) >> 4;
+    uint32_t hi = (9 * HI_PAIR(c10) + 3 * (HI_PAIR(c00) + HI_PAIR(c11)) + HI_PAIR(c01)) >> 4;
+    return COMBINE(lo, hi);
+}
+static unsigned bilerptr32(const uint32_t* a00, const uint32_t* a01, const uint32_t* a10, const uint32_t* a11) {
+    uint32_t c00 = *a00;
+    uint32_t c01 = *a01;
+    uint32_t c10 = *a10;
+    uint32_t c11 = *a11;
+    uint32_t lo = (3 * (LO_PAIR(c10) + LO_PAIR(c11)) + LO_PAIR(c00) + LO_PAIR(c01)) >> 3;
+    uint32_t hi = (3 * (HI_PAIR(c10) + HI_PAIR(c11)) + HI_PAIR(c00) + HI_PAIR(c01)) >> 3;
+    return COMBINE(lo, hi);
+}
+static unsigned bilerptr33(const uint32_t* a00, const uint32_t* a01, const uint32_t* a10, const uint32_t* a11) {
+    uint32_t c00 = *a00;
+    uint32_t c01 = *a01;
+    uint32_t c10 = *a10;
+    uint32_t c11 = *a11;
+    uint32_t lo = (9 * LO_PAIR(c11) + 3 * (LO_PAIR(c01) + LO_PAIR(c10)) + LO_PAIR(c00)) >> 4;
+    uint32_t hi = (9 * HI_PAIR(c11) + 3 * (HI_PAIR(c01) + HI_PAIR(c10)) + HI_PAIR(c00)) >> 4;
+    return COMBINE(lo, hi);
+}
+
+static const SkFilterPtrProc gBilerpPtrProcs[4 * 4] = {
+    bilerptr00, bilerptr01, bilerptr02, bilerptr03,
+    bilerptr10, bilerptr11, bilerptr12, bilerptr13,
+    bilerptr20, bilerptr21, bilerptr22, bilerptr23,
+    bilerptr30, bilerptr31, bilerptr32, bilerptr33
+};
+
+const SkFilterPtrProc* SkGetBilinearFilterPtrProcTable()
+{
+    return gBilerpPtrProcs;
 }
 
index a9c7223..993db83 100644 (file)
@@ -1,3 +1,20 @@
+/* libs/graphics/sgl/SkFilterProc.h
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #ifndef SkFilter_DEFINED
 #define SkFilter_DEFINED
 
@@ -9,12 +26,52 @@ const SkFilterProc* SkGetBilinearFilterProcTable();
 
 inline SkFilterProc SkGetBilinearFilterProc(const SkFilterProc* table, SkFixed x, SkFixed y)
 {
-       SkASSERT(table);
+    SkASSERT(table);
+
+    // convert to dot 2
+    x = (unsigned)(x << 16) >> 30;
+    y = (unsigned)(y << 16) >> 30;
+    return table[(y << 2) | x];
+}
+
+/** Special version of SkFilterProc. This takes the address of 4 ints, and combines them a byte at a
+    time. AABBCCDD.
+*/
+typedef uint32_t (*SkFilterPtrProc)(const uint32_t*, const uint32_t*, const uint32_t*, const uint32_t*);
+
+const SkFilterPtrProc* SkGetBilinearFilterPtrProcTable();
+inline SkFilterPtrProc SkGetBilinearFilterPtrProc(const SkFilterPtrProc* table, SkFixed x, SkFixed y)
+{
+    SkASSERT(table);
+
+    // convert to dot 2
+    x = (unsigned)(x << 16) >> 30;
+    y = (unsigned)(y << 16) >> 30;
+    return table[(y << 2) | x];
+}
+
+/** Given a Y value, return a subset of the proc table for that value.
+    Pass this to SkGetBilinearFilterPtrXProc with the corresponding X value to get the
+    correct proc.
+*/
+inline const SkFilterPtrProc* SkGetBilinearFilterPtrProcYTable(const SkFilterPtrProc* table, SkFixed y)
+{
+    SkASSERT(table);
+
+    y = (unsigned)(y << 16) >> 30;
+    return table + (y << 2);
+}
+
+/** Given a subtable returned by SkGetBilinearFilterPtrProcYTable(), return the proc for the
+    specified X value.
+*/
+inline SkFilterPtrProc SkGetBilinearFilterPtrXProc(const SkFilterPtrProc* table, SkFixed x)
+{
+    SkASSERT(table);
 
-       // convert to dot 2
-       x = (unsigned)(x << 16) >> 30;
-       y = (unsigned)(y << 16) >> 30;
-       return table[(y << 2) | x];
+    // convert to dot 2
+    x = (unsigned)(x << 16) >> 30;
+    return table[x];
 }
 
 #endif
index fe47cff..bc190f9 100644 (file)
+/* libs/graphics/sgl/SkGeometry.cpp
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #include "SkGeometry.h"
 #include "Sk64.h"
 #include "SkMatrix.h"
 
-/**    If defined, this makes eval_quad and eval_cubic do more setup (sometimes
-       involving integer multiplies by 2 or 3, but fewer calls to SkScalarMul.
-       May also introduce overflow of fixed when we compute our setup.
+/** If defined, this makes eval_quad and eval_cubic do more setup (sometimes
+    involving integer multiplies by 2 or 3, but fewer calls to SkScalarMul.
+    May also introduce overflow of fixed when we compute our setup.
 */
 #ifdef SK_SCALAR_IS_FIXED
-       #define DIRECT_EVAL_OF_POLYNOMIALS
+    #define DIRECT_EVAL_OF_POLYNOMIALS
 #endif
 
 ////////////////////////////////////////////////////////////////////////
 
 #if defined(SK_SCALAR_IS_FIXED) && !defined(SK_CPU_HAS_CONDITIONAL_INSTR)
-       static int is_not_monotonic(int a, int b, int c, int d)
-       {
-               return (((a - b) | (b - c) | (c - d)) & ((b - a) | (c - b) | (d - c))) >> 31;
-       }
-       static int is_not_monotonic(int a, int b, int c)
-       {
-               return (((a - b) | (b - c)) & ((b - a) | (c - b))) >> 31;
-       }
+    static int is_not_monotonic(int a, int b, int c, int d)
+    {
+        return (((a - b) | (b - c) | (c - d)) & ((b - a) | (c - b) | (d - c))) >> 31;
+    }
+    static int is_not_monotonic(int a, int b, int c)
+    {
+        return (((a - b) | (b - c)) & ((b - a) | (c - b))) >> 31;
+    }
 #else   // scalar-is-float or we have fast if/then instructions
-       static int is_not_monotonic(SkScalar a, SkScalar b, SkScalar c, SkScalar d)
-       {
-               int neg = 0, pos = 0;
-
-               if (a < b) neg = 1;
-               if (a > b) pos = 1;
-               if (b < c) neg = 1;
-               if (b > c) pos = 1;
-               if (c < d) neg = 1;
-               if (c > d) pos = 1;
-
-               return neg & pos;
-       }
-       static int is_not_monotonic(SkScalar a, SkScalar b, SkScalar c)
-       {
-               int neg = 0, pos = 0;
-
-               if (a < b) neg = 1;
-               if (a > b) pos = 1;
-               if (b < c) neg = 1;
-               if (b > c) pos = 1;
-
-               return neg & pos;
-       }
+    static int is_not_monotonic(SkScalar a, SkScalar b, SkScalar c, SkScalar d)
+    {
+        int neg = 0, pos = 0;
+
+        if (a < b) neg = 1;
+        if (a > b) pos = 1;
+        if (b < c) neg = 1;
+        if (b > c) pos = 1;
+        if (c < d) neg = 1;
+        if (c > d) pos = 1;
+
+        return neg & pos;
+    }
+    static int is_not_monotonic(SkScalar a, SkScalar b, SkScalar c)
+    {
+        int neg = 0, pos = 0;
+
+        if (a < b) neg = 1;
+        if (a > b) pos = 1;
+        if (b < c) neg = 1;
+        if (b > c) pos = 1;
+
+        return neg & pos;
+    }
 #endif
 
 ////////////////////////////////////////////////////////////////////////
 
 static bool is_unit_interval(SkScalar x)
 {
-       return x > 0 && x < SK_Scalar1;
+    return x > 0 && x < SK_Scalar1;
 }
 
 static int valid_unit_divide(SkScalar numer, SkScalar denom, SkScalar* ratio)
 {
-       if (numer < 0)
-       {
-               numer = -numer;
-               denom = -denom;
-       }
+    if (numer < 0)
+    {
+        numer = -numer;
+        denom = -denom;
+    }
 
-       if (denom == 0 || numer == 0 || numer >= denom)
-               return 0;
+    if (denom == 0 || numer == 0 || numer >= denom)
+        return 0;
 
-       if (ratio)
-       {
-               SkScalar r = SkScalarDiv(numer, denom);
-               SkASSERT(r >= 0 && r < SK_Scalar1);
-               if (r == 0)     // catch underflow if numer <<<< denom
-                       return 0;
-               *ratio = r;
-       }
-       return 1;
+    if (ratio)
+    {
+        SkScalar r = SkScalarDiv(numer, denom);
+        SkASSERT(r >= 0 && r < SK_Scalar1);
+        if (r == 0) // catch underflow if numer <<<< denom
+            return 0;
+        *ratio = r;
+    }
+    return 1;
 }
 
-/**    From Numerical Recipes in C.
+/** From Numerical Recipes in C.
 
-       Q = -1/2 (B + sign(B) sqrt[B*B - 4*A*C])
-       x1 = Q / A
-       x2 = C / Q
+    Q = -1/2 (B + sign(B) sqrt[B*B - 4*A*C])
+    x1 = Q / A
+    x2 = C / Q
 */
 int SkFindUnitQuadRoots(SkScalar A, SkScalar B, SkScalar C, SkScalar roots[2])
 {
-       SkScalar* r = roots;
+    SkScalar* r = roots;
 
-       if (A == 0)
-               return valid_unit_divide(-C, B, roots);
+    if (A == 0)
+        return valid_unit_divide(-C, B, roots);
 
 #ifdef SK_SCALAR_IS_FLOAT
-       float R = B*B - 4*A*C;
-       if (R < 0)      // complex roots
-               return 0;
-       R = sk_float_sqrt(R);
+    float R = B*B - 4*A*C;
+    if (R < 0)  // complex roots
+        return 0;
+    R = sk_float_sqrt(R);
 #else
-       Sk64    RR, tmp;
-
-       RR.setMul(B,B);
-       tmp.setMul(A,C);
-       tmp.shiftLeft(2);
-       RR.sub(tmp);
-       if (RR.isNeg())
-               return 0;
-       SkFixed R = RR.getSqrt();
+    Sk64    RR, tmp;
+
+    RR.setMul(B,B);
+    tmp.setMul(A,C);
+    tmp.shiftLeft(2);
+    RR.sub(tmp);
+    if (RR.isNeg())
+        return 0;
+    SkFixed R = RR.getSqrt();
 #endif
 
-       SkScalar Q = (B < 0) ? -(B-R)/2 : -(B+R)/2;
-       r += valid_unit_divide(Q, A, r);
-       r += valid_unit_divide(C, Q, r);
-       if (r - roots == 2)
-       {
-               if (roots[0] > roots[1])
-                       SkTSwap<SkScalar>(roots[0], roots[1]);
-               else if (roots[0] == roots[1])  // nearly-equal?
-                       r -= 1; // skip the double root
-       }
-       return (int)(r - roots);
+    SkScalar Q = (B < 0) ? -(B-R)/2 : -(B+R)/2;
+    r += valid_unit_divide(Q, A, r);
+    r += valid_unit_divide(C, Q, r);
+    if (r - roots == 2)
+    {
+        if (roots[0] > roots[1])
+            SkTSwap<SkScalar>(roots[0], roots[1]);
+        else if (roots[0] == roots[1])  // nearly-equal?
+            r -= 1; // skip the double root
+    }
+    return (int)(r - roots);
 }
 
 #ifdef SK_SCALAR_IS_FIXED
-/**    Trim A/B/C down so that they are all <= 32bits
-       and then call SkFindUnitQuadRoots()
+/** Trim A/B/C down so that they are all <= 32bits
+    and then call SkFindUnitQuadRoots()
 */
 static int Sk64FindFixedQuadRoots(const Sk64& A, const Sk64& B, const Sk64& C, SkFixed roots[2])
 {
-       int     na = A.shiftToMake32();
-       int     nb = B.shiftToMake32();
-       int     nc = C.shiftToMake32();
+    int na = A.shiftToMake32();
+    int nb = B.shiftToMake32();
+    int nc = C.shiftToMake32();
 
-       int shift = SkMax32(na, SkMax32(nb, nc));
-       SkASSERT(shift >= 0);
+    int shift = SkMax32(na, SkMax32(nb, nc));
+    SkASSERT(shift >= 0);
 
-       return SkFindUnitQuadRoots(A.getShiftRight(shift), B.getShiftRight(shift), C.getShiftRight(shift), roots);
+    return SkFindUnitQuadRoots(A.getShiftRight(shift), B.getShiftRight(shift), C.getShiftRight(shift), roots);
 }
 #endif
 
@@ -142,119 +159,119 @@ static int Sk64FindFixedQuadRoots(const Sk64& A, const Sk64& B, const Sk64& C, S
 
 static SkScalar eval_quad(const SkScalar src[], SkScalar t)
 {
-       SkASSERT(src);
-       SkASSERT(t >= 0 && t <= SK_Scalar1);
+    SkASSERT(src);
+    SkASSERT(t >= 0 && t <= SK_Scalar1);
 
 #ifdef DIRECT_EVAL_OF_POLYNOMIALS
-       SkScalar        C = src[0];
-       SkScalar        A = src[4] - 2 * src[2] + C;
-       SkScalar        B = 2 * (src[2] - C);
-       return SkScalarMul(SkScalarMul(A, t) + B, t) + C;
+    SkScalar    C = src[0];
+    SkScalar    A = src[4] - 2 * src[2] + C;
+    SkScalar    B = 2 * (src[2] - C);
+    return SkScalarMul(SkScalarMul(A, t) + B, t) + C;
 #else
-       SkScalar        ab = SkScalarInterp(src[0], src[2], t);
-       SkScalar        bc = SkScalarInterp(src[2], src[4], t); 
-       return SkScalarInterp(ab, bc, t);
+    SkScalar    ab = SkScalarInterp(src[0], src[2], t);
+    SkScalar    bc = SkScalarInterp(src[2], src[4], t); 
+    return SkScalarInterp(ab, bc, t);
 #endif
 }
 
 static SkScalar eval_quad_derivative(const SkScalar src[], SkScalar t)
 {
-       SkScalar A = src[4] - 2 * src[2] + src[0];
-       SkScalar B = src[2] - src[0];
+    SkScalar A = src[4] - 2 * src[2] + src[0];
+    SkScalar B = src[2] - src[0];
 
-       return 2 * (SkScalarMul(A, t) + B);
+    return 2 * (SkScalarMul(A, t) + B);
 }
 
 static SkScalar eval_quad_derivative_at_half(const SkScalar src[])
 {
-       SkScalar A = src[4] - 2 * src[2] + src[0];
-       SkScalar B = src[2] - src[0];
-       return A + 2 * B;
+    SkScalar A = src[4] - 2 * src[2] + src[0];
+    SkScalar B = src[2] - src[0];
+    return A + 2 * B;
 }
 
 void SkEvalQuadAt(const SkPoint src[3], SkScalar t, SkPoint* pt, SkVector* tangent)
 {
-       SkASSERT(src);
-       SkASSERT(t >= 0 && t <= SK_Scalar1);
-
-       if (pt)
-               pt->set(eval_quad(&src[0].fX, t), eval_quad(&src[0].fY, t));
-       if (tangent)
-               tangent->set(eval_quad_derivative(&src[0].fX, t),
-                                        eval_quad_derivative(&src[0].fY, t));
+    SkASSERT(src);
+    SkASSERT(t >= 0 && t <= SK_Scalar1);
+
+    if (pt)
+        pt->set(eval_quad(&src[0].fX, t), eval_quad(&src[0].fY, t));
+    if (tangent)
+        tangent->set(eval_quad_derivative(&src[0].fX, t),
+                     eval_quad_derivative(&src[0].fY, t));
 }
 
 void SkEvalQuadAtHalf(const SkPoint src[3], SkPoint* pt, SkVector* tangent)
 {
-       SkASSERT(src);
+    SkASSERT(src);
 
-       if (pt)
-       {
-               SkScalar x01 = SkScalarAve(src[0].fX, src[1].fX);
-               SkScalar y01 = SkScalarAve(src[0].fY, src[1].fY);
-               SkScalar x12 = SkScalarAve(src[1].fX, src[2].fX);
-               SkScalar y12 = SkScalarAve(src[1].fY, src[2].fY);
-               pt->set(SkScalarAve(x01, x12), SkScalarAve(y01, y12));
-       }
-       if (tangent)
-               tangent->set(eval_quad_derivative_at_half(&src[0].fX),
-                                        eval_quad_derivative_at_half(&src[0].fY));
+    if (pt)
+    {
+        SkScalar x01 = SkScalarAve(src[0].fX, src[1].fX);
+        SkScalar y01 = SkScalarAve(src[0].fY, src[1].fY);
+        SkScalar x12 = SkScalarAve(src[1].fX, src[2].fX);
+        SkScalar y12 = SkScalarAve(src[1].fY, src[2].fY);
+        pt->set(SkScalarAve(x01, x12), SkScalarAve(y01, y12));
+    }
+    if (tangent)
+        tangent->set(eval_quad_derivative_at_half(&src[0].fX),
+                     eval_quad_derivative_at_half(&src[0].fY));
 }
 
 static void interp_quad_coords(const SkScalar* src, SkScalar* dst, SkScalar t)
 {
-       SkScalar        ab = SkScalarInterp(src[0], src[2], t);
-       SkScalar        bc = SkScalarInterp(src[2], src[4], t);
-
-       dst[0] = src[0];
-       dst[2] = ab;
-       dst[4] = SkScalarInterp(ab, bc, t);
-       dst[6] = bc;
-       dst[8] = src[4];
+    SkScalar    ab = SkScalarInterp(src[0], src[2], t);
+    SkScalar    bc = SkScalarInterp(src[2], src[4], t);
+
+    dst[0] = src[0];
+    dst[2] = ab;
+    dst[4] = SkScalarInterp(ab, bc, t);
+    dst[6] = bc;
+    dst[8] = src[4];
 }
 
 void SkChopQuadAt(const SkPoint src[3], SkPoint dst[5], SkScalar t)
 {
-       SkASSERT(t > 0 && t < SK_Scalar1);
+    SkASSERT(t > 0 && t < SK_Scalar1);
 
-       interp_quad_coords(&src[0].fX, &dst[0].fX, t);
-       interp_quad_coords(&src[0].fY, &dst[0].fY, t);
+    interp_quad_coords(&src[0].fX, &dst[0].fX, t);
+    interp_quad_coords(&src[0].fY, &dst[0].fY, t);
 }
 
 void SkChopQuadAtHalf(const SkPoint src[3], SkPoint dst[5])
 {
-       SkScalar x01 = SkScalarAve(src[0].fX, src[1].fX);
-       SkScalar y01 = SkScalarAve(src[0].fY, src[1].fY);
-       SkScalar x12 = SkScalarAve(src[1].fX, src[2].fX);
-       SkScalar y12 = SkScalarAve(src[1].fY, src[2].fY);
-
-       dst[0] = src[0];
-       dst[1].set(x01, y01);
-       dst[2].set(SkScalarAve(x01, x12), SkScalarAve(y01, y12));
-       dst[3].set(x12, y12);
-       dst[4] = src[2];
+    SkScalar x01 = SkScalarAve(src[0].fX, src[1].fX);
+    SkScalar y01 = SkScalarAve(src[0].fY, src[1].fY);
+    SkScalar x12 = SkScalarAve(src[1].fX, src[2].fX);
+    SkScalar y12 = SkScalarAve(src[1].fY, src[2].fY);
+
+    dst[0] = src[0];
+    dst[1].set(x01, y01);
+    dst[2].set(SkScalarAve(x01, x12), SkScalarAve(y01, y12));
+    dst[3].set(x12, y12);
+    dst[4] = src[2];
 }
 
-/**    Quad'(t) = At + B, where
-       A = 2(a - 2b + c)
-       B = 2(b - a)
-       Solve for t, only if it fits between 0 < t < 1
+/** Quad'(t) = At + B, where
+    A = 2(a - 2b + c)
+    B = 2(b - a)
+    Solve for t, only if it fits between 0 < t < 1
 */
 int SkFindQuadExtrema(SkScalar a, SkScalar b, SkScalar c, SkScalar tValue[1])
 {
-       /*      At + B == 0
-               t = -B / A
-       */
+    /*  At + B == 0
+        t = -B / A
+    */
 #ifdef SK_SCALAR_IS_FIXED
     return is_not_monotonic(a, b, c) && valid_unit_divide(a - b, a - b - b + c, tValue);
 #else
-       return valid_unit_divide(a - b, a - b - b + c, tValue);
+    return valid_unit_divide(a - b, a - b - b + c, tValue);
 #endif
 }
 
 static void flatten_double_quad_extrema(SkScalar coords[14])
 {
-       coords[2] = coords[6] = coords[4];
+    coords[2] = coords[6] = coords[4];
 }
 
 static void force_quad_monotonic_in_y(SkPoint pts[3])
@@ -283,85 +300,85 @@ int SkChopQuadAtYExtrema(const SkPoint src[3], SkPoint dst[5])
     }
 #endif
 
-       SkScalar        tValue;
-       int                     roots = SkFindQuadExtrema(src[0].fY, src[1].fY, src[2].fY, &tValue);
+    SkScalar    tValue;
+    int         roots = SkFindQuadExtrema(src[0].fY, src[1].fY, src[2].fY, &tValue);
 
-       if (dst)
-       {
-               if (roots == 0) // nothing to chop
+    if (dst)
+    {
+        if (roots == 0) // nothing to chop
         {
-                       memcpy(dst, src, 3*sizeof(SkPoint));
+            memcpy(dst, src, 3*sizeof(SkPoint));
             // check if valid_unit_divide gave up but we're still not monotonic
             // can happen if valid_unit_divide can't see the t-value (underflow)
             // e.g. SkPoint s[3] = { 0, 26398, 0, 26331, 0, 20621428 };
             if (is_not_monotonic(src[0].fY, src[1].fY, src[2].fY))
                 force_quad_monotonic_in_y(dst);
         }
-               else
-               {
-                       SkChopQuadAt(src, dst, tValue);
-                       flatten_double_quad_extrema(&dst[0].fY);
-               }
-       }
-       return roots;
-}
-
-//     F(t)    = a (1 - t) ^ 2 + 2 b t (1 - t) + c t ^ 2
-//     F'(t)   = 2 (b - a) + 2 (a - 2b + c) t
-//     F''(t)  = 2 (a - 2b + c)
+        else
+        {
+            SkChopQuadAt(src, dst, tValue);
+            flatten_double_quad_extrema(&dst[0].fY);
+        }
+    }
+    return roots;
+}
+
+//  F(t)    = a (1 - t) ^ 2 + 2 b t (1 - t) + c t ^ 2
+//  F'(t)   = 2 (b - a) + 2 (a - 2b + c) t
+//  F''(t)  = 2 (a - 2b + c)
 //
-//     A = 2 (b - a)
-//     B = 2 (a - 2b + c)
+//  A = 2 (b - a)
+//  B = 2 (a - 2b + c)
 //
-//     Maximum curvature for a quadratic means solving
-//     Fx' Fx'' + Fy' Fy'' = 0
+//  Maximum curvature for a quadratic means solving
+//  Fx' Fx'' + Fy' Fy'' = 0
 //
-//     t = - (Ax Bx + Ay By) / (Bx ^ 2 + By ^ 2)
+//  t = - (Ax Bx + Ay By) / (Bx ^ 2 + By ^ 2)
 //
 int SkChopQuadAtMaxCurvature(const SkPoint src[3], SkPoint dst[5])
 {
-       SkScalar        Ax = src[1].fX - src[0].fX;
-       SkScalar        Ay = src[1].fY - src[0].fY;
-       SkScalar        Bx = src[0].fX - src[1].fX - src[1].fX + src[2].fX;
-       SkScalar        By = src[0].fY - src[1].fY - src[1].fY + src[2].fY;
-       SkScalar        t = 0;  // 0 means don't chop
+    SkScalar    Ax = src[1].fX - src[0].fX;
+    SkScalar    Ay = src[1].fY - src[0].fY;
+    SkScalar    Bx = src[0].fX - src[1].fX - src[1].fX + src[2].fX;
+    SkScalar    By = src[0].fY - src[1].fY - src[1].fY + src[2].fY;
+    SkScalar    t = 0;  // 0 means don't chop
 
 #ifdef SK_SCALAR_IS_FLOAT
-       (void)valid_unit_divide(-(Ax * Bx + Ay * By), Bx * Bx + By * By, &t);
+    (void)valid_unit_divide(-(Ax * Bx + Ay * By), Bx * Bx + By * By, &t);
 #else
-       // !!! should I use SkFloat here? seems like it
-       Sk64    numer, denom, tmp;
-
-       numer.setMul(Ax, -Bx);
-       tmp.setMul(Ay, -By);
-       numer.add(tmp);
-
-       if (numer.isPos())      // do nothing if numer <= 0
-       {
-               denom.setMul(Bx, Bx);
-               tmp.setMul(By, By);
-               denom.add(tmp);
-               SkASSERT(!denom.isNeg());
-               if (numer < denom)
-               {
-                       t = numer.getFixedDiv(denom);
-                       SkASSERT(t >= 0 && t <= SK_Fixed1);             // assert that we're numerically stable (ha!)
-                       if ((unsigned)t >= SK_Fixed1)                   // runtime check for numerical stability
-                               t = 0;  // ignore the chop
-               }
-       }
+    // !!! should I use SkFloat here? seems like it
+    Sk64    numer, denom, tmp;
+
+    numer.setMul(Ax, -Bx);
+    tmp.setMul(Ay, -By);
+    numer.add(tmp);
+
+    if (numer.isPos())  // do nothing if numer <= 0
+    {
+        denom.setMul(Bx, Bx);
+        tmp.setMul(By, By);
+        denom.add(tmp);
+        SkASSERT(!denom.isNeg());
+        if (numer < denom)
+        {
+            t = numer.getFixedDiv(denom);
+            SkASSERT(t >= 0 && t <= SK_Fixed1);     // assert that we're numerically stable (ha!)
+            if ((unsigned)t >= SK_Fixed1)           // runtime check for numerical stability
+                t = 0;  // ignore the chop
+        }
+    }
 #endif
 
-       if (t == 0)
-       {
-               memcpy(dst, src, 3 * sizeof(SkPoint));
-               return 1;
-       }
-       else
-       {
-               SkChopQuadAt(src, dst, t);
-               return 2;
-       }
+    if (t == 0)
+    {
+        memcpy(dst, src, 3 * sizeof(SkPoint));
+        return 1;
+    }
+    else
+    {
+        SkChopQuadAt(src, dst, t);
+        return 2;
+    }
 }
 
 ////////////////////////////////////////////////////////////////////////////////////////
@@ -370,295 +387,295 @@ int SkChopQuadAtMaxCurvature(const SkPoint src[3], SkPoint dst[5])
 
 static void get_cubic_coeff(const SkScalar pt[], SkScalar coeff[4])
 {
-       coeff[0] = pt[6] + 3*(pt[2] - pt[4]) - pt[0];
-       coeff[1] = 3*(pt[4] - pt[2] - pt[2] + pt[0]);
-       coeff[2] = 3*(pt[2] - pt[0]);
-       coeff[3] = pt[0];
+    coeff[0] = pt[6] + 3*(pt[2] - pt[4]) - pt[0];
+    coeff[1] = 3*(pt[4] - pt[2] - pt[2] + pt[0]);
+    coeff[2] = 3*(pt[2] - pt[0]);
+    coeff[3] = pt[0];
 }
 
 void SkGetCubicCoeff(const SkPoint pts[4], SkScalar cx[4], SkScalar cy[4])
 {
-       SkASSERT(pts);
+    SkASSERT(pts);
 
-       if (cx)
-               get_cubic_coeff(&pts[0].fX, cx);
-       if (cy)
-               get_cubic_coeff(&pts[0].fY, cy);
+    if (cx)
+        get_cubic_coeff(&pts[0].fX, cx);
+    if (cy)
+        get_cubic_coeff(&pts[0].fY, cy);
 }
 
 static SkScalar eval_cubic(const SkScalar src[], SkScalar t)
 {
-       SkASSERT(src);
-       SkASSERT(t >= 0 && t <= SK_Scalar1);
+    SkASSERT(src);
+    SkASSERT(t >= 0 && t <= SK_Scalar1);
 
-       if (t == 0)
-               return src[0];
+    if (t == 0)
+        return src[0];
 
 #ifdef DIRECT_EVAL_OF_POLYNOMIALS
-       SkScalar D = src[0];
-       SkScalar A = src[6] + 3*(src[2] - src[4]) - D;
-       SkScalar B = 3*(src[4] - src[2] - src[2] + D);
-       SkScalar C = 3*(src[2] - D);
+    SkScalar D = src[0];
+    SkScalar A = src[6] + 3*(src[2] - src[4]) - D;
+    SkScalar B = 3*(src[4] - src[2] - src[2] + D);
+    SkScalar C = 3*(src[2] - D);
 
-       return SkScalarMul(SkScalarMul(SkScalarMul(A, t) + B, t) + C, t) + D;
+    return SkScalarMul(SkScalarMul(SkScalarMul(A, t) + B, t) + C, t) + D;
 #else
-       SkScalar        ab = SkScalarInterp(src[0], src[2], t);
-       SkScalar        bc = SkScalarInterp(src[2], src[4], t);
-       SkScalar        cd = SkScalarInterp(src[4], src[6], t);
-       SkScalar        abc = SkScalarInterp(ab, bc, t);
-       SkScalar        bcd = SkScalarInterp(bc, cd, t);
-       return SkScalarInterp(abc, bcd, t);
+    SkScalar    ab = SkScalarInterp(src[0], src[2], t);
+    SkScalar    bc = SkScalarInterp(src[2], src[4], t);
+    SkScalar    cd = SkScalarInterp(src[4], src[6], t);
+    SkScalar    abc = SkScalarInterp(ab, bc, t);
+    SkScalar    bcd = SkScalarInterp(bc, cd, t);
+    return SkScalarInterp(abc, bcd, t);
 #endif
 }
 
-/**    return At^2 + Bt + C
+/** return At^2 + Bt + C
 */
 static SkScalar eval_quadratic(SkScalar A, SkScalar B, SkScalar C, SkScalar t)
 {
-       SkASSERT(t >= 0 && t <= SK_Scalar1);
+    SkASSERT(t >= 0 && t <= SK_Scalar1);
 
-       return SkScalarMul(SkScalarMul(A, t) + B, t) + C;
+    return SkScalarMul(SkScalarMul(A, t) + B, t) + C;
 }
 
 static SkScalar eval_cubic_derivative(const SkScalar src[], SkScalar t)
 {
-       SkScalar A = src[6] + 3*(src[2] - src[4]) - src[0];
-       SkScalar B = 2*(src[4] - 2 * src[2] + src[0]);
-       SkScalar C = src[2] - src[0];
+    SkScalar A = src[6] + 3*(src[2] - src[4]) - src[0];
+    SkScalar B = 2*(src[4] - 2 * src[2] + src[0]);
+    SkScalar C = src[2] - src[0];
 
-       return eval_quadratic(A, B, C, t);
+    return eval_quadratic(A, B, C, t);
 }
 
 static SkScalar eval_cubic_2ndDerivative(const SkScalar src[], SkScalar t)
 {
-       SkScalar A = src[6] + 3*(src[2] - src[4]) - src[0];
-       SkScalar B = src[4] - 2 * src[2] + src[0];
+    SkScalar A = src[6] + 3*(src[2] - src[4]) - src[0];
+    SkScalar B = src[4] - 2 * src[2] + src[0];
 
-       return SkScalarMul(A, t) + B;
+    return SkScalarMul(A, t) + B;
 }
 
 void SkEvalCubicAt(const SkPoint src[4], SkScalar t, SkPoint* loc, SkVector* tangent, SkVector* curvature)
 {
-       SkASSERT(src);
-       SkASSERT(t >= 0 && t <= SK_Scalar1);
-
-       if (loc)
-               loc->set(eval_cubic(&src[0].fX, t), eval_cubic(&src[0].fY, t));
-       if (tangent)
-               tangent->set(eval_cubic_derivative(&src[0].fX, t),
-                                        eval_cubic_derivative(&src[0].fY, t));
-       if (curvature)
-               curvature->set(eval_cubic_2ndDerivative(&src[0].fX, t),
-                                          eval_cubic_2ndDerivative(&src[0].fY, t));
+    SkASSERT(src);
+    SkASSERT(t >= 0 && t <= SK_Scalar1);
+
+    if (loc)
+        loc->set(eval_cubic(&src[0].fX, t), eval_cubic(&src[0].fY, t));
+    if (tangent)
+        tangent->set(eval_cubic_derivative(&src[0].fX, t),
+                     eval_cubic_derivative(&src[0].fY, t));
+    if (curvature)
+        curvature->set(eval_cubic_2ndDerivative(&src[0].fX, t),
+                       eval_cubic_2ndDerivative(&src[0].fY, t));
 }
 
-/**    Cubic'(t) = At^2 + Bt + C, where
-       A = 3(-a + 3(b - c) + d)
-       B = 6(a - 2b + c)
-       C = 3(b - a)
-       Solve for t, keeping only those that fit betwee 0 < t < 1
+/** Cubic'(t) = At^2 + Bt + C, where
+    A = 3(-a + 3(b - c) + d)
+    B = 6(a - 2b + c)
+    C = 3(b - a)
+    Solve for t, keeping only those that fit betwee 0 < t < 1
 */
 int SkFindCubicExtrema(SkScalar a, SkScalar b, SkScalar c, SkScalar d, SkScalar tValues[2])
 {
 #ifdef SK_SCALAR_IS_FIXED
-       if (!is_not_monotonic(a, b, c, d))
-               return 0;
+    if (!is_not_monotonic(a, b, c, d))
+        return 0;
 #endif
 
-       // we divide A,B,C by 3 to simplify
-       SkScalar A = d - a + 3*(b - c);
-       SkScalar B = 2*(a - b - b + c);
-       SkScalar C = b - a;
+    // we divide A,B,C by 3 to simplify
+    SkScalar A = d - a + 3*(b - c);
+    SkScalar B = 2*(a - b - b + c);
+    SkScalar C = b - a;
 
-       return SkFindUnitQuadRoots(A, B, C, tValues);
+    return SkFindUnitQuadRoots(A, B, C, tValues);
 }
 
 static void interp_cubic_coords(const SkScalar* src, SkScalar* dst, SkScalar t)
 {
-       SkScalar        ab = SkScalarInterp(src[0], src[2], t);
-       SkScalar        bc = SkScalarInterp(src[2], src[4], t);
-       SkScalar        cd = SkScalarInterp(src[4], src[6], t);
-       SkScalar        abc = SkScalarInterp(ab, bc, t);
-       SkScalar        bcd = SkScalarInterp(bc, cd, t);
-       SkScalar        abcd = SkScalarInterp(abc, bcd, t);
-
-       dst[0] = src[0];
-       dst[2] = ab;
-       dst[4] = abc;
-       dst[6] = abcd;
-       dst[8] = bcd;
-       dst[10] = cd;
-       dst[12] = src[6];
+    SkScalar    ab = SkScalarInterp(src[0], src[2], t);
+    SkScalar    bc = SkScalarInterp(src[2], src[4], t);
+    SkScalar    cd = SkScalarInterp(src[4], src[6], t);
+    SkScalar    abc = SkScalarInterp(ab, bc, t);
+    SkScalar    bcd = SkScalarInterp(bc, cd, t);
+    SkScalar    abcd = SkScalarInterp(abc, bcd, t);
+
+    dst[0] = src[0];
+    dst[2] = ab;
+    dst[4] = abc;
+    dst[6] = abcd;
+    dst[8] = bcd;
+    dst[10] = cd;
+    dst[12] = src[6];
 }
 
 void SkChopCubicAt(const SkPoint src[4], SkPoint dst[7], SkScalar t)
 {
-       SkASSERT(t > 0 && t < SK_Scalar1);
+    SkASSERT(t > 0 && t < SK_Scalar1);
 
-       interp_cubic_coords(&src[0].fX, &dst[0].fX, t);
-       interp_cubic_coords(&src[0].fY, &dst[0].fY, t);
+    interp_cubic_coords(&src[0].fX, &dst[0].fX, t);
+    interp_cubic_coords(&src[0].fY, &dst[0].fY, t);
 }
 
 void SkChopCubicAt(const SkPoint src[4], SkPoint dst[], const SkScalar tValues[], int roots)
 {
 #ifdef SK_DEBUG
-       {
-               for (int i = 0; i < roots - 1; i++)
-               {
-                       SkASSERT(is_unit_interval(tValues[i]));
-                       SkASSERT(is_unit_interval(tValues[i+1]));
-                       SkASSERT(tValues[i] < tValues[i+1]);
-               }
-       }
+    {
+        for (int i = 0; i < roots - 1; i++)
+        {
+            SkASSERT(is_unit_interval(tValues[i]));
+            SkASSERT(is_unit_interval(tValues[i+1]));
+            SkASSERT(tValues[i] < tValues[i+1]);
+        }
+    }
 #endif
 
-       if (dst)
-       {
-               if (roots == 0) // nothing to chop
-                       memcpy(dst, src, 4*sizeof(SkPoint));
-               else
-               {
-                       SkScalar        t = tValues[0];
-                       SkPoint         tmp[4];
-
-                       for (int i = 0; i < roots; i++)
-                       {
-                               SkChopCubicAt(src, dst, t);
-                               if (i == roots - 1)
-                                       break;
-
-                               SkDEBUGCODE(int valid =) valid_unit_divide(tValues[i+1] - tValues[i], SK_Scalar1 - tValues[i], &t);
-                               SkASSERT(valid);
-
-                               dst += 3;
-                               memcpy(tmp, dst, 4 * sizeof(SkPoint));
-                               src = tmp;
-                       }
-               }
-       }
+    if (dst)
+    {
+        if (roots == 0) // nothing to chop
+            memcpy(dst, src, 4*sizeof(SkPoint));
+        else
+        {
+            SkScalar    t = tValues[0];
+            SkPoint     tmp[4];
+
+            for (int i = 0; i < roots; i++)
+            {
+                SkChopCubicAt(src, dst, t);
+                if (i == roots - 1)
+                    break;
+
+                SkDEBUGCODE(int valid =) valid_unit_divide(tValues[i+1] - tValues[i], SK_Scalar1 - tValues[i], &t);
+                SkASSERT(valid);
+
+                dst += 3;
+                memcpy(tmp, dst, 4 * sizeof(SkPoint));
+                src = tmp;
+            }
+        }
+    }
 }
 
 void SkChopCubicAtHalf(const SkPoint src[4], SkPoint dst[7])
 {
-       SkScalar x01 = SkScalarAve(src[0].fX, src[1].fX);
-       SkScalar y01 = SkScalarAve(src[0].fY, src[1].fY);
-       SkScalar x12 = SkScalarAve(src[1].fX, src[2].fX);
-       SkScalar y12 = SkScalarAve(src[1].fY, src[2].fY);
-       SkScalar x23 = SkScalarAve(src[2].fX, src[3].fX);
-       SkScalar y23 = SkScalarAve(src[2].fY, src[3].fY);
-
-       SkScalar x012 = SkScalarAve(x01, x12);
-       SkScalar y012 = SkScalarAve(y01, y12);
-       SkScalar x123 = SkScalarAve(x12, x23);
-       SkScalar y123 = SkScalarAve(y12, y23);
-
-       dst[0] = src[0];
-       dst[1].set(x01, y01);
-       dst[2].set(x012, y012);
-       dst[3].set(SkScalarAve(x012, x123), SkScalarAve(y012, y123));
-       dst[4].set(x123, y123);
-       dst[5].set(x23, y23);
-       dst[6] = src[3];
+    SkScalar x01 = SkScalarAve(src[0].fX, src[1].fX);
+    SkScalar y01 = SkScalarAve(src[0].fY, src[1].fY);
+    SkScalar x12 = SkScalarAve(src[1].fX, src[2].fX);
+    SkScalar y12 = SkScalarAve(src[1].fY, src[2].fY);
+    SkScalar x23 = SkScalarAve(src[2].fX, src[3].fX);
+    SkScalar y23 = SkScalarAve(src[2].fY, src[3].fY);
+
+    SkScalar x012 = SkScalarAve(x01, x12);
+    SkScalar y012 = SkScalarAve(y01, y12);
+    SkScalar x123 = SkScalarAve(x12, x23);
+    SkScalar y123 = SkScalarAve(y12, y23);
+
+    dst[0] = src[0];
+    dst[1].set(x01, y01);
+    dst[2].set(x012, y012);
+    dst[3].set(SkScalarAve(x012, x123), SkScalarAve(y012, y123));
+    dst[4].set(x123, y123);
+    dst[5].set(x23, y23);
+    dst[6] = src[3];
 }
 
 static void flatten_double_cubic_extrema(SkScalar coords[14])
 {
-       coords[4] = coords[8] = coords[6];
+    coords[4] = coords[8] = coords[6];
 }
 
-/**    Given 4 points on a cubic bezier, chop it into 1, 2, 3 beziers such that
-       the resulting beziers are monotonic in Y. This is called by the scan converter.
-       Depending on what is returned, dst[] is treated as follows
-       0       dst[0..3] is the original cubic
-       1       dst[0..3] and dst[3..6] are the two new cubics
-       2       dst[0..3], dst[3..6], dst[6..9] are the three new cubics
-       If dst == nil, it is ignored and only the count is returned.
+/** Given 4 points on a cubic bezier, chop it into 1, 2, 3 beziers such that
+    the resulting beziers are monotonic in Y. This is called by the scan converter.
+    Depending on what is returned, dst[] is treated as follows
+    0   dst[0..3] is the original cubic
+    1   dst[0..3] and dst[3..6] are the two new cubics
+    2   dst[0..3], dst[3..6], dst[6..9] are the three new cubics
+    If dst == nil, it is ignored and only the count is returned.
 */
 int SkChopCubicAtYExtrema(const SkPoint src[4], SkPoint dst[10])
 {
-       SkScalar        tValues[2];
-       int                     roots = SkFindCubicExtrema(src[0].fY, src[1].fY, src[2].fY, src[3].fY, tValues);
-
-       SkChopCubicAt(src, dst, tValues, roots);
-       if (dst && roots > 0)
-       {
-               // we do some cleanup to ensure our Y extrema are flat
-               flatten_double_cubic_extrema(&dst[0].fY);
-               if (roots == 2)
-                       flatten_double_cubic_extrema(&dst[3].fY);
-       }
-       return roots;
-}
-
-/**    http://www.faculty.idc.ac.il/arik/quality/appendixA.html
-
-       Inflection means that curvature is zero.
-       Curvature is [F' x F''] / [F'^3]
-       So we solve F'x X F''y - F'y X F''y == 0
-       After some canceling of the cubic term, we get
-       A = b - a
-       B = c - 2b + a
-       C = d - 3c + 3b - a
-       (BxCy - ByCx)t^2 + (AxCy - AyCx)t + AxBy - AyBx == 0
+    SkScalar    tValues[2];
+    int         roots = SkFindCubicExtrema(src[0].fY, src[1].fY, src[2].fY, src[3].fY, tValues);
+
+    SkChopCubicAt(src, dst, tValues, roots);
+    if (dst && roots > 0)
+    {
+        // we do some cleanup to ensure our Y extrema are flat
+        flatten_double_cubic_extrema(&dst[0].fY);
+        if (roots == 2)
+            flatten_double_cubic_extrema(&dst[3].fY);
+    }
+    return roots;
+}
+
+/** http://www.faculty.idc.ac.il/arik/quality/appendixA.html
+
+    Inflection means that curvature is zero.
+    Curvature is [F' x F''] / [F'^3]
+    So we solve F'x X F''y - F'y X F''y == 0
+    After some canceling of the cubic term, we get
+    A = b - a
+    B = c - 2b + a
+    C = d - 3c + 3b - a
+    (BxCy - ByCx)t^2 + (AxCy - AyCx)t + AxBy - AyBx == 0
 */
 int SkFindCubicInflections(const SkPoint src[4], SkScalar tValues[])
 {
-       SkScalar        Ax = src[1].fX - src[0].fX;
-       SkScalar        Ay = src[1].fY - src[0].fY;
-       SkScalar        Bx = src[2].fX - 2 * src[1].fX + src[0].fX;
-       SkScalar        By = src[2].fY - 2 * src[1].fY + src[0].fY;
-       SkScalar        Cx = src[3].fX + 3 * (src[1].fX - src[2].fX) - src[0].fX;
-       SkScalar        Cy = src[3].fY + 3 * (src[1].fY - src[2].fY) - src[0].fY;
-       int                     count;
+    SkScalar    Ax = src[1].fX - src[0].fX;
+    SkScalar    Ay = src[1].fY - src[0].fY;
+    SkScalar    Bx = src[2].fX - 2 * src[1].fX + src[0].fX;
+    SkScalar    By = src[2].fY - 2 * src[1].fY + src[0].fY;
+    SkScalar    Cx = src[3].fX + 3 * (src[1].fX - src[2].fX) - src[0].fX;
+    SkScalar    Cy = src[3].fY + 3 * (src[1].fY - src[2].fY) - src[0].fY;
+    int         count;
 
 #ifdef SK_SCALAR_IS_FLOAT
-       count = SkFindUnitQuadRoots(Bx*Cy - By*Cx, Ax*Cy - Ay*Cx, Ax*By - Ay*Bx, tValues);
+    count = SkFindUnitQuadRoots(Bx*Cy - By*Cx, Ax*Cy - Ay*Cx, Ax*By - Ay*Bx, tValues);
 #else
-       Sk64    A, B, C, tmp;
+    Sk64    A, B, C, tmp;
 
-       A.setMul(Bx, Cy);
-       tmp.setMul(By, Cx);
-       A.sub(tmp);
+    A.setMul(Bx, Cy);
+    tmp.setMul(By, Cx);
+    A.sub(tmp);
 
-       B.setMul(Ax, Cy);
-       tmp.setMul(Ay, Cx);
-       B.sub(tmp);
+    B.setMul(Ax, Cy);
+    tmp.setMul(Ay, Cx);
+    B.sub(tmp);
 
-       C.setMul(Ax, By);
-       tmp.setMul(Ay, Bx);
-       C.sub(tmp);
+    C.setMul(Ax, By);
+    tmp.setMul(Ay, Bx);
+    C.sub(tmp);
 
-       count = Sk64FindFixedQuadRoots(A, B, C, tValues);
+    count = Sk64FindFixedQuadRoots(A, B, C, tValues);
 #endif
 
-       return count;
+    return count;
 }
 
 int SkChopCubicAtInflections(const SkPoint src[], SkPoint dst[10])
 {
-       SkScalar        tValues[2];
-       int                     count = SkFindCubicInflections(src, tValues);
+    SkScalar    tValues[2];
+    int         count = SkFindCubicInflections(src, tValues);
 
-       if (dst)
-       {
-               if (count == 0)
-                       memcpy(dst, src, 4 * sizeof(SkPoint));
-               else
-                       SkChopCubicAt(src, dst, tValues, count);
-       }
-       return count + 1;
+    if (dst)
+    {
+        if (count == 0)
+            memcpy(dst, src, 4 * sizeof(SkPoint));
+        else
+            SkChopCubicAt(src, dst, tValues, count);
+    }
+    return count + 1;
 }
 
 template <typename T> void bubble_sort(T array[], int count)
 {
-       for (int i = count - 1; i > 0; --i)
-               for (int j = i; j > 0; --j)
-                       if (array[j] < array[j-1])
-                       {
-                               T       tmp(array[j]);
-                               array[j] = array[j-1];
-                               array[j-1] = tmp;
-                       }
+    for (int i = count - 1; i > 0; --i)
+        for (int j = i; j > 0; --j)
+            if (array[j] < array[j-1])
+            {
+                T   tmp(array[j]);
+                array[j] = array[j-1];
+                array[j-1] = tmp;
+            }
 }
 
 #include "SkFP.h"
@@ -667,325 +684,325 @@ template <typename T> void bubble_sort(T array[], int count)
 #if 0
 static SkScalar refine_cubic_root(const SkFP coeff[4], SkScalar root)
 {
-       //      x1 = x0 - f(t) / f'(t)
+    //  x1 = x0 - f(t) / f'(t)
 
-       SkFP    T = SkScalarToFloat(root);
-       SkFP    N, D;
+    SkFP    T = SkScalarToFloat(root);
+    SkFP    N, D;
 
-       // f' = 3*coeff[0]*T^2 + 2*coeff[1]*T + coeff[2]
-       D = SkFPMul(SkFPMul(coeff[0], SkFPMul(T,T)), 3);
-       D = SkFPAdd(D, SkFPMulInt(SkFPMul(coeff[1], T), 2));
-       D = SkFPAdd(D, coeff[2]);
+    // f' = 3*coeff[0]*T^2 + 2*coeff[1]*T + coeff[2]
+    D = SkFPMul(SkFPMul(coeff[0], SkFPMul(T,T)), 3);
+    D = SkFPAdd(D, SkFPMulInt(SkFPMul(coeff[1], T), 2));
+    D = SkFPAdd(D, coeff[2]);
 
-       if (D == 0)
-               return root;
+    if (D == 0)
+        return root;
 
-       // f = coeff[0]*T^3 + coeff[1]*T^2 + coeff[2]*T + coeff[3]
-       N = SkFPMul(SkFPMul(SkFPMul(T, T), T), coeff[0]);
-       N = SkFPAdd(N, SkFPMul(SkFPMul(T, T), coeff[1]));
-       N = SkFPAdd(N, SkFPMul(T, coeff[2]));
-       N = SkFPAdd(N, coeff[3]);
+    // f = coeff[0]*T^3 + coeff[1]*T^2 + coeff[2]*T + coeff[3]
+    N = SkFPMul(SkFPMul(SkFPMul(T, T), T), coeff[0]);
+    N = SkFPAdd(N, SkFPMul(SkFPMul(T, T), coeff[1]));
+    N = SkFPAdd(N, SkFPMul(T, coeff[2]));
+    N = SkFPAdd(N, coeff[3]);
 
-       if (N)
-       {
-               SkScalar delta = SkFPToScalar(SkFPDiv(N, D));
+    if (N)
+    {
+        SkScalar delta = SkFPToScalar(SkFPDiv(N, D));
 
-               if (delta)
-                       root -= delta;
-       }
-       return root;
+        if (delta)
+            root -= delta;
+    }
+    return root;
 }
 #endif
 
-#if defined _WIN32 && _MSC_VER >= 1300 && defined SK_SCALAR_IS_FIXED // disable warning : unreachable code if building fixed point for windows desktop
+#if defined _WIN32 && _MSC_VER >= 1300  && defined SK_SCALAR_IS_FIXED // disable warning : unreachable code if building fixed point for windows desktop
 #pragma warning ( disable : 4702 )
 #endif
 
-/*     Solve coeff(t) == 0, returning the number of roots that
-       lie withing 0 < t < 1.
-       coeff[0]t^3 + coeff[1]t^2 + coeff[2]t + coeff[3]
+/*  Solve coeff(t) == 0, returning the number of roots that
+    lie withing 0 < t < 1.
+    coeff[0]t^3 + coeff[1]t^2 + coeff[2]t + coeff[3]
 */
 static int solve_cubic_polynomial(const SkFP coeff[4], SkScalar tValues[3])
 {
 #ifndef SK_SCALAR_IS_FLOAT
-       return 0;       // this is not yet implemented for software float
+    return 0;   // this is not yet implemented for software float
 #endif
 
-       if (SkScalarNearlyZero(coeff[0]))       // we're just a quadratic
-       {
-               return SkFindUnitQuadRoots(coeff[1], coeff[2], coeff[3], tValues);
-       }
-
-       SkFP    a, b, c, Q, R;
-
-       {
-               SkASSERT(coeff[0] != 0);
-
-               SkFP inva = SkFPInvert(coeff[0]);
-               a = SkFPMul(coeff[1], inva);
-               b = SkFPMul(coeff[2], inva);
-               c = SkFPMul(coeff[3], inva);
-       }
-       Q = SkFPDivInt(SkFPSub(SkFPMul(a,a), SkFPMulInt(b, 3)), 9);
-//     R = (2*a*a*a - 9*a*b + 27*c) / 54;
-       R = SkFPMulInt(SkFPMul(SkFPMul(a, a), a), 2);
-       R = SkFPSub(R, SkFPMulInt(SkFPMul(a, b), 9));
-       R = SkFPAdd(R, SkFPMulInt(c, 27));
-       R = SkFPDivInt(R, 54);
-
-       SkFP Q3 = SkFPMul(SkFPMul(Q, Q), Q);
-       SkFP R2MinusQ3 = SkFPSub(SkFPMul(R,R), Q3);
-       SkFP adiv3 = SkFPDivInt(a, 3);
-
-       SkScalar*       roots = tValues;
-       SkScalar        r;
-
-       if (SkFPLT(R2MinusQ3, 0))       // we have 3 real roots
-       {
+    if (SkScalarNearlyZero(coeff[0]))   // we're just a quadratic
+    {
+        return SkFindUnitQuadRoots(coeff[1], coeff[2], coeff[3], tValues);
+    }
+
+    SkFP    a, b, c, Q, R;
+
+    {
+        SkASSERT(coeff[0] != 0);
+
+        SkFP inva = SkFPInvert(coeff[0]);
+        a = SkFPMul(coeff[1], inva);
+        b = SkFPMul(coeff[2], inva);
+        c = SkFPMul(coeff[3], inva);
+    }
+    Q = SkFPDivInt(SkFPSub(SkFPMul(a,a), SkFPMulInt(b, 3)), 9);
+//  R = (2*a*a*a - 9*a*b + 27*c) / 54;
+    R = SkFPMulInt(SkFPMul(SkFPMul(a, a), a), 2);
+    R = SkFPSub(R, SkFPMulInt(SkFPMul(a, b), 9));
+    R = SkFPAdd(R, SkFPMulInt(c, 27));
+    R = SkFPDivInt(R, 54);
+
+    SkFP Q3 = SkFPMul(SkFPMul(Q, Q), Q);
+    SkFP R2MinusQ3 = SkFPSub(SkFPMul(R,R), Q3);
+    SkFP adiv3 = SkFPDivInt(a, 3);
+
+    SkScalar*   roots = tValues;
+    SkScalar    r;
+
+    if (SkFPLT(R2MinusQ3, 0))   // we have 3 real roots
+    {
 #ifdef SK_SCALAR_IS_FLOAT
-               float theta = sk_float_acos(R / sk_float_sqrt(Q3));
-               float neg2RootQ = -2 * sk_float_sqrt(Q);
+        float theta = sk_float_acos(R / sk_float_sqrt(Q3));
+        float neg2RootQ = -2 * sk_float_sqrt(Q);
 
-               r = neg2RootQ * sk_float_cos(theta/3) - adiv3;
-               if (is_unit_interval(r))
-                       *roots++ = r;
+        r = neg2RootQ * sk_float_cos(theta/3) - adiv3;
+        if (is_unit_interval(r))
+            *roots++ = r;
 
-               r = neg2RootQ * sk_float_cos((theta + 2*SK_ScalarPI)/3) - adiv3;
-               if (is_unit_interval(r))
-                       *roots++ = r;
+        r = neg2RootQ * sk_float_cos((theta + 2*SK_ScalarPI)/3) - adiv3;
+        if (is_unit_interval(r))
+            *roots++ = r;
 
-               r = neg2RootQ * sk_float_cos((theta - 2*SK_ScalarPI)/3) - adiv3;
-               if (is_unit_interval(r))
-                       *roots++ = r;
+        r = neg2RootQ * sk_float_cos((theta - 2*SK_ScalarPI)/3) - adiv3;
+        if (is_unit_interval(r))
+            *roots++ = r;
 
-               // now sort the roots
-               bubble_sort(tValues, (int)(roots - tValues));
+        // now sort the roots
+        bubble_sort(tValues, (int)(roots - tValues));
 #endif
-       }
-       else                            // we have 1 real root
-       {
-               SkFP A = SkFPAdd(SkFPAbs(R), SkFPSqrt(R2MinusQ3));
-               A = SkFPCubeRoot(A);
-               if (SkFPGT(R, 0))
-                       A = SkFPNeg(A);
-
-               if (A != 0)
-                       A = SkFPAdd(A, SkFPDiv(Q, A));
-               r = SkFPToScalar(SkFPSub(A, adiv3));
-               if (is_unit_interval(r))
-                       *roots++ = r;
-       }
-
-       return (int)(roots - tValues);
-}
-
-/*     Looking for F' dot F'' == 0
-       
-       A = b - a
-       B = c - 2b + a
-       C = d - 3c + 3b - a
-
-       F' = 3Ct^2 + 6Bt + 3A
-       F'' = 6Ct + 6B
-
-       F' dot F'' -> CCt^3 + 3BCt^2 + (2BB + CA)t + AB
+    }
+    else                // we have 1 real root
+    {
+        SkFP A = SkFPAdd(SkFPAbs(R), SkFPSqrt(R2MinusQ3));
+        A = SkFPCubeRoot(A);
+        if (SkFPGT(R, 0))
+            A = SkFPNeg(A);
+
+        if (A != 0)
+            A = SkFPAdd(A, SkFPDiv(Q, A));
+        r = SkFPToScalar(SkFPSub(A, adiv3));
+        if (is_unit_interval(r))
+            *roots++ = r;
+    }
+
+    return (int)(roots - tValues);
+}
+
+/*  Looking for F' dot F'' == 0
+    
+    A = b - a
+    B = c - 2b + a
+    C = d - 3c + 3b - a
+
+    F' = 3Ct^2 + 6Bt + 3A
+    F'' = 6Ct + 6B
+
+    F' dot F'' -> CCt^3 + 3BCt^2 + (2BB + CA)t + AB
 */
 static void formulate_F1DotF2(const SkScalar src[], SkFP coeff[4])
 {
-       SkScalar        a = src[2] - src[0];
-       SkScalar        b = src[4] - 2 * src[2] + src[0];
-       SkScalar        c = src[6] + 3 * (src[2] - src[4]) - src[0];
-
-       SkFP    A = SkScalarToFP(a);
-       SkFP    B = SkScalarToFP(b);
-       SkFP    C = SkScalarToFP(c);
-
-       coeff[0] = SkFPMul(C, C);
-       coeff[1] = SkFPMulInt(SkFPMul(B, C), 3);
-       coeff[2] = SkFPMulInt(SkFPMul(B, B), 2);
-       coeff[2] = SkFPAdd(coeff[2], SkFPMul(C, A));
-       coeff[3] = SkFPMul(A, B);
+    SkScalar    a = src[2] - src[0];
+    SkScalar    b = src[4] - 2 * src[2] + src[0];
+    SkScalar    c = src[6] + 3 * (src[2] - src[4]) - src[0];
+
+    SkFP    A = SkScalarToFP(a);
+    SkFP    B = SkScalarToFP(b);
+    SkFP    C = SkScalarToFP(c);
+
+    coeff[0] = SkFPMul(C, C);
+    coeff[1] = SkFPMulInt(SkFPMul(B, C), 3);
+    coeff[2] = SkFPMulInt(SkFPMul(B, B), 2);
+    coeff[2] = SkFPAdd(coeff[2], SkFPMul(C, A));
+    coeff[3] = SkFPMul(A, B);
 }
 
 // EXPERIMENTAL: can set this to zero to accept all t-values 0 < t < 1
-//#define kMinTValueForChopping        (SK_Scalar1 / 256)
-#define kMinTValueForChopping  0
+//#define kMinTValueForChopping (SK_Scalar1 / 256)
+#define kMinTValueForChopping   0
 
-/*     Looking for F' dot F'' == 0
-       
-       A = b - a
-       B = c - 2b + a
-       C = d - 3c + 3b - a
+/*  Looking for F' dot F'' == 0
+    
+    A = b - a
+    B = c - 2b + a
+    C = d - 3c + 3b - a
 
-       F' = 3Ct^2 + 6Bt + 3A
-       F'' = 6Ct + 6B
+    F' = 3Ct^2 + 6Bt + 3A
+    F'' = 6Ct + 6B
 
-       F' dot F'' -> CCt^3 + 3BCt^2 + (2BB + CA)t + AB
+    F' dot F'' -> CCt^3 + 3BCt^2 + (2BB + CA)t + AB
 */
 int SkFindCubicMaxCurvature(const SkPoint src[4], SkScalar tValues[3])
 {
-       SkFP    coeffX[4], coeffY[4];
-       int             i;
+    SkFP    coeffX[4], coeffY[4];
+    int     i;
 
-       formulate_F1DotF2(&src[0].fX, coeffX);
-       formulate_F1DotF2(&src[0].fY, coeffY);
+    formulate_F1DotF2(&src[0].fX, coeffX);
+    formulate_F1DotF2(&src[0].fY, coeffY);
 
-       for (i = 0; i < 4; i++)
-               coeffX[i] = SkFPAdd(coeffX[i],coeffY[i]);
+    for (i = 0; i < 4; i++)
+        coeffX[i] = SkFPAdd(coeffX[i],coeffY[i]);
 
-       SkScalar        t[3];
-       int                     count = solve_cubic_polynomial(coeffX, t);
-       int                     maxCount = 0;
+    SkScalar    t[3];
+    int         count = solve_cubic_polynomial(coeffX, t);
+    int         maxCount = 0;
 
-       // now remove extrema where the curvature is zero (mins)
-       // !!!! need a test for this !!!!
-       for (i = 0; i < count; i++)
-       {
-               // if (not_min_curvature())
-               if (t[i] > kMinTValueForChopping && t[i] < SK_Scalar1 - kMinTValueForChopping)
-                       tValues[maxCount++] = t[i];
-       }
-       return maxCount;
+    // now remove extrema where the curvature is zero (mins)
+    // !!!! need a test for this !!!!
+    for (i = 0; i < count; i++)
+    {
+        // if (not_min_curvature())
+        if (t[i] > kMinTValueForChopping && t[i] < SK_Scalar1 - kMinTValueForChopping)
+            tValues[maxCount++] = t[i];
+    }
+    return maxCount;
 }
 
 int SkChopCubicAtMaxCurvature(const SkPoint src[4], SkPoint dst[13], SkScalar tValues[3])
 {
-       SkScalar        t_storage[3];
+    SkScalar    t_storage[3];
 
-       if (tValues == nil)
-               tValues = t_storage;
+    if (tValues == nil)
+        tValues = t_storage;
 
-       int     count = SkFindCubicMaxCurvature(src, tValues);
+    int count = SkFindCubicMaxCurvature(src, tValues);
 
-       if (dst)
-       {
-               if (count == 0)
-                       memcpy(dst, src, 4 * sizeof(SkPoint));
-               else
-                       SkChopCubicAt(src, dst, tValues, count);
-       }
-       return count + 1;
+    if (dst)
+    {
+        if (count == 0)
+            memcpy(dst, src, 4 * sizeof(SkPoint));
+        else
+            SkChopCubicAt(src, dst, tValues, count);
+    }
+    return count + 1;
 }
 
 ////////////////////////////////////////////////////////////////////////////////
 
-/*     Find t value for quadratic [a, b, c] = d.
-       Return 0 if there is no solution
+/*  Find t value for quadratic [a, b, c] = d.
+    Return 0 if there is no solution
 */
 static SkScalar quad_solve(SkScalar a, SkScalar b, SkScalar c, SkScalar d)
 {
-       // At^2 + Bt + C = d
-       SkScalar A = a - 2 * b + c;
-       SkScalar B = 2 * (b - a);
-       SkScalar C = a - d;
+    // At^2 + Bt + C = d
+    SkScalar A = a - 2 * b + c;
+    SkScalar B = 2 * (b - a);
+    SkScalar C = a - d;
 
-       SkScalar        roots[2];
-       int                     count = SkFindUnitQuadRoots(A, B, C, roots);
+    SkScalar    roots[2];
+    int         count = SkFindUnitQuadRoots(A, B, C, roots);
 
-       SkASSERT(count <= 1);
-       return count == 1 ? roots[0] : 0;
+    SkASSERT(count <= 1);
+    return count == 1 ? roots[0] : 0;
 }
 
 /* given a quad-curve and a point (x,y), chop the quad at that point and return
-       the new quad's offCurve point.
+    the new quad's offCurve point.
 */
 static bool quad_pt2OffCurve(const SkPoint quad[3], SkScalar x, SkScalar y, SkPoint* offCurve)
 {
-       SkScalar t;
-       SkPoint tmp[5];
+    SkScalar t;
+    SkPoint tmp[5];
 
-       if (SkScalarAbs(x) < SkScalarAbs(y))
-               t = quad_solve(quad[0].fX, quad[1].fX, quad[2].fX, x);
-       else
-               t = quad_solve(quad[0].fY, quad[1].fY, quad[2].fY, y);
+    if (SkScalarAbs(x) < SkScalarAbs(y))
+        t = quad_solve(quad[0].fX, quad[1].fX, quad[2].fX, x);
+    else
+        t = quad_solve(quad[0].fY, quad[1].fY, quad[2].fY, y);
 
-       if (t > 0)
-       {
-               SkChopQuadAt(quad, tmp, t);
-               *offCurve = tmp[1];
-               return true;
-       }
-       return false;
+    if (t > 0)
+    {
+        SkChopQuadAt(quad, tmp, t);
+        *offCurve = tmp[1];
+        return true;
+    }
+    return false;
 }
 
 static const SkPoint gQuadCirclePts[kSkBuildQuadArcStorage] = {
-       { SK_Scalar1,                   0                               },
-       { SK_Scalar1,                   SK_ScalarTanPIOver8     },
-       { SK_ScalarRoot2Over2,  SK_ScalarRoot2Over2     },
-       { SK_ScalarTanPIOver8,  SK_Scalar1                      },
-
-       { 0,                                    SK_Scalar1              },
-       { -SK_ScalarTanPIOver8, SK_Scalar1      },
-       { -SK_ScalarRoot2Over2, SK_ScalarRoot2Over2     },
-       { -SK_Scalar1,                  SK_ScalarTanPIOver8     },
-
-       { -SK_Scalar1,                  0                               },
-       { -SK_Scalar1,                  -SK_ScalarTanPIOver8    },
-       { -SK_ScalarRoot2Over2, -SK_ScalarRoot2Over2    },
-       { -SK_ScalarTanPIOver8, -SK_Scalar1             },
-
-       { 0,                                    -SK_Scalar1             },
-       { SK_ScalarTanPIOver8,  -SK_Scalar1             },
-       { SK_ScalarRoot2Over2,  -SK_ScalarRoot2Over2    },
-       { SK_Scalar1,                   -SK_ScalarTanPIOver8    },
-
-       { SK_Scalar1,                   0       }
+    { SK_Scalar1,           0               },
+    { SK_Scalar1,           SK_ScalarTanPIOver8 },
+    { SK_ScalarRoot2Over2,  SK_ScalarRoot2Over2 },
+    { SK_ScalarTanPIOver8,  SK_Scalar1          },
+
+    { 0,                    SK_Scalar1      },
+    { -SK_ScalarTanPIOver8, SK_Scalar1  },
+    { -SK_ScalarRoot2Over2, SK_ScalarRoot2Over2 },
+    { -SK_Scalar1,          SK_ScalarTanPIOver8 },
+
+    { -SK_Scalar1,          0               },
+    { -SK_Scalar1,          -SK_ScalarTanPIOver8    },
+    { -SK_ScalarRoot2Over2, -SK_ScalarRoot2Over2    },
+    { -SK_ScalarTanPIOver8, -SK_Scalar1     },
+
+    { 0,                    -SK_Scalar1     },
+    { SK_ScalarTanPIOver8,  -SK_Scalar1     },
+    { SK_ScalarRoot2Over2,  -SK_ScalarRoot2Over2    },
+    { SK_Scalar1,           -SK_ScalarTanPIOver8    },
+
+    { SK_Scalar1,           0   }
 };
 
 int SkBuildQuadArc(const SkVector& uStart, const SkVector& uStop,
-                                  SkRotationDirection dir, const SkMatrix* userMatrix,
-                                  SkPoint quadPoints[])
-{
-       // check for (effectively) coincident vectors
-       {
-               SkScalar dot = SkScalarMul(uStart.fX, uStop.fX) + SkScalarMul(uStart.fY, uStop.fY);
-               if (SkScalarAbs(dot - SK_Scalar1) <= SK_ScalarNearlyZero)
-                       return 0;
-       }
-       // rotate unitStop so that unitStart is at (1,0)
-       SkScalar x = SkScalarMul(uStop.fX, uStart.fX) + SkScalarMul(uStop.fY, uStart.fY);
-       SkScalar y = SkScalarMul(uStop.fY, uStart.fX) - SkScalarMul(uStop.fX, uStart.fY);
-
-       if (dir == kCCW_SkRotationDirection)
-               y = -y;
-
-       // what octant (quadratic curve) is [xy] in?
-       int     oct = 0;
-       bool sameSign = true;
-
-       if (y < 0)
-               oct += 4;
-       if ((x < 0) != (y < 0))
-       {
-               oct += 2;
-               sameSign = false;
-       }
-       if ((SkScalarAbs(x) < SkScalarAbs(y)) == sameSign)
-               oct += 1;
-
-       if (SkScalarAbs(y) >= SK_Scalar1 || x <= -SK_Scalar1)
-               oct += 1;
-
-       int     wholeCount = oct << 1;
-       memcpy(quadPoints, gQuadCirclePts, (wholeCount + 1) * sizeof(SkPoint));
-
-       const SkPoint* arc = &gQuadCirclePts[wholeCount];
-       if (quad_pt2OffCurve(arc, x, y, &quadPoints[wholeCount + 1]))
-       {
-               quadPoints[wholeCount + 2].set(x, y);
-               wholeCount += 2;
-       }
-       wholeCount += 1;
-
-       // now handle counter-clockwise and the initial unitStart rotation
-       SkMatrix        matrix;
-       matrix.setSinCos(uStart.fY, uStart.fX, 0, 0);
-       if (dir == kCCW_SkRotationDirection)
-               matrix.preScale(SK_Scalar1, -SK_Scalar1, 0, 0);
-       if (userMatrix)
-               matrix.postConcat(*userMatrix);
-       matrix.mapPoints(quadPoints, wholeCount);
-       return wholeCount;
+                   SkRotationDirection dir, const SkMatrix* userMatrix,
+                   SkPoint quadPoints[])
+{
+    // check for (effectively) coincident vectors
+    {
+        SkScalar dot = SkScalarMul(uStart.fX, uStop.fX) + SkScalarMul(uStart.fY, uStop.fY);
+        if (SkScalarAbs(dot - SK_Scalar1) <= SK_ScalarNearlyZero)
+            return 0;
+    }
+    // rotate unitStop so that unitStart is at (1,0)
+    SkScalar x = SkScalarMul(uStop.fX, uStart.fX) + SkScalarMul(uStop.fY, uStart.fY);
+    SkScalar y = SkScalarMul(uStop.fY, uStart.fX) - SkScalarMul(uStop.fX, uStart.fY);
+
+    if (dir == kCCW_SkRotationDirection)
+        y = -y;
+
+    // what octant (quadratic curve) is [xy] in?
+    int oct = 0;
+    bool sameSign = true;
+
+    if (y < 0)
+        oct += 4;
+    if ((x < 0) != (y < 0))
+    {
+        oct += 2;
+        sameSign = false;
+    }
+    if ((SkScalarAbs(x) < SkScalarAbs(y)) == sameSign)
+        oct += 1;
+
+    if (SkScalarAbs(y) >= SK_Scalar1 || x <= -SK_Scalar1)
+        oct += 1;
+
+    int wholeCount = oct << 1;
+    memcpy(quadPoints, gQuadCirclePts, (wholeCount + 1) * sizeof(SkPoint));
+
+    const SkPoint* arc = &gQuadCirclePts[wholeCount];
+    if (quad_pt2OffCurve(arc, x, y, &quadPoints[wholeCount + 1]))
+    {
+        quadPoints[wholeCount + 2].set(x, y);
+        wholeCount += 2;
+    }
+    wholeCount += 1;
+
+    // now handle counter-clockwise and the initial unitStart rotation
+    SkMatrix    matrix;
+    matrix.setSinCos(uStart.fY, uStart.fX);
+    if (dir == kCCW_SkRotationDirection)
+        matrix.preScale(SK_Scalar1, -SK_Scalar1);
+    if (userMatrix)
+        matrix.postConcat(*userMatrix);
+    matrix.mapPoints(quadPoints, wholeCount);
+    return wholeCount;
 }
 
 
@@ -997,14 +1014,14 @@ int SkBuildQuadArc(const SkVector& uStart, const SkVector& uStop,
 void SkGeometry::UnitTest()
 {
 #ifdef SK_SUPPORT_UNITTEST
-       SkPoint pts[3], dst[5];
+    SkPoint pts[3], dst[5];
 
-       pts[0].set(0, 0);
-       pts[1].set(100, 50);
-       pts[2].set(0, 100);
+    pts[0].set(0, 0);
+    pts[1].set(100, 50);
+    pts[2].set(0, 100);
 
-       int count = SkChopQuadAtMaxCurvature(pts, dst);
-       SkASSERT(count == 1 || count == 2);
+    int count = SkChopQuadAtMaxCurvature(pts, dst);
+    SkASSERT(count == 1 || count == 2);
 #endif
 }
 
index a76dfc2..b8e2976 100644 (file)
+/* libs/graphics/sgl/SkGeometry.h
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #ifndef SkGeometry_DEFINED
 #define SkGeometry_DEFINED
 
 #include "SkMatrix.h"
 
-/**    Given a quadratic equation Ax^2 + Bx + C = 0, return 0, 1, 2 roots for the
-       equation.
+/** Given a quadratic equation Ax^2 + Bx + C = 0, return 0, 1, 2 roots for the
+    equation.
 */
 int SkFindUnitQuadRoots(SkScalar A, SkScalar B, SkScalar C, SkScalar roots[2]);
 
 ///////////////////////////////////////////////////////////////////////////////
 
-/**    Set pt to the point on the src quadratic specified by t. t must be
-       0 <= t <= 1.0
+/** Set pt to the point on the src quadratic specified by t. t must be
+    0 <= t <= 1.0
 */
 void SkEvalQuadAt(const SkPoint src[3], SkScalar t, SkPoint* pt, SkVector* tangent = nil);
 void SkEvalQuadAtHalf(const SkPoint src[3], SkPoint* pt, SkVector* tangent = nil);
 
-/**    Given a src quadratic bezier, chop it at the specified t value,
-       where 0 < t < 1, and return the two new quadratics in dst:
-       dst[0..2] and dst[2..4]
+/** Given a src quadratic bezier, chop it at the specified t value,
+    where 0 < t < 1, and return the two new quadratics in dst:
+    dst[0..2] and dst[2..4]
 */
 void SkChopQuadAt(const SkPoint src[3], SkPoint dst[5], SkScalar t);
 
-/**    Given a src quadratic bezier, chop it at the specified t == 1/2,
-       The new quads are returned in dst[0..2] and dst[2..4]
+/** Given a src quadratic bezier, chop it at the specified t == 1/2,
+    The new quads are returned in dst[0..2] and dst[2..4]
 */
 void SkChopQuadAtHalf(const SkPoint src[3], SkPoint dst[5]);
 
-/**    Given the 3 coefficients for a quadratic bezier (either X or Y values), look
-       for extrema, and return the number of t-values that are found that represent
-       these extrema. If the quadratic has no extrema betwee (0..1) exclusive, the
-       function returns 0.
-       Returned count          tValues[]
-       0                                       ignored
-       1                                       0 < tValues[0] < 1
+/** Given the 3 coefficients for a quadratic bezier (either X or Y values), look
+    for extrema, and return the number of t-values that are found that represent
+    these extrema. If the quadratic has no extrema betwee (0..1) exclusive, the
+    function returns 0.
+    Returned count      tValues[]
+    0                   ignored
+    1                   0 < tValues[0] < 1
 */
 int SkFindQuadExtrema(SkScalar a, SkScalar b, SkScalar c, SkScalar tValues[1]);
 
-/**    Given 3 points on a quadratic bezier, chop it into 1, 2 beziers such that
-       the resulting beziers are monotonic in Y. This is called by the scan converter.
-       Depending on what is returned, dst[] is treated as follows
-       1       dst[0..2] is the original quad
-       2       dst[0..2] and dst[2..4] are the two new quads
-       If dst == nil, it is ignored and only the count is returned.
+/** Given 3 points on a quadratic bezier, chop it into 1, 2 beziers such that
+    the resulting beziers are monotonic in Y. This is called by the scan converter.
+    Depending on what is returned, dst[] is treated as follows
+    1   dst[0..2] is the original quad
+    2   dst[0..2] and dst[2..4] are the two new quads
+    If dst == nil, it is ignored and only the count is returned.
 */
 int SkChopQuadAtYExtrema(const SkPoint src[3], SkPoint dst[5]);
 
-/**    Given 3 points on a quadratic bezier, divide it into 2 quadratics
-       if the point of maximum curvature exists on the quad segment.
-       Depending on what is returned, dst[] is treated as follows
-       1       dst[0..2] is the original quad
-       2       dst[0..2] and dst[2..4] are the two new quads
-       If dst == nil, it is ignored and only the count is returned.
+/** Given 3 points on a quadratic bezier, divide it into 2 quadratics
+    if the point of maximum curvature exists on the quad segment.
+    Depending on what is returned, dst[] is treated as follows
+    1   dst[0..2] is the original quad
+    2   dst[0..2] and dst[2..4] are the two new quads
+    If dst == nil, it is ignored and only the count is returned.
 */
 int SkChopQuadAtMaxCurvature(const SkPoint src[3], SkPoint dst[5]);
 
 ////////////////////////////////////////////////////////////////////////////////////////
 
-/**    Convert from parametric from (pts) to polynomial coefficients
-       coeff[0]*T^3 + coeff[1]*T^2 + coeff[2]*T + coeff[3]
+/** Convert from parametric from (pts) to polynomial coefficients
+    coeff[0]*T^3 + coeff[1]*T^2 + coeff[2]*T + coeff[3]
 */
 void SkGetCubicCoeff(const SkPoint pts[4], SkScalar cx[4], SkScalar cy[4]);
 
-/**    Set pt to the point on the src cubic specified by t. t must be
-       0 <= t <= 1.0
+/** Set pt to the point on the src cubic specified by t. t must be
+    0 <= t <= 1.0
 */
 void SkEvalCubicAt(const SkPoint src[4], SkScalar t, SkPoint* locOrNil, SkVector* tangentOrNil, SkVector* curvatureOrNil);
 
-/**    Given a src cubic bezier, chop it at the specified t value,
-       where 0 < t < 1, and return the two new cubics in dst:
-       dst[0..3] and dst[3..6]
+/** Given a src cubic bezier, chop it at the specified t value,
+    where 0 < t < 1, and return the two new cubics in dst:
+    dst[0..3] and dst[3..6]
 */
 void SkChopCubicAt(const SkPoint src[4], SkPoint dst[7], SkScalar t);
 void SkChopCubicAt(const SkPoint src[4], SkPoint dst[7], const SkScalar t[], int t_count);
 
-/**    Given a src cubic bezier, chop it at the specified t == 1/2,
-       The new cubics are returned in dst[0..3] and dst[3..6]
+/** Given a src cubic bezier, chop it at the specified t == 1/2,
+    The new cubics are returned in dst[0..3] and dst[3..6]
 */
 void SkChopCubicAtHalf(const SkPoint src[4], SkPoint dst[7]);
 
-/**    Given the 4 coefficients for a cubic bezier (either X or Y values), look
-       for extrema, and return the number of t-values that are found that represent
-       these extrema. If the cubic has no extrema betwee (0..1) exclusive, the
-       function returns 0.
-       Returned count          tValues[]
-       0                                       ignored
-       1                                       0 < tValues[0] < 1
-       2                                       0 < tValues[0] < tValues[1] < 1
+/** Given the 4 coefficients for a cubic bezier (either X or Y values), look
+    for extrema, and return the number of t-values that are found that represent
+    these extrema. If the cubic has no extrema betwee (0..1) exclusive, the
+    function returns 0.
+    Returned count      tValues[]
+    0                   ignored
+    1                   0 < tValues[0] < 1
+    2                   0 < tValues[0] < tValues[1] < 1
 */
 int SkFindCubicExtrema(SkScalar a, SkScalar b, SkScalar c, SkScalar d, SkScalar tValues[2]);
 
-/**    Given 4 points on a cubic bezier, chop it into 1, 2, 3 beziers such that
-       the resulting beziers are monotonic in Y. This is called by the scan converter.
-       Depending on what is returned, dst[] is treated as follows
-       1       dst[0..3] is the original cubic
-       2       dst[0..3] and dst[3..6] are the two new cubics
-       3       dst[0..3], dst[3..6], dst[6..9] are the three new cubics
-       If dst == nil, it is ignored and only the count is returned.
+/** Given 4 points on a cubic bezier, chop it into 1, 2, 3 beziers such that
+    the resulting beziers are monotonic in Y. This is called by the scan converter.
+    Depending on what is returned, dst[] is treated as follows
+    1   dst[0..3] is the original cubic
+    2   dst[0..3] and dst[3..6] are the two new cubics
+    3   dst[0..3], dst[3..6], dst[6..9] are the three new cubics
+    If dst == nil, it is ignored and only the count is returned.
 */
 int SkChopCubicAtYExtrema(const SkPoint src[4], SkPoint dst[10]);
 
-/**    Given a cubic bezier, return 0, 1, or 2 t-values that represent the
-       inflection points.
+/** Given a cubic bezier, return 0, 1, or 2 t-values that represent the
+    inflection points.
 */
 int SkFindCubicInflections(const SkPoint src[4], SkScalar tValues[2]);
 
-/**    Return 1 for no chop, or 2 for having chopped the cubic at its
-       inflection point.
+/** Return 1 for no chop, or 2 for having chopped the cubic at its
+    inflection point.
 */
 int SkChopCubicAtInflections(const SkPoint src[4], SkPoint dst[10]);
 
@@ -116,31 +133,31 @@ int SkChopCubicAtMaxCurvature(const SkPoint src[4], SkPoint dst[13], SkScalar tV
 ///////////////////////////////////////////////////////////////////////////////////////////
 
 enum SkRotationDirection {
-       kCW_SkRotationDirection,
-       kCCW_SkRotationDirection
+    kCW_SkRotationDirection,
+    kCCW_SkRotationDirection
 };
 
-/**    Maximum number of points needed in the quadPoints[] parameter for
-       SkBuildQuadArc()
+/** Maximum number of points needed in the quadPoints[] parameter for
+    SkBuildQuadArc()
 */
-#define kSkBuildQuadArcStorage 17
+#define kSkBuildQuadArcStorage  17
 
-/**    Given 2 unit vectors and a rotation direction, fill out the specified
-       array of points with quadratic segments. Return is the number of points
-       written to, which will be { 0, 3, 5, 7, ... kSkBuildQuadArcStorage }
+/** Given 2 unit vectors and a rotation direction, fill out the specified
+    array of points with quadratic segments. Return is the number of points
+    written to, which will be { 0, 3, 5, 7, ... kSkBuildQuadArcStorage }
 
-       matrix, if not nil, is appled to the points before they are returned.
+    matrix, if not nil, is appled to the points before they are returned.
 */
 int SkBuildQuadArc(const SkVector& unitStart, const SkVector& unitStop, SkRotationDirection,
-                                  const SkMatrix* matrix, SkPoint quadPoints[]);
+                   const SkMatrix* matrix, SkPoint quadPoints[]);
 
 //////////////////////////////////////////////////////////////////////////////
 
 #ifdef SK_DEBUG
-       class SkGeometry {
-       public:
-               static void UnitTest();
-       };
+    class SkGeometry {
+    public:
+        static void UnitTest();
+    };
 #endif
 
 #endif
index a53cc1d..c11d1e2 100644 (file)
@@ -1,3 +1,20 @@
+/* libs/graphics/sgl/SkGlobals.cpp
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #include "SkGlobals.h"
 #include "SkThread.h"
 
@@ -7,45 +24,45 @@ SkGlobals::Rec::~Rec()
 
 SkGlobals::Rec* SkGlobals::Find(U32 tag, Rec* (*create_proc)())
 {
-       SkGlobals::BootStrap&   bootstrap = SkGlobals::GetBootStrap();
-
-       Rec* rec = bootstrap.fHead;
-       while (rec)
-       {
-               if (rec->fTag == tag)
-                       return rec;
-               rec = rec->fNext;
-       }
-
-       if (create_proc == nil) // no create proc, just return not found
-               return nil;
-
-       // if we get here, we may need to create one. First grab the mutex, and
-       // search again, creating one if its not found the 2nd time.
-
-       bootstrap.fMutex.acquire();
-
-       // search again, now that we have the mutex. Odds are it won't be there, but we check again
-       // just in case it was added by another thread before we grabbed the mutex
-
-       Rec*& head = bootstrap.fHead;
-       rec = head;
-       while (rec)
-       {
-               if (rec->fTag == tag)
-                       break;
-               rec = rec->fNext;
-       }
-
-       if (rec == nil && (rec = create_proc()) != nil)
-       {
-               rec->fTag = tag;
-               rec->fNext = head;
-               bootstrap.fHead = rec;
-       }
-
-       bootstrap.fMutex.release();
-       return rec;
+    SkGlobals::BootStrap&   bootstrap = SkGlobals::GetBootStrap();
+
+    Rec* rec = bootstrap.fHead;
+    while (rec)
+    {
+        if (rec->fTag == tag)
+            return rec;
+        rec = rec->fNext;
+    }
+
+    if (create_proc == nil) // no create proc, just return not found
+        return nil;
+
+    // if we get here, we may need to create one. First grab the mutex, and
+    // search again, creating one if its not found the 2nd time.
+
+    bootstrap.fMutex.acquire();
+
+    // search again, now that we have the mutex. Odds are it won't be there, but we check again
+    // just in case it was added by another thread before we grabbed the mutex
+
+    Rec*& head = bootstrap.fHead;
+    rec = head;
+    while (rec)
+    {
+        if (rec->fTag == tag)
+            break;
+        rec = rec->fNext;
+    }
+
+    if (rec == nil && (rec = create_proc()) != nil)
+    {
+        rec->fTag = tag;
+        rec->fNext = head;
+        bootstrap.fHead = rec;
+    }
+
+    bootstrap.fMutex.release();
+    return rec;
 }
 
 void SkGlobals::Init()
@@ -54,22 +71,22 @@ void SkGlobals::Init()
 
 void SkGlobals::Term()
 {
-       SkGlobals::BootStrap&   bootstrap = SkGlobals::GetBootStrap();
+    SkGlobals::BootStrap&   bootstrap = SkGlobals::GetBootStrap();
 
-       bootstrap.fMutex.acquire();
+    bootstrap.fMutex.acquire();
 
-       Rec*&   head = bootstrap.fHead;
-       Rec*    rec = head;
+    Rec*&   head = bootstrap.fHead;
+    Rec*    rec = head;
 
-       while (rec)
-       {
-               Rec* next = rec->fNext;
-               SkDELETE(rec);
-               rec = next;
-       }
+    while (rec)
+    {
+        Rec* next = rec->fNext;
+        SkDELETE(rec);
+        rec = next;
+    }
 
-       bootstrap.fHead = nil;
-       bootstrap.fMutex.release();
+    bootstrap.fHead = nil;
+    bootstrap.fMutex.release();
 }
 
 
index 60d0ba3..5778227 100644 (file)
+/* libs/graphics/sgl/SkGlyphCache.cpp
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #include "SkGlyphCache.h"
 #include "SkPaint.h"
 #include "SkTemplates.h"
 
 //////////////////////////////////////////////////////////////////////
 
-#define kMinGlphAlloc          (sizeof(SkGlyph) * 64)
-#define kMinImageAlloc         (24 * 64)       // this guy should be pointsize-dependent IMHO
+#define kMinGlphAlloc       (sizeof(SkGlyph) * 64)
+#define kMinImageAlloc      (24 * 64)   // this guy should be pointsize-dependent IMHO
 
-/*  We use this local function instead of the static class method to work around
-    a bug in gcc98
-*/
-void SkDescriptor_Free(SkDescriptor* desc);
-void SkDescriptor_Free(SkDescriptor* desc)
+SkGlyphCache::SkGlyphCache(const SkDescriptor* desc)
+    : fGlyphAlloc(kMinGlphAlloc), fImageAlloc(kMinImageAlloc)
+{
+    fNext = NULL;
+
+    fDesc = desc->copy();
+    fScalerContext = SkScalerContext::Create(desc);
+    fScalerContext->getLineHeight(&fAbove, &fBelow);
+
+    // init to 0 so that all of the pointers will be null
+    memset(fGlyphHash, 0, sizeof(fGlyphHash));
+    // init with 0xFF so that the charCode field will be -1, which is invalid
+    memset(fCharToGlyphHash, 0xFF, sizeof(fCharToGlyphHash));
+}
+
+SkGlyphCache::~SkGlyphCache()
 {
-    SkDescriptor::Free(desc);
+    SkGlyph**   gptr = fGlyphArray.begin();
+    SkGlyph**   stop = fGlyphArray.end();
+    while (gptr < stop)
+    {
+        SkPath* path = (*gptr)->fPath;
+        if (path)
+            SkDELETE(path);
+        gptr += 1;
+    }
+    SkDescriptor::Free(fDesc);
+    SkDELETE(fScalerContext);
 }
 
-SkGlyphCache::SkGlyphCache(const SkDescriptor* desc)
-       : fGlyphAlloc(kMinGlphAlloc), fImageAlloc(kMinImageAlloc)
+const SkGlyph& SkGlyphCache::getUnicharMetrics(SkUnichar charCode)
 {
-       fNext = NULL;
-       fDesc = desc->copy();
-       SkAutoTCallProc<SkDescriptor, SkDescriptor_Free> autoFree(fDesc);
-       fScalerContext = SkScalerContext::Create(desc);
-       memset(fHash, 0, sizeof(fHash));
-
-       fScalerContext->getLineHeight(&fAbove, &fBelow);
-       (void)autoFree.detach();
+    CharGlyphRec* rec = &fCharToGlyphHash[charCode & kHashMask];
+
+    if (rec->fCharCode != charCode)
+    {
+        rec->fCharCode  = charCode;
+        rec->fGlyph     = this->lookupMetrics(fScalerContext->charToGlyphID(charCode));
+    }
+    return *rec->fGlyph;
 }
 
-SkGlyphCache::~SkGlyphCache()
+const SkGlyph& SkGlyphCache::getGlyphIDMetrics(uint16_t glyphID)
 {
-       SkGlyph**       gptr = fGlyphArray.begin();
-       SkGlyph**       stop = fGlyphArray.end();
-       while (gptr < stop)
-       {
-               SkPath* path = (*gptr)->fPath;
-               if (path)
-                       SkDELETE(path);
-               gptr += 1;
-       }
-       SkDescriptor::Free(fDesc);
-       SkDELETE(fScalerContext);
+    SkGlyph* glyph = fGlyphHash[glyphID & kHashMask];
+
+    if (NULL == glyph || glyph->f_GlyphID != glyphID)
+    {
+        glyph = this->lookupMetrics(glyphID);
+        fGlyphHash[glyphID & kHashMask] = glyph;
+    }
+    return *glyph;
 }
 
-const SkGlyph& SkGlyphCache::lookupMetrics(SkUnichar charCode)
+SkGlyph* SkGlyphCache::lookupMetrics(uint16_t glyphID)
 {
-       SkGlyph* glyph;
-
-       int             hi = 0;
-       int             count = fGlyphArray.count();
-
-       if (count)
-       {
-               SkGlyph**       gptr = fGlyphArray.begin();
-               int             lo = 0;
-
-               hi = count - 1;
-               while (lo < hi)
-               {
-                       int mid = (hi + lo) >> 1;
-                       if (gptr[mid]->fCharCode < charCode)
-                               lo = mid + 1;
-                       else
-                               hi = mid;
-               }
-               glyph = gptr[hi];
-               if (glyph->fCharCode == charCode)
-                       goto DONE;
-
-               // check if we need to bump hi before falling though to the allocator
-               if (glyph->fCharCode < charCode)
-                       hi += 1;
-       }
-
-       // not found, but hi tells us where to inser the new glyph
-
-       glyph = (SkGlyph*)fGlyphAlloc.alloc(sizeof(SkGlyph), SkChunkAlloc::kThrow_AllocFailType);
-       glyph->fCharCode = SkToU16(charCode);
-       glyph->fImage = NULL;
-       glyph->fPath = NULL;
-       fScalerContext->getMetrics(glyph);
-       *fGlyphArray.insert(hi) = glyph;
-
-DONE:
-       fHash[charCode & kHashMask] = glyph;
-       return *glyph;
+    SkGlyph* glyph;
+
+    int     hi = 0;
+    int     count = fGlyphArray.count();
+
+    if (count)
+    {
+        SkGlyph**   gptr = fGlyphArray.begin();
+        int     lo = 0;
+
+        hi = count - 1;
+        while (lo < hi)
+        {
+            int mid = (hi + lo) >> 1;
+            if (gptr[mid]->f_GlyphID < glyphID)
+                lo = mid + 1;
+            else
+                hi = mid;
+        }
+        glyph = gptr[hi];
+        if (glyph->f_GlyphID == glyphID)
+            return glyph;
+
+        // check if we need to bump hi before falling though to the allocator
+        if (glyph->f_GlyphID < glyphID)
+            hi += 1;
+    }
+
+    // not found, but hi tells us where to inser the new glyph
+
+    glyph = (SkGlyph*)fGlyphAlloc.alloc(sizeof(SkGlyph), SkChunkAlloc::kThrow_AllocFailType);
+    glyph->f_GlyphID = glyphID;
+    glyph->fImage = NULL;
+    glyph->fPath = NULL;
+    fScalerContext->getMetrics(glyph);
+    *fGlyphArray.insert(hi) = glyph;
+    return glyph;
 }
 
-const void* SkGlyphCache::findImage(SkUnichar uni)
+const void* SkGlyphCache::findImage(const SkGlyph& glyph)
 {
-       // cast away the constness, so we can update fImage if needed
-       SkGlyph* glyph = (SkGlyph*)&this->getMetrics(uni);
-
-       if (glyph->fWidth)
-       {
-               if (glyph->fImage == NULL)
-               {
-                       size_t  size = glyph->computeImageSize();
-                       glyph->fImage = fImageAlloc.alloc(size, SkChunkAlloc::kReturnNil_AllocFailType);
-                       fScalerContext->getImage(*glyph);
-               }
-       }
-       return glyph->fImage;
+    if (glyph.fWidth)
+    {
+        if (glyph.fImage == NULL)
+        {
+            size_t  size = glyph.computeImageSize();
+            const_cast<SkGlyph&>(glyph).fImage = fImageAlloc.alloc(size, SkChunkAlloc::kReturnNil_AllocFailType);
+            fScalerContext->getImage(glyph);
+        }
+    }
+    return glyph.fImage;
 }
 
-const SkPath* SkGlyphCache::findPath(SkUnichar uni)
+const SkPath* SkGlyphCache::findPath(const SkGlyph& glyph)
 {
-       // cast away the constness, so we can update fImage if needed
-       SkGlyph* glyph = (SkGlyph*)&this->getMetrics(uni);
-
-       if (glyph->fWidth)
-       {
-               if (glyph->fPath == NULL)
-               {
-                       glyph->fPath = SkNEW(SkPath);
-                       fScalerContext->getPath(*glyph, glyph->fPath);
-               }
-       }
-       return glyph->fPath;
+    if (glyph.fWidth)
+    {
+        if (glyph.fPath == NULL)
+        {
+            const_cast<SkGlyph&>(glyph).fPath = SkNEW(SkPath);
+            fScalerContext->getPath(glyph, glyph.fPath);
+        }
+    }
+    return glyph.fPath;
 }
 
 void SkGlyphCache::getLineHeight(SkPoint* above, SkPoint* below)
 {
-       if (above)
-               *above = fAbove;
-       if (below)
-               *below = fBelow;
+    if (above)
+        *above = fAbove;
+    if (below)
+        *below = fBelow;
 }
 
 /////////////////////////////////////////////////////////////////
 
 SkGlyphCache* SkGlyphCache::DetachCache(const SkPaint& paint, const SkMatrix* matrix)
 {
-       return paint.detachCache(matrix);
+    return paint.detachCache(matrix);
 }
 
 #include "SkGlobals.h"
 #include "SkThread.h"
 
-#define SkGlyphCache_GlobalsTag                SkSetFourByteTag('g', 'l', 'f', 'c')
+#define SkGlyphCache_GlobalsTag     SkSetFourByteTag('g', 'l', 'f', 'c')
 
 class SkGlyphCache_Globals : public SkGlobals::Rec {
 public:
-       SkMutex                 fMutex;
-       SkGlyphCache*   fHead;
+    SkMutex         fMutex;
+    SkGlyphCache*   fHead;
 };
 
 #ifdef SK_USE_RUNTIME_GLOBALS
-       static SkGlobals::Rec* create_globals()
-       {
-               SkGlyphCache_Globals* rec = SkNEW(SkGlyphCache_Globals);
-               rec->fHead = NULL;
-               return rec;
-       }
-
-       #define FIND_GC_GLOBALS()       *(SkGlyphCache_Globals*)SkGlobals::Find(SkGlyphCache_GlobalsTag, create_globals)
-       #define GET_GC_GLOBALS()        *(SkGlyphCache_Globals*)SkGlobals::Get(SkGlyphCache_GlobalsTag)
+    static SkGlobals::Rec* create_globals()
+    {
+        SkGlyphCache_Globals* rec = SkNEW(SkGlyphCache_Globals);
+        rec->fHead = NULL;
+        return rec;
+    }
+
+    #define FIND_GC_GLOBALS()   *(SkGlyphCache_Globals*)SkGlobals::Find(SkGlyphCache_GlobalsTag, create_globals)
+    #define GET_GC_GLOBALS()    *(SkGlyphCache_Globals*)SkGlobals::Get(SkGlyphCache_GlobalsTag)
 #else
-       static SkGlyphCache_Globals     gGCGlobals;
-       #define FIND_GC_GLOBALS()       gGCGlobals
-       #define GET_GC_GLOBALS()        gGCGlobals
+    static SkGlyphCache_Globals gGCGlobals;
+    #define FIND_GC_GLOBALS()   gGCGlobals
+    #define GET_GC_GLOBALS()    gGCGlobals
 #endif
 
 SkGlyphCache* SkGlyphCache::DetachCache(const SkDescriptor* desc)
 {
-       SkASSERT(desc);
-
-       SkGlyphCache_Globals& globals = FIND_GC_GLOBALS();
-
-       globals.fMutex.acquire();
-       SkGlyphCache*   cache = globals.fHead;
-       SkGlyphCache*   prev = NULL;
-
-       while (cache)
-       {
-               SkGlyphCache* next = cache->fNext;
-
-               if (*cache->fDesc == *desc)
-               {
-                       if (prev)
-                               prev->fNext = next;
-                       else
-                               globals.fHead = next;
-                       cache->fNext = NULL;
-                       break;
-               }
-               prev = cache;
-               cache = next;
-       }
-       globals.fMutex.release();
-
-       if (cache == NULL)
-               cache = SkNEW_ARGS(SkGlyphCache, (desc));
-       return cache;
+    SkASSERT(desc);
+
+    SkGlyphCache_Globals& globals = FIND_GC_GLOBALS();
+
+    globals.fMutex.acquire();
+    SkGlyphCache*   cache = globals.fHead;
+    SkGlyphCache*   prev = NULL;
+
+    while (cache)
+    {
+        SkGlyphCache* next = cache->fNext;
+
+        if (*cache->fDesc == *desc)
+        {
+            if (prev)
+                prev->fNext = next;
+            else
+                globals.fHead = next;
+            cache->fNext = NULL;
+            break;
+        }
+        prev = cache;
+        cache = next;
+    }
+    globals.fMutex.release();
+
+    if (cache == NULL)
+        cache = SkNEW_ARGS(SkGlyphCache, (desc));
+    return cache;
 }
 
 void SkGlyphCache::AttachCache(SkGlyphCache* cache)
 {
-       SkASSERT(cache);
-       SkASSERT(cache->fNext == NULL);
+    SkASSERT(cache);
+    SkASSERT(cache->fNext == NULL);
 
-       SkGlyphCache_Globals& globals = GET_GC_GLOBALS();
+    SkGlyphCache_Globals& globals = GET_GC_GLOBALS();
 
-       globals.fMutex.acquire();
+    globals.fMutex.acquire();
 
-       cache->fNext = globals.fHead;
-       globals.fHead = cache;
+    cache->fNext = globals.fHead;
+    globals.fHead = cache;
 
-       globals.fMutex.release();
+    globals.fMutex.release();
 }
 
 bool SkGlyphCache::FreeCache(size_t bytesNeeded)
 {
-       SkGlyphCache_Globals& globals = FIND_GC_GLOBALS();
+    SkGlyphCache_Globals& globals = FIND_GC_GLOBALS();
 
-       globals.fMutex.acquire();
-       SkGlyphCache*   cache = globals.fHead;
-       bool                    didSomething = (cache != NULL);
+    globals.fMutex.acquire();
+    SkGlyphCache*   cache = globals.fHead;
+    bool            didSomething = (cache != NULL);
 
-       while (cache)
-       {
-               SkGlyphCache* next = cache->fNext;
-               SkDELETE(cache);
-               cache = next;
-       }
+    while (cache)
+    {
+        SkGlyphCache* next = cache->fNext;
+        SkDELETE(cache);
+        cache = next;
+    }
 
-       globals.fHead = NULL;
-       globals.fMutex.release();
+    globals.fHead = NULL;
+    globals.fMutex.release();
 
-       return didSomething;
+    return didSomething;
 }
 
index 20a7ace..ab7f14d 100644 (file)
@@ -1,3 +1,20 @@
+/* libs/graphics/sgl/SkGlyphCache.h
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #ifndef SkGlyphCache_DEFINED
 #define SkGlyphCache_DEFINED
 
@@ -11,78 +28,77 @@ class SkPaint;
 
 class SkGlyphCache {
 public:
-       const SkGlyph& getMetrics(SkUnichar charCode)
-       {
-               int              hash = charCode & kHashMask;
-               SkGlyph* glyph = fHash[hash];
-
-               if (glyph != nil && glyph->fCharCode == charCode)
-                       return *glyph;
-               return this->lookupMetrics(charCode);
-       }
-
-
-       const void*             findImage(SkUnichar);
-       const SkPath*   findPath(SkUnichar);
-       void                    getLineHeight(SkPoint* above, SkPoint* below);
-
-       static SkGlyphCache* DetachCache(const SkPaint&, const SkMatrix* matrix);
-       static SkGlyphCache* DetachCache(const SkDescriptor*);
-       static void                      AttachCache(SkGlyphCache*);
-       static bool                      FreeCache(size_t bytesNeeded);
+    const SkGlyph& getUnicharMetrics(SkUnichar);
+    const SkGlyph& getGlyphIDMetrics(uint16_t);
+    
+    const void*     findImage(const SkGlyph&);
+    const SkPath*   findPath(const SkGlyph&);
+    void            getLineHeight(SkPoint* above, SkPoint* below);
+
+    static SkGlyphCache* DetachCache(const SkPaint&, const SkMatrix* matrix);
+    static SkGlyphCache* DetachCache(const SkDescriptor*);
+    static void          AttachCache(SkGlyphCache*);
+    static bool          FreeCache(size_t bytesNeeded);
 
 private:
-       SkGlyphCache(const SkDescriptor*);
-       ~SkGlyphCache();
-
-       const SkGlyph& lookupMetrics(SkUnichar charCode);
-
-       SkGlyphCache*           fNext;
-       SkDescriptor*           fDesc;
-       SkScalerContext*        fScalerContext;
-
-       enum {
-               kHashBits       = 6,
-               kHashCount      = 1 << kHashBits,
-               kHashMask       = kHashCount - 1
-       };
-       SkGlyph*                        fHash[kHashCount];
-       SkTDArray<SkGlyph*>     fGlyphArray;
-       SkChunkAlloc            fGlyphAlloc;
-       SkChunkAlloc            fImageAlloc;
-
-       SkPoint fAbove, fBelow;
+    SkGlyphCache(const SkDescriptor*);
+    ~SkGlyphCache();
+
+    SkGlyph* lookupMetrics(uint16_t);
+
+    SkGlyphCache*       fNext;
+    SkDescriptor*       fDesc;
+    SkScalerContext*    fScalerContext;
+
+    enum {
+        kHashBits   = 6,
+        kHashCount  = 1 << kHashBits,
+        kHashMask   = kHashCount - 1
+    };
+    SkGlyph*            fGlyphHash[kHashCount];
+    SkTDArray<SkGlyph*> fGlyphArray;
+    SkChunkAlloc        fGlyphAlloc;
+    SkChunkAlloc        fImageAlloc;
+    
+    struct CharGlyphRec {
+        SkUnichar   fCharCode;
+        SkGlyph*    fGlyph;
+    };
+    // no reason to use the same kHashCount as fGlyphHash, but we do for now
+    CharGlyphRec    fCharToGlyphHash[kHashCount];
+
+    SkPoint fAbove, fBelow;
 };
 
 class SkAutoGlyphCache {
 public:
-       SkAutoGlyphCache(SkGlyphCache* cache) : fCache(cache) {}
-       SkAutoGlyphCache(const SkDescriptor* desc)
-       {
-               fCache = SkGlyphCache::DetachCache(desc);
-       }
-       SkAutoGlyphCache(const SkPaint& paint, const SkMatrix* matrix)
-       {
-               fCache = SkGlyphCache::DetachCache(paint, matrix);
-       }
-       ~SkAutoGlyphCache()
-       {
-               if (fCache)
-                       SkGlyphCache::AttachCache(fCache);
-       }
-
-       SkGlyphCache*   getCache() const { return fCache; }
-
-       void release()
-       {
-               if (fCache)
-               {
-                       SkGlyphCache::AttachCache(fCache);
-                       fCache = nil;
-               }
-       }
+    SkAutoGlyphCache(SkGlyphCache* cache) : fCache(cache) {}
+    SkAutoGlyphCache(const SkDescriptor* desc)
+    {
+        fCache = SkGlyphCache::DetachCache(desc);
+    }
+    SkAutoGlyphCache(const SkPaint& paint, const SkMatrix* matrix)
+    {
+        fCache = SkGlyphCache::DetachCache(paint, matrix);
+    }
+    ~SkAutoGlyphCache()
+    {
+        if (fCache)
+            SkGlyphCache::AttachCache(fCache);
+    }
+
+    SkGlyphCache*   getCache() const { return fCache; }
+
+    void release()
+    {
+        if (fCache)
+        {
+            SkGlyphCache::AttachCache(fCache);
+            fCache = nil;
+        }
+    }
 private:
-       SkGlyphCache*   fCache;
+    SkGlyphCache*   fCache;
 };
 
 #endif
index 82c9a68..e5f73cf 100644 (file)
@@ -1,3 +1,20 @@
+/* libs/graphics/sgl/SkGraphics.cpp
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #include "SkGraphics.h"
 
 #include "Sk64.h"
 #include "SkPath.h"
 #include "SkPathEffect.h"
 #include "SkPathMeasure.h"
+#include "SkRandom.h"
 #include "SkRefCnt.h"
 #include "SkShader.h"
 #include "SkStream.h"
 #include "SkTSearch.h"
+#include "SkTime.h"
 #include "SkUtils.h"
 #include "SkXfermode.h"
 
-#define typesizeline(type)     { #type , sizeof(type) }
-#define unittestline(type)     { #type , type::UnitTest }
+#define typesizeline(type)  { #type , sizeof(type) }
+#define unittestline(type)  { #type , type::UnitTest }
 
 
 #ifdef BUILD_EMBOSS_TABLE
-       extern void SkEmbossMask_BuildTable();
+    extern void SkEmbossMask_BuildTable();
 #endif
 
 #ifdef BUILD_RADIALGRADIENT_TABLE
-       extern void SkRadialGradient_BuildTable();
+    extern void SkRadialGradient_BuildTable();
 #endif
 
+#define BIG_LOOP_COUNT  1000000
+
 void SkGraphics::Init(bool runUnitTests)
 {
-       SkGlobals::Init();
+    SkGlobals::Init();
 
 #ifdef BUILD_EMBOSS_TABLE
-       SkEmbossMask_BuildTable();
+    SkEmbossMask_BuildTable();
 #endif
 #ifdef BUILD_RADIALGRADIENT_TABLE
-       SkRadialGradient_BuildTable();
+    SkRadialGradient_BuildTable();
 #endif
 
 #ifdef SK_SUPPORT_UNITTEST
-       if (runUnitTests == false)
-               return;
-       int i;
-
-       static const struct {
-               const char*     fTypeName;
-               size_t          fSizeOf;
-       } gTypeSize[] = {
-               typesizeline(char),
-               typesizeline(short),
-               typesizeline(int),
-               typesizeline(long),
-               typesizeline(size_t),
-               typesizeline(void*),
-
-               typesizeline(S8),
-               typesizeline(U8),
-               typesizeline(S16),
-               typesizeline(U16),
-               typesizeline(S32),
-               typesizeline(U32),
-               typesizeline(S8CPU),
-               typesizeline(U8CPU),
-               typesizeline(S16CPU),
-               typesizeline(U16CPU),
-
-               typesizeline(SkPoint),
-               typesizeline(SkRect),
-               typesizeline(SkMatrix),
-               typesizeline(SkPath),
-               typesizeline(SkRefCnt),
-
-               typesizeline(SkPaint),
-               typesizeline(SkCanvas),
-               typesizeline(SkBlitter),
-               typesizeline(SkShader),
-               typesizeline(SkXfermode),
-               typesizeline(SkPathEffect)
-       };
-
-       {
-               char    test = (char)(0-1);     // use this subtract to avoid truncation warnings (in VC7 at least)
-               if (test < 0)
-                       SkDebugf("SkGraphics: char is signed\n");
-               else
-                       SkDebugf("SkGraphics: char is unsigned\n");
-       }
-       for (i = 0; i < (int)SK_ARRAY_COUNT(gTypeSize); i++)
-               SkDebugf("SkGraphics: sizeof(%s) = %d\n", gTypeSize[i].fTypeName, gTypeSize[i].fSizeOf);
-
-       static const struct {
-               const char*     fTypeName;
-               void (*fUnitTest)();
-       } gUnitTests[] = {
-               unittestline(Sk64),
-               unittestline(SkMath),
-               unittestline(SkUtils),
-               unittestline(SkString),
-               unittestline(SkFloat),
-               unittestline(SkMatrix),
-               unittestline(SkGeometry),
+    if (runUnitTests == false)
+        return;
+    int i;
+
+    static const struct {
+        const char* fTypeName;
+        size_t      fSizeOf;
+    } gTypeSize[] = {
+        typesizeline(char),
+        typesizeline(short),
+        typesizeline(int),
+        typesizeline(long),
+        typesizeline(size_t),
+        typesizeline(void*),
+
+        typesizeline(S8),
+        typesizeline(U8),
+        typesizeline(S16),
+        typesizeline(U16),
+        typesizeline(S32),
+        typesizeline(U32),
+        typesizeline(S8CPU),
+        typesizeline(U8CPU),
+        typesizeline(S16CPU),
+        typesizeline(U16CPU),
+
+        typesizeline(SkPoint),
+        typesizeline(SkRect),
+        typesizeline(SkMatrix),
+        typesizeline(SkPath),
+        typesizeline(SkRefCnt),
+
+        typesizeline(SkPaint),
+        typesizeline(SkCanvas),
+        typesizeline(SkBlitter),
+        typesizeline(SkShader),
+        typesizeline(SkXfermode),
+        typesizeline(SkPathEffect)
+    };
+
+    {
+        char    test = (char)(0-1); // use this subtract to avoid truncation warnings (in VC7 at least)
+        if (test < 0)
+            SkDebugf("SkGraphics: char is signed\n");
+        else
+            SkDebugf("SkGraphics: char is unsigned\n");
+    }
+    for (i = 0; i < (int)SK_ARRAY_COUNT(gTypeSize); i++)
+        SkDebugf("SkGraphics: sizeof(%s) = %d\n", gTypeSize[i].fTypeName, gTypeSize[i].fSizeOf);
+
+    static const struct {
+        const char* fTypeName;
+        void (*fUnitTest)();
+    } gUnitTests[] = {
+        unittestline(Sk64),
+        unittestline(SkMath),
+        unittestline(SkUtils),
+        unittestline(SkString),
+        unittestline(SkFloat),
+        unittestline(SkMatrix),
+        unittestline(SkGeometry),
         unittestline(SkDeque),
-               unittestline(SkPath),
-               unittestline(SkPathMeasure)
-       };
-
-       for (i = 0; i < (int)SK_ARRAY_COUNT(gUnitTests); i++)
-       {
-               SkDebugf("SkGraphics: Running UnitTest for %s\n", gUnitTests[i].fTypeName);
-               gUnitTests[i].fUnitTest();
-               SkDebugf("SkGraphics: End UnitTest for %s\n", gUnitTests[i].fTypeName);
-       }
-       SkQSort_UnitTest();
+        unittestline(SkPath),
+        unittestline(SkPathMeasure)
+    };
+
+    for (i = 0; i < (int)SK_ARRAY_COUNT(gUnitTests); i++)
+    {
+        SkDebugf("SkGraphics: Running UnitTest for %s\n", gUnitTests[i].fTypeName);
+        gUnitTests[i].fUnitTest();
+        SkDebugf("SkGraphics: End UnitTest for %s\n", gUnitTests[i].fTypeName);
+    }
+    SkQSort_UnitTest();
 
 #endif
+
+    if (false)  // test asm fixmul
+    {
+        int j;
+        SkMSec now = SkTime::GetMSecs();
+        for (j = 0; j < BIG_LOOP_COUNT; j++) {
+            (void)SkFixedMul_portable(0x8000, 0x150000);
+        }
+        SkMSec now2 = SkTime::GetMSecs();
+        printf("-------- SkFixedMul_portable = %d\n", now2 - now);
+
+        for (j = 0; j < BIG_LOOP_COUNT; j++) {
+            (void)SkFixedMul(0x8000, 0x150000);
+        }
+        printf("-------- SkFixedMul = %d\n", SkTime::GetMSecs() - now2);
+
+        SkRandom rand;
+        for (j = 0; j < 10000; j++) {
+            SkFixed a = rand.nextS() >> 8;
+            SkFixed b = rand.nextS() >> 8;
+            SkFixed c1 = SkFixedMul_portable(a, b);
+            SkFixed c2 = SkFixedMul(a, b);
+            if (SkAbs32(c1 - c2) > 1)
+                printf("------ FixMul disagreement: (%x %x) slow=%x fast=%x\n", a, b, c1, c2);
+        }
+    }
+    
+    if (false)  // test asm fractmul
+    {
+        int j;
+        SkMSec now = SkTime::GetMSecs();
+        for (j = 0; j < BIG_LOOP_COUNT; j++) {
+            (void)SkFractMul_portable(0x800000, 0x1500000);
+        }
+        SkMSec now2 = SkTime::GetMSecs();
+        printf("-------- SkFractMul_portable = %d\n", now2 - now);
+
+        for (j = 0; j < BIG_LOOP_COUNT; j++) {
+            (void)SkFractMul(0x800000, 0x1500000);
+        }
+        printf("-------- SkFractMul = %d\n", SkTime::GetMSecs() - now2);
+
+        SkRandom rand;
+        for (j = 0; j < 10000; j++) {
+            SkFixed a = rand.nextS() >> 1;
+            SkFixed b = rand.nextS() >> 1;
+            SkFixed c1 = SkFractMul_portable(a, b);
+            SkFixed c2 = SkFractMul(a, b);
+            if (SkAbs32(c1 - c2) > 1)
+                printf("------ FractMul disagreement: (%x %x) slow=%x fast=%x\n", a, b, c1, c2);
+        }
+    }
+    
+    if (false)   // test asm clz
+    {
+        int j;
+        SkMSec now = SkTime::GetMSecs();
+        for (j = 0; j < BIG_LOOP_COUNT; j++) {
+            (void)SkCLZ_portable(now);
+        }
+        SkMSec now2 = SkTime::GetMSecs();
+        printf("-------- SkCLZ_portable = %d\n", now2 - now);
+
+        for (j = 0; j < BIG_LOOP_COUNT; j++) {
+            (void)SkCLZ(now);
+        }
+        printf("-------- SkCLZ = %d\n", SkTime::GetMSecs() - now2);
+
+        SkRandom rand;
+        for (j = 0; j < 10000; j++) {
+            uint32_t a = rand.nextU();
+            int c1 = SkCLZ_portable(a);
+            int c2 = SkCLZ(a);
+            if (c1 != c2)
+                printf("------ CLZ disagreement: (%x) slow=%x fast=%x\n", a, c1, c2);
+        }
+    }
 }
 
 ////////////////////////////////////////////////////////////////////////////
@@ -128,16 +226,16 @@ void SkGraphics::Init(bool runUnitTests)
 
 void SkGraphics::Term()
 {
-       SkBitmapRef::PurgeCacheAll();
-       SkGraphics::FreeCaches(SK_MaxS32);
-       SkGlobals::Term();
+    SkBitmapRef::PurgeCacheAll();
+    SkGraphics::FreeCaches(SK_MaxS32);
+    SkGlobals::Term();
 }
 
 bool SkGraphics::FreeCaches(size_t bytesNeeded)
 {
-       bool didSomething = SkBitmapRef::PurgeCacheOne();
+    bool didSomething = SkBitmapRef::PurgeCacheOne();
 
-       return SkGlyphCache::FreeCache(bytesNeeded) || didSomething;
+    return SkGlyphCache::FreeCache(bytesNeeded) || didSomething;
 }
 
 
index a23b44e..0af75e6 100644 (file)
@@ -1,3 +1,20 @@
+/* libs/graphics/sgl/SkMaskFilter.cpp
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #include "SkMaskFilter.h"
 #include "SkBlitter.h"
 #include "SkBounder.h"
 
 size_t SkMask::computeImageSize() const
 {
-       return fBounds.height() * fRowBytes;
+    return fBounds.height() * fRowBytes;
 }
 
 size_t SkMask::computeTotalImageSize() const
 {
-       size_t size = this->computeImageSize();
+    size_t size = this->computeImageSize();
 
-       if (fFormat == SkMask::k3D_Format)
-               size *= 3;
-       return size;
+    if (fFormat == SkMask::k3D_Format)
+        size *= 3;
+    return size;
 }
 
 uint8_t* SkMask::AllocImage(size_t size)
 {
-       return (uint8_t*)sk_malloc_throw(SkAlign4(size));
+    return (uint8_t*)sk_malloc_throw(SkAlign4(size));
 }
 
 void SkMask::FreeImage(uint8_t* image)
 {
-       sk_free(image);
+    sk_free(image);
 }
 
 bool SkMaskFilter::filterMask(SkMask*, const SkMask&, const SkMatrix&, SkPoint16*)
 {
-       return false;
+    return false;
 }
 
 bool SkMaskFilter::filterPath(const SkPath& devPath, const SkMatrix& matrix,
-                                                         const SkRegion& clip, SkBounder* bounder,
-                                                         SkBlitter* blitter)
+                              const SkRegion& clip, SkBounder* bounder,
+                              SkBlitter* blitter)
 {
-       SkMask  srcM, dstM;
+    SkMask  srcM, dstM;
 
     if (!SkDraw::DrawToMask(devPath, &clip.getBounds(), this, &matrix, &srcM,
                             SkMask::kComputeBoundsAndRenderImage_CreateMode))
@@ -46,24 +63,24 @@ bool SkMaskFilter::filterPath(const SkPath& devPath, const SkMatrix& matrix,
         return false;
     }
 
-       SkAutoMaskImage autoSrc(&srcM, false);
+    SkAutoMaskImage autoSrc(&srcM, false);
 
-       if (!this->filterMask(&dstM, srcM, matrix, NULL))
-               return false;
+    if (!this->filterMask(&dstM, srcM, matrix, NULL))
+        return false;
 
-       SkAutoMaskImage                 autoDst(&dstM, false);
-       SkRegion::Cliperator    clipper(clip, dstM.fBounds);
+    SkAutoMaskImage         autoDst(&dstM, false);
+    SkRegion::Cliperator    clipper(clip, dstM.fBounds);
 
-       if (!clipper.done() && (bounder == NULL || bounder->doIRect(dstM.fBounds, clip)))
-       {
-               const SkRect16& cr = clipper.rect();
-               do {
-                       blitter->blitMask(dstM, cr);
-                       clipper.next();
-               } while (!clipper.done());
-       }
+    if (!clipper.done() && (bounder == NULL || bounder->doIRect(dstM.fBounds, clip)))
+    {
+        const SkRect16& cr = clipper.rect();
+        do {
+            blitter->blitMask(dstM, cr);
+            clipper.next();
+        } while (!clipper.done());
+    }
 
-       return true;
+    return true;
 }
 
 
index 2321684..4ff10f5 100644 (file)
@@ -1,3 +1,20 @@
+/* libs/graphics/sgl/SkPaint.cpp
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #include "SkPaint.h"
 #include "SkColorFilter.h"
 #include "SkFontHost.h"
 #include "SkShader.h"
 #include "SkScalerContext.h"
 #include "SkStroke.h"
-#include "SkTextLayout.h"
 #include "SkTypeface.h"
 #include "SkXfermode.h"
 
-#define SK_DefaultTextSize             SkIntToScalar(12)
+#define SK_DefaultTextSize      SkIntToScalar(12)
 
 SkPaint::SkPaint()
 {
-       fTypeface       = NULL;
-       fTextSize       = SK_DefaultTextSize;
-       fTextScaleX     = SK_Scalar1;
-       fTextSkewX      = 0;
+    fTypeface   = NULL;
+    fTextSize   = SK_DefaultTextSize;
+    fTextScaleX = SK_Scalar1;
+    fTextSkewX  = 0;
 
-       fPathEffect     = NULL;
-       fShader         = NULL;
-       fXfermode       = NULL;
-       fMaskFilter     = NULL;
+    fPathEffect = NULL;
+    fShader     = NULL;
+    fXfermode   = NULL;
+    fMaskFilter = NULL;
     fColorFilter = NULL;
-    fTextLayout = NULL;
     fRasterizer = NULL;
 
-       fColor          = SK_ColorBLACK;
-       fWidth          = 0;
-       fMiterLimit     = SK_DefaultMiterLimit;
-       fFlags          = 0;
-       fCapType        = kDefault_Cap;
-       fJoinType       = kDefault_Join;
-       fFilterType     = kNo_FilterType;
-       fTextAlign      = kLeft_Align;
-       fStyle          = kFill_Style;
+    fColor      = SK_ColorBLACK;
+    fWidth      = 0;
+    fMiterLimit = SK_DefaultMiterLimit;
+    fFlags      = 0;
+    fCapType    = kDefault_Cap;
+    fJoinType   = kDefault_Join;
+    fFilterType = kNo_FilterType;
+    fTextAlign  = kLeft_Align;
+    fStyle      = kFill_Style;
+    fTextEncoding = kUTF8_TextEncoding;
 }
 
 SkPaint::SkPaint(const SkPaint& src)
 {
-       memcpy(this, &src, sizeof(src));
+    memcpy(this, &src, sizeof(src));
 
-       fTypeface->safeRef();
-       fPathEffect->safeRef();
-       fShader->safeRef();
-       fXfermode->safeRef();
-       fMaskFilter->safeRef();
-       fColorFilter->safeRef();
-    fTextLayout->safeRef();
+    fTypeface->safeRef();
+    fPathEffect->safeRef();
+    fShader->safeRef();
+    fXfermode->safeRef();
+    fMaskFilter->safeRef();
+    fColorFilter->safeRef();
     fRasterizer->safeRef();
 }
 
 SkPaint::~SkPaint()
 {
-       fTypeface->safeUnref();
-       fPathEffect->safeUnref();
-       fShader->safeUnref();
-       fXfermode->safeUnref();
-       fMaskFilter->safeUnref();
-       fColorFilter->safeUnref();
-    fTextLayout->safeUnref();
+    fTypeface->safeUnref();
+    fPathEffect->safeUnref();
+    fShader->safeUnref();
+    fXfermode->safeUnref();
+    fMaskFilter->safeUnref();
+    fColorFilter->safeUnref();
     fRasterizer->safeUnref();
 }
 
 SkPaint& SkPaint::operator=(const SkPaint& src)
 {
-       SkASSERT(&src);
+    SkASSERT(&src);
 
-       src.fTypeface->safeRef();
-       src.fPathEffect->safeRef();
-       src.fShader->safeRef();
-       src.fXfermode->safeRef();
-       src.fMaskFilter->safeRef();
-       src.fColorFilter->safeRef();
-       src.fTextLayout->safeRef();
-       src.fRasterizer->safeRef();
+    src.fTypeface->safeRef();
+    src.fPathEffect->safeRef();
+    src.fShader->safeRef();
+    src.fXfermode->safeRef();
+    src.fMaskFilter->safeRef();
+    src.fColorFilter->safeRef();
+    src.fRasterizer->safeRef();
 
-       fTypeface->safeUnref();
-       fPathEffect->safeUnref();
-       fShader->safeUnref();
-       fXfermode->safeUnref();
-       fMaskFilter->safeUnref();
-       fColorFilter->safeUnref();
-       fTextLayout->safeUnref();
-       fRasterizer->safeUnref();
+    fTypeface->safeUnref();
+    fPathEffect->safeUnref();
+    fShader->safeUnref();
+    fXfermode->safeUnref();
+    fMaskFilter->safeUnref();
+    fColorFilter->safeUnref();
+    fRasterizer->safeUnref();
 
-       memcpy(this, &src, sizeof(src));
+    memcpy(this, &src, sizeof(src));
 
-       return *this;
+    return *this;
 }
 
 int operator==(const SkPaint& a, const SkPaint& b)
 {
-       return memcmp(&a, &b, sizeof(a)) == 0;
+    return memcmp(&a, &b, sizeof(a)) == 0;
 }
 
 void SkPaint::reset()
 {
-       SkPaint init;
+    SkPaint init;
 
-       *this = init;
+    *this = init;
 }
 
 void SkPaint::setFlags(U32 flags)
 {
-       fFlags = SkToU8(flags);
+    fFlags = SkToU8(flags);
 }
 
 void SkPaint::setAntiAliasOn(bool doAA)
 {
-       this->setFlags(SkSetClear32(fFlags, doAA, kAntiAlias_Shift));
+    this->setFlags(SkSetClear32(fFlags, doAA, kAntiAlias_Shift));
 }
 
 void SkPaint::setLinearTextOn(bool doLinearText)
 {
-       this->setFlags(SkSetClear32(fFlags, doLinearText, kLinearText_Shift));
+    this->setFlags(SkSetClear32(fFlags, doLinearText, kLinearText_Shift));
 }
 
 void SkPaint::setUnderlineTextOn(bool doUnderline)
 {
-       this->setFlags(SkSetClear32(fFlags, doUnderline, kUnderlineText_Shift));
+    this->setFlags(SkSetClear32(fFlags, doUnderline, kUnderlineText_Shift));
 }
 
 void SkPaint::setStrikeThruTextOn(bool doStrikeThru)
 {
-       this->setFlags(SkSetClear32(fFlags, doStrikeThru, kStrikeThruText_Shift));
+    this->setFlags(SkSetClear32(fFlags, doStrikeThru, kStrikeThruText_Shift));
 }
 
 void SkPaint::setFakeBoldTextOn(bool doFakeBold)
 {
-       this->setFlags(SkSetClear32(fFlags, doFakeBold, kFakeBoldText_Shift));
+    this->setFlags(SkSetClear32(fFlags, doFakeBold, kFakeBoldText_Shift));
 }
 
 void SkPaint::setStyle(Style style)
 {
-       SkASSERT((unsigned)style < kStyleCount);
-       fStyle = style;
+    SkASSERT((unsigned)style < kStyleCount);
+    fStyle = style;
 }
 
 void SkPaint::setColor(SkColor color)
 {
-       fColor = color;
+    fColor = color;
 }
 
 void SkPaint::setAlpha(U8CPU a)
 {
-       fColor = SkColorSetARGB(a, SkColorGetR(fColor), SkColorGetG(fColor), SkColorGetB(fColor));
+    fColor = SkColorSetARGB(a, SkColorGetR(fColor), SkColorGetG(fColor), SkColorGetB(fColor));
 }
 
 void SkPaint::setARGB(U8CPU a, U8CPU r, U8CPU g, U8CPU b)
 {
-       fColor = SkColorSetARGB(a, r, g, b);
+    fColor = SkColorSetARGB(a, r, g, b);
 }
 
 void SkPaint::setStrokeWidth(SkScalar width)
 {
-       SkASSERT(width >= 0);
-       fWidth = width;
+    SkASSERT(width >= 0);
+    fWidth = width;
 }
 
 void SkPaint::setStrokeMiter(SkScalar limit)
 {
-       SkASSERT(limit >= 0);
-       fMiterLimit = limit;
+    SkASSERT(limit >= 0);
+    fMiterLimit = limit;
 }
 
 void SkPaint::setStrokeCap(Cap ct)
 {
-       SkASSERT((unsigned)ct < kCapCount);
-       fCapType = SkToU8(ct);
+    SkASSERT((unsigned)ct < kCapCount);
+    fCapType = SkToU8(ct);
 }
 
 void SkPaint::setStrokeJoin(Join jt)
 {
-       SkASSERT((unsigned)jt < kJoinCount);
-       fJoinType = SkToU8(jt);
+    SkASSERT((unsigned)jt < kJoinCount);
+    fJoinType = SkToU8(jt);
 }
 
 void SkPaint::setFilterType(FilterType ft)
 {
-       SkASSERT((unsigned)ft < kFilterTypeCount);
-       fFilterType = SkToU8(ft);
+    SkASSERT((unsigned)ft < kFilterTypeCount);
+    fFilterType = SkToU8(ft);
 }
 
 //////////////////////////////////////////////////////////////////
 
 void SkPaint::setTextAlign(Align align)
 {
-       SkASSERT((unsigned)align < kAlignCount);
-       fTextAlign = SkToU8(align);
+    SkASSERT((unsigned)align < kAlignCount);
+    fTextAlign = SkToU8(align);
 }
 
 void SkPaint::setTextSize(SkScalar ts)
 {
-       SkASSERT(ts > 0);
-       fTextSize = ts;
+    SkASSERT(ts > 0);
+    fTextSize = ts;
 }
 
 void SkPaint::setTextScaleX(SkScalar scaleX)
 {
-       fTextScaleX = scaleX;
+    fTextScaleX = scaleX;
 }
 
 void SkPaint::setTextSkewX(SkScalar skewX)
 {
-       fTextSkewX = skewX;
+    fTextSkewX = skewX;
 }
 
-///////////////////////////////////////////////////////////////////////////////////////
-
-SkTextLayout* SkPaint::setTextLayout(SkTextLayout* layout)
+void SkPaint::setTextEncoding(TextEncoding encoding)
 {
-    SkRefCnt_SafeAssign(fTextLayout, layout);
-    return layout;
+    SkASSERT((unsigned)encoding <= kGlyphID_TextEncoding);
+    fTextEncoding = encoding;
 }
 
+///////////////////////////////////////////////////////////////////////////////////////
+
 SkTypeface* SkPaint::setTypeface(SkTypeface* font)
 {
-       SkRefCnt_SafeAssign(fTypeface, font);
-       return font;
+    SkRefCnt_SafeAssign(fTypeface, font);
+    return font;
 }
 
 SkRasterizer* SkPaint::setRasterizer(SkRasterizer* r)
@@ -234,179 +246,230 @@ SkRasterizer* SkPaint::setRasterizer(SkRasterizer* r)
 #include "SkGlyphCache.h"
 #include "SkUtils.h"
 
+int SkPaint::textToGlyphs(const void* textData, size_t byteLength, uint16_t glyphs[]) const
+{
+    if (byteLength == 0)
+        return 0;
+    
+    SkASSERT(textData != NULL);
+
+    if (NULL == glyphs)
+    {
+        switch (this->getTextEncoding()) {
+        case kUTF8_TextEncoding:
+            return SkUTF8_CountUnichars((const char*)textData, byteLength);
+        case kUTF16_TextEncoding:
+            return SkUTF16_CountUnichars((const uint16_t*)textData, byteLength >> 1);
+        case kGlyphID_TextEncoding:
+            return byteLength >> 1;
+        default:
+            SkASSERT(!"unknown text encoding");
+        }
+        return 0;
+    }
+    
+    // if we get here, we have a valid glyphs[] array, so time to fill it in
+    
+    if (this->getTextEncoding() == kGlyphID_TextEncoding)
+    {
+        // we want to ignore the low bit of byteLength
+        memcpy(glyphs, textData, byteLength >> 1 << 1);
+        return byteLength >> 1;
+    }
+    
+    SkAutoGlyphCache    autoCache(*this, NULL);
+    SkGlyphCache*       cache = autoCache.getCache();
+    SkGlyphCacheProc    glyphCacheProc = this->getGlyphCacheProc();
+    const char*         text = (const char*)textData;
+    const char*         stop = text + byteLength;
+    uint16_t*           gptr = glyphs;
+
+    while (text < stop)
+    {
+        *gptr++ = glyphCacheProc(cache, &text).f_GlyphID;
+    }
+    return gptr - glyphs;
+}
+
+static uint32_t sk_glyphID_walker(const char** text)
+{
+    const uint16_t* glyph = (const uint16_t*)text;
+    int32_t value = *glyph;
+    *text = (const char*)(glyph + 1);
+    return value;
+}
+
+static const SkGlyph& sk_getMetrics_utf8(SkGlyphCache* cache, const char** text)
+{
+    SkASSERT(cache != NULL);
+    SkASSERT(text != NULL);
+
+    return cache->getUnicharMetrics(SkUTF8_NextUnichar(text));
+}
+
+static const SkGlyph& sk_getMetrics_utf16(SkGlyphCache* cache, const char** text)
+{
+    SkASSERT(cache != NULL);
+    SkASSERT(text != NULL);
+
+    return cache->getUnicharMetrics(SkUTF16_NextUnichar((const uint16_t**)text));
+}
+
+static const SkGlyph& sk_getMetrics_glyph(SkGlyphCache* cache, const char** text)
+{
+    SkASSERT(cache != NULL);
+    SkASSERT(text != NULL);
+
+    unsigned glyphID = **(const uint16_t**)text;
+    *text += sizeof(uint16_t);
+    return cache->getGlyphIDMetrics(glyphID);
+}
+
+SkGlyphCacheProc SkPaint::getGlyphCacheProc() const
+{
+    static const SkGlyphCacheProc gGlyphCacheProcs[] = {
+        sk_getMetrics_utf8,
+        sk_getMetrics_utf16,
+        sk_getMetrics_glyph
+    };
+    
+    SkASSERT((unsigned)this->getTextEncoding() < SK_ARRAY_COUNT(gGlyphCacheProcs));
+    return gGlyphCacheProcs[this->getTextEncoding()];
+}
+
+/////////////////////////////////////////////////////////////////////////////////////////////////////////
+
 class SkAutoRestorePaintTextSizeAndFrame {
 public:
-       SkAutoRestorePaintTextSizeAndFrame(const SkPaint* paint) : fPaint((SkPaint*)paint)
-       {
-               fTextSize = paint->getTextSize();
-               fStyle = paint->getStyle();
-               fPaint->setStyle(SkPaint::kFill_Style);
-       }
-       ~SkAutoRestorePaintTextSizeAndFrame()
-       {
-               fPaint->setStyle(fStyle);
-               fPaint->setTextSize(fTextSize);
-       }
+    SkAutoRestorePaintTextSizeAndFrame(const SkPaint* paint) : fPaint((SkPaint*)paint)
+    {
+        fTextSize = paint->getTextSize();
+        fStyle = paint->getStyle();
+        fPaint->setStyle(SkPaint::kFill_Style);
+    }
+    ~SkAutoRestorePaintTextSizeAndFrame()
+    {
+        fPaint->setStyle(fStyle);
+        fPaint->setTextSize(fTextSize);
+    }
     
 private:
-       SkPaint*                fPaint;
-       SkScalar                fTextSize;
-       SkPaint::Style  fStyle;
+    SkPaint*        fPaint;
+    SkScalar        fTextSize;
+    SkPaint::Style  fStyle;
 };
 
-static SkScalar measure_text(const SkPaint& paint, SkGlyphCache* cache,
-                             SkUnicodeWalkerProc proc, const char* text, size_t byteLength,
-                             int* count)
+SkScalar SkPaint::measure_text(SkGlyphCache* cache,
+                               const char* text, size_t byteLength,
+                               int* count) const
 {
-       SkASSERT(count);
+    SkASSERT(count);
 
-       SkFixed         x = 0;
-       int             n;
-    SkTextLayout*   layout = paint.getTextLayout();
-    
-    if (layout)
+    SkGlyphCacheProc glyphCacheProc = this->getGlyphCacheProc();
+
+    SkFixed     x = 0;
+    int         n;
+    const char* stop = (const char*)text + byteLength;
+
+    for (n = 0; text < stop; n++)
     {
-        SkAutoSTMalloc<32, SkTextLayout::Rec>   storage(byteLength);
-        SkTextLayout::Rec*                      rec = storage.get();
+        x += glyphCacheProc(cache, &text).fAdvanceX;
+    }
+    SkASSERT(text == stop);
 
-        n = layout->layout(paint, text, byteLength, proc, rec);
-        for (int i = 0; i < n; i++)
-        {
-            // should pass rec[i].glyphID when we have it
-            x += cache->getMetrics(rec[i].charCode()).fAdvanceX + SkScalarToFixed(rec[i].fDeltaAdvance);
-        }
+    *count = n;
+    return SkFixedToScalar(x);
+}
+
+SkScalar SkPaint::measureText(const void* textData, size_t length,
+                              SkScalar* above, SkScalar* below) const
+{
+    const char* text = (const char*)textData;
+    SkASSERT(text != NULL || length == 0);
+
+    SkScalar                            scale = 0;
+    SkAutoRestorePaintTextSizeAndFrame  restore(this);
+
+    if (this->isLinearTextOn())
+    {
+        scale = fTextSize / kCanonicalTextSizeForPaths;
+        // this gets restored by restore
+        ((SkPaint*)this)->setTextSize(SkIntToScalar(kCanonicalTextSizeForPaths));
     }
-    else
+
+    SkAutoGlyphCache    autoCache(*this, NULL);
+    SkGlyphCache*       cache = autoCache.getCache();
+
+    if (above || below)
     {
-        const char*    stop = (const char*)text + byteLength;
-        for (n = 0; text < stop; n++)
+        SkPoint abovePt, belowPt;
+        cache->getLineHeight(&abovePt, &belowPt);
+        if (scale)
         {
-            x += cache->getMetrics(proc(&text)).fAdvanceX;
+            abovePt.fY = SkScalarMul(abovePt.fY, scale);
+            belowPt.fY = SkScalarMul(belowPt.fY, scale);
         }
-        SkASSERT(text == stop);
+        if (above)
+            *above = abovePt.fY;
+        if (below)
+            *below = belowPt.fY;
     }
-       *count = n;
-       return SkFixedToScalar(x);
-}
-
-SkScalar SkPaint::privateMeasureText(SkUnicodeWalkerProc textProc,
-                                     const char* text, size_t byteLength,
-                                     SkScalar* above, SkScalar* below) const
-{
-       SkASSERT(text != NULL || byteLength == 0);
-
-       SkScalar                            scale = 0;
-    SkAutoRestorePaintTextSizeAndFrame restore(this);
-
-       if (this->isLinearTextOn())
-       {
-               scale = fTextSize / kCanonicalTextSizeForPaths;
-               // this gets restored by restore
-               ((SkPaint*)this)->setTextSize(SkIntToScalar(kCanonicalTextSizeForPaths));
-       }
-
-       SkAutoGlyphCache        autoCache(*this, NULL);
-       SkGlyphCache*           cache = autoCache.getCache();
-
-       if (above || below)
-       {
-               SkPoint abovePt, belowPt;
-               cache->getLineHeight(&abovePt, &belowPt);
-               if (scale)
-               {
-                       abovePt.fY = SkScalarMul(abovePt.fY, scale);
-                       belowPt.fY = SkScalarMul(belowPt.fY, scale);
-               }
-               if (above)
-                       *above = abovePt.fY;
-               if (below)
-                       *below = belowPt.fY;
-       }
     
     SkScalar width = 0;
     
-    if (byteLength)
+    if (length > 0)
     {
         int count;
-        width = measure_text(*this, cache, textProc, text, byteLength, &count);
 
+        width = this->measure_text(cache, text, length, &count);
         if (scale)
             width = SkScalarMul(width, scale);
     }
     return width;
 }
 
-SkScalar SkPaint::measureText(const char utf8[], size_t length,
-                                                         SkScalar* above, SkScalar* below) const
-{
-    return this->privateMeasureText((SkUnicodeWalkerProc)SkUTF8_NextUnichar, utf8, length, above, below);
-}
+////////////////////////////////////////////////////////////////////////////////////////////
 
-SkScalar SkPaint::measureText16(const U16 utf16[], size_t numberOf16BitValues,
-                                                         SkScalar* above, SkScalar* below) const
+int SkPaint::getTextWidths(const void* textData, size_t byteLength, SkScalar widths[]) const
 {
-    return this->privateMeasureText((SkUnicodeWalkerProc)SkUTF16_NextUnichar, (const char*)utf16, numberOf16BitValues << 1, above, below);
-}
+    if (0 == byteLength)
+        return 0;
 
-////////////////////////////////////////////////////////////////////////////////////////////
+    SkASSERT(NULL != textData);
 
-int SkPaint::privateGetTextWidths(const char text[], size_t byteLength,
-                                  SkScalar widths[], SkUnicodeWalkerProc proc) const
-{
-       SkASSERT(text != NULL && byteLength > 0);
+    if (NULL == widths)
+        return this->countText(textData, byteLength);
 
-       SkAutoRestorePaintTextSizeAndFrame      restore(this);
-       SkScalar                                                        scale = 0;
+    SkAutoRestorePaintTextSizeAndFrame  restore(this);
+    SkScalar                            scale = 0;
 
-       if (this->isLinearTextOn())
-       {
-               scale = fTextSize / kCanonicalTextSizeForPaths;
-               // this gets restored by restore
-               ((SkPaint*)this)->setTextSize(SkIntToScalar(kCanonicalTextSizeForPaths));
-       }
+    if (this->isLinearTextOn())
+    {
+        scale = fTextSize / kCanonicalTextSizeForPaths;
+        // this gets restored by restore
+        ((SkPaint*)this)->setTextSize(SkIntToScalar(kCanonicalTextSizeForPaths));
+    }
 
-       SkAutoGlyphCache        autoCache(*this, NULL);
-       SkGlyphCache*           cache = autoCache.getCache();
+    SkAutoGlyphCache    autoCache(*this, NULL);
+    SkGlyphCache*       cache = autoCache.getCache();
+    SkGlyphCacheProc    glyphCacheProc = this->getGlyphCacheProc();
 
     SkScalar*   w = widths;
-       const char*     stop = (const char*)text + byteLength;
+    const char* text = (const char*)textData;
+    const char* stop = text + byteLength;
+
     if (scale) {
         while (text < stop)
-            *w++ = SkScalarMul(SkFixedToScalar(cache->getMetrics(proc(&text)).fAdvanceX), scale);
+            *w++ = SkScalarMul(SkFixedToScalar(glyphCacheProc(cache, &text).fAdvanceX), scale);
     }
     else {
         while (text < stop)
-            *w++ = SkFixedToScalar(cache->getMetrics(proc(&text)).fAdvanceX);
+            *w++ = SkFixedToScalar(glyphCacheProc(cache, &text).fAdvanceX);
     }
+    SkASSERT(text == stop);
     return w - widths;  // count
 }
 
-int SkPaint::getTextWidths(const char text[], size_t byteLength, SkScalar widths[]) const
-{
-    if (0 == byteLength)
-        return 0;
-    
-    if (NULL == widths)
-        return SkUTF8_CountUnichars(text, byteLength);
-    
-    int count = this->privateGetTextWidths(text, byteLength, widths, (SkUnicodeWalkerProc)SkUTF8_NextUnichar);
-    SkASSERT(SkUTF8_CountUnichars(text, byteLength) == count);
-    return count;
-}
-
-int SkPaint::getTextWidths16(const uint16_t text[], size_t numberOf16BitValues, SkScalar widths[]) const
-{
-    if (0 == numberOf16BitValues)
-        return 0;
-    
-    if (NULL == widths)
-        return SkUTF16_CountUnichars(text, numberOf16BitValues);
-    
-    int count = this->privateGetTextWidths((const char*)text, numberOf16BitValues << 1, widths, (SkUnicodeWalkerProc)SkUTF16_NextUnichar);
-    SkASSERT(SkUTF16_CountUnichars(text, numberOf16BitValues) == count);
-    return count;
-}
-
 ////////////////////////////////////////////////////////////////////////////////////////////
 
 SkScalar SkPaint::ascent() const
@@ -425,47 +488,37 @@ SkScalar SkPaint::descent() const
 
 #include "SkDraw.h"
 
-void SkPaint::privateGetTextPath(SkUnicodeWalkerProc textProc, const char text[], size_t length, SkScalar x, SkScalar y, SkPath* path) const
+void SkPaint::getTextPath(const void* textData, size_t length, SkScalar x, SkScalar y, SkPath* path) const
 {
-       SkASSERT(length == 0 || text != NULL);
-       if (text == NULL || length == 0 || path == NULL)
-               return;
-    SkASSERT(textProc);
+    const char* text = (const char*)textData;
+    SkASSERT(length == 0 || text != NULL);
+    if (text == NULL || length == 0 || path == NULL)
+        return;
 
-       SkTextToPathIter        iter(textProc, text, length, *this, false, true);
-       SkMatrix                        matrix;
-       SkScalar                        prevXPos = 0;
+    SkTextToPathIter    iter(text, length, *this, false, true);
+    SkMatrix            matrix;
+    SkScalar            prevXPos = 0;
 
-       matrix.setScale(iter.getPathScale(), iter.getPathScale(), 0, 0);
-       matrix.postTranslate(x, y);
-       path->reset();
+    matrix.setScale(iter.getPathScale(), iter.getPathScale());
+    matrix.postTranslate(x, y);
+    path->reset();
 
-       SkScalar                xpos;
-       const SkPath*   iterPath;
-       while ((iterPath = iter.next(&xpos)) != NULL)
-       {
-               matrix.postTranslate(xpos - prevXPos, 0);
-               path->addPath(*iterPath, matrix);
-               prevXPos = xpos;
-       }
-}
-
-void SkPaint::getTextPath(const char text[], size_t length, SkScalar x, SkScalar y, SkPath* path) const
-{
-    this->privateGetTextPath((SkUnicodeWalkerProc)SkUTF8_NextUnichar, text, length, x, y, path);
-}
-
-void SkPaint::getText16Path(const U16 text[], size_t numberOf16BitValues, SkScalar x, SkScalar y, SkPath* path) const
-{
-    this->privateGetTextPath((SkUnicodeWalkerProc)SkUTF16_NextUnichar, (const char*)text, numberOf16BitValues << 1, x, y, path);
+    SkScalar        xpos;
+    const SkPath*   iterPath;
+    while ((iterPath = iter.next(&xpos)) != NULL)
+    {
+        matrix.postTranslate(xpos - prevXPos, 0);
+        path->addPath(*iterPath, matrix);
+        prevXPos = xpos;
+    }
 }
 
 static void add_flattenable(SkDescriptor* desc, U32 tag, U32 len, SkFlattenable* obj)
 {
-       SkFlattenable::Factory fact = obj->getFactory();
-       SkASSERT(fact);
+    SkFlattenable::Factory fact = obj->getFactory();
+    SkASSERT(fact);
 
-       SkWBuffer   buffer(desc->addEntry(tag, sizeof(void*) + len, NULL), sizeof(void*) + len);
+    SkWBuffer   buffer(desc->addEntry(tag, sizeof(void*) + len, NULL), sizeof(void*) + len);
  
     buffer.writePtr((const void*)fact);
     obj->flatten(buffer);
@@ -477,9 +530,9 @@ static void add_flattenable(SkDescriptor* desc, U32 tag, U32 len, SkFlattenable*
     inspired by a desire to change the multiplier for thickness in fakebold
     therefore, i assumed number of pairs (length) will be small, so a linear search is sufficient
     repeated keys are allowed for discontinuous functions (so long as keys is monotonically increasing), and if 
-       key is the value of a repeated scalar in keys, the first one will be used 
-       - this may change if a binary search is used
-       - also, this ensures that there is no divide by zero (an assert also checks for that)
+        key is the value of a repeated scalar in keys, the first one will be used 
+    - this may change if a binary search is used
+    - also, this ensures that there is no divide by zero (an assert also checks for that)
 */
 static SkScalar interpolate(SkScalar key, const SkScalar keys[], const SkScalar values[], int length)
 {
@@ -515,26 +568,46 @@ static SkScalar interpolate(SkScalar key, const SkScalar keys[], const SkScalar
 static const SkScalar pointSizes[] = { SkIntToScalar(9), SkIntToScalar(36) };
 static const SkScalar multipliers[] = { SK_Scalar1/24, SK_Scalar1/32 };
 
+static SkMask::Format computeMaskFormat(const SkPaint& paint)
+{
+    uint32_t flags = paint.getFlags();
+    
+    if (flags & SkPaint::kLCDText_Flag)
+        return SkMask::kLCD_Format;
+    
+    return (flags & SkPaint::kAntiAlias_Flag) ? SkMask::kA8_Format : SkMask::kBW_Format;
+}
+
+static SkScalerContext::Hints computeScalerHints(const SkPaint& paint)
+{
+    uint32_t flags = paint.getFlags();
+    
+    if (flags & SkPaint::kLinearText_Flag)
+        return SkScalerContext::kNo_Hints;
+    
+    return (flags & SkPaint::kNativeHintsText_Flag) ? SkScalerContext::kNative_Hints : SkScalerContext::kAuto_Hints;
+}
+
 void SkScalerContext::MakeRec(const SkPaint& paint, const SkMatrix* deviceMatrix, Rec* rec)
 {
-       SkASSERT(deviceMatrix == NULL || (deviceMatrix->getType() & SkMatrix::kPerspective_Mask) == 0);
-
-       rec->fTextSize = paint.getTextSize();
-       rec->fPreScaleX = paint.getTextScaleX();
-       rec->fPreSkewX  = paint.getTextSkewX();
-
-       if (deviceMatrix)
-       {
-               rec->fPost2x2[0][0] = deviceMatrix->getScaleX();
-               rec->fPost2x2[0][1] = deviceMatrix->getSkewX();
-               rec->fPost2x2[1][0] = deviceMatrix->getSkewY();
-               rec->fPost2x2[1][1] = deviceMatrix->getScaleY();
-       }
-       else
-       {
-               rec->fPost2x2[0][0] = rec->fPost2x2[1][1] = SK_Scalar1;
-               rec->fPost2x2[0][1] = rec->fPost2x2[1][0] = 0;
-       }
+    SkASSERT(deviceMatrix == NULL || (deviceMatrix->getType() & SkMatrix::kPerspective_Mask) == 0);
+
+    rec->fTextSize = paint.getTextSize();
+    rec->fPreScaleX = paint.getTextScaleX();
+    rec->fPreSkewX  = paint.getTextSkewX();
+
+    if (deviceMatrix)
+    {
+        rec->fPost2x2[0][0] = deviceMatrix->getScaleX();
+        rec->fPost2x2[0][1] = deviceMatrix->getSkewX();
+        rec->fPost2x2[1][0] = deviceMatrix->getSkewY();
+        rec->fPost2x2[1][1] = deviceMatrix->getScaleY();
+    }
+    else
+    {
+        rec->fPost2x2[0][0] = rec->fPost2x2[1][1] = SK_Scalar1;
+        rec->fPost2x2[0][1] = rec->fPost2x2[1][0] = 0;
+    }
     
     SkPaint::Style  style = paint.getStyle();
     SkScalar        strokeWidth = paint.getStrokeWidth();
@@ -553,152 +626,153 @@ void SkScalerContext::MakeRec(const SkPaint& paint, const SkMatrix* deviceMatrix
             strokeWidth += extra;
     }
 
-       if (style != SkPaint::kFill_Style && strokeWidth > 0)
-       {
-               rec->fFrameWidth = strokeWidth;
-               rec->fMiterLimit = paint.getStrokeMiter();
-               rec->fFrameAndFill = SkToU8(style == SkPaint::kStrokeAndFill_Style);
-               rec->fStrokeJoin = SkToU8(paint.getStrokeJoin());
-       }
-       else
-       {
-               rec->fFrameWidth = 0;
-               rec->fMiterLimit = 0;
-               rec->fFrameAndFill = false;
-               rec->fStrokeJoin = 0;
-       }
-
-       rec->fUseHints = SkToU8(!paint.isLinearTextOn());
-       rec->fDoAA = SkToU8(paint.isAntiAliasOn());
+    if (style != SkPaint::kFill_Style && strokeWidth > 0)
+    {
+        rec->fFrameWidth = strokeWidth;
+        rec->fMiterLimit = paint.getStrokeMiter();
+        rec->fFrameAndFill = SkToU8(style == SkPaint::kStrokeAndFill_Style);
+        rec->fStrokeJoin = SkToU8(paint.getStrokeJoin());
+    }
+    else
+    {
+        rec->fFrameWidth = 0;
+        rec->fMiterLimit = 0;
+        rec->fFrameAndFill = false;
+        rec->fStrokeJoin = 0;
+    }
+
+    rec->fHints = SkToU8(computeScalerHints(paint));
+    rec->fMaskFormat = SkToU8(computeMaskFormat(paint));
 }
 
 SkGlyphCache* SkPaint::detachCache(const SkMatrix* deviceMatrix) const
 {
-       SkScalerContext::Rec    rec;
+    SkScalerContext::Rec    rec;
 
-       SkScalerContext::MakeRec(*this, deviceMatrix, &rec);
+    SkScalerContext::MakeRec(*this, deviceMatrix, &rec);
 
-       size_t                  descSize = sizeof(rec);
-       int                             entryCount = 2; // scalerrec + typeface
-       SkTypeface*             tf = this->getTypeface();
-       size_t                  tfSize = 0;
-       SkPathEffect*   pe = this->getPathEffect();
-       size_t                  peLen = 0;
-       SkMaskFilter*   mf = this->getMaskFilter();
-       size_t                  mfLen = 0;
-       SkRasterizer*   ra = this->getRasterizer();
-       size_t                  raLen = 0;
+    size_t          descSize = sizeof(rec);
+    int             entryCount = 2; // scalerrec + typeface
+    SkTypeface*     tf = this->getTypeface();
+    size_t          tfSize = 0;
+    SkPathEffect*   pe = this->getPathEffect();
+    size_t          peLen = 0;
+    SkMaskFilter*   mf = this->getMaskFilter();
+    size_t          mfLen = 0;
+    SkRasterizer*   ra = this->getRasterizer();
+    size_t          raLen = 0;
 
     // we always do this, even if tf is NULL
     tfSize = SkFontHost::FlattenTypeface(tf, NULL);
     descSize += tfSize;
 
-       if (pe)
-       {
-               if (pe->getFactory())
-               {
+    if (pe)
+    {
+        if (pe->getFactory())
+        {
             SkWBuffer   buffer;
-                       pe->flatten(buffer);
+            pe->flatten(buffer);
             peLen = buffer.pos();
-                       descSize += sizeof(SkFlattenable::Factory) + peLen;
-                       entryCount += 1;
-                       rec.fDoAA = true;       // force antialiasing when we do the scan conversion
-               }
-               else
-                       pe = NULL;
-       }
-       if (mf)
-       {
-               if (mf->getFactory())
-               {
+            descSize += sizeof(SkFlattenable::Factory) + peLen;
+            entryCount += 1;
+            rec.fMaskFormat = SkMask::kA8_Format;   // force antialiasing when we do the scan conversion
+            // seems like we could support kLCD as well at this point <reed>...
+        }
+        else
+            pe = NULL;
+    }
+    if (mf)
+    {
+        if (mf->getFactory())
+        {
             SkWBuffer   buffer;
             mf->flatten(buffer);
-                       mfLen = buffer.pos();
-                       descSize += sizeof(SkFlattenable::Factory) + mfLen;
-                       entryCount += 1;
-                       rec.fDoAA = true;       // force antialiasing with maskfilters
-               }
-               else
-                       mf = NULL;
-       }
-       if (ra)
-       {
-               if (ra->getFactory())
-               {
+            mfLen = buffer.pos();
+            descSize += sizeof(SkFlattenable::Factory) + mfLen;
+            entryCount += 1;
+            rec.fMaskFormat = SkMask::kA8_Format;   // force antialiasing with maskfilters
+        }
+        else
+            mf = NULL;
+    }
+    if (ra)
+    {
+        if (ra->getFactory())
+        {
             SkWBuffer   buffer;
             ra->flatten(buffer);
-                       raLen = buffer.pos();
-                       descSize += sizeof(SkFlattenable::Factory) + raLen;
-                       entryCount += 1;
-                       rec.fDoAA = true;       // force antialiasing when we do the scan conversion
-               }
-               else
-                       ra = NULL;
-       }
-       descSize += SkDescriptor::ComputeOverhead(entryCount);
-
-       SkAutoDescriptor        ad(descSize);
-       SkDescriptor*           desc = ad.getDesc();
-
-       desc->init();
-       desc->addEntry(kRec_SkDescriptorTag, sizeof(rec), &rec);
+            raLen = buffer.pos();
+            descSize += sizeof(SkFlattenable::Factory) + raLen;
+            entryCount += 1;
+            rec.fMaskFormat = SkMask::kA8_Format;   // force antialiasing when we do the scan conversion
+        }
+        else
+            ra = NULL;
+    }
+    descSize += SkDescriptor::ComputeOverhead(entryCount);
+
+    SkAutoDescriptor    ad(descSize);
+    SkDescriptor*       desc = ad.getDesc();
+
+    desc->init();
+    desc->addEntry(kRec_SkDescriptorTag, sizeof(rec), &rec);
 
     // we always do this, even if tf is NULL
     {
         SkDEBUGCODE(size_t tfSize2 = ) SkFontHost::FlattenTypeface(tf, desc->addEntry(kTypeface_SkDescriptorTag, tfSize, NULL));
-               SkASSERT(tfSize2 == tfSize);
-       }
+        SkASSERT(tfSize2 == tfSize);
+    }
 
-       if (pe)
-               add_flattenable(desc, kPathEffect_SkDescriptorTag, peLen, pe);
-       if (mf)
-               add_flattenable(desc, kMaskFilter_SkDescriptorTag, mfLen, mf);
-       if (ra)
-               add_flattenable(desc, kRasterizer_SkDescriptorTag, raLen, ra);
+    if (pe)
+        add_flattenable(desc, kPathEffect_SkDescriptorTag, peLen, pe);
+    if (mf)
+        add_flattenable(desc, kMaskFilter_SkDescriptorTag, mfLen, mf);
+    if (ra)
+        add_flattenable(desc, kRasterizer_SkDescriptorTag, raLen, ra);
 
-       SkASSERT(descSize == desc->getLength());
-       desc->computeChecksum();
+    SkASSERT(descSize == desc->getLength());
+    desc->computeChecksum();
 
-       return SkGlyphCache::DetachCache(desc);
+    return SkGlyphCache::DetachCache(desc);
 }
 
 //////////////////////////////////////////////////////////////////
 
 SkShader* SkPaint::setShader(SkShader* shader)
 {
-       SkRefCnt_SafeAssign(fShader, shader);
-       return shader;
+    SkRefCnt_SafeAssign(fShader, shader);
+    return shader;
 }
 
 SkColorFilter* SkPaint::setColorFilter(SkColorFilter* filter)
 {
-       SkRefCnt_SafeAssign(fColorFilter, filter);
-       return filter;
+    SkRefCnt_SafeAssign(fColorFilter, filter);
+    return filter;
 }
 
 SkXfermode* SkPaint::setXfermode(SkXfermode* mode)
 {
-       SkRefCnt_SafeAssign(fXfermode, mode);
-       return mode;
+    SkRefCnt_SafeAssign(fXfermode, mode);
+    return mode;
 }
 
 SkXfermode* SkPaint::setPorterDuffXfermode(SkPorterDuff::Mode mode)
 {
     fXfermode->safeUnref();
     fXfermode = SkPorterDuff::CreateXfermode(mode);
-       return fXfermode;
+    return fXfermode;
 }
 
 SkPathEffect* SkPaint::setPathEffect(SkPathEffect* effect)
 {
-       SkRefCnt_SafeAssign(fPathEffect, effect);
-       return effect;
+    SkRefCnt_SafeAssign(fPathEffect, effect);
+    return effect;
 }
 
 SkMaskFilter* SkPaint::setMaskFilter(SkMaskFilter* filter)
 {
-       SkRefCnt_SafeAssign(fMaskFilter, filter);
-       return filter;
+    SkRefCnt_SafeAssign(fMaskFilter, filter);
+    return filter;
 }
 
 ////////////////////////////////////////////////////////////////////////////////////////
@@ -708,7 +782,7 @@ bool SkPaint::getFillPath(const SkPath& src, SkPath* dst) const
     SkPath          effectPath, strokePath;
     const SkPath*   path = &src;
 
-       SkScalar width = this->getStrokeWidth();
+    SkScalar width = this->getStrokeWidth();
     
     switch (this->getStyle()) {
     case SkPaint::kFill_Style:
@@ -724,14 +798,14 @@ bool SkPaint::getFillPath(const SkPath& src, SkPath* dst) const
         SkASSERT(!"unknown paint style");
     }
 
-       if (this->getPathEffect())
-       {
+    if (this->getPathEffect())
+    {
         // lie to the pathEffect if our style is strokeandfill, so that it treats us as just fill
         if (this->getStyle() == SkPaint::kStrokeAndFill_Style)
             width = -1; // mark it as no-stroke
 
-               if (this->getPathEffect()->filterPath(&effectPath, src, &width))
-                       path = &effectPath;
+        if (this->getPathEffect()->filterPath(&effectPath, src, &width))
+            path = &effectPath;
         
         // restore the width if we earlier had to lie, and if we're still set to no-stroke
         // note: if we're now stroke (width >= 0), then the pathEffect asked for that change
@@ -742,14 +816,14 @@ bool SkPaint::getFillPath(const SkPath& src, SkPath* dst) const
             if (width == 0)
                 width = -1;
         }
-       }
+    }
     
     if (width > 0 && !path->isEmpty())
     {
-               SkStroke stroker(*this, width);
-               stroker.strokePath(*path, &strokePath);
+        SkStroke stroker(*this, width);
+        stroker.strokePath(*path, &strokePath);
         path = &strokePath;
-       }
+    }
 
     if (path == &src)
         *dst = src;
@@ -766,103 +840,104 @@ bool SkPaint::getFillPath(const SkPath& src, SkPath* dst) const
 
 static bool has_thick_frame(const SkPaint& paint)
 {
-       return paint.getStrokeWidth() > 0 && paint.getStyle() != SkPaint::kFill_Style;
+    return paint.getStrokeWidth() > 0 && paint.getStyle() != SkPaint::kFill_Style;
 }
 
-SkTextToPathIter::SkTextToPathIter( SkUnicodeWalkerProc textProc,
-                                    const char text[], size_t length,
+SkTextToPathIter::SkTextToPathIter( const char text[], size_t length,
                                     const SkPaint& paint,
                                     bool applyStrokeAndPathEffects,
                                     bool forceLinearTextOn)
-                                    : fPaint(paint), fTextProc(textProc)
-{
-       if (forceLinearTextOn)
-               fPaint.setLinearTextOn(true);
-       fPaint.setMaskFilter(NULL);   // don't want this affecting our path-cache lookup
-
-       if (fPaint.getPathEffect() == NULL && !has_thick_frame(fPaint))
-               applyStrokeAndPathEffects = false;
-
-       // can't use our canonical size if we need to apply patheffects/strokes
-       if (fPaint.isLinearTextOn() && !applyStrokeAndPathEffects)
-       {
-               fPaint.setTextSize(SkIntToScalar(SkPaint::kCanonicalTextSizeForPaths));
-               fScale = paint.getTextSize() / SkPaint::kCanonicalTextSizeForPaths;
-       }
-       else
-               fScale = SK_Scalar1;
-       
-       if (!applyStrokeAndPathEffects)
-       {
-               fPaint.setStyle(SkPaint::kFill_Style);
-               fPaint.setPathEffect(NULL);
-       }
-
-       fCache = SkGlyphCache::DetachCache(fPaint, NULL);
-
-       SkPaint::Style  style = SkPaint::kFill_Style;
-       SkPathEffect*   pe = NULL;
-
-       if (!applyStrokeAndPathEffects)
-       {
-               style = paint.getStyle();       // restore
-               pe = paint.getPathEffect();             // restore
-       }
-       fPaint.setStyle(style);
-       fPaint.setPathEffect(pe);
-       fPaint.setMaskFilter(paint.getMaskFilter());    // restore
-
-       // now compute fXOffset if needed
-
-       SkScalar xOffset = 0;
-       if (paint.getTextAlign() != SkPaint::kLeft_Align)       // need to measure first
-       {
-               int              count;
-               SkScalar width = SkScalarMul(measure_text(paint, fCache, textProc, text, length, &count), fScale);
-               if (paint.getTextAlign() == SkPaint::kCenter_Align)
-                       width = SkScalarHalf(width);
-               xOffset = -width;
-       }
-       fXPos = xOffset; // + SkScalarHalf(paint.getTextTracking()); do we need to return the textlayout's first deltaAdvance?
-       fPrevAdvance = 0;
-
-       fText = text;
-       fStop = text + length;
+                                    : fPaint(paint) /* make a copy of the paint */
+{
+    fGlyphCacheProc = paint.getGlyphCacheProc();
+
+    if (forceLinearTextOn)
+        fPaint.setLinearTextOn(true);
+    fPaint.setMaskFilter(NULL);   // don't want this affecting our path-cache lookup
+
+    if (fPaint.getPathEffect() == NULL && !has_thick_frame(fPaint))
+        applyStrokeAndPathEffects = false;
+
+    // can't use our canonical size if we need to apply patheffects/strokes
+    if (fPaint.isLinearTextOn() && !applyStrokeAndPathEffects)
+    {
+        fPaint.setTextSize(SkIntToScalar(SkPaint::kCanonicalTextSizeForPaths));
+        fScale = paint.getTextSize() / SkPaint::kCanonicalTextSizeForPaths;
+    }
+    else
+        fScale = SK_Scalar1;
+    
+    if (!applyStrokeAndPathEffects)
+    {
+        fPaint.setStyle(SkPaint::kFill_Style);
+        fPaint.setPathEffect(NULL);
+    }
+
+    fCache = SkGlyphCache::DetachCache(fPaint, NULL);
+
+    SkPaint::Style  style = SkPaint::kFill_Style;
+    SkPathEffect*   pe = NULL;
+
+    if (!applyStrokeAndPathEffects)
+    {
+        style = paint.getStyle();   // restore
+        pe = paint.getPathEffect();     // restore
+    }
+    fPaint.setStyle(style);
+    fPaint.setPathEffect(pe);
+    fPaint.setMaskFilter(paint.getMaskFilter());    // restore
+
+    // now compute fXOffset if needed
+
+    SkScalar xOffset = 0;
+    if (paint.getTextAlign() != SkPaint::kLeft_Align)   // need to measure first
+    {
+        int      count;
+        SkScalar width = SkScalarMul(fPaint.measure_text(fCache, text, length, &count), fScale);
+        if (paint.getTextAlign() == SkPaint::kCenter_Align)
+            width = SkScalarHalf(width);
+        xOffset = -width;
+    }
+    fXPos = xOffset;
+    fPrevAdvance = 0;
+
+    fText = text;
+    fStop = text + length;
 }
 
 SkTextToPathIter::~SkTextToPathIter()
 {
-       SkGlyphCache::AttachCache(fCache);
+    SkGlyphCache::AttachCache(fCache);
 }
 
 const SkPath* SkTextToPathIter::next(SkScalar* xpos)
 {
-       while (fText < fStop)
-       {
-               const SkGlyph& glyph = fCache->getMetrics(fTextProc(&fText));
+    while (fText < fStop)
+    {
+        const SkGlyph& glyph = fGlyphCacheProc(fCache, &fText);
 
-               fXPos += fPrevAdvance;
-               fPrevAdvance = SkScalarMul(SkFixedToScalar(glyph.fAdvanceX), fScale);   // + fPaint.getTextTracking();
+        fXPos += fPrevAdvance;
+        fPrevAdvance = SkScalarMul(SkFixedToScalar(glyph.fAdvanceX), fScale);   // + fPaint.getTextTracking();
 
-               if (glyph.fWidth)
-               {
-                       if (xpos)
-                               *xpos = fXPos;
-                       return fCache->findPath(glyph.fCharCode);
-               }
-       }
-       return NULL;
+        if (glyph.fWidth)
+        {
+            if (xpos)
+                *xpos = fXPos;
+            return fCache->findPath(glyph);
+        }
+    }
+    return NULL;
 }
 
 /////////////////////////////////////////////////////////////////////////////////////////////////////
 
 SkTypeface* SkTypeface::Create(const char name[], Style style)
 {
-       return SkFontHost::CreateTypeface(NULL, name, style);
+    return SkFontHost::CreateTypeface(NULL, name, style);
 }
 
 SkTypeface* SkTypeface::CreateFromTypeface(const SkTypeface* family, Style style)
 {
-       return SkFontHost::CreateTypeface(family, NULL, style);
+    return SkFontHost::CreateTypeface(family, NULL, style);
 }
 
index 18e4fb8..cf18a01 100644 (file)
@@ -1,15 +1,32 @@
+/* libs/graphics/sgl/SkPath.cpp
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #include "SkPath.h"
 #include "SkMath.h"
 
 /*
-       Stores the verbs and points as they are given to us, with exceptions:
-       - we only record "Close" if it was immediately preceeded by Line | Quad | Cubic
-       - we insert a Move(0,0) if Line | Quad | Cubic is our first command
-
-       The iterator does more cleanup, especially if forceClose == true
-       1. if we encounter Close, return a cons'd up Line() first (if the curr-pt != start-pt)
-       2. if we encounter Move without a preceeding Close, and forceClose is true, goto #1
-       3. if we encounter Line | Quad | Cubic after Close, cons up a Move
+    Stores the verbs and points as they are given to us, with exceptions:
+    - we only record "Close" if it was immediately preceeded by Line | Quad | Cubic
+    - we insert a Move(0,0) if Line | Quad | Cubic is our first command
+
+    The iterator does more cleanup, especially if forceClose == true
+    1. if we encounter Close, return a cons'd up Line() first (if the curr-pt != start-pt)
+    2. if we encounter Move without a preceeding Close, and forceClose is true, goto #1
+    3. if we encounter Line | Quad | Cubic after Close, cons up a Move
 */
 
 ////////////////////////////////////////////////////////////////////////////
@@ -20,7 +37,7 @@ SkPath::SkPath() : fFillType(kWinding_FillType)
 
 SkPath::SkPath(const SkPath& src)
 {
-       *this = src;
+    *this = src;
 }
 
 SkPath::~SkPath()
@@ -31,211 +48,211 @@ SkPath& SkPath::operator=(const SkPath& src)
 {
     if (this != &src)
     {
-        fPts           = src.fPts;
-        fVerbs         = src.fVerbs;
-        fFillType      = src.fFillType;
+        fPts        = src.fPts;
+        fVerbs      = src.fVerbs;
+        fFillType   = src.fFillType;
     }
-       return *this;
+    return *this;
 }
 
 void SkPath::swap(SkPath& other)
 {
-       SkASSERT(&other != nil);
-
-       if (this != &other)
-       {
-               fPts.swap(other.fPts);
-               fVerbs.swap(other.fVerbs);
-               SkTSwap<U8>(fFillType, other.fFillType);
-       }
+    SkASSERT(&other != nil);
+
+    if (this != &other)
+    {
+        fPts.swap(other.fPts);
+        fVerbs.swap(other.fVerbs);
+        SkTSwap<U8>(fFillType, other.fFillType);
+    }
 }
 
 void SkPath::reset()
 {
-       fPts.reset();
-       fVerbs.reset();
+    fPts.reset();
+    fVerbs.reset();
 }
 
 bool SkPath::isEmpty() const
 {
-       int count = fVerbs.count();
-       return count == 0 || (count == 1 && fVerbs[0] == kMove_Verb);
+    int count = fVerbs.count();
+    return count == 0 || (count == 1 && fVerbs[0] == kMove_Verb);
 }
 
 bool SkPath::isRect(SkRect*) const
 {
-       SkASSERT(!"unimplemented");
-       return false;
+    SkASSERT(!"unimplemented");
+    return false;
 }
 
 int SkPath::getPoints(SkPoint copy[], int max) const
 {
-       SkASSERT(max >= 0);
-       int count = fPts.count();
-       if (copy && max > 0 && count > 0)
-               memcpy(copy, fPts.begin(), sizeof(SkPoint) * SkMin32(max, count));
-       return count;
+    SkASSERT(max >= 0);
+    int count = fPts.count();
+    if (copy && max > 0 && count > 0)
+        memcpy(copy, fPts.begin(), sizeof(SkPoint) * SkMin32(max, count));
+    return count;
 }
 
 void SkPath::getLastPt(SkPoint* lastPt) const
 {
-       if (lastPt)
-       {
-               int count = fPts.count();
-               if (count == 0)
-                       lastPt->set(0, 0);
-               else
-                       *lastPt = fPts[count - 1];
-       }
+    if (lastPt)
+    {
+        int count = fPts.count();
+        if (count == 0)
+            lastPt->set(0, 0);
+        else
+            *lastPt = fPts[count - 1];
+    }
 }
 
 void SkPath::setLastPt(SkScalar x, SkScalar y)
 {
-       int count = fPts.count();
-       if (count == 0)
-               this->moveTo(x, y);
-       else
-               fPts[count - 1].set(x, y);
+    int count = fPts.count();
+    if (count == 0)
+        this->moveTo(x, y);
+    else
+        fPts[count - 1].set(x, y);
 }
 
 void SkPath::computeBounds(SkRect* bounds, BoundsType bt) const
 {
-       SkASSERT(bounds);
-
-       if (fPts.count() <= 1)
-               bounds->set(0, 0, 0, 0);
-       else if (true || bt == kFast_BoundsType)
-               bounds->set(fPts.begin(), fPts.count());
-       else
-       {
-               SkASSERT(!"unimplemented");
-               Iter    iter(*this, false);
-               SkPoint pts[4];
-               Verb    verb;
-
-               while ((verb = iter.next(pts)) != kDone_Verb)
-               {
-                       switch (verb) {
-                       case kLine_Verb:
-                       case kQuad_Verb:
-                       case kCubic_Verb:
-                               break;
-                       default:
-                               break;
-                       }
-               }
-       }
+    SkASSERT(bounds);
+
+    if (fPts.count() <= 1)
+        bounds->set(0, 0, 0, 0);
+    else if (true || bt == kFast_BoundsType)
+        bounds->set(fPts.begin(), fPts.count());
+    else
+    {
+        SkASSERT(!"unimplemented");
+        Iter    iter(*this, false);
+        SkPoint pts[4];
+        Verb    verb;
+
+        while ((verb = iter.next(pts)) != kDone_Verb)
+        {
+            switch (verb) {
+            case kLine_Verb:
+            case kQuad_Verb:
+            case kCubic_Verb:
+                break;
+            default:
+                break;
+            }
+        }
+    }
 }
 
 //////////////////////////////////////////////////////////////////////////////
-//     Construction methods
+//  Construction methods
 
 void SkPath::incReserve(U16CPU inc)
 {
-       fVerbs.setReserve(fVerbs.count() + inc);
-       fPts.setReserve(fPts.count() + inc);
+    fVerbs.setReserve(fVerbs.count() + inc);
+    fPts.setReserve(fPts.count() + inc);
 }
 
 void SkPath::moveTo(SkScalar x, SkScalar y)
 {
-       int              vc = fVerbs.count();
-       SkPoint* pt;
-
-       if (vc > 0 && fVerbs[vc - 1] == kMove_Verb)
-       {
-               pt = &fPts[fPts.count() - 1];
-       }
-       else
-       {
-               pt = fPts.append();
-               *fVerbs.append() = kMove_Verb;
-       }
-       pt->set(x, y);
+    int      vc = fVerbs.count();
+    SkPoint* pt;
+
+    if (vc > 0 && fVerbs[vc - 1] == kMove_Verb)
+    {
+        pt = &fPts[fPts.count() - 1];
+    }
+    else
+    {
+        pt = fPts.append();
+        *fVerbs.append() = kMove_Verb;
+    }
+    pt->set(x, y);
 }
 
 void SkPath::rMoveTo(SkScalar x, SkScalar y)
 {
-       SkPoint pt;
-       this->getLastPt(&pt);
-       this->moveTo(pt.fX + x, pt.fY + y);
+    SkPoint pt;
+    this->getLastPt(&pt);
+    this->moveTo(pt.fX + x, pt.fY + y);
 }
 
 void SkPath::lineTo(SkScalar x, SkScalar y)
 {
-       if (fVerbs.count() == 0)
-       {
-               fPts.append()->set(0, 0);
-               *fVerbs.append() = kMove_Verb;
-       }
-       fPts.append()->set(x, y);
-       *fVerbs.append() = kLine_Verb;
+    if (fVerbs.count() == 0)
+    {
+        fPts.append()->set(0, 0);
+        *fVerbs.append() = kMove_Verb;
+    }
+    fPts.append()->set(x, y);
+    *fVerbs.append() = kLine_Verb;
 }
 
 void SkPath::rLineTo(SkScalar x, SkScalar y)
 {
-       SkPoint pt;
-       this->getLastPt(&pt);
-       this->lineTo(pt.fX + x, pt.fY + y);
+    SkPoint pt;
+    this->getLastPt(&pt);
+    this->lineTo(pt.fX + x, pt.fY + y);
 }
 
 void SkPath::quadTo(SkScalar x1, SkScalar y1, SkScalar x2, SkScalar y2)
 {
-       if (fVerbs.count() == 0)
-       {
-               fPts.append()->set(0, 0);
-               *fVerbs.append() = kMove_Verb;
-       }
-
-       SkPoint* pts = fPts.append(2);
-       pts[0].set(x1, y1);
-       pts[1].set(x2, y2);
-       *fVerbs.append() = kQuad_Verb;
+    if (fVerbs.count() == 0)
+    {
+        fPts.append()->set(0, 0);
+        *fVerbs.append() = kMove_Verb;
+    }
+
+    SkPoint* pts = fPts.append(2);
+    pts[0].set(x1, y1);
+    pts[1].set(x2, y2);
+    *fVerbs.append() = kQuad_Verb;
 }
 
 void SkPath::rQuadTo(SkScalar x1, SkScalar y1, SkScalar x2, SkScalar y2)
 {
-       SkPoint pt;
-       this->getLastPt(&pt);
-       this->quadTo(pt.fX + x1, pt.fY + y1, pt.fX + x2, pt.fY + y2);
+    SkPoint pt;
+    this->getLastPt(&pt);
+    this->quadTo(pt.fX + x1, pt.fY + y1, pt.fX + x2, pt.fY + y2);
 }
 
 void SkPath::cubicTo(SkScalar x1, SkScalar y1, SkScalar x2, SkScalar y2, SkScalar x3, SkScalar y3)
 {
-       if (fVerbs.count() == 0)
-       {
-               fPts.append()->set(0, 0);
-               *fVerbs.append() = kMove_Verb;
-       }
-       SkPoint* pts = fPts.append(3);
-       pts[0].set(x1, y1);
-       pts[1].set(x2, y2);
-       pts[2].set(x3, y3);
-       *fVerbs.append() = kCubic_Verb;
+    if (fVerbs.count() == 0)
+    {
+        fPts.append()->set(0, 0);
+        *fVerbs.append() = kMove_Verb;
+    }
+    SkPoint* pts = fPts.append(3);
+    pts[0].set(x1, y1);
+    pts[1].set(x2, y2);
+    pts[2].set(x3, y3);
+    *fVerbs.append() = kCubic_Verb;
 }
 
 void SkPath::rCubicTo(SkScalar x1, SkScalar y1, SkScalar x2, SkScalar y2, SkScalar x3, SkScalar y3)
 {
-       SkPoint pt;
-       this->getLastPt(&pt);
-       this->cubicTo(pt.fX + x1, pt.fY + y1, pt.fX + x2, pt.fY + y2, pt.fX + x3, pt.fY + y3);
+    SkPoint pt;
+    this->getLastPt(&pt);
+    this->cubicTo(pt.fX + x1, pt.fY + y1, pt.fX + x2, pt.fY + y2, pt.fX + x3, pt.fY + y3);
 }
 
 void SkPath::close()
 {
-       int count = fVerbs.count();
-       if (count > 0)
-       {
-               switch (fVerbs[count - 1]) {
-               case kLine_Verb:
-               case kQuad_Verb:
-               case kCubic_Verb:
-                       *fVerbs.append() = kClose_Verb;
-                       break;
-               default:
-                       // don't add a close if the prev wasn't a primitive
-                       break;
-               }
-       }
+    int count = fVerbs.count();
+    if (count > 0)
+    {
+        switch (fVerbs[count - 1]) {
+        case kLine_Verb:
+        case kQuad_Verb:
+        case kCubic_Verb:
+            *fVerbs.append() = kClose_Verb;
+            break;
+        default:
+            // don't add a close if the prev wasn't a primitive
+            break;
+        }
+    }
 }
 
 ////////////////////////////////////////////////////////////////////////////////////
@@ -247,304 +264,360 @@ void SkPath::addRect(const SkRect& rect, Direction dir)
 
 void SkPath::addRect(SkScalar left, SkScalar top, SkScalar right, SkScalar bottom, Direction dir)
 {
-       this->moveTo(left, top);
-       if (dir == kCCW_Direction)
-       {
-               this->lineTo(left, bottom);
-               this->lineTo(right, bottom);
-               this->lineTo(right, top);
-       }
-       else
-       {
-               this->lineTo(right, top);
-               this->lineTo(right, bottom);
-               this->lineTo(left, bottom);
-       }
-       this->close();
+    this->moveTo(left, top);
+    if (dir == kCCW_Direction)
+    {
+        this->lineTo(left, bottom);
+        this->lineTo(right, bottom);
+        this->lineTo(right, top);
+    }
+    else
+    {
+        this->lineTo(right, top);
+        this->lineTo(right, bottom);
+        this->lineTo(left, bottom);
+    }
+    this->close();
 }
 
-#define CUBIC_ARC_FACTOR       ((SK_ScalarSqrt2 - SK_Scalar1) * 4 / 3)
+#define CUBIC_ARC_FACTOR    ((SK_ScalarSqrt2 - SK_Scalar1) * 4 / 3)
 
 void SkPath::addRoundRect(const SkRect& rect, SkScalar rx, SkScalar ry, Direction dir)
 {
-       SkScalar        w = rect.width();
-       SkScalar        halfW = SkScalarHalf(w);
-       SkScalar        h = rect.height();
-       SkScalar        halfH = SkScalarHalf(h);
-
-       if (halfW <= 0 || halfH <= 0)
-               return;
-
-       bool    skip_hori = rx >= halfW;
-       bool    skip_vert = ry >= halfH;
-
-       if (skip_hori && skip_vert)
-       {
-               this->addOval(rect, dir);
-               return;
-       }
-       if (skip_hori)
-               rx = halfW;
-       else if (skip_vert)
-               ry = halfH;
-
-       SkScalar        sx = SkScalarMul(rx, CUBIC_ARC_FACTOR);
-       SkScalar        sy = SkScalarMul(ry, CUBIC_ARC_FACTOR);
-
-       this->incReserve(17);
-       this->moveTo(rect.fRight - rx, rect.fTop);
-       if (dir == kCCW_Direction)
-       {
-               if (!skip_hori)
-                       this->lineTo(rect.fLeft + rx, rect.fTop);               // top
-               this->cubicTo(rect.fLeft + rx - sx, rect.fTop,
-                                         rect.fLeft, rect.fTop + ry - sy,
-                                         rect.fLeft, rect.fTop + ry);                  // top-left
-               if (!skip_vert)
-                       this->lineTo(rect.fLeft, rect.fBottom - ry);            // left
-               this->cubicTo(rect.fLeft, rect.fBottom - ry + sy,
-                                         rect.fLeft + rx - sx, rect.fBottom,
-                                         rect.fLeft + rx, rect.fBottom);               // bot-left
-               if (!skip_hori)
-                       this->lineTo(rect.fRight - rx, rect.fBottom);   // bottom
-               this->cubicTo(rect.fRight - rx + sx, rect.fBottom,
-                                         rect.fRight, rect.fBottom - ry + sy,
-                                         rect.fRight, rect.fBottom - ry);              // bot-right
-               if (!skip_vert)
-                       this->lineTo(rect.fRight, rect.fTop + ry);
-               this->cubicTo(rect.fRight, rect.fTop + ry - sy,
-                                         rect.fRight - rx + sx, rect.fTop,
-                                         rect.fRight - rx, rect.fTop);                 // top-right
-       }
-       else
-       {
-               this->cubicTo(rect.fRight - rx + sx, rect.fTop,
-                                         rect.fRight, rect.fTop + ry - sy,
-                                         rect.fRight, rect.fTop + ry);                 // top-right
-               if (!skip_vert)
-                       this->lineTo(rect.fRight, rect.fBottom - ry);
-               this->cubicTo(rect.fRight, rect.fBottom - ry + sy,
-                                         rect.fRight - rx + sx, rect.fBottom,
-                                         rect.fRight - rx, rect.fBottom);              // bot-right
-               if (!skip_hori)
-                       this->lineTo(rect.fLeft + rx, rect.fBottom);    // bottom
-               this->cubicTo(rect.fLeft + rx - sx, rect.fBottom,
-                                         rect.fLeft, rect.fBottom - ry + sy,
-                                         rect.fLeft, rect.fBottom - ry);               // bot-left
-               if (!skip_vert)
-                       this->lineTo(rect.fLeft, rect.fTop + ry);               // left
-               this->cubicTo(rect.fLeft, rect.fTop + ry - sy,
-                                         rect.fLeft + rx - sx, rect.fTop,
-                                         rect.fLeft + rx, rect.fTop);                  // top-left
-               if (!skip_hori)
-                       this->lineTo(rect.fRight - rx, rect.fTop);              // top
-       }
-       this->close();
+    SkScalar    w = rect.width();
+    SkScalar    halfW = SkScalarHalf(w);
+    SkScalar    h = rect.height();
+    SkScalar    halfH = SkScalarHalf(h);
+
+    if (halfW <= 0 || halfH <= 0)
+        return;
+
+    bool    skip_hori = rx >= halfW;
+    bool    skip_vert = ry >= halfH;
+
+    if (skip_hori && skip_vert)
+    {
+        this->addOval(rect, dir);
+        return;
+    }
+    if (skip_hori)
+        rx = halfW;
+    else if (skip_vert)
+        ry = halfH;
+
+    SkScalar    sx = SkScalarMul(rx, CUBIC_ARC_FACTOR);
+    SkScalar    sy = SkScalarMul(ry, CUBIC_ARC_FACTOR);
+
+    this->incReserve(17);
+    this->moveTo(rect.fRight - rx, rect.fTop);
+    if (dir == kCCW_Direction)
+    {
+        if (!skip_hori)
+            this->lineTo(rect.fLeft + rx, rect.fTop);       // top
+        this->cubicTo(rect.fLeft + rx - sx, rect.fTop,
+                      rect.fLeft, rect.fTop + ry - sy,
+                      rect.fLeft, rect.fTop + ry);          // top-left
+        if (!skip_vert)
+            this->lineTo(rect.fLeft, rect.fBottom - ry);        // left
+        this->cubicTo(rect.fLeft, rect.fBottom - ry + sy,
+                      rect.fLeft + rx - sx, rect.fBottom,
+                      rect.fLeft + rx, rect.fBottom);       // bot-left
+        if (!skip_hori)
+            this->lineTo(rect.fRight - rx, rect.fBottom);   // bottom
+        this->cubicTo(rect.fRight - rx + sx, rect.fBottom,
+                      rect.fRight, rect.fBottom - ry + sy,
+                      rect.fRight, rect.fBottom - ry);      // bot-right
+        if (!skip_vert)
+            this->lineTo(rect.fRight, rect.fTop + ry);
+        this->cubicTo(rect.fRight, rect.fTop + ry - sy,
+                      rect.fRight - rx + sx, rect.fTop,
+                      rect.fRight - rx, rect.fTop);         // top-right
+    }
+    else
+    {
+        this->cubicTo(rect.fRight - rx + sx, rect.fTop,
+                      rect.fRight, rect.fTop + ry - sy,
+                      rect.fRight, rect.fTop + ry);         // top-right
+        if (!skip_vert)
+            this->lineTo(rect.fRight, rect.fBottom - ry);
+        this->cubicTo(rect.fRight, rect.fBottom - ry + sy,
+                      rect.fRight - rx + sx, rect.fBottom,
+                      rect.fRight - rx, rect.fBottom);      // bot-right
+        if (!skip_hori)
+            this->lineTo(rect.fLeft + rx, rect.fBottom);    // bottom
+        this->cubicTo(rect.fLeft + rx - sx, rect.fBottom,
+                      rect.fLeft, rect.fBottom - ry + sy,
+                      rect.fLeft, rect.fBottom - ry);       // bot-left
+        if (!skip_vert)
+            this->lineTo(rect.fLeft, rect.fTop + ry);       // left
+        this->cubicTo(rect.fLeft, rect.fTop + ry - sy,
+                      rect.fLeft + rx - sx, rect.fTop,
+                      rect.fLeft + rx, rect.fTop);          // top-left
+        if (!skip_hori)
+            this->lineTo(rect.fRight - rx, rect.fTop);      // top
+    }
+    this->close();
 }
 
 void SkPath::addOval(const SkRect& oval, Direction dir)
 {
-       SkScalar        cx = oval.centerX();
-       SkScalar        cy = oval.centerY();
-       SkScalar        rx = SkScalarHalf(oval.width());
-       SkScalar        ry = SkScalarHalf(oval.height());
-#if 1  // these seem faster than using quads (1/2 the number of edges to process)
-       SkScalar        sx = SkScalarMul(rx, CUBIC_ARC_FACTOR);
-       SkScalar        sy = SkScalarMul(ry, CUBIC_ARC_FACTOR);
-
-       this->incReserve(13);
-       this->moveTo(cx + rx, cy);
-       if (dir == kCCW_Direction)
-       {
-               this->cubicTo(cx + rx, cy - sy, cx + sx, cy - ry, cx, cy - ry);
-               this->cubicTo(cx - sx, cy - ry, cx - rx, cy - sy, cx - rx, cy);
-               this->cubicTo(cx - rx, cy + sy, cx - sx, cy + ry, cx, cy + ry);
-               this->cubicTo(cx + sx, cy + ry, cx + rx, cy + sy, cx + rx, cy);
-       }
-       else
-       {
-               this->cubicTo(cx + rx, cy + sy, cx + sx, cy + ry, cx, cy + ry);
-               this->cubicTo(cx - sx, cy + ry, cx - rx, cy + sy, cx - rx, cy);
-               this->cubicTo(cx - rx, cy - sy, cx - sx, cy - ry, cx, cy - ry);
-               this->cubicTo(cx + sx, cy - ry, cx + rx, cy - sy, cx + rx, cy);
-       }
+    SkScalar    cx = oval.centerX();
+    SkScalar    cy = oval.centerY();
+    SkScalar    rx = SkScalarHalf(oval.width());
+    SkScalar    ry = SkScalarHalf(oval.height());
+#if 1   // these seem faster than using quads (1/2 the number of edges to process)
+    SkScalar    sx = SkScalarMul(rx, CUBIC_ARC_FACTOR);
+    SkScalar    sy = SkScalarMul(ry, CUBIC_ARC_FACTOR);
+
+    this->incReserve(13);
+    this->moveTo(cx + rx, cy);
+    if (dir == kCCW_Direction)
+    {
+        this->cubicTo(cx + rx, cy - sy, cx + sx, cy - ry, cx, cy - ry);
+        this->cubicTo(cx - sx, cy - ry, cx - rx, cy - sy, cx - rx, cy);
+        this->cubicTo(cx - rx, cy + sy, cx - sx, cy + ry, cx, cy + ry);
+        this->cubicTo(cx + sx, cy + ry, cx + rx, cy + sy, cx + rx, cy);
+    }
+    else
+    {
+        this->cubicTo(cx + rx, cy + sy, cx + sx, cy + ry, cx, cy + ry);
+        this->cubicTo(cx - sx, cy + ry, cx - rx, cy + sy, cx - rx, cy);
+        this->cubicTo(cx - rx, cy - sy, cx - sx, cy - ry, cx, cy - ry);
+        this->cubicTo(cx + sx, cy - ry, cx + rx, cy - sy, cx + rx, cy);
+    }
 #else
-       SkScalar        sx = SkScalarMul(rx, SK_ScalarTanPIOver8);
-       SkScalar        sy = SkScalarMul(ry, SK_ScalarTanPIOver8);
-       SkScalar        mx = SkScalarMul(rx, SK_ScalarRoot2Over2);
-       SkScalar        my = SkScalarMul(ry, SK_ScalarRoot2Over2);
-
-       this->incReserve(16);
-       this->moveTo(cx + rx, cy);
-       if (dir == kCCW_Direction)
-       {
-               this->quadTo(cx + rx, cy - sy, cx + mx, cy - my);
-               this->quadTo(cx + sx, cy - ry, cx +  0, cy - ry);
-               this->quadTo(cx - sx, cy - ry, cx - mx, cy - my);
-               this->quadTo(cx - rx, cy - sy, cx - rx, cy -  0);
-               this->quadTo(cx - rx, cy + sy, cx - mx, cy + my);
-               this->quadTo(cx - sx, cy + ry, cx -  0, cy + ry);
-               this->quadTo(cx + sx, cy + ry, cx + mx, cy + my);
-               this->quadTo(cx + rx, cy + sy, cx + rx, cy +  0);
-       }
-       else
-       {
-               this->quadTo(cx + rx, cy + sy, cx + mx, cy + my);
-               this->quadTo(cx + sx, cy + ry, cx -  0, cy + ry);
-               this->quadTo(cx - sx, cy + ry, cx - mx, cy + my);
-               this->quadTo(cx - rx, cy + sy, cx - rx, cy -  0);
-               this->quadTo(cx - rx, cy - sy, cx - mx, cy - my);
-               this->quadTo(cx - sx, cy - ry, cx +  0, cy - ry);
-               this->quadTo(cx + sx, cy - ry, cx + mx, cy - my);
-               this->quadTo(cx + rx, cy - sy, cx + rx, cy +  0);
-       }
+    SkScalar    sx = SkScalarMul(rx, SK_ScalarTanPIOver8);
+    SkScalar    sy = SkScalarMul(ry, SK_ScalarTanPIOver8);
+    SkScalar    mx = SkScalarMul(rx, SK_ScalarRoot2Over2);
+    SkScalar    my = SkScalarMul(ry, SK_ScalarRoot2Over2);
+
+    this->incReserve(16);
+    this->moveTo(cx + rx, cy);
+    if (dir == kCCW_Direction)
+    {
+        this->quadTo(cx + rx, cy - sy, cx + mx, cy - my);
+        this->quadTo(cx + sx, cy - ry, cx +  0, cy - ry);
+        this->quadTo(cx - sx, cy - ry, cx - mx, cy - my);
+        this->quadTo(cx - rx, cy - sy, cx - rx, cy -  0);
+        this->quadTo(cx - rx, cy + sy, cx - mx, cy + my);
+        this->quadTo(cx - sx, cy + ry, cx -  0, cy + ry);
+        this->quadTo(cx + sx, cy + ry, cx + mx, cy + my);
+        this->quadTo(cx + rx, cy + sy, cx + rx, cy +  0);
+    }
+    else
+    {
+        this->quadTo(cx + rx, cy + sy, cx + mx, cy + my);
+        this->quadTo(cx + sx, cy + ry, cx -  0, cy + ry);
+        this->quadTo(cx - sx, cy + ry, cx - mx, cy + my);
+        this->quadTo(cx - rx, cy + sy, cx - rx, cy -  0);
+        this->quadTo(cx - rx, cy - sy, cx - mx, cy - my);
+        this->quadTo(cx - sx, cy - ry, cx +  0, cy - ry);
+        this->quadTo(cx + sx, cy - ry, cx + mx, cy - my);
+        this->quadTo(cx + rx, cy - sy, cx + rx, cy +  0);
+    }
 #endif
-       this->close();
+    this->close();
 }
 
 void SkPath::addCircle(SkScalar x, SkScalar y, SkScalar r, Direction dir)
 {
-       if (r > 0)
-       {
-               SkRect  rect;
-               rect.set(x - r, y - r, x + r, y + r);
-               this->addOval(rect, dir);
-       }
+    if (r > 0)
+    {
+        SkRect  rect;
+        rect.set(x - r, y - r, x + r, y + r);
+        this->addOval(rect, dir);
+    }
+}
+
+#include "SkGeometry.h"
+
+static int build_arc_points(const SkRect& oval, SkScalar startAngle, SkScalar sweepAngle,
+                            SkPoint pts[kSkBuildQuadArcStorage])
+{
+    SkVector start, stop;
+
+    start.fY = SkScalarSinCos(SkDegreesToRadians(startAngle), &start.fX);
+    stop.fY = SkScalarSinCos(SkDegreesToRadians(startAngle + sweepAngle), &stop.fX);
+        
+    SkMatrix    matrix;
+    
+    matrix.setScale(SkScalarHalf(oval.width()), SkScalarHalf(oval.height()));
+    matrix.postTranslate(oval.centerX(), oval.centerY());
+    
+    return SkBuildQuadArc(start, stop,
+                          sweepAngle > 0 ? kCW_SkRotationDirection : kCCW_SkRotationDirection,
+                          &matrix, pts);
+}
+
+void SkPath::arcTo(const SkRect& oval, SkScalar startAngle, SkScalar sweepAngle, bool forceMoveTo)
+{
+    SkPoint pts[kSkBuildQuadArcStorage];
+    int count = build_arc_points(oval, startAngle, sweepAngle, pts);
+
+    if (fVerbs.count() == 0)
+        forceMoveTo = true;
+
+    this->incReserve(count);
+    forceMoveTo ? this->moveTo(pts[0]) : this->lineTo(pts[0]);
+    for (int i = 1; i < count; i += 2)
+        this->quadTo(pts[i], pts[i+1]);
+}
+
+void SkPath::addArc(const SkRect& oval, SkScalar startAngle, SkScalar sweepAngle)
+{
+    if (oval.isEmpty() || 0 == sweepAngle)
+        return;
+    
+    const SkScalar kFullCircleAngle = SkIntToScalar(360);
+
+    if (sweepAngle >= kFullCircleAngle || sweepAngle <= -kFullCircleAngle)
+    {
+        this->addOval(oval, sweepAngle > 0 ? kCW_Direction : kCCW_Direction);
+        return;
+    }
+
+    SkPoint pts[kSkBuildQuadArcStorage];
+    int count = build_arc_points(oval, startAngle, sweepAngle, pts);
+
+    this->incReserve(count);
+    this->moveTo(pts[0]);
+    for (int i = 1; i < count; i += 2)
+        this->quadTo(pts[i], pts[i+1]);
 }
 
 void SkPath::addPath(const SkPath& path, SkScalar dx, SkScalar dy)
 {
-       SkMatrix matrix;
+    SkMatrix matrix;
 
-       matrix.setTranslate(dx, dy);
-       this->addPath(path, matrix);
+    matrix.setTranslate(dx, dy);
+    this->addPath(path, matrix);
 }
 
 void SkPath::addPath(const SkPath& path, const SkMatrix& matrix)
 {
-       this->incReserve(path.fPts.count());
-
-       Iter    iter(path, false);
-       SkPoint pts[4];
-       Verb    verb;
-
-       SkMatrix::TypeMask mask = matrix.getType();
-
-       while ((verb = iter.next(pts)) != kDone_Verb)
-       {
-               switch (verb) {
-               case kMove_Verb:
-                       matrix.mapPoints(&pts[0], &pts[0], 1, mask);
-                       this->moveTo(pts[0]);
-                       break;
-               case kLine_Verb:
-                       matrix.mapPoints(&pts[1], &pts[1], 1, mask);
-                       this->lineTo(pts[1]);
-                       break;
-               case kQuad_Verb:
-                       matrix.mapPoints(&pts[1], &pts[1], 2, mask);
-                       this->quadTo(pts[1], pts[2]);
-                       break;
-               case kCubic_Verb:
-                       matrix.mapPoints(&pts[1], &pts[1], 3, mask);
-                       this->cubicTo(pts[1], pts[2], pts[3]);
-                       break;
-               case kClose_Verb:
-                       this->close();
-                       break;
-               default:
-                       SkASSERT(!"unknown verb");
-               }
-       }
+    this->incReserve(path.fPts.count());
+
+    Iter    iter(path, false);
+    SkPoint pts[4];
+    Verb    verb;
+
+    SkMatrix::TypeMask mask = matrix.getType();
+
+    while ((verb = iter.next(pts)) != kDone_Verb)
+    {
+        switch (verb) {
+        case kMove_Verb:
+            matrix.mapPoints(&pts[0], &pts[0], 1, mask);
+            this->moveTo(pts[0]);
+            break;
+        case kLine_Verb:
+            matrix.mapPoints(&pts[1], &pts[1], 1, mask);
+            this->lineTo(pts[1]);
+            break;
+        case kQuad_Verb:
+            matrix.mapPoints(&pts[1], &pts[1], 2, mask);
+            this->quadTo(pts[1], pts[2]);
+            break;
+        case kCubic_Verb:
+            matrix.mapPoints(&pts[1], &pts[1], 3, mask);
+            this->cubicTo(pts[1], pts[2], pts[3]);
+            break;
+        case kClose_Verb:
+            this->close();
+            break;
+        default:
+            SkASSERT(!"unknown verb");
+        }
+    }
 }
 
 ////////////////////////////////////////////////////////////////////////////////////
 
 static const U8 gPtsInVerb[] = {
-       1,      // kMove
-       1,      // kLine
-       2,      // kQuad
-       3,      // kCubic
-       0,      // kClose
-       0       // kDone
+    1,  // kMove
+    1,  // kLine
+    2,  // kQuad
+    3,  // kCubic
+    0,  // kClose
+    0   // kDone
 };
 
 // ignore the initial moveto, and stop when the 1st contour ends
 void SkPath::pathTo(const SkPath& path)
 {
-       int     i, vcount = path.fVerbs.count();
-       if (vcount == 0)
-               return;
-
-       const U8*               verbs = path.fVerbs.begin();
-       const SkPoint*  pts = path.fPts.begin() + 1;    // 1 for the initial moveTo
-
-       SkASSERT(verbs[0] == kMove_Verb);
-       for (i = 1; i < vcount; i++)
-       {
-               switch (verbs[i]) {
-               case kLine_Verb:
-                       this->lineTo(pts[0].fX, pts[0].fY);
-                       break;
-               case kQuad_Verb:
-                       this->quadTo(pts[0].fX, pts[0].fY, pts[1].fX, pts[1].fY);
-                       break;
-               case kCubic_Verb:
-                       this->cubicTo(pts[0].fX, pts[0].fY, pts[1].fX, pts[1].fY, pts[2].fX, pts[2].fY);
-                       break;
-               case kClose_Verb:
-                       return;
-               }
-               pts += gPtsInVerb[verbs[i]];
-       }
+    int i, vcount = path.fVerbs.count();
+    if (vcount == 0)
+        return;
+
+    const U8*       verbs = path.fVerbs.begin();
+    const SkPoint*  pts = path.fPts.begin() + 1;    // 1 for the initial moveTo
+
+    SkASSERT(verbs[0] == kMove_Verb);
+    for (i = 1; i < vcount; i++)
+    {
+        switch (verbs[i]) {
+        case kLine_Verb:
+            this->lineTo(pts[0].fX, pts[0].fY);
+            break;
+        case kQuad_Verb:
+            this->quadTo(pts[0].fX, pts[0].fY, pts[1].fX, pts[1].fY);
+            break;
+        case kCubic_Verb:
+            this->cubicTo(pts[0].fX, pts[0].fY, pts[1].fX, pts[1].fY, pts[2].fX, pts[2].fY);
+            break;
+        case kClose_Verb:
+            return;
+        }
+        pts += gPtsInVerb[verbs[i]];
+    }
 }
 
 // ignore the last point of the 1st contour
 void SkPath::reversePathTo(const SkPath& path)
 {
-       int     i, vcount = path.fVerbs.count();
-       if (vcount == 0)
-               return;
-
-       const U8*               verbs = path.fVerbs.begin();
-       const SkPoint*  pts = path.fPts.begin();
-
-       SkASSERT(verbs[0] == kMove_Verb);
-       for (i = 1; i < vcount; i++)
-       {
-               int n = gPtsInVerb[verbs[i]];
-               if (n == 0)
-                       break;
-               pts += n;
-       }
-
-       while (--i > 0)
-       {
-               switch (verbs[i]) {
-               case kLine_Verb:
-                       this->lineTo(pts[-1].fX, pts[-1].fY);
-                       break;
-               case kQuad_Verb:
-                       this->quadTo(pts[-1].fX, pts[-1].fY, pts[-2].fX, pts[-2].fY);
-                       break;
-               case kCubic_Verb:
-                       this->cubicTo(pts[-1].fX, pts[-1].fY, pts[-2].fX, pts[-2].fY, pts[-3].fX, pts[-3].fY);
-                       break;
-               default:
-                       SkASSERT(!"bad verb");
-                       break;
-               }
-               pts -= gPtsInVerb[verbs[i]];
-       }
+    int i, vcount = path.fVerbs.count();
+    if (vcount == 0)
+        return;
+
+    const U8*       verbs = path.fVerbs.begin();
+    const SkPoint*  pts = path.fPts.begin();
+
+    SkASSERT(verbs[0] == kMove_Verb);
+    for (i = 1; i < vcount; i++)
+    {
+        int n = gPtsInVerb[verbs[i]];
+        if (n == 0)
+            break;
+        pts += n;
+    }
+
+    while (--i > 0)
+    {
+        switch (verbs[i]) {
+        case kLine_Verb:
+            this->lineTo(pts[-1].fX, pts[-1].fY);
+            break;
+        case kQuad_Verb:
+            this->quadTo(pts[-1].fX, pts[-1].fY, pts[-2].fX, pts[-2].fY);
+            break;
+        case kCubic_Verb:
+            this->cubicTo(pts[-1].fX, pts[-1].fY, pts[-2].fX, pts[-2].fY, pts[-3].fX, pts[-3].fY);
+            break;
+        default:
+            SkASSERT(!"bad verb");
+            break;
+        }
+        pts -= gPtsInVerb[verbs[i]];
+    }
 }
 
 ////////////////////////////////////////////////////////////////////////////////////
 
 bool SkPath::offset(SkScalar dx, SkScalar dy, SkPath* dst) const
 {
-       SkMatrix        matrix;
+    SkMatrix    matrix;
 
-       matrix.setTranslate(dx, dy);
+    matrix.setTranslate(dx, dy);
     return this->transform(matrix, dst);
 }
 
@@ -552,121 +625,121 @@ bool SkPath::offset(SkScalar dx, SkScalar dy, SkPath* dst) const
 
 static void subdivide_quad_to(SkPath* path, const SkPoint pts[3], int level = 2)
 {
-       if (--level >= 0)
-       {
-               SkPoint tmp[5];
-
-               SkChopQuadAtHalf(pts, tmp);
-               subdivide_quad_to(path, &tmp[0], level);
-               subdivide_quad_to(path, &tmp[2], level);
-       }
-       else
-               path->quadTo(pts[1], pts[2]);
+    if (--level >= 0)
+    {
+        SkPoint tmp[5];
+
+        SkChopQuadAtHalf(pts, tmp);
+        subdivide_quad_to(path, &tmp[0], level);
+        subdivide_quad_to(path, &tmp[2], level);
+    }
+    else
+        path->quadTo(pts[1], pts[2]);
 }
 
 static void subdivide_cubic_to(SkPath* path, const SkPoint pts[4], int level = 2)
 {
-       if (--level >= 0)
-       {
-               SkPoint tmp[7];
-
-               SkChopCubicAtHalf(pts, tmp);
-               subdivide_cubic_to(path, &tmp[0], level);
-               subdivide_cubic_to(path, &tmp[3], level);
-       }
-       else
-               path->cubicTo(pts[1], pts[2], pts[3]);
+    if (--level >= 0)
+    {
+        SkPoint tmp[7];
+
+        SkChopCubicAtHalf(pts, tmp);
+        subdivide_cubic_to(path, &tmp[0], level);
+        subdivide_cubic_to(path, &tmp[3], level);
+    }
+    else
+        path->cubicTo(pts[1], pts[2], pts[3]);
 }
 
 bool SkPath::transform(const SkMatrix& matrix, SkPath* dst) const
 {
-       if (dst == nil)
-               dst = (SkPath*)this;
-
-       if (matrix.getType() & SkMatrix::kPerspective_Mask)
-       {
-               SkPath  tmp;
-               tmp.fFillType = fFillType;
-
-               SkPath::Iter    iter(*this, false);
-               SkPoint                 pts[4];
-               SkPath::Verb    verb;
-
-               while ((verb = iter.next(pts)) != kDone_Verb)
-               {
-                       switch (verb) {
-                       case kMove_Verb:
-                               tmp.moveTo(pts[0]);
-                               break;
-                       case kLine_Verb:
-                               tmp.lineTo(pts[1]);
-                               break;
-                       case kQuad_Verb:
-                               subdivide_quad_to(&tmp, pts);
-                               break;
-                       case kCubic_Verb:
-                               subdivide_cubic_to(&tmp, pts);
-                               break;
-                       case kClose_Verb:
-                               tmp.close();
-                               break;
-                       default:
-                               SkASSERT(!"unknown verb");
-                               break;
-                       }
-               }
-
-               dst->swap(tmp);
-               return matrix.mapPoints(dst->fPts.begin(), dst->fPts.count());
-       }
-
-       else
-       {
-               if (this != dst)
-               {
-                       dst->fVerbs = fVerbs;
-                       dst->fPts.setCount(fPts.count());
-                       dst->fFillType = fFillType;
-               }
-               return matrix.mapPoints(dst->fPts.begin(), fPts.begin(), fPts.count());
-       }
+    if (dst == nil)
+        dst = (SkPath*)this;
+
+    if (matrix.getType() & SkMatrix::kPerspective_Mask)
+    {
+        SkPath  tmp;
+        tmp.fFillType = fFillType;
+
+        SkPath::Iter    iter(*this, false);
+        SkPoint         pts[4];
+        SkPath::Verb    verb;
+
+        while ((verb = iter.next(pts)) != kDone_Verb)
+        {
+            switch (verb) {
+            case kMove_Verb:
+                tmp.moveTo(pts[0]);
+                break;
+            case kLine_Verb:
+                tmp.lineTo(pts[1]);
+                break;
+            case kQuad_Verb:
+                subdivide_quad_to(&tmp, pts);
+                break;
+            case kCubic_Verb:
+                subdivide_cubic_to(&tmp, pts);
+                break;
+            case kClose_Verb:
+                tmp.close();
+                break;
+            default:
+                SkASSERT(!"unknown verb");
+                break;
+            }
+        }
+
+        dst->swap(tmp);
+        return matrix.mapPoints(dst->fPts.begin(), dst->fPts.count());
+    }
+
+    else
+    {
+        if (this != dst)
+        {
+            dst->fVerbs = fVerbs;
+            dst->fPts.setCount(fPts.count());
+            dst->fFillType = fFillType;
+        }
+        return matrix.mapPoints(dst->fPts.begin(), fPts.begin(), fPts.count());
+    }
 }
 
 ////////////////////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////////////////////
 
 enum NeedMoveToState {
-       kAfterClose_NeedMoveToState,
-       kAfterCons_NeedMoveToState,
-       kAfterPrefix_NeedMoveToState
+    kAfterClose_NeedMoveToState,
+    kAfterCons_NeedMoveToState,
+    kAfterPrefix_NeedMoveToState
 };
 
 SkPath::Iter::Iter()
 {
 #ifdef SK_DEBUG
-       fPts = nil;
-       fMoveTo.fX = fMoveTo.fY = fLastPt.fX = fLastPt.fY = 0;
-       fForceClose = fNeedMoveTo = fCloseLine = false;
+    fPts = nil;
+    fMoveTo.fX = fMoveTo.fY = fLastPt.fX = fLastPt.fY = 0;
+    fForceClose = fNeedMoveTo = fCloseLine = false;
 #endif
-       // need to init enough to make next() harmlessly return kDone_Verb
-       fVerbs = nil;
-       fVerbStop = nil;
-       fNeedClose = false;
+    // need to init enough to make next() harmlessly return kDone_Verb
+    fVerbs = nil;
+    fVerbStop = nil;
+    fNeedClose = false;
 }
 
 SkPath::Iter::Iter(const SkPath& path, bool forceClose)
 {
-       this->setPath(path, forceClose);
+    this->setPath(path, forceClose);
 }
 
 void SkPath::Iter::setPath(const SkPath& path, bool forceClose)
 {
-       fPts = path.fPts.begin();
-       fVerbs = path.fVerbs.begin();
-       fVerbStop = path.fVerbs.end();
-       fForceClose = SkToU8(forceClose);
-       fNeedClose = false;
-       fNeedMoveTo = kAfterPrefix_NeedMoveToState;
+    fPts = path.fPts.begin();
+    fVerbs = path.fVerbs.begin();
+    fVerbStop = path.fVerbs.end();
+    fForceClose = SkToU8(forceClose);
+    fNeedClose = false;
+    fNeedMoveTo = kAfterPrefix_NeedMoveToState;
 }
 
 bool SkPath::Iter::isClosedContour() const
@@ -695,226 +768,226 @@ bool SkPath::Iter::isClosedContour() const
 
 SkPath::Verb SkPath::Iter::autoClose(SkPoint pts[2])
 {
-       if (fLastPt != fMoveTo)
-       {
-               if (pts)
-               {
-                       pts[0] = fLastPt;
-                       pts[1] = fMoveTo;
-               }
-               fLastPt = fMoveTo;
-               fCloseLine = true;
-               return kLine_Verb;
-       }
-       return kClose_Verb;
+    if (fLastPt != fMoveTo)
+    {
+        if (pts)
+        {
+            pts[0] = fLastPt;
+            pts[1] = fMoveTo;
+        }
+        fLastPt = fMoveTo;
+        fCloseLine = true;
+        return kLine_Verb;
+    }
+    return kClose_Verb;
 }
 
 bool SkPath::Iter::cons_moveTo(SkPoint pts[1])
 {
-       if (fNeedMoveTo == kAfterClose_NeedMoveToState)
-       {
-               if (pts)
-                       *pts = fMoveTo;
-               fNeedClose = fForceClose;
-               fNeedMoveTo = kAfterCons_NeedMoveToState;
-               fVerbs -= 1;
-               return true;
-       }
-
-       if (fNeedMoveTo == kAfterCons_NeedMoveToState)
-       {
-               if (pts)
-                       *pts = fMoveTo;
-               fNeedMoveTo = kAfterPrefix_NeedMoveToState;
-       }
-       else
-       {
-               SkASSERT(fNeedMoveTo == kAfterPrefix_NeedMoveToState);
-               if (pts)
-                       *pts = fPts[-1];
-       }
-       return false;
+    if (fNeedMoveTo == kAfterClose_NeedMoveToState)
+    {
+        if (pts)
+            *pts = fMoveTo;
+        fNeedClose = fForceClose;
+        fNeedMoveTo = kAfterCons_NeedMoveToState;
+        fVerbs -= 1;
+        return true;
+    }
+
+    if (fNeedMoveTo == kAfterCons_NeedMoveToState)
+    {
+        if (pts)
+            *pts = fMoveTo;
+        fNeedMoveTo = kAfterPrefix_NeedMoveToState;
+    }
+    else
+    {
+        SkASSERT(fNeedMoveTo == kAfterPrefix_NeedMoveToState);
+        if (pts)
+            *pts = fPts[-1];
+    }
+    return false;
 }
 
 SkPath::Verb SkPath::Iter::next(SkPoint pts[4])
 {
-       if (fVerbs == fVerbStop)
-       {
-               if (fNeedClose)
-               {
-                       if (kLine_Verb == this->autoClose(pts))
-                               return kLine_Verb;
-                       fNeedClose = false;
-                       return kClose_Verb;
-               }
-               return kDone_Verb;
-       }
-
-       unsigned                verb = *fVerbs++;
-       const SkPoint*  srcPts = fPts;
-
-       switch (verb) {
-       case kMove_Verb:
-               if (fNeedClose)
-               {
-                       fVerbs -= 1;
-                       verb = this->autoClose(pts);
-                       if (verb == kClose_Verb)
-                               fNeedClose = false;
-                       return (Verb)verb;
-               }
-               if (fVerbs == fVerbStop)        // might be a trailing moveto
-                       return kDone_Verb;
-               fMoveTo = *srcPts;
-               if (pts)
-                       pts[0] = *srcPts;
-               srcPts += 1;
-               fNeedMoveTo = kAfterCons_NeedMoveToState;
-               fNeedClose = fForceClose;
-               break;
-       case kLine_Verb:
-               if (this->cons_moveTo(pts))
-                       return kMove_Verb;
-               if (pts)
-                       pts[1] = srcPts[0];
-               fLastPt = srcPts[0];
-               fCloseLine = false;
-               srcPts += 1;
-               break;
-       case kQuad_Verb:
-               if (this->cons_moveTo(pts))
-                       return kMove_Verb;
-               if (pts)
-                       memcpy(&pts[1], srcPts, 2 * sizeof(SkPoint));
-               fLastPt = srcPts[1];
-               srcPts += 2;
-               break;
-       case kCubic_Verb:
-               if (this->cons_moveTo(pts))
-                       return kMove_Verb;
-               if (pts)
-                       memcpy(&pts[1], srcPts, 3 * sizeof(SkPoint));
-               fLastPt = srcPts[2];
-               srcPts += 3;
-               break;
-       case kClose_Verb:
-               verb = this->autoClose(pts);
-               if (verb == kLine_Verb)
-                       fVerbs -= 1;
-               else
-                       fNeedClose = false;
-               fNeedMoveTo = kAfterClose_NeedMoveToState;
-               break;
-       }
-       fPts = srcPts;
-       return (Verb)verb;
+    if (fVerbs == fVerbStop)
+    {
+        if (fNeedClose)
+        {
+            if (kLine_Verb == this->autoClose(pts))
+                return kLine_Verb;
+            fNeedClose = false;
+            return kClose_Verb;
+        }
+        return kDone_Verb;
+    }
+
+    unsigned        verb = *fVerbs++;
+    const SkPoint*  srcPts = fPts;
+
+    switch (verb) {
+    case kMove_Verb:
+        if (fNeedClose)
+        {
+            fVerbs -= 1;
+            verb = this->autoClose(pts);
+            if (verb == kClose_Verb)
+                fNeedClose = false;
+            return (Verb)verb;
+        }
+        if (fVerbs == fVerbStop)    // might be a trailing moveto
+            return kDone_Verb;
+        fMoveTo = *srcPts;
+        if (pts)
+            pts[0] = *srcPts;
+        srcPts += 1;
+        fNeedMoveTo = kAfterCons_NeedMoveToState;
+        fNeedClose = fForceClose;
+        break;
+    case kLine_Verb:
+        if (this->cons_moveTo(pts))
+            return kMove_Verb;
+        if (pts)
+            pts[1] = srcPts[0];
+        fLastPt = srcPts[0];
+        fCloseLine = false;
+        srcPts += 1;
+        break;
+    case kQuad_Verb:
+        if (this->cons_moveTo(pts))
+            return kMove_Verb;
+        if (pts)
+            memcpy(&pts[1], srcPts, 2 * sizeof(SkPoint));
+        fLastPt = srcPts[1];
+        srcPts += 2;
+        break;
+    case kCubic_Verb:
+        if (this->cons_moveTo(pts))
+            return kMove_Verb;
+        if (pts)
+            memcpy(&pts[1], srcPts, 3 * sizeof(SkPoint));
+        fLastPt = srcPts[2];
+        srcPts += 3;
+        break;
+    case kClose_Verb:
+        verb = this->autoClose(pts);
+        if (verb == kLine_Verb)
+            fVerbs -= 1;
+        else
+            fNeedClose = false;
+        fNeedMoveTo = kAfterClose_NeedMoveToState;
+        break;
+    }
+    fPts = srcPts;
+    return (Verb)verb;
 }
 
 ///////////////////////////////////////////////////////////////////////
 
 static bool exceeds_dist(const SkScalar p[], const SkScalar q[], SkScalar dist, int count)
 {
-       SkASSERT(dist > 0);
+    SkASSERT(dist > 0);
 
-       count *= 2;
-       for (int i = 0; i < count; i++)
-               if (SkScalarAbs(p[i] - q[i]) > dist)
-                       return true;
-       return false;
+    count *= 2;
+    for (int i = 0; i < count; i++)
+        if (SkScalarAbs(p[i] - q[i]) > dist)
+            return true;
+    return false;
 }
 
 static void subdivide_quad(SkPath* dst, const SkPoint pts[3], SkScalar dist, int subLevel = 4)
 {
-       if (--subLevel >= 0 && exceeds_dist(&pts[0].fX, &pts[1].fX, dist, 4))
-       {
-               SkPoint tmp[5];
-               SkChopQuadAtHalf(pts, tmp);
-
-               subdivide_quad(dst, &tmp[0], dist, subLevel);
-               subdivide_quad(dst, &tmp[2], dist, subLevel);
-       }
-       else
-               dst->quadTo(pts[1], pts[2]);
+    if (--subLevel >= 0 && exceeds_dist(&pts[0].fX, &pts[1].fX, dist, 4))
+    {
+        SkPoint tmp[5];
+        SkChopQuadAtHalf(pts, tmp);
+
+        subdivide_quad(dst, &tmp[0], dist, subLevel);
+        subdivide_quad(dst, &tmp[2], dist, subLevel);
+    }
+    else
+        dst->quadTo(pts[1], pts[2]);
 }
 
 static void subdivide_cubic(SkPath* dst, const SkPoint pts[4], SkScalar dist, int subLevel = 4)
 {
-       if (--subLevel >= 0 && exceeds_dist(&pts[0].fX, &pts[1].fX, dist, 6))
-       {
-               SkPoint tmp[7];
-               SkChopCubicAtHalf(pts, tmp);
-
-               subdivide_cubic(dst, &tmp[0], dist, subLevel);
-               subdivide_cubic(dst, &tmp[3], dist, subLevel);
-       }
-       else
-               dst->cubicTo(pts[1], pts[2], pts[3]);
+    if (--subLevel >= 0 && exceeds_dist(&pts[0].fX, &pts[1].fX, dist, 6))
+    {
+        SkPoint tmp[7];
+        SkChopCubicAtHalf(pts, tmp);
+
+        subdivide_cubic(dst, &tmp[0], dist, subLevel);
+        subdivide_cubic(dst, &tmp[3], dist, subLevel);
+    }
+    else
+        dst->cubicTo(pts[1], pts[2], pts[3]);
 }
 
 void SkPath::subdivide(SkScalar dist, bool bendLines, SkPath* dst) const
 {
-       SkPath  tmpPath;
-       if (nil == dst || this == dst)
-               dst = &tmpPath;
-
-       SkPath::Iter    iter(*this, false);
-       SkPoint                 pts[4];
-
-       for (;;)
-       {
-               switch (iter.next(pts)) {
-               case SkPath::kMove_Verb:
-                       dst->moveTo(pts[0]);
-                       break;
-               case SkPath::kLine_Verb:
-                       if (!bendLines)
-                       {
-                               dst->lineTo(pts[1]);
-                               break;
-                       }
-                       // construct a quad from the line
-                       pts[2] = pts[1];
-                       pts[1].set(SkScalarAve(pts[0].fX, pts[2].fX), SkScalarAve(pts[0].fY, pts[2].fY));
-                       // fall through to the quad case
-               case SkPath::kQuad_Verb:
-                       subdivide_quad(dst, pts, dist);
-                       break;
-               case SkPath::kCubic_Verb:
-                       subdivide_cubic(dst, pts, dist);
-                       break;
-               case SkPath::kClose_Verb:
-                       dst->close();
-                       break;
-               case SkPath::kDone_Verb:
-                       goto DONE;
-               }
-       }
+    SkPath  tmpPath;
+    if (nil == dst || this == dst)
+        dst = &tmpPath;
+
+    SkPath::Iter    iter(*this, false);
+    SkPoint         pts[4];
+
+    for (;;)
+    {
+        switch (iter.next(pts)) {
+        case SkPath::kMove_Verb:
+            dst->moveTo(pts[0]);
+            break;
+        case SkPath::kLine_Verb:
+            if (!bendLines)
+            {
+                dst->lineTo(pts[1]);
+                break;
+            }
+            // construct a quad from the line
+            pts[2] = pts[1];
+            pts[1].set(SkScalarAve(pts[0].fX, pts[2].fX), SkScalarAve(pts[0].fY, pts[2].fY));
+            // fall through to the quad case
+        case SkPath::kQuad_Verb:
+            subdivide_quad(dst, pts, dist);
+            break;
+        case SkPath::kCubic_Verb:
+            subdivide_cubic(dst, pts, dist);
+            break;
+        case SkPath::kClose_Verb:
+            dst->close();
+            break;
+        case SkPath::kDone_Verb:
+            goto DONE;
+        }
+    }
 DONE:
-       if (&tmpPath == dst)    // i.e. the dst should be us
-               dst->swap(*(SkPath*)this);
+    if (&tmpPath == dst)    // i.e. the dst should be us
+        dst->swap(*(SkPath*)this);
 }
 
 ///////////////////////////////////////////////////////////////////////
 /*
-       Format in flattened buffer: [ptCount, verbCount, pts[], verbs[]]
+    Format in flattened buffer: [ptCount, verbCount, pts[], verbs[]]
 */
 
 #include "SkBuffer.h"
 
 U32 SkPath::flatten(void* storage) const
 {
-       if (storage)
-       {
+    if (storage)
+    {
         SkWBuffer   buffer(storage);
         
         buffer.write32(fPts.count());
-               buffer.write32(fVerbs.count());
-               buffer.write32(fFillType);
-               buffer.write(fPts.begin(), sizeof(SkPoint) * fPts.count());
+        buffer.write32(fVerbs.count());
+        buffer.write32(fFillType);
+        buffer.write(fPts.begin(), sizeof(SkPoint) * fPts.count());
         buffer.write(fVerbs.begin(), fVerbs.count());
         buffer.padToAlign4();
-       }
-       return 3 * sizeof(int32_t) + sizeof(SkPoint) * fPts.count() + SkAlign4(fVerbs.count());
+    }
+    return 3 * sizeof(int32_t) + sizeof(SkPoint) * fPts.count() + SkAlign4(fVerbs.count());
 }
 
 void SkPath::unflatten(const void* storage)
@@ -989,114 +1062,114 @@ void SkPath::toString(SkString* str) const
 
 #ifdef SK_DEBUG
 
-#if 0  // test to ensure that the iterator returns the same data as the path
+#if 0   // test to ensure that the iterator returns the same data as the path
 void SkPath::test() const
 {
-       Iter    iter(*this, false);
-       SkPoint pts[4];
-       Verb    verb;
-
-       const U8*               verbs = fVerbs.begin();
-       const SkPoint*  points = fPts.begin();
-
-       while ((verb = iter.next(pts)) != kDone_Verb)
-       {
-               SkASSERT(*verbs == verb);
-               verbs += 1;
-
-               int count;
-               switch (verb) {
-               case kMove_Verb:
-                       count = 1;
-                       break;
-               case kLine_Verb:
-                       count = 2;
-                       break;
-               case kQuad_Verb:
-                       count = 3;
-                       break;
-               case kCubic_Verb:
-                       count = 4;
-                       break;
-               case kClose_Verb:
-               default:
-                       count = 0;
-                       break;
-               }
-               if (count > 1)
-                       points -= 1;
-               SkASSERT(memcmp(pts, points, count * sizeof(SkPoint)) == 0);
-               points += count;
-       }
-
-       int vc = fVerbs.count(), pc = fPts.count();
-       if (vc && fVerbs.begin()[vc-1] == kMove_Verb)
-       {
-               vc -= 1;
-               pc -= 1;
-       }
-       SkASSERT(verbs - fVerbs.begin() == vc);
-       SkASSERT(points - fPts.begin() == pc);
+    Iter    iter(*this, false);
+    SkPoint pts[4];
+    Verb    verb;
+
+    const U8*       verbs = fVerbs.begin();
+    const SkPoint*  points = fPts.begin();
+
+    while ((verb = iter.next(pts)) != kDone_Verb)
+    {
+        SkASSERT(*verbs == verb);
+        verbs += 1;
+
+        int count;
+        switch (verb) {
+        case kMove_Verb:
+            count = 1;
+            break;
+        case kLine_Verb:
+            count = 2;
+            break;
+        case kQuad_Verb:
+            count = 3;
+            break;
+        case kCubic_Verb:
+            count = 4;
+            break;
+        case kClose_Verb:
+        default:
+            count = 0;
+            break;
+        }
+        if (count > 1)
+            points -= 1;
+        SkASSERT(memcmp(pts, points, count * sizeof(SkPoint)) == 0);
+        points += count;
+    }
+
+    int vc = fVerbs.count(), pc = fPts.count();
+    if (vc && fVerbs.begin()[vc-1] == kMove_Verb)
+    {
+        vc -= 1;
+        pc -= 1;
+    }
+    SkASSERT(verbs - fVerbs.begin() == vc);
+    SkASSERT(points - fPts.begin() == pc);
 }
 #endif
 
 void SkPath::dump(bool forceClose, const char title[]) const
 {
-       Iter    iter(*this, forceClose);
-       SkPoint pts[4];
-       Verb    verb;
+    Iter    iter(*this, forceClose);
+    SkPoint pts[4];
+    Verb    verb;
 
-       SkDebugf("path: forceClose=%s %s\n", forceClose ? "true" : "false", title ? title : "");
+    SkDebugf("path: forceClose=%s %s\n", forceClose ? "true" : "false", title ? title : "");
 
-       while ((verb = iter.next(pts)) != kDone_Verb)
-       {
-               switch (verb) {
-               case kMove_Verb:
+    while ((verb = iter.next(pts)) != kDone_Verb)
+    {
+        switch (verb) {
+        case kMove_Verb:
 #ifdef SK_CAN_USE_FLOAT
-                       SkDebugf("  path: moveTo [%g %g]\n",
+            SkDebugf("  path: moveTo [%g %g]\n",
                     SkScalarToFloat(pts[0].fX), SkScalarToFloat(pts[0].fY));
 #else
-                       SkDebugf("  path: moveTo [%x %x]\n", pts[0].fX, pts[0].fY);
+            SkDebugf("  path: moveTo [%x %x]\n", pts[0].fX, pts[0].fY);
 #endif
-                       break;
-               case kLine_Verb:
+            break;
+        case kLine_Verb:
 #ifdef SK_CAN_USE_FLOAT
-                       SkDebugf("  path: lineTo [%g %g]\n",
+            SkDebugf("  path: lineTo [%g %g]\n",
                     SkScalarToFloat(pts[1].fX), SkScalarToFloat(pts[1].fY));
 #else
-                       SkDebugf("  path: lineTo [%x %x]\n", pts[1].fX, pts[1].fY);
+            SkDebugf("  path: lineTo [%x %x]\n", pts[1].fX, pts[1].fY);
 #endif
-                       break;
-               case kQuad_Verb:
+            break;
+        case kQuad_Verb:
 #ifdef SK_CAN_USE_FLOAT
-                       SkDebugf("  path: quadTo [%g %g] [%g %g]\n",
+            SkDebugf("  path: quadTo [%g %g] [%g %g]\n",
                     SkScalarToFloat(pts[1].fX), SkScalarToFloat(pts[1].fY),
                     SkScalarToFloat(pts[2].fX), SkScalarToFloat(pts[2].fY));
 #else
-                       SkDebugf("  path: quadTo [%x %x] [%x %x]\n", pts[1].fX, pts[1].fY, pts[2].fX, pts[2].fY);
+            SkDebugf("  path: quadTo [%x %x] [%x %x]\n", pts[1].fX, pts[1].fY, pts[2].fX, pts[2].fY);
 #endif
-                       break;
-               case kCubic_Verb:
+            break;
+        case kCubic_Verb:
 #ifdef SK_CAN_USE_FLOAT
-                       SkDebugf("  path: cubeTo [%g %g] [%g %g] [%g %g]\n",
+            SkDebugf("  path: cubeTo [%g %g] [%g %g] [%g %g]\n",
                     SkScalarToFloat(pts[1].fX), SkScalarToFloat(pts[1].fY),
                     SkScalarToFloat(pts[2].fX), SkScalarToFloat(pts[2].fY),
                     SkScalarToFloat(pts[3].fX), SkScalarToFloat(pts[3].fY));
 #else
-                       SkDebugf("  path: cubeTo [%x %x] [%x %x] [%x %x]\n",
+            SkDebugf("  path: cubeTo [%x %x] [%x %x] [%x %x]\n",
                     pts[1].fX, pts[1].fY, pts[2].fX, pts[2].fY, pts[3].fX, pts[3].fY);
 #endif
-                       break;
-               case kClose_Verb:
-                       SkDebugf("  path: close\n");
-                       break;
-               default:
-                       SkDebugf("  path: UNKNOWN VERB %d, aborting dump...\n", verb);
-                       verb = kDone_Verb;      // stop the loop
-                       break;
-               }
-       }
-       SkDebugf("path: done %s\n", title ? title : "");
+            break;
+        case kClose_Verb:
+            SkDebugf("  path: close\n");
+            break;
+        default:
+            SkDebugf("  path: UNKNOWN VERB %d, aborting dump...\n", verb);
+            verb = kDone_Verb;  // stop the loop
+            break;
+        }
+    }
+    SkDebugf("path: done %s\n", title ? title : "");
 }
 
 #include "SkTSort.h"
@@ -1104,35 +1177,35 @@ void SkPath::dump(bool forceClose, const char title[]) const
 void SkPath::UnitTest()
 {
 #ifdef SK_SUPPORT_UNITTEST
-       SkPath  p;
-       SkRect  r;
-
-       r.set(0, 0, 10, 20);
-       p.addRect(r);
-       p.dump(false);
-       p.dump(true);
-
-       {
-               int array[] = { 5, 3, 7, 2, 6, 1, 2, 9, 5, 0 };
-               int i;
-
-               for (i = 0; i < (int)SK_ARRAY_COUNT(array); i++)
-                       SkDebugf(" %d", array[i]);
-               SkDebugf("\n");
-               SkTHeapSort<int>(array, SK_ARRAY_COUNT(array));
-               for (i = 0; i < (int)SK_ARRAY_COUNT(array); i++)
-                       SkDebugf(" %d", array[i]);
-               SkDebugf("\n");
-       }
-
-       {
-               SkPath  p;
-               SkPoint pt;
-
-               p.moveTo(SK_Scalar1, 0);
-               p.getLastPt(&pt);
-               SkASSERT(pt.fX == SK_Scalar1);
-       }
+    SkPath  p;
+    SkRect  r;
+
+    r.set(0, 0, 10, 20);
+    p.addRect(r);
+    p.dump(false);
+    p.dump(true);
+
+    {
+        int array[] = { 5, 3, 7, 2, 6, 1, 2, 9, 5, 0 };
+        int i;
+
+        for (i = 0; i < (int)SK_ARRAY_COUNT(array); i++)
+            SkDebugf(" %d", array[i]);
+        SkDebugf("\n");
+        SkTHeapSort<int>(array, SK_ARRAY_COUNT(array));
+        for (i = 0; i < (int)SK_ARRAY_COUNT(array); i++)
+            SkDebugf(" %d", array[i]);
+        SkDebugf("\n");
+    }
+
+    {
+        SkPath  p;
+        SkPoint pt;
+
+        p.moveTo(SK_Scalar1, 0);
+        p.getLastPt(&pt);
+        SkASSERT(pt.fX == SK_Scalar1);
+    }
 #endif
 }
 
index cb09db1..1b33f65 100644 (file)
@@ -1,10 +1,27 @@
+/* libs/graphics/sgl/SkPathEffect.cpp
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #include "SkPathEffect.h"
 #include "SkPath.h"
 #include "SkBuffer.h"
 
 SkFlattenable::Factory SkFlattenable::getFactory()
 {
-       return NULL;
+    return NULL;
 }
 
 void SkFlattenable::flatten(SkWBuffer&)
@@ -15,38 +32,38 @@ void SkFlattenable::flatten(SkWBuffer&)
 
 bool SkPathEffect::filterPath(SkPath*, const SkPath&, SkScalar*)
 {
-       return false;
+    return false;
 }
 
 static SkFlattenable* create_null_patheffect(SkRBuffer&)
 {
-       return SkNEW(SkPathEffect);
+    return SkNEW(SkPathEffect);
 }
 
 SkFlattenable::Factory SkPathEffect::getFactory()
 {
-       return create_null_patheffect;
+    return create_null_patheffect;
 }
 
 //////////////////////////////////////////////////////////////////////////////////
 
 SkPairPathEffect::SkPairPathEffect(SkPathEffect* pe0, SkPathEffect* pe1)
-       : fPE0(pe0), fPE1(pe1)
+    : fPE0(pe0), fPE1(pe1)
 {
-       SkASSERT(pe0);
-       SkASSERT(pe1);
-       fPE0->ref();
-       fPE1->ref();
+    SkASSERT(pe0);
+    SkASSERT(pe1);
+    fPE0->ref();
+    fPE1->ref();
 }
 
 SkPairPathEffect::~SkPairPathEffect()
 {
-       fPE0->unref();
-       fPE1->unref();
+    fPE0->unref();
+    fPE1->unref();
 }
 
 /*
-       Format: [oe0-factory][pe1-factory][pe0-size][pe0-data][pe1-data]
+    Format: [oe0-factory][pe1-factory][pe0-size][pe0-data][pe1-data]
 */
 void SkPairPathEffect::flatten(SkWBuffer& buffer)
 {
@@ -60,49 +77,49 @@ SkPairPathEffect::SkPairPathEffect(SkRBuffer& buffer)
 {
     Factory factory0 = (Factory)buffer.readPtr();
     Factory factory1 = (Factory)buffer.readPtr();
-       
-       fPE0 = (SkPathEffect*)factory0(buffer);
-       fPE1 = (SkPathEffect*)factory1(buffer);
+    
+    fPE0 = (SkPathEffect*)factory0(buffer);
+    fPE1 = (SkPathEffect*)factory1(buffer);
 }
 
 //////////////////////////////////////////////////////////////////////////////////
 
 bool SkComposePathEffect::filterPath(SkPath* dst, const SkPath& src, SkScalar* width)
 {
-       SkPath                  tmp;
-       const SkPath*   ptr = &src;
+    SkPath          tmp;
+    const SkPath*   ptr = &src;
 
-       if (fPE1->filterPath(&tmp, src, width))
-               ptr = &tmp;
-       return fPE0->filterPath(dst, *ptr, width);
+    if (fPE1->filterPath(&tmp, src, width))
+        ptr = &tmp;
+    return fPE0->filterPath(dst, *ptr, width);
 }
 
 SkFlattenable* SkComposePathEffect::CreateProc(SkRBuffer& buffer)
 {
-       return SkNEW_ARGS(SkComposePathEffect, (buffer));
+    return SkNEW_ARGS(SkComposePathEffect, (buffer));
 }
 
 SkFlattenable::Factory SkComposePathEffect::getFactory()
 {
-       return SkComposePathEffect::CreateProc;
+    return SkComposePathEffect::CreateProc;
 }
 
 //////////////////////////////////////////////////////////////////////////////////
 
 bool SkSumPathEffect::filterPath(SkPath* dst, const SkPath& src, SkScalar* width)
 {
-       // use bit-or so that we always call both, even if the first one succeeds
-       return  fPE0->filterPath(dst, src, width) | fPE1->filterPath(dst, src, width);
+    // use bit-or so that we always call both, even if the first one succeeds
+    return  fPE0->filterPath(dst, src, width) | fPE1->filterPath(dst, src, width);
 }
 
 SkFlattenable* SkSumPathEffect::CreateProc(SkRBuffer& buffer)
 {
-       return SkNEW_ARGS(SkSumPathEffect, (buffer));
+    return SkNEW_ARGS(SkSumPathEffect, (buffer));
 }
 
 SkFlattenable::Factory SkSumPathEffect::getFactory()
 {
-       return SkSumPathEffect::CreateProc;
+    return SkSumPathEffect::CreateProc;
 }
 
 /////////////////////////////////////////////////////////////////////////////////
@@ -110,57 +127,57 @@ SkFlattenable::Factory SkSumPathEffect::getFactory()
 #include "SkStroke.h"
 
 SkStrokePathEffect::SkStrokePathEffect(const SkPaint& paint)
-       : fWidth(paint.getStrokeWidth()), fMiter(paint.getStrokeMiter()),
-         fStyle(SkToU8(paint.getStyle())), fJoin(SkToU8(paint.getStrokeJoin())), fCap(SkToU8(paint.getStrokeCap()))
+    : fWidth(paint.getStrokeWidth()), fMiter(paint.getStrokeMiter()),
+      fStyle(SkToU8(paint.getStyle())), fJoin(SkToU8(paint.getStrokeJoin())), fCap(SkToU8(paint.getStrokeCap()))
 {
 }
 
 SkStrokePathEffect::SkStrokePathEffect(SkScalar width, SkPaint::Style style, SkPaint::Join join, SkPaint::Cap cap, SkScalar miter)
-       : fWidth(width), fMiter(miter), fStyle(SkToU8(style)), fJoin(SkToU8(join)), fCap(SkToU8(cap))
+    : fWidth(width), fMiter(miter), fStyle(SkToU8(style)), fJoin(SkToU8(join)), fCap(SkToU8(cap))
 {
-       if (miter < 0)  // signal they want the default
-               fMiter = SK_DefaultMiterLimit;
+    if (miter < 0)  // signal they want the default
+        fMiter = SK_DefaultMiterLimit;
 }
 
 bool SkStrokePathEffect::filterPath(SkPath* dst, const SkPath& src, SkScalar* width)
 {
-       if (fWidth < 0 || fStyle == SkPaint::kFill_Style)
-               return false;
+    if (fWidth < 0 || fStyle == SkPaint::kFill_Style)
+        return false;
 
-       if (fStyle == SkPaint::kStroke_Style && fWidth == 0)    // hairline
-       {
-               *width = 0;
-               return true;
-       }
+    if (fStyle == SkPaint::kStroke_Style && fWidth == 0)    // hairline
+    {
+        *width = 0;
+        return true;
+    }
 
-       SkStroke        stroke;
+    SkStroke    stroke;
 
-       stroke.setWidth(fWidth);
-       stroke.setMiterLimit(fMiter);
-       stroke.setJoin((SkPaint::Join)fJoin);
-       stroke.setCap((SkPaint::Cap)fCap);
-       stroke.setDoFill(fStyle == SkPaint::kStrokeAndFill_Style);
+    stroke.setWidth(fWidth);
+    stroke.setMiterLimit(fMiter);
+    stroke.setJoin((SkPaint::Join)fJoin);
+    stroke.setCap((SkPaint::Cap)fCap);
+    stroke.setDoFill(fStyle == SkPaint::kStrokeAndFill_Style);
 
-       stroke.strokePath(src, dst);
-       return true;
+    stroke.strokePath(src, dst);
+    return true;
 }
 
 SkFlattenable::Factory SkStrokePathEffect::getFactory()
 {
-       return CreateProc;
+    return CreateProc;
 }
 
 SkFlattenable* SkStrokePathEffect::CreateProc(SkRBuffer& buffer)
 {
-       return SkNEW_ARGS(SkStrokePathEffect, (buffer));
+    return SkNEW_ARGS(SkStrokePathEffect, (buffer));
 }
 
 void SkStrokePathEffect::flatten(SkWBuffer& buffer)
 {
     this->INHERITED::flatten(buffer);
 
-       buffer.writeScalar(fWidth);
-       buffer.writeScalar(fMiter);
+    buffer.writeScalar(fWidth);
+    buffer.writeScalar(fMiter);
     buffer.write8(fStyle);
     buffer.write8(fJoin);
     buffer.write8(fCap);
@@ -168,7 +185,7 @@ void SkStrokePathEffect::flatten(SkWBuffer& buffer)
 }
 
 SkStrokePathEffect::SkStrokePathEffect(SkRBuffer& buffer)
-       : SkPathEffect(buffer)
+    : SkPathEffect(buffer)
 {
     fWidth = buffer.readScalar();
     fMiter = buffer.readScalar();
index 6191724..58cd34c 100644 (file)
@@ -1,3 +1,20 @@
+/* libs/graphics/sgl/SkPathMeasure.cpp
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #include "SkPathMeasure.h"
 #include "SkGeometry.h"
 #include "SkPath.h"
 
 // these must be 0,1,2 since they are in our 2-bit field
 enum {
-       kLine_SegType,
-       kCloseLine_SegType,
-       kQuad_SegType,
-       kCubic_SegType
+    kLine_SegType,
+    kCloseLine_SegType,
+    kQuad_SegType,
+    kCubic_SegType
 };
 
-#define kMaxTValue     32767
+#define kMaxTValue  32767
 
 static inline SkScalar tValue2Scalar(int t)
 {
-       SkASSERT((unsigned)t <= kMaxTValue);
+    SkASSERT((unsigned)t <= kMaxTValue);
 
 #ifdef SK_SCALAR_IS_FLOAT
-       return t * 3.05185e-5f; // t / 32767
+    return t * 3.05185e-5f; // t / 32767
 #else
-       return (t + (t >> 14)) << 1;
+    return (t + (t >> 14)) << 1;
 #endif
 }
 
 SkScalar SkPathMeasure::Segment::getScalarT() const
 {
-       return tValue2Scalar(fTValue);
+    return tValue2Scalar(fTValue);
 }
 
 const SkPathMeasure::Segment* SkPathMeasure::NextSegment(const Segment* seg)
 {
-       unsigned ptIndex = seg->fPtIndex;
+    unsigned ptIndex = seg->fPtIndex;
 
-       do {
-               ++seg;
-       } while (seg->fPtIndex == ptIndex);
-       return seg;
+    do {
+        ++seg;
+    } while (seg->fPtIndex == ptIndex);
+    return seg;
 }
 
 /////////////////////////////////////////////////////////////////////////////////
 
 static inline int tspan_big_enough(int tspan)
 {
-       SkASSERT((unsigned)tspan <= kMaxTValue);
-       return tspan >> 10;
+    SkASSERT((unsigned)tspan <= kMaxTValue);
+    return tspan >> 10;
 }
 
 #if 0
 static inline bool tangents_too_curvy(const SkVector& tan0, SkVector& tan1)
 {
-       static const SkScalar kFlatEnoughTangentDotProd = SK_Scalar1 * 99 / 100;
+    static const SkScalar kFlatEnoughTangentDotProd = SK_Scalar1 * 99 / 100;
 
-       SkASSERT(kFlatEnoughTangentDotProd > 0 && kFlatEnoughTangentDotProd < SK_Scalar1);
+    SkASSERT(kFlatEnoughTangentDotProd > 0 && kFlatEnoughTangentDotProd < SK_Scalar1);
 
-       return SkPoint::DotProduct(tan0, tan1) < kFlatEnoughTangentDotProd;
+    return SkPoint::DotProduct(tan0, tan1) < kFlatEnoughTangentDotProd;
 }
 #endif
 
 // can't use tangents, since we need [0..1..................2] to be seen
 // as definitely not a line (it is when drawn, but not parametrically)
 // so we compare midpoints
-#define CHEAP_DIST_LIMIT       (SK_Scalar1/2)  // just made this value up
+#define CHEAP_DIST_LIMIT    (SK_Scalar1/2)  // just made this value up
 
 static bool cheap_dist_exceeds_limit(const SkPoint& pt, SkScalar x, SkScalar y)
 {
-       SkScalar dist = SkMaxScalar(SkScalarAbs(x - pt.fX), SkScalarAbs(y - pt.fY));
-       // just made up the 1/2
-       return dist > CHEAP_DIST_LIMIT;
+    SkScalar dist = SkMaxScalar(SkScalarAbs(x - pt.fX), SkScalarAbs(y - pt.fY));
+    // just made up the 1/2
+    return dist > CHEAP_DIST_LIMIT;
 }
 
 static bool quad_too_curvy(const SkPoint pts[3])
 {
 #if 0
-       SkPoint         mid;
-       SkEvalQuadAtHalf(pts, &mid);
-       return cheap_dist_exceeds_limit(mid,
-                                                                       SkScalarAve(pts[0].fX, pts[2].fX),
-                                                                       SkScalarAve(pts[0].fY, pts[2].fY));
+    SkPoint     mid;
+    SkEvalQuadAtHalf(pts, &mid);
+    return cheap_dist_exceeds_limit(mid,
+                                    SkScalarAve(pts[0].fX, pts[2].fX),
+                                    SkScalarAve(pts[0].fY, pts[2].fY));
 #else
-       // diff = (a/4 + b/2 + c/4) - (a/2 + c/2)
-       // diff = -a/4 + b/2 - c/4
-       SkScalar dx = SkScalarHalf(pts[1].fX) - SkScalarHalf(SkScalarHalf(pts[0].fX + pts[2].fX));
-       SkScalar dy = SkScalarHalf(pts[1].fY) - SkScalarHalf(SkScalarHalf(pts[0].fY + pts[2].fY));
+    // diff = (a/4 + b/2 + c/4) - (a/2 + c/2)
+    // diff = -a/4 + b/2 - c/4
+    SkScalar dx = SkScalarHalf(pts[1].fX) - SkScalarHalf(SkScalarHalf(pts[0].fX + pts[2].fX));
+    SkScalar dy = SkScalarHalf(pts[1].fY) - SkScalarHalf(SkScalarHalf(pts[0].fY + pts[2].fY));
 
-       SkScalar dist = SkMaxScalar(SkScalarAbs(dx), SkScalarAbs(dy));
-       return dist > CHEAP_DIST_LIMIT;
+    SkScalar dist = SkMaxScalar(SkScalarAbs(dx), SkScalarAbs(dy));
+    return dist > CHEAP_DIST_LIMIT;
 #endif
 }
 
 static bool cubic_too_curvy(const SkPoint pts[4])
 {
-       SkPoint third;
-
-       // test 1/3
-       SkEvalCubicAt(pts, SK_Scalar1/3, &third, nil, nil);
-       if (cheap_dist_exceeds_limit(third,
-                                                                SkScalarInterp(pts[0].fX, pts[3].fX, SK_Scalar1/3),
-                                                                SkScalarInterp(pts[0].fY, pts[2].fY, SK_Scalar1/3)))
-               return true;
-
-       // test 2/3
-       SkEvalCubicAt(pts, SK_Scalar1*2/3, &third, nil, nil);
-       return cheap_dist_exceeds_limit(third,
-                                                                       SkScalarInterp(pts[0].fX, pts[3].fX, SK_Scalar1*2/3),
-                                                                       SkScalarInterp(pts[0].fY, pts[2].fY, SK_Scalar1*2/3));
+    SkPoint third;
+
+    // test 1/3
+    SkEvalCubicAt(pts, SK_Scalar1/3, &third, nil, nil);
+    if (cheap_dist_exceeds_limit(third,
+                                 SkScalarInterp(pts[0].fX, pts[3].fX, SK_Scalar1/3),
+                                 SkScalarInterp(pts[0].fY, pts[2].fY, SK_Scalar1/3)))
+        return true;
+
+    // test 2/3
+    SkEvalCubicAt(pts, SK_Scalar1*2/3, &third, nil, nil);
+    return cheap_dist_exceeds_limit(third,
+                                    SkScalarInterp(pts[0].fX, pts[3].fX, SK_Scalar1*2/3),
+                                    SkScalarInterp(pts[0].fY, pts[2].fY, SK_Scalar1*2/3));
 }
 
 SkScalar SkPathMeasure::compute_quad_segs(const SkPoint pts[3], SkScalar distance,
-                                                                                 int mint, int maxt, int ptIndex)
+                                          int mint, int maxt, int ptIndex)
 {
-       if (tspan_big_enough(maxt - mint) && quad_too_curvy(pts))
-       {
-               SkPoint tmp[5];
-               int             halft = (mint + maxt) >> 1;
-
-               SkChopQuadAtHalf(pts, tmp);
-               distance = this->compute_quad_segs(tmp, distance, mint, halft, ptIndex);
-               distance = this->compute_quad_segs(&tmp[2], distance, halft, maxt, ptIndex);
-       }
-       else
-       {
-               SkScalar d = SkPoint::Distance(pts[0], pts[2]);
-               SkASSERT(d >= 0);
-               if (!SkScalarNearlyZero(d))
-               {
-                       distance += d;
-                       Segment* seg = fSegments.append();
-                       seg->fDistance = distance;
-                       seg->fPtIndex = ptIndex;
-                       seg->fType = kQuad_SegType;
-                       seg->fTValue = maxt;
-               }
-       }
-       return distance;
+    if (tspan_big_enough(maxt - mint) && quad_too_curvy(pts))
+    {
+        SkPoint tmp[5];
+        int     halft = (mint + maxt) >> 1;
+
+        SkChopQuadAtHalf(pts, tmp);
+        distance = this->compute_quad_segs(tmp, distance, mint, halft, ptIndex);
+        distance = this->compute_quad_segs(&tmp[2], distance, halft, maxt, ptIndex);
+    }
+    else
+    {
+        SkScalar d = SkPoint::Distance(pts[0], pts[2]);
+        SkASSERT(d >= 0);
+        if (!SkScalarNearlyZero(d))
+        {
+            distance += d;
+            Segment* seg = fSegments.append();
+            seg->fDistance = distance;
+            seg->fPtIndex = ptIndex;
+            seg->fType = kQuad_SegType;
+            seg->fTValue = maxt;
+        }
+    }
+    return distance;
 }
 
 SkScalar SkPathMeasure::compute_cubic_segs(const SkPoint pts[4], SkScalar distance,
-                                                                                  int mint, int maxt, int ptIndex)
+                                           int mint, int maxt, int ptIndex)
 {
-       if (tspan_big_enough(maxt - mint) && cubic_too_curvy(pts))
-       {
-               SkPoint tmp[7];
-               int             halft = (mint + maxt) >> 1;
-
-               SkChopCubicAtHalf(pts, tmp);
-               distance = this->compute_cubic_segs(tmp, distance, mint, halft, ptIndex);
-               distance = this->compute_cubic_segs(&tmp[3], distance, halft, maxt, ptIndex);
-       }
-       else
-       {
-               SkScalar d = SkPoint::Distance(pts[0], pts[3]);
-               SkASSERT(d >= 0);
-               if (!SkScalarNearlyZero(d))
-               {
-                       distance += d;
-                       Segment* seg = fSegments.append();
-                       seg->fDistance = distance;
-                       seg->fPtIndex = ptIndex;
-                       seg->fType = kCubic_SegType;
-                       seg->fTValue = maxt;
-               }
-       }
-       return distance;
+    if (tspan_big_enough(maxt - mint) && cubic_too_curvy(pts))
+    {
+        SkPoint tmp[7];
+        int     halft = (mint + maxt) >> 1;
+
+        SkChopCubicAtHalf(pts, tmp);
+        distance = this->compute_cubic_segs(tmp, distance, mint, halft, ptIndex);
+        distance = this->compute_cubic_segs(&tmp[3], distance, halft, maxt, ptIndex);
+    }
+    else
+    {
+        SkScalar d = SkPoint::Distance(pts[0], pts[3]);
+        SkASSERT(d >= 0);
+        if (!SkScalarNearlyZero(d))
+        {
+            distance += d;
+            Segment* seg = fSegments.append();
+            seg->fDistance = distance;
+            seg->fPtIndex = ptIndex;
+            seg->fType = kCubic_SegType;
+            seg->fTValue = maxt;
+        }
+    }
+    return distance;
 }
 
 void SkPathMeasure::buildSegments()
 {
-       SkPoint                 pts[4];
-       int                             ptIndex = fFirstPtIndex;
-       SkScalar                d, distance = 0;
-       bool                    isClosed = fForceClosed;
-       bool                    firstMoveTo = ptIndex < 0;
-       Segment*                seg;
-
-       fSegments.reset();
-       for (;;)
-       {
-               switch (fIter.next(pts)) {
-               case SkPath::kMove_Verb:
-                       if (!firstMoveTo)
-                               goto DONE;
-                       ptIndex += 1;
-                       firstMoveTo = false;
-                       break;
-
-               case SkPath::kLine_Verb:
-                       d = SkPoint::Distance(pts[0], pts[1]);
-                       SkASSERT(d >= 0);
-                       if (!SkScalarNearlyZero(d))
-                       {
-                               distance += d;
-                               seg = fSegments.append();
-                               seg->fDistance = distance;
-                               seg->fPtIndex = ptIndex;
-                               seg->fType = fIter.isCloseLine() ? kCloseLine_SegType : kLine_SegType;
-                               seg->fTValue = kMaxTValue;
-                       }
-                       ptIndex += !fIter.isCloseLine();
-                       break;
-
-               case SkPath::kQuad_Verb:
-                       distance = this->compute_quad_segs(pts, distance, 0, kMaxTValue, ptIndex);
-                       ptIndex += 2;
-                       break;
-
-               case SkPath::kCubic_Verb:
-                       distance = this->compute_cubic_segs(pts, distance, 0, kMaxTValue, ptIndex);
-                       ptIndex += 3;
-                       break;
-
-               case SkPath::kClose_Verb:
-                       isClosed = true;
-                       break;
-                       
-               case SkPath::kDone_Verb:
-                       goto DONE;
-               }
-       }
+    SkPoint         pts[4];
+    int             ptIndex = fFirstPtIndex;
+    SkScalar        d, distance = 0;
+    bool            isClosed = fForceClosed;
+    bool            firstMoveTo = ptIndex < 0;
+    Segment*        seg;
+
+    fSegments.reset();
+    for (;;)
+    {
+        switch (fIter.next(pts)) {
+        case SkPath::kMove_Verb:
+            if (!firstMoveTo)
+                goto DONE;
+            ptIndex += 1;
+            firstMoveTo = false;
+            break;
+
+        case SkPath::kLine_Verb:
+            d = SkPoint::Distance(pts[0], pts[1]);
+            SkASSERT(d >= 0);
+            if (!SkScalarNearlyZero(d))
+            {
+                distance += d;
+                seg = fSegments.append();
+                seg->fDistance = distance;
+                seg->fPtIndex = ptIndex;
+                seg->fType = fIter.isCloseLine() ? kCloseLine_SegType : kLine_SegType;
+                seg->fTValue = kMaxTValue;
+            }
+            ptIndex += !fIter.isCloseLine();
+            break;
+
+        case SkPath::kQuad_Verb:
+            distance = this->compute_quad_segs(pts, distance, 0, kMaxTValue, ptIndex);
+            ptIndex += 2;
+            break;
+
+        case SkPath::kCubic_Verb:
+            distance = this->compute_cubic_segs(pts, distance, 0, kMaxTValue, ptIndex);
+            ptIndex += 3;
+            break;
+
+        case SkPath::kClose_Verb:
+            isClosed = true;
+            break;
+            
+        case SkPath::kDone_Verb:
+            goto DONE;
+        }
+    }
 DONE:
-       fLength = distance;
-       fIsClosed = isClosed;
-       fFirstPtIndex = ptIndex + 1;
+    fLength = distance;
+    fIsClosed = isClosed;
+    fFirstPtIndex = ptIndex + 1;
 
 #ifdef SK_DEBUG
-       {
-               const Segment* seg = fSegments.begin();
-               const Segment* stop = fSegments.end();
-               unsigned                ptIndex = 0;
-               SkScalar                distance = 0;
-
-               while (seg < stop)
-               {
-               //      SkDebugf("seg dist=%g t=%d p=%d\n", seg->fDistance, seg->fTValue, seg->fPtIndex);
-
-                       SkASSERT(seg->fDistance > distance);
-                       SkASSERT(seg->fPtIndex >= ptIndex);
-                       SkASSERT(seg->fTValue > 0);
-
-                       const Segment* s = seg;
-                       while (s < stop - 1 && s[0].fPtIndex == s[1].fPtIndex)
-                       {
-                               SkASSERT(s[0].fType == s[1].fType);
-                               SkASSERT(s[0].fTValue < s[1].fTValue);
-                               s += 1;
-                       }
-
-                       distance = seg->fDistance;
-                       ptIndex = seg->fPtIndex;
-                       seg += 1;
-               }
-       //      SkDebugf("\n");
-       }
+    {
+        const Segment* seg = fSegments.begin();
+        const Segment* stop = fSegments.end();
+        unsigned        ptIndex = 0;
+        SkScalar        distance = 0;
+
+        while (seg < stop)
+        {
+        //  SkDebugf("seg dist=%g t=%d p=%d\n", seg->fDistance, seg->fTValue, seg->fPtIndex);
+
+            SkASSERT(seg->fDistance > distance);
+            SkASSERT(seg->fPtIndex >= ptIndex);
+            SkASSERT(seg->fTValue > 0);
+
+            const Segment* s = seg;
+            while (s < stop - 1 && s[0].fPtIndex == s[1].fPtIndex)
+            {
+                SkASSERT(s[0].fType == s[1].fType);
+                SkASSERT(s[0].fTValue < s[1].fTValue);
+                s += 1;
+            }
+
+            distance = seg->fDistance;
+            ptIndex = seg->fPtIndex;
+            seg += 1;
+        }
+    //  SkDebugf("\n");
+    }
 #endif
 }
 
 // marked as a friend in SkPath.h
 const SkPoint* sk_get_path_points(const SkPath& path, int index)
 {
-       return &path.fPts[index];
+    return &path.fPts[index];
 }
 
 static void compute_pos_tan(const SkPath& path, int firstPtIndex, int ptIndex, int segType,
-                                                       SkScalar t, SkPoint* pos, SkVector* tangent)
+                            SkScalar t, SkPoint* pos, SkVector* tangent)
 {
-       const SkPoint*  pts = sk_get_path_points(path, ptIndex);
-
-       switch (segType) {
-       case kLine_SegType:
-       case kCloseLine_SegType:
-               {
-                       const SkPoint* endp = (segType == kLine_SegType) ?
-                                                                       &pts[1] :
-                                                                       sk_get_path_points(path, firstPtIndex);
-
-                       if (pos)
-                               pos->set(SkScalarInterp(pts[0].fX, endp->fX, t),
-                                               SkScalarInterp(pts[0].fY, endp->fY, t));
-                       if (tangent)
-                               tangent->setUnit(endp->fX - pts[0].fX, endp->fY - pts[0].fY);
-               }
-               break;
-       case kQuad_SegType:
-               SkEvalQuadAt(pts, t, pos, tangent);
-               if (tangent)
-                       tangent->normalize();
-               break;
-       case kCubic_SegType:
-               SkEvalCubicAt(pts, t, pos, tangent, nil);
-               if (tangent)
-                       tangent->normalize();
-               break;
-       default:
-               SkASSERT(!"unknown segType");
-       }
+    const SkPoint*  pts = sk_get_path_points(path, ptIndex);
+
+    switch (segType) {
+    case kLine_SegType:
+    case kCloseLine_SegType:
+        {
+            const SkPoint* endp = (segType == kLine_SegType) ?
+                                    &pts[1] :
+                                    sk_get_path_points(path, firstPtIndex);
+
+            if (pos)
+                pos->set(SkScalarInterp(pts[0].fX, endp->fX, t),
+                        SkScalarInterp(pts[0].fY, endp->fY, t));
+            if (tangent)
+                tangent->setUnit(endp->fX - pts[0].fX, endp->fY - pts[0].fY);
+        }
+        break;
+    case kQuad_SegType:
+        SkEvalQuadAt(pts, t, pos, tangent);
+        if (tangent)
+            tangent->normalize();
+        break;
+    case kCubic_SegType:
+        SkEvalCubicAt(pts, t, pos, tangent, nil);
+        if (tangent)
+            tangent->normalize();
+        break;
+    default:
+        SkASSERT(!"unknown segType");
+    }
 }
 
 static void seg_to(const SkPath& src, int firstPtIndex, int ptIndex, int segType, SkScalar startT, SkScalar stopT, SkPath* dst)
 {
-       SkASSERT(startT >= 0 && startT <= SK_Scalar1);
-       SkASSERT(stopT >= 0 && stopT <= SK_Scalar1);
-       SkASSERT(startT <= stopT);
-
-       if (SkScalarNearlyZero(stopT - startT))
-               return;
-
-       const SkPoint*  pts = sk_get_path_points(src, ptIndex);
-       SkPoint                 tmp0[7], tmp1[7];
-
-       switch (segType) {
-       case kLine_SegType:
-       case kCloseLine_SegType:
-               {
-                       const SkPoint* endp = (segType == kLine_SegType) ?
-                                                                       &pts[1] :
-                                                                       sk_get_path_points(src, firstPtIndex);
-
-                       if (stopT == kMaxTValue)
-                               dst->lineTo(*endp);
-                       else
-                               dst->lineTo(SkScalarInterp(pts[0].fX, endp->fX, stopT),
-                                                       SkScalarInterp(pts[0].fY, endp->fY, stopT));
-               }
-               break;
-       case kQuad_SegType:
-               if (startT == 0)
-               {
-                       if (stopT == SK_Scalar1)
-                               dst->quadTo(pts[1], pts[2]);
-                       else
-                       {
-                               SkChopQuadAt(pts, tmp0, stopT);
-                               dst->quadTo(tmp0[1], tmp0[2]);
-                       }
-               }
-               else
-               {
-                       SkChopQuadAt(pts, tmp0, startT);
-                       if (stopT == SK_Scalar1)
-                               dst->quadTo(tmp0[3], tmp0[4]);
-                       else
-                       {
-                               SkChopQuadAt(&tmp0[2], tmp1, SkScalarDiv(stopT - startT, SK_Scalar1 - startT));
-                               dst->quadTo(tmp1[1], tmp1[2]);
-                       }
-               }
-               break;
-       case kCubic_SegType:
-               if (startT == 0)
-               {
-                       if (stopT == SK_Scalar1)
-                               dst->cubicTo(pts[1], pts[2], pts[3]);
-                       else
-                       {
-                               SkChopCubicAt(pts, tmp0, stopT);
-                               dst->cubicTo(tmp0[1], tmp0[2], tmp0[3]);
-                       }
-               }
-               else
-               {
-                       SkChopCubicAt(pts, tmp0, startT);
-                       if (stopT == SK_Scalar1)
-                               dst->cubicTo(tmp0[4], tmp0[5], tmp0[6]);
-                       else
-                       {
-                               SkChopCubicAt(&tmp0[3], tmp1, SkScalarDiv(stopT - startT, SK_Scalar1 - startT));
-                               dst->cubicTo(tmp1[1], tmp1[2], tmp1[3]);
-                       }
-               }
-               break;
-       default:
-               SkASSERT(!"unknown segType");
-               sk_throw();
-       }
+    SkASSERT(startT >= 0 && startT <= SK_Scalar1);
+    SkASSERT(stopT >= 0 && stopT <= SK_Scalar1);
+    SkASSERT(startT <= stopT);
+
+    if (SkScalarNearlyZero(stopT - startT))
+        return;
+
+    const SkPoint*  pts = sk_get_path_points(src, ptIndex);
+    SkPoint         tmp0[7], tmp1[7];
+
+    switch (segType) {
+    case kLine_SegType:
+    case kCloseLine_SegType:
+        {
+            const SkPoint* endp = (segType == kLine_SegType) ?
+                                    &pts[1] :
+                                    sk_get_path_points(src, firstPtIndex);
+
+            if (stopT == kMaxTValue)
+                dst->lineTo(*endp);
+            else
+                dst->lineTo(SkScalarInterp(pts[0].fX, endp->fX, stopT),
+                            SkScalarInterp(pts[0].fY, endp->fY, stopT));
+        }
+        break;
+    case kQuad_SegType:
+        if (startT == 0)
+        {
+            if (stopT == SK_Scalar1)
+                dst->quadTo(pts[1], pts[2]);
+            else
+            {
+                SkChopQuadAt(pts, tmp0, stopT);
+                dst->quadTo(tmp0[1], tmp0[2]);
+            }
+        }
+        else
+        {
+            SkChopQuadAt(pts, tmp0, startT);
+            if (stopT == SK_Scalar1)
+                dst->quadTo(tmp0[3], tmp0[4]);
+            else
+            {
+                SkChopQuadAt(&tmp0[2], tmp1, SkScalarDiv(stopT - startT, SK_Scalar1 - startT));
+                dst->quadTo(tmp1[1], tmp1[2]);
+            }
+        }
+        break;
+    case kCubic_SegType:
+        if (startT == 0)
+        {
+            if (stopT == SK_Scalar1)
+                dst->cubicTo(pts[1], pts[2], pts[3]);
+            else
+            {
+                SkChopCubicAt(pts, tmp0, stopT);
+                dst->cubicTo(tmp0[1], tmp0[2], tmp0[3]);
+            }
+        }
+        else
+        {
+            SkChopCubicAt(pts, tmp0, startT);
+            if (stopT == SK_Scalar1)
+                dst->cubicTo(tmp0[4], tmp0[5], tmp0[6]);
+            else
+            {
+                SkChopCubicAt(&tmp0[3], tmp1, SkScalarDiv(stopT - startT, SK_Scalar1 - startT));
+                dst->cubicTo(tmp1[1], tmp1[2], tmp1[3]);
+            }
+        }
+        break;
+    default:
+        SkASSERT(!"unknown segType");
+        sk_throw();
+    }
 }
 
 ////////////////////////////////////////////////////////////////////////////////
@@ -380,20 +397,20 @@ static void seg_to(const SkPath& src, int firstPtIndex, int ptIndex, int segType
 
 SkPathMeasure::SkPathMeasure()
 {
-       fPath = nil;
-       fLength = -1;   // signal we need to compute it
-       fForceClosed = false;
-       fFirstPtIndex = -1;
+    fPath = nil;
+    fLength = -1;   // signal we need to compute it
+    fForceClosed = false;
+    fFirstPtIndex = -1;
 }
 
 SkPathMeasure::SkPathMeasure(const SkPath& path, bool forceClosed)
 {
-       fPath = &path;
-       fLength = -1;   // signal we need to compute it
-       fForceClosed = forceClosed;
-       fFirstPtIndex = -1;
+    fPath = &path;
+    fLength = -1;   // signal we need to compute it
+    fForceClosed = forceClosed;
+    fFirstPtIndex = -1;
 
-       fIter.setPath(path, forceClosed);
+    fIter.setPath(path, forceClosed);
 }
 
 SkPathMeasure::~SkPathMeasure()
@@ -404,165 +421,165 @@ SkPathMeasure::~SkPathMeasure()
 */
 void SkPathMeasure::setPath(const SkPath* path, bool forceClosed)
 {
-       fPath = path;
-       fLength = -1;   // signal we need to compute it
-       fForceClosed = forceClosed;
-       fFirstPtIndex = -1;
-
-       if (path)
-               fIter.setPath(*path, forceClosed);
-       fSegments.reset();
+    fPath = path;
+    fLength = -1;   // signal we need to compute it
+    fForceClosed = forceClosed;
+    fFirstPtIndex = -1;
+
+    if (path)
+        fIter.setPath(*path, forceClosed);
+    fSegments.reset();
 }
 
 SkScalar SkPathMeasure::getLength()
 {
-       if (fPath == nil)
-               return 0;
+    if (fPath == nil)
+        return 0;
 
-       if (fLength < 0)
-               this->buildSegments();
+    if (fLength < 0)
+        this->buildSegments();
 
-       SkASSERT(fLength >= 0);
-       return fLength;
+    SkASSERT(fLength >= 0);
+    return fLength;
 }
 
 const SkPathMeasure::Segment* SkPathMeasure::distanceToSegment(SkScalar distance, SkScalar* t)
 {
-       SkDEBUGCODE(SkScalar length = ) this->getLength();
-       SkASSERT(distance >= 0 && distance <= length);
-
-       const Segment*  seg = fSegments.begin();
-       int                             count = fSegments.count();
-
-       int index = SkTSearch<SkScalar>(&seg->fDistance, count, distance, sizeof(Segment));
-       // don't care if we hit an exact match or not, so we xor index if it is negative
-       index ^= (index >> 31);
-       seg = &seg[index];
-
-       // now interpolate t-values with the prev segment (if possible)
-       SkScalar        startT = 0, startD = 0;
-       // check if the prev segment is legal, and references the same set of points
-       if (index > 0)
-       {
-               startD = seg[-1].fDistance;
-               if (seg[-1].fPtIndex == seg->fPtIndex)
-               {
-                       SkASSERT(seg[-1].fType == seg->fType);
-                       startT = seg[-1].getScalarT();
-               }
-       }
-
-       SkASSERT(seg->getScalarT() > startT);
-       SkASSERT(distance >= startD);
-       SkASSERT(seg->fDistance > startD);
-
-       *t = startT + SkScalarMulDiv(seg->getScalarT() - startT,
-                                                                distance - startD,
-                                                                seg->fDistance - startD);
-       return seg;
+    SkDEBUGCODE(SkScalar length = ) this->getLength();
+    SkASSERT(distance >= 0 && distance <= length);
+
+    const Segment*  seg = fSegments.begin();
+    int             count = fSegments.count();
+
+    int index = SkTSearch<SkScalar>(&seg->fDistance, count, distance, sizeof(Segment));
+    // don't care if we hit an exact match or not, so we xor index if it is negative
+    index ^= (index >> 31);
+    seg = &seg[index];
+
+    // now interpolate t-values with the prev segment (if possible)
+    SkScalar    startT = 0, startD = 0;
+    // check if the prev segment is legal, and references the same set of points
+    if (index > 0)
+    {
+        startD = seg[-1].fDistance;
+        if (seg[-1].fPtIndex == seg->fPtIndex)
+        {
+            SkASSERT(seg[-1].fType == seg->fType);
+            startT = seg[-1].getScalarT();
+        }
+    }
+
+    SkASSERT(seg->getScalarT() > startT);
+    SkASSERT(distance >= startD);
+    SkASSERT(seg->fDistance > startD);
+
+    *t = startT + SkScalarMulDiv(seg->getScalarT() - startT,
+                                 distance - startD,
+                                 seg->fDistance - startD);
+    return seg;
 }
 
 bool SkPathMeasure::getPosTan(SkScalar distance, SkPoint* pos, SkVector* tangent)
 {
-       SkASSERT(fPath);
-       if (fPath == nil)
-       {
-       EMPTY:
-               return false;
-       }
-
-       SkScalar        length = this->getLength();     // call this to force computing it
-       int                     count = fSegments.count();
-
-       if (count == 0 || length == 0)
-               goto EMPTY;
-
-       // pin the distance to a legal range
-       if (distance < 0)
-               distance = 0;
-       else if (distance > length)
-               distance = length;
-
-       SkScalar                t;
-       const Segment*  seg = this->distanceToSegment(distance, &t);
-
-       compute_pos_tan(*fPath, fSegments[0].fPtIndex, seg->fPtIndex, seg->fType, t, pos, tangent);
-       return true;
+    SkASSERT(fPath);
+    if (fPath == nil)
+    {
+    EMPTY:
+        return false;
+    }
+
+    SkScalar    length = this->getLength(); // call this to force computing it
+    int         count = fSegments.count();
+
+    if (count == 0 || length == 0)
+        goto EMPTY;
+
+    // pin the distance to a legal range
+    if (distance < 0)
+        distance = 0;
+    else if (distance > length)
+        distance = length;
+
+    SkScalar        t;
+    const Segment*  seg = this->distanceToSegment(distance, &t);
+
+    compute_pos_tan(*fPath, fSegments[0].fPtIndex, seg->fPtIndex, seg->fType, t, pos, tangent);
+    return true;
 }
 
 bool SkPathMeasure::getMatrix(SkScalar distance, SkMatrix* matrix, MatrixFlags flags)
 {
-       SkPoint         position;
-       SkVector        tangent;
-
-       if (this->getPosTan(distance, &position, &tangent))
-       {
-               if (matrix)
-               {
-                       if (flags & kGetTangent_MatrixFlag)
-                               matrix->setSinCos(tangent.fY, tangent.fX, 0, 0);
-                       else
-                               matrix->reset();
-                       if (flags & kGetPosition_MatrixFlag)
-                               matrix->postTranslate(position.fX, position.fY);
-               }
-               return true;
-       }
-       return false;
+    SkPoint     position;
+    SkVector    tangent;
+
+    if (this->getPosTan(distance, &position, &tangent))
+    {
+        if (matrix)
+        {
+            if (flags & kGetTangent_MatrixFlag)
+                matrix->setSinCos(tangent.fY, tangent.fX, 0, 0);
+            else
+                matrix->reset();
+            if (flags & kGetPosition_MatrixFlag)
+                matrix->postTranslate(position.fX, position.fY);
+        }
+        return true;
+    }
+    return false;
 }
 
 bool SkPathMeasure::getSegment(SkScalar startD, SkScalar stopD, SkPath* dst, bool startWithMoveTo)
 {
-       SkASSERT(dst);
-
-       SkScalar length = this->getLength();    // ensure we have built our segments
-
-       if (startD < 0)
-               startD = 0;
-       if (stopD > length)
-               stopD = length;
-       if (startD >= stopD)
-               return false;
-
-       SkPoint  p;
-       SkScalar startT, stopT;
-       const Segment* seg = this->distanceToSegment(startD, &startT);
-       const Segment* stopSeg = this->distanceToSegment(stopD, &stopT);
-       SkASSERT(seg <= stopSeg);
-
-       if (startWithMoveTo)
-       {
-               compute_pos_tan(*fPath, fSegments[0].fPtIndex, seg->fPtIndex, seg->fType, startT, &p, nil);
-               dst->moveTo(p);
-       }
-
-       if (seg->fPtIndex == stopSeg->fPtIndex)
-               seg_to(*fPath, fSegments[0].fPtIndex, seg->fPtIndex, seg->fType, startT, stopT, dst);
-       else
-       {
-               do {
-                       seg_to(*fPath, fSegments[0].fPtIndex, seg->fPtIndex, seg->fType, startT, SK_Scalar1, dst);
-                       seg = SkPathMeasure::NextSegment(seg);
-                       startT = 0;
-               } while (seg->fPtIndex < stopSeg->fPtIndex);
-               seg_to(*fPath, fSegments[0].fPtIndex, seg->fPtIndex, seg->fType, 0, stopT, dst);
-       }
-       return true;
+    SkASSERT(dst);
+
+    SkScalar length = this->getLength();    // ensure we have built our segments
+
+    if (startD < 0)
+        startD = 0;
+    if (stopD > length)
+        stopD = length;
+    if (startD >= stopD)
+        return false;
+
+    SkPoint  p;
+    SkScalar startT, stopT;
+    const Segment* seg = this->distanceToSegment(startD, &startT);
+    const Segment* stopSeg = this->distanceToSegment(stopD, &stopT);
+    SkASSERT(seg <= stopSeg);
+
+    if (startWithMoveTo)
+    {
+        compute_pos_tan(*fPath, fSegments[0].fPtIndex, seg->fPtIndex, seg->fType, startT, &p, nil);
+        dst->moveTo(p);
+    }
+
+    if (seg->fPtIndex == stopSeg->fPtIndex)
+        seg_to(*fPath, fSegments[0].fPtIndex, seg->fPtIndex, seg->fType, startT, stopT, dst);
+    else
+    {
+        do {
+            seg_to(*fPath, fSegments[0].fPtIndex, seg->fPtIndex, seg->fType, startT, SK_Scalar1, dst);
+            seg = SkPathMeasure::NextSegment(seg);
+            startT = 0;
+        } while (seg->fPtIndex < stopSeg->fPtIndex);
+        seg_to(*fPath, fSegments[0].fPtIndex, seg->fPtIndex, seg->fType, 0, stopT, dst);
+    }
+    return true;
 }
 
 bool SkPathMeasure::isClosed()
 {
-       (void)this->getLength();
-       return fIsClosed;
+    (void)this->getLength();
+    return fIsClosed;
 }
 
-/**    Move to the next contour in the path. Return true if one exists, or false if
-       we're done with the path.
+/** Move to the next contour in the path. Return true if one exists, or false if
+    we're done with the path.
 */
 bool SkPathMeasure::nextContour()
 {
-       fLength = -1;
-       return this->getLength() > 0;
+    fLength = -1;
+    return this->getLength() > 0;
 }
 
 ////////////////////////////////////////////////////////////////////////////////////////
@@ -572,51 +589,51 @@ bool SkPathMeasure::nextContour()
 
 void SkPathMeasure::dump()
 {
-       SkDebugf("pathmeas: length=%g, segs=%d\n", fLength, fSegments.count());
-
-       for (int i = 0; i < fSegments.count(); i++)
-       {
-               const Segment* seg = &fSegments[i];
-               SkDebugf("pathmeas: seg[%d] distance=%g, point=%d, t=%g, type=%d\n",
-                               i, seg->fDistance, seg->fPtIndex, seg->getScalarT(), seg->fType);
-       }
+    SkDebugf("pathmeas: length=%g, segs=%d\n", fLength, fSegments.count());
+
+    for (int i = 0; i < fSegments.count(); i++)
+    {
+        const Segment* seg = &fSegments[i];
+        SkDebugf("pathmeas: seg[%d] distance=%g, point=%d, t=%g, type=%d\n",
+                i, seg->fDistance, seg->fPtIndex, seg->getScalarT(), seg->fType);
+    }
 }
 
 void SkPathMeasure::UnitTest()
 {
 #ifdef SK_SUPPORT_UNITTEST
-       SkPath  path;
-
-       path.moveTo(0, 0);
-       path.lineTo(SK_Scalar1, 0);
-       path.lineTo(SK_Scalar1, SK_Scalar1);
-       path.lineTo(0, SK_Scalar1);
-
-       SkPathMeasure   meas(path, true);
-       SkScalar                length = meas.getLength();
-       SkASSERT(length == SK_Scalar1*4);
-
-       path.reset();
-       path.moveTo(0, 0);
-       path.lineTo(SK_Scalar1*3, SK_Scalar1*4);
-       meas.setPath(&path, false);
-       length = meas.getLength();
-       SkASSERT(length == SK_Scalar1*5);
-
-       path.reset();
-       path.addCircle(0, 0, SK_Scalar1);
-       meas.setPath(&path, true);
-       length = meas.getLength();
-       SkDebugf("circle arc-length = %g\n", length);
-
-       for (int i = 0; i < 8; i++)
-       {
-               SkScalar        d = length * i / 8;
-               SkPoint         p;
-               SkVector        v;
-               meas.getPosTan(d, &p, &v);
-               SkDebugf("circle arc-length=%g, pos[%g %g] tan[%g %g]\n", d, p.fX, p.fY, v.fX, v.fY);
-       }
+    SkPath  path;
+
+    path.moveTo(0, 0);
+    path.lineTo(SK_Scalar1, 0);
+    path.lineTo(SK_Scalar1, SK_Scalar1);
+    path.lineTo(0, SK_Scalar1);
+
+    SkPathMeasure   meas(path, true);
+    SkScalar        length = meas.getLength();
+    SkASSERT(length == SK_Scalar1*4);
+
+    path.reset();
+    path.moveTo(0, 0);
+    path.lineTo(SK_Scalar1*3, SK_Scalar1*4);
+    meas.setPath(&path, false);
+    length = meas.getLength();
+    SkASSERT(length == SK_Scalar1*5);
+
+    path.reset();
+    path.addCircle(0, 0, SK_Scalar1);
+    meas.setPath(&path, true);
+    length = meas.getLength();
+    SkDebugf("circle arc-length = %g\n", length);
+
+    for (int i = 0; i < 8; i++)
+    {
+        SkScalar    d = length * i / 8;
+        SkPoint     p;
+        SkVector    v;
+        meas.getPosTan(d, &p, &v);
+        SkDebugf("circle arc-length=%g, pos[%g %g] tan[%g %g]\n", d, p.fX, p.fY, v.fX, v.fY);
+    }
 #endif
 }
 
index 9f0592f..c07fead 100644 (file)
@@ -1,38 +1,55 @@
-#if 0  // experimental
+/* libs/graphics/sgl/SkProcSpriteBlitter.cpp
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
+#if 0   // experimental
 
 class SkProcSpriteBlitter : public SkSpriteBlitter {
 public:
-       typedef void (*Proc)(void* dst, const void* src, int count, const U32 ctable[]);
-
-       SkProcSpriteBlitter(const SkBitmap& source, Proc proc, unsigned srcShift, unsigned dstShift)
-               : SkSpriteBlitter(source), fProc(proc), fSrcShift(SkToU8(srcShift)), fDstShift(SkToU8(dstShift)) {}
-
-       virtual void blitRect(int x, int y, int width, int height)
-       {
-               size_t          dstRB = fDevice.rowBytes();
-               size_t          srcRB = fSource.rowBytes();
-               char*           dst = (char*)fDevice.getPixels() + y * dstRB + (x << fDstShift);
-               const char*     src = (const char*)fSource.getPixels() + (y - fTop) * srcRB + ((x - fLeft) << fSrcShift);
-               Proc            proc = fProc;
-               const U32*      ctable = nil;
-
-               if fSource.getColorTable())
-                       ctable = fSource.getColorTable()->lockColors();
-
-               while (--height >= 0)
-               {
-                       proc(dst, src, width, ctable);
-                       dst += dstRB;
-                       src += srcRB;
-               }
-
-               if fSource.getColorTable())
-                       fSource.getColorTable()->unlockColors(false);
-       }
+    typedef void (*Proc)(void* dst, const void* src, int count, const U32 ctable[]);
+
+    SkProcSpriteBlitter(const SkBitmap& source, Proc proc, unsigned srcShift, unsigned dstShift)
+        : SkSpriteBlitter(source), fProc(proc), fSrcShift(SkToU8(srcShift)), fDstShift(SkToU8(dstShift)) {}
+
+    virtual void blitRect(int x, int y, int width, int height)
+    {
+        size_t      dstRB = fDevice.rowBytes();
+        size_t      srcRB = fSource.rowBytes();
+        char*       dst = (char*)fDevice.getPixels() + y * dstRB + (x << fDstShift);
+        const char* src = (const char*)fSource.getPixels() + (y - fTop) * srcRB + ((x - fLeft) << fSrcShift);
+        Proc        proc = fProc;
+        const U32*  ctable = nil;
+
+        if fSource.getColorTable())
+            ctable = fSource.getColorTable()->lockColors();
+
+        while (--height >= 0)
+        {
+            proc(dst, src, width, ctable);
+            dst += dstRB;
+            src += srcRB;
+        }
+
+        if fSource.getColorTable())
+            fSource.getColorTable()->unlockColors(false);
+    }
 
 private:
-       Proc    fProc;
-       U8              fSrcShift, fDstShift;
+    Proc    fProc;
+    U8      fSrcShift, fDstShift;
 };
 
 #endif
index 5e3dc99..36a4f1c 100644 (file)
@@ -1,3 +1,20 @@
+/* libs/graphics/sgl/SkRasterizer.cpp
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #include "SkRasterizer.h"
 #include "SkDraw.h"
 #include "SkMaskFilter.h"
index 7c3d59c..974fb68 100644 (file)
@@ -1,36 +1,53 @@
+/* libs/graphics/sgl/SkRefCnt.cpp
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #include "SkRefCnt.h"
 
 SkAutoUnref::~SkAutoUnref()
 {
-       if (fObj)
-               fObj->unref();
+    if (fObj)
+        fObj->unref();
 }
 
 bool SkAutoUnref::ref()
 {
-       if (fObj)
-       {
-               fObj->ref();
-               return true;
-       }
-       return false;
+    if (fObj)
+    {
+        fObj->ref();
+        return true;
+    }
+    return false;
 }
 
 bool SkAutoUnref::unref()
 {
-       if (fObj)
-       {
-               fObj->unref();
-               fObj = nil;
-               return true;
-       }
-       return false;
+    if (fObj)
+    {
+        fObj->unref();
+        fObj = nil;
+        return true;
+    }
+    return false;
 }
 
 SkRefCnt* SkAutoUnref::detach()
 {
-       SkRefCnt* obj = fObj;
+    SkRefCnt* obj = fObj;
 
-       fObj = nil;
-       return obj;
+    fObj = nil;
+    return obj;
 }
index ab45c8f..3942eb2 100644 (file)
@@ -1,3 +1,20 @@
+/* libs/graphics/sgl/SkRegion_path.cpp
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #include "SkRegionPriv.h"
 #include "SkBlitter.h"
 #include "SkScan.h"
 
 class SkRgnBuilder : public SkBlitter {
 public:
-       virtual ~SkRgnBuilder();
-       
-       void    init(int maxHeight, int maxTransitions);
-       void    done() { (void)this->collapsWithPrev(); }
+    virtual ~SkRgnBuilder();
+    
+    void    init(int maxHeight, int maxTransitions);
+    void    done()
+    {
+        if (fCurrScanline != NULL)
+        {
+            fCurrScanline->fXCount = SkToS16((int)(fCurrXPtr - fCurrScanline->firstX()));
+            if (!this->collapsWithPrev()) // flush the last line
+                fCurrScanline = fCurrScanline->nextScanline();
+        }
+    }
 
-       int             computeRunCount() const;
-       void    copyToRect(SkRect16*) const;
-       void    copyToRgn(S16 runs[]) const;
+    int     computeRunCount() const;
+    void    copyToRect(SkRect16*) const;
+    void    copyToRgn(S16 runs[]) const;
 
-       virtual void blitH(int x, int y, int width);
+    virtual void blitH(int x, int y, int width);
 
 #ifdef SK_DEBUG
-       void dump() const
-       {
-               SkDebugf("SkRgnBuilder: Top = %d\n", fTop);
-               const Scanline* line = (Scanline*)fStorage;
-               while (line < fCurrScanline)
-               {
-                       SkDebugf("SkRgnBuilder::Scanline: LastY=%d, fXCount=%d", line->fLastY, line->fXCount);
-                       for (int i = 0; i < line->fXCount; i++)
-                               SkDebugf(" %d", line->firstX()[i]);
-                       SkDebugf("\n");
-
-                       line = line->nextScanline();
-               }
-       }
+    void dump() const
+    {
+        SkDebugf("SkRgnBuilder: Top = %d\n", fTop);
+        const Scanline* line = (Scanline*)fStorage;
+        while (line < fCurrScanline)
+        {
+            SkDebugf("SkRgnBuilder::Scanline: LastY=%d, fXCount=%d", line->fLastY, line->fXCount);
+            for (int i = 0; i < line->fXCount; i++)
+                SkDebugf(" %d", line->firstX()[i]);
+            SkDebugf("\n");
+
+            line = line->nextScanline();
+        }
+    }
 #endif
 private:
-       struct Scanline {
-               S16     fLastY;
-               S16     fXCount;
-
-               S16*            firstX() const { return (S16*)(this + 1); }
-               Scanline*       nextScanline() const { return (Scanline*)((S16*)(this + 1) + fXCount); }
-       };
-       S16*            fStorage;
-       Scanline*       fCurrScanline;
-       Scanline*       fPrevScanline;
-       S16*            fCurrXPtr;              //      points at next avialable x[] in fCurrScanline
-       S16                     fTop;                   // first Y value
-
-       bool collapsWithPrev()
-       {
-               if (fPrevScanline != nil &&
-                       fPrevScanline->fLastY + 1 == fCurrScanline->fLastY &&
-                       fPrevScanline->fXCount == fCurrScanline->fXCount &&
-                       !memcmp(fPrevScanline->firstX(),
-                                       fCurrScanline->firstX(),
-                                       fCurrScanline->fXCount * sizeof(S16)))
-               {
-                       // update the height of fPrevScanline
-                       fPrevScanline->fLastY = fCurrScanline->fLastY;
-                       return true;
-               }
-               return false;
-       }
+    struct Scanline {
+        S16 fLastY;
+        S16 fXCount;
+
+        S16*        firstX() const { return (S16*)(this + 1); }
+        Scanline*   nextScanline() const { return (Scanline*)((S16*)(this + 1) + fXCount); }
+    };
+    S16*        fStorage;
+    Scanline*   fCurrScanline;
+    Scanline*   fPrevScanline;
+    S16*        fCurrXPtr;      //  points at next avialable x[] in fCurrScanline
+    S16         fTop;           // first Y value
+
+    bool collapsWithPrev()
+    {
+        if (fPrevScanline != nil &&
+            fPrevScanline->fLastY + 1 == fCurrScanline->fLastY &&
+            fPrevScanline->fXCount == fCurrScanline->fXCount &&
+            !memcmp(fPrevScanline->firstX(),
+                    fCurrScanline->firstX(),
+                    fCurrScanline->fXCount * sizeof(S16)))
+        {
+            // update the height of fPrevScanline
+            fPrevScanline->fLastY = fCurrScanline->fLastY;
+            return true;
+        }
+        return false;
+    }
 };
 
 SkRgnBuilder::~SkRgnBuilder()
 {
-       sk_free(fStorage);
+    sk_free(fStorage);
 }
 
 void SkRgnBuilder::init(int maxHeight, int maxTransitions)
 {
-       int     count = maxHeight * (3 + maxTransitions);
+    int count = maxHeight * (3 + maxTransitions);
 
-       // add maxTransitions to have slop for working buffer
-       fStorage = (S16*)sk_malloc_throw((count + 3 + maxTransitions) * sizeof(S16));
+    // add maxTransitions to have slop for working buffer
+    fStorage = (S16*)sk_malloc_throw((count + 3 + maxTransitions) * sizeof(S16));
 
-       fCurrScanline = nil;    // signal empty collection
-       fPrevScanline = nil;    // signal first scanline
+    fCurrScanline = nil;    // signal empty collection
+    fPrevScanline = nil;    // signal first scanline
 }
 
 void SkRgnBuilder::blitH(int x, int y, int width)
 {
-       if (fCurrScanline == nil)       // first time
-       {
-               fTop = SkToS16(y);
-               fCurrScanline = (Scanline*)fStorage;
-               fCurrScanline->fLastY = SkToS16(y);
-               fCurrXPtr = fCurrScanline->firstX();
-       }
-       else
-       {
-               SkASSERT(y >= fCurrScanline->fLastY);
-
-               if (y > fCurrScanline->fLastY)
-               {
-                       // if we get here, we're done with fCurrScanline
-                       fCurrScanline->fXCount = SkToS16((int)(fCurrXPtr - fCurrScanline->firstX()));
-
-                       int     prevLastY = fCurrScanline->fLastY;
-                       if (!this->collapsWithPrev())
-                       {
-                               fPrevScanline = fCurrScanline;
-                               fCurrScanline = fCurrScanline->nextScanline();
-
-                       }
-                       if (y - 1 > prevLastY)  // insert empty run
-                       {
-                               fCurrScanline->fLastY = SkToS16(y - 1);
-                               fCurrScanline->fXCount = 0;
-                               fCurrScanline = fCurrScanline->nextScanline();
-                       }
-                       // setup for the new curr line
-                       fCurrScanline->fLastY = SkToS16(y);
-                       fCurrXPtr = fCurrScanline->firstX();
-               }
-       }
-       //      check if we should extend the current run, or add a new one
-       if (fCurrXPtr > fCurrScanline->firstX() && fCurrXPtr[-1] == x)
-               fCurrXPtr[-1] = SkToS16(x + width);
-       else
-       {
-               fCurrXPtr[0] = SkToS16(x);
-               fCurrXPtr[1] = SkToS16(x + width);
-               fCurrXPtr += 2;
-       }
+    if (fCurrScanline == nil)   // first time
+    {
+        fTop = SkToS16(y);
+        fCurrScanline = (Scanline*)fStorage;
+        fCurrScanline->fLastY = SkToS16(y);
+        fCurrXPtr = fCurrScanline->firstX();
+    }
+    else
+    {
+        SkASSERT(y >= fCurrScanline->fLastY);
+
+        if (y > fCurrScanline->fLastY)
+        {
+            // if we get here, we're done with fCurrScanline
+            fCurrScanline->fXCount = SkToS16((int)(fCurrXPtr - fCurrScanline->firstX()));
+
+            int prevLastY = fCurrScanline->fLastY;
+            if (!this->collapsWithPrev())
+            {
+                fPrevScanline = fCurrScanline;
+                fCurrScanline = fCurrScanline->nextScanline();
+
+            }
+            if (y - 1 > prevLastY)  // insert empty run
+            {
+                fCurrScanline->fLastY = SkToS16(y - 1);
+                fCurrScanline->fXCount = 0;
+                fCurrScanline = fCurrScanline->nextScanline();
+            }
+            // setup for the new curr line
+            fCurrScanline->fLastY = SkToS16(y);
+            fCurrXPtr = fCurrScanline->firstX();
+        }
+    }
+    //  check if we should extend the current run, or add a new one
+    if (fCurrXPtr > fCurrScanline->firstX() && fCurrXPtr[-1] == x)
+        fCurrXPtr[-1] = SkToS16(x + width);
+    else
+    {
+        fCurrXPtr[0] = SkToS16(x);
+        fCurrXPtr[1] = SkToS16(x + width);
+        fCurrXPtr += 2;
+    }
 }
 
 int SkRgnBuilder::computeRunCount() const
 {
-       if (fCurrScanline == nil)
-               return 0;
+    if (fCurrScanline == nil)
+        return 0;
 
-       const S16*      line = fStorage;
-       const S16*      stop = (const S16*)fCurrScanline;
+    const S16*  line = fStorage;
+    const S16*  stop = (const S16*)fCurrScanline;
 
-       return 2 + (int)(stop - line);
+    return 2 + (int)(stop - line);
 }
 
 void SkRgnBuilder::copyToRect(SkRect16* r) const
 {
-       SkASSERT(fCurrScanline != nil);
-       SkASSERT((const S16*)fCurrScanline - fStorage == 4);
+    SkASSERT(fCurrScanline != nil);
+    SkASSERT((const S16*)fCurrScanline - fStorage == 4);
 
-       const Scanline* line = (const Scanline*)fStorage;
-       SkASSERT(line->fXCount == 2);
+    const Scanline* line = (const Scanline*)fStorage;
+    SkASSERT(line->fXCount == 2);
 
-       r->set(line->firstX()[0], fTop, line->firstX()[1], line->fLastY + 1);
+    r->set(line->firstX()[0], fTop, line->firstX()[1], line->fLastY + 1);
 }
 
 void SkRgnBuilder::copyToRgn(S16 runs[]) const
 {
-       SkASSERT(fCurrScanline != nil);
-       SkASSERT((const S16*)fCurrScanline - fStorage > 4);
-
-       const Scanline* line = (const Scanline*)fStorage;
-       const Scanline* stop = fCurrScanline;
-
-       *runs++ = fTop;
-       do {
-               *runs++ = SkToS16(line->fLastY + 1);
-               int     count = line->fXCount;
-               if (count)
-               {
-                       memcpy(runs, line->firstX(), count * sizeof(S16));
-                       runs += count;
-               }
-               *runs++ = kRunTypeSentinel;
-               line = line->nextScanline();
-       } while (line < stop);
-       SkASSERT(line == stop);
-       *runs = kRunTypeSentinel;
+    SkASSERT(fCurrScanline != nil);
+    SkASSERT((const S16*)fCurrScanline - fStorage > 4);
+
+    const Scanline* line = (const Scanline*)fStorage;
+    const Scanline* stop = fCurrScanline;
+
+    *runs++ = fTop;
+    do {
+        *runs++ = SkToS16(line->fLastY + 1);
+        int count = line->fXCount;
+        if (count)
+        {
+            memcpy(runs, line->firstX(), count * sizeof(S16));
+            runs += count;
+        }
+        *runs++ = kRunTypeSentinel;
+        line = line->nextScanline();
+    } while (line < stop);
+    SkASSERT(line == stop);
+    *runs = kRunTypeSentinel;
 }
 
 static int count_path_runtype_values(const SkPath& path, int* itop, int* ibot)
 {
-       static const U8 gPathVerbToInitialPointCount[] = {
-               0,      //      kMove_Verb
-               1,      //      kLine_Verb
-               2,      //      kQuad_Verb
-               3,      //      kCubic_Verb
-               0,      //      kClose_Verb
-               0       //      kDone_Verb
-       };
-
-       static const U8 gPathVerbToMaxEdges[] = {
-               0,      //      kMove_Verb
-               1,      //      kLine_Verb
-               2,      //      kQuad_VerbB
-               3,      //      kCubic_Verb
-               0,      //      kClose_Verb
-               0       //      kDone_Verb
-       };
-
-       SkPath::Iter    iter(path, true);
-       SkPoint                 pts[4];
-       SkPath::Verb    verb;
-
-       int     maxEdges = 0;
-       SkScalar        top = SkIntToScalar(SK_MaxS16);
-       SkScalar        bot = SkIntToScalar(SK_MinS16);
-
-       while ((verb = iter.next(pts)) != SkPath::kDone_Verb)
-       {
-               int     ptCount = gPathVerbToInitialPointCount[verb];
-               if (ptCount)
-               {
-                       maxEdges += gPathVerbToMaxEdges[verb];
-                       for (int i = ptCount - 1; i >= 0; --i)
-                       {
-                               if (top > pts[i].fY)
-                                       top = pts[i].fY;
-                               else if (bot < pts[i].fY)
-                                       bot = pts[i].fY;
-                       }
-               }
-       }
-       SkASSERT(top <= bot);
-
-       *itop = SkScalarRound(top);
-       *ibot = SkScalarRound(bot);
-       return maxEdges;
+    static const U8 gPathVerbToInitialPointCount[] = {
+        0,  //  kMove_Verb
+        1,  //  kLine_Verb
+        2,  //  kQuad_Verb
+        3,  //  kCubic_Verb
+        0,  //  kClose_Verb
+        0   //  kDone_Verb
+    };
+
+    static const U8 gPathVerbToMaxEdges[] = {
+        0,  //  kMove_Verb
+        1,  //  kLine_Verb
+        2,  //  kQuad_VerbB
+        3,  //  kCubic_Verb
+        0,  //  kClose_Verb
+        0   //  kDone_Verb
+    };
+
+    SkPath::Iter    iter(path, true);
+    SkPoint         pts[4];
+    SkPath::Verb    verb;
+
+    int maxEdges = 0;
+    SkScalar    top = SkIntToScalar(SK_MaxS16);
+    SkScalar    bot = SkIntToScalar(SK_MinS16);
+
+    while ((verb = iter.next(pts)) != SkPath::kDone_Verb)
+    {
+        int ptCount = gPathVerbToInitialPointCount[verb];
+        if (ptCount)
+        {
+            maxEdges += gPathVerbToMaxEdges[verb];
+            for (int i = ptCount - 1; i >= 0; --i)
+            {
+                if (top > pts[i].fY)
+                    top = pts[i].fY;
+                else if (bot < pts[i].fY)
+                    bot = pts[i].fY;
+            }
+        }
+    }
+    SkASSERT(top <= bot);
+
+    *itop = SkScalarRound(top);
+    *ibot = SkScalarRound(bot);
+    return maxEdges;
 }
 
 bool SkRegion::setPath(const SkPath& path, const SkRegion* clip)
 {
-       SkDEBUGCODE(this->validate();)
+    SkDEBUGCODE(this->validate();)
 
-       if (path.isEmpty() || clip && clip->isEmpty())
-               return this->setEmpty();
+    if (path.isEmpty() || clip && clip->isEmpty())
+        return this->setEmpty();
 
-       //      compute worst-case rgn-size for the path
-       int     pathTop, pathBot;
-       int     pathTransitions = count_path_runtype_values(path, &pathTop, &pathBot);
-       int     clipTop, clipBot;
-       int clipTransitions = clip->count_runtype_values(&clipTop, &clipBot);
+    //  compute worst-case rgn-size for the path
+    int pathTop, pathBot;
+    int pathTransitions = count_path_runtype_values(path, &pathTop, &pathBot);
+    int clipTop, clipBot;
+    int clipTransitions = clip->count_runtype_values(&clipTop, &clipBot);
 
-       int     top = SkMax32(pathTop, clipTop);
-       int bot = SkMin32(pathBot, clipBot);
+    int top = SkMax32(pathTop, clipTop);
+    int bot = SkMin32(pathBot, clipBot);
 
-       if (top >= bot)
-               return this->setEmpty();
+    if (top >= bot)
+        return this->setEmpty();
 
-       SkRgnBuilder builder;
-       
-       builder.init(bot - top, SkMax32(pathTransitions, clipTransitions));
-       SkScan::FillPath(path, clip, &builder);
-       builder.done();
+    SkRgnBuilder builder;
+    
+    builder.init(bot - top, SkMax32(pathTransitions, clipTransitions));
+    SkScan::FillPath(path, clip, &builder);
+    builder.done();
 
-       int     count = builder.computeRunCount();
-       if (count == 0)
+    int count = builder.computeRunCount();
+    if (count == 0)
     {
-               return this->setEmpty();
+        return this->setEmpty();
     }
-       else if (count == kRectRegionRuns)
-       {
-               builder.copyToRect(&fBounds);
+    else if (count == kRectRegionRuns)
+    {
+        builder.copyToRect(&fBounds);
         this->setRect(fBounds);
-       }
-       else
-       {
-               SkRegion        tmp;
-
-               tmp.fRunHead = RunHead::Alloc(count);
-               builder.copyToRgn(tmp.fRunHead->runs());
-               compute_run_bounds(tmp.fRunHead->runs(), count, &tmp.fBounds);
-               this->swap(tmp);
-       }
-       SkDEBUGCODE(this->validate();)
-       return true;
+    }
+    else
+    {
+        SkRegion    tmp;
+
+        tmp.fRunHead = RunHead::Alloc(count);
+        builder.copyToRgn(tmp.fRunHead->runs());
+        compute_run_bounds(tmp.fRunHead->runs(), count, &tmp.fBounds);
+        this->swap(tmp);
+    }
+    SkDEBUGCODE(this->validate();)
+    return true;
 }
 
 /////////////////////////////////////////////////////////////////////////////////////////////////
index 9e44bdc..8e296ea 100644 (file)
@@ -1,3 +1,20 @@
+/* libs/graphics/sgl/SkScalerContext.cpp
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #include "SkScalerContext.h"
 #include "SkDescriptor.h"
 #include "SkDraw.h"
 #include "SkStroke.h"
 #include "SkThread.h"
 
-#define ComputeBWRowBytes(width)               (((unsigned)(width) + 7) >> 3)
+#define ComputeBWRowBytes(width)        (((unsigned)(width) + 7) >> 3)
 
 static uint16_t compute_rowbytes(unsigned format, unsigned width)
 {
-       if (format == SkMask::kBW_Format)
-               width = ComputeBWRowBytes(width);
-       return SkToU16(width);
+    if (format == SkMask::kBW_Format)
+        width = ComputeBWRowBytes(width);
+    return SkToU16(width);
+}
+
+static void glyph2mask(const SkGlyph& glyph, SkMask* mask)
+{
+    SkASSERT(&glyph && mask);
+
+    mask->fImage = (uint8_t*)glyph.fImage;
+    mask->fBounds.set(glyph.fLeft, glyph.fTop,
+                    glyph.fLeft + glyph.fWidth,
+                    glyph.fTop + glyph.fHeight);
+    mask->fRowBytes = glyph.fRowBytes;
+    mask->fFormat = glyph.fMaskFormat;
 }
 
 size_t SkGlyph::computeImageSize() const
 {
-       size_t size = fRowBytes * fHeight;
-       if (fMaskFormat == SkMask::k3D_Format)
-               size *= 3;
-       return size;
+    size_t size = fRowBytes * fHeight;
+    if (fMaskFormat == SkMask::k3D_Format)
+        size *= 3;
+    return size;
 }
 
 #ifdef SK_DEBUG
-       #define DUMP_RECx
+    #define DUMP_RECx
 #endif
 
 static SkFlattenable* load_flattenable(const SkDescriptor* desc, uint32_t tag)
 {
     SkFlattenable*  obj = NULL;
     uint32_t        len;
-       const void*     data = desc->findEntry(tag, &len);
+    const void*     data = desc->findEntry(tag, &len);
 
-       if (data)
-       {
+    if (data)
+    {
         SkRBuffer   buffer(data, len);
-               SkFlattenable::Factory fact = (SkFlattenable::Factory)buffer.readPtr();
-               SkASSERT(fact);
-               obj = fact(buffer);
+        SkFlattenable::Factory fact = (SkFlattenable::Factory)buffer.readPtr();
+        SkASSERT(fact);
+        obj = fact(buffer);
         SkASSERT(buffer.pos() == buffer.size());
-       }
+    }
     return obj;
 }
 
 SkScalerContext::SkScalerContext(const SkDescriptor* desc)
-       : fPathEffect(NULL), fMaskFilter(NULL)
+    : fPathEffect(NULL), fMaskFilter(NULL)
 {
-    memset(fAuxContext, 0, sizeof(fAuxContext));
+    fBaseGlyphCount = 0;
+    fAuxScalerContext = NULL;
 
-       const Rec* rec = (const Rec*)desc->findEntry(kRec_SkDescriptorTag, NULL);
-       SkASSERT(rec);
+    const Rec* rec = (const Rec*)desc->findEntry(kRec_SkDescriptorTag, NULL);
+    SkASSERT(rec);
 
-       fRec = *rec;
+    fRec = *rec;
 
 #ifdef DUMP_REC
-       desc->assertChecksum();
-       SkDebugf("SkScalarContext checksum %x count %d length %d\n", desc->getChecksum(), desc->getCount(), desc->getLength());
-       SkDebugf(" textsize %g prescale %g preskew %g post [%g %g %g %g]\n",
-               rec->fTextSize, rec->fPreScaleX, rec->fPreSkewX, rec->fPost2x2[0][0],
-               rec->fPost2x2[0][1], rec->fPost2x2[1][0], rec->fPost2x2[1][1]);
-       SkDebugf("  frame %g miter %g hints %d framefill %d aa %d join %d\n",
-               rec->fFrameWidth, rec->fMiterLimit, rec->fUseHints, rec->fFrameAndFill,
-               rec->fDoAA, rec->fStrokeJoin);
-       SkDebugf("  pathEffect %x maskFilter %x\n", desc->findEntry(kPathEffect_SkDescriptorTag, NULL),
-               desc->findEntry(kMaskFilter_SkDescriptorTag, NULL));
+    desc->assertChecksum();
+    SkDebugf("SkScalarContext checksum %x count %d length %d\n", desc->getChecksum(), desc->getCount(), desc->getLength());
+    SkDebugf(" textsize %g prescale %g preskew %g post [%g %g %g %g]\n",
+        rec->fTextSize, rec->fPreScaleX, rec->fPreSkewX, rec->fPost2x2[0][0],
+        rec->fPost2x2[0][1], rec->fPost2x2[1][0], rec->fPost2x2[1][1]);
+    SkDebugf("  frame %g miter %g hints %d framefill %d format %d join %d\n",
+        rec->fFrameWidth, rec->fMiterLimit, rec->fHints, rec->fFrameAndFill,
+        rec->fMaskFormat, rec->fStrokeJoin);
+    SkDebugf("  pathEffect %x maskFilter %x\n", desc->findEntry(kPathEffect_SkDescriptorTag, NULL),
+        desc->findEntry(kMaskFilter_SkDescriptorTag, NULL));
 #endif
 
     fPathEffect = (SkPathEffect*)load_flattenable(desc, kPathEffect_SkDescriptorTag);
@@ -77,54 +107,81 @@ SkScalerContext::SkScalerContext(const SkDescriptor* desc)
 
 SkScalerContext::~SkScalerContext()
 {
-       fPathEffect->safeUnref();
-       fMaskFilter->safeUnref();
+    fPathEffect->safeUnref();
+    fMaskFilter->safeUnref();
     fRasterizer->safeUnref();
-    
-    for (unsigned i = 0; i < SK_ARRAY_COUNT(fAuxContext); i++)
-        delete fAuxContext[i];
+
+    SkDELETE(fAuxScalerContext);
 }
 
-static void glyph2mask(const SkGlyph& glyph, SkMask* mask)
+SkScalerContext* SkScalerContext::loadAuxContext() const
 {
-       SkASSERT(&glyph && mask);
-
-       mask->fImage = (uint8_t*)glyph.fImage;
-       mask->fBounds.set(glyph.fLeft, glyph.fTop,
-                                       glyph.fLeft + glyph.fWidth,
-                                       glyph.fTop + glyph.fHeight);
-       mask->fRowBytes = glyph.fRowBytes;
-       mask->fFormat = glyph.fMaskFormat;
+    if (NULL == fAuxScalerContext)
+    {
+        fAuxScalerContext = SkFontHost::CreateFallbackScalerContext(fRec);
+        if (NULL != fAuxScalerContext)
+            fAuxScalerContext->setBaseGlyphCount(this->getGlyphCount());
+    }
+    return fAuxScalerContext;
 }
 
-void SkScalerContext::getMetrics(SkGlyph* glyph)
+uint16_t SkScalerContext::charToGlyphID(SkUnichar uni)
 {
-    this->generateMetrics(glyph);
-    // assume that we're handling this glyph
-    glyph->fUseAuxContext = false;
-    
-    if (0 == glyph->fGlyphID)
+    unsigned glyphID = this->generateCharToGlyph(uni);
+
+    if (0 == glyphID)   // try auxcontext
     {
-        SkFontHost::ScalerContextID id = SkFontHost::FindScalerContextIDForUnichar(glyph->fCharCode);
-        if (SK_UnknownAuxScalerContextID != id)
+        unsigned base = this->getGlyphCount();
+
+        SkScalerContext* ctx = this->loadAuxContext();
+        if (NULL == ctx)
+            return 0;
+        
+        glyphID = ctx->generateCharToGlyph(uni);
+        if (0 != glyphID)   // only fiddle with it if its not missing
         {
-            SkASSERT(id > 0 && (unsigned)id <= SK_ARRAY_COUNT(fAuxContext));
-            SkScalerContext* ctx = fAuxContext[id - 1];
-            if (NULL == ctx)
-            {
-                ctx = SkFontHost::CreateScalerContextFromID(id, fRec);
-                SkASSERT(ctx);
-                fAuxContext[id - 1] = ctx;
-            }
-            ctx->generateMetrics(glyph);
-            glyph->fUseAuxContext = true;
+            glyphID += base;
+            if (glyphID > 0xFFFF)
+                glyphID = 0;
         }
     }
+    return SkToU16(glyphID);
+}
+
+/*  Internal routine to resolve auxContextID into a real context.
+    Only makes sense to call once the glyph has been given a
+    valid auxGlyphID.
+*/
+SkScalerContext* SkScalerContext::getGlyphContext(const SkGlyph& glyph) const
+{
+    SkScalerContext* ctx = const_cast<SkScalerContext*>(this);
+    
+    if (glyph.f_GlyphID >= this->getGlyphCount())
+    {
+        ctx = this->loadAuxContext();
+        if (NULL == ctx)    // if no aux, just return us
+            ctx = const_cast<SkScalerContext*>(this);
+    }
+    return ctx;
+}
+
+void SkScalerContext::getMetrics(SkGlyph* glyph)
+{
+    this->getGlyphContext(*glyph)->generateMetrics(glyph);
 
-       if (0 == glyph->fWidth)
-               return;
+    // if either dimensin is empty, zap the image bounds of the glyph
+    if (0 == glyph->fWidth || 0 == glyph->fHeight)
+    {
+        glyph->fWidth   = 0;
+        glyph->fHeight  = 0;
+        glyph->fTop     = 0;
+        glyph->fLeft    = 0;
+        glyph->fRowBytes = 0;
+        glyph->fMaskFormat = 0;
+        return;
+    }
     
-       if (fRec.fFrameWidth > 0 || fPathEffect != NULL || fRasterizer != NULL)
+    if (fRec.fFrameWidth > 0 || fPathEffect != NULL || fRasterizer != NULL)
     {
         SkPath      devPath, fillPath;
         SkMatrix    fillToDevMatrix;
@@ -139,58 +196,58 @@ void SkScalerContext::getMetrics(SkGlyph* glyph)
                                        fMaskFilter, &mask,
                                        SkMask::kJustComputeBounds_CreateMode))
             {
-                glyph->fLeft   = mask.fBounds.fLeft;
-                glyph->fTop            = mask.fBounds.fTop;
-                glyph->fWidth  = SkToU16(mask.fBounds.width());
-                glyph->fHeight = SkToU16(mask.fBounds.height());
+                glyph->fLeft    = mask.fBounds.fLeft;
+                glyph->fTop     = mask.fBounds.fTop;
+                glyph->fWidth   = SkToU16(mask.fBounds.width());
+                glyph->fHeight  = SkToU16(mask.fBounds.height());
             }
             else    // draw nothing 'cause we failed
             {
-                glyph->fLeft   = 0;
-                glyph->fTop            = 0;
-                glyph->fWidth  = 0;
-                glyph->fHeight = 0;
+                glyph->fLeft    = 0;
+                glyph->fTop     = 0;
+                glyph->fWidth   = 0;
+                glyph->fHeight  = 0;
                 return;
             }
         }
         else    // just use devPath
         {
-            SkRect             r;
-            SkRect16   ir;
+            SkRect      r;
+            SkRect16    ir;
 
             devPath.computeBounds(&r, SkPath::kExact_BoundsType);
             r.roundOut(&ir);
             
-            glyph->fLeft       = ir.fLeft;
-            glyph->fTop                = ir.fTop;
-            glyph->fWidth      = SkToU16(ir.width());
-            glyph->fHeight     = SkToU16(ir.height());
+            glyph->fLeft    = ir.fLeft;
+            glyph->fTop     = ir.fTop;
+            glyph->fWidth   = SkToU16(ir.width());
+            glyph->fHeight  = SkToU16(ir.height());
+        }
+    }
+
+    glyph->fMaskFormat = fRec.fMaskFormat;
+
+    if (fMaskFilter)
+    {
+        SkMask      src, dst;
+        SkMatrix    matrix;
+
+        glyph2mask(*glyph, &src);
+        fRec.getMatrixFrom2x2(&matrix);
+
+        src.fImage = NULL;  // only want the bounds from the filter
+        if (fMaskFilter->filterMask(&dst, src, matrix, NULL))
+        {
+            SkASSERT(dst.fImage == NULL);
+            glyph->fLeft    = dst.fBounds.fLeft;
+            glyph->fTop     = dst.fBounds.fTop;
+            glyph->fWidth   = SkToU16(dst.fBounds.width());
+            glyph->fHeight  = SkToU16(dst.fBounds.height());
+            glyph->fMaskFormat = dst.fFormat;
         }
     }
 
-       glyph->fMaskFormat = SkToU8(fRec.fDoAA ? SkMask::kA8_Format : SkMask::kBW_Format);
-
-       if (fMaskFilter)
-       {
-               SkMask          src, dst;
-               SkMatrix        matrix;
-
-               glyph2mask(*glyph, &src);
-               fRec.getMatrixFrom2x2(&matrix);
-
-               src.fImage = NULL;      // only want the bounds from the filter
-               if (fMaskFilter->filterMask(&dst, src, matrix, NULL))
-               {
-                       SkASSERT(dst.fImage == NULL);
-                       glyph->fLeft    = dst.fBounds.fLeft;
-                       glyph->fTop             = dst.fBounds.fTop;
-                       glyph->fWidth   = SkToU16(dst.fBounds.width());
-                       glyph->fHeight  = SkToU16(dst.fBounds.height());
-                       glyph->fMaskFormat = dst.fFormat;
-               }
-       }
-
-       glyph->fRowBytes = compute_rowbytes(glyph->fMaskFormat, glyph->fWidth);
+    glyph->fRowBytes = compute_rowbytes(glyph->fMaskFormat, glyph->fWidth);
 }
 
 //#define PLAY_WITH_GAMMA
@@ -203,11 +260,11 @@ static SkFixed interp(SkFixed a, SkFixed b, int scale)  // scale is [0..255]
 
 static void filter_image(uint8_t image[], size_t size)
 {
-       static uint8_t gGammaTable[256];
+    static uint8_t gGammaTable[256];
     static bool gInit;
 
-       if (!gInit)
-       {
+    if (!gInit)
+    {
         for (int i = 0; i < 256; i++)
         {
             SkFixed n = i * 257;
@@ -218,11 +275,11 @@ static void filter_image(uint8_t image[], size_t size)
             n = interp(SkFixedMul(n, n), n, 0xDD);
 
             n = n * 255 >> 16;
-        //     SkDebugf("morph %d -> %d\n", i, n);
+        //  SkDebugf("morph %d -> %d\n", i, n);
             gGammaTable[i] = SkToU8(n);
         }
         gInit = true;
-       }
+    }
     
     const uint8_t*   table = gGammaTable;
     uint8_t*         stop = image + size;
@@ -236,28 +293,28 @@ static void filter_image(uint8_t image[], size_t size)
 
 void SkScalerContext::getImage(const SkGlyph& origGlyph)
 {
-       const SkGlyph*  glyph = &origGlyph;
+    const SkGlyph*  glyph = &origGlyph;
 
-       SkGlyph tmpGlyph;
-       if (fMaskFilter)        // restore the prefilter bounds
-       {
-               tmpGlyph.fCharCode = origGlyph.fCharCode;
+    SkGlyph tmpGlyph;
+    if (fMaskFilter)    // restore the prefilter bounds
+    {
+        tmpGlyph.f_GlyphID = origGlyph.f_GlyphID;
 
-               // need the original bounds, sans our maskfilter
-               SkMaskFilter* mf = fMaskFilter;
-               fMaskFilter = NULL;                             // temp disable
-               this->getMetrics(&tmpGlyph);
-               fMaskFilter = mf;                               // restore
+        // need the original bounds, sans our maskfilter
+        SkMaskFilter* mf = fMaskFilter;
+        fMaskFilter = NULL;             // temp disable
+        this->getMetrics(&tmpGlyph);
+        fMaskFilter = mf;               // restore
 
-               tmpGlyph.fImage = origGlyph.fImage;
+        tmpGlyph.fImage = origGlyph.fImage;
 
-               // we need the prefilter bounds to be <= filter bounds
-               SkASSERT(tmpGlyph.fWidth <= origGlyph.fWidth);
-               SkASSERT(tmpGlyph.fHeight <= origGlyph.fHeight);
-               glyph = &tmpGlyph;
-       }
+        // we need the prefilter bounds to be <= filter bounds
+        SkASSERT(tmpGlyph.fWidth <= origGlyph.fWidth);
+        SkASSERT(tmpGlyph.fHeight <= origGlyph.fHeight);
+        glyph = &tmpGlyph;
+    }
 
-       if (fRec.fFrameWidth > 0 || fPathEffect != NULL || fRasterizer != NULL)
+    if (fRec.fFrameWidth > 0 || fPathEffect != NULL || fRasterizer != NULL)
     {
         SkPath      devPath, fillPath;
         SkMatrix    fillToDevMatrix;
@@ -285,20 +342,21 @@ void SkScalerContext::getImage(const SkGlyph& origGlyph)
         }
         else
         {
-            SkBitmap   bm;
+            SkBitmap    bm;
             SkBitmap::Config config;
-            SkMatrix   matrix;
-            SkRegion   clip;
-            SkPaint            paint;
-            SkDraw             draw;
+            SkMatrix    matrix;
+            SkRegion    clip;
+            SkPaint     paint;
+            SkDraw      draw;
 
-            if (fRec.fDoAA)
+            if (SkMask::kA8_Format == fRec.fMaskFormat)
             {
                 config = SkBitmap::kA8_Config;
                 paint.setAntiAliasOn(true);
             }
             else
             {
+                SkASSERT(SkMask::kBW_Format == fRec.fMaskFormat);
                 config = SkBitmap::kA1_Config;
                 paint.setAntiAliasOn(false);
             }
@@ -309,37 +367,29 @@ void SkScalerContext::getImage(const SkGlyph& origGlyph)
             bm.setPixels(glyph->fImage);
             memset(glyph->fImage, 0, bm.height() * bm.rowBytes());
 
-            draw.fClip = &clip;
+            draw.fClip  = &clip;
             draw.fMatrix = &matrix;
             draw.fDevice = &bm;
             draw.fBounder = NULL;
             draw.drawPath(devPath, paint);
         }
     }
-       else
+    else
     {
-        SkScalerContext* ctx = this;
-        if (glyph->fUseAuxContext)
-        {
-            SkFontHost::ScalerContextID id = SkFontHost::FindScalerContextIDForUnichar(glyph->fCharCode);
-            SkASSERT(id > 0 && (unsigned)id <= SK_ARRAY_COUNT(fAuxContext));
-            ctx = fAuxContext[id - 1];
-            SkASSERT(ctx);
-        }
-        ctx->generateImage(*glyph);
+        this->getGlyphContext(*glyph)->generateImage(*glyph);
     }
 
-       if (fMaskFilter)
-       {
-               SkMask          srcM, dstM;
-               SkMatrix        matrix;
+    if (fMaskFilter)
+    {
+        SkMask      srcM, dstM;
+        SkMatrix    matrix;
 
-               SkASSERT(SkMask::k3D_Format != glyph->fMaskFormat);     // the src glyph image shouldn't be 3D
-               glyph2mask(*glyph, &srcM);
-               fRec.getMatrixFrom2x2(&matrix);
+        SkASSERT(SkMask::k3D_Format != glyph->fMaskFormat); // the src glyph image shouldn't be 3D
+        glyph2mask(*glyph, &srcM);
+        fRec.getMatrixFrom2x2(&matrix);
 
-               if (fMaskFilter->filterMask(&dstM, srcM, matrix, NULL))
-               {
+        if (fMaskFilter->filterMask(&dstM, srcM, matrix, NULL))
+        {
             if (true)   // hack until I can figure out why the assert below sometimes fails
             {
                 int width = SkFastMin32(origGlyph.fWidth, dstM.fBounds.width());
@@ -370,9 +420,9 @@ void SkScalerContext::getImage(const SkGlyph& origGlyph)
 
                 memcpy(glyph->fImage, dstM.fImage, dstM.computeTotalImageSize());
             }
-                       SkMask::FreeImage(dstM.fImage);
-               }
-       }
+            SkMask::FreeImage(dstM.fImage);
+        }
+    }
 }
 
 void SkScalerContext::getPath(const SkGlyph& glyph, SkPath* path)
@@ -382,9 +432,9 @@ void SkScalerContext::getPath(const SkGlyph& glyph, SkPath* path)
 
 void SkScalerContext::getLineHeight(SkPoint* above, SkPoint* below)
 {
-       this->generateLineHeight(above, below);
+    this->generateLineHeight(above, below);
 
-       // apply any mods due to effects (e.g. stroking, etc.)...
+    // apply any mods due to effects (e.g. stroking, etc.)...
 }
 
 ///////////////////////////////////////////////////////////////////////
@@ -393,44 +443,44 @@ void SkScalerContext::internalGetPath(const SkGlyph& glyph, SkPath* fillPath, Sk
 {
     SkPath  path;
 
-       this->generatePath(glyph, &path);
-
-       if (fRec.fFrameWidth > 0 || fPathEffect != NULL)
-       {
-               // need the path in user-space, with only the point-size applied
-               // so that our stroking and effects will operate the same way they
-               // would if the user had extracted the path themself, and then
-               // called drawPath
-               SkPath          localPath;
-               SkMatrix        matrix, inverse;
-
-               fRec.getMatrixFrom2x2(&matrix);
-               matrix.invert(&inverse);
-               path.transform(inverse, &localPath);
-               // now localPath is only affected by the paint settings, and not the canvas matrix
-
-               SkScalar width = fRec.fFrameWidth;
-
-               if (fPathEffect)
-               {
-                       SkPath effectPath;
-
-                       if (fPathEffect->filterPath(&effectPath, localPath, &width))
-                               localPath.swap(effectPath);
-               }
-
-               if (width > 0)
-               {
-                       SkStroke        stroker;
-                       SkPath          outline;
-
-                       stroker.setWidth(width);
-                       stroker.setMiterLimit(fRec.fMiterLimit);
-                       stroker.setJoin((SkPaint::Join)fRec.fStrokeJoin);
-                       stroker.setDoFill(fRec.fFrameAndFill != 0);
-                       stroker.strokePath(localPath, &outline);
-                       localPath.swap(outline);
-               }
+    this->getGlyphContext(glyph)->generatePath(glyph, &path);
+
+    if (fRec.fFrameWidth > 0 || fPathEffect != NULL)
+    {
+        // need the path in user-space, with only the point-size applied
+        // so that our stroking and effects will operate the same way they
+        // would if the user had extracted the path themself, and then
+        // called drawPath
+        SkPath      localPath;
+        SkMatrix    matrix, inverse;
+
+        fRec.getMatrixFrom2x2(&matrix);
+        matrix.invert(&inverse);
+        path.transform(inverse, &localPath);
+        // now localPath is only affected by the paint settings, and not the canvas matrix
+
+        SkScalar width = fRec.fFrameWidth;
+
+        if (fPathEffect)
+        {
+            SkPath effectPath;
+
+            if (fPathEffect->filterPath(&effectPath, localPath, &width))
+                localPath.swap(effectPath);
+        }
+
+        if (width > 0)
+        {
+            SkStroke    stroker;
+            SkPath      outline;
+
+            stroker.setWidth(width);
+            stroker.setMiterLimit(fRec.fMiterLimit);
+            stroker.setJoin((SkPaint::Join)fRec.fStrokeJoin);
+            stroker.setDoFill(fRec.fFrameAndFill != 0);
+            stroker.strokePath(localPath, &outline);
+            localPath.swap(outline);
+        }
         
         // now return stuff to the caller
         if (fillToDevMatrix)
@@ -441,7 +491,7 @@ void SkScalerContext::internalGetPath(const SkGlyph& glyph, SkPath* fillPath, Sk
         
         if (fillPath)
             fillPath->swap(localPath);
-       }
+    }
     else    // nothing tricky to do
     {
         if (fillToDevMatrix)
@@ -463,36 +513,36 @@ void SkScalerContext::internalGetPath(const SkGlyph& glyph, SkPath* fillPath, Sk
 
 void SkScalerContext::Rec::getMatrixFrom2x2(SkMatrix* dst) const
 {
-       dst->reset();
-       dst->setScaleX(fPost2x2[0][0]);
-       dst->setSkewX( fPost2x2[0][1]);
-       dst->setSkewY( fPost2x2[1][0]);
-       dst->setScaleY(fPost2x2[1][1]);
+    dst->reset();
+    dst->setScaleX(fPost2x2[0][0]);
+    dst->setSkewX( fPost2x2[0][1]);
+    dst->setSkewY( fPost2x2[1][0]);
+    dst->setScaleY(fPost2x2[1][1]);
 }
 
 void SkScalerContext::Rec::getLocalMatrix(SkMatrix* m) const
 {
-       m->setScale(SkScalarMul(fTextSize, fPreScaleX), fTextSize, 0, 0);
-       if (fPreSkewX)
-               m->postSkew(fPreSkewX, 0, 0, 0);
+    m->setScale(SkScalarMul(fTextSize, fPreScaleX), fTextSize);
+    if (fPreSkewX)
+        m->postSkew(fPreSkewX, 0);
 }
 
 void SkScalerContext::Rec::getSingleMatrix(SkMatrix* m) const
 {
-       this->getLocalMatrix(m);
-
-       //      now concat the device matrix
-       {
-               SkMatrix        deviceMatrix;
-               this->getMatrixFrom2x2(&deviceMatrix);
-               m->postConcat(deviceMatrix);
-       }
+    this->getLocalMatrix(m);
+
+    //  now concat the device matrix
+    {
+        SkMatrix    deviceMatrix;
+        this->getMatrixFrom2x2(&deviceMatrix);
+        m->postConcat(deviceMatrix);
+    }
 }
 
 #include "SkFontHost.h"
 
 SkScalerContext* SkScalerContext::Create(const SkDescriptor* desc)
 {
-       return SkFontHost::CreateScalerContext(desc);
+    return SkFontHost::CreateScalerContext(desc);
 }
 
index b8534e6..cf25e5c 100644 (file)
@@ -1,32 +1,49 @@
+/* libs/graphics/sgl/SkScan.cpp
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #include "SkScan.h"
 #include "SkBlitter.h"
 #include "SkRegion.h"
 
 void SkScan::FillRect(const SkRect& rect, const SkRegion* clip, SkBlitter* blitter)
 {
-       SkRect16 r;
+    SkRect16 r;
 
-       rect.round(&r);
-       SkScan::FillDevRect(r, clip, blitter);
+    rect.round(&r);
+    SkScan::FillDevRect(r, clip, blitter);
 }
 
 void SkScan::FillDevRect(const SkRect16& r, const SkRegion* clip, SkBlitter* blitter)
 {
-       if (!r.isEmpty())
-       {
-               if (clip)
-               {
-                       SkRegion::Cliperator    cliper(*clip, r);
-                       const SkRect16&                 rr = cliper.rect();
+    if (!r.isEmpty())
+    {
+        if (clip)
+        {
+            SkRegion::Cliperator    cliper(*clip, r);
+            const SkRect16&         rr = cliper.rect();
 
-                       while (!cliper.done())
-                       {
-                               blitter->blitRect(rr.fLeft, rr.fTop, rr.width(), rr.height());
-                               cliper.next();
-                       }
-               }
-               else
-                       blitter->blitRect(r.fLeft, r.fTop, r.width(), r.height());
-       }
+            while (!cliper.done())
+            {
+                blitter->blitRect(rr.fLeft, rr.fTop, rr.width(), rr.height());
+                cliper.next();
+            }
+        }
+        else
+            blitter->blitRect(r.fLeft, r.fTop, r.width(), r.height());
+    }
 }
 
index c8b62c8..dc12eee 100644 (file)
@@ -1,3 +1,20 @@
+/* libs/graphics/sgl/SkScan.h
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #ifndef SkScan_DEFINED
 #define SkScan_DEFINED
 
@@ -9,22 +26,22 @@ class SkPath;
 
 class SkScan {
 public:
-       static void     FillDevRect(const SkRect16&, const SkRegion* clip, SkBlitter*);
-       static void     FillRect(const SkRect&, const SkRegion* clip, SkBlitter*);
-       static void FillPath(const SkPath&, const SkRegion* clip, SkBlitter*);
+    static void FillDevRect(const SkRect16&, const SkRegion* clip, SkBlitter*);
+    static void FillRect(const SkRect&, const SkRegion* clip, SkBlitter*);
+    static void FillPath(const SkPath&, const SkRegion* clip, SkBlitter*);
 
-       static void HairLine(const SkPoint&, const SkPoint&, const SkRegion* clip, SkBlitter*);
-       static void HairRect(const SkRect&, const SkRegion* clip, SkBlitter*);
-       static void HairPath(const SkPath&, const SkRegion* clip, SkBlitter*);
+    static void HairLine(const SkPoint&, const SkPoint&, const SkRegion* clip, SkBlitter*);
+    static void HairRect(const SkRect&, const SkRegion* clip, SkBlitter*);
+    static void HairPath(const SkPath&, const SkRegion* clip, SkBlitter*);
 
-       static void FrameRect(const SkRect&, SkScalar width, const SkRegion* clip, SkBlitter*);
+    static void FrameRect(const SkRect&, SkScalar width, const SkRegion* clip, SkBlitter*);
 
-       static void     AntiFillRect(const SkRect&, const SkRegion* clip, SkBlitter*);
-       static void AntiFillPath(const SkPath&, const SkRegion* clip, SkBlitter*);
+    static void AntiFillRect(const SkRect&, const SkRegion* clip, SkBlitter*);
+    static void AntiFillPath(const SkPath&, const SkRegion* clip, SkBlitter*);
 
-       static void AntiHairLine(const SkPoint&, const SkPoint&, const SkRegion* clip, SkBlitter*);
-       static void AntiHairRect(const SkRect&, const SkRegion* clip, SkBlitter*);
-       static void AntiHairPath(const SkPath&, const SkRegion* clip, SkBlitter*);
+    static void AntiHairLine(const SkPoint&, const SkPoint&, const SkRegion* clip, SkBlitter*);
+    static void AntiHairRect(const SkRect&, const SkRegion* clip, SkBlitter*);
+    static void AntiHairPath(const SkPath&, const SkRegion* clip, SkBlitter*);
 };
 
 #endif
index 2fce606..9800c11 100644 (file)
@@ -1,3 +1,20 @@
+/* libs/graphics/sgl/SkScanPriv.h
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #ifndef SkScanPriv_DEFINED
 #define SkScanPriv_DEFINED
 
 
 class SkScanClipper {
 public:
-       SkScanClipper(SkBlitter* blitter, const SkRegion* clip, const SkRect16& bounds);
+    SkScanClipper(SkBlitter* blitter, const SkRegion* clip, const SkRect16& bounds);
 
-       SkBlitter*              getBlitter() const { return fBlitter; }
-       const SkRect16* getClipRect() const { return fClipRect; }
+    SkBlitter*      getBlitter() const { return fBlitter; }
+    const SkRect16* getClipRect() const { return fClipRect; }
 
 private:
-       SkRectClipBlitter       fRectBlitter;
-       SkRgnClipBlitter        fRgnBlitter;
-       SkBlitter*                      fBlitter;
-       const SkRect16*         fClipRect;
+    SkRectClipBlitter   fRectBlitter;
+    SkRgnClipBlitter    fRgnBlitter;
+    SkBlitter*          fBlitter;
+    const SkRect16*     fClipRect;
 };
 
 void sk_fill_path(const SkPath& path, const SkRect16* clipRect, SkBlitter* blitter,
-                                 const SkRect16& ir, int shiftEdgesUp);
+                  const SkRect16& ir, int shiftEdgesUp);
 
 #endif
 
index 592edff..3c7e48d 100644 (file)
@@ -1,3 +1,20 @@
+/* libs/graphics/sgl/SkScan_AntiPath.cpp
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #include "SkScanPriv.h"
 #include "SkPath.h"
 #include "SkMatrix.h"
 #include "SkRegion.h"
 #include "SkAntiRun.h"
 
-#define SHIFT  2
-#define SCALE  (1 << SHIFT)
-#define MASK   (SCALE - 1)
+#define SHIFT   2
+#define SCALE   (1 << SHIFT)
+#define MASK    (SCALE - 1)
 
 ///////////////////////////////////////////////////////////////////////////////////////////
 
 class SuperBlitter : public SkBlitter {
 public:
-       SuperBlitter(SkBlitter* realBlitter, const SkRegion* clip, const SkRect16& ir);
-       virtual ~SuperBlitter()
-       {
-               sk_free(fRuns.fRuns);
-       }
-       void flush();
-
-       virtual void    blitH(int x, int y, int width);
-       virtual void    blitAntiH(int x, int y, const SkAlpha antialias[], const S16 runs[])
-       {
-               SkASSERT(!"How did I get here?");
-       }
-       virtual void    blitV(int x, int y, int height, SkAlpha alpha)
-       {
-               SkASSERT(!"How did I get here?");
-       }
-       virtual void    blitRect(int x, int y, int width, int height)
-       {
-               SkASSERT(!"How did I get here?");
-       }
+    SuperBlitter(SkBlitter* realBlitter, const SkRegion* clip, const SkRect16& ir);
+    virtual ~SuperBlitter()
+    {
+        sk_free(fRuns.fRuns);
+    }
+    void flush();
+
+    virtual void    blitH(int x, int y, int width);
+    virtual void    blitAntiH(int x, int y, const SkAlpha antialias[], const S16 runs[])
+    {
+        SkASSERT(!"How did I get here?");
+    }
+    virtual void    blitV(int x, int y, int height, SkAlpha alpha)
+    {
+        SkASSERT(!"How did I get here?");
+    }
+    virtual void    blitRect(int x, int y, int width, int height)
+    {
+        SkASSERT(!"How did I get here?");
+    }
 
 private:
-       SkBlitter*                      fRealBlitter;
-       int                                     fCurrIY;
-       int                                     fWidth, fLeft, fSuperLeft;
-       SkAlphaRuns                     fRuns;
+    SkBlitter*          fRealBlitter;
+    int                 fCurrIY;
+    int                 fWidth, fLeft, fSuperLeft;
+    SkAlphaRuns         fRuns;
 
-       SkDEBUGCODE(int fCurrX;)
-       SkDEBUGCODE(int fCurrY;)
+    SkDEBUGCODE(int fCurrX;)
+    SkDEBUGCODE(int fCurrY;)
 };
 
 SuperBlitter::SuperBlitter(SkBlitter* realBlitter, const SkRegion* clip, const SkRect16& ir)
 {
-       fRealBlitter = realBlitter;
+    fRealBlitter = realBlitter;
 
-       int     width = ir.width();
+    int width = ir.width();
 
-       // extra one to store the zero at the end
-       fRuns.fRuns = (S16*)sk_malloc_throw((width + 1 + (width + 2)/2) * sizeof(S16));
-       fRuns.fAlpha = (U8*)(fRuns.fRuns + width + 1);
-       fRuns.reset(width);
+    // extra one to store the zero at the end
+    fRuns.fRuns = (S16*)sk_malloc_throw((width + 1 + (width + 2)/2) * sizeof(S16));
+    fRuns.fAlpha = (U8*)(fRuns.fRuns + width + 1);
+    fRuns.reset(width);
 
-       fLeft = ir.fLeft;
-       fSuperLeft = ir.fLeft << SHIFT;
-       fWidth = ir.width();
-       fCurrIY = -1;
-       SkDEBUGCODE(fCurrX = -1; fCurrY = -1;)
+    fLeft = ir.fLeft;
+    fSuperLeft = ir.fLeft << SHIFT;
+    fWidth = ir.width();
+    fCurrIY = -1;
+    SkDEBUGCODE(fCurrX = -1; fCurrY = -1;)
 }
 
 void SuperBlitter::flush()
 {
-       if (fCurrIY >= 0)
-       {
-               if (!fRuns.empty())
-               {
-               //      SkDEBUGCODE(fRuns.dump();)
-                       fRealBlitter->blitAntiH(fLeft, fCurrIY, fRuns.fAlpha, fRuns.fRuns);
-                       fRuns.reset(fWidth);
-               }
-               fCurrIY = -1;
-               SkDEBUGCODE(fCurrX = -1;)
-       }
+    if (fCurrIY >= 0)
+    {
+        if (!fRuns.empty())
+        {
+        //  SkDEBUGCODE(fRuns.dump();)
+            fRealBlitter->blitAntiH(fLeft, fCurrIY, fRuns.fAlpha, fRuns.fRuns);
+            fRuns.reset(fWidth);
+        }
+        fCurrIY = -1;
+        SkDEBUGCODE(fCurrX = -1;)
+    }
 }
 
 static inline int coverage_to_alpha(int aa)
 {
-       aa <<= 8 - 2*SHIFT;
-       aa -= aa >> (8 - SHIFT - 1);
-       return aa;
+    aa <<= 8 - 2*SHIFT;
+    aa -= aa >> (8 - SHIFT - 1);
+    return aa;
 }
 
-#define SUPER_Mask             ((1 << SHIFT) - 1)
+#define SUPER_Mask      ((1 << SHIFT) - 1)
 
 void SuperBlitter::blitH(int x, int y, int width)
 {
-       int     iy = y >> SHIFT;
-       SkASSERT(iy >= fCurrIY);
+    int iy = y >> SHIFT;
+    SkASSERT(iy >= fCurrIY);
 
-       x -= fSuperLeft;
-#if 0  // I should just need to assert
-       SkASSERT(x >= 0);
+    x -= fSuperLeft;
+#if 0   // I should just need to assert
+    SkASSERT(x >= 0);
 #else
-       // hack, until I figure out why my cubics (I think) go beyond the bounds
-       if (x < 0)
-       {
-               width += x;
-               x = 0;
-       }
+    // hack, until I figure out why my cubics (I think) go beyond the bounds
+    if (x < 0)
+    {
+        width += x;
+        x = 0;
+    }
 #endif
 
 #ifdef SK_DEBUG
-       SkASSERT(y >= fCurrY);
-       SkASSERT(y != fCurrY || x >= fCurrX);
-       fCurrY = y;
+    SkASSERT(y >= fCurrY);
+    SkASSERT(y != fCurrY || x >= fCurrX);
+    fCurrY = y;
 #endif
 
-       if (iy != fCurrIY)      // new scanline
-       {
-               this->flush();
-               fCurrIY = iy;
-       }
+    if (iy != fCurrIY)  // new scanline
+    {
+        this->flush();
+        fCurrIY = iy;
+    }
 
-       // we sub 1 from maxValue 1 time for each block, so that we don't
-       // hit 256 as a summed max, but 255.
-//     int maxValue = (1 << (8 - SHIFT)) - (((y & MASK) + 1) >> SHIFT);
+    // we sub 1 from maxValue 1 time for each block, so that we don't
+    // hit 256 as a summed max, but 255.
+//  int maxValue = (1 << (8 - SHIFT)) - (((y & MASK) + 1) >> SHIFT);
 
 #if 0
-       SkAntiRun<SHIFT>        arun;   
-       arun.set(x, x + width);
-       fRuns.add(x >> SHIFT, arun.getStartAlpha(), arun.getMiddleCount(), arun.getStopAlpha(), maxValue);
+    SkAntiRun<SHIFT>    arun;   
+    arun.set(x, x + width);
+    fRuns.add(x >> SHIFT, arun.getStartAlpha(), arun.getMiddleCount(), arun.getStopAlpha(), maxValue);
 #else
-       {
-               int start = x;
-               int stop = x + width;
-
-               SkASSERT(start >= 0 && stop > start);
-               int     fb = start & SUPER_Mask;
-               int fe = stop & SUPER_Mask;
-               int     n = (stop >> SHIFT) - (start >> SHIFT) - 1;
-
-               if (n < 0)
-               {
-                       fb = fe - fb;
-                       n = 0;
-                       fe = 0;
-               }
-               else
-               {
-                       if (fb == 0)
-                               n += 1;
-                       else
-                               fb = (1 << SHIFT) - fb;
-               }
-               fRuns.add(x >> SHIFT, coverage_to_alpha(fb), n, coverage_to_alpha(fe), (1 << (8 - SHIFT)) - (((y & MASK) + 1) >> SHIFT));
-       }
+    {
+        int start = x;
+        int stop = x + width;
+
+        SkASSERT(start >= 0 && stop > start);
+        int fb = start & SUPER_Mask;
+        int fe = stop & SUPER_Mask;
+        int n = (stop >> SHIFT) - (start >> SHIFT) - 1;
+
+        if (n < 0)
+        {
+            fb = fe - fb;
+            n = 0;
+            fe = 0;
+        }
+        else
+        {
+            if (fb == 0)
+                n += 1;
+            else
+                fb = (1 << SHIFT) - fb;
+        }
+        fRuns.add(x >> SHIFT, coverage_to_alpha(fb), n, coverage_to_alpha(fe), (1 << (8 - SHIFT)) - (((y & MASK) + 1) >> SHIFT));
+    }
 #endif
 
 #ifdef SK_DEBUG
-       fRuns.assertValid(y & MASK, (1 << (8 - SHIFT)));
-       fCurrX = x + width;
+    fRuns.assertValid(y & MASK, (1 << (8 - SHIFT)));
+    fCurrX = x + width;
 #endif
 }
 
@@ -160,50 +177,50 @@ void SuperBlitter::blitH(int x, int y, int width)
 
 static int overflows_short(int value)
 {
-       return value - (short)value;
+    return value - (short)value;
 }
 
 void SkScan::AntiFillPath(const SkPath& path, const SkRegion* clip, SkBlitter* blitter)
 {
-       if (clip && clip->isEmpty())
-               return;
-
-       SkRect          r;
-       SkRect16        ir;
-
-       path.computeBounds(&r, SkPath::kFast_BoundsType);
-       r.roundOut(&ir);
-       if (ir.isEmpty())
-               return;
-
-       if (overflows_short(ir.fLeft << SHIFT) ||
-               overflows_short(ir.fRight << SHIFT) ||
-               overflows_short(ir.width() << SHIFT) ||
-               overflows_short(ir.fTop << SHIFT) ||
-               overflows_short(ir.fBottom << SHIFT) ||
-               overflows_short(ir.height() << SHIFT))
-               return;
-
-       SkScanClipper   clipper(blitter, clip, ir);
-       const SkRect16* clipRect = clipper.getClipRect();
-
-       blitter = clipper.getBlitter();
-       if (blitter == nil)     // clipped out
-               return;
-
-       SuperBlitter    superBlit(blitter, clip, ir);
-       SkRect16                superIR, superRect, *superClipRect = nil;
-
-       superIR.set(ir.fLeft << SHIFT, ir.fTop << SHIFT,
-                               ir.fRight << SHIFT, ir.fBottom << SHIFT);
-
-       if (clipRect)
-       {
-               superRect.set(  clipRect->fLeft << SHIFT, clipRect->fTop << SHIFT,
-                                               clipRect->fRight << SHIFT, clipRect->fBottom << SHIFT);
-               superClipRect = &superRect;
-       }
-
-       sk_fill_path(path, superClipRect, &superBlit, superIR, SHIFT);
-       superBlit.flush();
+    if (clip && clip->isEmpty())
+        return;
+
+    SkRect      r;
+    SkRect16    ir;
+
+    path.computeBounds(&r, SkPath::kFast_BoundsType);
+    r.roundOut(&ir);
+    if (ir.isEmpty())
+        return;
+
+    if (overflows_short(ir.fLeft << SHIFT) ||
+        overflows_short(ir.fRight << SHIFT) ||
+        overflows_short(ir.width() << SHIFT) ||
+        overflows_short(ir.fTop << SHIFT) ||
+        overflows_short(ir.fBottom << SHIFT) ||
+        overflows_short(ir.height() << SHIFT))
+        return;
+
+    SkScanClipper   clipper(blitter, clip, ir);
+    const SkRect16* clipRect = clipper.getClipRect();
+
+    blitter = clipper.getBlitter();
+    if (blitter == nil) // clipped out
+        return;
+
+    SuperBlitter    superBlit(blitter, clip, ir);
+    SkRect16        superIR, superRect, *superClipRect = nil;
+
+    superIR.set(ir.fLeft << SHIFT, ir.fTop << SHIFT,
+                ir.fRight << SHIFT, ir.fBottom << SHIFT);
+
+    if (clipRect)
+    {
+        superRect.set(  clipRect->fLeft << SHIFT, clipRect->fTop << SHIFT,
+                        clipRect->fRight << SHIFT, clipRect->fBottom << SHIFT);
+        superClipRect = &superRect;
+    }
+
+    sk_fill_path(path, superClipRect, &superBlit, superIR, SHIFT);
+    superBlit.flush();
 }
index 81f503b..b9bee6d 100644 (file)
+/* libs/graphics/sgl/SkScan_Antihair.cpp
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #include "SkScan.h"
 #include "SkBlitter.h"
 #include "SkRegion.h"
 #include "SkFDot6.h"
 
-#define HLINE_STACK_BUFFER             100
+#define HLINE_STACK_BUFFER      100
 
 //#define TEST_GAMMA
 
 #ifdef TEST_GAMMA
-       static U8 gGammaTable[256];
-       #define ApplyGamma(table, alpha)        (table)[alpha]
-
-       static void build_gamma_table()
-       {
-               static bool gInit = false;
-
-               if (gInit == false)
-               {
-                       for (int i = 0; i < 256; i++)
-                       {
-                               SkFixed n = i * 257;
-                               n += n >> 15;
-                               SkASSERT(n >= 0 && n <= SK_Fixed1);
-                               n = SkFixedSqrt(n);
-                               n = n * 255 >> 16;
-                       //      SkDebugf("morph %d -> %d\n", i, n);
-                               gGammaTable[i] = SkToU8(n);
-                       }
-                       gInit = true;
-               }
-       }
+    static U8 gGammaTable[256];
+    #define ApplyGamma(table, alpha)    (table)[alpha]
+
+    static void build_gamma_table()
+    {
+        static bool gInit = false;
+
+        if (gInit == false)
+        {
+            for (int i = 0; i < 256; i++)
+            {
+                SkFixed n = i * 257;
+                n += n >> 15;
+                SkASSERT(n >= 0 && n <= SK_Fixed1);
+                n = SkFixedSqrt(n);
+                n = n * 255 >> 16;
+            //  SkDebugf("morph %d -> %d\n", i, n);
+                gGammaTable[i] = SkToU8(n);
+            }
+            gInit = true;
+        }
+    }
 #else
-       #define ApplyGamma(table, alpha)        SkToU8(alpha)
+    #define ApplyGamma(table, alpha)    SkToU8(alpha)
 #endif
 
 
 static void call_hline_blitter(SkBlitter* blitter, int x, int y, int count, U8 alpha)
 {
-       SkASSERT(count > 0);
-
-       S16     runs[HLINE_STACK_BUFFER + 1];
-       U8      aa[HLINE_STACK_BUFFER];
-
-       aa[0] = ApplyGamma(gGammaTable, alpha);
-       do {
-               int n = count;
-               if (n > HLINE_STACK_BUFFER)
-                       n = HLINE_STACK_BUFFER;
-
-               runs[0] = SkToS16(n);
-               runs[n] = 0;
-               blitter->blitAntiH(x, y, aa, runs);
-               x += n;
-               count -= n;
-       } while (count > 0);
+    SkASSERT(count > 0);
+
+    S16 runs[HLINE_STACK_BUFFER + 1];
+    U8  aa[HLINE_STACK_BUFFER];
+
+    aa[0] = ApplyGamma(gGammaTable, alpha);
+    do {
+        int n = count;
+        if (n > HLINE_STACK_BUFFER)
+            n = HLINE_STACK_BUFFER;
+
+        runs[0] = SkToS16(n);
+        runs[n] = 0;
+        blitter->blitAntiH(x, y, aa, runs);
+        x += n;
+        count -= n;
+    } while (count > 0);
 }
 
 static void hline(int x, int stopx, SkFixed fy, SkFixed /*slope*/, SkBlitter* blitter)
 {
-       SkASSERT(x < stopx);
-       int     count = stopx - x;
-       fy += SK_Fixed1/2;
+    SkASSERT(x < stopx);
+    int count = stopx - x;
+    fy += SK_Fixed1/2;
 
-       int     y = fy >> 16;
-       U8      a = (U8)(fy >> 8);
+    int y = fy >> 16;
+    U8  a = (U8)(fy >> 8);
 
-       // lower line
-       if (a)
-               call_hline_blitter(blitter, x, y, count, a);
+    // lower line
+    if (a)
+        call_hline_blitter(blitter, x, y, count, a);
 
-       // upper line
-       a = (U8)(255 - a);
-       if (a)
-               call_hline_blitter(blitter, x, y - 1, count, a);
+    // upper line
+    a = (U8)(255 - a);
+    if (a)
+        call_hline_blitter(blitter, x, y - 1, count, a);
 }
 
 static void horish(int x, int stopx, SkFixed fy, SkFixed dy, SkBlitter* blitter)
 {
-       SkASSERT(x < stopx);
+    SkASSERT(x < stopx);
 
 #ifdef TEST_GAMMA
-       const U8* gamma = gGammaTable;
+    const U8* gamma = gGammaTable;
 #endif
-       S16     runs[2];
-       U8      aa[1];
-
-       runs[0] = 1;
-       runs[1] = 0;
-
-       fy += SK_Fixed1/2;
-       do {
-               int     lower_y = fy >> 16;
-               U8      a = (U8)(fy >> 8);
-
-               if (a)
-               {
-                       aa[0] = ApplyGamma(gamma, a);
-                       blitter->blitAntiH(x, lower_y, aa, runs);
-                       // the clipping blitters might edit runs, but should not affect us
-                       SkASSERT(runs[0] == 1);
-                       SkASSERT(runs[1] == 0);
-               }
-               a = (U8)(255 - a);
-               if (a)
-               {
-                       aa[0] = ApplyGamma(gamma, a);
-                       blitter->blitAntiH(x, lower_y - 1, aa, runs);
-                       // the clipping blitters might edit runs, but should not affect us
-                       SkASSERT(runs[0] == 1);
-                       SkASSERT(runs[1] == 0);
-               }
-               fy += dy;
-       } while (++x < stopx);
+    S16 runs[2];
+    U8  aa[1];
+
+    runs[0] = 1;
+    runs[1] = 0;
+
+    fy += SK_Fixed1/2;
+    do {
+        int lower_y = fy >> 16;
+        U8  a = (U8)(fy >> 8);
+
+        if (a)
+        {
+            aa[0] = ApplyGamma(gamma, a);
+            blitter->blitAntiH(x, lower_y, aa, runs);
+            // the clipping blitters might edit runs, but should not affect us
+            SkASSERT(runs[0] == 1);
+            SkASSERT(runs[1] == 0);
+        }
+        a = (U8)(255 - a);
+        if (a)
+        {
+            aa[0] = ApplyGamma(gamma, a);
+            blitter->blitAntiH(x, lower_y - 1, aa, runs);
+            // the clipping blitters might edit runs, but should not affect us
+            SkASSERT(runs[0] == 1);
+            SkASSERT(runs[1] == 0);
+        }
+        fy += dy;
+    } while (++x < stopx);
 }
 
 static void vline(int y, int stopy, SkFixed fx, SkFixed /*slope*/, SkBlitter* blitter)
 {
-       SkASSERT(y < stopy);
-       fx += SK_Fixed1/2;
+    SkASSERT(y < stopy);
+    fx += SK_Fixed1/2;
 
-       int x = fx >> 16;
-       int     a = (U8)(fx >> 8);
+    int x = fx >> 16;
+    int a = (U8)(fx >> 8);
 
-       if (a)
-               blitter->blitV(x, y, stopy - y, ApplyGamma(gGammaTable, a));
-       a = 255 - a;
-       if (a)
-               blitter->blitV(x - 1, y, stopy - y, ApplyGamma(gGammaTable, a));
+    if (a)
+        blitter->blitV(x, y, stopy - y, ApplyGamma(gGammaTable, a));
+    a = 255 - a;
+    if (a)
+        blitter->blitV(x - 1, y, stopy - y, ApplyGamma(gGammaTable, a));
 }
 
 static void vertish(int y, int stopy, SkFixed fx, SkFixed dx, SkBlitter* blitter)
 {
-       SkASSERT(y < stopy);
+    SkASSERT(y < stopy);
 #ifdef TEST_GAMMA
-       const U8* gamma = gGammaTable;
+    const U8* gamma = gGammaTable;
 #endif
-       S16     runs[3];
-       U8      aa[2];
-
-       runs[0] = 1;
-       runs[2] = 0;
-
-       fx += SK_Fixed1/2;
-       do {
-               int x = fx >> 16;
-               U8      a = (U8)(fx >> 8);
-
-               aa[0] = ApplyGamma(gamma, 255 - a);
-               aa[1] = ApplyGamma(gamma, a);
-               // the clippng blitters might overwrite this guy, so we have to reset it each time
-               runs[1] = 1;
-               blitter->blitAntiH(x - 1, y, aa, runs);
-               // the clipping blitters might edit runs, but should not affect us
-               SkASSERT(runs[0] == 1);
-               SkASSERT(runs[2] == 0);
-               fx += dx;
-       } while (++y < stopy);
+    S16 runs[3];
+    U8  aa[2];
+
+    runs[0] = 1;
+    runs[2] = 0;
+
+    fx += SK_Fixed1/2;
+    do {
+        int x = fx >> 16;
+        U8  a = (U8)(fx >> 8);
+
+        aa[0] = ApplyGamma(gamma, 255 - a);
+        aa[1] = ApplyGamma(gamma, a);
+        // the clippng blitters might overwrite this guy, so we have to reset it each time
+        runs[1] = 1;
+        blitter->blitAntiH(x - 1, y, aa, runs);
+        // the clipping blitters might edit runs, but should not affect us
+        SkASSERT(runs[0] == 1);
+        SkASSERT(runs[2] == 0);
+        fx += dx;
+    } while (++y < stopy);
 }
 
 typedef void (*LineProc)(int istart, int istop, SkFixed fstart, SkFixed slope, SkBlitter*);
 
 static inline SkFixed fastfixdiv(SkFDot6 a, SkFDot6 b)
 {
-       SkASSERT((a << 16 >> 16) == a);
-       SkASSERT(b != 0);
-       return (a << 16) / b;
+    SkASSERT((a << 16 >> 16) == a);
+    SkASSERT(b != 0);
+    return (a << 16) / b;
 }
 static inline SkFDot6 fastfixmul(SkFixed fixed, SkFDot6 b)
 {
-       SkASSERT(SkAbs32(fixed) <= SK_Fixed1 && SkAbs32(b) <= SkIntToFDot6(511));
-       return (fixed * b + 0x8000) >> 16;
+    SkASSERT(SkAbs32(fixed) <= SK_Fixed1 && SkAbs32(b) <= SkIntToFDot6(511));
+    return (fixed * b + 0x8000) >> 16;
 }
 
 static void do_anti_hairline(SkFDot6 x0, SkFDot6 y0, SkFDot6 x1, SkFDot6 y1,
-                                                        const SkRect16* clip, SkBlitter* blitter)
+                             const SkRect16* clip, SkBlitter* blitter)
 {
-       // check that we're no larger than 511 pixels (so we can do a faster div).
-       // if we are, subdivide and call again
-
-       if (SkAbs32(x1 - x0) > SkIntToFDot6(511) || SkAbs32(y1 - y0) > SkIntToFDot6(511))
-       {
-               int     hx = (x0 + x1) >> 1;
-               int     hy = (y0 + y1) >> 1;
-               do_anti_hairline(x0, y0, hx, hy, clip, blitter);
-               do_anti_hairline(hx, hy, x1, y1, clip, blitter);
-               return;
-       }
-
-       int                     istart, istop;
-       SkFixed         fstart, slope; 
-       LineProc        proc;
-
-       if (SkAbs32(x1 - x0) > SkAbs32(y1 - y0))        // mostly horizontal
-       {
-               if (x0 > x1)    // we want to go left-to-right
-               {
-                       SkTSwap<SkFDot6>(x0, x1);
-                       SkTSwap<SkFDot6>(y0, y1);
-               }
-               istart = SkFDot6Round(x0);
-               istop = SkFDot6Round(x1);
-               if (istart == istop)    // too short to draw
-                       return;
-
-               if (y0 == y1)   // completely horizontal, take fast case
-               {
-                       slope = 0;
-                       fstart = SkFDot6ToFixed(y0);
-                       proc = hline;
-               }
-               else
-               {
-                       slope = fastfixdiv(y1 - y0, x1 - x0);
-                       SkASSERT(slope >= -SK_Fixed1 && slope <= SK_Fixed1);
-                       fstart = SkFDot6ToFixed(y0 + fastfixmul(slope, (32 - x0) & 63));
-                       proc = horish;
-               }
-
-               if (clip)
-               {
-                       if (istart >= clip->fRight || istop <= clip->fLeft)
-                               return;
-                       if (istart < clip->fLeft)
-                       {
-                               fstart += slope * (clip->fLeft - istart);
-                               istart = clip->fLeft;
-                       }
-                       if (istop > clip->fRight)
-                               istop = clip->fRight;
-                       SkASSERT(istart <= istop);
-                       if (istart == istop)
-                               return;
-                       // now test if our Y values are completely inside the clip
-                       int     top, bottom;
-                       if (slope >= 0) // T2B
-                       {
-                               top = SkFixedFloor(fstart - SK_FixedHalf);
-                               bottom = SkFixedCeil(fstart + (istop - istart - 1) * slope + SK_FixedHalf);
-                       }
-                       else                    // B2T
-                       {
-                               bottom = SkFixedCeil(fstart + SK_FixedHalf);
-                               top = SkFixedFloor(fstart + (istop - istart - 1) * slope - SK_FixedHalf);
-                       }
-                       if (top >= clip->fBottom || bottom <= clip->fTop)
-                               return;
-                       if (clip->fTop <= top && clip->fBottom >= bottom)
-                               clip = nil;
-               }
-       }
-       else    // mostly vertical
-       {
-               if (y0 > y1)    // we want to go top-to-bottom
-               {
-                       SkTSwap<SkFDot6>(x0, x1);
-                       SkTSwap<SkFDot6>(y0, y1);
-               }
-               istart = SkFDot6Round(y0);
-               istop = SkFDot6Round(y1);
-               if (istart == istop)    // too short to draw
-                       return;
-
-               if (x0 == x1)
-               {
-                       slope = 0;
-                       fstart = SkFDot6ToFixed(x0);
-                       proc = vline;
-               }
-               else
-               {
-                       slope = fastfixdiv(x1 - x0, y1 - y0);
-                       SkASSERT(slope <= SK_Fixed1 && slope >= -SK_Fixed1);
-                       fstart = SkFDot6ToFixed(x0 + fastfixmul(slope, (32 - y0) & 63));
-                       proc = vertish;
-               }
-
-               if (clip)
-               {
-                       if (istart >= clip->fBottom || istop <= clip->fTop)
-                               return;
-                       if (istart < clip->fTop)
-                       {
-                               fstart += slope * (clip->fTop - istart);
-                               istart = clip->fTop;
-                       }
-                       if (istop > clip->fBottom)
-                               istop = clip->fBottom;
-                       SkASSERT(istart <= istop);
-                       if (istart == istop)
-                               return;
-                       // now test if our X values are completely inside the clip
-                       int     left, right;
-                       if (slope >= 0) // L2R
-                       {
-                               left = SkFixedFloor(fstart - SK_FixedHalf);
-                               right = SkFixedCeil(fstart + (istop - istart - 1) * slope + SK_FixedHalf);
-                       }
-                       else                    // R2L
-                       {
-                               right = SkFixedCeil(fstart + SK_FixedHalf);
-                               left = SkFixedFloor(fstart + (istop - istart - 1) * slope - SK_FixedHalf);
-                       }
-                       if (left >= clip->fRight || right <= clip->fLeft)
-                               return;
-                       if (clip->fLeft <= left && clip->fRight >= right)
-                               clip = nil;
-               }
-       }
-
-       SkRectClipBlitter       rectClipper;
-       if (clip)
-       {
-               rectClipper.init(blitter, *clip);
-               blitter = &rectClipper;
-       }
-       proc(istart, istop, fstart, slope, blitter);
+    // check that we're no larger than 511 pixels (so we can do a faster div).
+    // if we are, subdivide and call again
+
+    if (SkAbs32(x1 - x0) > SkIntToFDot6(511) || SkAbs32(y1 - y0) > SkIntToFDot6(511))
+    {
+        int hx = (x0 + x1) >> 1;
+        int hy = (y0 + y1) >> 1;
+        do_anti_hairline(x0, y0, hx, hy, clip, blitter);
+        do_anti_hairline(hx, hy, x1, y1, clip, blitter);
+        return;
+    }
+
+    int         istart, istop;
+    SkFixed     fstart, slope; 
+    LineProc    proc;
+
+    if (SkAbs32(x1 - x0) > SkAbs32(y1 - y0))    // mostly horizontal
+    {
+        if (x0 > x1)    // we want to go left-to-right
+        {
+            SkTSwap<SkFDot6>(x0, x1);
+            SkTSwap<SkFDot6>(y0, y1);
+        }
+        istart = SkFDot6Round(x0);
+        istop = SkFDot6Round(x1);
+        if (istart == istop)    // too short to draw
+            return;
+
+        if (y0 == y1)   // completely horizontal, take fast case
+        {
+            slope = 0;
+            fstart = SkFDot6ToFixed(y0);
+            proc = hline;
+        }
+        else
+        {
+            slope = fastfixdiv(y1 - y0, x1 - x0);
+            SkASSERT(slope >= -SK_Fixed1 && slope <= SK_Fixed1);
+            fstart = SkFDot6ToFixed(y0 + fastfixmul(slope, (32 - x0) & 63));
+            proc = horish;
+        }
+
+        if (clip)
+        {
+            if (istart >= clip->fRight || istop <= clip->fLeft)
+                return;
+            if (istart < clip->fLeft)
+            {
+                fstart += slope * (clip->fLeft - istart);
+                istart = clip->fLeft;
+            }
+            if (istop > clip->fRight)
+                istop = clip->fRight;
+            SkASSERT(istart <= istop);
+            if (istart == istop)
+                return;
+            // now test if our Y values are completely inside the clip
+            int top, bottom;
+            if (slope >= 0) // T2B
+            {
+                top = SkFixedFloor(fstart - SK_FixedHalf);
+                bottom = SkFixedCeil(fstart + (istop - istart - 1) * slope + SK_FixedHalf);
+            }
+            else            // B2T
+            {
+                bottom = SkFixedCeil(fstart + SK_FixedHalf);
+                top = SkFixedFloor(fstart + (istop - istart - 1) * slope - SK_FixedHalf);
+            }
+            if (top >= clip->fBottom || bottom <= clip->fTop)
+                return;
+            if (clip->fTop <= top && clip->fBottom >= bottom)
+                clip = nil;
+        }
+    }
+    else    // mostly vertical
+    {
+        if (y0 > y1)    // we want to go top-to-bottom
+        {
+            SkTSwap<SkFDot6>(x0, x1);
+            SkTSwap<SkFDot6>(y0, y1);
+        }
+        istart = SkFDot6Round(y0);
+        istop = SkFDot6Round(y1);
+        if (istart == istop)    // too short to draw
+            return;
+
+        if (x0 == x1)
+        {
+            slope = 0;
+            fstart = SkFDot6ToFixed(x0);
+            proc = vline;
+        }
+        else
+        {
+            slope = fastfixdiv(x1 - x0, y1 - y0);
+            SkASSERT(slope <= SK_Fixed1 && slope >= -SK_Fixed1);
+            fstart = SkFDot6ToFixed(x0 + fastfixmul(slope, (32 - y0) & 63));
+            proc = vertish;
+        }
+
+        if (clip)
+        {
+            if (istart >= clip->fBottom || istop <= clip->fTop)
+                return;
+            if (istart < clip->fTop)
+            {
+                fstart += slope * (clip->fTop - istart);
+                istart = clip->fTop;
+            }
+            if (istop > clip->fBottom)
+                istop = clip->fBottom;
+            SkASSERT(istart <= istop);
+            if (istart == istop)
+                return;
+            // now test if our X values are completely inside the clip
+            int left, right;
+            if (slope >= 0) // L2R
+            {
+                left = SkFixedFloor(fstart - SK_FixedHalf);
+                right = SkFixedCeil(fstart + (istop - istart - 1) * slope + SK_FixedHalf);
+            }
+            else            // R2L
+            {
+                right = SkFixedCeil(fstart + SK_FixedHalf);
+                left = SkFixedFloor(fstart + (istop - istart - 1) * slope - SK_FixedHalf);
+            }
+            if (left >= clip->fRight || right <= clip->fLeft)
+                return;
+            if (clip->fLeft <= left && clip->fRight >= right)
+                clip = nil;
+        }
+    }
+
+    SkRectClipBlitter   rectClipper;
+    if (clip)
+    {
+        rectClipper.init(blitter, *clip);
+        blitter = &rectClipper;
+    }
+    proc(istart, istop, fstart, slope, blitter);
 }
 
 void SkScan::AntiHairLine(const SkPoint& pt0, const SkPoint& pt1,
-                                                 const SkRegion* clip, SkBlitter* blitter)
+                          const SkRegion* clip, SkBlitter* blitter)
 {
-       if (clip && clip->isEmpty())
-               return;
+    if (clip && clip->isEmpty())
+        return;
 
-       SkASSERT(clip == nil || !clip->getBounds().isEmpty());
+    SkASSERT(clip == nil || !clip->getBounds().isEmpty());
 
 #ifdef TEST_GAMMA
-       build_gamma_table();
+    build_gamma_table();
 #endif
 
-       SkFDot6 x0 = SkScalarToFDot6(pt0.fX);
-       SkFDot6 y0 = SkScalarToFDot6(pt0.fY);
-       SkFDot6 x1 = SkScalarToFDot6(pt1.fX);
-       SkFDot6 y1 = SkScalarToFDot6(pt1.fY);
-
-       if (clip)
-       {
-               SkFDot6         left = SkMin32(x0, x1);
-               SkFDot6         top = SkMin32(y0, y1);
-               SkFDot6         right = SkMax32(x0, x1);
-               SkFDot6         bottom = SkMax32(y0, y1);
-               SkRect16        ir;
-
-               ir.set( SkFDot6Round(left) - 1,
-                               SkFDot6Round(top) - 1,
-                               SkFDot6Round(right) + 1,
-                               SkFDot6Round(bottom) + 1);
-
-               if (clip->quickReject(ir))
-                       return;
-               if (!clip->quickContains(ir))
-               {
-                       SkRegion::Cliperator iter(*clip, ir);
-                       const SkRect16*          r = &iter.rect();
-
-                       while (!iter.done())
-                       {
-                               do_anti_hairline(x0, y0, x1, y1, r, blitter);
-                               iter.next();
-                       }
-                       return;
-               }
-               // fall through to no-clip case
-       }
-       do_anti_hairline(x0, y0, x1, y1, nil, blitter);
+    SkFDot6 x0 = SkScalarToFDot6(pt0.fX);
+    SkFDot6 y0 = SkScalarToFDot6(pt0.fY);
+    SkFDot6 x1 = SkScalarToFDot6(pt1.fX);
+    SkFDot6 y1 = SkScalarToFDot6(pt1.fY);
+
+    if (clip)
+    {
+        SkFDot6     left = SkMin32(x0, x1);
+        SkFDot6     top = SkMin32(y0, y1);
+        SkFDot6     right = SkMax32(x0, x1);
+        SkFDot6     bottom = SkMax32(y0, y1);
+        SkRect16    ir;
+
+        ir.set( SkFDot6Round(left) - 1,
+                SkFDot6Round(top) - 1,
+                SkFDot6Round(right) + 1,
+                SkFDot6Round(bottom) + 1);
+
+        if (clip->quickReject(ir))
+            return;
+        if (!clip->quickContains(ir))
+        {
+            SkRegion::Cliperator iter(*clip, ir);
+            const SkRect16*      r = &iter.rect();
+
+            while (!iter.done())
+            {
+                do_anti_hairline(x0, y0, x1, y1, r, blitter);
+                iter.next();
+            }
+            return;
+        }
+        // fall through to no-clip case
+    }
+    do_anti_hairline(x0, y0, x1, y1, nil, blitter);
 }
 
 void SkScan::AntiHairRect(const SkRect& rect, const SkRegion* clip, SkBlitter* blitter)
 {
-       if (clip)
-       {
-               SkRect16        ir;
-               SkRect          r = rect;
-
-               r.inset(-SK_Scalar1/2, -SK_Scalar1/2);
-               r.roundOut(&ir);
-               if (clip->quickReject(ir))
-                       return;
-               if (clip->quickContains(ir))
-                       clip = nil;
-       }
-
-       SkPoint p0, p1;
-
-       p0.set(rect.fLeft, rect.fTop);
-       p1.set(rect.fRight, rect.fTop);
-       SkScan::AntiHairLine(p0, p1, clip, blitter);
-       p0.set(rect.fRight, rect.fBottom);
-       SkScan::AntiHairLine(p0, p1, clip, blitter);
-       p1.set(rect.fLeft, rect.fBottom);
-       SkScan::AntiHairLine(p0, p1, clip, blitter);
-       p0.set(rect.fLeft, rect.fTop);
-       SkScan::AntiHairLine(p0, p1, clip, blitter);
+    if (clip)
+    {
+        SkRect16    ir;
+        SkRect      r = rect;
+
+        r.inset(-SK_Scalar1/2, -SK_Scalar1/2);
+        r.roundOut(&ir);
+        if (clip->quickReject(ir))
+            return;
+        if (clip->quickContains(ir))
+            clip = nil;
+    }
+
+    SkPoint p0, p1;
+
+    p0.set(rect.fLeft, rect.fTop);
+    p1.set(rect.fRight, rect.fTop);
+    SkScan::AntiHairLine(p0, p1, clip, blitter);
+    p0.set(rect.fRight, rect.fBottom);
+    SkScan::AntiHairLine(p0, p1, clip, blitter);
+    p1.set(rect.fLeft, rect.fBottom);
+    SkScan::AntiHairLine(p0, p1, clip, blitter);
+    p0.set(rect.fLeft, rect.fTop);
+    SkScan::AntiHairLine(p0, p1, clip, blitter);
 }
 
 
index 2af9e12..70667e8 100644 (file)
@@ -1,3 +1,20 @@
+/* libs/graphics/sgl/SkScan_Hairline.cpp
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #include "SkScan.h"
 #include "SkBlitter.h"
 #include "SkRegion.h"
 
 static void horiline(int x, int stopx, SkFixed fy, SkFixed dy, SkBlitter* blitter)
 {
-       SkASSERT(x < stopx);
+    SkASSERT(x < stopx);
 
-       do {
-               blitter->blitH(x, fy >> 16, 1);
-               fy += dy;
-       } while (++x < stopx);
+    do {
+        blitter->blitH(x, fy >> 16, 1);
+        fy += dy;
+    } while (++x < stopx);
 }
 
 static void vertline(int y, int stopy, SkFixed fx, SkFixed dx, SkBlitter* blitter)
 {
-       SkASSERT(y < stopy);
+    SkASSERT(y < stopy);
 
-       do {
-               blitter->blitH(fx >> 16, y, 1);
-               fx += dx;
-       } while (++y < stopy);
+    do {
+        blitter->blitH(fx >> 16, y, 1);
+        fx += dx;
+    } while (++y < stopy);
 }
 
 void SkScan::HairLine(const SkPoint& pt0, const SkPoint& pt1, const SkRegion* clip, SkBlitter* blitter)
 {
-       SkBlitterClipper        clipper;
-
-       SkFDot6 x0 = SkScalarToFDot6(pt0.fX);
-       SkFDot6 y0 = SkScalarToFDot6(pt0.fY);
-       SkFDot6 x1 = SkScalarToFDot6(pt1.fX);
-       SkFDot6 y1 = SkScalarToFDot6(pt1.fY);
-
-       if (clip)
-       {
-               SkRect          r;
-               SkRect16        ir;
-               SkPoint         pts[2];
-
-               pts[0] = pt0;
-               pts[1] = pt1;
-               r.set(pts, 2);
-               r.roundOut(&ir);
-
-               if (clip->quickReject(ir))
-                       return;
-               if (clip->quickContains(ir))
-                       clip = nil;
-               else
-               {
-                       blitter = clipper.apply(blitter, clip);
-               }
-       }
-
-       SkFDot6 dx = x1 - x0;
-       SkFDot6 dy = y1 - y0;
-
-       if (SkAbs32(dx) > SkAbs32(dy))  // mostly horizontal
-       {
-               if (x0 > x1)    // we want to go left-to-right
-               {
-                       SkTSwap<SkFDot6>(x0, x1);
-                       SkTSwap<SkFDot6>(y0, y1);
-               }
-               int ix0 = SkFDot6Round(x0);
-               int ix1 = SkFDot6Round(x1);
-               if (ix0 == ix1) // too short to draw
-                       return;
-
-               SkFixed slope = SkFixedDiv(dy, dx);
-               SkFixed startY = SkFDot6ToFixed(y0 + SkFixedMul(slope, (32 - x0) & 63));
-
-               horiline(ix0, ix1, startY, slope, blitter);
-       }
-       else                            // mostly vertical
-       {
-               if (y0 > y1)    // we want to go top-to-bottom
-               {
-                       SkTSwap<SkFDot6>(x0, x1);
-                       SkTSwap<SkFDot6>(y0, y1);
-               }
-               int iy0 = SkFDot6Round(y0);
-               int iy1 = SkFDot6Round(y1);
-               if (iy0 == iy1) // too short to draw
-                       return;
-
-               SkFixed slope = SkFixedDiv(dx, dy);
-               SkFixed startX = SkFDot6ToFixed(x0 + SkFixedMul(slope, (32 - y0) & 63));
-
-               vertline(iy0, iy1, startX, slope, blitter);
-       }
+    SkBlitterClipper    clipper;
+
+    SkFDot6 x0 = SkScalarToFDot6(pt0.fX);
+    SkFDot6 y0 = SkScalarToFDot6(pt0.fY);
+    SkFDot6 x1 = SkScalarToFDot6(pt1.fX);
+    SkFDot6 y1 = SkScalarToFDot6(pt1.fY);
+
+    if (clip)
+    {
+        SkRect      r;
+        SkRect16    ir;
+        SkPoint     pts[2];
+
+        pts[0] = pt0;
+        pts[1] = pt1;
+        r.set(pts, 2);
+        r.roundOut(&ir);
+
+        if (clip->quickReject(ir))
+            return;
+        if (clip->quickContains(ir))
+            clip = nil;
+        else
+        {
+            blitter = clipper.apply(blitter, clip);
+        }
+    }
+
+    SkFDot6 dx = x1 - x0;
+    SkFDot6 dy = y1 - y0;
+
+    if (SkAbs32(dx) > SkAbs32(dy))  // mostly horizontal
+    {
+        if (x0 > x1)    // we want to go left-to-right
+        {
+            SkTSwap<SkFDot6>(x0, x1);
+            SkTSwap<SkFDot6>(y0, y1);
+        }
+        int ix0 = SkFDot6Round(x0);
+        int ix1 = SkFDot6Round(x1);
+        if (ix0 == ix1) // too short to draw
+            return;
+
+        SkFixed slope = SkFixedDiv(dy, dx);
+        SkFixed startY = SkFDot6ToFixed(y0 + SkFixedMul(slope, (32 - x0) & 63));
+
+        horiline(ix0, ix1, startY, slope, blitter);
+    }
+    else                // mostly vertical
+    {
+        if (y0 > y1)    // we want to go top-to-bottom
+        {
+            SkTSwap<SkFDot6>(x0, x1);
+            SkTSwap<SkFDot6>(y0, y1);
+        }
+        int iy0 = SkFDot6Round(y0);
+        int iy1 = SkFDot6Round(y1);
+        if (iy0 == iy1) // too short to draw
+            return;
+
+        SkFixed slope = SkFixedDiv(dx, dy);
+        SkFixed startX = SkFDot6ToFixed(x0 + SkFixedMul(slope, (32 - y0) & 63));
+
+        vertline(iy0, iy1, startX, slope, blitter);
+    }
 }
 
 void SkScan::HairRect(const SkRect& rect, const SkRegion* clip, SkBlitter* blitter)
 {
-       SkPoint p0, p1;
-
-       p0.set(rect.fLeft, rect.fTop);
-       p1.set(rect.fRight, rect.fTop);
-       SkScan::HairLine(p0, p1, clip, blitter);
-       p0.set(rect.fRight, rect.fBottom);
-       SkScan::HairLine(p0, p1, clip, blitter);
-       p1.set(rect.fLeft, rect.fBottom);
-       SkScan::HairLine(p0, p1, clip, blitter);
-       p0.set(rect.fLeft, rect.fTop);
-       SkScan::HairLine(p0, p1, clip, blitter);
+    SkPoint p0, p1;
+
+    p0.set(rect.fLeft, rect.fTop);
+    p1.set(rect.fRight, rect.fTop);
+    SkScan::HairLine(p0, p1, clip, blitter);
+    p0.set(rect.fRight, rect.fBottom);
+    SkScan::HairLine(p0, p1, clip, blitter);
+    p1.set(rect.fLeft, rect.fBottom);
+    SkScan::HairLine(p0, p1, clip, blitter);
+    p0.set(rect.fLeft, rect.fTop);
+    SkScan::HairLine(p0, p1, clip, blitter);
 }
 
 /////////////////////////////////////////////////////////////////////////////////////////////////
@@ -114,141 +131,141 @@ void SkScan::HairRect(const SkRect& rect, const SkRegion* clip, SkBlitter* blitt
 
 static bool quad_too_curvy(const SkPoint pts[3])
 {
-       return true;
+    return true;
 }
 
 static void hairquad(const SkPoint pts[3], const SkRegion* clip, SkBlitter* blitter, int level,
-                                        void (*lineproc)(const SkPoint&, const SkPoint&, const SkRegion* clip, SkBlitter*))
+                     void (*lineproc)(const SkPoint&, const SkPoint&, const SkRegion* clip, SkBlitter*))
 {
 #if 1
-       if (level > 0 && quad_too_curvy(pts))
-       {
-               SkPoint tmp[5];
-
-               SkChopQuadAtHalf(pts, tmp);
-               hairquad(tmp, clip, blitter, level - 1, lineproc);
-               hairquad(&tmp[2], clip, blitter, level - 1, lineproc);
-       }
-       else
-               lineproc(pts[0], pts[2], clip, blitter);
+    if (level > 0 && quad_too_curvy(pts))
+    {
+        SkPoint tmp[5];
+
+        SkChopQuadAtHalf(pts, tmp);
+        hairquad(tmp, clip, blitter, level - 1, lineproc);
+        hairquad(&tmp[2], clip, blitter, level - 1, lineproc);
+    }
+    else
+        lineproc(pts[0], pts[2], clip, blitter);
 #else
-       lineproc(pts[0], pts[1], clip, blitter);
-       lineproc(pts[1], pts[2], clip, blitter);
+    lineproc(pts[0], pts[1], clip, blitter);
+    lineproc(pts[1], pts[2], clip, blitter);
 #endif
 }
 
 static bool cubic_too_curvy(const SkPoint pts[4])
 {
-       return true;
+    return true;
 }
 
 static void haircubic(const SkPoint pts[4], const SkRegion* clip, SkBlitter* blitter, int level,
-                                         void (*lineproc)(const SkPoint&, const SkPoint&, const SkRegion*, SkBlitter*))
+                      void (*lineproc)(const SkPoint&, const SkPoint&, const SkRegion*, SkBlitter*))
 {
-       if (level > 0 && cubic_too_curvy(pts))
-       {
-               SkPoint tmp[7];
-
-               SkChopCubicAt(pts, tmp, SK_Scalar1/2);
-               haircubic(tmp, clip, blitter, level - 1, lineproc);
-               haircubic(&tmp[3], clip, blitter, level - 1, lineproc);
-       }
-       else
-               lineproc(pts[0], pts[3], clip, blitter);
+    if (level > 0 && cubic_too_curvy(pts))
+    {
+        SkPoint tmp[7];
+
+        SkChopCubicAt(pts, tmp, SK_Scalar1/2);
+        haircubic(tmp, clip, blitter, level - 1, lineproc);
+        haircubic(&tmp[3], clip, blitter, level - 1, lineproc);
+    }
+    else
+        lineproc(pts[0], pts[3], clip, blitter);
 }
 
-#define kMaxCubicSubdivideLevel        6
-#define kMaxQuadSubdivideLevel 5
+#define kMaxCubicSubdivideLevel 6
+#define kMaxQuadSubdivideLevel  5
 
 static void hair_path(const SkPath& path, const SkRegion* clip, SkBlitter* blitter,
-                                         void (*lineproc)(const SkPoint&, const SkPoint&, const SkRegion*, SkBlitter*))
+                      void (*lineproc)(const SkPoint&, const SkPoint&, const SkRegion*, SkBlitter*))
 {
-       if (path.isEmpty())
-               return;
-
-       const SkRect16* clipR = nil;
-
-       if (clip)
-       {
-               SkRect          bounds;
-               SkRect16        ibounds;
-
-               path.computeBounds(&bounds, SkPath::kFast_BoundsType);
-               bounds.roundOut(&ibounds);
-               ibounds.inset(-1, -1);
-
-               if (clip->quickReject(ibounds))
-                       return;
-
-               if (clip->quickContains(ibounds))
-                       clip = nil;
-               else
-                       clipR = &clip->getBounds();
-       }
-
-       SkPath::Iter    iter(path, false);
-       SkPoint                 pts[4];
-       SkPath::Verb    verb;
-
-       while ((verb = iter.next(pts)) != SkPath::kDone_Verb)
-       {
-               switch (verb) {
-               case SkPath::kLine_Verb:
-                       lineproc(pts[0], pts[1], clip, blitter);
-                       break;
-               case SkPath::kQuad_Verb:
-                       hairquad(pts, clip, blitter, kMaxQuadSubdivideLevel, lineproc);
-                       break;
-               case SkPath::kCubic_Verb:
-                       haircubic(pts, clip, blitter, kMaxCubicSubdivideLevel, lineproc);
-                       break;
-               default:
-                       break;
-               }
-       }
+    if (path.isEmpty())
+        return;
+
+    const SkRect16* clipR = nil;
+
+    if (clip)
+    {
+        SkRect      bounds;
+        SkRect16    ibounds;
+
+        path.computeBounds(&bounds, SkPath::kFast_BoundsType);
+        bounds.roundOut(&ibounds);
+        ibounds.inset(-1, -1);
+
+        if (clip->quickReject(ibounds))
+            return;
+
+        if (clip->quickContains(ibounds))
+            clip = nil;
+        else
+            clipR = &clip->getBounds();
+    }
+
+    SkPath::Iter    iter(path, false);
+    SkPoint         pts[4];
+    SkPath::Verb    verb;
+
+    while ((verb = iter.next(pts)) != SkPath::kDone_Verb)
+    {
+        switch (verb) {
+        case SkPath::kLine_Verb:
+            lineproc(pts[0], pts[1], clip, blitter);
+            break;
+        case SkPath::kQuad_Verb:
+            hairquad(pts, clip, blitter, kMaxQuadSubdivideLevel, lineproc);
+            break;
+        case SkPath::kCubic_Verb:
+            haircubic(pts, clip, blitter, kMaxCubicSubdivideLevel, lineproc);
+            break;
+        default:
+            break;
+        }
+    }
 }
 
 void SkScan::HairPath(const SkPath& path, const SkRegion* clip, SkBlitter* blitter)
 {
-       hair_path(path, clip, blitter, SkScan::HairLine);
+    hair_path(path, clip, blitter, SkScan::HairLine);
 }
 
 void SkScan::AntiHairPath(const SkPath& path, const SkRegion* clip, SkBlitter* blitter)
 {
-       hair_path(path, clip, blitter, SkScan::AntiHairLine);
+    hair_path(path, clip, blitter, SkScan::AntiHairLine);
 }
 
 ////////////////////////////////////////////////////////////////////////////////
 
 void SkScan::FrameRect(const SkRect& r, SkScalar diameter, const SkRegion* clip, SkBlitter* blitter)
 {
-       SkASSERT(diameter > 0);
-
-       if (r.isEmpty())
-               return;
-
-       SkScalar radius = diameter / 2;
-       SkRect   outer, tmp;
-
-       outer.set(      r.fLeft - radius, r.fTop - radius,
-                               r.fRight + radius, r.fBottom + radius);
-
-       if (r.width() <= diameter || r.height() <= diameter)
-       {
-               SkScan::FillRect(outer, clip, blitter);
-               return;
-       }
-
-       tmp.set(outer.fLeft, outer.fTop, outer.fRight, outer.fTop + diameter);
-       SkScan::FillRect(tmp, clip, blitter);
-       tmp.fTop = outer.fBottom - diameter;
-       tmp.fBottom = outer.fBottom;
-       SkScan::FillRect(tmp, clip, blitter);
-
-       tmp.set(outer.fLeft, outer.fTop + diameter, outer.fLeft + diameter, outer.fBottom - diameter);
-       SkScan::FillRect(tmp, clip, blitter);
-       tmp.fLeft = outer.fRight - diameter;
-       tmp.fRight = outer.fRight;
-       SkScan::FillRect(tmp, clip, blitter);
+    SkASSERT(diameter > 0);
+
+    if (r.isEmpty())
+        return;
+
+    SkScalar radius = diameter / 2;
+    SkRect   outer, tmp;
+
+    outer.set(  r.fLeft - radius, r.fTop - radius,
+                r.fRight + radius, r.fBottom + radius);
+
+    if (r.width() <= diameter || r.height() <= diameter)
+    {
+        SkScan::FillRect(outer, clip, blitter);
+        return;
+    }
+
+    tmp.set(outer.fLeft, outer.fTop, outer.fRight, outer.fTop + diameter);
+    SkScan::FillRect(tmp, clip, blitter);
+    tmp.fTop = outer.fBottom - diameter;
+    tmp.fBottom = outer.fBottom;
+    SkScan::FillRect(tmp, clip, blitter);
+
+    tmp.set(outer.fLeft, outer.fTop + diameter, outer.fLeft + diameter, outer.fBottom - diameter);
+    SkScan::FillRect(tmp, clip, blitter);
+    tmp.fLeft = outer.fRight - diameter;
+    tmp.fRight = outer.fRight;
+    SkScan::FillRect(tmp, clip, blitter);
 }
 
index 2518bb5..29f543e 100644 (file)
@@ -1,3 +1,20 @@
+/* libs/graphics/sgl/SkScan_Path.cpp
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #include "SkScanPriv.h"
 #include "SkBlitter.h"
 #include "SkEdge.h"
 #include "SkRegion.h"
 #include "SkTemplates.h"
 
-#define kEDGE_HEAD_Y   SK_MinS16
-#define kEDGE_TAIL_Y   SK_MaxS16
+#define kEDGE_HEAD_Y    SK_MinS16
+#define kEDGE_TAIL_Y    SK_MaxS16
 
 #ifdef SK_DEBUG
-       static void validate_sort(const SkEdge* edge)
-       {
-               int     y = kEDGE_HEAD_Y;
-
-               while (edge->fFirstY != SK_MaxS16)
-               {
-                       edge->validate();
-                       SkASSERT(y <= edge->fFirstY);
-
-                       y = edge->fFirstY;
-                       edge = edge->fNext;
-               }
-       }
+    static void validate_sort(const SkEdge* edge)
+    {
+        int y = kEDGE_HEAD_Y;
+
+        while (edge->fFirstY != SK_MaxS16)
+        {
+            edge->validate();
+            SkASSERT(y <= edge->fFirstY);
+
+            y = edge->fFirstY;
+            edge = edge->fNext;
+        }
+    }
 #else
-       #define validate_sort(edge)
+    #define validate_sort(edge)
 #endif
 
 static inline void remove_edge(SkEdge* edge)
 {
-       edge->fPrev->fNext = edge->fNext;
-       edge->fNext->fPrev = edge->fPrev;
+    edge->fPrev->fNext = edge->fNext;
+    edge->fNext->fPrev = edge->fPrev;
 }
 
 static inline void swap_edges(SkEdge* prev, SkEdge* next)
 {
-       SkASSERT(prev->fNext == next && next->fPrev == prev);
+    SkASSERT(prev->fNext == next && next->fPrev == prev);
 
-       // remove prev from the list
-       prev->fPrev->fNext = next;
-       next->fPrev = prev->fPrev;
+    // remove prev from the list
+    prev->fPrev->fNext = next;
+    next->fPrev = prev->fPrev;
 
-       // insert prev after next
-       prev->fNext = next->fNext;
-       next->fNext->fPrev = prev;
-       next->fNext = prev;
-       prev->fPrev = next;
+    // insert prev after next
+    prev->fNext = next->fNext;
+    next->fNext->fPrev = prev;
+    next->fNext = prev;
+    prev->fPrev = next;
 }
 
 static void backward_insert_edge_based_on_x(SkEdge* edge SkDECLAREPARAM(int, curr_y))
 {
-       SkFixed x = edge->fX;
+    SkFixed x = edge->fX;
 
-       for (;;)
-       {
-               SkEdge* prev = edge->fPrev;
-               
-               // add 1 to curr_y since we may have added new edges (built from curves)
-               // that start on the next scanline
-               SkASSERT(prev && prev->fFirstY <= curr_y + 1);
+    for (;;)
+    {
+        SkEdge* prev = edge->fPrev;
+        
+        // add 1 to curr_y since we may have added new edges (built from curves)
+        // that start on the next scanline
+        SkASSERT(prev && prev->fFirstY <= curr_y + 1);
 
-               if (prev->fX <= x)
-                       break;
+        if (prev->fX <= x)
+            break;
 
-               swap_edges(prev, edge);
-       }
+        swap_edges(prev, edge);
+    }
 }
 
 static void insert_new_edges(SkEdge* newEdge, int curr_y)
 {
-       SkASSERT(newEdge->fFirstY >= curr_y);
-
-       while (newEdge->fFirstY == curr_y)
-       {
-               SkEdge* next = newEdge->fNext;
-               backward_insert_edge_based_on_x(newEdge  SkPARAM(curr_y));
-               newEdge = next;
-       }
+    SkASSERT(newEdge->fFirstY >= curr_y);
+
+    while (newEdge->fFirstY == curr_y)
+    {
+        SkEdge* next = newEdge->fNext;
+        backward_insert_edge_based_on_x(newEdge  SkPARAM(curr_y));
+        newEdge = next;
+    }
 }
 
 #ifdef SK_DEBUG
 static void validate_edges_for_y(const SkEdge* edge, int curr_y)
 {
-       while (edge->fFirstY <= curr_y)
-       {
-               SkASSERT(edge->fPrev && edge->fNext);
-               SkASSERT(edge->fPrev->fNext == edge);
-               SkASSERT(edge->fNext->fPrev == edge);
-               SkASSERT(edge->fFirstY <= edge->fLastY);
-
-               SkASSERT(edge->fPrev->fX <= edge->fX);
-               edge = edge->fNext;
-       }
+    while (edge->fFirstY <= curr_y)
+    {
+        SkASSERT(edge->fPrev && edge->fNext);
+        SkASSERT(edge->fPrev->fNext == edge);
+        SkASSERT(edge->fNext->fPrev == edge);
+        SkASSERT(edge->fFirstY <= edge->fLastY);
+
+        SkASSERT(edge->fPrev->fX <= edge->fX);
+        edge = edge->fNext;
+    }
 }
 #else
-       #define validate_edges_for_y(edge, curr_y)
+    #define validate_edges_for_y(edge, curr_y)
 #endif
 
-#if defined _WIN32 && _MSC_VER >= 1300 // disable warning : local variable used without having been initialized
+#if defined _WIN32 && _MSC_VER >= 1300  // disable warning : local variable used without having been initialized
 #pragma warning ( push )
 #pragma warning ( disable : 4701 )
 #endif
 
 static void walk_edges(SkEdge* prevHead, SkPath::FillType fillType, SkBlitter* blitter,
-                                          int stop_y)
+                       int stop_y)
 {
-       validate_sort(prevHead->fNext);
-
-       int     curr_y = prevHead->fNext->fFirstY;
-       int windingMask = (fillType == SkPath::kWinding_FillType) ? -1 : 1;
-
-       for (;;)
-       {
-               int             w = 0;
-               int             left SK_INIT_TO_AVOID_WARNING;
-               bool    in_interval     = false;
-               SkEdge* currE = prevHead->fNext;
-               SkFixed prevX = prevHead->fX;
-
-               validate_edges_for_y(currE, curr_y);
-
-               while (currE->fFirstY <= curr_y)
-               {
-                       SkASSERT(currE->fLastY >= curr_y);
-
-                       int x = (currE->fX + SK_Fixed1/2) >> 16;
-                       w += currE->fWinding;
-                       if ((w & windingMask) == 0)     // we finished an interval
-                       {
-                               SkASSERT(in_interval);
-                               int width = x - left;
-                               SkASSERT(width >= 0);
-                               if (width)
-                                       blitter->blitH(left, curr_y, width);
-                               in_interval = false;
-                       }
-                       else if (!in_interval)
-                       {
-                               left = x;
-                               in_interval = true;
-                       }
-
-                       SkEdge* next = currE->fNext;
-                       SkFixed newX;
-
-                       if (currE->fLastY == curr_y)    // are we done with this edge?
-                       {
-                               if (currE->fCurveCount < 0)
-                               {
-                                       if (((SkCubicEdge*)currE)->updateCubic())
-                                       {
-                                               SkASSERT(currE->fFirstY == curr_y + 1);
-                                               
-                                               newX = currE->fX;
-                                               goto NEXT_X;
-                                       }
-                               }
-                               else if (currE->fCurveCount > 0)
-                               {
-                                       if (((SkQuadraticEdge*)currE)->updateQuadratic())
-                                       {
-                                               newX = currE->fX;
-                                               goto NEXT_X;
-                                       }
-                               }
-                               remove_edge(currE);
-                       }
-                       else
-                       {
-                               SkASSERT(currE->fLastY > curr_y);
-                               newX = currE->fX + currE->fDX;
-                               currE->fX = newX;
-                       NEXT_X:
-                               if (newX < prevX)       // ripple currE backwards until it is x-sorted
-                                       backward_insert_edge_based_on_x(currE  SkPARAM(curr_y));
-                               else
-                                       prevX = newX;
-                       }
-                       currE = next;
-                       SkASSERT(currE);
-               }
-
-               curr_y += 1;
-               if (curr_y >= stop_y)
-                       break;
-
-               // now currE points to the first edge with a Yint larger than curr_y
-               insert_new_edges(currE, curr_y);
-       }
+    validate_sort(prevHead->fNext);
+
+    int curr_y = prevHead->fNext->fFirstY;
+    int windingMask = (fillType == SkPath::kWinding_FillType) ? -1 : 1;
+
+    for (;;)
+    {
+        int     w = 0;
+        int     left SK_INIT_TO_AVOID_WARNING;
+        bool    in_interval = false;
+        SkEdge* currE = prevHead->fNext;
+        SkFixed prevX = prevHead->fX;
+
+        validate_edges_for_y(currE, curr_y);
+
+        while (currE->fFirstY <= curr_y)
+        {
+            SkASSERT(currE->fLastY >= curr_y);
+
+            int x = (currE->fX + SK_Fixed1/2) >> 16;
+            w += currE->fWinding;
+            if ((w & windingMask) == 0) // we finished an interval
+            {
+                SkASSERT(in_interval);
+                int width = x - left;
+                SkASSERT(width >= 0);
+                if (width)
+                    blitter->blitH(left, curr_y, width);
+                in_interval = false;
+            }
+            else if (!in_interval)
+            {
+                left = x;
+                in_interval = true;
+            }
+
+            SkEdge* next = currE->fNext;
+            SkFixed newX;
+
+            if (currE->fLastY == curr_y)    // are we done with this edge?
+            {
+                if (currE->fCurveCount < 0)
+                {
+                    if (((SkCubicEdge*)currE)->updateCubic())
+                    {
+                        SkASSERT(currE->fFirstY == curr_y + 1);
+                        
+                        newX = currE->fX;
+                        goto NEXT_X;
+                    }
+                }
+                else if (currE->fCurveCount > 0)
+                {
+                    if (((SkQuadraticEdge*)currE)->updateQuadratic())
+                    {
+                        newX = currE->fX;
+                        goto NEXT_X;
+                    }
+                }
+                remove_edge(currE);
+            }
+            else
+            {
+                SkASSERT(currE->fLastY > curr_y);
+                newX = currE->fX + currE->fDX;
+                currE->fX = newX;
+            NEXT_X:
+                if (newX < prevX)   // ripple currE backwards until it is x-sorted
+                    backward_insert_edge_based_on_x(currE  SkPARAM(curr_y));
+                else
+                    prevX = newX;
+            }
+            currE = next;
+            SkASSERT(currE);
+        }
+
+        curr_y += 1;
+        if (curr_y >= stop_y)
+            break;
+
+        // now currE points to the first edge with a Yint larger than curr_y
+        insert_new_edges(currE, curr_y);
+    }
 }
 
 #if defined _WIN32 && _MSC_VER >= 1300
 #pragma warning ( pop )
 #endif
 
-/*     Our line edge relies on the maximum span being <= 512, so that it can
-       use FDot6 and keep the dx,dy in 16bits (for much faster slope divide).
-       This function returns true if the specified line is too big.
+/*  Our line edge relies on the maximum span being <= 512, so that it can
+    use FDot6 and keep the dx,dy in 16bits (for much faster slope divide).
+    This function returns true if the specified line is too big.
 */
 static inline bool line_too_big(const SkPoint pts[2])
 {
-       SkScalar dx = pts[1].fX - pts[0].fX;
-       SkScalar dy = pts[1].fY - pts[0].fY;
+    SkScalar dx = pts[1].fX - pts[0].fX;
+    SkScalar dy = pts[1].fY - pts[0].fY;
 
-       return  SkScalarAbs(dx) > SkIntToScalar(511) ||
-                       SkScalarAbs(dy) > SkIntToScalar(511);
+    return  SkScalarAbs(dx) > SkIntToScalar(511) ||
+            SkScalarAbs(dy) > SkIntToScalar(511);
 }
 
 static int build_edges(SkEdge edge[], const SkPath& path, const SkRect16* clipRect, SkEdge* list[], int shiftUp)
 {
-       SkEdge**                start = list;
-       SkPath::Iter    iter(path, true);
-       SkPoint                 pts[4];
-       SkPath::Verb    verb;
-
-       while ((verb = iter.next(pts)) != SkPath::kDone_Verb)
-       {
-               switch (verb) {
-               case SkPath::kLine_Verb:
-                       if (edge->setLine(pts, clipRect, shiftUp))
-                       {
-                               *list++ = edge;
-                               edge = (SkEdge*)((char*)edge + sizeof(SkEdge));
-                       }
-                       break;
-               case SkPath::kQuad_Verb:
-                       {
-                               SkPoint tmp[5];
-                               SkPoint* p = tmp;
-                               int             count = SkChopQuadAtYExtrema(pts, tmp);
-
-                               do {
-                                       if (((SkQuadraticEdge*)edge)->setQuadratic(p, clipRect, shiftUp))
-                                       {
-                                               *list++ = edge;
-                                               edge = (SkEdge*)((char*)edge + sizeof(SkQuadraticEdge));
-                                       }
-                                       p += 2;
-                               } while (--count >= 0);
-                       }
-                       break;
-               case SkPath::kCubic_Verb:
-                       {
-                               SkPoint tmp[10];
-                               SkPoint* p = tmp;
-                               int             count = SkChopCubicAtYExtrema(pts, tmp);                                
-                               SkASSERT(count >= 0 && count <= 2);
-
-                               do {
-                                       if (((SkCubicEdge*)edge)->setCubic(p, clipRect, shiftUp))
-                                       {
-                                               *list++ = edge;
-                                               edge = (SkEdge*)((char*)edge + sizeof(SkCubicEdge));
-                                       }
-                                       p += 3;
-                               } while (--count >= 0);
-                       }
-                       break;
-               default:
-                       break;
-               }
-       }
-       return (int)(list - start);
+    SkEdge**        start = list;
+    SkPath::Iter    iter(path, true);
+    SkPoint         pts[4];
+    SkPath::Verb    verb;
+
+    while ((verb = iter.next(pts)) != SkPath::kDone_Verb)
+    {
+        switch (verb) {
+        case SkPath::kLine_Verb:
+            if (edge->setLine(pts, clipRect, shiftUp))
+            {
+                *list++ = edge;
+                edge = (SkEdge*)((char*)edge + sizeof(SkEdge));
+            }
+            break;
+        case SkPath::kQuad_Verb:
+            {
+                SkPoint tmp[5];
+                SkPoint* p = tmp;
+                int     count = SkChopQuadAtYExtrema(pts, tmp);
+
+                do {
+                    if (((SkQuadraticEdge*)edge)->setQuadratic(p, clipRect, shiftUp))
+                    {
+                        *list++ = edge;
+                        edge = (SkEdge*)((char*)edge + sizeof(SkQuadraticEdge));
+                    }
+                    p += 2;
+                } while (--count >= 0);
+            }
+            break;
+        case SkPath::kCubic_Verb:
+            {
+                SkPoint tmp[10];
+                SkPoint* p = tmp;
+                int     count = SkChopCubicAtYExtrema(pts, tmp);                
+                SkASSERT(count >= 0 && count <= 2);
+
+                do {
+                    if (((SkCubicEdge*)edge)->setCubic(p, clipRect, shiftUp))
+                    {
+                        *list++ = edge;
+                        edge = (SkEdge*)((char*)edge + sizeof(SkCubicEdge));
+                    }
+                    p += 3;
+                } while (--count >= 0);
+            }
+            break;
+        default:
+            break;
+        }
+    }
+    return (int)(list - start);
 }
 
 extern "C" {
-       static int edge_compare(const void* a, const void* b)
-       {
-               const SkEdge* edgea = *(const SkEdge**)a;
-               const SkEdge* edgeb = *(const SkEdge**)b;
-
-               int valuea = edgea->fFirstY;
-               int valueb = edgeb->fFirstY;
-
-               if (valuea == valueb)
-               {
-                       valuea = edgea->fX;
-                       valueb = edgeb->fX;
-               }
-               return valuea - valueb;
-       }
+    static int edge_compare(const void* a, const void* b)
+    {
+        const SkEdge* edgea = *(const SkEdge**)a;
+        const SkEdge* edgeb = *(const SkEdge**)b;
+
+        int valuea = edgea->fFirstY;
+        int valueb = edgeb->fFirstY;
+
+        if (valuea == valueb)
+        {
+            valuea = edgea->fX;
+            valueb = edgeb->fX;
+        }
+        return valuea - valueb;
+    }
 }
 
 static SkEdge* sort_edges(SkEdge* list[], int count, SkEdge** last)
 {
-       qsort(list, count, sizeof(SkEdge*), edge_compare);
+    qsort(list, count, sizeof(SkEdge*), edge_compare);
 
-       // now make the edges linked in sorted order
-       for (int i = 1; i < count; i++)
-       {
-               list[i - 1]->fNext = list[i];
-               list[i]->fPrev = list[i - 1];
-       }
+    // now make the edges linked in sorted order
+    for (int i = 1; i < count; i++)
+    {
+        list[i - 1]->fNext = list[i];
+        list[i]->fPrev = list[i - 1];
+    }
 
-       *last = list[count - 1];
-       return list[0];
+    *last = list[count - 1];
+    return list[0];
 }
 
 static int worst_case_edge_count(const SkPath& path, size_t* storage)
 {
-       size_t  size = 0;
-       int             edgeCount = 0;
-
-       SkPath::Iter    iter(path, true);
-       SkPath::Verb    verb;
-
-       while ((verb = iter.next(nil)) != SkPath::kDone_Verb)
-       {
-               switch (verb) {
-               case SkPath::kLine_Verb:
-                       edgeCount += 1;
-                       size += sizeof(SkQuadraticEdge);        // treat line like Quad (in case its > 512)
-                       break;
-               case SkPath::kQuad_Verb:
-                       edgeCount += 2;                                         // might need 2 edges when we chop on Y extrema
-                       size += 2 * sizeof(SkQuadraticEdge);
-                       break;
-               case SkPath::kCubic_Verb:
-                       edgeCount += 3;                                         // might need 3 edges when we chop on Y extrema
-                       size += 3 * sizeof(SkCubicEdge);
-                       break;
-               default:
-                       break;
-               }
-       }
-
-       SkASSERT(storage);
-       *storage = size;
-       return edgeCount;
+    size_t  size = 0;
+    int     edgeCount = 0;
+
+    SkPath::Iter    iter(path, true);
+    SkPath::Verb    verb;
+
+    while ((verb = iter.next(nil)) != SkPath::kDone_Verb)
+    {
+        switch (verb) {
+        case SkPath::kLine_Verb:
+            edgeCount += 1;
+            size += sizeof(SkQuadraticEdge);    // treat line like Quad (in case its > 512)
+            break;
+        case SkPath::kQuad_Verb:
+            edgeCount += 2;                     // might need 2 edges when we chop on Y extrema
+            size += 2 * sizeof(SkQuadraticEdge);
+            break;
+        case SkPath::kCubic_Verb:
+            edgeCount += 3;                     // might need 3 edges when we chop on Y extrema
+            size += 3 * sizeof(SkCubicEdge);
+            break;
+        default:
+            break;
+        }
+    }
+
+    SkASSERT(storage);
+    *storage = size;
+    return edgeCount;
 }
 
 void sk_fill_path(const SkPath& path, const SkRect16* clipRect, SkBlitter* blitter,
-                                 const SkRect16& ir, int shiftEdgesUp)
+                  const SkRect16& ir, int shiftEdgesUp)
 {
-       SkASSERT(&path && blitter);
-
-       size_t  size;
-       int             maxCount = worst_case_edge_count(path, &size);
-
-       SkAutoMalloc    memory(maxCount * sizeof(SkEdge*) + size);
-       SkEdge**                list = (SkEdge**)memory.get();
-       SkEdge*                 edge = (SkEdge*)(list + maxCount);
-       int                             count = build_edges(edge, path, clipRect, list, shiftEdgesUp);
-       SkEdge                  headEdge, tailEdge, *last;
-
-       SkASSERT(count <= maxCount);
-       if (count == 0)
-               return;
-       SkASSERT(count > 1);
-
-       // this returns the first and last edge after they're sorted into a dlink list
-       edge = sort_edges(list, count, &last);
-
-       headEdge.fPrev = nil;
-       headEdge.fNext = edge;
-       headEdge.fFirstY = kEDGE_HEAD_Y;
-       headEdge.fX = SK_MinS32;
-       edge->fPrev = &headEdge;
-
-       tailEdge.fPrev = last;
-       tailEdge.fNext = nil;
-       tailEdge.fFirstY = kEDGE_TAIL_Y;
-       last->fNext = &tailEdge;
-
-       // now edge is the head of the sorted linklist
-       int     stop_y = ir.fBottom;
-       if (clipRect && stop_y > clipRect->fBottom)
-               stop_y = clipRect->fBottom;
-       walk_edges(&headEdge, path.getFillType(), blitter, stop_y);
+    SkASSERT(&path && blitter);
+
+    size_t  size;
+    int     maxCount = worst_case_edge_count(path, &size);
+
+    SkAutoMalloc    memory(maxCount * sizeof(SkEdge*) + size);
+    SkEdge**        list = (SkEdge**)memory.get();
+    SkEdge*         edge = (SkEdge*)(list + maxCount);
+    int             count = build_edges(edge, path, clipRect, list, shiftEdgesUp);
+    SkEdge          headEdge, tailEdge, *last;
+
+    SkASSERT(count <= maxCount);
+    if (count == 0)
+        return;
+    SkASSERT(count > 1);
+
+    // this returns the first and last edge after they're sorted into a dlink list
+    edge = sort_edges(list, count, &last);
+
+    headEdge.fPrev = nil;
+    headEdge.fNext = edge;
+    headEdge.fFirstY = kEDGE_HEAD_Y;
+    headEdge.fX = SK_MinS32;
+    edge->fPrev = &headEdge;
+
+    tailEdge.fPrev = last;
+    tailEdge.fNext = nil;
+    tailEdge.fFirstY = kEDGE_TAIL_Y;
+    last->fNext = &tailEdge;
+
+    // now edge is the head of the sorted linklist
+    int stop_y = ir.fBottom;
+    if (clipRect && stop_y > clipRect->fBottom)
+        stop_y = clipRect->fBottom;
+    walk_edges(&headEdge, path.getFillType(), blitter, stop_y);
 }
 
 /////////////////////////////////////////////////////////////////////////////////////
 
 SkScanClipper::SkScanClipper(SkBlitter* blitter, const SkRegion* clip, const SkRect16& ir)
 {
-       fBlitter = nil;         // nil means blit nothing
-       fClipRect = nil;
-
-       if (clip)
-       {
-               fClipRect = &clip->getBounds();
-               if (!SkRect16::Intersects(*fClipRect, ir))      // completely clipped out
-                       return;
-
-               if (clip->isRect())
-               {
-                       if (fClipRect->contains(ir))
-                               fClipRect = nil;
-                       else
-                       {
-                               // only need a wrapper blitter if we're horizontally clipped
-                               if (fClipRect->fLeft > ir.fLeft || fClipRect->fRight < ir.fRight)
-                               {
-                                       fRectBlitter.init(blitter, *fClipRect);
-                                       blitter = &fRectBlitter;
-                               }
-                       }
-               }
-               else
-               {
-                       fRgnBlitter.init(blitter, clip);
-                       blitter = &fRgnBlitter;
-               }
-       }
-       fBlitter = blitter;
+    fBlitter = nil;     // nil means blit nothing
+    fClipRect = nil;
+
+    if (clip)
+    {
+        fClipRect = &clip->getBounds();
+        if (!SkRect16::Intersects(*fClipRect, ir))  // completely clipped out
+            return;
+
+        if (clip->isRect())
+        {
+            if (fClipRect->contains(ir))
+                fClipRect = nil;
+            else
+            {
+                // only need a wrapper blitter if we're horizontally clipped
+                if (fClipRect->fLeft > ir.fLeft || fClipRect->fRight < ir.fRight)
+                {
+                    fRectBlitter.init(blitter, *fClipRect);
+                    blitter = &fRectBlitter;
+                }
+            }
+        }
+        else
+        {
+            fRgnBlitter.init(blitter, clip);
+            blitter = &fRgnBlitter;
+        }
+    }
+    fBlitter = blitter;
 }
 
 /////////////////////////////////////////////////////////////////////////////////////
 
 void SkScan::FillPath(const SkPath& path, const SkRegion* clip, SkBlitter* blitter)
 {
-       if (clip && clip->isEmpty())
-               return;
+    if (clip && clip->isEmpty())
+        return;
 
-       SkRect          r;
-       SkRect16        ir;
+    SkRect      r;
+    SkRect16    ir;
 
-       path.computeBounds(&r, SkPath::kFast_BoundsType);
-       r.round(&ir);
-       if (ir.isEmpty())
-               return;
+    path.computeBounds(&r, SkPath::kFast_BoundsType);
+    r.round(&ir);
+    if (ir.isEmpty())
+        return;
 
-       SkScanClipper   clipper(blitter, clip, ir);
+    SkScanClipper   clipper(blitter, clip, ir);
 
-       blitter = clipper.getBlitter();
-       if (blitter)
-               sk_fill_path(path, clipper.getClipRect(), blitter, ir, 0);
+    blitter = clipper.getBlitter();
+    if (blitter)
+        sk_fill_path(path, clipper.getClipRect(), blitter, ir, 0);
 }
 
index 6d1ac3e..7ec5ff7 100644 (file)
+/* libs/graphics/sgl/SkShader.cpp
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #include "SkShader.h"
 #include "SkPaint.h"
 
-SkShader::SkShader() : fLocalMatrix(nil)
+SkShader::SkShader() : fLocalMatrix(NULL)
 {
 }
 
 SkShader::~SkShader()
 {
-       sk_free(fLocalMatrix);
+    sk_free(fLocalMatrix);
 }
 
 void SkShader::setLocalMatrix(const SkMatrix& matrix)
 {
-       if (matrix.isIdentity())
-       {
-               if (fLocalMatrix)
-               {
-                       sk_free(fLocalMatrix);
-                       fLocalMatrix = nil;
-               }
-       }
-       else
-       {
-               if (fLocalMatrix == nil)
-                       fLocalMatrix = (SkMatrix*)sk_malloc_throw(sizeof(SkMatrix));
-               *fLocalMatrix = matrix;
-       }
+    if (matrix.isIdentity())
+    {
+        if (fLocalMatrix)
+        {
+            sk_free(fLocalMatrix);
+            fLocalMatrix = NULL;
+        }
+    }
+    else
+    {
+        if (fLocalMatrix == NULL)
+            fLocalMatrix = (SkMatrix*)sk_malloc_throw(sizeof(SkMatrix));
+        *fLocalMatrix = matrix;
+    }
 }
 
 bool SkShader::setContext(const SkBitmap& device,
-                                                 const SkPaint& paint,
-                                                 const SkMatrix& matrix)
-{
-       const SkMatrix* m = &matrix;
-       SkMatrix                total;
-
-       fDeviceConfig = SkToU8(device.getConfig());
-       fPaintAlpha = paint.getAlpha();
-       if (fLocalMatrix)
-       {
-               total.setConcat(matrix, *fLocalMatrix);
-               m = &total;
-       }
-       if (m->invert(&fTotalInverse))
-       {
-               fInverseMapPtProc = fTotalInverse.getMapPtProc();
-               fTotalInverseClass = (U8)SkShader::ComputeMatrixClass(fTotalInverse);
-               return true;
-       }
-       return false;
-}
-
-U32 SkShader::getFlags()
-{
-       return 0;
+                          const SkPaint& paint,
+                          const SkMatrix& matrix)
+{
+    const SkMatrix* m = &matrix;
+    SkMatrix        total;
+
+    fDeviceConfig = SkToU8(device.getConfig());
+    fPaintAlpha = paint.getAlpha();
+    if (fLocalMatrix)
+    {
+        total.setConcat(matrix, *fLocalMatrix);
+        m = &total;
+    }
+    if (m->invert(&fTotalInverse))
+    {
+        fInverseMapPtProc = fTotalInverse.getMapPtProc();
+        fTotalInverseClass = (uint8_t)SkShader::ComputeMatrixClass(fTotalInverse);
+        return true;
+    }
+    return false;
 }
 
 #include "SkColorPriv.h"
 
-void SkShader::shadeSpanOpaque16(int x, int y, U16 span16[], int count)
+void SkShader::shadeSpan16(int x, int y, uint16_t span16[], int count)
 {
-       SkASSERT(span16);
-       SkASSERT(count > 0);
-       SkASSERT(this->canCallShadeSpanOpaque16());
+    SkASSERT(span16);
+    SkASSERT(count > 0);
+    SkASSERT(this->canCallShadeSpan16());
 
-       // basically, if we get here, the subclass screwed up
-       SkASSERT(!"kHasSpan16 flag is set, but shadeSpanOpaque16() not implemented");
+    // basically, if we get here, the subclass screwed up
+    SkASSERT(!"kHasSpan16 flag is set, but shadeSpan16() not implemented");
 }
 
-#define kTempColorQuadCount    6       // balance between speed (larger) and saving stack-space
-#define kTempColorCount                (kTempColorQuadCount << 2)      
+#define kTempColorQuadCount 6   // balance between speed (larger) and saving stack-space
+#define kTempColorCount     (kTempColorQuadCount << 2)  
 
 #ifdef SK_CPU_BENDIAN
-       #define SkU32BitShiftToByteOffset(shift)        (3 - ((shift) >> 3))
+    #define SkU32BitShiftToByteOffset(shift)    (3 - ((shift) >> 3))
 #else
-       #define SkU32BitShiftToByteOffset(shift)        ((shift) >> 3)
+    #define SkU32BitShiftToByteOffset(shift)    ((shift) >> 3)
 #endif
 
-void SkShader::shadeSpanAlpha(int x, int y, U8 alpha[], int count)
-{
-       SkASSERT(count > 0);
-
-       SkPMColor       colors[kTempColorCount];
-
-       while ((count -= kTempColorCount) >= 0)
-       {
-               this->shadeSpan(x, y, colors, kTempColorCount);
-               x += kTempColorCount;
-
-               const U8* srcA = (const U8*)colors + SkU32BitShiftToByteOffset(SK_A32_SHIFT);
-               int quads = kTempColorQuadCount;
-               do {
-                       U8CPU a0 = srcA[0];
-                       U8CPU a1 = srcA[4];
-                       U8CPU a2 = srcA[8];
-                       U8CPU a3 = srcA[12];
-                       srcA += 4*4;
-                       *alpha++ = SkToU8(a0);
-                       *alpha++ = SkToU8(a1);
-                       *alpha++ = SkToU8(a2);
-                       *alpha++ = SkToU8(a3);
-               } while (--quads != 0);
-       }
-       SkASSERT(count < 0);
-       SkASSERT(count + kTempColorCount >= 0);
-       if (count += kTempColorCount)
-       {
-               this->shadeSpan(x, y, colors, count);
-
-               const U8* srcA = (const U8*)colors + SkU32BitShiftToByteOffset(SK_A32_SHIFT);
-               do {
-                       *alpha++ = *srcA;
-                       srcA += 4;
-               } while (--count != 0);
-       }
+void SkShader::shadeSpanAlpha(int x, int y, uint8_t alpha[], int count)
+{
+    SkASSERT(count > 0);
+
+    SkPMColor   colors[kTempColorCount];
+
+    while ((count -= kTempColorCount) >= 0)
+    {
+        this->shadeSpan(x, y, colors, kTempColorCount);
+        x += kTempColorCount;
+
+        const uint8_t* srcA = (const uint8_t*)colors + SkU32BitShiftToByteOffset(SK_A32_SHIFT);
+        int quads = kTempColorQuadCount;
+        do {
+            U8CPU a0 = srcA[0];
+            U8CPU a1 = srcA[4];
+            U8CPU a2 = srcA[8];
+            U8CPU a3 = srcA[12];
+            srcA += 4*4;
+            *alpha++ = SkToU8(a0);
+            *alpha++ = SkToU8(a1);
+            *alpha++ = SkToU8(a2);
+            *alpha++ = SkToU8(a3);
+        } while (--quads != 0);
+    }
+    SkASSERT(count < 0);
+    SkASSERT(count + kTempColorCount >= 0);
+    if (count += kTempColorCount)
+    {
+        this->shadeSpan(x, y, colors, count);
+
+        const uint8_t* srcA = (const uint8_t*)colors + SkU32BitShiftToByteOffset(SK_A32_SHIFT);
+        do {
+            *alpha++ = *srcA;
+            srcA += 4;
+        } while (--count != 0);
+    }
 #if 0
-       do {
-               int n = count;
-               if (n > kTempColorCount)
-                       n = kTempColorCount;
-               SkASSERT(n > 0);
-
-               this->shadeSpan(x, y, colors, n);
-               x += n;
-               count -= n;
-
-               const U8* srcA = (const U8*)colors + SkU32BitShiftToByteOffset(SK_A32_SHIFT);
-               do {
-                       *alpha++ = *srcA;
-                       srcA += 4;
-               } while (--n != 0);
-       } while (count > 0);
+    do {
+        int n = count;
+        if (n > kTempColorCount)
+            n = kTempColorCount;
+        SkASSERT(n > 0);
+
+        this->shadeSpan(x, y, colors, n);
+        x += n;
+        count -= n;
+
+        const uint8_t* srcA = (const uint8_t*)colors + SkU32BitShiftToByteOffset(SK_A32_SHIFT);
+        do {
+            *alpha++ = *srcA;
+            srcA += 4;
+        } while (--n != 0);
+    } while (count > 0);
 #endif
 }
 
 SkShader::MatrixClass SkShader::ComputeMatrixClass(const SkMatrix& mat)
 {
-       MatrixClass     mc = kLinear_MatrixClass;
-
-       if (mat.getType() & SkMatrix::kPerspective_Mask)
-       {
-               if (mat.fixedStepInX(0, nil, nil))
-                       mc = kFixedStepInX_MatrixClass;
-               else
-                       mc = kPerspective_MatrixClass;
-       }
-       return mc;
-}
+    MatrixClass mc = kLinear_MatrixClass;
 
-////////////////////////////////////////////////////////////////////////////////////////
-
-#if 0
-SkPairShader::SkPairShader(SkShader* s0, SkShader* s1)
-       : fShader0(s0), fShader1(s1)
-{
-       s0->safeRef();
-       s1->safeRef();
+    if (mat.getType() & SkMatrix::kPerspective_Mask)
+    {
+        if (mat.fixedStepInX(0, NULL, NULL))
+            mc = kFixedStepInX_MatrixClass;
+        else
+            mc = kPerspective_MatrixClass;
+    }
+    return mc;
 }
 
-SkPairShader::~SkPairShader()
-{
-       fShader1->safeUnref();
-       fShader0->safeUnref();
-}
-
-U32 SkPairShader::getFlags()
-{
-       SkASSERT(fShader0 || fShader1);
-
-       U32     flags = 0-1U;
-
-       if (fShader0)
-               flags &= fShader0->getFlags();
-       if (fShader1)
-               flags &= fShader1->getFlags();
-       return flags;
-}
-
-bool SkPairShader::setContext( const SkBitmap& device,
-                                                               const SkPaint& paint,
-                                                               const SkMatrix& matrix)
-{
-       if (fShader0 == nil && fShader1 == nil)
-               return false;
-
-       const SkMatrix* localM = this->getLocalMatrix();
-       SkMatrix                tmp;
-
-       if (localM)
-       {
-               tmp.setConcat(matrix, *localM);
-               localM = &tmp;
-       }
-       else
-               localM = &matrix;
-
-       //      wonder if some subclasses will want OR instead of AND?
-
-       if (fShader0 && !fShader0->setContext(device, paint, *localM))
-               return false;
-       if (fShader1 && !fShader1->setContext(device, paint, *localM))
-               return false;
-       return true;
-}
-
-////////////////////////////////////////////////////////////////////////////////////////
-
-void SkComposeShader::shadeSpan(int x, int y, SkPMColor span[], int count)
-{
-       SkShader*       s0 = this->getShader0();
-       SkShader*       s1 = this->getShader1();
-
-       if (s1)
-               s1->shadeSpan(x, y, span, count);
-       if (s0)
-               s0->shadeSpan(x, y, span, count);
-}
-
-void SkComposeShader::shadeSpanOpaque16(int x, int y, U16 span[], int count)
-{
-       SkShader*       s0 = this->getShader0();
-       SkShader*       s1 = this->getShader1();
-
-       if (s1)
-               s1->shadeSpanOpaque16(x, y, span, count);
-       if (s0)
-               s0->shadeSpanOpaque16(x, y, span, count);
-}
-
-void SkComposeShader::shadeSpanAlpha(int x, int y, U8 span[], int count)
-{
-       SkShader*       s0 = this->getShader0();
-       SkShader*       s1 = this->getShader1();
-
-       if (s1)
-               s1->shadeSpanAlpha(x, y, span, count);
-       if (s0)
-               s0->shadeSpanAlpha(x, y, span, count);
-}
-
-////////////////////////////////////////////////////////////////////////////////////////
-
-#include "SkXfermode.h"
-#include "SkColorPriv.h"
-#include "SkBitmap.h"
-
-SkSumShader::SkSumShader(SkShader* s0, SkShader* s1, U8CPU weight)
-       : SkPairShader(s0, s1), fBuffer(nil), fMode(nil), fWeight(SkToU8(weight))
-{
-}
-
-SkSumShader::SkSumShader(SkShader* s0, SkShader* s1, SkXfermode* mode)
-       : SkPairShader(s0, s1), fBuffer(nil), fMode(mode), fWeight(0xFF)
-{
-       mode->safeRef();
-}
-
-SkSumShader::~SkSumShader()
-{
-       fMode->safeUnref();
-       sk_free(fBuffer);
-}
-
-bool SkSumShader::setContext(const SkBitmap& device,
-                                                        const SkPaint& paint,
-                                                        const SkMatrix& matrix)
-{
-       if (!this->INHERITED::setContext(device, paint, matrix))
-               return false;
-
-       if (fBuffer == nil)
-               fBuffer = (SkPMColor*)sk_malloc_throw(device.width() * sizeof(SkPMColor));
-       else
-               fBuffer = (SkPMColor*)sk_realloc_throw(fBuffer, device.width() * sizeof(SkPMColor));
-       return true;
-}
-
-void SkSumShader::shadeSpan(int x, int y, SkPMColor dst[], int count)
-{
-       SkShader*       s0 = this->getShader0();
-       SkShader*       s1 = this->getShader1();
-       SkASSERT(s0 || s1);
-
-       if (s0 == nil)
-               s1->shadeSpan(x, y, dst, count);
-       else
-       {
-               s0->shadeSpan(x, y, dst, count);
-               if (s1)
-               {
-                       SkPMColor* src = fBuffer;
-                       s1->shadeSpan(x, y, src, count);
-
-                       if (fMode)
-                               fMode->xfer32(dst, src, count, nil);
-                       else
-                       {
-                               unsigned weight = fWeight;
-                               for (int i = 0; i < count; i++)
-                                       dst[i] = SkBlendARGB32(src[i], dst[i], weight);
-                       }
-               }
-       }
-}
-
-void SkSumShader::shadeSpanOpaque16(int x, int y, U16 dst[], int count)
-{
-       SkShader*       s0 = this->getShader0();
-       SkShader*       s1 = this->getShader1();
-       SkASSERT(s0 || s1);
-
-       if (s0 == nil)
-               s1->shadeSpanOpaque16(x, y, dst, count);
-       else
-       {
-               s0->shadeSpanOpaque16(x, y, dst, count);
-               if (s1)
-               {
-                       if (fMode)
-                       {
-                               SkPMColor* src = fBuffer;
-                               s1->shadeSpan(x, y, src, count);
-                               fMode->xfer16(dst, src, count, nil);
-                       }
-                       else
-                       {
-                               U16* src = (U16*)fBuffer;
-                               s1->shadeSpanOpaque16(x, y, src, count);
-
-                               unsigned scale = SkAlpha255To256(fWeight);
-                               for (int i = 0; i < count; i++)
-                                       dst[i] = (U16)SkBlendRGB16(src[i], dst[i], scale);
-                       }
-               }
-       }
-}
-
-void SkSumShader::shadeSpanAlpha(int x, int y, U8 dst[], int count)
-{
-       SkShader*       s0 = this->getShader0();
-       SkShader*       s1 = this->getShader1();
-       SkASSERT(s0 || s1);
-
-       if (s0 == nil)
-               s1->shadeSpanAlpha(x, y, dst, count);
-       else
-       {
-               s0->shadeSpanAlpha(x, y, dst, count);
-               if (s1)
-               {
-                       if (fMode)
-                       {
-                               SkPMColor* src = fBuffer;
-                               s1->shadeSpan(x, y, src, count);
-                               fMode->xferA8(dst, src, count, nil);
-                       }
-                       else
-                       {
-                               U8* src = (U8*)fBuffer;
-                               s1->shadeSpanAlpha(x, y, src, count);
-
-                               unsigned scale = SkAlpha255To256(fWeight);
-                               for (int i = 0; i < count; i++)
-                                       dst[i] = (U8)SkAlphaBlend(src[i], dst[i], scale);
-                       }
-               }
-       }
-}
-#endif
index 2c4c11d..3ec1523 100644 (file)
+/* libs/graphics/sgl/SkSinTable.h
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #ifndef SkSinTable_DEFINED
 #define SkSinTable_DEFINED
 
 #include "SkTypes.h"
 
 /* Fixed point values (low 16 bits) of sin(radians) for
-       radians in [0...PI/2)
+    radians in [0...PI/2)
 */
 static const U16 gSkSinTable[256] = {
-       0x0000,
-       0x0192,
-       0x0324,
-       0x04B6,
-       0x0648,
-       0x07DA,
-       0x096C,
-       0x0AFE,
-       0x0C8F,
-       0x0E21,
-       0x0FB2,
-       0x1144,
-       0x12D5,
-       0x1466,
-       0x15F6,
-       0x1787,
-       0x1917,
-       0x1AA7,
-       0x1C37,
-       0x1DC7,
-       0x1F56,
-       0x20E5,
-       0x2273,
-       0x2402,
-       0x2590,
-       0x271D,
-       0x28AA,
-       0x2A37,
-       0x2BC4,
-       0x2D50,
-       0x2EDB,
-       0x3066,
-       0x31F1,
-       0x337B,
-       0x3505,
-       0x368E,
-       0x3817,
-       0x399F,
-       0x3B26,
-       0x3CAD,
-       0x3E33,
-       0x3FB9,
-       0x413E,
-       0x42C3,
-       0x4447,
-       0x45CA,
-       0x474D,
-       0x48CE,
-       0x4A50,
-       0x4BD0,
-       0x4D50,
-       0x4ECF,
-       0x504D,
-       0x51CA,
-       0x5347,
-       0x54C3,
-       0x563E,
-       0x57B8,
-       0x5931,
-       0x5AAA,
-       0x5C22,
-       0x5D98,
-       0x5F0E,
-       0x6083,
-       0x61F7,
-       0x636A,
-       0x64DC,
-       0x664D,
-       0x67BD,
-       0x692D,
-       0x6A9B,
-       0x6C08,
-       0x6D74,
-       0x6EDF,
-       0x7049,
-       0x71B1,
-       0x7319,
-       0x7480,
-       0x75E5,
-       0x774A,
-       0x78AD,
-       0x7A0F,
-       0x7B70,
-       0x7CD0,
-       0x7E2E,
-       0x7F8B,
-       0x80E7,
-       0x8242,
-       0x839C,
-       0x84F4,
-       0x864B,
-       0x87A1,
-       0x88F5,
-       0x8A48,
-       0x8B9A,
-       0x8CEA,
-       0x8E39,
-       0x8F87,
-       0x90D3,
-       0x921E,
-       0x9368,
-       0x94B0,
-       0x95F6,
-       0x973C,
-       0x987F,
-       0x99C2,
-       0x9B02,
-       0x9C42,
-       0x9D7F,
-       0x9EBC,
-       0x9FF6,
-       0xA12F,
-       0xA267,
-       0xA39D,
-       0xA4D2,
-       0xA605,
-       0xA736,
-       0xA866,
-       0xA994,
-       0xAAC0,
-       0xABEB,
-       0xAD14,
-       0xAE3B,
-       0xAF61,
-       0xB085,
-       0xB1A8,
-       0xB2C8,
-       0xB3E7,
-       0xB504,
-       0xB620,
-       0xB73A,
-       0xB852,
-       0xB968,
-       0xBA7C,
-       0xBB8F,
-       0xBCA0,
-       0xBDAE,
-       0xBEBC,
-       0xBFC7,
-       0xC0D0,
-       0xC1D8,
-       0xC2DE,
-       0xC3E2,
-       0xC4E3,
-       0xC5E4,
-       0xC6E2,
-       0xC7DE,
-       0xC8D8,
-       0xC9D1,
-       0xCAC7,
-       0xCBBB,
-       0xCCAE,
-       0xCD9F,
-       0xCE8D,
-       0xCF7A,
-       0xD064,
-       0xD14D,
-       0xD233,
-       0xD318,
-       0xD3FA,
-       0xD4DB,
-       0xD5B9,
-       0xD695,
-       0xD770,
-       0xD848,
-       0xD91E,
-       0xD9F2,
-       0xDAC4,
-       0xDB94,
-       0xDC61,
-       0xDD2D,
-       0xDDF6,
-       0xDEBE,
-       0xDF83,
-       0xE046,
-       0xE106,
-       0xE1C5,
-       0xE282,
-       0xE33C,
-       0xE3F4,
-       0xE4AA,
-       0xE55E,
-       0xE60F,
-       0xE6BE,
-       0xE76B,
-       0xE816,
-       0xE8BF,
-       0xE965,
-       0xEA09,
-       0xEAAB,
-       0xEB4B,
-       0xEBE8,
-       0xEC83,
-       0xED1C,
-       0xEDB2,
-       0xEE46,
-       0xEED8,
-       0xEF68,
-       0xEFF5,
-       0xF080,
-       0xF109,
-       0xF18F,
-       0xF213,
-       0xF294,
-       0xF314,
-       0xF391,
-       0xF40B,
-       0xF484,
-       0xF4FA,
-       0xF56D,
-       0xF5DE,
-       0xF64D,
-       0xF6BA,
-       0xF724,
-       0xF78B,
-       0xF7F1,
-       0xF853,
-       0xF8B4,
-       0xF912,
-       0xF96E,
-       0xF9C7,
-       0xFA1E,
-       0xFA73,
-       0xFAC5,
-       0xFB14,
-       0xFB61,
-       0xFBAC,
-       0xFBF5,
-       0xFC3B,
-       0xFC7E,
-       0xFCBF,
-       0xFCFE,
-       0xFD3A,
-       0xFD74,
-       0xFDAB,
-       0xFDE0,
-       0xFE13,
-       0xFE43,
-       0xFE70,
-       0xFE9B,
-       0xFEC4,
-       0xFEEA,
-       0xFF0E,
-       0xFF2F,
-       0xFF4E,
-       0xFF6A,
-       0xFF84,
-       0xFF9C,
-       0xFFB1,
-       0xFFC3,
-       0xFFD3,
-       0xFFE1,
-       0xFFEC,
-       0xFFF4,
-       0xFFFB,
-       0xFFFE
+    0x0000,
+    0x0192,
+    0x0324,
+    0x04B6,
+    0x0648,
+    0x07DA,
+    0x096C,
+    0x0AFE,
+    0x0C8F,
+    0x0E21,
+    0x0FB2,
+    0x1144,
+    0x12D5,
+    0x1466,
+    0x15F6,
+    0x1787,
+    0x1917,
+    0x1AA7,
+    0x1C37,
+    0x1DC7,
+    0x1F56,
+    0x20E5,
+    0x2273,
+    0x2402,
+    0x2590,
+    0x271D,
+    0x28AA,
+    0x2A37,
+    0x2BC4,
+    0x2D50,
+    0x2EDB,
+    0x3066,
+    0x31F1,
+    0x337B,
+    0x3505,
+    0x368E,
+    0x3817,
+    0x399F,
+    0x3B26,
+    0x3CAD,
+    0x3E33,
+    0x3FB9,
+    0x413E,
+    0x42C3,
+    0x4447,
+    0x45CA,
+    0x474D,
+    0x48CE,
+    0x4A50,
+    0x4BD0,
+    0x4D50,
+    0x4ECF,
+    0x504D,
+    0x51CA,
+    0x5347,
+    0x54C3,
+    0x563E,
+    0x57B8,
+    0x5931,
+    0x5AAA,
+    0x5C22,
+    0x5D98,
+    0x5F0E,
+    0x6083,
+    0x61F7,
+    0x636A,
+    0x64DC,
+    0x664D,
+    0x67BD,
+    0x692D,
+    0x6A9B,
+    0x6C08,
+    0x6D74,
+    0x6EDF,
+    0x7049,
+    0x71B1,
+    0x7319,
+    0x7480,
+    0x75E5,
+    0x774A,
+    0x78AD,
+    0x7A0F,
+    0x7B70,
+    0x7CD0,
+    0x7E2E,
+    0x7F8B,
+    0x80E7,
+    0x8242,
+    0x839C,
+    0x84F4,
+    0x864B,
+    0x87A1,
+    0x88F5,
+    0x8A48,
+    0x8B9A,
+    0x8CEA,
+    0x8E39,
+    0x8F87,
+    0x90D3,
+    0x921E,
+    0x9368,
+    0x94B0,
+    0x95F6,
+    0x973C,
+    0x987F,
+    0x99C2,
+    0x9B02,
+    0x9C42,
+    0x9D7F,
+    0x9EBC,
+    0x9FF6,
+    0xA12F,
+    0xA267,
+    0xA39D,
+    0xA4D2,
+    0xA605,
+    0xA736,
+    0xA866,
+    0xA994,
+    0xAAC0,
+    0xABEB,
+    0xAD14,
+    0xAE3B,
+    0xAF61,
+    0xB085,
+    0xB1A8,
+    0xB2C8,
+    0xB3E7,
+    0xB504,
+    0xB620,
+    0xB73A,
+    0xB852,
+    0xB968,
+    0xBA7C,
+    0xBB8F,
+    0xBCA0,
+    0xBDAE,
+    0xBEBC,
+    0xBFC7,
+    0xC0D0,
+    0xC1D8,
+    0xC2DE,
+    0xC3E2,
+    0xC4E3,
+    0xC5E4,
+    0xC6E2,
+    0xC7DE,
+    0xC8D8,
+    0xC9D1,
+    0xCAC7,
+    0xCBBB,
+    0xCCAE,
+    0xCD9F,
+    0xCE8D,
+    0xCF7A,
+    0xD064,
+    0xD14D,
+    0xD233,
+    0xD318,
+    0xD3FA,
+    0xD4DB,
+    0xD5B9,
+    0xD695,
+    0xD770,
+    0xD848,
+    0xD91E,
+    0xD9F2,
+    0xDAC4,
+    0xDB94,
+    0xDC61,
+    0xDD2D,
+    0xDDF6,
+    0xDEBE,
+    0xDF83,
+    0xE046,
+    0xE106,
+    0xE1C5,
+    0xE282,
+    0xE33C,
+    0xE3F4,
+    0xE4AA,
+    0xE55E,
+    0xE60F,
+    0xE6BE,
+    0xE76B,
+    0xE816,
+    0xE8BF,
+    0xE965,
+    0xEA09,
+    0xEAAB,
+    0xEB4B,
+    0xEBE8,
+    0xEC83,
+    0xED1C,
+    0xEDB2,
+    0xEE46,
+    0xEED8,
+    0xEF68,
+    0xEFF5,
+    0xF080,
+    0xF109,
+    0xF18F,
+    0xF213,
+    0xF294,
+    0xF314,
+    0xF391,
+    0xF40B,
+    0xF484,
+    0xF4FA,
+    0xF56D,
+    0xF5DE,
+    0xF64D,
+    0xF6BA,
+    0xF724,
+    0xF78B,
+    0xF7F1,
+    0xF853,
+    0xF8B4,
+    0xF912,
+    0xF96E,
+    0xF9C7,
+    0xFA1E,
+    0xFA73,
+    0xFAC5,
+    0xFB14,
+    0xFB61,
+    0xFBAC,
+    0xFBF5,
+    0xFC3B,
+    0xFC7E,
+    0xFCBF,
+    0xFCFE,
+    0xFD3A,
+    0xFD74,
+    0xFDAB,
+    0xFDE0,
+    0xFE13,
+    0xFE43,
+    0xFE70,
+    0xFE9B,
+    0xFEC4,
+    0xFEEA,
+    0xFF0E,
+    0xFF2F,
+    0xFF4E,
+    0xFF6A,
+    0xFF84,
+    0xFF9C,
+    0xFFB1,
+    0xFFC3,
+    0xFFD3,
+    0xFFE1,
+    0xFFEC,
+    0xFFF4,
+    0xFFFB,
+    0xFFFE
 };
 
 #endif
index b85690e..2120690 100644 (file)
@@ -1,3 +1,20 @@
+/* libs/graphics/sgl/SkSpriteBlitter.h
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #ifndef SkSpriteBlitter_DEFINED
 #define SkSpriteBlitter_DEFINED
 
@@ -8,33 +25,33 @@ class SkXfermode;
 
 class SkSpriteBlitter : public SkBlitter {
 public:
-                       SkSpriteBlitter(const SkBitmap& source);
-       virtual ~SkSpriteBlitter();
+            SkSpriteBlitter(const SkBitmap& source);
+    virtual ~SkSpriteBlitter();
 
-       void setup(const SkBitmap& device, int left, int top)
-       {
-               fDevice = &device;
-               fLeft = left;
-               fTop = top;
-       }
+    void setup(const SkBitmap& device, int left, int top)
+    {
+        fDevice = &device;
+        fLeft = left;
+        fTop = top;
+    }
 
-       // overrides
+    // overrides
 #ifdef SK_DEBUG
-       virtual void    blitH(int x, int y, int width);
-       virtual void    blitAntiH(int x, int y, const SkAlpha antialias[], const S16 runs[]);
-       virtual void    blitV(int x, int y, int height, SkAlpha alpha);
-       virtual void    blitMask(const SkMask&, const SkRect16& clip);
+    virtual void    blitH(int x, int y, int width);
+    virtual void    blitAntiH(int x, int y, const SkAlpha antialias[], const S16 runs[]);
+    virtual void    blitV(int x, int y, int height, SkAlpha alpha);
+    virtual void    blitMask(const SkMask&, const SkRect16& clip);
 #endif
 
-       static SkSpriteBlitter* ChooseD16(const SkBitmap& source, SkXfermode* mode, U8 alpha,
-                                                                         void* storage, size_t storageSize);
-       static SkSpriteBlitter* ChooseD32(const SkBitmap& source, SkXfermode* mode, U8 alpha,
-                                                                         void* storage, size_t storageSize);
+    static SkSpriteBlitter* ChooseD16(const SkBitmap& source, SkXfermode* mode, U8 alpha,
+                                      void* storage, size_t storageSize);
+    static SkSpriteBlitter* ChooseD32(const SkBitmap& source, SkXfermode* mode, U8 alpha,
+                                      void* storage, size_t storageSize);
 
 protected:
-       const SkBitmap* fDevice;
-       const SkBitmap* fSource;
-       int                             fLeft, fTop;
+    const SkBitmap* fDevice;
+    const SkBitmap* fSource;
+    int             fLeft, fTop;
 };
 
 #endif
index 23d2fbf..1492a2b 100644 (file)
@@ -1,47 +1,64 @@
+/* libs/graphics/sgl/SkSpriteBlitterTemplate.h
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 
 class SkSPRITE_CLASSNAME : public SkSpriteBlitter {
 public:
-       SkSPRITE_CLASSNAME(const SkBitmap& source SkSPRITE_ARGS)
-               : SkSpriteBlitter(source)
-       {
-               SkSPRITE_INIT
-       }
-       virtual void blitRect(int x, int y, int width, int height)
-       {
-               SkASSERT(width > 0 && height > 0);
-               int srcX = x - fLeft;
-               int srcY = y - fTop;
-               SkSPRITE_DST_TYPE*                      dst = fDevice->SkSPRITE_DST_GETADDR(x, y);
-               const SkSPRITE_SRC_TYPE*        src = fSource->SkSPRITE_SRC_GETADDR(srcX, srcY);
-               unsigned                                        dstRB = fDevice->rowBytes();
-               unsigned                                        srcRB = fSource->rowBytes();
-
-               SkDEBUGCODE((void)fDevice->SkSPRITE_DST_GETADDR(x + width - 1, y + height - 1);)
-               SkDEBUGCODE((void)fSource->SkSPRITE_SRC_GETADDR(srcX + width  - 1, srcY + height - 1);)
-
-               SkSPRITE_PREAMBLE((*fSource), srcX, srcY);
-
-               do {
-                       SkSPRITE_DST_TYPE* d = dst;
-                       const SkSPRITE_SRC_TYPE* s = src;
+    SkSPRITE_CLASSNAME(const SkBitmap& source SkSPRITE_ARGS)
+        : SkSpriteBlitter(source)
+    {
+        SkSPRITE_INIT
+    }
+    virtual void blitRect(int x, int y, int width, int height)
+    {
+        SkASSERT(width > 0 && height > 0);
+        int srcX = x - fLeft;
+        int srcY = y - fTop;
+        SkSPRITE_DST_TYPE*          dst = fDevice->SkSPRITE_DST_GETADDR(x, y);
+        const SkSPRITE_SRC_TYPE*    src = fSource->SkSPRITE_SRC_GETADDR(srcX, srcY);
+        unsigned                    dstRB = fDevice->rowBytes();
+        unsigned                    srcRB = fSource->rowBytes();
+
+        SkDEBUGCODE((void)fDevice->SkSPRITE_DST_GETADDR(x + width - 1, y + height - 1);)
+        SkDEBUGCODE((void)fSource->SkSPRITE_SRC_GETADDR(srcX + width  - 1, srcY + height - 1);)
+
+        SkSPRITE_PREAMBLE((*fSource), srcX, srcY);
+
+        do {
+            SkSPRITE_DST_TYPE* d = dst;
+            const SkSPRITE_SRC_TYPE* s = src;
 #ifdef SkSPRITE_BEGIN_ROW
-                       SkSPRITE_BEGIN_ROW
+            SkSPRITE_BEGIN_ROW
 #endif
-                       int w = width;
-                       do {
-                               SkSPRITE_SRC_TYPE sc = *s++;
-                               SkSPRITE_BLIT_PIXEL(d, sc);
-                               d += 1;
-                       } while (--w != 0);
-                       dst = (SkSPRITE_DST_TYPE*)((char*)dst + dstRB);
-                       src = (const SkSPRITE_SRC_TYPE*)((const char*)src + srcRB);
-                       SkSPRITE_NEXT_ROW
-               } while (--height != 0);
-
-               SkSPRITE_POSTAMBLE((*fSource));
-       }
+            int w = width;
+            do {
+                SkSPRITE_SRC_TYPE sc = *s++;
+                SkSPRITE_BLIT_PIXEL(d, sc);
+                d += 1;
+            } while (--w != 0);
+            dst = (SkSPRITE_DST_TYPE*)((char*)dst + dstRB);
+            src = (const SkSPRITE_SRC_TYPE*)((const char*)src + srcRB);
+            SkSPRITE_NEXT_ROW
+        } while (--height != 0);
+
+        SkSPRITE_POSTAMBLE((*fSource));
+    }
 private:
-       SkSPRITE_FIELDS
+    SkSPRITE_FIELDS
 };
 
 #undef SkSPRITE_BLIT_PIXEL
index 80ab5a5..97a435d 100644 (file)
@@ -1,53 +1,70 @@
+/* libs/graphics/sgl/SkSpriteBlitter_ARGB32.cpp
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #include "SkSpriteBlitter.h"
 #include "SkTemplates.h"
 #include "SkUtils.h"
 #include "SkColorPriv.h"
 
-#define D32_S32A_Opaque_Pixel(dst, sc)                                                                                                                         \
-do {                                                                                                                                                                                           \
-       if (sc)                                                                                                                                                                                 \
-       {                                                                                                                                                                                               \
-               unsigned srcA = SkGetPackedA32(sc);                                                                                                                     \
-               U32 result = sc;                                                                                                        \
-               if (srcA != 0xFF)                                                                                                                                                       \
-                       result += SkAlphaMulQ(*dst, SkAlpha255To256(255 - srcA));                                                       \
-               *dst = result;                                                                                                                                                          \
-       }                                                                                                                                                                                               \
+#define D32_S32A_Opaque_Pixel(dst, sc)                                                              \
+do {                                                                                                \
+    if (sc)                                                                                         \
+    {                                                                                               \
+        unsigned srcA = SkGetPackedA32(sc);                                                         \
+        U32 result = sc;                                                    \
+        if (srcA != 0xFF)                                                                           \
+            result += SkAlphaMulQ(*dst, SkAlpha255To256(255 - srcA));                           \
+        *dst = result;                                                                              \
+    }                                                                                               \
 } while (0)
 
-#define SkSPRITE_CLASSNAME                                     Sprite_D32_S32A_Opaque
+#define SkSPRITE_CLASSNAME                  Sprite_D32_S32A_Opaque
 #define SkSPRITE_ARGS
 #define SkSPRITE_FIELDS
 #define SkSPRITE_INIT
-#define SkSPRITE_DST_TYPE                                      uint32_t
-#define SkSPRITE_SRC_TYPE                                      uint32_t
-#define SkSPRITE_DST_GETADDR                           getAddr32
-#define SkSPRITE_SRC_GETADDR                           getAddr32
+#define SkSPRITE_DST_TYPE                   uint32_t
+#define SkSPRITE_SRC_TYPE                   uint32_t
+#define SkSPRITE_DST_GETADDR                getAddr32
+#define SkSPRITE_SRC_GETADDR                getAddr32
 #define SkSPRITE_PREAMBLE(srcBM, x, y)
-#define SkSPRITE_BLIT_PIXEL(dst, src)          D32_S32A_Opaque_Pixel(dst, src)
+#define SkSPRITE_BLIT_PIXEL(dst, src)       D32_S32A_Opaque_Pixel(dst, src)
 #define SkSPRITE_NEXT_ROW
 #define SkSPRITE_POSTAMBLE(srcBM)
 #include "SkSpriteBlitterTemplate.h"
 
 class Sprite_D32_S32_Opaque : public SkSpriteBlitter {
 public:
-       Sprite_D32_S32_Opaque(const SkBitmap& source) : SkSpriteBlitter(source) {}
+    Sprite_D32_S32_Opaque(const SkBitmap& source) : SkSpriteBlitter(source) {}
 
-       virtual void blitRect(int x, int y, int width, int height)
-       {
-               SkASSERT(width > 0 && height > 0);
-               uint32_t*               dst = fDevice->getAddr32(x, y);
-               const uint32_t* src = fSource->getAddr32(x - fLeft, y - fTop);
-               unsigned                dstRB = fDevice->rowBytes();
-               unsigned                srcRB = fSource->rowBytes();
+    virtual void blitRect(int x, int y, int width, int height)
+    {
+        SkASSERT(width > 0 && height > 0);
+        uint32_t*       dst = fDevice->getAddr32(x, y);
+        const uint32_t* src = fSource->getAddr32(x - fLeft, y - fTop);
+        unsigned        dstRB = fDevice->rowBytes();
+        unsigned        srcRB = fSource->rowBytes();
         size_t          size = width * sizeof(uint32_t);
 
-               do {
+        do {
             memcpy(dst, src, size);
-                       dst = (uint32_t*)((char*)dst + dstRB);
-                       src = (const uint32_t*)((const char*)src + srcRB);
-               } while (--height != 0);
-       }
+            dst = (uint32_t*)((char*)dst + dstRB);
+            src = (const uint32_t*)((const char*)src + srcRB);
+        } while (--height != 0);
+    }
 };
 
 //////////////////////////////////////////////////////////////////////////////////////////
@@ -56,26 +73,26 @@ public:
 #include "SkTemplatesPriv.h"
 
 SkSpriteBlitter* SkSpriteBlitter::ChooseD32(const SkBitmap& source, SkXfermode* mode, U8 alpha,
-                                                                                       void* storage, size_t storageSize)
+                                            void* storage, size_t storageSize)
 {
-       SkSpriteBlitter* blitter = nil;
+    SkSpriteBlitter* blitter = nil;
 
-       switch (source.getConfig()) {
-       case SkBitmap::kARGB_8888_Config:
-               if (mode == nil)
-               {
-                       if (alpha == 255)
+    switch (source.getConfig()) {
+    case SkBitmap::kARGB_8888_Config:
+        if (mode == nil)
+        {
+            if (alpha == 255)
             {
                 if (source.isOpaque())
                     SK_PLACEMENT_NEW_ARGS(blitter, Sprite_D32_S32_Opaque, storage, storageSize, (source));
                 else
                     SK_PLACEMENT_NEW_ARGS(blitter, Sprite_D32_S32A_Opaque, storage, storageSize, (source));
             }
-               }
-               break;
-       default:
-               break;
-       }
-       return blitter;
+        }
+        break;
+    default:
+        break;
+    }
+    return blitter;
 }
 
index ab65bae..99e392b 100644 (file)
+/* libs/graphics/sgl/SkSpriteBlitter_RGB16.cpp
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #include "SkSpriteBlitter.h"
 #include "SkTemplates.h"
 #include "SkUtils.h"
 #include "SkColorPriv.h"
 
-#define D16_S32A_Opaque_Pixel(dst, sc)                                                                                                                         \
-do {                                                                                                                                                                                           \
-       if (sc)                                                                                                                                                                                 \
-       {                                                                                                                                                                                               \
-               unsigned srcA = SkGetPackedA32(sc);                                                                                                                     \
-               unsigned result = SkPixel32ToPixel16(sc);                                                                                                       \
-               if (srcA != 0xFF)                                                                                                                                                       \
-                       result += SkAlphaMulRGB16(*dst, SkAlpha255To256(255 - srcA));                                                   \
-               *dst = SkToU16(result);                                                                                                                                                         \
-       }                                                                                                                                                                                               \
+#define D16_S32A_Opaque_Pixel(dst, sc)                                                              \
+do {                                                                                                \
+    if (sc)                                                                                         \
+    {                                                                                               \
+        unsigned srcA = SkGetPackedA32(sc);                                                         \
+        unsigned result = SkPixel32ToPixel16(sc);                                                   \
+        if (srcA != 0xFF)                                                                           \
+            result += SkAlphaMulRGB16(*dst, SkAlpha255To256(255 - srcA));                           \
+        *dst = SkToU16(result);                                                                             \
+    }                                                                                               \
 } while (0)
 
-#define SkSPRITE_CLASSNAME                                     Sprite_D16_S32A_Opaque
+#define SkSPRITE_CLASSNAME                  Sprite_D16_S32A_Opaque
 #define SkSPRITE_ARGS
 #define SkSPRITE_FIELDS
 #define SkSPRITE_INIT
-#define SkSPRITE_DST_TYPE                                      uint16_t
-#define SkSPRITE_SRC_TYPE                                      uint32_t
-#define SkSPRITE_DST_GETADDR                           getAddr16
-#define SkSPRITE_SRC_GETADDR                           getAddr32
+#define SkSPRITE_DST_TYPE                   uint16_t
+#define SkSPRITE_SRC_TYPE                   uint32_t
+#define SkSPRITE_DST_GETADDR                getAddr16
+#define SkSPRITE_SRC_GETADDR                getAddr32
 #define SkSPRITE_PREAMBLE(srcBM, x, y)
-#define SkSPRITE_BLIT_PIXEL(dst, src)          D16_S32A_Opaque_Pixel(dst, src)
+#define SkSPRITE_BLIT_PIXEL(dst, src)       D16_S32A_Opaque_Pixel(dst, src)
 #define SkSPRITE_NEXT_ROW
 #define SkSPRITE_POSTAMBLE(srcBM)
 #include "SkSpriteBlitterTemplate.h"
 
 static inline void D16_S32A_Blend_Pixel_helper(U16* dst, U32 sc, unsigned src_scale)
 {
-       uint16_t dc = *dst;
-       unsigned sa = SkGetPackedA32(sc);
-       unsigned dr, dg, db;
+    uint16_t dc = *dst;
+    unsigned sa = SkGetPackedA32(sc);
+    unsigned dr, dg, db;
 
-       if (sa == 255)
-       {
-               dr = SkAlphaBlend(SkPacked32ToR16(sc), SkGetPackedR16(dc), src_scale);
-               dg = SkAlphaBlend(SkPacked32ToG16(sc), SkGetPackedG16(dc), src_scale);
-               db = SkAlphaBlend(SkPacked32ToB16(sc), SkGetPackedB16(dc), src_scale);
-       }
-       else
-       {
-               unsigned dst_scale = 255 - SkAlphaMul(sa, src_scale);
-               dr = (SkPacked32ToR16(sc) * src_scale + SkGetPackedR16(dc) * dst_scale) >> 8;
-               dg = (SkPacked32ToG16(sc) * src_scale + SkGetPackedG16(dc) * dst_scale) >> 8;
-               db = (SkPacked32ToB16(sc) * src_scale + SkGetPackedB16(dc) * dst_scale) >> 8;
-       }
-       *dst = SkPackRGB16(dr, dg, db);
+    if (sa == 255)
+    {
+        dr = SkAlphaBlend(SkPacked32ToR16(sc), SkGetPackedR16(dc), src_scale);
+        dg = SkAlphaBlend(SkPacked32ToG16(sc), SkGetPackedG16(dc), src_scale);
+        db = SkAlphaBlend(SkPacked32ToB16(sc), SkGetPackedB16(dc), src_scale);
+    }
+    else
+    {
+        unsigned dst_scale = 255 - SkAlphaMul(sa, src_scale);
+        dr = (SkPacked32ToR16(sc) * src_scale + SkGetPackedR16(dc) * dst_scale) >> 8;
+        dg = (SkPacked32ToG16(sc) * src_scale + SkGetPackedG16(dc) * dst_scale) >> 8;
+        db = (SkPacked32ToB16(sc) * src_scale + SkGetPackedB16(dc) * dst_scale) >> 8;
+    }
+    *dst = SkPackRGB16(dr, dg, db);
 }
 
-#define D16_S32A_Blend_Pixel(dst, sc, src_scale)       do { if (sc) D16_S32A_Blend_Pixel_helper(dst, sc, src_scale); } while (0)
+#define D16_S32A_Blend_Pixel(dst, sc, src_scale)    do { if (sc) D16_S32A_Blend_Pixel_helper(dst, sc, src_scale); } while (0)
 
 
-#define SkSPRITE_CLASSNAME                                     Sprite_D16_S32A_Blend
-#define SkSPRITE_ARGS                                          , U8 alpha
-#define SkSPRITE_FIELDS                                                U8 fSrcAlpha;
-#define SkSPRITE_INIT                                          fSrcAlpha = alpha;
-#define SkSPRITE_DST_TYPE                                      uint16_t
-#define SkSPRITE_SRC_TYPE                                      uint32_t
-#define SkSPRITE_DST_GETADDR                           getAddr16
-#define SkSPRITE_SRC_GETADDR                           getAddr32
-#define SkSPRITE_PREAMBLE(srcBM, x, y)         unsigned src_scale = SkAlpha255To256(fSrcAlpha);
-#define SkSPRITE_BLIT_PIXEL(dst, src)          D16_S32A_Blend_Pixel(dst, src, src_scale)
+#define SkSPRITE_CLASSNAME                  Sprite_D16_S32A_Blend
+#define SkSPRITE_ARGS                       , U8 alpha
+#define SkSPRITE_FIELDS                     U8 fSrcAlpha;
+#define SkSPRITE_INIT                       fSrcAlpha = alpha;
+#define SkSPRITE_DST_TYPE                   uint16_t
+#define SkSPRITE_SRC_TYPE                   uint32_t
+#define SkSPRITE_DST_GETADDR                getAddr16
+#define SkSPRITE_SRC_GETADDR                getAddr32
+#define SkSPRITE_PREAMBLE(srcBM, x, y)      unsigned src_scale = SkAlpha255To256(fSrcAlpha);
+#define SkSPRITE_BLIT_PIXEL(dst, src)       D16_S32A_Blend_Pixel(dst, src, src_scale)
 #define SkSPRITE_NEXT_ROW
 #define SkSPRITE_POSTAMBLE(srcBM)
 #include "SkSpriteBlitterTemplate.h"
 
 //////////////////////////////////////////////////////////////////////////////////////////////////
 
-#define SkSPRITE_CLASSNAME                                     Sprite_D16_S32_Opaque
+#define SkSPRITE_CLASSNAME                  Sprite_D16_S32_Opaque
 #define SkSPRITE_ARGS
 #define SkSPRITE_FIELDS
 #define SkSPRITE_INIT
-#define SkSPRITE_DST_TYPE                                      uint16_t
-#define SkSPRITE_SRC_TYPE                                      uint32_t
-#define SkSPRITE_DST_GETADDR                           getAddr16
-#define SkSPRITE_SRC_GETADDR                           getAddr32
+#define SkSPRITE_DST_TYPE                   uint16_t
+#define SkSPRITE_SRC_TYPE                   uint32_t
+#define SkSPRITE_DST_GETADDR                getAddr16
+#define SkSPRITE_SRC_GETADDR                getAddr32
 #define SkSPRITE_PREAMBLE(srcBM, x, y)
-#define SkSPRITE_BLIT_PIXEL(dst, src)          *dst = SkPixel32ToPixel16_ToU16(src)
+#define SkSPRITE_BLIT_PIXEL(dst, src)       *dst = SkPixel32ToPixel16_ToU16(src)
 #define SkSPRITE_NEXT_ROW
 #define SkSPRITE_POSTAMBLE(srcBM)
 #include "SkSpriteBlitterTemplate.h"
 
 #if 1
-#define D16_S32_Blend_Pixel(dst, sc, scale)                                                                                            \
-do {                                                                                                                                                                   \
-       U16 dc = *dst;                                                                                                                                          \
-       *dst = SkPackRGB16(     SkAlphaBlend(SkPacked32ToR16(sc), SkGetPackedR16(dc), scale),   \
-                                               SkAlphaBlend(SkPacked32ToG16(sc), SkGetPackedG16(dc), scale),   \
-                                               SkAlphaBlend(SkPacked32ToB16(sc), SkGetPackedB16(dc), scale));  \
+#define D16_S32_Blend_Pixel(dst, sc, scale)                                             \
+do {                                                                                    \
+    U16 dc = *dst;                                                                      \
+    *dst = SkPackRGB16( SkAlphaBlend(SkPacked32ToR16(sc), SkGetPackedR16(dc), scale),   \
+                        SkAlphaBlend(SkPacked32ToG16(sc), SkGetPackedG16(dc), scale),   \
+                        SkAlphaBlend(SkPacked32ToB16(sc), SkGetPackedB16(dc), scale));  \
 } while (0)
 #else
 static inline void D16_S32_Blend_Pixel(uint16_t* dst, uint32_t sc, int scale)
 {
-       U16 dc = *dst;
-       *dst = SkPackRGB16(     SkAlphaBlend(SkPacked32ToR16(sc), SkGetPackedR16(dc), scale),
-                                               SkAlphaBlend(SkPacked32ToG16(sc), SkGetPackedG16(dc), scale),
-                                               SkAlphaBlend(SkPacked32ToB16(sc), SkGetPackedB16(dc), scale));
+    U16 dc = *dst;
+    *dst = SkPackRGB16( SkAlphaBlend(SkPacked32ToR16(sc), SkGetPackedR16(dc), scale),
+                        SkAlphaBlend(SkPacked32ToG16(sc), SkGetPackedG16(dc), scale),
+                        SkAlphaBlend(SkPacked32ToB16(sc), SkGetPackedB16(dc), scale));
 }
 #endif
 
-#define SkSPRITE_CLASSNAME                                     Sprite_D16_S32_Blend
-#define SkSPRITE_ARGS                                          , uint8_t alpha
-#define SkSPRITE_FIELDS                                                uint8_t fSrcAlpha;
-#define SkSPRITE_INIT                                          fSrcAlpha = alpha;
-#define SkSPRITE_DST_TYPE                                      uint16_t
-#define SkSPRITE_SRC_TYPE                                      uint32_t
-#define SkSPRITE_DST_GETADDR                           getAddr16
-#define SkSPRITE_SRC_GETADDR                           getAddr32
-#define SkSPRITE_PREAMBLE(srcBM, x, y)         int src_scale = SkAlpha255To256(fSrcAlpha);
-#define SkSPRITE_BLIT_PIXEL(dst, src)          D16_S32_Blend_Pixel(dst, src, src_scale)
+#define SkSPRITE_CLASSNAME                  Sprite_D16_S32_Blend
+#define SkSPRITE_ARGS                       , uint8_t alpha
+#define SkSPRITE_FIELDS                     uint8_t fSrcAlpha;
+#define SkSPRITE_INIT                       fSrcAlpha = alpha;
+#define SkSPRITE_DST_TYPE                   uint16_t
+#define SkSPRITE_SRC_TYPE                   uint32_t
+#define SkSPRITE_DST_GETADDR                getAddr16
+#define SkSPRITE_SRC_GETADDR                getAddr32
+#define SkSPRITE_PREAMBLE(srcBM, x, y)      int src_scale = SkAlpha255To256(fSrcAlpha);
+#define SkSPRITE_BLIT_PIXEL(dst, src)       D16_S32_Blend_Pixel(dst, src, src_scale)
 #define SkSPRITE_NEXT_ROW
 #define SkSPRITE_POSTAMBLE(srcBM)
 #include "SkSpriteBlitterTemplate.h"
@@ -120,104 +137,104 @@ static inline void D16_S32_Blend_Pixel(uint16_t* dst, uint32_t sc, int scale)
 
 class Sprite_D16_S16_Opaque : public SkSpriteBlitter {
 public:
-       Sprite_D16_S16_Opaque(const SkBitmap& source)
-               : SkSpriteBlitter(source) {}
+    Sprite_D16_S16_Opaque(const SkBitmap& source)
+        : SkSpriteBlitter(source) {}
 
-       // overrides
-       virtual void blitRect(int x, int y, int width, int height)
-       {
-               uint16_t*               dst = fDevice->getAddr16(x, y);
-               const uint16_t* src = fSource->getAddr16(x - fLeft, y - fTop);
-               unsigned        dstRB = fDevice->rowBytes();
-               unsigned        srcRB = fSource->rowBytes();
+    // overrides
+    virtual void blitRect(int x, int y, int width, int height)
+    {
+        uint16_t*       dst = fDevice->getAddr16(x, y);
+        const uint16_t* src = fSource->getAddr16(x - fLeft, y - fTop);
+        unsigned        dstRB = fDevice->rowBytes();
+        unsigned        srcRB = fSource->rowBytes();
 
-               while (--height >= 0)
-               {
-                       memcpy(dst, src, width << 1);
-                       dst = (uint16_t*)((char*)dst + dstRB);
-                       src = (const uint16_t*)((const char*)src + srcRB);
-               }
-       }
+        while (--height >= 0)
+        {
+            memcpy(dst, src, width << 1);
+            dst = (uint16_t*)((char*)dst + dstRB);
+            src = (const uint16_t*)((const char*)src + srcRB);
+        }
+    }
 };
 
-#define D16_S16_Blend_Pixel(dst, sc, scale)                            \
-       do {                                                                                            \
-               uint16_t dc = *dst;                                                             \
-               *dst = SkToU16(SkBlendRGB16(sc, dc, scale));    \
-       } while (0)
+#define D16_S16_Blend_Pixel(dst, sc, scale)             \
+    do {                                                \
+        uint16_t dc = *dst;                             \
+        *dst = SkToU16(SkBlendRGB16(sc, dc, scale));    \
+    } while (0)
 
-#define SkSPRITE_CLASSNAME                                     Sprite_D16_S16_Blend
-#define SkSPRITE_ARGS                                          , U8 alpha
-#define SkSPRITE_FIELDS                                                U8      fSrcAlpha;
-#define SkSPRITE_INIT                                          fSrcAlpha = alpha;
-#define SkSPRITE_DST_TYPE                                      uint16_t
-#define SkSPRITE_SRC_TYPE                                      uint16_t
-#define SkSPRITE_DST_GETADDR                           getAddr16
-#define SkSPRITE_SRC_GETADDR                           getAddr16
-#define SkSPRITE_PREAMBLE(srcBM, x, y)         int scale = SkAlpha255To256(fSrcAlpha);
-#define SkSPRITE_BLIT_PIXEL(dst, src)          D16_S16_Blend_Pixel(dst, src, scale)
+#define SkSPRITE_CLASSNAME                  Sprite_D16_S16_Blend
+#define SkSPRITE_ARGS                       , U8 alpha
+#define SkSPRITE_FIELDS                     U8  fSrcAlpha;
+#define SkSPRITE_INIT                       fSrcAlpha = alpha;
+#define SkSPRITE_DST_TYPE                   uint16_t
+#define SkSPRITE_SRC_TYPE                   uint16_t
+#define SkSPRITE_DST_GETADDR                getAddr16
+#define SkSPRITE_SRC_GETADDR                getAddr16
+#define SkSPRITE_PREAMBLE(srcBM, x, y)      int scale = SkAlpha255To256(fSrcAlpha);
+#define SkSPRITE_BLIT_PIXEL(dst, src)       D16_S16_Blend_Pixel(dst, src, scale)
 #define SkSPRITE_NEXT_ROW
 #define SkSPRITE_POSTAMBLE(srcBM)
 #include "SkSpriteBlitterTemplate.h"
 
 //////////////////////////////////////////////////////////////////////////////////////////////////
 
-#define SkSPRITE_CLASSNAME                                     Sprite_D16_SIndex8A_Opaque
+#define SkSPRITE_CLASSNAME                  Sprite_D16_SIndex8A_Opaque
 #define SkSPRITE_ARGS
 #define SkSPRITE_FIELDS
 #define SkSPRITE_INIT
-#define SkSPRITE_DST_TYPE                                      uint16_t
-#define SkSPRITE_SRC_TYPE                                      uint8_t
-#define SkSPRITE_DST_GETADDR                           getAddr16
-#define SkSPRITE_SRC_GETADDR                           getAddr8
-#define SkSPRITE_PREAMBLE(srcBM, x, y)         const SkPMColor* ctable = srcBM.getColorTable()->lockColors()
-#define SkSPRITE_BLIT_PIXEL(dst, src)          D16_S32A_Opaque_Pixel(dst, ctable[src])
+#define SkSPRITE_DST_TYPE                   uint16_t
+#define SkSPRITE_SRC_TYPE                   uint8_t
+#define SkSPRITE_DST_GETADDR                getAddr16
+#define SkSPRITE_SRC_GETADDR                getAddr8
+#define SkSPRITE_PREAMBLE(srcBM, x, y)      const SkPMColor* ctable = srcBM.getColorTable()->lockColors()
+#define SkSPRITE_BLIT_PIXEL(dst, src)       D16_S32A_Opaque_Pixel(dst, ctable[src])
 #define SkSPRITE_NEXT_ROW
-#define SkSPRITE_POSTAMBLE(srcBM)                      srcBM.getColorTable()->unlockColors(false)
+#define SkSPRITE_POSTAMBLE(srcBM)           srcBM.getColorTable()->unlockColors(false)
 #include "SkSpriteBlitterTemplate.h"
 
-#define SkSPRITE_CLASSNAME                                     Sprite_D16_SIndex8A_Blend
-#define SkSPRITE_ARGS                                          , uint8_t alpha
-#define SkSPRITE_FIELDS                                                uint8_t fSrcAlpha;
-#define SkSPRITE_INIT                                          fSrcAlpha = alpha;
-#define SkSPRITE_DST_TYPE                                      uint16_t
-#define SkSPRITE_SRC_TYPE                                      uint8_t
-#define SkSPRITE_DST_GETADDR                           getAddr16
-#define SkSPRITE_SRC_GETADDR                           getAddr8
-#define SkSPRITE_PREAMBLE(srcBM, x, y)         const SkPMColor* ctable = srcBM.getColorTable()->lockColors(); unsigned src_scale = SkAlpha255To256(fSrcAlpha);
-#define SkSPRITE_BLIT_PIXEL(dst, src)          D16_S32A_Blend_Pixel(dst, ctable[src], src_scale)
+#define SkSPRITE_CLASSNAME                  Sprite_D16_SIndex8A_Blend
+#define SkSPRITE_ARGS                       , uint8_t alpha
+#define SkSPRITE_FIELDS                     uint8_t fSrcAlpha;
+#define SkSPRITE_INIT                       fSrcAlpha = alpha;
+#define SkSPRITE_DST_TYPE                   uint16_t
+#define SkSPRITE_SRC_TYPE                   uint8_t
+#define SkSPRITE_DST_GETADDR                getAddr16
+#define SkSPRITE_SRC_GETADDR                getAddr8
+#define SkSPRITE_PREAMBLE(srcBM, x, y)      const SkPMColor* ctable = srcBM.getColorTable()->lockColors(); unsigned src_scale = SkAlpha255To256(fSrcAlpha);
+#define SkSPRITE_BLIT_PIXEL(dst, src)       D16_S32A_Blend_Pixel(dst, ctable[src], src_scale)
 #define SkSPRITE_NEXT_ROW
-#define SkSPRITE_POSTAMBLE(srcBM)                      srcBM.getColorTable()->unlockColors(false);
+#define SkSPRITE_POSTAMBLE(srcBM)           srcBM.getColorTable()->unlockColors(false);
 #include "SkSpriteBlitterTemplate.h"
 
 //////////////////////////////////////////////////////////////////////////////////////////////////
 
-#define SkSPRITE_CLASSNAME                                     Sprite_D16_SIndex8_Opaque
+#define SkSPRITE_CLASSNAME                  Sprite_D16_SIndex8_Opaque
 #define SkSPRITE_ARGS
 #define SkSPRITE_FIELDS
 #define SkSPRITE_INIT
-#define SkSPRITE_DST_TYPE                                      uint16_t
-#define SkSPRITE_SRC_TYPE                                      uint8_t
-#define SkSPRITE_DST_GETADDR                           getAddr16
-#define SkSPRITE_SRC_GETADDR                           getAddr8
-#define SkSPRITE_PREAMBLE(srcBM, x, y)         const uint16_t* ctable = srcBM.getColorTable()->lock16BitCache()
-#define SkSPRITE_BLIT_PIXEL(dst, src)          *dst = ctable[src]
+#define SkSPRITE_DST_TYPE                   uint16_t
+#define SkSPRITE_SRC_TYPE                   uint8_t
+#define SkSPRITE_DST_GETADDR                getAddr16
+#define SkSPRITE_SRC_GETADDR                getAddr8
+#define SkSPRITE_PREAMBLE(srcBM, x, y)      const uint16_t* ctable = srcBM.getColorTable()->lock16BitCache()
+#define SkSPRITE_BLIT_PIXEL(dst, src)       *dst = ctable[src]
 #define SkSPRITE_NEXT_ROW
-#define SkSPRITE_POSTAMBLE(srcBM)                      srcBM.getColorTable()->unlock16BitCache()
+#define SkSPRITE_POSTAMBLE(srcBM)           srcBM.getColorTable()->unlock16BitCache()
 #include "SkSpriteBlitterTemplate.h"
 
-#define SkSPRITE_CLASSNAME                                     Sprite_D16_SIndex8_Blend
-#define SkSPRITE_ARGS                                          , uint8_t alpha
-#define SkSPRITE_FIELDS                                                uint8_t fSrcAlpha;
-#define SkSPRITE_INIT                                          fSrcAlpha = alpha;
-#define SkSPRITE_DST_TYPE                                      uint16_t
-#define SkSPRITE_SRC_TYPE                                      uint8_t
-#define SkSPRITE_DST_GETADDR                           getAddr16
-#define SkSPRITE_SRC_GETADDR                           getAddr8
-#define SkSPRITE_PREAMBLE(srcBM, x, y)         const uint16_t* ctable = srcBM.getColorTable()->lock16BitCache(); unsigned src_scale = SkAlpha255To256(fSrcAlpha);
-#define SkSPRITE_BLIT_PIXEL(dst, src)          D16_S16_Blend_Pixel(dst, ctable[src], src_scale)
+#define SkSPRITE_CLASSNAME                  Sprite_D16_SIndex8_Blend
+#define SkSPRITE_ARGS                       , uint8_t alpha
+#define SkSPRITE_FIELDS                     uint8_t fSrcAlpha;
+#define SkSPRITE_INIT                       fSrcAlpha = alpha;
+#define SkSPRITE_DST_TYPE                   uint16_t
+#define SkSPRITE_SRC_TYPE                   uint8_t
+#define SkSPRITE_DST_GETADDR                getAddr16
+#define SkSPRITE_SRC_GETADDR                getAddr8
+#define SkSPRITE_PREAMBLE(srcBM, x, y)      const uint16_t* ctable = srcBM.getColorTable()->lock16BitCache(); unsigned src_scale = SkAlpha255To256(fSrcAlpha);
+#define SkSPRITE_BLIT_PIXEL(dst, src)       D16_S16_Blend_Pixel(dst, ctable[src], src_scale)
 #define SkSPRITE_NEXT_ROW
-#define SkSPRITE_POSTAMBLE(srcBM)                      srcBM.getColorTable()->unlock16BitCache();
+#define SkSPRITE_POSTAMBLE(srcBM)           srcBM.getColorTable()->unlock16BitCache();
 #include "SkSpriteBlitterTemplate.h"
 
 //////////////////////////////////////////////////////////////////////////////////////////
@@ -226,12 +243,12 @@ public:
 #include "SkTemplatesPriv.h"
 
 SkSpriteBlitter* SkSpriteBlitter::ChooseD16(const SkBitmap& source, SkXfermode* mode, U8 alpha,
-                                                                                       void* storage, size_t storageSize)
+                                            void* storage, size_t storageSize)
 {
-       SkSpriteBlitter* blitter = nil;
+    SkSpriteBlitter* blitter = nil;
 
-       switch (source.getConfig()) {
-       case SkBitmap::kARGB_8888_Config:
+    switch (source.getConfig()) {
+    case SkBitmap::kARGB_8888_Config:
         if (mode == nil)
         {
             bool srcIsOpaque = source.isOpaque();
@@ -250,51 +267,51 @@ SkSpriteBlitter* SkSpriteBlitter::ChooseD16(const SkBitmap& source, SkXfermode*
                     SK_PLACEMENT_NEW_ARGS(blitter, Sprite_D16_S32A_Blend, storage, storageSize, (source, alpha));
             }
         }
-               break;
-       case SkBitmap::kRGB_565_Config:
+        break;
+    case SkBitmap::kRGB_565_Config:
 #ifdef SK_SUPPORT_16_8_BITMAP
-               if (source.getA8Plane())
-               {
-                       if (mode == nil)
-                       {
-                               if (alpha == 255)
-                                       SK_PLACEMENT_NEW_ARGS(blitter, Sprite_D16_S816_Opaque, storage, storageSize, (source));
-                               else
-                                       SK_PLACEMENT_NEW_ARGS(blitter, Sprite_D16_S816_Blend, storage, storageSize, (source, alpha));
-                       }
-               }
-               else
+        if (source.getA8Plane())
+        {
+            if (mode == nil)
+            {
+                if (alpha == 255)
+                    SK_PLACEMENT_NEW_ARGS(blitter, Sprite_D16_S816_Opaque, storage, storageSize, (source));
+                else
+                    SK_PLACEMENT_NEW_ARGS(blitter, Sprite_D16_S816_Blend, storage, storageSize, (source, alpha));
+            }
+        }
+        else
 #endif
-               if (mode == nil)
-               {
-                       if (alpha == 255)
-                               SK_PLACEMENT_NEW_ARGS(blitter, Sprite_D16_S16_Opaque, storage, storageSize, (source));
-                       else
-                               SK_PLACEMENT_NEW_ARGS(blitter, Sprite_D16_S16_Blend, storage, storageSize, (source, alpha));
-               }
-               break;
-       case SkBitmap::kIndex8_Config:
-               if (mode == nil)
-               {
-                       if (source.getColorTable()->getFlags() & SkColorTable::kColorsAreOpaque_Flag)
-                       {
-                               if (alpha == 255)
-                                       SK_PLACEMENT_NEW_ARGS(blitter, Sprite_D16_SIndex8_Opaque, storage, storageSize, (source));
-                               else
-                                       SK_PLACEMENT_NEW_ARGS(blitter, Sprite_D16_SIndex8_Blend, storage, storageSize, (source, alpha));
-                       }
-                       else
-                       {
-                               if (alpha == 255)
-                                       SK_PLACEMENT_NEW_ARGS(blitter, Sprite_D16_SIndex8A_Opaque, storage, storageSize, (source));
-                               else
-                                       SK_PLACEMENT_NEW_ARGS(blitter, Sprite_D16_SIndex8A_Blend, storage, storageSize, (source, alpha));
-                       }
-               }
-               break;
-       default:
-               break;
-       }
-       return blitter;
+        if (mode == nil)
+        {
+            if (alpha == 255)
+                SK_PLACEMENT_NEW_ARGS(blitter, Sprite_D16_S16_Opaque, storage, storageSize, (source));
+            else
+                SK_PLACEMENT_NEW_ARGS(blitter, Sprite_D16_S16_Blend, storage, storageSize, (source, alpha));
+        }
+        break;
+    case SkBitmap::kIndex8_Config:
+        if (mode == nil)
+        {
+            if (source.getColorTable()->getFlags() & SkColorTable::kColorsAreOpaque_Flag)
+            {
+                if (alpha == 255)
+                    SK_PLACEMENT_NEW_ARGS(blitter, Sprite_D16_SIndex8_Opaque, storage, storageSize, (source));
+                else
+                    SK_PLACEMENT_NEW_ARGS(blitter, Sprite_D16_SIndex8_Blend, storage, storageSize, (source, alpha));
+            }
+            else
+            {
+                if (alpha == 255)
+                    SK_PLACEMENT_NEW_ARGS(blitter, Sprite_D16_SIndex8A_Opaque, storage, storageSize, (source));
+                else
+                    SK_PLACEMENT_NEW_ARGS(blitter, Sprite_D16_SIndex8A_Blend, storage, storageSize, (source, alpha));
+            }
+        }
+        break;
+    default:
+        break;
+    }
+    return blitter;
 }
 
index 1859f98..d6f96c9 100644 (file)
@@ -1,3 +1,20 @@
+/* libs/graphics/sgl/SkString.cpp
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #include "SkString.h"
 #include "SkFixed.h"
 #include "SkUtils.h"
 
 bool SkStrStartsWith(const char string[], const char prefix[])
 {
-       SkASSERT(string);
-       SkASSERT(prefix);
-       return !strncmp(string, prefix, strlen(prefix));
+    SkASSERT(string);
+    SkASSERT(prefix);
+    return !strncmp(string, prefix, strlen(prefix));
 }
 
 bool SkStrEndsWith(const char string[], const char suffix[])
 {
-       SkASSERT(string);
-       SkASSERT(suffix);
-       size_t  strLen = strlen(string);
-       size_t  suffixLen = strlen(suffix);
-       return  strLen >= suffixLen &&
-                       !strncmp(string + strLen - suffixLen, suffix, suffixLen);
+    SkASSERT(string);
+    SkASSERT(suffix);
+    size_t  strLen = strlen(string);
+    size_t  suffixLen = strlen(suffix);
+    return  strLen >= suffixLen &&
+            !strncmp(string + strLen - suffixLen, suffix, suffixLen);
 }
 
 int SkStrStartsWithOneOf(const char string[], const char prefixes[])
 {
-       int index = 0;
-       do {
-               const char* limit = strchr(prefixes, '\0');
+    int index = 0;
+    do {
+        const char* limit = strchr(prefixes, '\0');
         if (!strncmp(string, prefixes, limit - prefixes))
-                       return index;
-               prefixes = limit + 1;
-               index++;
-       } while (prefixes[0]);
-       return -1;
+            return index;
+        prefixes = limit + 1;
+        index++;
+    } while (prefixes[0]);
+    return -1;
 }
 
 char* SkStrAppendS32(char string[], int32_t dec)
 {
     SkDEBUGCODE(char* start = string;)
 
-       char    buffer[SkStrAppendS32_MaxSize];
-       char*   p = buffer + sizeof(buffer);
-       bool    neg = false;
-
-       if (dec < 0)
-       {
-               neg = true;
-               dec = -dec;
-       }
-       do {
-               *--p = SkToU8('0' + dec % 10);
-               dec /= 10;
-       } while (dec != 0);
-       if (neg)
-               *--p = '-';
-
-       SkASSERT(p >= buffer);
+    char    buffer[SkStrAppendS32_MaxSize];
+    char*   p = buffer + sizeof(buffer);
+    bool    neg = false;
+
+    if (dec < 0)
+    {
+        neg = true;
+        dec = -dec;
+    }
+    do {
+        *--p = SkToU8('0' + dec % 10);
+        dec /= 10;
+    } while (dec != 0);
+    if (neg)
+        *--p = '-';
+
+    SkASSERT(p >= buffer);
     char* stop = buffer + sizeof(buffer);
     while (p < stop)
         *string++ = *p++;
@@ -66,38 +83,38 @@ char* SkStrAppendScalar(char string[], SkScalar value)
 {
     SkDEBUGCODE(char* start = string;)
 
-       SkFixed x = SkScalarToFixed(value);
+    SkFixed x = SkScalarToFixed(value);
 
-       if (x < 0)
-       {
+    if (x < 0)
+    {
         *string++ = '-';
-               x = -x;
-       }
-
-       unsigned frac = x & 0xFFFF;
-       x >>= 16;
-       if (frac == 0xFFFF)     // need to do this to "round up", since 65535/65536 is closer to 1 than to .9999
-       {
-               x += 1;
-               frac = 0;
-       }
+        x = -x;
+    }
+
+    unsigned frac = x & 0xFFFF;
+    x >>= 16;
+    if (frac == 0xFFFF) // need to do this to "round up", since 65535/65536 is closer to 1 than to .9999
+    {
+        x += 1;
+        frac = 0;
+    }
     string = SkStrAppendS32(string, x);
 
-       // now handle the fractional part (if any)
-       if (frac)
-       {
-               static const uint16_t   gTens[] = { 1000, 100, 10, 1 };
-               const uint16_t*         tens = gTens;
-
-               x = SkFixedRound(frac * 10000);
-               SkASSERT(x < 10000);
-               *string++ = '.';
-               do {
-                       unsigned powerOfTen = *tens++;
-                       *string++ = SkToU8('0' + x / powerOfTen);
-                       x %= powerOfTen;
-               } while (x != 0);
-       }
+    // now handle the fractional part (if any)
+    if (frac)
+    {
+        static const uint16_t   gTens[] = { 1000, 100, 10, 1 };
+        const uint16_t*         tens = gTens;
+
+        x = SkFixedRound(frac * 10000);
+        SkASSERT(x < 10000);
+        *string++ = '.';
+        do {
+            unsigned powerOfTen = *tens++;
+            *string++ = SkToU8('0' + x / powerOfTen);
+            x %= powerOfTen;
+        } while (x != 0);
+    }
     
     SkASSERT(string - start <= SkStrAppendScalar_MaxSize);
     return string;
@@ -105,339 +122,341 @@ char* SkStrAppendScalar(char string[], SkScalar value)
 
 ////////////////////////////////////////////////////////////////////////////////////
 
-#define kMaxRefCnt_SkString            SK_MaxU16
+#define kMaxRefCnt_SkString     SK_MaxU16
 
 // the 3 values are [length] [refcnt] [terminating zero data]
-static const U16 gEmptyRec[3] = { 0, 0, 0 };
+const SkString::Rec SkString::gEmptyRec = { 0, 0, 0 };
+
+#define SizeOfRec()     (gEmptyRec.data() - (const char*)&gEmptyRec)
 
 SkString::Rec* SkString::AllocRec(const char text[], U16CPU len)
 {
-       Rec* rec;
+    Rec* rec;
 
-       if (len == 0)
-               rec = (Rec*)gEmptyRec;
-       else
-       {
-               // add 1 for terminating 0, then align4 so we can have some slop when growing the string
-               rec = (Rec*)sk_malloc_throw(sizeof(Rec) + SkAlign4(len + 1));
-               rec->fLength = SkToU16(len);
-               rec->fRefCnt = 1;
-               if (text)
-                       memcpy(rec->data(), text, len);
-               rec->data()[len] = 0;
-       }
-       return rec;
+    if (len == 0)
+        rec = const_cast<Rec*>(&gEmptyRec);
+    else
+    {
+        // add 1 for terminating 0, then align4 so we can have some slop when growing the string
+        rec = (Rec*)sk_malloc_throw(SizeOfRec() + SkAlign4(len + 1));
+        rec->fLength = SkToU16(len);
+        rec->fRefCnt = 1;
+        if (text)
+            memcpy(rec->data(), text, len);
+        rec->data()[len] = 0;
+    }
+    return rec;
 }
 
 SkString::Rec* SkString::RefRec(Rec* src)
 {
-       if (src != (Rec*)gEmptyRec)
-       {
-               if (src->fRefCnt == kMaxRefCnt_SkString) {
-                       src = AllocRec(src->data(), src->fLength);
-               } else
-                       src->fRefCnt += 1;
-       }
-       return src;
+    if (src != &gEmptyRec)
+    {
+        if (src->fRefCnt == kMaxRefCnt_SkString) {
+            src = AllocRec(src->data(), src->fLength);
+        } else
+            src->fRefCnt += 1;
+    }
+    return src;
 }
 
 #ifdef SK_DEBUG
 void SkString::validate() const
 {
-       // make sure know one has written over our global
-       SkASSERT(((Rec*)gEmptyRec)->fLength == 0);
-       SkASSERT(((Rec*)gEmptyRec)->fRefCnt == 0);
-       SkASSERT(((Rec*)gEmptyRec)->data()[0] == 0);
+    // make sure know one has written over our global
+    SkASSERT(gEmptyRec.fLength == 0);
+    SkASSERT(gEmptyRec.fRefCnt == 0);
+    SkASSERT(gEmptyRec.data()[0] == 0);
 
-       if (fRec != (Rec*)gEmptyRec)
-       {
-               SkASSERT(fRec->fLength > 0);
-               SkASSERT(fRec->fRefCnt > 0);
-               SkASSERT(fRec->data()[fRec->fLength] == 0);
-       }
-       SkASSERT(fStr == c_str());
+    if (fRec != &gEmptyRec)
+    {
+        SkASSERT(fRec->fLength > 0);
+        SkASSERT(fRec->fRefCnt > 0);
+        SkASSERT(fRec->data()[fRec->fLength] == 0);
+    }
+    SkASSERT(fStr == c_str());
 }
 #endif
 
 ///////////////////////////////////////////////////////////////////////
 
-SkString::SkString() : fRec((Rec*)gEmptyRec) {
+SkString::SkString() : fRec(const_cast<Rec*>(&gEmptyRec)) {
 #ifdef SK_DEBUG
-       fStr = fRec->data();
+    fStr = fRec->data();
 #endif
 }
 
 SkString::SkString(size_t len)
 {
-       SkASSERT(SkToU16(len) == len);  // can't handle larger than 64K
+    SkASSERT(SkToU16(len) == len);  // can't handle larger than 64K
 
-       fRec = AllocRec(nil, (U16CPU)len);
+    fRec = AllocRec(nil, (U16CPU)len);
 #ifdef SK_DEBUG
-       fStr = fRec->data();
+    fStr = fRec->data();
 #endif
 }
 
 SkString::SkString(const char text[])
 {
-       size_t  len = text ? strlen(text) : 0;
+    size_t  len = text ? strlen(text) : 0;
 
-       fRec = AllocRec(text, (U16CPU)len);
+    fRec = AllocRec(text, (U16CPU)len);
 #ifdef SK_DEBUG
-       fStr = fRec->data();
+    fStr = fRec->data();
 #endif
 }
 
 SkString::SkString(const char text[], size_t len)
 {
-       fRec = AllocRec(text, (U16CPU)len);
+    fRec = AllocRec(text, (U16CPU)len);
 #ifdef SK_DEBUG
-       fStr = fRec->data();
+    fStr = fRec->data();
 #endif
 }
 
 SkString::SkString(const SkString& src)
 {
-       src.validate();
+    src.validate();
 
-       fRec = RefRec(src.fRec);
+    fRec = RefRec(src.fRec);
 #ifdef SK_DEBUG
-       fStr = fRec->data();
+    fStr = fRec->data();
 #endif
 }
 
 SkString::~SkString()
 {
-       this->validate();
+    this->validate();
 
-       if (fRec->fLength)
-       {
-               SkASSERT(fRec->fRefCnt > 0);
-               if (--fRec->fRefCnt == 0)
-                       sk_free(fRec);
-       }
+    if (fRec->fLength)
+    {
+        SkASSERT(fRec->fRefCnt > 0);
+        if (--fRec->fRefCnt == 0)
+            sk_free(fRec);
+    }
 }
 
 bool SkString::equals(const SkString& src) const
 {
-       return fRec == src.fRec || this->equals(src.c_str(), src.size());
+    return fRec == src.fRec || this->equals(src.c_str(), src.size());
 }
 
 bool SkString::equals(const char text[]) const
 {
-       return this->equals(text, text ? strlen(text) : 0);
+    return this->equals(text, text ? strlen(text) : 0);
 }
 
 bool SkString::equals(const char text[], size_t len) const
 {
-       SkASSERT(len == 0 || text != nil);
+    SkASSERT(len == 0 || text != nil);
 
-       return fRec->fLength == len && !memcmp(fRec->data(), text, len);
+    return fRec->fLength == len && !memcmp(fRec->data(), text, len);
 }
 
 SkString& SkString::operator=(const SkString& src)
 {
-       this->validate();
+    this->validate();
 
-       if (fRec != src.fRec)
-       {
-               SkString        tmp(src);
-               this->swap(tmp);
-       }
-       return *this;
+    if (fRec != src.fRec)
+    {
+        SkString    tmp(src);
+        this->swap(tmp);
+    }
+    return *this;
 }
 
 void SkString::reset()
 {
-       this->validate();
+    this->validate();
 
-       if (fRec->fLength)
-       {
-               SkASSERT(fRec->fRefCnt > 0);
-               if (--fRec->fRefCnt == 0)
-                       sk_free(fRec);
-       }
+    if (fRec->fLength)
+    {
+        SkASSERT(fRec->fRefCnt > 0);
+        if (--fRec->fRefCnt == 0)
+            sk_free(fRec);
+    }
 
-       fRec = (Rec*)gEmptyRec;
+    fRec = const_cast<Rec*>(&gEmptyRec);
 #ifdef SK_DEBUG
-       fStr = fRec->data();
+    fStr = fRec->data();
 #endif
 }
 
 char* SkString::writable_str()
 {
-       this->validate();
+    this->validate();
 
-       if (fRec->fLength)
-       {
-               if (fRec->fRefCnt > 1)
-               {
-                       fRec->fRefCnt -= 1;
-                       fRec = AllocRec(fRec->data(), fRec->fLength);
-               #ifdef SK_DEBUG
-                       fStr = fRec->data();
-               #endif
-               }
-       }
-       return fRec->data();
+    if (fRec->fLength)
+    {
+        if (fRec->fRefCnt > 1)
+        {
+            fRec->fRefCnt -= 1;
+            fRec = AllocRec(fRec->data(), fRec->fLength);
+        #ifdef SK_DEBUG
+            fStr = fRec->data();
+        #endif
+        }
+    }
+    return fRec->data();
 }
 
 void SkString::set(const char text[])
 {
-       this->set(text, text ? strlen(text) : 0);
+    this->set(text, text ? strlen(text) : 0);
 }
 
 void SkString::set(const char text[], size_t len)
 {
-       if (len == 0)
-               this->reset();
-       else if (fRec->fRefCnt == 1 && len <= fRec->fLength)    // should we resize if len <<<< fLength, to save RAM? (e.g. len < (fLength>>1))
-       {
-               // just use less of the buffer without allocating a smaller one
-               char* p = this->writable_str();
-               if (text)
-                       memcpy(p, text, len);
-               p[len] = 0;
-               fRec->fLength = SkToU16(len);
-       }
-       else if (fRec->fRefCnt == 1 && ((unsigned)fRec->fLength >> 2) == (len >> 2))
-       {
-               // we have spare room in the current allocation, so don't alloc a larger one
-               char* p = this->writable_str();
-               if (text)
-                       memcpy(p, text, len);
-               p[len] = 0;
-               fRec->fLength = SkToU16(len);
-       }
-       else
-       {
-               SkString tmp(text, len);
-               this->swap(tmp);
-       }
-}
-
-void SkString::setUTF16(const U16 src[])
-{
-       int     count = 0;
-
-       while (src[count])
-               count += 1;
-
-       if (count == 0)
-               this->reset();
-       else if (count <= fRec->fLength)        // should we resize if len <<<< fLength, to save RAM? (e.g. len < (fLength>>1))
-       {
-               if (count < fRec->fLength)
-                       this->resize(count);
-               char* p = this->writable_str();
-               for (int i = 0; i < count; i++)
-                       p[i] = SkToU8(src[i]);
-               p[count] = 0;
-       }
-       else
-       {
-               SkString        tmp(count);
-               char*           p = tmp.writable_str();
-
-               for (int i = 0; i < count; i++)
-                       p[i] = SkToU8(src[i]);
-
-               this->swap(tmp);
-       }
+    if (len == 0)
+        this->reset();
+    else if (fRec->fRefCnt == 1 && len <= fRec->fLength)    // should we resize if len <<<< fLength, to save RAM? (e.g. len < (fLength>>1))
+    {
+        // just use less of the buffer without allocating a smaller one
+        char* p = this->writable_str();
+        if (text)
+            memcpy(p, text, len);
+        p[len] = 0;
+        fRec->fLength = SkToU16(len);
+    }
+    else if (fRec->fRefCnt == 1 && ((unsigned)fRec->fLength >> 2) == (len >> 2))
+    {
+        // we have spare room in the current allocation, so don't alloc a larger one
+        char* p = this->writable_str();
+        if (text)
+            memcpy(p, text, len);
+        p[len] = 0;
+        fRec->fLength = SkToU16(len);
+    }
+    else
+    {
+        SkString tmp(text, len);
+        this->swap(tmp);
+    }
+}
+
+void SkString::setUTF16(const uint16_t src[])
+{
+    int count = 0;
+
+    while (src[count])
+        count += 1;
+
+    if (count == 0)
+        this->reset();
+    else if (count <= fRec->fLength)    // should we resize if len <<<< fLength, to save RAM? (e.g. len < (fLength>>1))
+    {
+        if (count < fRec->fLength)
+            this->resize(count);
+        char* p = this->writable_str();
+        for (int i = 0; i < count; i++)
+            p[i] = SkToU8(src[i]);
+        p[count] = 0;
+    }
+    else
+    {
+        SkString    tmp(count);
+        char*       p = tmp.writable_str();
+
+        for (int i = 0; i < count; i++)
+            p[i] = SkToU8(src[i]);
+
+        this->swap(tmp);
+    }
 }
 
 void SkString::insert(size_t offset, const char text[])
 {
-       this->insert(offset, text, text ? strlen(text) : 0);
+    this->insert(offset, text, text ? strlen(text) : 0);
 }
 
 void SkString::insert(size_t offset, const char text[], size_t len)
 {
-       if (len)
-       {
-               size_t length = fRec->fLength;
-               if (offset > length)
-                       offset = length;
-
-               /*      If we're the only owner, and we have room in our allocation for the insert,
-                       do it in place, rather than allocating a new buffer.
-
-                       To know we have room, compare the allocated sizes
-                       beforeAlloc = SkAlign4(length + 1)
-                       afterAlloc  = SkAligh4(length + 1 + len)
-                       but SkAlign4(x) is (x + 3) >> 2 << 2
-                       which is equivalent for testing to (length + 1 + 3) >> 2 == (length + 1 + 3 + len) >> 2
-                       and we can then eliminate the +1+3 since that doesn't affec the answer
-               */
-               if (fRec->fRefCnt == 1 && (length >> 2) == ((length + len) >> 2))
-               {
-                       char* dst = this->writable_str();
-
-                       if (offset < length)
-                               memmove(dst + offset + len, dst + offset, length - offset);
-                       memcpy(dst + offset, text, len);
-
-                       dst[length + len] = 0;
-                       fRec->fLength = SkToU16(length + len);
-               }
-               else
-               {
-                       /*      Seems we should use realloc here, since that is safe if it fails
-                               (we have the original data), and might be faster than alloc/copy/free.
-                       */
-                       SkString        tmp(fRec->fLength + len);
-                       char*           dst = tmp.writable_str();
-
-                       if (offset > 0)
-                               memcpy(dst, fRec->data(), offset);
-                       memcpy(dst + offset, text, len);
-                       if (offset < fRec->fLength)
-                               memcpy(dst + offset + len, fRec->data() + offset, fRec->fLength - offset);
-
-                       this->swap(tmp);
-               }
-       }
+    if (len)
+    {
+        size_t length = fRec->fLength;
+        if (offset > length)
+            offset = length;
+
+        /*  If we're the only owner, and we have room in our allocation for the insert,
+            do it in place, rather than allocating a new buffer.
+
+            To know we have room, compare the allocated sizes
+            beforeAlloc = SkAlign4(length + 1)
+            afterAlloc  = SkAligh4(length + 1 + len)
+            but SkAlign4(x) is (x + 3) >> 2 << 2
+            which is equivalent for testing to (length + 1 + 3) >> 2 == (length + 1 + 3 + len) >> 2
+            and we can then eliminate the +1+3 since that doesn't affec the answer
+        */
+        if (fRec->fRefCnt == 1 && (length >> 2) == ((length + len) >> 2))
+        {
+            char* dst = this->writable_str();
+
+            if (offset < length)
+                memmove(dst + offset + len, dst + offset, length - offset);
+            memcpy(dst + offset, text, len);
+
+            dst[length + len] = 0;
+            fRec->fLength = SkToU16(length + len);
+        }
+        else
+        {
+            /*  Seems we should use realloc here, since that is safe if it fails
+                (we have the original data), and might be faster than alloc/copy/free.
+            */
+            SkString    tmp(fRec->fLength + len);
+            char*       dst = tmp.writable_str();
+
+            if (offset > 0)
+                memcpy(dst, fRec->data(), offset);
+            memcpy(dst + offset, text, len);
+            if (offset < fRec->fLength)
+                memcpy(dst + offset + len, fRec->data() + offset, fRec->fLength - offset);
+
+            this->swap(tmp);
+        }
+    }
 }
 
 void SkString::insertUnichar(size_t offset, SkUnichar uni)
 {
-       char    buffer[kMaxBytesInUTF8Sequence];
-       size_t  len = SkUTF8_FromUnichar(uni, buffer);
+    char    buffer[kMaxBytesInUTF8Sequence];
+    size_t  len = SkUTF8_FromUnichar(uni, buffer);
 
-       if (len)
-               this->insert(offset, buffer, len);
+    if (len)
+        this->insert(offset, buffer, len);
 }
 
-void SkString::insertS32(size_t offset, S32 dec)
+void SkString::insertS32(size_t offset, int32_t dec)
 {
-       char    buffer[SkStrAppendS32_MaxSize];
+    char    buffer[SkStrAppendS32_MaxSize];
     char*   stop = SkStrAppendS32(buffer, dec);
     this->insert(offset, buffer, stop - buffer);
 }
 
-void SkString::insertHex(size_t offset, U32 hex, int minDigits)
+void SkString::insertHex(size_t offset, uint32_t hex, int minDigits)
 {
-       minDigits = SkPin32(minDigits, 0, 8);
-       
-       static const char gHex[] = "0123456789ABCDEF";
+    minDigits = SkPin32(minDigits, 0, 8);
+    
+    static const char gHex[] = "0123456789ABCDEF";
 
-       char    buffer[8];
-       char*   p = buffer + sizeof(buffer);
+    char    buffer[8];
+    char*   p = buffer + sizeof(buffer);
 
-       do {
-               *--p = gHex[hex & 0xF];
-               hex >>= 4;
-               minDigits -= 1;
-       } while (hex != 0);
-       while (--minDigits >= 0)
-               *--p = '0';
+    do {
+        *--p = gHex[hex & 0xF];
+        hex >>= 4;
+        minDigits -= 1;
+    } while (hex != 0);
+    while (--minDigits >= 0)
+        *--p = '0';
 
-       SkASSERT(p >= buffer);
-       this->insert(offset, p, buffer + sizeof(buffer) - p);
+    SkASSERT(p >= buffer);
+    this->insert(offset, p, buffer + sizeof(buffer) - p);
 }
 
 void SkString::insertScalar(size_t offset, SkScalar value)
 {
-       char    buffer[SkStrAppendScalar_MaxSize];
+    char    buffer[SkStrAppendScalar_MaxSize];
     char*   stop = SkStrAppendScalar(buffer, value);
     this->insert(offset, buffer, stop - buffer);
 }
@@ -446,75 +465,75 @@ void SkString::insertScalar(size_t offset, SkScalar value)
 
 //#include <stdarg.h>
 #if defined(SK_BUILD_FOR_WIN) || defined(SK_BUILD_FOR_MAC) || defined(SK_BUILD_FOR_UNIX)
-       #include <stdio.h>
+    #include <stdio.h>
 #endif
 
 void SkString::printf(const char format[], ...)
 {
-       static const size_t kBufferSize = 100;
+    static const size_t kBufferSize = 100;
 
-       char    buffer[kBufferSize + 1];
+    char    buffer[kBufferSize + 1];
 
 #ifdef SK_BUILD_FOR_WIN
-       va_list args;
-       va_start(args, format);
-       _vsnprintf(buffer, kBufferSize, format, args);
-       va_end(args);
+    va_list args;
+    va_start(args, format);
+    _vsnprintf(buffer, kBufferSize, format, args);
+    va_end(args);
 #elif defined(SK_BUILD_FOR_MAC) || defined(SK_BUILD_FOR_UNIX)
-       va_list args;
-       va_start(args, format);
-       vsnprintf(buffer, kBufferSize, format, args);
-       va_end(args);
+    va_list args;
+    va_start(args, format);
+    vsnprintf(buffer, kBufferSize, format, args);
+    va_end(args);
 #else
-       buffer[0] = 0;
+    buffer[0] = 0;
 #endif
 
-       this->set(buffer, strlen(buffer));
+    this->set(buffer, strlen(buffer));
 }
 
 ///////////////////////////////////////////////////////////////////////////
 
 void SkString::remove(size_t offset, size_t length)
 {
-       size_t size = this->size();
-
-       if (offset < size)
-       {
-               if (offset + length > size)
-                       length = size - offset;
-               if (length > 0)
-               {
-                       SkASSERT(size > length);
-                       SkString        tmp(size - length);
-                       char*           dst = tmp.writable_str();
-                       const char*     src = this->c_str();
-
-                       if (offset)
-                       {
-                               SkASSERT(offset <= tmp.size());
-                               memcpy(dst, src, offset);
-                       }
-                       size_t tail = size - offset - length;
-                       SkASSERT((S32)tail >= 0);
-                       if (tail)
-                       {
-               //              SkASSERT(offset + length <= tmp.size());
-                               memcpy(dst + offset, src + offset + length, tail);
-                       }
-                       SkASSERT(dst[tmp.size()] == 0);
-                       this->swap(tmp);
-               }
-       }
+    size_t size = this->size();
+
+    if (offset < size)
+    {
+        if (offset + length > size)
+            length = size - offset;
+        if (length > 0)
+        {
+            SkASSERT(size > length);
+            SkString    tmp(size - length);
+            char*       dst = tmp.writable_str();
+            const char* src = this->c_str();
+
+            if (offset)
+            {
+                SkASSERT(offset <= tmp.size());
+                memcpy(dst, src, offset);
+            }
+            size_t tail = size - offset - length;
+            SkASSERT((int32_t)tail >= 0);
+            if (tail)
+            {
+        //      SkASSERT(offset + length <= tmp.size());
+                memcpy(dst + offset, src + offset + length, tail);
+            }
+            SkASSERT(dst[tmp.size()] == 0);
+            this->swap(tmp);
+        }
+    }
 }
 
 void SkString::swap(SkString& other)
 {
-       this->validate();
-       other.validate();
+    this->validate();
+    other.validate();
 
-       SkTSwap<Rec*>(fRec, other.fRec);
+    SkTSwap<Rec*>(fRec, other.fRec);
 #ifdef SK_DEBUG
-       SkTSwap<const char*>(fStr, other.fStr);
+    SkTSwap<const char*>(fStr, other.fStr);
 #endif
 }
 
@@ -522,23 +541,23 @@ void SkString::swap(SkString& other)
 
 SkAutoUCS2::SkAutoUCS2(const char utf8[])
 {
-       size_t len = strlen(utf8);
-       fUCS2 = (U16*)sk_malloc_throw((len + 1) * sizeof(U16));
+    size_t len = strlen(utf8);
+    fUCS2 = (uint16_t*)sk_malloc_throw((len + 1) * sizeof(uint16_t));
 
-       U16* dst = fUCS2;
-       for (;;)
-       {
-               SkUnichar       uni = SkUTF8_NextUnichar(&utf8);
-               *dst++ = SkToU16(uni);
-               if (uni == 0)
-                       break;
-       }
-       fCount = (int)(dst - fUCS2);
+    uint16_t* dst = fUCS2;
+    for (;;)
+    {
+        SkUnichar   uni = SkUTF8_NextUnichar(&utf8);
+        *dst++ = SkToU16(uni);
+        if (uni == 0)
+            break;
+    }
+    fCount = (int)(dst - fUCS2);
 }
 
 SkAutoUCS2::~SkAutoUCS2()
 {
-       delete[] fUCS2;
+    delete[] fUCS2;
 }
 
 /////////////////////////////////////////////////////////////////////////////////
@@ -549,52 +568,52 @@ SkAutoUCS2::~SkAutoUCS2()
 void SkString::UnitTest()
 {
 #ifdef SK_SUPPORT_UNITTEST
-       SkString        a;
-       SkString        b((size_t)0);
-       SkString        c("");
-       SkString        d(nil, 0);
-
-       SkASSERT(a.isEmpty());
-       SkASSERT(a == b && a == c && a == d);
-
-       a.set("hello");
-       b.set("hellox", 5);
-       c.set(a);
-       d.resize(5);
-       memcpy(d.writable_str(), "helloz", 5);
-
-       SkASSERT(!a.isEmpty());
-       SkASSERT(a.size() == 5);
-       SkASSERT(a == b && a == c && a == d);
-       SkASSERT(a.equals("hello", 5));
-       SkASSERT(a.equals("hello"));
-       SkASSERT(!a.equals("help"));
-
-       SkString        e(a);
-       SkString        f("hello");
-       SkString        g("helloz", 5);
-
-       SkASSERT(a == e && a == f && a == g);
-
-       b.set("world");
-       c = b;
-       SkASSERT(a != b && a != c && b == c);
-
-       a.append(" world");
-       e.append("worldz", 5);
-       e.insert(5, " ");
-       f.set("world");
-       f.prepend("hello ");
-       SkASSERT(a.equals("hello world") && a == e && a == f);
-
-       a.reset();
-       b.resize(0);
-       SkASSERT(a.isEmpty() && b.isEmpty() && a == b);
-
-       a.set("a");
-       a.set("ab");
-       a.set("abc");
-       a.set("abcd");
+    SkString    a;
+    SkString    b((size_t)0);
+    SkString    c("");
+    SkString    d(nil, 0);
+
+    SkASSERT(a.isEmpty());
+    SkASSERT(a == b && a == c && a == d);
+
+    a.set("hello");
+    b.set("hellox", 5);
+    c.set(a);
+    d.resize(5);
+    memcpy(d.writable_str(), "helloz", 5);
+
+    SkASSERT(!a.isEmpty());
+    SkASSERT(a.size() == 5);
+    SkASSERT(a == b && a == c && a == d);
+    SkASSERT(a.equals("hello", 5));
+    SkASSERT(a.equals("hello"));
+    SkASSERT(!a.equals("help"));
+
+    SkString    e(a);
+    SkString    f("hello");
+    SkString    g("helloz", 5);
+
+    SkASSERT(a == e && a == f && a == g);
+
+    b.set("world");
+    c = b;
+    SkASSERT(a != b && a != c && b == c);
+
+    a.append(" world");
+    e.append("worldz", 5);
+    e.insert(5, " ");
+    f.set("world");
+    f.prepend("hello ");
+    SkASSERT(a.equals("hello world") && a == e && a == f);
+
+    a.reset();
+    b.resize(0);
+    SkASSERT(a.isEmpty() && b.isEmpty() && a == b);
+
+    a.set("a");
+    a.set("ab");
+    a.set("abc");
+    a.set("abcd");
 #endif
 }
 
index f0c6654..a0833fc 100644 (file)
+/* libs/graphics/sgl/SkStroke.cpp
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #include "SkStrokerPriv.h"
 #include "SkGeometry.h"
 #include "SkPath.h"
 
-#define kMaxQuadSubdivide      5
-#define kMaxCubicSubdivide     4
+#define kMaxQuadSubdivide   5
+#define kMaxCubicSubdivide  4
 
 static inline bool degenerate_vector(const SkVector& v)
 {
-       return SkScalarNearlyZero(v.fX) && SkScalarNearlyZero(v.fY);
+    return SkScalarNearlyZero(v.fX) && SkScalarNearlyZero(v.fY);
 }
 
 static inline bool degenerate_line(const SkPoint& a, const SkPoint& b, SkScalar tolerance = SK_ScalarNearlyZero)
 {
-       return SkScalarNearlyZero(a.fX - b.fX, tolerance) && SkScalarNearlyZero(a.fY - b.fY, tolerance);
+    return SkScalarNearlyZero(a.fX - b.fX, tolerance) && SkScalarNearlyZero(a.fY - b.fY, tolerance);
 }
 
 static inline bool normals_too_curvy(const SkVector& norm0, SkVector& norm1)
 {
-       /*      root2/2 is a 45-degree angle
-               make this constant bigger for more subdivisions (but not >= 1)
-       */
-       static const SkScalar kFlatEnoughNormalDotProd = SK_ScalarSqrt2/2 + SK_Scalar1/10;
+    /*  root2/2 is a 45-degree angle
+        make this constant bigger for more subdivisions (but not >= 1)
+    */
+    static const SkScalar kFlatEnoughNormalDotProd = SK_ScalarSqrt2/2 + SK_Scalar1/10;
 
-       SkASSERT(kFlatEnoughNormalDotProd > 0 && kFlatEnoughNormalDotProd < SK_Scalar1);
+    SkASSERT(kFlatEnoughNormalDotProd > 0 && kFlatEnoughNormalDotProd < SK_Scalar1);
 
-       return SkPoint::DotProduct(norm0, norm1) <= kFlatEnoughNormalDotProd;
+    return SkPoint::DotProduct(norm0, norm1) <= kFlatEnoughNormalDotProd;
 }
 
 static inline bool normals_too_pinchy(const SkVector& norm0, SkVector& norm1)
 {
-       static const SkScalar kTooPinchyNormalDotProd = -SK_Scalar1 * 999 / 1000;
+    static const SkScalar kTooPinchyNormalDotProd = -SK_Scalar1 * 999 / 1000;
 
-       return SkPoint::DotProduct(norm0, norm1) <= kTooPinchyNormalDotProd;
+    return SkPoint::DotProduct(norm0, norm1) <= kTooPinchyNormalDotProd;
 }
 
 static bool set_normal_unitnormal(const SkPoint& before, const SkPoint& after,
-                                                                 SkScalar radius,
-                                                                 SkVector* normal, SkVector* unitNormal)
+                                  SkScalar radius,
+                                  SkVector* normal, SkVector* unitNormal)
 {
-       if (!unitNormal->setUnit(after.fX - before.fX, after.fY - before.fY))
-               return false;
+    if (!unitNormal->setUnit(after.fX - before.fX, after.fY - before.fY))
+        return false;
 
-       unitNormal->rotateCCW();
-       unitNormal->scale(radius, normal);
-       return true;
+    unitNormal->rotateCCW();
+    unitNormal->scale(radius, normal);
+    return true;
 }
 
 static bool set_normal_unitnormal(const SkVector& vec,
-                                                                 SkScalar radius,
-                                                                 SkVector* normal, SkVector* unitNormal)
+                                  SkScalar radius,
+                                  SkVector* normal, SkVector* unitNormal)
 {
-       if (!unitNormal->setUnit(vec.fX, vec.fY))
-               return false;
+    if (!unitNormal->setUnit(vec.fX, vec.fY))
+        return false;
 
-       unitNormal->rotateCCW();
-       unitNormal->scale(radius, normal);
-       return true;
+    unitNormal->rotateCCW();
+    unitNormal->scale(radius, normal);
+    return true;
 }
 
 //////////////////////////////////////////////////////////////////////////////////////////
 
 class SkPathStroker {
 public:
-       SkPathStroker(SkScalar radius, SkScalar miterLimit, SkPaint::Cap cap, SkPaint::Join join);
+    SkPathStroker(SkScalar radius, SkScalar miterLimit, SkPaint::Cap cap, SkPaint::Join join);
 
-       void    moveTo(const SkPoint&);
-       void    lineTo(const SkPoint&);
-       void    quadTo(const SkPoint&, const SkPoint&);
-       void    cubicTo(const SkPoint&, const SkPoint&, const SkPoint&);
-       void    close(bool isLine) { this->finishContour(true, isLine); }
+    void    moveTo(const SkPoint&);
+    void    lineTo(const SkPoint&);
+    void    quadTo(const SkPoint&, const SkPoint&);
+    void    cubicTo(const SkPoint&, const SkPoint&, const SkPoint&);
+    void    close(bool isLine) { this->finishContour(true, isLine); }
 
-       void    done(SkPath* dst, bool isLine)
-       {
-               this->finishContour(false, isLine);
-               fOuter.addPath(fExtra);
-               dst->swap(fOuter);
-       }
+    void    done(SkPath* dst, bool isLine)
+    {
+        this->finishContour(false, isLine);
+        fOuter.addPath(fExtra);
+        dst->swap(fOuter);
+    }
 
 private:
-       SkScalar        fRadius;
-       SkScalar        fInvMiterLimit;
-
-       SkVector        fFirstNormal, fPrevNormal, fFirstUnitNormal, fPrevUnitNormal;
-       SkPoint         fFirstPt, fPrevPt;      // on original path
-       SkPoint         fFirstOuterPt;
-       int                     fSegmentCount;
-       bool            fPrevIsLine;
-
-       SkStrokerPriv::CapProc  fCapper;
-       SkStrokerPriv::JoinProc fJoiner;
-
-       SkPath  fInner, fOuter; // outer is our working answer, inner is temp
-       SkPath  fExtra;                 // added as extra complete contours
-
-       void    finishContour(bool close, bool isLine);
-       void    preJoinTo(const SkPoint&, SkVector* normal, SkVector* unitNormal, bool isLine);
-       void    postJoinTo(const SkPoint&, const SkVector& normal, const SkVector& unitNormal);
-
-       void    line_to(const SkPoint& currPt, const SkVector& normal);
-       void    quad_to(const SkPoint pts[3],
-                                       const SkVector& normalAB, const SkVector& unitNormalAB,
-                                       SkVector* normalBC, SkVector* unitNormalBC,
-                                       int subDivide);
-       void    cubic_to(const SkPoint pts[4],
-                                       const SkVector& normalAB, const SkVector& unitNormalAB,
-                                       SkVector* normalCD, SkVector* unitNormalCD,
-                                       int subDivide);
+    SkScalar    fRadius;
+    SkScalar    fInvMiterLimit;
+
+    SkVector    fFirstNormal, fPrevNormal, fFirstUnitNormal, fPrevUnitNormal;
+    SkPoint     fFirstPt, fPrevPt;  // on original path
+    SkPoint     fFirstOuterPt;
+    int         fSegmentCount;
+    bool        fPrevIsLine;
+
+    SkStrokerPriv::CapProc  fCapper;
+    SkStrokerPriv::JoinProc fJoiner;
+
+    SkPath  fInner, fOuter; // outer is our working answer, inner is temp
+    SkPath  fExtra;         // added as extra complete contours
+
+    void    finishContour(bool close, bool isLine);
+    void    preJoinTo(const SkPoint&, SkVector* normal, SkVector* unitNormal, bool isLine);
+    void    postJoinTo(const SkPoint&, const SkVector& normal, const SkVector& unitNormal);
+
+    void    line_to(const SkPoint& currPt, const SkVector& normal);
+    void    quad_to(const SkPoint pts[3],
+                    const SkVector& normalAB, const SkVector& unitNormalAB,
+                    SkVector* normalBC, SkVector* unitNormalBC,
+                    int subDivide);
+    void    cubic_to(const SkPoint pts[4],
+                    const SkVector& normalAB, const SkVector& unitNormalAB,
+                    SkVector* normalCD, SkVector* unitNormalCD,
+                    int subDivide);
 };
 
 ////////////////////////////////////////////////////////////////////////////
 
 void SkPathStroker::preJoinTo(const SkPoint& currPt, SkVector* normal, SkVector* unitNormal, bool currIsLine)
 {
-       SkASSERT(fSegmentCount >= 0);
-
-       SkScalar        prevX = fPrevPt.fX;
-       SkScalar        prevY = fPrevPt.fY;
-
-       SkAssertResult(set_normal_unitnormal(fPrevPt, currPt, fRadius, normal, unitNormal));
-
-       if (fSegmentCount == 0)
-       {
-               fFirstNormal = *normal;
-               fFirstUnitNormal = *unitNormal;
-               fFirstOuterPt.set(prevX + normal->fX, prevY + normal->fY);
-
-               fOuter.moveTo(fFirstOuterPt.fX, fFirstOuterPt.fY);
-               fInner.moveTo(prevX - normal->fX, prevY - normal->fY);
-       }
-       else    // we have a previous segment
-       {
-               fJoiner(&fOuter, &fInner, fPrevUnitNormal, fPrevPt, *unitNormal, fRadius, fInvMiterLimit,
-                               fPrevIsLine, currIsLine);
-       }
-       fPrevIsLine = currIsLine;
+    SkASSERT(fSegmentCount >= 0);
+
+    SkScalar    prevX = fPrevPt.fX;
+    SkScalar    prevY = fPrevPt.fY;
+
+    SkAssertResult(set_normal_unitnormal(fPrevPt, currPt, fRadius, normal, unitNormal));
+
+    if (fSegmentCount == 0)
+    {
+        fFirstNormal = *normal;
+        fFirstUnitNormal = *unitNormal;
+        fFirstOuterPt.set(prevX + normal->fX, prevY + normal->fY);
+
+        fOuter.moveTo(fFirstOuterPt.fX, fFirstOuterPt.fY);
+        fInner.moveTo(prevX - normal->fX, prevY - normal->fY);
+    }
+    else    // we have a previous segment
+    {
+        fJoiner(&fOuter, &fInner, fPrevUnitNormal, fPrevPt, *unitNormal, fRadius, fInvMiterLimit,
+                fPrevIsLine, currIsLine);
+    }
+    fPrevIsLine = currIsLine;
 }
 
 void SkPathStroker::postJoinTo(const SkPoint& currPt, const SkVector& normal, const SkVector& unitNormal)
 {
-       fPrevPt = currPt;
-       fPrevUnitNormal = unitNormal;
-       fPrevNormal = normal;
-       fSegmentCount += 1;
+    fPrevPt = currPt;
+    fPrevUnitNormal = unitNormal;
+    fPrevNormal = normal;
+    fSegmentCount += 1;
 }
 
 void SkPathStroker::finishContour(bool close, bool currIsLine)
 {
-       if (fSegmentCount > 0)
-       {
-               SkPoint pt;
-
-               if (close)
-               {
-                       fJoiner(&fOuter, &fInner, fPrevUnitNormal, fPrevPt, fFirstUnitNormal,
-                                       fRadius, fInvMiterLimit, fPrevIsLine, currIsLine);
-                       fOuter.close();
-                       // now add fInner as its own contour
-                       fInner.getLastPt(&pt);
-                       fOuter.moveTo(pt.fX, pt.fY);
-                       fOuter.reversePathTo(fInner);
-                       fOuter.close();
-               }
-               else    // add caps to start and end
-               {
-                       // cap the end
-                       fInner.getLastPt(&pt);
-                       fCapper(&fOuter, fPrevPt, fPrevNormal, pt, currIsLine ? &fInner : nil);
-                       fOuter.reversePathTo(fInner);
-                       // cap the start
-                       fCapper(&fOuter, fFirstPt, -fFirstNormal, fFirstOuterPt, fPrevIsLine ? &fInner : nil);
-                       fOuter.close();
-               }
-       }
-       fInner.reset();
-       fSegmentCount = -1;
+    if (fSegmentCount > 0)
+    {
+        SkPoint pt;
+
+        if (close)
+        {
+            fJoiner(&fOuter, &fInner, fPrevUnitNormal, fPrevPt, fFirstUnitNormal,
+                    fRadius, fInvMiterLimit, fPrevIsLine, currIsLine);
+            fOuter.close();
+            // now add fInner as its own contour
+            fInner.getLastPt(&pt);
+            fOuter.moveTo(pt.fX, pt.fY);
+            fOuter.reversePathTo(fInner);
+            fOuter.close();
+        }
+        else    // add caps to start and end
+        {
+            // cap the end
+            fInner.getLastPt(&pt);
+            fCapper(&fOuter, fPrevPt, fPrevNormal, pt, currIsLine ? &fInner : nil);
+            fOuter.reversePathTo(fInner);
+            // cap the start
+            fCapper(&fOuter, fFirstPt, -fFirstNormal, fFirstOuterPt, fPrevIsLine ? &fInner : nil);
+            fOuter.close();
+        }
+    }
+    fInner.reset();
+    fSegmentCount = -1;
 }
 
 ////////////////////////////////////////////////////////////////////////////
 
 SkPathStroker::SkPathStroker(SkScalar radius, SkScalar miterLimit, SkPaint::Cap cap, SkPaint::Join join)
-       : fRadius(radius)
+    : fRadius(radius)
 {
-       if (join == SkPaint::kMiter_Join)
-       {
-               if (miterLimit <= SK_Scalar1)
-                       join = SkPaint::kBevel_Join;
-               else
-                       fInvMiterLimit = SkScalarInvert(miterLimit);
-       }
-       fCapper = SkStrokerPriv::CapFactory(cap);
-       fJoiner = SkStrokerPriv::JoinFactory(join);
-       fSegmentCount = -1;
-       fPrevIsLine = false;
+    if (join == SkPaint::kMiter_Join)
+    {
+        if (miterLimit <= SK_Scalar1)
+            join = SkPaint::kBevel_Join;
+        else
+            fInvMiterLimit = SkScalarInvert(miterLimit);
+    }
+    fCapper = SkStrokerPriv::CapFactory(cap);
+    fJoiner = SkStrokerPriv::JoinFactory(join);
+    fSegmentCount = -1;
+    fPrevIsLine = false;
 }
 
 void SkPathStroker::moveTo(const SkPoint& pt)
 {
-       if (fSegmentCount > 0)
-               this->finishContour(false, false);
+    if (fSegmentCount > 0)
+        this->finishContour(false, false);
 
-       fSegmentCount = 0;
-       fFirstPt = fPrevPt = pt;
+    fSegmentCount = 0;
+    fFirstPt = fPrevPt = pt;
 }
 
 void SkPathStroker::line_to(const SkPoint& currPt, const SkVector& normal)
 {
-       fOuter.lineTo(currPt.fX + normal.fX, currPt.fY + normal.fY);
-       fInner.lineTo(currPt.fX - normal.fX, currPt.fY - normal.fY);
+    fOuter.lineTo(currPt.fX + normal.fX, currPt.fY + normal.fY);
+    fInner.lineTo(currPt.fX - normal.fX, currPt.fY - normal.fY);
 }
 
 void SkPathStroker::lineTo(const SkPoint& currPt)
 {
-       if (degenerate_line(fPrevPt, currPt))
-               return;
+    if (degenerate_line(fPrevPt, currPt))
+        return;
 
-       SkVector        normal, unitNormal;
+    SkVector    normal, unitNormal;
 
-       this->preJoinTo(currPt, &normal, &unitNormal, true);
-       this->line_to(currPt, normal);
-       this->postJoinTo(currPt, normal, unitNormal);
+    this->preJoinTo(currPt, &normal, &unitNormal, true);
+    this->line_to(currPt, normal);
+    this->postJoinTo(currPt, normal, unitNormal);
 }
 
 void SkPathStroker::quad_to(const SkPoint pts[3],
-                                         const SkVector& normalAB, const SkVector& unitNormalAB,
-                                         SkVector* normalBC, SkVector* unitNormalBC,
-                                         int subDivide)
+                      const SkVector& normalAB, const SkVector& unitNormalAB,
+                      SkVector* normalBC, SkVector* unitNormalBC,
+                      int subDivide)
 {
-       if (!set_normal_unitnormal(pts[1], pts[2], fRadius, normalBC, unitNormalBC))
-       {
-               // pts[1] nearly equals pts[2], so just draw a line to pts[2]
-               this->line_to(pts[2], normalAB);
-               *normalBC = normalAB;
-               *unitNormalBC = unitNormalAB;
-               return;
-       }
-
-       if (--subDivide >= 0 && normals_too_curvy(unitNormalAB, *unitNormalBC))
-       {
-               SkPoint         tmp[5];
-               SkVector        norm, unit;
-
-               SkChopQuadAtHalf(pts, tmp);
-               this->quad_to(&tmp[0], normalAB, unitNormalAB, &norm, &unit, subDivide);
-               this->quad_to(&tmp[2], norm, unit, normalBC, unitNormalBC, subDivide);
-       }
-       else
-       {
-               SkVector        normalB, unitB;
-               SkAssertResult(set_normal_unitnormal(pts[0], pts[2], fRadius, &normalB, &unitB));
-
-               fOuter.quadTo(  pts[1].fX + normalB.fX, pts[1].fY + normalB.fY,
-                                               pts[2].fX + normalBC->fX, pts[2].fY + normalBC->fY);
-               fInner.quadTo(  pts[1].fX - normalB.fX, pts[1].fY - normalB.fY,
-                                               pts[2].fX - normalBC->fX, pts[2].fY - normalBC->fY);
-       }
+    if (!set_normal_unitnormal(pts[1], pts[2], fRadius, normalBC, unitNormalBC))
+    {
+        // pts[1] nearly equals pts[2], so just draw a line to pts[2]
+        this->line_to(pts[2], normalAB);
+        *normalBC = normalAB;
+        *unitNormalBC = unitNormalAB;
+        return;
+    }
+
+    if (--subDivide >= 0 && normals_too_curvy(unitNormalAB, *unitNormalBC))
+    {
+        SkPoint     tmp[5];
+        SkVector    norm, unit;
+
+        SkChopQuadAtHalf(pts, tmp);
+        this->quad_to(&tmp[0], normalAB, unitNormalAB, &norm, &unit, subDivide);
+        this->quad_to(&tmp[2], norm, unit, normalBC, unitNormalBC, subDivide);
+    }
+    else
+    {
+        SkVector    normalB, unitB;
+        SkAssertResult(set_normal_unitnormal(pts[0], pts[2], fRadius, &normalB, &unitB));
+
+        fOuter.quadTo(  pts[1].fX + normalB.fX, pts[1].fY + normalB.fY,
+                        pts[2].fX + normalBC->fX, pts[2].fY + normalBC->fY);
+        fInner.quadTo(  pts[1].fX - normalB.fX, pts[1].fY - normalB.fY,
+                        pts[2].fX - normalBC->fX, pts[2].fY - normalBC->fY);
+    }
 }
 
 void SkPathStroker::cubic_to(const SkPoint pts[4],
-                                         const SkVector& normalAB, const SkVector& unitNormalAB,
-                                         SkVector* normalCD, SkVector* unitNormalCD,
-                                         int subDivide)
+                      const SkVector& normalAB, const SkVector& unitNormalAB,
+                      SkVector* normalCD, SkVector* unitNormalCD,
+                      int subDivide)
 {
-       SkVector        ab = pts[1] - pts[0];
-       SkVector        cd = pts[3] - pts[2];
-       SkVector        normalBC, unitNormalBC;
+    SkVector    ab = pts[1] - pts[0];
+    SkVector    cd = pts[3] - pts[2];
+    SkVector    normalBC, unitNormalBC;
 
-       bool    degenerateAB = degenerate_vector(ab);
-       bool    degenerateCD = degenerate_vector(cd);
+    bool    degenerateAB = degenerate_vector(ab);
+    bool    degenerateCD = degenerate_vector(cd);
 
-       if (degenerateAB && degenerateCD)
-       {
+    if (degenerateAB && degenerateCD)
+    {
 DRAW_LINE:
-               this->line_to(pts[3], normalAB);
-               *normalCD = normalAB;
-               *unitNormalCD = unitNormalAB;
-               return;
-       }
-
-       if (degenerateAB)
-       {
-               ab = pts[2] - pts[0];
-               degenerateAB = degenerate_vector(ab);
-       }
-       if (degenerateCD)
-       {
-               cd = pts[3] - pts[1];
-               degenerateCD = degenerate_vector(cd);
-       }
-       if (degenerateAB || degenerateCD)
-               goto DRAW_LINE;
-
-       SkAssertResult(set_normal_unitnormal(cd, fRadius, normalCD, unitNormalCD));
-       bool degenerateBC = !set_normal_unitnormal(pts[1], pts[2], fRadius, &normalBC, &unitNormalBC);
-
-       if (--subDivide >= 0 &&
-               (degenerateBC || normals_too_curvy(unitNormalAB, unitNormalBC) || normals_too_curvy(unitNormalBC, *unitNormalCD)))
-       {
-               SkPoint         tmp[7];
-               SkVector        norm, unit, dummy, unitDummy;
-
-               SkChopCubicAtHalf(pts, tmp);
-               this->cubic_to(&tmp[0], normalAB, unitNormalAB, &norm, &unit, subDivide);
-               // we use dummys since we already have a valid (and more accurate) normals for CD
-               this->cubic_to(&tmp[3], norm, unit, &dummy, &unitDummy, subDivide);
-       }
-       else
-       {
-               SkVector        normalB, normalC;
-               
-               // need normals to inset/outset the off-curve pts B and C
-
-               if (0)// this is normal to the line between our adjacent pts
-               {
-                       normalB = pts[2] - pts[0];
-                       normalB.rotateCCW();
-                       SkAssertResult(normalB.setLength(fRadius));
-
-                       normalC = pts[3] - pts[1];
-                       normalC.rotateCCW();
-                       SkAssertResult(normalC.setLength(fRadius));
-               }
-               else    // miter-join
-               {
-                       SkVector        unitBC = pts[2] - pts[1];
-                       unitBC.normalize();
-                       unitBC.rotateCCW();
-
-                       normalB = unitNormalAB + unitBC;
-                       normalC = *unitNormalCD + unitBC;
-
-                       SkScalar dot = SkPoint::DotProduct(unitNormalAB, unitBC);
-                       SkAssertResult(normalB.setLength(SkScalarDiv(fRadius, SkScalarSqrt((SK_Scalar1 + dot)/2))));
-                       dot = SkPoint::DotProduct(*unitNormalCD, unitBC);
-                       SkAssertResult(normalC.setLength(SkScalarDiv(fRadius, SkScalarSqrt((SK_Scalar1 + dot)/2))));
-               }
-
-               fOuter.cubicTo( pts[1].fX + normalB.fX, pts[1].fY + normalB.fY,
-                                               pts[2].fX + normalC.fX, pts[2].fY + normalC.fY,
-                                               pts[3].fX + normalCD->fX, pts[3].fY + normalCD->fY);
-
-               fInner.cubicTo( pts[1].fX - normalB.fX, pts[1].fY - normalB.fY,
-                                               pts[2].fX - normalC.fX, pts[2].fY - normalC.fY,
-                                               pts[3].fX - normalCD->fX, pts[3].fY - normalCD->fY);
-       }
+        this->line_to(pts[3], normalAB);
+        *normalCD = normalAB;
+        *unitNormalCD = unitNormalAB;
+        return;
+    }
+
+    if (degenerateAB)
+    {
+        ab = pts[2] - pts[0];
+        degenerateAB = degenerate_vector(ab);
+    }
+    if (degenerateCD)
+    {
+        cd = pts[3] - pts[1];
+        degenerateCD = degenerate_vector(cd);
+    }
+    if (degenerateAB || degenerateCD)
+        goto DRAW_LINE;
+
+    SkAssertResult(set_normal_unitnormal(cd, fRadius, normalCD, unitNormalCD));
+    bool degenerateBC = !set_normal_unitnormal(pts[1], pts[2], fRadius, &normalBC, &unitNormalBC);
+
+    if (--subDivide >= 0 &&
+        (degenerateBC || normals_too_curvy(unitNormalAB, unitNormalBC) || normals_too_curvy(unitNormalBC, *unitNormalCD)))
+    {
+        SkPoint     tmp[7];
+        SkVector    norm, unit, dummy, unitDummy;
+
+        SkChopCubicAtHalf(pts, tmp);
+        this->cubic_to(&tmp[0], normalAB, unitNormalAB, &norm, &unit, subDivide);
+        // we use dummys since we already have a valid (and more accurate) normals for CD
+        this->cubic_to(&tmp[3], norm, unit, &dummy, &unitDummy, subDivide);
+    }
+    else
+    {
+        SkVector    normalB, normalC;
+        
+        // need normals to inset/outset the off-curve pts B and C
+
+        if (0)// this is normal to the line between our adjacent pts
+        {
+            normalB = pts[2] - pts[0];
+            normalB.rotateCCW();
+            SkAssertResult(normalB.setLength(fRadius));
+
+            normalC = pts[3] - pts[1];
+            normalC.rotateCCW();
+            SkAssertResult(normalC.setLength(fRadius));
+        }
+        else    // miter-join
+        {
+            SkVector    unitBC = pts[2] - pts[1];
+            unitBC.normalize();
+            unitBC.rotateCCW();
+
+            normalB = unitNormalAB + unitBC;
+            normalC = *unitNormalCD + unitBC;
+
+            SkScalar dot = SkPoint::DotProduct(unitNormalAB, unitBC);
+            SkAssertResult(normalB.setLength(SkScalarDiv(fRadius, SkScalarSqrt((SK_Scalar1 + dot)/2))));
+            dot = SkPoint::DotProduct(*unitNormalCD, unitBC);
+            SkAssertResult(normalC.setLength(SkScalarDiv(fRadius, SkScalarSqrt((SK_Scalar1 + dot)/2))));
+        }
+
+        fOuter.cubicTo( pts[1].fX + normalB.fX, pts[1].fY + normalB.fY,
+                        pts[2].fX + normalC.fX, pts[2].fY + normalC.fY,
+                        pts[3].fX + normalCD->fX, pts[3].fY + normalCD->fY);
+
+        fInner.cubicTo( pts[1].fX - normalB.fX, pts[1].fY - normalB.fY,
+                        pts[2].fX - normalC.fX, pts[2].fY - normalC.fY,
+                        pts[3].fX - normalCD->fX, pts[3].fY - normalCD->fY);
+    }
 }
 
 void SkPathStroker::quadTo(const SkPoint& pt1, const SkPoint& pt2)
 {
-       bool    degenerateAB = degenerate_line(fPrevPt, pt1);
-       bool    degenerateBC = degenerate_line(pt1, pt2);
-
-       if (degenerateAB | degenerateBC)
-       {
-               if (degenerateAB ^ degenerateBC)
-                       this->lineTo(pt2);
-               return;
-       }
-
-       SkVector        normalAB, unitAB, normalBC, unitBC;
-
-       this->preJoinTo(pt1, &normalAB, &unitAB, false);
-
-       {
-               SkPoint pts[3], tmp[5];
-               pts[0] = fPrevPt;
-               pts[1] = pt1;
-               pts[2] = pt2;
-
-               if (SkChopQuadAtMaxCurvature(pts, tmp) == 2)
-               {
-                       unitBC.setUnit(pts[2].fX - pts[1].fX, pts[2].fY - pts[1].fY);
-                       unitBC.rotateCCW();
-                       if (normals_too_pinchy(unitAB, unitBC))
-                       {
-                               normalBC = unitBC;
-                               normalBC.scale(fRadius);
-
-                               fOuter.lineTo(tmp[2].fX + normalAB.fX, tmp[2].fY + normalAB.fY);
-                               fOuter.lineTo(tmp[2].fX + normalBC.fX, tmp[2].fY + normalBC.fY);
-                               fOuter.lineTo(tmp[4].fX + normalBC.fX, tmp[4].fY + normalBC.fY);
-
-                               fInner.lineTo(tmp[2].fX - normalAB.fX, tmp[2].fY - normalAB.fY);
-                               fInner.lineTo(tmp[2].fX - normalBC.fX, tmp[2].fY - normalBC.fY);
-                               fInner.lineTo(tmp[4].fX - normalBC.fX, tmp[4].fY - normalBC.fY);
-
-                               fExtra.addCircle(tmp[2].fX, tmp[2].fY, fRadius, SkPath::kCW_Direction);
-                       }
-                       else
-                       {
-                               this->quad_to(&tmp[0], normalAB, unitAB, &normalBC, &unitBC, kMaxQuadSubdivide);
-                               SkVector n = normalBC;
-                               SkVector u = unitBC;
-                               this->quad_to(&tmp[2], n, u, &normalBC, &unitBC, kMaxQuadSubdivide);
-                       }
-               }
-               else
-                       this->quad_to(pts, normalAB, unitAB, &normalBC, &unitBC, kMaxQuadSubdivide);
-       }
-
-       this->postJoinTo(pt2, normalBC, unitBC);
+    bool    degenerateAB = degenerate_line(fPrevPt, pt1);
+    bool    degenerateBC = degenerate_line(pt1, pt2);
+
+    if (degenerateAB | degenerateBC)
+    {
+        if (degenerateAB ^ degenerateBC)
+            this->lineTo(pt2);
+        return;
+    }
+
+    SkVector    normalAB, unitAB, normalBC, unitBC;
+
+    this->preJoinTo(pt1, &normalAB, &unitAB, false);
+
+    {
+        SkPoint pts[3], tmp[5];
+        pts[0] = fPrevPt;
+        pts[1] = pt1;
+        pts[2] = pt2;
+
+        if (SkChopQuadAtMaxCurvature(pts, tmp) == 2)
+        {
+            unitBC.setUnit(pts[2].fX - pts[1].fX, pts[2].fY - pts[1].fY);
+            unitBC.rotateCCW();
+            if (normals_too_pinchy(unitAB, unitBC))
+            {
+                normalBC = unitBC;
+                normalBC.scale(fRadius);
+
+                fOuter.lineTo(tmp[2].fX + normalAB.fX, tmp[2].fY + normalAB.fY);
+                fOuter.lineTo(tmp[2].fX + normalBC.fX, tmp[2].fY + normalBC.fY);
+                fOuter.lineTo(tmp[4].fX + normalBC.fX, tmp[4].fY + normalBC.fY);
+
+                fInner.lineTo(tmp[2].fX - normalAB.fX, tmp[2].fY - normalAB.fY);
+                fInner.lineTo(tmp[2].fX - normalBC.fX, tmp[2].fY - normalBC.fY);
+                fInner.lineTo(tmp[4].fX - normalBC.fX, tmp[4].fY - normalBC.fY);
+
+                fExtra.addCircle(tmp[2].fX, tmp[2].fY, fRadius, SkPath::kCW_Direction);
+            }
+            else
+            {
+                this->quad_to(&tmp[0], normalAB, unitAB, &normalBC, &unitBC, kMaxQuadSubdivide);
+                SkVector n = normalBC;
+                SkVector u = unitBC;
+                this->quad_to(&tmp[2], n, u, &normalBC, &unitBC, kMaxQuadSubdivide);
+            }
+        }
+        else
+            this->quad_to(pts, normalAB, unitAB, &normalBC, &unitBC, kMaxQuadSubdivide);
+    }
+
+    this->postJoinTo(pt2, normalBC, unitBC);
 }
 
 void SkPathStroker::cubicTo(const SkPoint& pt1, const SkPoint& pt2, const SkPoint& pt3)
 {
-       bool    degenerateAB = degenerate_line(fPrevPt, pt1);
-       bool    degenerateBC = degenerate_line(pt1, pt2);
-       bool    degenerateCD = degenerate_line(pt2, pt3);
-
-       if (degenerateAB + degenerateBC + degenerateCD >= 2)
-       {
-               this->lineTo(pt3);
-               return;
-       }
-
-       SkVector        normalAB, unitAB, normalCD, unitCD;
-
-       // find the first tangent (which might be pt1 or pt2
-       {
-               const SkPoint*  nextPt = &pt1;
-               if (degenerateAB)
-                       nextPt = &pt2;
-               this->preJoinTo(*nextPt, &normalAB, &unitAB, false);
-       }
-
-       {
-               SkPoint pts[4], tmp[13];
-               int                     i, count;
-               SkVector        n, u;
-               SkScalar        tValues[3];
-
-               pts[0] = fPrevPt;
-               pts[1] = pt1;
-               pts[2] = pt2;
-               pts[3] = pt3;
+    bool    degenerateAB = degenerate_line(fPrevPt, pt1);
+    bool    degenerateBC = degenerate_line(pt1, pt2);
+    bool    degenerateCD = degenerate_line(pt2, pt3);
+
+    if (degenerateAB + degenerateBC + degenerateCD >= 2)
+    {
+        this->lineTo(pt3);
+        return;
+    }
+
+    SkVector    normalAB, unitAB, normalCD, unitCD;
+
+    // find the first tangent (which might be pt1 or pt2
+    {
+        const SkPoint*  nextPt = &pt1;
+        if (degenerateAB)
+            nextPt = &pt2;
+        this->preJoinTo(*nextPt, &normalAB, &unitAB, false);
+    }
+
+    {
+        SkPoint pts[4], tmp[13];
+        int         i, count;
+        SkVector    n, u;
+        SkScalar    tValues[3];
+
+        pts[0] = fPrevPt;
+        pts[1] = pt1;
+        pts[2] = pt2;
+        pts[3] = pt3;
 
 #if 1
-               count = SkChopCubicAtMaxCurvature(pts, tmp, tValues);
+        count = SkChopCubicAtMaxCurvature(pts, tmp, tValues);
 #else
-               count = 1;
-               memcpy(tmp, pts, 4 * sizeof(SkPoint));
+        count = 1;
+        memcpy(tmp, pts, 4 * sizeof(SkPoint));
 #endif
-               n = normalAB;
-               u = unitAB;
-               for (i = 0; i < count; i++)
-               {
-                       this->cubic_to(&tmp[i * 3], n, u, &normalCD, &unitCD, kMaxCubicSubdivide);
-                       if (i == count - 1)
-                               break;
-                       n = normalCD;
-                       u = unitCD;
-
-               }
-
-               // check for too pinchy
-               for (i = 1; i < count; i++)
-               {
-                       SkPoint p;
-                       SkVector        v, c;
-
-                       SkEvalCubicAt(pts, tValues[i - 1], &p, &v, &c);
-
-                       SkScalar        dot = SkPoint::DotProduct(c, c);
-                       v.scale(SkScalarInvert(dot));
-
-                       if (SkScalarNearlyZero(v.fX) && SkScalarNearlyZero(v.fY))
-                       {
-                               fExtra.addCircle(p.fX, p.fY, fRadius, SkPath::kCW_Direction);
-                       }
-               }
-
-       }
-
-       this->postJoinTo(pt3, normalCD, unitCD);
+        n = normalAB;
+        u = unitAB;
+        for (i = 0; i < count; i++)
+        {
+            this->cubic_to(&tmp[i * 3], n, u, &normalCD, &unitCD, kMaxCubicSubdivide);
+            if (i == count - 1)
+                break;
+            n = normalCD;
+            u = unitCD;
+
+        }
+
+        // check for too pinchy
+        for (i = 1; i < count; i++)
+        {
+            SkPoint p;
+            SkVector    v, c;
+
+            SkEvalCubicAt(pts, tValues[i - 1], &p, &v, &c);
+
+            SkScalar    dot = SkPoint::DotProduct(c, c);
+            v.scale(SkScalarInvert(dot));
+
+            if (SkScalarNearlyZero(v.fX) && SkScalarNearlyZero(v.fY))
+            {
+                fExtra.addCircle(p.fX, p.fY, fRadius, SkPath::kCW_Direction);
+            }
+        }
+
+    }
+
+    this->postJoinTo(pt3, normalCD, unitCD);
 }
 
 /////////////////////////////////////////////////////////////////////////////////
@@ -481,106 +498,106 @@ void SkPathStroker::cubicTo(const SkPoint& pt1, const SkPoint& pt2, const SkPoin
 
 SkStroke::SkStroke()
 {
-       fWidth          = SK_DefaultStrokeWidth;
-       fMiterLimit     = SK_DefaultMiterLimit;
-       fCap            = SkPaint::kDefault_Cap;
-       fJoin           = SkPaint::kDefault_Join;
-       fDoFill         = false;
+    fWidth      = SK_DefaultStrokeWidth;
+    fMiterLimit = SK_DefaultMiterLimit;
+    fCap        = SkPaint::kDefault_Cap;
+    fJoin       = SkPaint::kDefault_Join;
+    fDoFill     = false;
 }
 
 SkStroke::SkStroke(const SkPaint& p)
 {
-       fWidth          = p.getStrokeWidth();
-       fMiterLimit     = p.getStrokeMiter();
-       fCap            = (U8)p.getStrokeCap();
-       fJoin           = (U8)p.getStrokeJoin();
-       fDoFill         = SkToU8(p.getStyle() == SkPaint::kStrokeAndFill_Style);
+    fWidth      = p.getStrokeWidth();
+    fMiterLimit = p.getStrokeMiter();
+    fCap        = (U8)p.getStrokeCap();
+    fJoin       = (U8)p.getStrokeJoin();
+    fDoFill     = SkToU8(p.getStyle() == SkPaint::kStrokeAndFill_Style);
 }
 
 SkStroke::SkStroke(const SkPaint& p, SkScalar width)
 {
-       fWidth          = width;
-       fMiterLimit     = p.getStrokeMiter();
-       fCap            = (U8)p.getStrokeCap();
-       fJoin           = (U8)p.getStrokeJoin();
-       fDoFill         = SkToU8(p.getStyle() == SkPaint::kStrokeAndFill_Style);
+    fWidth      = width;
+    fMiterLimit = p.getStrokeMiter();
+    fCap        = (U8)p.getStrokeCap();
+    fJoin       = (U8)p.getStrokeJoin();
+    fDoFill     = SkToU8(p.getStyle() == SkPaint::kStrokeAndFill_Style);
 }
 
 void SkStroke::setWidth(SkScalar width)
 {
-       SkASSERT(width >= 0);
-       fWidth = width;
+    SkASSERT(width >= 0);
+    fWidth = width;
 }
 
 void SkStroke::setMiterLimit(SkScalar miterLimit)
 {
-       SkASSERT(miterLimit >= 0);
-       fMiterLimit = miterLimit;
+    SkASSERT(miterLimit >= 0);
+    fMiterLimit = miterLimit;
 }
 
 void SkStroke::setCap(SkPaint::Cap cap)
 {
-       SkASSERT((unsigned)cap < SkPaint::kCapCount);
-       fCap = SkToU8(cap);
+    SkASSERT((unsigned)cap < SkPaint::kCapCount);
+    fCap = SkToU8(cap);
 }
 
 void SkStroke::setJoin(SkPaint::Join join)
 {
-       SkASSERT((unsigned)join < SkPaint::kJoinCount);
-       fJoin = SkToU8(join);
+    SkASSERT((unsigned)join < SkPaint::kJoinCount);
+    fJoin = SkToU8(join);
 }
 
 void SkStroke::strokePath(const SkPath& src, SkPath* dst) const
 {
-       SkASSERT(&src != nil && dst != nil);
-
-       dst->reset();
-       if (SkScalarHalf(fWidth) <= 0)
-               return;
-
-       SkPathStroker   stroker(SkScalarHalf(fWidth), fMiterLimit, this->getCap(), this->getJoin());
-
-       SkPath::Iter    iter(src, false);
-       SkPoint                 pts[4];
-       SkPath::Verb    verb, lastSegment = SkPath::kMove_Verb;
-
-       while ((verb = iter.next(pts)) != SkPath::kDone_Verb)
-       {
-               switch (verb) {
-               case SkPath::kMove_Verb:
-                       stroker.moveTo(pts[0]);
-                       break;
-               case SkPath::kLine_Verb:
-                       stroker.lineTo(pts[1]);
-                       lastSegment = verb;
-                       break;
-               case SkPath::kQuad_Verb:
-                       stroker.quadTo(pts[1], pts[2]);
-                       lastSegment = verb;
-                       break;
-               case SkPath::kCubic_Verb:
-                       stroker.cubicTo(pts[1], pts[2], pts[3]);
-                       lastSegment = verb;
-                       break;
-               case SkPath::kClose_Verb:
-                       stroker.close(lastSegment == SkPath::kLine_Verb);
-                       break;
-               default:
-                       break;
-               }
-       }
-       stroker.done(dst, lastSegment == SkPath::kLine_Verb);
-
-       if (fDoFill)
-               dst->addPath(src);
+    SkASSERT(&src != nil && dst != nil);
+
+    dst->reset();
+    if (SkScalarHalf(fWidth) <= 0)
+        return;
+
+    SkPathStroker   stroker(SkScalarHalf(fWidth), fMiterLimit, this->getCap(), this->getJoin());
+
+    SkPath::Iter    iter(src, false);
+    SkPoint         pts[4];
+    SkPath::Verb    verb, lastSegment = SkPath::kMove_Verb;
+
+    while ((verb = iter.next(pts)) != SkPath::kDone_Verb)
+    {
+        switch (verb) {
+        case SkPath::kMove_Verb:
+            stroker.moveTo(pts[0]);
+            break;
+        case SkPath::kLine_Verb:
+            stroker.lineTo(pts[1]);
+            lastSegment = verb;
+            break;
+        case SkPath::kQuad_Verb:
+            stroker.quadTo(pts[1], pts[2]);
+            lastSegment = verb;
+            break;
+        case SkPath::kCubic_Verb:
+            stroker.cubicTo(pts[1], pts[2], pts[3]);
+            lastSegment = verb;
+            break;
+        case SkPath::kClose_Verb:
+            stroker.close(lastSegment == SkPath::kLine_Verb);
+            break;
+        default:
+            break;
+        }
+    }
+    stroker.done(dst, lastSegment == SkPath::kLine_Verb);
+
+    if (fDoFill)
+        dst->addPath(src);
 }
 
 void SkStroke::strokeLine(const SkPoint& p0, const SkPoint& p1, SkPath* dst) const
 {
-       SkPath  tmp;
+    SkPath  tmp;
 
-       tmp.moveTo(p0);
-       tmp.lineTo(p1);
-       this->strokePath(tmp, dst);
+    tmp.moveTo(p0);
+    tmp.lineTo(p1);
+    this->strokePath(tmp, dst);
 }
 
index 4daf932..7fdc33c 100644 (file)
+/* libs/graphics/sgl/SkStrokerPriv.cpp
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #include "SkStrokerPriv.h"
 #include "SkGeometry.h"
 #include "SkPath.h"
 
 static void ButtCapper(SkPath* path, const SkPoint& pivot,
-                                          const SkVector& normal, const SkPoint& stop,
-                                          SkPath*)
+                       const SkVector& normal, const SkPoint& stop,
+                       SkPath*)
 {
-       path->lineTo(stop.fX, stop.fY);
+    path->lineTo(stop.fX, stop.fY);
 }
 
 static void RoundCapper(SkPath* path, const SkPoint& pivot,
-                                               const SkVector& normal, const SkPoint& stop,
-                                               SkPath*)
+                        const SkVector& normal, const SkPoint& stop,
+                        SkPath*)
 {
-       SkScalar        px = pivot.fX;
-       SkScalar        py = pivot.fY;
-       SkScalar        nx = normal.fX;
-       SkScalar        ny = normal.fY;
-       SkScalar        sx = SkScalarMul(nx, CUBIC_ARC_FACTOR);
-       SkScalar        sy = SkScalarMul(ny, CUBIC_ARC_FACTOR);
-
-       path->cubicTo(px + nx + CWX(sx, sy), py + ny + CWY(sx, sy),
-                                 px + CWX(nx, ny) + sx, py + CWY(nx, ny) + sy,
-                                 px + CWX(nx, ny), py + CWY(nx, ny));
-       path->cubicTo(px + CWX(nx, ny) - sx, py + CWY(nx, ny) - sy,
-                                 px - nx + CWX(sx, sy), py - ny + CWY(sx, sy),
-                                 stop.fX, stop.fY);
+    SkScalar    px = pivot.fX;
+    SkScalar    py = pivot.fY;
+    SkScalar    nx = normal.fX;
+    SkScalar    ny = normal.fY;
+    SkScalar    sx = SkScalarMul(nx, CUBIC_ARC_FACTOR);
+    SkScalar    sy = SkScalarMul(ny, CUBIC_ARC_FACTOR);
+
+    path->cubicTo(px + nx + CWX(sx, sy), py + ny + CWY(sx, sy),
+                  px + CWX(nx, ny) + sx, py + CWY(nx, ny) + sy,
+                  px + CWX(nx, ny), py + CWY(nx, ny));
+    path->cubicTo(px + CWX(nx, ny) - sx, py + CWY(nx, ny) - sy,
+                  px - nx + CWX(sx, sy), py - ny + CWY(sx, sy),
+                  stop.fX, stop.fY);
 }
 
 static void SquareCapper(SkPath* path, const SkPoint& pivot,
-                                                const SkVector& normal, const SkPoint& stop,
-                                                SkPath* otherPath)
+                         const SkVector& normal, const SkPoint& stop,
+                         SkPath* otherPath)
 {
-       SkVector parallel;
-       normal.rotateCW(&parallel);
-
-       if (otherPath)
-       {
-               path->setLastPt(pivot.fX + normal.fX + parallel.fX, pivot.fY + normal.fY + parallel.fY);
-               path->lineTo(pivot.fX - normal.fX + parallel.fX, pivot.fY - normal.fY + parallel.fY);
-       }
-       else
-       {
-               path->lineTo(pivot.fX + normal.fX + parallel.fX, pivot.fY + normal.fY + parallel.fY);
-               path->lineTo(pivot.fX - normal.fX + parallel.fX, pivot.fY - normal.fY + parallel.fY);
-               path->lineTo(stop.fX, stop.fY);
-       }
+    SkVector parallel;
+    normal.rotateCW(&parallel);
+
+    if (otherPath)
+    {
+        path->setLastPt(pivot.fX + normal.fX + parallel.fX, pivot.fY + normal.fY + parallel.fY);
+        path->lineTo(pivot.fX - normal.fX + parallel.fX, pivot.fY - normal.fY + parallel.fY);
+    }
+    else
+    {
+        path->lineTo(pivot.fX + normal.fX + parallel.fX, pivot.fY + normal.fY + parallel.fY);
+        path->lineTo(pivot.fX - normal.fX + parallel.fX, pivot.fY - normal.fY + parallel.fY);
+        path->lineTo(stop.fX, stop.fY);
+    }
 }
 
 /////////////////////////////////////////////////////////////////////////////
 
 static bool is_clockwise(const SkVector& before, const SkVector& after)
 {
-       return SkScalarMul(before.fX, after.fY) - SkScalarMul(before.fY, after.fX) > 0;
+    return SkScalarMul(before.fX, after.fY) - SkScalarMul(before.fY, after.fX) > 0;
 }
 
 enum AngleType {
-       kNearly180_AngleType,
-       kSharp_AngleType,
-       kShallow_AngleType,
-       kNearlyLine_AngleType
+    kNearly180_AngleType,
+    kSharp_AngleType,
+    kShallow_AngleType,
+    kNearlyLine_AngleType
 };
 
 static AngleType Dot2AngleType(SkScalar dot)
 {
 // need more precise fixed normalization
-//     SkASSERT(SkScalarAbs(dot) <= SK_Scalar1 + SK_ScalarNearlyZero);
+//  SkASSERT(SkScalarAbs(dot) <= SK_Scalar1 + SK_ScalarNearlyZero);
 
-       if (dot >= 0)   // shallow or line
-               return SkScalarNearlyZero(SK_Scalar1 - dot) ? kNearlyLine_AngleType : kShallow_AngleType;
-       else                    // sharp or 180
-               return SkScalarNearlyZero(SK_Scalar1 + dot) ? kNearly180_AngleType : kSharp_AngleType;
+    if (dot >= 0)   // shallow or line
+        return SkScalarNearlyZero(SK_Scalar1 - dot) ? kNearlyLine_AngleType : kShallow_AngleType;
+    else            // sharp or 180
+        return SkScalarNearlyZero(SK_Scalar1 + dot) ? kNearly180_AngleType : kSharp_AngleType;
 }
 
 static void BluntJoiner(SkPath* outer, SkPath* inner, const SkVector& beforeUnitNormal,
-                                               const SkPoint& pivot, const SkVector& afterUnitNormal,
-                                               SkScalar radius, SkScalar invMiterLimit, bool, bool)
+                        const SkPoint& pivot, const SkVector& afterUnitNormal,
+                        SkScalar radius, SkScalar invMiterLimit, bool, bool)
 {
-       SkVector        after;
-       afterUnitNormal.scale(radius, &after);
+    SkVector    after;
+    afterUnitNormal.scale(radius, &after);
 
-       outer->lineTo(pivot.fX + after.fX, pivot.fY + after.fY);
-       inner->lineTo(pivot.fX - after.fX, pivot.fY - after.fY);
+    outer->lineTo(pivot.fX + after.fX, pivot.fY + after.fY);
+    inner->lineTo(pivot.fX - after.fX, pivot.fY - after.fY);
 }
 
 static void RoundJoiner(SkPath* outer, SkPath* inner, const SkVector& beforeUnitNormal,
-                                               const SkPoint& pivot, const SkVector& afterUnitNormal,
-                                               SkScalar radius, SkScalar invMiterLimit, bool, bool)
+                        const SkPoint& pivot, const SkVector& afterUnitNormal,
+                        SkScalar radius, SkScalar invMiterLimit, bool, bool)
 {
-       SkScalar        dotProd = SkPoint::DotProduct(beforeUnitNormal, afterUnitNormal);
-       AngleType       angleType = Dot2AngleType(dotProd);
-
-       if (angleType == kNearlyLine_AngleType)
-               return;
-
-       SkVector                        before = beforeUnitNormal;
-       SkVector                        after = afterUnitNormal;
-       SkRotationDirection     dir = kCW_SkRotationDirection;
-
-       if (!is_clockwise(before, after))
-       {
-               SkTSwap<SkPath*>(outer, inner);
-               before.negate();
-               after.negate();
-               dir = kCCW_SkRotationDirection;
-       }
-
-       SkPoint         pts[kSkBuildQuadArcStorage];
-       SkMatrix        matrix;
-       matrix.setScale(radius, radius, 0, 0);
-       matrix.postTranslate(pivot.fX, pivot.fY);
-       int count = SkBuildQuadArc(before, after, dir, &matrix, pts);
-
-       if (count > 0)
-       {
-               for (int i = 1; i < count; i += 2)
-                       outer->quadTo(pts[i].fX, pts[i].fY, pts[i+1].fX, pts[i+1].fY);
-
-               after.scale(radius);
-               inner->lineTo(pivot.fX - after.fX, pivot.fY - after.fY);
-       }
+    SkScalar    dotProd = SkPoint::DotProduct(beforeUnitNormal, afterUnitNormal);
+    AngleType   angleType = Dot2AngleType(dotProd);
+
+    if (angleType == kNearlyLine_AngleType)
+        return;
+
+    SkVector            before = beforeUnitNormal;
+    SkVector            after = afterUnitNormal;
+    SkRotationDirection dir = kCW_SkRotationDirection;
+
+    if (!is_clockwise(before, after))
+    {
+        SkTSwap<SkPath*>(outer, inner);
+        before.negate();
+        after.negate();
+        dir = kCCW_SkRotationDirection;
+    }
+
+    SkPoint     pts[kSkBuildQuadArcStorage];
+    SkMatrix    matrix;
+    matrix.setScale(radius, radius);
+    matrix.postTranslate(pivot.fX, pivot.fY);
+    int count = SkBuildQuadArc(before, after, dir, &matrix, pts);
+
+    if (count > 0)
+    {
+        for (int i = 1; i < count; i += 2)
+            outer->quadTo(pts[i].fX, pts[i].fY, pts[i+1].fX, pts[i+1].fY);
+
+        after.scale(radius);
+        inner->lineTo(pivot.fX - after.fX, pivot.fY - after.fY);
+    }
 }
 
 static void MiterJoiner(SkPath* outer, SkPath* inner, const SkVector& beforeUnitNormal,
-                                               const SkPoint& pivot, const SkVector& afterUnitNormal,
-                                               SkScalar radius, SkScalar invMiterLimit,
-                                               bool prevIsLine, bool currIsLine)
+                        const SkPoint& pivot, const SkVector& afterUnitNormal,
+                        SkScalar radius, SkScalar invMiterLimit,
+                        bool prevIsLine, bool currIsLine)
 {
-       // negate the dot since we're using normals instead of tangents
-       SkScalar        dotProd = SkPoint::DotProduct(beforeUnitNormal, afterUnitNormal);
-       AngleType       angleType = Dot2AngleType(dotProd);
-       SkVector        before = beforeUnitNormal;
-       SkVector        after = afterUnitNormal;
-       SkVector        mid;
-       SkScalar        sinHalfAngle;
-       bool            ccw;
-
-       if (angleType == kNearlyLine_AngleType)
-               return;
-       if (angleType == kNearly180_AngleType)
-       {
-               currIsLine = false;
-               goto DO_BLUNT;
-       }
-
-       /*      midLength = radius / sinHalfAngle
-               if (midLength > miterLimit * radius) abort
-               if (radius / sinHalf > miterLimit * radius) abort
-               if (1 / sinHalf > miterLimit) abort
-               if (1 / miterLimit > sinHalf) abort
-               My dotProd is opposite sign, since it is built from normals and not tangents
-               hence 1 + dot instead of 1 - dot in the formula
-       */
-       sinHalfAngle = SkScalarSqrt(SkScalarHalf(SK_Scalar1 + dotProd));
-       if (sinHalfAngle < invMiterLimit)
-       {
-               currIsLine = false;
-               goto DO_BLUNT;
-       }
-
-       ccw = !is_clockwise(before, after);
-       if (ccw)
-       {
-               SkTSwap<SkPath*>(outer, inner);
-               before.negate();
-               after.negate();
-       }
-
-       // choose the most accurate way to form the initial mid-vector
-       if (angleType == kSharp_AngleType)
-       {
-               mid.set(after.fY - before.fY, before.fX - after.fX);
-               if (ccw)
-                       mid.negate();
-       }
-       else
-               mid.set(before.fX + after.fX, before.fY + after.fY);
-
-       mid.setLength(SkScalarDiv(radius, sinHalfAngle));
-       if (prevIsLine)
-               outer->setLastPt(pivot.fX + mid.fX, pivot.fY + mid.fY);
-       else
-               outer->lineTo(pivot.fX + mid.fX, pivot.fY + mid.fY);
+    // negate the dot since we're using normals instead of tangents
+    SkScalar    dotProd = SkPoint::DotProduct(beforeUnitNormal, afterUnitNormal);
+    AngleType   angleType = Dot2AngleType(dotProd);
+    SkVector    before = beforeUnitNormal;
+    SkVector    after = afterUnitNormal;
+    SkVector    mid;
+    SkScalar    sinHalfAngle;
+    bool        ccw;
+
+    if (angleType == kNearlyLine_AngleType)
+        return;
+    if (angleType == kNearly180_AngleType)
+    {
+        currIsLine = false;
+        goto DO_BLUNT;
+    }
+
+    /*  midLength = radius / sinHalfAngle
+        if (midLength > miterLimit * radius) abort
+        if (radius / sinHalf > miterLimit * radius) abort
+        if (1 / sinHalf > miterLimit) abort
+        if (1 / miterLimit > sinHalf) abort
+        My dotProd is opposite sign, since it is built from normals and not tangents
+        hence 1 + dot instead of 1 - dot in the formula
+    */
+    sinHalfAngle = SkScalarSqrt(SkScalarHalf(SK_Scalar1 + dotProd));
+    if (sinHalfAngle < invMiterLimit)
+    {
+        currIsLine = false;
+        goto DO_BLUNT;
+    }
+
+    ccw = !is_clockwise(before, after);
+    if (ccw)
+    {
+        SkTSwap<SkPath*>(outer, inner);
+        before.negate();
+        after.negate();
+    }
+
+    // choose the most accurate way to form the initial mid-vector
+    if (angleType == kSharp_AngleType)
+    {
+        mid.set(after.fY - before.fY, before.fX - after.fX);
+        if (ccw)
+            mid.negate();
+    }
+    else
+        mid.set(before.fX + after.fX, before.fY + after.fY);
+
+    mid.setLength(SkScalarDiv(radius, sinHalfAngle));
+    if (prevIsLine)
+        outer->setLastPt(pivot.fX + mid.fX, pivot.fY + mid.fY);
+    else
+        outer->lineTo(pivot.fX + mid.fX, pivot.fY + mid.fY);
 
 DO_BLUNT:
-       after.scale(radius);
-       if (!currIsLine)
-               outer->lineTo(pivot.fX + after.fX, pivot.fY + after.fY);
-       inner->lineTo(pivot.fX - after.fX, pivot.fY - after.fY);
+    after.scale(radius);
+    if (!currIsLine)
+        outer->lineTo(pivot.fX + after.fX, pivot.fY + after.fY);
+    inner->lineTo(pivot.fX - after.fX, pivot.fY - after.fY);
 }
 
 /////////////////////////////////////////////////////////////////////////////
 
 SkStrokerPriv::CapProc SkStrokerPriv::CapFactory(SkPaint::Cap cap)
 {
-       static const SkStrokerPriv::CapProc gCappers[] = {
-               ButtCapper, RoundCapper, SquareCapper
-       };
+    static const SkStrokerPriv::CapProc gCappers[] = {
+        ButtCapper, RoundCapper, SquareCapper
+    };
 
-       SkASSERT((unsigned)cap < SkPaint::kCapCount);
-       return gCappers[cap];
+    SkASSERT((unsigned)cap < SkPaint::kCapCount);
+    return gCappers[cap];
 }
 
 SkStrokerPriv::JoinProc SkStrokerPriv::JoinFactory(SkPaint::Join join)
 {
-       static const SkStrokerPriv::JoinProc gJoiners[] = {
-               MiterJoiner, RoundJoiner, BluntJoiner
-       };
+    static const SkStrokerPriv::JoinProc gJoiners[] = {
+        MiterJoiner, RoundJoiner, BluntJoiner
+    };
 
-       SkASSERT((unsigned)join < SkPaint::kJoinCount);
-       return gJoiners[join];
+    SkASSERT((unsigned)join < SkPaint::kJoinCount);
+    return gJoiners[join];
 }
 
 
index 60a2a1f..1d1eb89 100644 (file)
@@ -1,32 +1,49 @@
+/* libs/graphics/sgl/SkStrokerPriv.h
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #ifndef SkStrokerPriv_DEFINED
 #define SkStrokerPriv_DEFINED
 
 #include "SkStroke.h"
 
-#define CWX(x, y)      (-y)
-#define CWY(x, y)      (x)
-#define CCWX(x, y)     (y)
-#define CCWY(x, y)     (-x)
+#define CWX(x, y)   (-y)
+#define CWY(x, y)   (x)
+#define CCWX(x, y)  (y)
+#define CCWY(x, y)  (-x)
 
-#define CUBIC_ARC_FACTOR       ((SK_ScalarSqrt2 - SK_Scalar1) * 4 / 3)
+#define CUBIC_ARC_FACTOR    ((SK_ScalarSqrt2 - SK_Scalar1) * 4 / 3)
 
 class SkStrokerPriv {
 public:
-       typedef void (*CapProc)(SkPath* path,
-                                                       const SkPoint& pivot,
-                                                       const SkVector& normal,
-                                                       const SkPoint& stop,
-                                                       SkPath* otherPath);
-
-       typedef void (*JoinProc)(SkPath* outer, SkPath* inner,
-                                                        const SkVector& beforeUnitNormal,
-                                                        const SkPoint& pivot,
-                                                        const SkVector& afterUnitNormal,
-                                                        SkScalar radius, SkScalar invMiterLimit,
-                                                        bool prevIsLine, bool currIsLine);
-
-       static CapProc  CapFactory(SkPaint::Cap);
-       static JoinProc JoinFactory(SkPaint::Join);
+    typedef void (*CapProc)(SkPath* path,
+                            const SkPoint& pivot,
+                            const SkVector& normal,
+                            const SkPoint& stop,
+                            SkPath* otherPath);
+
+    typedef void (*JoinProc)(SkPath* outer, SkPath* inner,
+                             const SkVector& beforeUnitNormal,
+                             const SkPoint& pivot,
+                             const SkVector& afterUnitNormal,
+                             SkScalar radius, SkScalar invMiterLimit,
+                             bool prevIsLine, bool currIsLine);
+
+    static CapProc  CapFactory(SkPaint::Cap);
+    static JoinProc JoinFactory(SkPaint::Join);
 };
 
 #endif
index 41118bb..eda6f61 100644 (file)
+/* libs/graphics/sgl/SkTSearch.cpp
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #include "SkTSearch.h"
 #include <ctype.h>
 
 static inline const char* index_into_base(const char*const* base, int index, size_t elemSize)
 {
-       return *(const char*const*)((const char*)base + index * elemSize);
+    return *(const char*const*)((const char*)base + index * elemSize);
 }
 
 int SkStrSearch(const char*const* base, int count, const char target[], size_t target_len, size_t elemSize)
 {
-       SkASSERT(base != nil);
-       SkASSERT(count >= 0);
-
-       if (count <= 0)
-               return ~0;
-
-       int     lo = 0;
-       int     hi = count - 1;
-
-       while (lo < hi)
-       {
-               int mid = (hi + lo) >> 1;
-               const char* elem = index_into_base(base, mid, elemSize);
-
-               int cmp = strncmp(elem, target, target_len);
-               if (cmp < 0)
-                       lo = mid + 1;
-               else if (cmp > 0 || strlen(elem) > target_len)
-                       hi = mid;
-               else
-                       return mid;
-       }
-
-       const char* elem = index_into_base(base, hi, elemSize);
-       int cmp = strncmp(elem, target, target_len);
-       if (cmp || strlen(elem) > target_len)
-       {
-               if (cmp < 0)
-                       hi += 1;
-               hi = ~hi;
-       }
-       return hi;
+    SkASSERT(base != nil);
+    SkASSERT(count >= 0);
+
+    if (count <= 0)
+        return ~0;
+
+    int lo = 0;
+    int hi = count - 1;
+
+    while (lo < hi)
+    {
+        int mid = (hi + lo) >> 1;
+        const char* elem = index_into_base(base, mid, elemSize);
+
+        int cmp = strncmp(elem, target, target_len);
+        if (cmp < 0)
+            lo = mid + 1;
+        else if (cmp > 0 || strlen(elem) > target_len)
+            hi = mid;
+        else
+            return mid;
+    }
+
+    const char* elem = index_into_base(base, hi, elemSize);
+    int cmp = strncmp(elem, target, target_len);
+    if (cmp || strlen(elem) > target_len)
+    {
+        if (cmp < 0)
+            hi += 1;
+        hi = ~hi;
+    }
+    return hi;
 }
 
 int SkStrSearch(const char*const* base, int count, const char target[], size_t elemSize) {
-       return SkStrSearch(base, count, target, strlen(target), elemSize);
+    return SkStrSearch(base, count, target, strlen(target), elemSize);
 }
 
-#define kLCBufferSize  32
+#define kLCBufferSize   32
 
 int SkStrLCSearch(const char*const* base, int count, const char target[], size_t len, size_t elemSize)
 {
-       SkASSERT(target);
+    SkASSERT(target);
 
-       char            lcBuffer[kLCBufferSize + 1];
-       char*           lc;
+    char        lcBuffer[kLCBufferSize + 1];
+    char*       lc;
 
-       if (len <= kLCBufferSize)
-               lc = lcBuffer;
-       else
-               lc = (char*)sk_malloc_throw(len + 1);
+    if (len <= kLCBufferSize)
+        lc = lcBuffer;
+    else
+        lc = (char*)sk_malloc_throw(len + 1);
 
-       for (int i = (int)(len - 1); i >= 0; --i)
-       {
-               SkASSERT((target[i] & 0x80) == 0);      // only works for ascii
-               lc[i] = (char)tolower(target[i]);
-       }
-       lc[len] = 0;
+    for (int i = (int)(len - 1); i >= 0; --i)
+    {
+        SkASSERT((target[i] & 0x80) == 0);  // only works for ascii
+        lc[i] = (char)tolower(target[i]);
+    }
+    lc[len] = 0;
 
-       int index = SkStrSearch(base, count, lc, len, elemSize);
+    int index = SkStrSearch(base, count, lc, len, elemSize);
 
-       if (lc != lcBuffer)
-               sk_free(lc);
-       return index;
+    if (lc != lcBuffer)
+        sk_free(lc);
+    return index;
 }
 
 int SkStrLCSearch(const char*const* base, int count, const char target[], size_t elemSize) {
-       return SkStrLCSearch(base, count, target, strlen(target), elemSize);
+    return SkStrLCSearch(base, count, target, strlen(target), elemSize);
 }
 
 //////////////////////////////////////////////////////////////////////////////
 
-#define SK_QSortTempSize       16
+#define SK_QSortTempSize    16
 
 static inline void sk_qsort_swap(char a[], char b[], size_t elemSize)
 {
-       char    tmp[SK_QSortTempSize];
-
-       while (elemSize > 0)
-       {
-               size_t size = elemSize;
-               if (size > SK_QSortTempSize)
-                       size = SK_QSortTempSize;
-               elemSize -= size;
-
-               memcpy(tmp, a, size);
-               memcpy(a, b, size);
-               memcpy(b, tmp, size);
-               a += size;
-               b += size;
-       }
+    char    tmp[SK_QSortTempSize];
+
+    while (elemSize > 0)
+    {
+        size_t size = elemSize;
+        if (size > SK_QSortTempSize)
+            size = SK_QSortTempSize;
+        elemSize -= size;
+
+        memcpy(tmp, a, size);
+        memcpy(a, b, size);
+        memcpy(b, tmp, size);
+        a += size;
+        b += size;
+    }
 }
 
 static void SkQSort_Partition(char* first, char* last, size_t elemSize, SkQSortCompareProc compare)
 {
-       char*   left = first;
-       char*   rite = last;
-       char*   pivot = left;
-
-       while (left <= rite)
-       {
-               while (left < last && compare(left, pivot) < 0)
-                       left += elemSize;
-               while (first < rite && compare(rite, pivot) > 0)
-                       rite -= elemSize;
-               if (left <= rite)
-               {
-                       if (left < rite)
-                       {
-                               SkASSERT(compare(left, rite) >= 0);
-                               sk_qsort_swap(left, rite, elemSize);
-                       }
-                       left += elemSize;
-                       rite -= elemSize;
-               }
-       }
-       if (first < rite)
-               SkQSort_Partition(first, rite, elemSize, compare);
-       if (left < last)
-               SkQSort_Partition(left, last, elemSize, compare);
+    char*   left = first;
+    char*   rite = last;
+    char*   pivot = left;
+
+    while (left <= rite)
+    {
+        while (left < last && compare(left, pivot) < 0)
+            left += elemSize;
+        while (first < rite && compare(rite, pivot) > 0)
+            rite -= elemSize;
+        if (left <= rite)
+        {
+            if (left < rite)
+            {
+                SkASSERT(compare(left, rite) >= 0);
+                sk_qsort_swap(left, rite, elemSize);
+            }
+            left += elemSize;
+            rite -= elemSize;
+        }
+    }
+    if (first < rite)
+        SkQSort_Partition(first, rite, elemSize, compare);
+    if (left < last)
+        SkQSort_Partition(left, last, elemSize, compare);
 }
 
 void SkQSort(void* base, size_t count, size_t elemSize, SkQSortCompareProc compare)
 {
-       SkASSERT(base);
-       SkASSERT(compare);
-       SkASSERT(elemSize > 0);
+    SkASSERT(base);
+    SkASSERT(compare);
+    SkASSERT(elemSize > 0);
 
-       if (count <= 1)
-               return;
+    if (count <= 1)
+        return;
 
-       SkQSort_Partition((char*)base, (char*)base + (count - 1) * elemSize, elemSize, compare);
+    SkQSort_Partition((char*)base, (char*)base + (count - 1) * elemSize, elemSize, compare);
 }
 
 #ifdef SK_DEBUG
@@ -148,28 +165,28 @@ void SkQSort(void* base, size_t count, size_t elemSize, SkQSortCompareProc compa
 
 #ifdef SK_SUPPORT_UNITTEST
 extern "C" {
-       int compare_int(const void* a, const void* b)
-       {
-               return *(const int*)a - *(const int*)b;
-       }
+    int compare_int(const void* a, const void* b)
+    {
+        return *(const int*)a - *(const int*)b;
+    }
 }
 #endif
 
 void SkQSort_UnitTest()
 {
 #ifdef SK_SUPPORT_UNITTEST
-       int                     array[100];
-       SkRandom        rand;
-
-       for (int i = 0; i < 1000; i++)
-       {
-               int     j, count = rand.nextRangeU(1, SK_ARRAY_COUNT(array));
-               for (j = 0; j < count; j++)
-                       array[j] = rand.nextS() & 0xFF;
-               SkQSort(array, count, sizeof(int), compare_int);
-               for (j = 1; j < count; j++)
-                       SkASSERT(array[j-1] <= array[j]);
-       }
+    int         array[100];
+    SkRandom    rand;
+
+    for (int i = 0; i < 1000; i++)
+    {
+        int j, count = rand.nextRangeU(1, SK_ARRAY_COUNT(array));
+        for (j = 0; j < count; j++)
+            array[j] = rand.nextS() & 0xFF;
+        SkQSort(array, count, sizeof(int), compare_int);
+        for (j = 1; j < count; j++)
+            SkASSERT(array[j-1] <= array[j]);
+    }
 #endif
 }
 
index bdfbf6d..660b689 100644 (file)
@@ -1,3 +1,20 @@
+/* libs/graphics/sgl/SkTSort.h
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #ifndef SkTSort_DEFINED
 #define SkTSort_DEFINED
 
 template <typename T>
 void SkTHeapSort_SiftDown(T array[], int root, int bottom)
 {
-       int     root2 = root << 1;
-
-       while (root2 <= bottom)
-       {
-               int     maxChild;
-
-               if (root2 == bottom)
-                       maxChild = root2;
-               else if (array[root2] > array[root2 + 1])
-                       maxChild = root2;
-               else
-                       maxChild = root2 + 1;
-
-               if (array[root] < array[maxChild])
-               {
-                       SkTSwap<T>(array[root], array[maxChild]);
-                       root = maxChild;
-                       root2 = root << 1;
-               }
-               else
-                       break;
-       }
+    int root2 = root << 1;
+
+    while (root2 <= bottom)
+    {
+        int maxChild;
+
+        if (root2 == bottom)
+            maxChild = root2;
+        else if (array[root2] > array[root2 + 1])
+            maxChild = root2;
+        else
+            maxChild = root2 + 1;
+
+        if (array[root] < array[maxChild])
+        {
+            SkTSwap<T>(array[root], array[maxChild]);
+            root = maxChild;
+            root2 = root << 1;
+        }
+        else
+            break;
+    }
 }
 
 template <typename T>
 void SkTHeapSort(T array[], int count)
 {
-       int i;
+    int i;
 
-       for (i = count/2 - 1; i >= 0; --i)
-               SkTHeapSort_SiftDown<T>(array, i, count);
+    for (i = count/2 - 1; i >= 0; --i)
+        SkTHeapSort_SiftDown<T>(array, i, count);
 
-       for (i = count - 2; i >= 0; --i)
-       {
-               SkTSwap<T>(array[0], array[i + 1]);
-               SkTHeapSort_SiftDown<T>(array, 0, i);
-       }
+    for (i = count - 2; i >= 0; --i)
+    {
+        SkTSwap<T>(array[0], array[i + 1]);
+        SkTHeapSort_SiftDown<T>(array, 0, i);
+    }
 }
 
 #endif
index 7c2e915..f07c329 100644 (file)
@@ -1,3 +1,20 @@
+/* libs/graphics/sgl/SkTemplatesPriv.h
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #ifndef SkTemplatesPriv_DEFINED
 #define SkTemplatesPriv_DEFINED
 
 ////////////////////////////////////////////////////////////////////////////////
 
 #ifdef SK_BUILD_FOR_WIN32
-       #define SK_PLACEMENT_NEW(result, classname, storage, storageSize)       \
-               result = SkNEW(classname)
+    #define SK_PLACEMENT_NEW(result, classname, storage, storageSize)   \
+        result = SkNEW(classname)
 
-       #define SK_PLACEMENT_NEW_ARGS(result, classname, storage, storageSize, args)    \
-               result = SkNEW_ARGS(classname, args)
+    #define SK_PLACEMENT_NEW_ARGS(result, classname, storage, storageSize, args)    \
+        result = SkNEW_ARGS(classname, args)
 #else
-       #include <new>
-       #define SK_PLACEMENT_NEW(result, classname, storage, storagesize)               \
-       do {                                                                                                                                    \
-               if (storagesize)                                                                                                        \
-               {                                                                                                                                       \
-                       SkASSERT(storageSize >= sizeof(classname));                                             \
-                       result = new(storage) classname;                                                                \
-               }                                                                                                                                       \
-               else                                                                                                                            \
-                       result = SkNEW(classname);                                                                              \
-       } while (0)
+    #include <new>
+    #define SK_PLACEMENT_NEW(result, classname, storage, storagesize)       \
+    do {                                                                    \
+        if (storagesize)                                                    \
+        {                                                                   \
+            SkASSERT(storageSize >= sizeof(classname));                     \
+            result = new(storage) classname;                                \
+        }                                                                   \
+        else                                                                \
+            result = SkNEW(classname);                                      \
+    } while (0)
 
-       #define SK_PLACEMENT_NEW_ARGS(result, classname, storage, storagesize, args)            \
-       do {                                                                                                                                                            \
-               if (storagesize)                                                                                                                                \
-               {                                                                                                                                                               \
-                       SkASSERT(storageSize >= sizeof(classname));                                                                     \
-                       result = new(storage) classname args;                                                                           \
-               }                                                                                                                                                               \
-               else                                                                                                                                                    \
-                       result = SkNEW_ARGS(classname, args);                                                                           \
-       } while (0)
+    #define SK_PLACEMENT_NEW_ARGS(result, classname, storage, storagesize, args)        \
+    do {                                                                                \
+        if (storagesize)                                                                \
+        {                                                                               \
+            SkASSERT(storageSize >= sizeof(classname));                                 \
+            result = new(storage) classname args;                                       \
+        }                                                                               \
+        else                                                                            \
+            result = SkNEW_ARGS(classname, args);                                       \
+    } while (0)
 #endif
 
 ////////////////////////////////////////////////////////////////////////////////
 
 template <class T> class SkAutoTPlacementDelete {
 public:
-       SkAutoTPlacementDelete(T* obj, void* storage) : fObj(obj), fStorage(storage)
-       {
-       }
-       ~SkAutoTPlacementDelete()
-       {
-               if (fObj)
-               {
-                       if (fObj == fStorage)
-                               fObj->~T();
-                       else
-                               delete fObj;
-               }
-       }
-       T* detach()
-       {
-               T*      obj = fObj;
-               fObj = nil;
-               return obj;
-       }
+    SkAutoTPlacementDelete(T* obj, void* storage) : fObj(obj), fStorage(storage)
+    {
+    }
+    ~SkAutoTPlacementDelete()
+    {
+        if (fObj)
+        {
+            if (fObj == fStorage)
+                fObj->~T();
+            else
+                delete fObj;
+        }
+    }
+    T* detach()
+    {
+        T*  obj = fObj;
+        fObj = nil;
+        return obj;
+    }
 private:
-       T*              fObj;
-       void*   fStorage;
+    T*      fObj;
+    void*   fStorage;
 };
 
 #endif
diff --git a/libs/graphics/sgl/SkTextLayout.cpp b/libs/graphics/sgl/SkTextLayout.cpp
deleted file mode 100644 (file)
index 1ff4264..0000000
+++ /dev/null
@@ -1,66 +0,0 @@
-#include "SkTextLayout.h"
-#include "SkPaint.h"
-
-int SkTextLayout::layout(const SkPaint& paint,
-                          const char* text, size_t byteLength, SkUnicodeWalkerProc proc,
-                          Rec rec[])
-{
-    const char* stop = text + byteLength;
-    Rec*        recStart = rec;
-    
-    while (text < stop)
-    {
-        rec->fCharCode = proc(&text);
-        rec += 1;
-        // set private fields of Rec (when we use them)
-    }
-    
-    int count = rec - recStart;
-    if (count > 0)
-        this->onLayout(paint, recStart, count);
-    return count;
-}
-
-/////////////////////////////////////////////////////////////////////////////////////////////
-
-class SkTrackingTextLayout : public SkTextLayout {
-public:
-    SkTrackingTextLayout(SkScalar charExtra, SkScalar spaceExtra)
-        : fCharExtra(charExtra), fSpaceExtra(spaceExtra) {}
-
-protected:
-    // override
-    virtual void onLayout(const SkPaint& paint, Rec rec[], int count)
-    {
-        SkScalar ce = fCharExtra;
-        SkScalar se = fSpaceExtra;
-
-        if (0 == se)    // special case no space-extra (so we don't have to read charCode()
-        {
-            for (int i = 0; i < count; i++)
-                rec[i].fDeltaAdvance = ce;
-        }
-        else
-        {
-            for (int i = 0; i < count; i++)
-            {
-                SkScalar delta = ce;
-                if (32 == rec[i].charCode())    // do I need a fancier test?
-                    delta += se;
-                rec[i].fDeltaAdvance = delta;
-            }
-        }
-    }
-
-private:
-    SkScalar    fCharExtra, fSpaceExtra;
-};
-
-/////////////////////////////////////////////////////////////////////////////////////////////
-
-SkTextLayout* SkTextLayout::CreateTrackingLayout(SkScalar charExtra, SkScalar spaceExtra)
-{
-    return SkNEW_ARGS(SkTrackingTextLayout, (charExtra, spaceExtra));
-}
-
-
index 9cb7c65..0e13c71 100644 (file)
@@ -1,29 +1,46 @@
+/* libs/graphics/sgl/SkUtils.cpp
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #include "SkUtils.h"
 
 #if 0
-#define assign_16_longs(dst, value)                            \
-       do {                                                                            \
-               (dst)[0] = value;       (dst)[1] = value;       \
-               (dst)[2] = value;       (dst)[3] = value;       \
-               (dst)[4] = value;       (dst)[5] = value;       \
-               (dst)[6] = value;       (dst)[7] = value;       \
-               (dst)[8] = value;       (dst)[9] = value;       \
-               (dst)[10] = value;      (dst)[11] = value;      \
-               (dst)[12] = value;      (dst)[13] = value;      \
-               (dst)[14] = value;      (dst)[15] = value;      \
-       } while (0)
+#define assign_16_longs(dst, value)             \
+    do {                                        \
+        (dst)[0] = value;   (dst)[1] = value;   \
+        (dst)[2] = value;   (dst)[3] = value;   \
+        (dst)[4] = value;   (dst)[5] = value;   \
+        (dst)[6] = value;   (dst)[7] = value;   \
+        (dst)[8] = value;   (dst)[9] = value;   \
+        (dst)[10] = value;  (dst)[11] = value;  \
+        (dst)[12] = value;  (dst)[13] = value;  \
+        (dst)[14] = value;  (dst)[15] = value;  \
+    } while (0)
 #else
-#define assign_16_longs(dst, value)                            \
-       do {                                                                            \
-               *(dst)++ = value;       *(dst)++ = value;       \
-               *(dst)++ = value;       *(dst)++ = value;       \
-               *(dst)++ = value;       *(dst)++ = value;       \
-               *(dst)++ = value;       *(dst)++ = value;       \
-               *(dst)++ = value;       *(dst)++ = value;       \
-               *(dst)++ = value;       *(dst)++ = value;       \
-               *(dst)++ = value;       *(dst)++ = value;       \
-               *(dst)++ = value;       *(dst)++ = value;       \
-       } while (0)
+#define assign_16_longs(dst, value)             \
+    do {                                        \
+        *(dst)++ = value;   *(dst)++ = value;   \
+        *(dst)++ = value;   *(dst)++ = value;   \
+        *(dst)++ = value;   *(dst)++ = value;   \
+        *(dst)++ = value;   *(dst)++ = value;   \
+        *(dst)++ = value;   *(dst)++ = value;   \
+        *(dst)++ = value;   *(dst)++ = value;   \
+        *(dst)++ = value;   *(dst)++ = value;   \
+        *(dst)++ = value;   *(dst)++ = value;   \
+    } while (0)
 #endif
 
 ///////////////////////////////////////////////////////////////////////////
 #ifndef SK_MEMSET16_REDIRECT
 void sk_memset16(uint16_t dst[], U16CPU value, int count)
 {
-       SkASSERT(dst != NULL && count >= 0);
-
-       if (count <= 0)
-               return;
-
-       // not sure if this helps to short-circuit on small values of count
-       if (count < 8)
-       {
-               do {
-                       *dst++ = (uint16_t)value;
-               } while (--count != 0);
-               return;
-       }
-
-       // ensure we're on a long boundary
-       if ((size_t)dst & 2)
-       {
-               *dst++ = (uint16_t)value;
-               count -= 1;
-       }
-
-       uint32_t value32 = ((uint32_t)value << 16) | value;
-
-       // handle the bulk with our unrolled macro
-       {
-               int sixteenlongs = count >> 5;
-               if (sixteenlongs)
-               {
-                       U32* dst32 = (U32*)dst;
-                       do {
-                               assign_16_longs(dst32, value32);
-                       } while (--sixteenlongs != 0);
-                       dst = (uint16_t*)dst32;
-                       count &= 31;
-               }
-       }
-
-       // handle (most) of the rest
-       {
-               int longs = count >> 1;
-               if (longs)
-               {
-                       do {
-                               *(uint32_t*)dst = value32;
-                               dst += 2;
-                       } while (--longs != 0);
-               }
-       }
-
-       // cleanup a possible trailing short
-       if (count & 1)
-               *dst = (uint16_t)value;
+    SkASSERT(dst != NULL && count >= 0);
+
+    if (count <= 0)
+        return;
+
+    // not sure if this helps to short-circuit on small values of count
+    if (count < 8)
+    {
+        do {
+            *dst++ = (uint16_t)value;
+        } while (--count != 0);
+        return;
+    }
+
+    // ensure we're on a long boundary
+    if ((size_t)dst & 2)
+    {
+        *dst++ = (uint16_t)value;
+        count -= 1;
+    }
+
+    uint32_t value32 = ((uint32_t)value << 16) | value;
+
+    // handle the bulk with our unrolled macro
+    {
+        int sixteenlongs = count >> 5;
+        if (sixteenlongs)
+        {
+            U32* dst32 = (U32*)dst;
+            do {
+                assign_16_longs(dst32, value32);
+            } while (--sixteenlongs != 0);
+            dst = (uint16_t*)dst32;
+            count &= 31;
+        }
+    }
+
+    // handle (most) of the rest
+    {
+        int longs = count >> 1;
+        if (longs)
+        {
+            do {
+                *(uint32_t*)dst = value32;
+                dst += 2;
+            } while (--longs != 0);
+        }
+    }
+
+    // cleanup a possible trailing short
+    if (count & 1)
+        *dst = (uint16_t)value;
 }
 #endif
 
 #ifndef SK_MEMSET32_REDIRECT
 void sk_memset32(uint32_t dst[], uint32_t value, int count)
 {
-       SkASSERT(dst != NULL && count >= 0);
-
-       {
-               int sixteenlongs = count >> 4;
-               if (sixteenlongs)
-               {
-                       do {
-                               assign_16_longs(dst, value);
-                       } while (--sixteenlongs != 0);
-                       count &= 15;
-               }
-       }
-
-       if (count)
-       {
-               do {
-                       *dst++ = value;
-               } while (--count != 0);
-       }
+    SkASSERT(dst != NULL && count >= 0);
+
+    {
+        int sixteenlongs = count >> 4;
+        if (sixteenlongs)
+        {
+            do {
+                assign_16_longs(dst, value);
+            } while (--sixteenlongs != 0);
+            count &= 15;
+        }
+    }
+
+    if (count)
+    {
+        do {
+            *dst++ = value;
+        } while (--count != 0);
+    }
 }
 #endif
 
 //////////////////////////////////////////////////////////////////////////////
 
-/*     0xxxxxxx        1 total
-       10xxxxxx        // never a leading byte
-       110xxxxx        2 total
-       1110xxxx        3 total
-       11110xxx        4 total
+/*  0xxxxxxx    1 total
+    10xxxxxx    // never a leading byte
+    110xxxxx    2 total
+    1110xxxx    3 total
+    11110xxx    4 total
 
-       11 10 01 01 xx xx xx xx 0...
-       0xE5XX0000
-       0xE5 << 24
+    11 10 01 01 xx xx xx xx 0...
+    0xE5XX0000
+    0xE5 << 24
 */
 
 #ifdef SK_DEBUG
-       static void assert_utf8_leadingbyte(unsigned c)
-       {
-               SkASSERT(c <= 0xF7);    // otherwise leading byte is too big (more than 4 bytes)
-               SkASSERT((c & 0xC0) != 0x80);   // can't begin with a middle char
-       }
-
-       int SkUTF8_LeadByteToCount(unsigned c)
-       {
-               assert_utf8_leadingbyte(c);
-               return (((0xE5 << 24) >> (c >> 4 << 1)) & 3) + 1;
-       }
+    static void assert_utf8_leadingbyte(unsigned c)
+    {
+        SkASSERT(c <= 0xF7);    // otherwise leading byte is too big (more than 4 bytes)
+        SkASSERT((c & 0xC0) != 0x80);   // can't begin with a middle char
+    }
+
+    int SkUTF8_LeadByteToCount(unsigned c)
+    {
+        assert_utf8_leadingbyte(c);
+        return (((0xE5 << 24) >> (c >> 4 << 1)) & 3) + 1;
+    }
 #else
-       #define assert_utf8_leadingbyte(c)
+    #define assert_utf8_leadingbyte(c)
 #endif
 
 int SkUTF8_CountUnichars(const char utf8[])
 {
-       SkASSERT(utf8);
+    SkASSERT(utf8);
 
-       int count = 0;
+    int count = 0;
 
-       for (;;)
-       {
-               int c = *(const U8*)utf8;
-               if (c == 0)
-                       break;
+    for (;;)
+    {
+        int c = *(const U8*)utf8;
+        if (c == 0)
+            break;
 
-               utf8 += SkUTF8_LeadByteToCount(c);
-               count += 1;
-       }
-       return count;
+        utf8 += SkUTF8_LeadByteToCount(c);
+        count += 1;
+    }
+    return count;
 }
 
 int SkUTF8_CountUnichars(const char utf8[], size_t byteLength)
 {
-       SkASSERT(NULL != utf8 || 0 == byteLength);
+    SkASSERT(NULL != utf8 || 0 == byteLength);
 
-       int         count = 0;
+    int         count = 0;
     const char* stop = utf8 + byteLength;
 
-       while (utf8 < stop)
-       {
-               utf8 += SkUTF8_LeadByteToCount(*(const uint8_t*)utf8);
-               count += 1;
-       }
-       return count;
+    while (utf8 < stop)
+    {
+        utf8 += SkUTF8_LeadByteToCount(*(const uint8_t*)utf8);
+        count += 1;
+    }
+    return count;
 }
 
 SkUnichar SkUTF8_ToUnichar(const char utf8[])
 {
     SkASSERT(NULL != utf8);
 
-       const U8*       p = (const U8*)utf8;
-       int                     c = *p;
-       int                     hic = c << 24;
-
-       assert_utf8_leadingbyte(c);
-
-       if (hic < 0)
-       {
-               U32 mask = (U32)~0x3F;
-               hic <<= 1;
-               do {
-                       c = (c << 6) | (*++p & 0x3F);
-                       mask <<= 5;
-               } while ((hic <<= 1) < 0);
-               c &= ~mask;
-       }
-       return c;
+    const U8*   p = (const U8*)utf8;
+    int         c = *p;
+    int         hic = c << 24;
+
+    assert_utf8_leadingbyte(c);
+
+    if (hic < 0)
+    {
+        U32 mask = (U32)~0x3F;
+        hic <<= 1;
+        do {
+            c = (c << 6) | (*++p & 0x3F);
+            mask <<= 5;
+        } while ((hic <<= 1) < 0);
+        c &= ~mask;
+    }
+    return c;
 }
 
 SkUnichar SkUTF8_NextUnichar(const char** ptr)
 {
     SkASSERT(NULL != ptr && NULL != *ptr);
 
-       const U8*       p = (const U8*)*ptr;
-       int                     c = *p;
-       int                     hic = c << 24;
-       
-       assert_utf8_leadingbyte(c);
-
-       if (hic < 0)
-       {
-               U32 mask = (U32)~0x3F;
-               hic <<= 1;
-               do {
-                       c = (c << 6) | (*++p & 0x3F);
-                       mask <<= 5;
-               } while ((hic <<= 1) < 0);
-               c &= ~mask;
-       }
-       *ptr = (char*)p + 1;
-       return c;
+    const U8*   p = (const U8*)*ptr;
+    int         c = *p;
+    int         hic = c << 24;
+    
+    assert_utf8_leadingbyte(c);
+
+    if (hic < 0)
+    {
+        U32 mask = (U32)~0x3F;
+        hic <<= 1;
+        do {
+            c = (c << 6) | (*++p & 0x3F);
+            mask <<= 5;
+        } while ((hic <<= 1) < 0);
+        c &= ~mask;
+    }
+    *ptr = (char*)p + 1;
+    return c;
 }
 
 size_t SkUTF8_FromUnichar(SkUnichar uni, char utf8[])
 {
-       if ((uint32_t)uni > 0x10FFFF)
-       {
-               SkASSERT(!"bad unichar");
-               return 0;
-       }
-
-       if (uni <= 127)
-       {
-               if (utf8)
-                       *utf8 = (char)uni;
-               return 1;
-       }
-
-       char    tmp[4];
-       char*   p = tmp;
-       size_t  count = 1;
-
-       SkDEBUGCODE(SkUnichar orig = uni;)
-
-       while (uni > 0x3F)
-       {
-               *p++ = (char)(0x80 | (uni & 0x3F));
-               uni >>= 6;
-               count += 1;
-       }
-
-       if (utf8)
-       {
-               p = tmp;
-               utf8 += count;
-               while (p < tmp + count - 1)
-                       *--utf8 = *p++;
-               *--utf8 = (char)(~(0xFF >> count) | uni);
-       }
-
-       SkASSERT(utf8 == NULL || orig == SkUTF8_ToUnichar(utf8));
-       return count;
+    if ((uint32_t)uni > 0x10FFFF)
+    {
+        SkASSERT(!"bad unichar");
+        return 0;
+    }
+
+    if (uni <= 127)
+    {
+        if (utf8)
+            *utf8 = (char)uni;
+        return 1;
+    }
+
+    char    tmp[4];
+    char*   p = tmp;
+    size_t  count = 1;
+
+    SkDEBUGCODE(SkUnichar orig = uni;)
+
+    while (uni > 0x3F)
+    {
+        *p++ = (char)(0x80 | (uni & 0x3F));
+        uni >>= 6;
+        count += 1;
+    }
+
+    if (utf8)
+    {
+        p = tmp;
+        utf8 += count;
+        while (p < tmp + count - 1)
+            *--utf8 = *p++;
+        *--utf8 = (char)(~(0xFF >> count) | uni);
+    }
+
+    SkASSERT(utf8 == NULL || orig == SkUTF8_ToUnichar(utf8));
+    return count;
 }
 
 ////////////////////////////////////////////////////////////////////////////////////
@@ -386,54 +403,54 @@ size_t SkUTF16_ToUTF8(const uint16_t utf16[], int numberOf16BitValues, char utf8
 #include "SkTSearch.h"
 #include "SkTSort.h"
 
-#define kSEARCH_COUNT  91
+#define kSEARCH_COUNT   91
 
 #ifdef SK_SUPPORT_UNITTEST
 static void test_search()
 {
-       int                     i, array[kSEARCH_COUNT];
-       SkRandom        rand;
-
-       for (i = 0; i < kSEARCH_COUNT; i++)
-               array[i] = rand.nextS();
-
-       SkTHeapSort<int>(array, kSEARCH_COUNT);
-       // make sure we got sorted properly
-       for (i = 1; i < kSEARCH_COUNT; i++)
-               SkASSERT(array[i-1] <= array[i]);
-
-       // make sure we can find all of our values
-       for (i = 0; i < kSEARCH_COUNT; i++)
-       {
-               int index = SkTSearch<int>(array, kSEARCH_COUNT, array[i], sizeof(int));
-               SkASSERT(index == i);
-       }
-
-       // make sure that random values are either found, or the correct
-       // insertion index is returned
-       for (i = 0; i < 10000; i++)
-       {
-               int value = rand.nextS();
-               int index = SkTSearch<int>(array, kSEARCH_COUNT, value, sizeof(int));
-
-               if (index >= 0)
-                       SkASSERT(index < kSEARCH_COUNT && array[index] == value);
-               else
-               {
-                       index = ~index;
-                       SkASSERT(index <= kSEARCH_COUNT);
-                       if (index < kSEARCH_COUNT)
-                       {
-                               SkASSERT(value < array[index]);
-                               if (index > 0)
-                                       SkASSERT(value > array[index - 1]);
-                       }
-                       else    // we should append the new value
-                       {
-                               SkASSERT(value > array[kSEARCH_COUNT - 1]);
-                       }
-               }
-       }
+    int         i, array[kSEARCH_COUNT];
+    SkRandom    rand;
+
+    for (i = 0; i < kSEARCH_COUNT; i++)
+        array[i] = rand.nextS();
+
+    SkTHeapSort<int>(array, kSEARCH_COUNT);
+    // make sure we got sorted properly
+    for (i = 1; i < kSEARCH_COUNT; i++)
+        SkASSERT(array[i-1] <= array[i]);
+
+    // make sure we can find all of our values
+    for (i = 0; i < kSEARCH_COUNT; i++)
+    {
+        int index = SkTSearch<int>(array, kSEARCH_COUNT, array[i], sizeof(int));
+        SkASSERT(index == i);
+    }
+
+    // make sure that random values are either found, or the correct
+    // insertion index is returned
+    for (i = 0; i < 10000; i++)
+    {
+        int value = rand.nextS();
+        int index = SkTSearch<int>(array, kSEARCH_COUNT, value, sizeof(int));
+
+        if (index >= 0)
+            SkASSERT(index < kSEARCH_COUNT && array[index] == value);
+        else
+        {
+            index = ~index;
+            SkASSERT(index <= kSEARCH_COUNT);
+            if (index < kSEARCH_COUNT)
+            {
+                SkASSERT(value < array[index]);
+                if (index > 0)
+                    SkASSERT(value > array[index - 1]);
+            }
+            else    // we should append the new value
+            {
+                SkASSERT(value > array[kSEARCH_COUNT - 1]);
+            }
+        }
+    }
 }
 
 static void test_utf16()
@@ -462,32 +479,32 @@ static void test_utf16()
 void SkUtils::UnitTest()
 {
 #ifdef SK_SUPPORT_UNITTEST
-       static const struct {
-               const char*     fUtf8;
-               SkUnichar       fUni;
-       } gTest[] = {
-               { "a",                                  'a'     },
-               { "\xC3\x83",                   (3 << 6) | 3    },
-               { "\xE3\x83\x83",               (3 << 12) | (3 << 6) | 3        },
-               { "\xF3\x83\x83\x83",   (3 << 18) | (3 << 12) | (3 << 6) | 3    }
-       };
-
-       for (unsigned i = 0; i < SK_ARRAY_COUNT(gTest); i++)
-       {
-               const char*     p = gTest[i].fUtf8;
-               int                     n = SkUTF8_CountUnichars(p);
-               SkUnichar       u0 = SkUTF8_ToUnichar(gTest[i].fUtf8);
-               SkUnichar       u1 = SkUTF8_NextUnichar(&p);
-
-               SkASSERT(n == 1);
-               SkASSERT(u0 == u1);
-               SkASSERT(u0 == gTest[i].fUni);
-               SkASSERT(p - gTest[i].fUtf8 == (int)strlen(gTest[i].fUtf8));
-       }
+    static const struct {
+        const char* fUtf8;
+        SkUnichar   fUni;
+    } gTest[] = {
+        { "a",                  'a' },
+        { "\xC3\x83",           (3 << 6) | 3    },
+        { "\xE3\x83\x83",       (3 << 12) | (3 << 6) | 3    },
+        { "\xF3\x83\x83\x83",   (3 << 18) | (3 << 12) | (3 << 6) | 3    }
+    };
+
+    for (unsigned i = 0; i < SK_ARRAY_COUNT(gTest); i++)
+    {
+        const char* p = gTest[i].fUtf8;
+        int         n = SkUTF8_CountUnichars(p);
+        SkUnichar   u0 = SkUTF8_ToUnichar(gTest[i].fUtf8);
+        SkUnichar   u1 = SkUTF8_NextUnichar(&p);
+
+        SkASSERT(n == 1);
+        SkASSERT(u0 == u1);
+        SkASSERT(u0 == gTest[i].fUni);
+        SkASSERT(p - gTest[i].fUtf8 == (int)strlen(gTest[i].fUtf8));
+    }
     
     test_utf16();
 
-       test_search();
+    test_search();
 #endif
 }
 
index 6f5a9a8..1aaa3ee 100644 (file)
@@ -1,3 +1,20 @@
+/* libs/graphics/sgl/SkXfermode.cpp
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #include "SkXfermode.h"
 #include "SkColorPriv.h"
 
@@ -13,124 +30,124 @@ static inline U8CPU SkAlphaMulAlpha(U8CPU a, U8CPU b)
 
 void SkXfermode::xfer32(SkPMColor dst[], const SkPMColor src[], int count, const SkAlpha aa[])
 {
-       // override in subclass
+    // override in subclass
 }
 
 void SkXfermode::xfer16(uint16_t dst[], const SkPMColor src[], int count, const SkAlpha aa[])
 {
-       // override in subclass
+    // override in subclass
 }
 
 void SkXfermode::xferA8(SkAlpha dst[], const SkPMColor src[], int count, const SkAlpha aa[])
 {
-       // override in subclass
+    // override in subclass
 }
 
 //////////////////////////////////////////////////////////////////////////////////
 
 static SkPMColor SkFourByteInterp(SkPMColor src, SkPMColor dst, U8CPU alpha)
 {
-       unsigned scale = SkAlpha255To256(alpha);
+    unsigned scale = SkAlpha255To256(alpha);
 
-       unsigned a = SkAlphaBlend(SkGetPackedA32(src), SkGetPackedA32(dst), scale);
-       unsigned r = SkAlphaBlend(SkGetPackedR32(src), SkGetPackedR32(dst), scale);
-       unsigned g = SkAlphaBlend(SkGetPackedG32(src), SkGetPackedG32(dst), scale);
-       unsigned b = SkAlphaBlend(SkGetPackedB32(src), SkGetPackedB32(dst), scale);
+    unsigned a = SkAlphaBlend(SkGetPackedA32(src), SkGetPackedA32(dst), scale);
+    unsigned r = SkAlphaBlend(SkGetPackedR32(src), SkGetPackedR32(dst), scale);
+    unsigned g = SkAlphaBlend(SkGetPackedG32(src), SkGetPackedG32(dst), scale);
+    unsigned b = SkAlphaBlend(SkGetPackedB32(src), SkGetPackedB32(dst), scale);
 
-       return SkPackARGB32(a, r, g, b);
+    return SkPackARGB32(a, r, g, b);
 }
 
 void SkProcXfermode::xfer32(SkPMColor dst[], const SkPMColor src[], int count, const SkAlpha aa[])
 {
-       SkASSERT(dst && src && count >= 0);
-
-       SkXfermodeProc proc = fProc;
-       if (proc)
-       {
-               if (NULL == aa)         
-               {
-                       for (int i = count - 1; i >= 0; --i)
-                               dst[i] = proc(src[i], dst[i]);
-               }
-               else
-               {
-                       for (int i = count - 1; i >= 0; --i)
-                       {
-                               unsigned a = aa[i];
-                               if (a != 0)
-                               {
-                                       SkPMColor dstC = dst[i];
-                                       SkPMColor C = proc(src[i], dstC);
-                                       if (a != 0xFF)
-                                               C = SkFourByteInterp(C, dstC, a);
-                                       dst[i] = C;
-                               }
-                       }
-               }
-       }
+    SkASSERT(dst && src && count >= 0);
+
+    SkXfermodeProc proc = fProc;
+    if (proc)
+    {
+        if (NULL == aa)     
+        {
+            for (int i = count - 1; i >= 0; --i)
+                dst[i] = proc(src[i], dst[i]);
+        }
+        else
+        {
+            for (int i = count - 1; i >= 0; --i)
+            {
+                unsigned a = aa[i];
+                if (a != 0)
+                {
+                    SkPMColor dstC = dst[i];
+                    SkPMColor C = proc(src[i], dstC);
+                    if (a != 0xFF)
+                        C = SkFourByteInterp(C, dstC, a);
+                    dst[i] = C;
+                }
+            }
+        }
+    }
 }
 
 void SkProcXfermode::xfer16(uint16_t dst[], const SkPMColor src[], int count, const SkAlpha aa[])
 {
-       SkASSERT(dst && src && count >= 0);
-
-       SkXfermodeProc proc = fProc;
-       if (proc)
-       {
-               if (NULL == aa)         
-               {
-                       for (int i = count - 1; i >= 0; --i)
-                       {
-                               SkPMColor dstC = SkPixel16ToPixel32(dst[i]);
-                               dst[i] = SkPixel32ToPixel16_ToU16(proc(src[i], dstC));
-                       }
-               }
-               else
-               {
-                       for (int i = count - 1; i >= 0; --i)
-                       {
-                               unsigned a = aa[i];
-                               if (a != 0)
-                               {
-                                       SkPMColor dstC = SkPixel16ToPixel32(dst[i]);
-                                       SkPMColor C = proc(src[i], dstC);
-                                       if (a != 0xFF)
-                                               C = SkFourByteInterp(C, dstC, a);
-                                       dst[i] = SkPixel32ToPixel16_ToU16(C);
-                               }
-                       }
-               }
-       }
+    SkASSERT(dst && src && count >= 0);
+
+    SkXfermodeProc proc = fProc;
+    if (proc)
+    {
+        if (NULL == aa)     
+        {
+            for (int i = count - 1; i >= 0; --i)
+            {
+                SkPMColor dstC = SkPixel16ToPixel32(dst[i]);
+                dst[i] = SkPixel32ToPixel16_ToU16(proc(src[i], dstC));
+            }
+        }
+        else
+        {
+            for (int i = count - 1; i >= 0; --i)
+            {
+                unsigned a = aa[i];
+                if (a != 0)
+                {
+                    SkPMColor dstC = SkPixel16ToPixel32(dst[i]);
+                    SkPMColor C = proc(src[i], dstC);
+                    if (a != 0xFF)
+                        C = SkFourByteInterp(C, dstC, a);
+                    dst[i] = SkPixel32ToPixel16_ToU16(C);
+                }
+            }
+        }
+    }
 }
 
 void SkProcXfermode::xferA8(SkAlpha dst[], const SkPMColor src[], int count, const SkAlpha aa[])
 {
-       SkASSERT(dst && src && count >= 0);
-
-       SkXfermodeProc proc = fProc;
-       if (proc)
-       {
-               if (NULL == aa)         
-               {
-                       for (int i = count - 1; i >= 0; --i)
-                               dst[i] = SkToU8(SkGetPackedA32(proc(src[i], (SkPMColor)(dst[i] << SK_A32_SHIFT))));
-               }
-               else
-               {
-                       for (int i = count - 1; i >= 0; --i)
-                       {
-                               unsigned a = aa[i];
-                               if (a != 0)
-                               {
-                                       SkAlpha dstA = dst[i];
-                                       unsigned A = SkGetPackedA32(proc(src[i], (SkPMColor)(dstA << SK_A32_SHIFT)));
-                                       if (a != 0xFF)
-                                               A = SkAlphaBlend(A, dstA, SkAlpha255To256(a));
-                                       dst[i] = SkToU8(A);
-                               }
-                       }
-               }
-       }
+    SkASSERT(dst && src && count >= 0);
+
+    SkXfermodeProc proc = fProc;
+    if (proc)
+    {
+        if (NULL == aa)     
+        {
+            for (int i = count - 1; i >= 0; --i)
+                dst[i] = SkToU8(SkGetPackedA32(proc(src[i], (SkPMColor)(dst[i] << SK_A32_SHIFT))));
+        }
+        else
+        {
+            for (int i = count - 1; i >= 0; --i)
+            {
+                unsigned a = aa[i];
+                if (a != 0)
+                {
+                    SkAlpha dstA = dst[i];
+                    unsigned A = SkGetPackedA32(proc(src[i], (SkPMColor)(dstA << SK_A32_SHIFT)));
+                    if (a != 0xFF)
+                        A = SkAlphaBlend(A, dstA, SkAlpha255To256(a));
+                    dst[i] = SkToU8(A);
+                }
+            }
+        }
+    }
 }
 
 SkProcXfermode::SkProcXfermode(SkRBuffer& buffer) : SkXfermode(buffer)
@@ -158,106 +175,106 @@ SkFlattenable* SkProcXfermode::CreateProc(SkRBuffer& buffer)
 //////////////////////////////////////////////////////////////////////////////////
 //////////////////////////////////////////////////////////////////////////////////
 
-//     kClear_Mode,    //!< [0, 0]
+//  kClear_Mode,    //!< [0, 0]
 static SkPMColor clear_modeproc(SkPMColor src, SkPMColor dst)
 {
-       return 0;
+    return 0;
 }
 
-//     kSrc_Mode,              //!< [Sa, Sc]
+//  kSrc_Mode,      //!< [Sa, Sc]
 static SkPMColor src_modeproc(SkPMColor src, SkPMColor dst)
 {
-       return src;
+    return src;
 }
 
-//     kDst_Mode,              //!< [Da, Dc]
+//  kDst_Mode,      //!< [Da, Dc]
 static SkPMColor dst_modeproc(SkPMColor src, SkPMColor dst)
 {
-       return dst;
+    return dst;
 }
 
-//     kSrcOver_Mode,  //!< [Sa + (1 - Sa)*Da, Sc + (1 - Sa)*Dc] this is the default mode
+//  kSrcOver_Mode,  //!< [Sa + (1 - Sa)*Da, Sc + (1 - Sa)*Dc] this is the default mode
 static SkPMColor srcover_modeproc(SkPMColor src, SkPMColor dst)
 {
-       return src + SkAlphaMulQ(dst, SkAlpha255To256(255 - SkGetPackedA32(src)));
+    return src + SkAlphaMulQ(dst, SkAlpha255To256(255 - SkGetPackedA32(src)));
 }
 
-//     kDstOver_Mode,  //!< [Sa + (1 - Sa)*Da, Dc + (1 - Da)*Sc]
+//  kDstOver_Mode,  //!< [Sa + (1 - Sa)*Da, Dc + (1 - Da)*Sc]
 static SkPMColor dstover_modeproc(SkPMColor src, SkPMColor dst)
 {
-       unsigned sa = SkGetPackedA32(src);
-       unsigned da = SkGetPackedA32(dst);
+    unsigned sa = SkGetPackedA32(src);
+    unsigned da = SkGetPackedA32(dst);
 
-       return SkPackARGB32(sa + da - SkAlphaMulAlpha(sa, da),
-                                               SkGetPackedR32(dst) + SkAlphaMulAlpha(255 - da, SkGetPackedR32(src)),
-                                               SkGetPackedG32(dst) + SkAlphaMulAlpha(255 - da, SkGetPackedG32(src)),
-                                               SkGetPackedB32(dst) + SkAlphaMulAlpha(255 - da, SkGetPackedB32(src)));
+    return SkPackARGB32(sa + da - SkAlphaMulAlpha(sa, da),
+                        SkGetPackedR32(dst) + SkAlphaMulAlpha(255 - da, SkGetPackedR32(src)),
+                        SkGetPackedG32(dst) + SkAlphaMulAlpha(255 - da, SkGetPackedG32(src)),
+                        SkGetPackedB32(dst) + SkAlphaMulAlpha(255 - da, SkGetPackedB32(src)));
 }
 
-//     kSrcIn_Mode,    //!< [Sa * Da, Sc * Da]
+//  kSrcIn_Mode,    //!< [Sa * Da, Sc * Da]
 static SkPMColor srcin_modeproc(SkPMColor src, SkPMColor dst)
 {
-       return SkAlphaMulQ(src, SkAlpha255To256(SkGetPackedA32(dst)));
+    return SkAlphaMulQ(src, SkAlpha255To256(SkGetPackedA32(dst)));
 }
 
-//     kDstIn_Mode,    //!< [Sa * Da, Sa * Dc]
+//  kDstIn_Mode,    //!< [Sa * Da, Sa * Dc]
 static SkPMColor dstin_modeproc(SkPMColor src, SkPMColor dst)
 {
-       return SkAlphaMulQ(dst, SkAlpha255To256(SkGetPackedA32(src)));
+    return SkAlphaMulQ(dst, SkAlpha255To256(SkGetPackedA32(src)));
 }
 
-//     kSrcOut_Mode,   //!< [Sa * (1 - Da), Sc * (1 - Da)]
+//  kSrcOut_Mode,   //!< [Sa * (1 - Da), Sc * (1 - Da)]
 static SkPMColor srcout_modeproc(SkPMColor src, SkPMColor dst)
 {
-       return SkAlphaMulQ(src, SkAlpha255To256(255 - SkGetPackedA32(dst)));
+    return SkAlphaMulQ(src, SkAlpha255To256(255 - SkGetPackedA32(dst)));
 }
 
-//     kDstOut_Mode,   //!< [Da * (1 - Sa), Dc * (1 - Sa)]
+//  kDstOut_Mode,   //!< [Da * (1 - Sa), Dc * (1 - Sa)]
 static SkPMColor dstout_modeproc(SkPMColor src, SkPMColor dst)
 {
-       return SkAlphaMulQ(dst, SkAlpha255To256(255 - SkGetPackedA32(src)));
+    return SkAlphaMulQ(dst, SkAlpha255To256(255 - SkGetPackedA32(src)));
 }
 
-//     kSrcATop_Mode,  //!< [Da, Sc * Da + (1 - Sa) * Dc]
+//  kSrcATop_Mode,  //!< [Da, Sc * Da + (1 - Sa) * Dc]
 static SkPMColor srcatop_modeproc(SkPMColor src, SkPMColor dst)
 {
-       unsigned sa = SkGetPackedA32(src);
-       unsigned da = SkGetPackedA32(dst);
-       unsigned src_scale = SkAlpha255To256(255 - sa);
-       unsigned dst_scale = SkAlpha255To256(da);
+    unsigned sa = SkGetPackedA32(src);
+    unsigned da = SkGetPackedA32(dst);
+    unsigned src_scale = SkAlpha255To256(255 - sa);
+    unsigned dst_scale = SkAlpha255To256(da);
 
-       return SkPackARGB32(da,
-                                               (dst_scale * SkGetPackedR32(src) + src_scale * SkGetPackedR32(dst)) >> 8,
-                                               (dst_scale * SkGetPackedG32(src) + src_scale * SkGetPackedG32(dst)) >> 8,
-                                               (dst_scale * SkGetPackedB32(src) + src_scale * SkGetPackedB32(dst)) >> 8);
+    return SkPackARGB32(da,
+                        (dst_scale * SkGetPackedR32(src) + src_scale * SkGetPackedR32(dst)) >> 8,
+                        (dst_scale * SkGetPackedG32(src) + src_scale * SkGetPackedG32(dst)) >> 8,
+                        (dst_scale * SkGetPackedB32(src) + src_scale * SkGetPackedB32(dst)) >> 8);
 }
 
-//     kDstATop_Mode,  //!< [Sa, Sa * Dc + Sc * (1 - Da)]
+//  kDstATop_Mode,  //!< [Sa, Sa * Dc + Sc * (1 - Da)]
 static SkPMColor dstatop_modeproc(SkPMColor src, SkPMColor dst)
 {
-       unsigned sa = SkGetPackedA32(src);
-       unsigned da = SkGetPackedA32(dst);
-       unsigned src_scale = SkAlpha255To256(sa);
-       unsigned dst_scale = SkAlpha255To256(255 - da);
+    unsigned sa = SkGetPackedA32(src);
+    unsigned da = SkGetPackedA32(dst);
+    unsigned src_scale = SkAlpha255To256(sa);
+    unsigned dst_scale = SkAlpha255To256(255 - da);
 
-       return SkPackARGB32(sa,
-                                               (dst_scale * SkGetPackedR32(src) + src_scale * SkGetPackedR32(dst)) >> 8,
-                                               (dst_scale * SkGetPackedG32(src) + src_scale * SkGetPackedG32(dst)) >> 8,
-                                               (dst_scale * SkGetPackedB32(src) + src_scale * SkGetPackedB32(dst)) >> 8);
+    return SkPackARGB32(sa,
+                        (dst_scale * SkGetPackedR32(src) + src_scale * SkGetPackedR32(dst)) >> 8,
+                        (dst_scale * SkGetPackedG32(src) + src_scale * SkGetPackedG32(dst)) >> 8,
+                        (dst_scale * SkGetPackedB32(src) + src_scale * SkGetPackedB32(dst)) >> 8);
 }
 
-//     kXor_Mode,              //!< [Sa + Da - 2 * Sa * Da, Sc * (1 - Da) + (1 - Sa) * Dc]
+//  kXor_Mode,      //!< [Sa + Da - 2 * Sa * Da, Sc * (1 - Da) + (1 - Sa) * Dc]
 static SkPMColor xor_modeproc(SkPMColor src, SkPMColor dst)
 {
-       unsigned sa = SkGetPackedA32(src);
-       unsigned da = SkGetPackedA32(dst);
-       unsigned src_scale = SkAlpha255To256(255 - sa);
-       unsigned dst_scale = SkAlpha255To256(255 - da);
+    unsigned sa = SkGetPackedA32(src);
+    unsigned da = SkGetPackedA32(dst);
+    unsigned src_scale = SkAlpha255To256(255 - sa);
+    unsigned dst_scale = SkAlpha255To256(255 - da);
 
-       return SkPackARGB32(sa + da - (SkAlphaMulAlpha(sa, da) << 1),
-                                               (dst_scale * SkGetPackedR32(src) + src_scale * SkGetPackedR32(dst)) >> 8,
-                                               (dst_scale * SkGetPackedG32(src) + src_scale * SkGetPackedG32(dst)) >> 8,
-                                               (dst_scale * SkGetPackedB32(src) + src_scale * SkGetPackedB32(dst)) >> 8);
+    return SkPackARGB32(sa + da - (SkAlphaMulAlpha(sa, da) << 1),
+                        (dst_scale * SkGetPackedR32(src) + src_scale * SkGetPackedR32(dst)) >> 8,
+                        (dst_scale * SkGetPackedG32(src) + src_scale * SkGetPackedG32(dst)) >> 8,
+                        (dst_scale * SkGetPackedB32(src) + src_scale * SkGetPackedB32(dst)) >> 8);
 }
 
 
@@ -270,17 +287,17 @@ static inline unsigned darken_p(unsigned src, unsigned dst, unsigned src_mul, un
 
 static SkPMColor darken_modeproc(SkPMColor src, SkPMColor dst)
 {
-       unsigned sa = SkGetPackedA32(src);
-       unsigned da = SkGetPackedA32(dst);
-       unsigned src_scale = SkAlpha255To256(255 - sa);
-       unsigned dst_scale = SkAlpha255To256(255 - da);
+    unsigned sa = SkGetPackedA32(src);
+    unsigned da = SkGetPackedA32(dst);
+    unsigned src_scale = SkAlpha255To256(255 - sa);
+    unsigned dst_scale = SkAlpha255To256(255 - da);
 
     unsigned ra = sa + da - SkAlphaMulAlpha(sa, da);
     unsigned rr = darken_p(SkGetPackedR32(src), SkGetPackedR32(dst), src_scale, dst_scale);
     unsigned rg = darken_p(SkGetPackedG32(src), SkGetPackedG32(dst), src_scale, dst_scale);
     unsigned rb = darken_p(SkGetPackedB32(src), SkGetPackedB32(dst), src_scale, dst_scale);
 
-       return SkPackARGB32(ra, SkFastMin32(rr, ra), SkFastMin32(rg, ra), SkFastMin32(rb, ra));
+    return SkPackARGB32(ra, SkFastMin32(rr, ra), SkFastMin32(rg, ra), SkFastMin32(rb, ra));
 }
 
 //        kLighten_Mode,  [Sa + Da - SaáDa, Scá(1 - Da) + Dcá(1 - Sa) + max(Sc, Dc)]
@@ -291,52 +308,52 @@ static inline unsigned lighten_p(unsigned src, unsigned dst, unsigned src_mul, u
 
 static SkPMColor lighten_modeproc(SkPMColor src, SkPMColor dst)
 {
-       unsigned sa = SkGetPackedA32(src);
-       unsigned da = SkGetPackedA32(dst);
-       unsigned src_scale = SkAlpha255To256(255 - sa);
-       unsigned dst_scale = SkAlpha255To256(255 - da);
+    unsigned sa = SkGetPackedA32(src);
+    unsigned da = SkGetPackedA32(dst);
+    unsigned src_scale = SkAlpha255To256(255 - sa);
+    unsigned dst_scale = SkAlpha255To256(255 - da);
     
     unsigned ra = sa + da - SkAlphaMulAlpha(sa, da);
     unsigned rr = lighten_p(SkGetPackedR32(src), SkGetPackedR32(dst), src_scale, dst_scale);
     unsigned rg = lighten_p(SkGetPackedG32(src), SkGetPackedG32(dst), src_scale, dst_scale);
     unsigned rb = lighten_p(SkGetPackedB32(src), SkGetPackedB32(dst), src_scale, dst_scale);
 
-       return SkPackARGB32(ra, SkFastMin32(rr, ra), SkFastMin32(rg, ra), SkFastMin32(rb, ra));
+    return SkPackARGB32(ra, SkFastMin32(rr, ra), SkFastMin32(rg, ra), SkFastMin32(rb, ra));
 }
 
 //////////////////////////////////////////////////////////////////////////////////
 
 #if 0 // maybe do these later
 
-#define SkPinToU8(value)       SkFastMin32(value, 0xFF)
+#define SkPinToU8(value)    SkFastMin32(value, 0xFF)
 
-//     kAdd_Mode,              //!< clamp [Sa + Da, Sc + Dc]
+//  kAdd_Mode,      //!< clamp [Sa + Da, Sc + Dc]
 static SkPMColor add_modeproc(SkPMColor src, SkPMColor dst)
 {
-       return SkPackARGB32(SkPinToU8(SkGetPackedA32(src) + SkGetPackedA32(dst)),
-                                               SkPinToU8(SkGetPackedR32(src) + SkGetPackedR32(dst)),
-                                               SkPinToU8(SkGetPackedG32(src) + SkGetPackedG32(dst)),
-                                               SkPinToU8(SkGetPackedB32(src) + SkGetPackedB32(dst)));
+    return SkPackARGB32(SkPinToU8(SkGetPackedA32(src) + SkGetPackedA32(dst)),
+                        SkPinToU8(SkGetPackedR32(src) + SkGetPackedR32(dst)),
+                        SkPinToU8(SkGetPackedG32(src) + SkGetPackedG32(dst)),
+                        SkPinToU8(SkGetPackedB32(src) + SkGetPackedB32(dst)));
 }
 
 static U8CPU do_mul(U8CPU src, U8CPU dst, unsigned src_scale, unsigned dst_scale)
 {
-       return (src * dst_scale + dst * (SkAlpha255To256(src) + src_scale)) >> 8;
+    return (src * dst_scale + dst * (SkAlpha255To256(src) + src_scale)) >> 8;
 }
 
-//     kMul_Mode,              //!< clamp [Sa + Da - Sa * Da, Sc * Dc + Sc * (1 - Da) + (1 - Sa) * Dc]
+//  kMul_Mode,      //!< clamp [Sa + Da - Sa * Da, Sc * Dc + Sc * (1 - Da) + (1 - Sa) * Dc]
 static SkPMColor mul_modeproc(SkPMColor src, SkPMColor dst)
 {
-       unsigned sa = SkGetPackedA32(src);
-       unsigned src_scale = SkAlpha255To256(255 - sa);
+    unsigned sa = SkGetPackedA32(src);
+    unsigned src_scale = SkAlpha255To256(255 - sa);
 
-       unsigned da = SkGetPackedA32(dst);
-       unsigned dst_scale = SkAlpha255To256(255 - da);
+    unsigned da = SkGetPackedA32(dst);
+    unsigned dst_scale = SkAlpha255To256(255 - da);
 
-       return SkPackARGB32(sa + da - SkAlphaMul(SkAlpha255To256(sa), da),
-                                               do_mul(SkGetPackedR32(src), SkGetPackedR32(dst), src_scale, dst_scale),
-                                               do_mul(SkGetPackedG32(src), SkGetPackedG32(dst), src_scale, dst_scale),
-                                               do_mul(SkGetPackedB32(src), SkGetPackedB32(dst), src_scale, dst_scale));
+    return SkPackARGB32(sa + da - SkAlphaMul(SkAlpha255To256(sa), da),
+                        do_mul(SkGetPackedR32(src), SkGetPackedR32(dst), src_scale, dst_scale),
+                        do_mul(SkGetPackedG32(src), SkGetPackedG32(dst), src_scale, dst_scale),
+                        do_mul(SkGetPackedB32(src), SkGetPackedB32(dst), src_scale, dst_scale));
 }
 #endif
 
@@ -344,44 +361,44 @@ static SkPMColor mul_modeproc(SkPMColor src, SkPMColor dst)
 
 class SkClearXfermode : public SkProcXfermode {
 public:
-       SkClearXfermode() : SkProcXfermode(clear_modeproc) {}
-
-       virtual void xfer32(SkPMColor dst[], const SkPMColor[], int count, const SkAlpha aa[])
-       {
-               SkASSERT(dst && count >= 0);
-
-               if (NULL == aa)
-                       memset(dst, 0, count << 2);
-               else
-               {
-                       for (int i = count - 1; i >= 0; --i)
-                       {
-                               unsigned a = aa[i];
-                               if (a == 0xFF)
-                                       dst[i] = 0;
-                               else if (a != 0)
-                                       dst[i] = SkAlphaMulQ(dst[i], SkAlpha255To256(255 - a));
-                       }
-               }
-       }
-       virtual void xferA8(SkAlpha dst[], const SkPMColor[], int count, const SkAlpha aa[])
-       {
-               SkASSERT(dst && count >= 0);
-
-               if (NULL == aa)
-                       memset(dst, 0, count);
-               else
-               {
-                       for (int i = count - 1; i >= 0; --i)
-                       {
-                               unsigned a = aa[i];
-                               if (a == 0xFF)
-                                       dst[i] = 0;
-                               else if (a != 0)
-                                       dst[i] = SkToU8(SkAlphaMul(dst[i], SkAlpha255To256(255 - a)));
-                       }
-               }
-       }
+    SkClearXfermode() : SkProcXfermode(clear_modeproc) {}
+
+    virtual void xfer32(SkPMColor dst[], const SkPMColor[], int count, const SkAlpha aa[])
+    {
+        SkASSERT(dst && count >= 0);
+
+        if (NULL == aa)
+            memset(dst, 0, count << 2);
+        else
+        {
+            for (int i = count - 1; i >= 0; --i)
+            {
+                unsigned a = aa[i];
+                if (a == 0xFF)
+                    dst[i] = 0;
+                else if (a != 0)
+                    dst[i] = SkAlphaMulQ(dst[i], SkAlpha255To256(255 - a));
+            }
+        }
+    }
+    virtual void xferA8(SkAlpha dst[], const SkPMColor[], int count, const SkAlpha aa[])
+    {
+        SkASSERT(dst && count >= 0);
+
+        if (NULL == aa)
+            memset(dst, 0, count);
+        else
+        {
+            for (int i = count - 1; i >= 0; --i)
+            {
+                unsigned a = aa[i];
+                if (a == 0xFF)
+                    dst[i] = 0;
+                else if (a != 0)
+                    dst[i] = SkToU8(SkAlphaMul(dst[i], SkAlpha255To256(255 - a)));
+            }
+        }
+    }
     
     virtual Factory getFactory() { return CreateProc; }
     // we have nothing to flatten(), so don't need to override it
@@ -399,51 +416,51 @@ private:
 
 class SkSrcXfermode : public SkProcXfermode {
 public:
-       SkSrcXfermode() : SkProcXfermode(src_modeproc) {}
-
-       virtual void xfer32(SkPMColor dst[], const SkPMColor src[], int count, const SkAlpha aa[])
-       {
-               SkASSERT(dst && src && count >= 0);
-
-               if (NULL == aa)
-                       memcpy(dst, src, count << 2);
-               else
-               {
-                       for (int i = count - 1; i >= 0; --i)
-                       {
-                               unsigned a = aa[i];
-                               if (a == 0xFF)
-                                       dst[i] = src[i];
-                               else if (a != 0)
-                                       dst[i] = SkFourByteInterp(src[i], dst[i], a);
-                       }
-               }
-       }
-       virtual void xferA8(SkAlpha dst[], const SkPMColor src[], int count, const SkAlpha aa[])
-       {
-               SkASSERT(dst && src && count >= 0);
-
-               if (NULL == aa)
-               {
-                       for (int i = count - 1; i >= 0; --i)
-                               dst[i] = SkToU8(SkGetPackedA32(src[i]));
-               }
-               else
-               {
-                       for (int i = count - 1; i >= 0; --i)
-                       {
-                               unsigned a = aa[i];
-                               if (a != 0)
-                               {
-                                       unsigned srcA = SkGetPackedA32(src[i]);
-                                       if (a == 0xFF)
-                                               dst[i] = SkToU8(srcA);
-                                       else
-                                               dst[i] = SkToU8(SkAlphaBlend(srcA, dst[i], a));
-                               }
-                       }
-               }
-       }
+    SkSrcXfermode() : SkProcXfermode(src_modeproc) {}
+
+    virtual void xfer32(SkPMColor dst[], const SkPMColor src[], int count, const SkAlpha aa[])
+    {
+        SkASSERT(dst && src && count >= 0);
+
+        if (NULL == aa)
+            memcpy(dst, src, count << 2);
+        else
+        {
+            for (int i = count - 1; i >= 0; --i)
+            {
+                unsigned a = aa[i];
+                if (a == 0xFF)
+                    dst[i] = src[i];
+                else if (a != 0)
+                    dst[i] = SkFourByteInterp(src[i], dst[i], a);
+            }
+        }
+    }
+    virtual void xferA8(SkAlpha dst[], const SkPMColor src[], int count, const SkAlpha aa[])
+    {
+        SkASSERT(dst && src && count >= 0);
+
+        if (NULL == aa)
+        {
+            for (int i = count - 1; i >= 0; --i)
+                dst[i] = SkToU8(SkGetPackedA32(src[i]));
+        }
+        else
+        {
+            for (int i = count - 1; i >= 0; --i)
+            {
+                unsigned a = aa[i];
+                if (a != 0)
+                {
+                    unsigned srcA = SkGetPackedA32(src[i]);
+                    if (a == 0xFF)
+                        dst[i] = SkToU8(srcA);
+                    else
+                        dst[i] = SkToU8(SkAlphaBlend(srcA, dst[i], a));
+                }
+            }
+        }
+    }
     
     virtual Factory getFactory() { return CreateProc; }
     // we have nothing to flatten(), so don't need to override it
@@ -462,37 +479,37 @@ private:
 #include "SkPorterDuff.h"
 
 static const SkXfermodeProc gPorterDuffModeProcs[] = {
-       clear_modeproc,
-       src_modeproc,
-       dst_modeproc,
-       srcover_modeproc,
-       dstover_modeproc,
-       srcin_modeproc,
-       dstin_modeproc,
-       srcout_modeproc,
-       dstout_modeproc,
-       srcatop_modeproc,
-       dstatop_modeproc,
-       xor_modeproc,
+    clear_modeproc,
+    src_modeproc,
+    dst_modeproc,
+    srcover_modeproc,
+    dstover_modeproc,
+    srcin_modeproc,
+    dstin_modeproc,
+    srcout_modeproc,
+    dstout_modeproc,
+    srcatop_modeproc,
+    dstatop_modeproc,
+    xor_modeproc,
     darken_modeproc,
     lighten_modeproc
 };
 
 SkXfermode* SkPorterDuff::CreateXfermode(SkPorterDuff::Mode mode)
 {
-       SkASSERT(SK_ARRAY_COUNT(gPorterDuffModeProcs) == SkPorterDuff::kModeCount);
-       SkASSERT((unsigned)mode < SkPorterDuff::kModeCount);
-
-       switch (mode) {
-       case kClear_Mode:
-               return SkNEW(SkClearXfermode);
-       case kSrc_Mode:
-               return SkNEW(SkSrcXfermode);
-       case kSrcOver_Mode:
-               return NULL;
-       default:
-               return SkNEW_ARGS(SkProcXfermode, (gPorterDuffModeProcs[mode]));
-       }
+    SkASSERT(SK_ARRAY_COUNT(gPorterDuffModeProcs) == SkPorterDuff::kModeCount);
+    SkASSERT((unsigned)mode < SkPorterDuff::kModeCount);
+
+    switch (mode) {
+    case kClear_Mode:
+        return SkNEW(SkClearXfermode);
+    case kSrc_Mode:
+        return SkNEW(SkSrcXfermode);
+    case kSrcOver_Mode:
+        return NULL;
+    default:
+        return SkNEW_ARGS(SkProcXfermode, (gPorterDuffModeProcs[mode]));
+    }
 }
 
 #ifdef SK_DEBUG
index 190957a..7c39044 100644 (file)
@@ -1,3 +1,20 @@
+/* libs/graphics/svg/SkSVG.cpp
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #include "SkSVG.h"
 #include 'SkSVGParser.h"
 
@@ -9,11 +26,11 @@ SkSVG::~SkSVG() {
 
 bool SkSVG::decodeStream(SkStream* stream);
 {
-       size_t size = stream->read(nil, 0);
+    size_t size = stream->read(nil, 0);
     SkAutoMalloc    storage(size);
     char* data = (char*)storage.get();
-       size_t actual = stream->read(data, size);
+    size_t actual = stream->read(data, size);
     SkASSERT(size == actual);
-       SkSVGParser parser(*fMaker);
-       return parser.parse(data, actual, &fErrorCode, &fErrorLineNumber);
+    SkSVGParser parser(*fMaker);
+    return parser.parse(data, actual, &fErrorCode, &fErrorLineNumber);
 }
index e964229..b72d46c 100644 (file)
@@ -1,36 +1,53 @@
+/* libs/graphics/svg/SkSVGCircle.cpp
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #include "SkSVGCircle.h"
 #include "SkSVGParser.h"
 #include "SkParse.h"
 #include <stdio.h>
 
 const SkSVGAttribute SkSVGCircle::gAttributes[] = {
-       SVG_ATTRIBUTE(cx),
-       SVG_ATTRIBUTE(cy),
-       SVG_ATTRIBUTE(r)
+    SVG_ATTRIBUTE(cx),
+    SVG_ATTRIBUTE(cy),
+    SVG_ATTRIBUTE(r)
 };
 
 DEFINE_SVG_INFO(Circle)
 
 void SkSVGCircle::translate(SkSVGParser& parser, bool defState) {
-       parser._startElement("oval");
-       INHERITED::translate(parser, defState);
-       SkScalar cx, cy, r;
-       SkParse::FindScalar(f_cx.c_str(), &cx);
-       SkParse::FindScalar(f_cy.c_str(), &cy);
-       SkParse::FindScalar(f_r.c_str(), &r);
-       SkScalar left, top, right, bottom;
-       left = cx - r;
-       top = cy - r;
-       right = cx + r;
-       bottom = cy + r;
-       char scratch[16];
-       sprintf(scratch, "%g", left);
-       parser._addAttribute("left", scratch);
-       sprintf(scratch, "%g", top);
-       parser._addAttribute("top", scratch);
-       sprintf(scratch, "%g", right);
-       parser._addAttribute("right", scratch);
-       sprintf(scratch, "%g", bottom);
-       parser._addAttribute("bottom", scratch);
-       parser._endElement();
+    parser._startElement("oval");
+    INHERITED::translate(parser, defState);
+    SkScalar cx, cy, r;
+    SkParse::FindScalar(f_cx.c_str(), &cx);
+    SkParse::FindScalar(f_cy.c_str(), &cy);
+    SkParse::FindScalar(f_r.c_str(), &r);
+    SkScalar left, top, right, bottom;
+    left = cx - r;
+    top = cy - r;
+    right = cx + r;
+    bottom = cy + r;
+    char scratch[16];
+    sprintf(scratch, "%g", left);
+    parser._addAttribute("left", scratch);
+    sprintf(scratch, "%g", top);
+    parser._addAttribute("top", scratch);
+    sprintf(scratch, "%g", right);
+    parser._addAttribute("right", scratch);
+    sprintf(scratch, "%g", bottom);
+    parser._addAttribute("bottom", scratch);
+    parser._endElement();
 }
index 4535a66..9124c1c 100644 (file)
@@ -1,15 +1,32 @@
+/* libs/graphics/svg/SkSVGCircle.h
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #ifndef SkSVGCircle_DEFINED
 #define SkSVGCircle_DEFINED
 
 #include "SkSVGElements.h"
 
 class SkSVGCircle : public SkSVGElement {
-       DECLARE_SVG_INFO(Circle);
+    DECLARE_SVG_INFO(Circle);
 private:
-       SkString f_cx;
-       SkString f_cy;
-       SkString f_r;
-       typedef SkSVGElement INHERITED;
+    SkString f_cx;
+    SkString f_cy;
+    SkString f_r;
+    typedef SkSVGElement INHERITED;
 };
 
 #endif // SkSVGCircle_DEFINED
index 6671921..586571a 100644 (file)
@@ -1,3 +1,20 @@
+/* libs/graphics/svg/SkSVGClipPath.cpp
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #include "SkSVGClipPath.h"
 #include "SkSVGParser.h"
 #include "SkSVGUse.h"
 DEFINE_SVG_NO_INFO(ClipPath)
 
 bool SkSVGClipPath::isDef() {
-       return true;
+    return true;
 }
 
 bool SkSVGClipPath::isNotDef() {
-       return false;
+    return false;
 }
 
 void SkSVGClipPath::translate(SkSVGParser& parser, bool defState) {
-       parser._startElement("clip");
-       INHERITED::translate(parser, defState);
-       SkASSERT(fChildren.count() == 1);
-       SkSVGElement* child = *fChildren.begin();
-       SkASSERT(child->getType() == SkSVGType_Use);
-       SkSVGUse* use = (SkSVGUse*) child;
-       SkSVGElement* ref;
-       const char* refStr = &use->f_xlink_href.c_str()[1];
-       SkASSERT(parser.getIDs().find(refStr, &ref));
-       SkASSERT(ref);
-       if (ref->getType() == SkSVGType_Rect) 
-               parser._addAttribute("rectangle", refStr);
-       else
-               parser._addAttribute("path", refStr);
-       parser._endElement();
+    parser._startElement("clip");
+    INHERITED::translate(parser, defState);
+    SkASSERT(fChildren.count() == 1);
+    SkSVGElement* child = *fChildren.begin();
+    SkASSERT(child->getType() == SkSVGType_Use);
+    SkSVGUse* use = (SkSVGUse*) child;
+    SkSVGElement* ref;
+    const char* refStr = &use->f_xlink_href.c_str()[1];
+    SkASSERT(parser.getIDs().find(refStr, &ref));
+    SkASSERT(ref);
+    if (ref->getType() == SkSVGType_Rect) 
+        parser._addAttribute("rectangle", refStr);
+    else
+        parser._addAttribute("path", refStr);
+    parser._endElement();
 }
index a06103a..4fc7da6 100644 (file)
@@ -1,14 +1,31 @@
+/* libs/graphics/svg/SkSVGClipPath.h
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #ifndef SkSVGClipPath_DEFINED
 #define SkSVGClipPath_DEFINED
 
 #include "SkSVGElements.h"
 
 class SkSVGClipPath : public SkSVGElement {
-       DECLARE_SVG_INFO(ClipPath);
-       virtual bool isDef();
-       virtual bool isNotDef();
+    DECLARE_SVG_INFO(ClipPath);
+    virtual bool isDef();
+    virtual bool isNotDef();
 private:
-       typedef SkSVGElement INHERITED;
+    typedef SkSVGElement INHERITED;
 };
 
 #endif // SkSVGClipPath_DEFINED
index d0aaef5..ae1da54 100644 (file)
@@ -1,15 +1,32 @@
+/* libs/graphics/svg/SkSVGDefs.cpp
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #include "SkSVGDefs.h"
 
 DEFINE_SVG_NO_INFO(Defs)
 
 bool SkSVGDefs::isDef() {
-       return true;
+    return true;
 }
 
 bool SkSVGDefs::isNotDef() {
-       return false;
+    return false;
 }
 
 void SkSVGDefs::translate(SkSVGParser& parser, bool defState) {
-       INHERITED::translate(parser, defState);
+    INHERITED::translate(parser, defState);
 }
index 5a4f087..b4f024c 100644 (file)
@@ -1,14 +1,31 @@
+/* libs/graphics/svg/SkSVGDefs.h
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #ifndef SkSVGDefs_DEFINED
 #define SkSVGDefs_DEFINED
 
 #include "SkSVGGroup.h"
 
 class SkSVGDefs : public SkSVGGroup {
-       DECLARE_SVG_INFO(Defs);
-       virtual bool isDef();
-       virtual bool isNotDef();
+    DECLARE_SVG_INFO(Defs);
+    virtual bool isDef();
+    virtual bool isNotDef();
 private:
-       typedef SkSVGGroup INHERITED;
+    typedef SkSVGGroup INHERITED;
 };
 
 #endif // SkSVGDefs_DEFINED
index 0848436..748a1dd 100644 (file)
@@ -1,3 +1,20 @@
+/* libs/graphics/svg/SkSVGElements.cpp
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #include "SkSVGElements.h"
 #include "SkSVGParser.h"
 
@@ -5,10 +22,10 @@ SkSVGBase::~SkSVGBase() {
 }
 
 void SkSVGBase::addAttribute(SkSVGParser& parser, int attrIndex, 
-               const char* attrValue, size_t attrLength) {
-       SkString* first = (SkString*) ((char*) this + sizeof(SkSVGElement));
-       first += attrIndex;
-       first->set(attrValue, attrLength);
+        const char* attrValue, size_t attrLength) {
+    SkString* first = (SkString*) ((char*) this + sizeof(SkSVGElement));
+    first += attrIndex;
+    first->set(attrValue, attrLength);
 }
 
 
@@ -19,61 +36,61 @@ SkSVGElement::~SkSVGElement() {
 }
 
 SkSVGElement* SkSVGElement::getGradient() {
-       return nil;
+    return nil;
 }
 
 bool SkSVGElement::isGroupParent() {
-       SkSVGElement* parent = fParent;
-       while (parent) {
-               if (parent->getType() != SkSVGType_G)
-                       return false;
-               parent = parent->fParent;
-       }
-       return true;
+    SkSVGElement* parent = fParent;
+    while (parent) {
+        if (parent->getType() != SkSVGType_G)
+            return false;
+        parent = parent->fParent;
+    }
+    return true;
 }
 
 bool SkSVGElement::isDef() {
-       return isGroupParent() == false ? fParent->isDef() : fIsDef;
+    return isGroupParent() == false ? fParent->isDef() : fIsDef;
 }
 
 bool SkSVGElement::isFlushable() {
-       return true;
+    return true;
 }
 
 bool SkSVGElement::isGroup() {
-       return false;
+    return false;
 }
 
 bool SkSVGElement::isNotDef() {
-       return isGroupParent() == false ? fParent->isNotDef() : fIsNotDef;
+    return isGroupParent() == false ? fParent->isNotDef() : fIsNotDef;
 }
 
 bool SkSVGElement::onEndElement(SkSVGParser& parser) {
-       if (f_id.size() > 0)
-               parser.getIDs().set(f_id.c_str(), f_id.size(), this);
-       return false;
+    if (f_id.size() > 0)
+        parser.getIDs().set(f_id.c_str(), f_id.size(), this);
+    return false;
 }
 
 bool SkSVGElement::onStartElement(SkSVGElement* child) {
-       *fChildren.append() = child;
-       return false;
+    *fChildren.append() = child;
+    return false;
 }
 
 void SkSVGElement::translate(SkSVGParser& parser, bool) {
-       if (f_id.size() > 0)
-               SVG_ADD_ATTRIBUTE(id);
+    if (f_id.size() > 0)
+        SVG_ADD_ATTRIBUTE(id);
 }
 
 void SkSVGElement::setIsDef() {
-       fIsDef = isDef();
+    fIsDef = isDef();
 }
 
 //void SkSVGElement::setIsNotDef() {
-//     fIsNotDef = isNotDef();
+//  fIsNotDef = isNotDef();
 //}
 
 void SkSVGElement::write(SkSVGParser& , SkString& ) {
-       SkASSERT(0); 
+    SkASSERT(0); 
 }
 
 
index 8fe7814..743d07f 100644 (file)
@@ -1,3 +1,20 @@
+/* libs/graphics/svg/SkSVGElements.h
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #ifndef SkSVGElements_DEFINED
 #define SkSVGElements_DEFINED
 
@@ -9,56 +26,56 @@ class SkSVGParser;
 
 #define DECLARE_SVG_INFO(_type) \
 public: \
-       virtual ~SkSVG##_type(); \
-       static const SkSVGAttribute gAttributes[]; \
-       virtual int getAttributes(const SkSVGAttribute** attrPtr); \
-       virtual SkSVGTypes getType() const; \
-       virtual void translate(SkSVGParser& parser, bool defState); \
-       typedef SkSVG##_type BASE_CLASS
+    virtual ~SkSVG##_type(); \
+    static const SkSVGAttribute gAttributes[]; \
+    virtual int getAttributes(const SkSVGAttribute** attrPtr); \
+    virtual SkSVGTypes getType() const; \
+    virtual void translate(SkSVGParser& parser, bool defState); \
+    typedef SkSVG##_type BASE_CLASS
 
 #define DEFINE_SVG_INFO(_type) \
-       SkSVG##_type::~SkSVG##_type() {} \
-       int SkSVG##_type::getAttributes(const SkSVGAttribute** attrPtr) { \
-               *attrPtr = gAttributes; \
-               return SK_ARRAY_COUNT(gAttributes); \
-       } \
-       SkSVGTypes SkSVG##_type::getType() const { return SkSVGType_##_type; }
+    SkSVG##_type::~SkSVG##_type() {} \
+    int SkSVG##_type::getAttributes(const SkSVGAttribute** attrPtr) { \
+        *attrPtr = gAttributes; \
+        return SK_ARRAY_COUNT(gAttributes); \
+    } \
+    SkSVGTypes SkSVG##_type::getType() const { return SkSVGType_##_type; }
 
 #define DEFINE_SVG_NO_INFO(_type) \
-       SkSVG##_type::~SkSVG##_type() {} \
-       int SkSVG##_type::getAttributes(const SkSVGAttribute** ) { return 0; } \
-       SkSVGTypes SkSVG##_type::getType() const { return SkSVGType_##_type; }
+    SkSVG##_type::~SkSVG##_type() {} \
+    int SkSVG##_type::getAttributes(const SkSVGAttribute** ) { return 0; } \
+    SkSVGTypes SkSVG##_type::getType() const { return SkSVGType_##_type; }
 
 
 struct SkSVGTypeName {
-       const char* fName;
-       SkSVGTypes fType;
+    const char* fName;
+    SkSVGTypes fType;
 };
 
 class SkSVGElement : public SkSVGBase {
 public:
-       SkSVGElement();
-       virtual ~SkSVGElement();
-       virtual SkSVGElement* getGradient();
-       virtual SkSVGTypes getType() const  = 0;
-       virtual bool isDef();
-       virtual bool isFlushable();
-       virtual bool isGroup();
-       virtual bool isNotDef();
-       virtual bool onEndElement(SkSVGParser& parser);
-       virtual bool onStartElement(SkSVGElement* child);
-       void setIsDef();
-//     void setIsNotDef();
-       virtual void translate(SkSVGParser& parser, bool defState);
-       virtual void write(SkSVGParser& , SkString& color);
-       SkString f_id;
-       SkSVGPaint fPaintState;
-       SkTDArray<SkSVGElement*> fChildren;
-       SkSVGElement* fParent;
-       bool fIsDef;
-       bool fIsNotDef;
+    SkSVGElement();
+    virtual ~SkSVGElement();
+    virtual SkSVGElement* getGradient();
+    virtual SkSVGTypes getType() const  = 0;
+    virtual bool isDef();
+    virtual bool isFlushable();
+    virtual bool isGroup();
+    virtual bool isNotDef();
+    virtual bool onEndElement(SkSVGParser& parser);
+    virtual bool onStartElement(SkSVGElement* child);
+    void setIsDef();
+//  void setIsNotDef();
+    virtual void translate(SkSVGParser& parser, bool defState);
+    virtual void write(SkSVGParser& , SkString& color);
+    SkString f_id;
+    SkSVGPaint fPaintState;
+    SkTDArray<SkSVGElement*> fChildren;
+    SkSVGElement* fParent;
+    bool fIsDef;
+    bool fIsNotDef;
 private:
-       bool isGroupParent();
+    bool isGroupParent();
 };
 
 #endif // SkSVGElements_DEFINED
index a4dfd02..f795d21 100644 (file)
@@ -1,38 +1,55 @@
+/* libs/graphics/svg/SkSVGEllipse.cpp
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #include "SkSVGEllipse.h"
 #include "SkSVGParser.h"
 #include "SkParse.h"
 #include <stdio.h>
 
 const SkSVGAttribute SkSVGEllipse::gAttributes[] = {
-       SVG_ATTRIBUTE(cx),
-       SVG_ATTRIBUTE(cy),
-       SVG_ATTRIBUTE(rx),
-       SVG_ATTRIBUTE(ry)
+    SVG_ATTRIBUTE(cx),
+    SVG_ATTRIBUTE(cy),
+    SVG_ATTRIBUTE(rx),
+    SVG_ATTRIBUTE(ry)
 };
 
 DEFINE_SVG_INFO(Ellipse)
 
 void SkSVGEllipse::translate(SkSVGParser& parser, bool defState) {
-       parser._startElement("oval");
-       INHERITED::translate(parser, defState);
-       SkScalar cx, cy, rx, ry;
-       SkParse::FindScalar(f_cx.c_str(), &cx);
-       SkParse::FindScalar(f_cy.c_str(), &cy);
-       SkParse::FindScalar(f_rx.c_str(), &rx);
-       SkParse::FindScalar(f_ry.c_str(), &ry);
-       SkScalar left, top, right, bottom;
-       left = cx - rx;
-       top = cy - ry;
-       right = cx + rx;
-       bottom = cy + ry;
-       char scratch[16];
-       sprintf(scratch, "%g", left);
-       parser._addAttribute("left", scratch);
-       sprintf(scratch, "%g", top);
-       parser._addAttribute("top", scratch);
-       sprintf(scratch, "%g", right);
-       parser._addAttribute("right", scratch);
-       sprintf(scratch, "%g", bottom);
-       parser._addAttribute("bottom", scratch);
-       parser._endElement();
+    parser._startElement("oval");
+    INHERITED::translate(parser, defState);
+    SkScalar cx, cy, rx, ry;
+    SkParse::FindScalar(f_cx.c_str(), &cx);
+    SkParse::FindScalar(f_cy.c_str(), &cy);
+    SkParse::FindScalar(f_rx.c_str(), &rx);
+    SkParse::FindScalar(f_ry.c_str(), &ry);
+    SkScalar left, top, right, bottom;
+    left = cx - rx;
+    top = cy - ry;
+    right = cx + rx;
+    bottom = cy + ry;
+    char scratch[16];
+    sprintf(scratch, "%g", left);
+    parser._addAttribute("left", scratch);
+    sprintf(scratch, "%g", top);
+    parser._addAttribute("top", scratch);
+    sprintf(scratch, "%g", right);
+    parser._addAttribute("right", scratch);
+    sprintf(scratch, "%g", bottom);
+    parser._addAttribute("bottom", scratch);
+    parser._endElement();
 }
index b822e4d..ea5d291 100644 (file)
@@ -1,16 +1,33 @@
+/* libs/graphics/svg/SkSVGEllipse.h
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #ifndef SkSVGEllipse_DEFINED
 #define SkSVGEllipse_DEFINED
 
 #include "SkSVGElements.h"
 
 class SkSVGEllipse : public SkSVGElement {
-       DECLARE_SVG_INFO(Ellipse);
+    DECLARE_SVG_INFO(Ellipse);
 private:
-       SkString f_cx;
-       SkString f_cy;
-       SkString f_rx;
-       SkString f_ry;
-       typedef SkSVGElement INHERITED;
+    SkString f_cx;
+    SkString f_cy;
+    SkString f_rx;
+    SkString f_ry;
+    typedef SkSVGElement INHERITED;
 };
 
 #endif // SkSVGEllipse_DEFINED
index 46225f8..f55985a 100644 (file)
@@ -1,15 +1,32 @@
+/* libs/graphics/svg/SkSVGFeColorMatrix.cpp
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #include "SkSVGFeColorMatrix.h"
 #include "SkSVGParser.h"
 
 const SkSVGAttribute SkSVGFeColorMatrix::gAttributes[] = {
-       SVG_LITERAL_ATTRIBUTE(color-interpolation-filters, f_color_interpolation_filters),
-       SVG_ATTRIBUTE(result),
-       SVG_ATTRIBUTE(type),
-       SVG_ATTRIBUTE(values)
+    SVG_LITERAL_ATTRIBUTE(color-interpolation-filters, f_color_interpolation_filters),
+    SVG_ATTRIBUTE(result),
+    SVG_ATTRIBUTE(type),
+    SVG_ATTRIBUTE(values)
 };
 
 DEFINE_SVG_INFO(FeColorMatrix)
 
 void SkSVGFeColorMatrix::translate(SkSVGParser& parser, bool defState) {
-       INHERITED::translate(parser, defState);
+    INHERITED::translate(parser, defState);
 }
index 408c501..bb79ed9 100644 (file)
@@ -1,17 +1,34 @@
+/* libs/graphics/svg/SkSVGFeColorMatrix.h
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #ifndef SkSVGFeColorMatrix_DEFINED
 #define SkSVGFeColorMatrix_DEFINED
 
 #include "SkSVGElements.h"
 
 class SkSVGFeColorMatrix : public SkSVGElement {
-       DECLARE_SVG_INFO(FeColorMatrix);
+    DECLARE_SVG_INFO(FeColorMatrix);
 protected:
-       SkString f_color_interpolation_filters;
-       SkString f_result;
-       SkString f_type;
-       SkString f_values;
+    SkString f_color_interpolation_filters;
+    SkString f_result;
+    SkString f_type;
+    SkString f_values;
 private:
-       typedef SkSVGElement INHERITED;
+    typedef SkSVGElement INHERITED;
 };
 
 #endif // SkSVGFeColorMatrix_DEFINED
index 0463ee1..9d97f69 100644 (file)
@@ -1,16 +1,33 @@
+/* libs/graphics/svg/SkSVGFilter.cpp
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #include "SkSVGFilter.h"
 #include "SkSVGParser.h"
 
 const SkSVGAttribute SkSVGFilter::gAttributes[] = {
-       SVG_ATTRIBUTE(filterUnits),
-       SVG_ATTRIBUTE(height),
-       SVG_ATTRIBUTE(width),
-       SVG_ATTRIBUTE(x),
-       SVG_ATTRIBUTE(y)
+    SVG_ATTRIBUTE(filterUnits),
+    SVG_ATTRIBUTE(height),
+    SVG_ATTRIBUTE(width),
+    SVG_ATTRIBUTE(x),
+    SVG_ATTRIBUTE(y)
 };
 
 DEFINE_SVG_INFO(Filter)
 
 void SkSVGFilter::translate(SkSVGParser& parser, bool defState) {
-//     INHERITED::translate(parser, defState);
+//  INHERITED::translate(parser, defState);
 }
index 71bb45f..5323e1b 100644 (file)
@@ -1,18 +1,36 @@
+/* libs/graphics/svg/SkSVGFilter.h
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #ifndef SkSVGFilter_DEFINED
 #define SkSVGFilter_DEFINED
 
 #include "SkSVGElements.h"
 
 class SkSVGFilter : public SkSVGElement {
-       DECLARE_SVG_INFO(Filter);
+    DECLARE_SVG_INFO(Filter);
 protected:
-       SkString f_filterUnits;
-       SkString f_height;
-       SkString f_width;
-       SkString f_x;
-       SkString f_y;
+    SkString f_filterUnits;
+    SkString f_height;
+    SkString f_width;
+    SkString f_x;
+    SkString f_y;
 private:
-       typedef SkSVGElement INHERITED;
+    typedef SkSVGElement INHERITED;
 };
 
-#endif // SkSVGFilter_DEFINED
\ No newline at end of file
+#endif // SkSVGFilter_DEFINEDRITED;
+
index cf45054..2e2c876 100644 (file)
@@ -1,7 +1,24 @@
+/* libs/graphics/svg/SkSVGG.cpp
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #include "SkSVGG.h"
 
 DEFINE_SVG_NO_INFO(G)
 
 void SkSVGG::translate(SkSVGParser& parser, bool defState) {
-       INHERITED::translate(parser, defState);
+    INHERITED::translate(parser, defState);
 }
index 3e9e5c9..4200c2c 100644 (file)
@@ -1,12 +1,29 @@
+/* libs/graphics/svg/SkSVGG.h
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #ifndef SkSVGG_DEFINED
 #define SkSVGG_DEFINED
 
 #include "SkSVGGroup.h"
 
 class SkSVGG : public SkSVGGroup {
-       DECLARE_SVG_INFO(G);
+    DECLARE_SVG_INFO(G);
 private:
-       typedef SkSVGGroup INHERITED;
+    typedef SkSVGGroup INHERITED;
 };
 
 #endif // SkSVGG_DEFINED
index ba64c16..345a9d8 100644 (file)
@@ -1,3 +1,20 @@
+/* libs/graphics/svg/SkSVGGradient.cpp
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #include "SkSVGGradient.h"
 #include "SkSVGParser.h"
 #include "SkSVGStop.h"
@@ -6,101 +23,101 @@ SkSVGGradient::SkSVGGradient() {
 }
 
 SkSVGElement* SkSVGGradient::getGradient() {
-       return this;
+    return this;
 }
 
 bool SkSVGGradient::isDef() {
-       return true;
+    return true;
 }
 
 bool SkSVGGradient::isNotDef() {
-       return false;
+    return false;
 }
 
 void SkSVGGradient::translate(SkSVGParser& parser, bool defState) {
-       INHERITED::translate(parser, defState);
-       // !!! no support for 'objectBoundingBox' yet
-       bool first = true;
-       bool addedFirst = false;
-       bool addedLast = false;
-       SkString offsets("[");
-       SkString* lastOffset = nil;
-       for (SkSVGElement** ptr = fChildren.begin(); ptr < fChildren.end(); ptr++) {
-               SkASSERT((*ptr)->getType() == SkSVGType_Stop);
-               SkSVGStop* stop = (SkSVGStop*) *ptr;
-               if (first && stop->f_offset.equals("0") == false) {
-                       addedFirst = true;
-                       offsets.append("0,");
-               }
-               SkString* thisOffset = &stop->f_offset;
-               if (lastOffset && thisOffset->equals(*lastOffset)) {
-                       if (thisOffset->equals("1")) {
-                               offsets.remove(offsets.size() - 2, 2);
-                               offsets.append(".999,");
-                       } else {
-                               SkASSERT(0); // !!! need to write this case
-                       }
-               }
-               offsets.append(*thisOffset);
-               if (ptr == fChildren.end() - 1) { // last
-                       if (stop->f_offset.equals("1") == false) {
-                               offsets.append(",1");
-                               addedLast = true;
-                       }
-               } else
-                       offsets.appendUnichar(',');
-               first = false;
-               lastOffset = thisOffset;
-       }
-       offsets.appendUnichar(']');
-       parser._addAttribute("offsets", offsets);
-       if (addedFirst)
-               parser.translate(*fChildren.begin(), defState);
-       for (SkSVGElement** ptr = fChildren.begin(); ptr < fChildren.end(); ptr++)
-               parser.translate(*ptr, defState);
-       if (addedLast)
-               parser.translate(*(fChildren.end() - 1), defState);
+    INHERITED::translate(parser, defState);
+    // !!! no support for 'objectBoundingBox' yet
+    bool first = true;
+    bool addedFirst = false;
+    bool addedLast = false;
+    SkString offsets("[");
+    SkString* lastOffset = nil;
+    for (SkSVGElement** ptr = fChildren.begin(); ptr < fChildren.end(); ptr++) {
+        SkASSERT((*ptr)->getType() == SkSVGType_Stop);
+        SkSVGStop* stop = (SkSVGStop*) *ptr;
+        if (first && stop->f_offset.equals("0") == false) {
+            addedFirst = true;
+            offsets.append("0,");
+        }
+        SkString* thisOffset = &stop->f_offset;
+        if (lastOffset && thisOffset->equals(*lastOffset)) {
+            if (thisOffset->equals("1")) {
+                offsets.remove(offsets.size() - 2, 2);
+                offsets.append(".999,");
+            } else {
+                SkASSERT(0); // !!! need to write this case
+            }
+        }
+        offsets.append(*thisOffset);
+        if (ptr == fChildren.end() - 1) { // last
+            if (stop->f_offset.equals("1") == false) {
+                offsets.append(",1");
+                addedLast = true;
+            }
+        } else
+            offsets.appendUnichar(',');
+        first = false;
+        lastOffset = thisOffset;
+    }
+    offsets.appendUnichar(']');
+    parser._addAttribute("offsets", offsets);
+    if (addedFirst)
+        parser.translate(*fChildren.begin(), defState);
+    for (SkSVGElement** ptr = fChildren.begin(); ptr < fChildren.end(); ptr++)
+        parser.translate(*ptr, defState);
+    if (addedLast)
+        parser.translate(*(fChildren.end() - 1), defState);
 }
 
 void SkSVGGradient::translateGradientUnits(SkString& units) {
-       // !!! no support for 'objectBoundingBox' yet
-       SkASSERT(strcmp(units.c_str(), "userSpaceOnUse") == 0);
+    // !!! no support for 'objectBoundingBox' yet
+    SkASSERT(strcmp(units.c_str(), "userSpaceOnUse") == 0);
 }
 
 void SkSVGGradient::write(SkSVGParser& parser, SkString& baseColor) {
-       if (baseColor.c_str()[0] != '#')
-               return;
-       SkSVGPaint* saveHead = parser.fHead;
-       parser.fHead = &fPaintState;
-       parser.fSuppressPaint = true;
-       SkString originalID(f_id);
-       f_id.set("mask"); // write out gradient named given name + color (less initial #)
-       f_id.append(baseColor.c_str() + 1); 
-       SkString originalColors;
-       for (SkSVGElement** ptr = fChildren.begin(); ptr < fChildren.end(); ptr++) {
-               SkSVGStop* colorElement = (SkSVGStop*) *ptr;
-               SkString& color = colorElement->fPaintState.f_stopColor;
-               originalColors.append(color);
-               originalColors.appendUnichar(',');
-               SkASSERT(color.c_str()[0] == '#');
-               SkString replacement;
-               replacement.set("0x");
-               replacement.append(color.c_str() + 1, 2); // add stop colors using given color, turning existing stop color into alpha
-               SkASSERT(baseColor.c_str()[0] == '#');
-               SkASSERT(baseColor.size() == 7);
-               replacement.append(baseColor.c_str() + 1);
-               color.set(replacement);
-       }
-       translate(parser, true);
-       const char* originalPtr = originalColors.c_str(); // restore original gradient values
-       for (SkSVGElement** ptr = fChildren.begin(); ptr < fChildren.end(); ptr++) {
-               SkSVGStop* color = (SkSVGStop*) *ptr;
-               const char* originalEnd = strchr(originalPtr, ',');
-               color->fPaintState.f_stopColor.set(originalPtr, originalEnd - originalPtr);
-               originalPtr = originalEnd + 1;
-       }
-       f_id.set(originalID);
-       parser.fSuppressPaint = false;
-       parser.fHead = saveHead;
+    if (baseColor.c_str()[0] != '#')
+        return;
+    SkSVGPaint* saveHead = parser.fHead;
+    parser.fHead = &fPaintState;
+    parser.fSuppressPaint = true;
+    SkString originalID(f_id);
+    f_id.set("mask"); // write out gradient named given name + color (less initial #)
+    f_id.append(baseColor.c_str() + 1); 
+    SkString originalColors;
+    for (SkSVGElement** ptr = fChildren.begin(); ptr < fChildren.end(); ptr++) {
+        SkSVGStop* colorElement = (SkSVGStop*) *ptr;
+        SkString& color = colorElement->fPaintState.f_stopColor;
+        originalColors.append(color);
+        originalColors.appendUnichar(',');
+        SkASSERT(color.c_str()[0] == '#');
+        SkString replacement;
+        replacement.set("0x");
+        replacement.append(color.c_str() + 1, 2); // add stop colors using given color, turning existing stop color into alpha
+        SkASSERT(baseColor.c_str()[0] == '#');
+        SkASSERT(baseColor.size() == 7);
+        replacement.append(baseColor.c_str() + 1);
+        color.set(replacement);
+    }
+    translate(parser, true);
+    const char* originalPtr = originalColors.c_str(); // restore original gradient values
+    for (SkSVGElement** ptr = fChildren.begin(); ptr < fChildren.end(); ptr++) {
+        SkSVGStop* color = (SkSVGStop*) *ptr;
+        const char* originalEnd = strchr(originalPtr, ',');
+        color->fPaintState.f_stopColor.set(originalPtr, originalEnd - originalPtr);
+        originalPtr = originalEnd + 1;
+    }
+    f_id.set(originalID);
+    parser.fSuppressPaint = false;
+    parser.fHead = saveHead;
 }
 
index 25421ce..1f91b1c 100644 (file)
@@ -1,3 +1,20 @@
+/* libs/graphics/svg/SkSVGGradient.h
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #ifndef SkSVGGradient_DEFINED
 #define SkSVGGradient_DEFINED
 
 
 class SkSVGGradient : public SkSVGElement {
 public:
-       SkSVGGradient();
-       virtual SkSVGElement* getGradient();
-       virtual bool isDef();
-       virtual bool isNotDef();
-       virtual void write(SkSVGParser& , SkString& color);
+    SkSVGGradient();
+    virtual SkSVGElement* getGradient();
+    virtual bool isDef();
+    virtual bool isNotDef();
+    virtual void write(SkSVGParser& , SkString& color);
 protected:
-       void translate(SkSVGParser& , bool defState);
-       void translateGradientUnits(SkString& units);
+    void translate(SkSVGParser& , bool defState);
+    void translateGradientUnits(SkString& units);
 private:
-       typedef SkSVGElement INHERITED;
+    typedef SkSVGElement INHERITED;
 };
 
 #endif // SkSVGGradient_DEFINED
index a72dd8a..b044c4e 100644 (file)
@@ -1,36 +1,53 @@
+/* libs/graphics/svg/SkSVGGroup.cpp
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #include "SkSVGGroup.h"
 #include "SkSVGParser.h"
 
 SkSVGGroup::SkSVGGroup() {
-       fIsNotDef = false;
+    fIsNotDef = false;
 }
 
 SkSVGElement* SkSVGGroup::getGradient() {
-       for (SkSVGElement** ptr = fChildren.begin(); ptr < fChildren.end(); ptr++) {
-               SkSVGElement* result = (*ptr)->getGradient();
-               if (result != nil)
-                       return result;
-       }
-       return nil;
+    for (SkSVGElement** ptr = fChildren.begin(); ptr < fChildren.end(); ptr++) {
+        SkSVGElement* result = (*ptr)->getGradient();
+        if (result != nil)
+            return result;
+    }
+    return nil;
 }
 
 bool SkSVGGroup::isDef() {
-       return fParent ? fParent->isDef() : false;
+    return fParent ? fParent->isDef() : false;
 }
 
 bool SkSVGGroup::isFlushable() {
-       return false;
+    return false;
 }
 
 bool SkSVGGroup::isGroup() {
-       return true;
+    return true;
 }
 
 bool SkSVGGroup::isNotDef() {
-       return fParent ? fParent->isNotDef() : false;
+    return fParent ? fParent->isNotDef() : false;
 }
 
 void SkSVGGroup::translate(SkSVGParser& parser, bool defState) {
-       for (SkSVGElement** ptr = fChildren.begin(); ptr < fChildren.end(); ptr++)
-               parser.translate(*ptr, defState);
+    for (SkSVGElement** ptr = fChildren.begin(); ptr < fChildren.end(); ptr++)
+        parser.translate(*ptr, defState);
 }
index ff4c342..31fff46 100644 (file)
@@ -1,3 +1,20 @@
+/* libs/graphics/svg/SkSVGGroup.h
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #ifndef SkSVGGroup_DEFINED
 #define SkSVGGroup_DEFINED
 
 
 class SkSVGGroup : public SkSVGElement {
 public:
-       SkSVGGroup();
-       virtual SkSVGElement* getGradient();
-       virtual bool isDef();
-       virtual bool isFlushable();
-       virtual bool isGroup();
-       virtual bool isNotDef();
-       void translate(SkSVGParser& , bool defState);
+    SkSVGGroup();
+    virtual SkSVGElement* getGradient();
+    virtual bool isDef();
+    virtual bool isFlushable();
+    virtual bool isGroup();
+    virtual bool isNotDef();
+    void translate(SkSVGParser& , bool defState);
 private:
-       typedef SkSVGElement INHERITED;
+    typedef SkSVGElement INHERITED;
 };
 
 #endif // SkSVGGroup_DEFINED
index bcf8a4f..17df84d 100644 (file)
@@ -1,35 +1,52 @@
+/* libs/graphics/svg/SkSVGImage.cpp
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #include "SkSVGImage.h"
 #include "SkSVGParser.h"
 
 const SkSVGAttribute SkSVGImage::gAttributes[] = {
-       SVG_ATTRIBUTE(height),
-       SVG_ATTRIBUTE(width),
-       SVG_ATTRIBUTE(x),
-       SVG_LITERAL_ATTRIBUTE(xlink:href, f_xlink_href),
-       SVG_ATTRIBUTE(y)
+    SVG_ATTRIBUTE(height),
+    SVG_ATTRIBUTE(width),
+    SVG_ATTRIBUTE(x),
+    SVG_LITERAL_ATTRIBUTE(xlink:href, f_xlink_href),
+    SVG_ATTRIBUTE(y)
 };
 
 DEFINE_SVG_INFO(Image)
 
 void SkSVGImage::translate(SkSVGParser& parser, bool defState) {
-       parser._startElement("image");
-       INHERITED::translate(parser, defState);
-       SVG_ADD_ATTRIBUTE(x);
-       SVG_ADD_ATTRIBUTE(y);
-//     SVG_ADD_ATTRIBUTE(width);
-//     SVG_ADD_ATTRIBUTE(height);
-       translateImage(parser);
-       parser._endElement();
+    parser._startElement("image");
+    INHERITED::translate(parser, defState);
+    SVG_ADD_ATTRIBUTE(x);
+    SVG_ADD_ATTRIBUTE(y);
+//  SVG_ADD_ATTRIBUTE(width);
+//  SVG_ADD_ATTRIBUTE(height);
+    translateImage(parser);
+    parser._endElement();
 }
 
 void SkSVGImage::translateImage(SkSVGParser& parser) {
-       SkASSERT(f_xlink_href.size() > 0);
-       const char* data = f_xlink_href.c_str();
-       SkASSERT(strncmp(data, "data:image/", 11) == 0);
-       data += 11;
-       SkASSERT(strncmp(data, "png;", 4) == 0 || strncmp(data, "jpeg;", 5) == 0);
-       data = strchr(data, ';');
-       SkASSERT(strncmp(data, ";base64,", 8) == 0);
-       data += 8;
-       parser._addAttribute("base64", data);
+    SkASSERT(f_xlink_href.size() > 0);
+    const char* data = f_xlink_href.c_str();
+    SkASSERT(strncmp(data, "data:image/", 11) == 0);
+    data += 11;
+    SkASSERT(strncmp(data, "png;", 4) == 0 || strncmp(data, "jpeg;", 5) == 0);
+    data = strchr(data, ';');
+    SkASSERT(strncmp(data, ";base64,", 8) == 0);
+    data += 8;
+    parser._addAttribute("base64", data);
 }
index 3a0a2a5..9b21f69 100644 (file)
@@ -1,3 +1,20 @@
+/* libs/graphics/svg/SkSVGImage.h
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #ifndef SkSVGImage_DEFINED
 #define SkSVGImage_DEFINED
 
 
 class SkSVGImage : public SkSVGElement {
 public:
-       DECLARE_SVG_INFO(Image);
+    DECLARE_SVG_INFO(Image);
 private:
-       void translateImage(SkSVGParser& parser);
-       SkString f_height;
-       SkString f_width;
-       SkString f_x;
-       SkString f_xlink_href;
-       SkString f_y;
-       typedef SkSVGElement INHERITED;
+    void translateImage(SkSVGParser& parser);
+    SkString f_height;
+    SkString f_width;
+    SkString f_x;
+    SkString f_xlink_href;
+    SkString f_y;
+    typedef SkSVGElement INHERITED;
 };
 
 #endif // SkSVGImage_DEFINED
index 5a5e978..23cc46f 100644 (file)
@@ -1,21 +1,38 @@
+/* libs/graphics/svg/SkSVGLine.cpp
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #include "SkSVGLine.h"
 #include "SkSVGParser.h"
 
 const SkSVGAttribute SkSVGLine::gAttributes[] = {
-       SVG_ATTRIBUTE(x1),
-       SVG_ATTRIBUTE(x2),
-       SVG_ATTRIBUTE(y1),
-       SVG_ATTRIBUTE(y2)
+    SVG_ATTRIBUTE(x1),
+    SVG_ATTRIBUTE(x2),
+    SVG_ATTRIBUTE(y1),
+    SVG_ATTRIBUTE(y2)
 };
 
 DEFINE_SVG_INFO(Line)
 
 void SkSVGLine::translate(SkSVGParser& parser, bool defState) {
-       parser._startElement("line");
-       INHERITED::translate(parser, defState);
-       SVG_ADD_ATTRIBUTE(x1);
-       SVG_ADD_ATTRIBUTE(y1);
-       SVG_ADD_ATTRIBUTE(x2);
-       SVG_ADD_ATTRIBUTE(y2);
-       parser._endElement();
+    parser._startElement("line");
+    INHERITED::translate(parser, defState);
+    SVG_ADD_ATTRIBUTE(x1);
+    SVG_ADD_ATTRIBUTE(y1);
+    SVG_ADD_ATTRIBUTE(x2);
+    SVG_ADD_ATTRIBUTE(y2);
+    parser._endElement();
 }
index f7a665b..6d8b733 100644 (file)
@@ -1,16 +1,33 @@
+/* libs/graphics/svg/SkSVGLine.h
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #ifndef SkSVGLine_DEFINED
 #define SkSVGLine_DEFINED
 
 #include "SkSVGElements.h"
 
 class SkSVGLine : public SkSVGElement {
-       DECLARE_SVG_INFO(Line);
+    DECLARE_SVG_INFO(Line);
 private:
-       SkString f_x1;
-       SkString f_x2;
-       SkString f_y1;
-       SkString f_y2;
-       typedef SkSVGElement INHERITED;
+    SkString f_x1;
+    SkString f_x2;
+    SkString f_y1;
+    SkString f_y2;
+    typedef SkSVGElement INHERITED;
 };
 
 #endif // SkSVGLine_DEFINED
index 69f4823..d950cae 100644 (file)
@@ -1,35 +1,52 @@
+/* libs/graphics/svg/SkSVGLinearGradient.cpp
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #include "SkSVGLinearGradient.h"
 #include "SkSVGParser.h"
 
 const SkSVGAttribute SkSVGLinearGradient::gAttributes[] = {
-       SVG_ATTRIBUTE(gradientTransform),
-       SVG_ATTRIBUTE(gradientUnits),
-       SVG_ATTRIBUTE(x1),
-       SVG_ATTRIBUTE(x2),
-       SVG_ATTRIBUTE(y1),
-       SVG_ATTRIBUTE(y2)
+    SVG_ATTRIBUTE(gradientTransform),
+    SVG_ATTRIBUTE(gradientUnits),
+    SVG_ATTRIBUTE(x1),
+    SVG_ATTRIBUTE(x2),
+    SVG_ATTRIBUTE(y1),
+    SVG_ATTRIBUTE(y2)
 };
 
 DEFINE_SVG_INFO(LinearGradient)
 
 void SkSVGLinearGradient::translate(SkSVGParser& parser, bool defState) {
-       if (fMatrixID.size() == 0)
-               parser.translateMatrix(f_gradientTransform, &fMatrixID);
-       parser._startElement("linearGradient");
-       if (fMatrixID.size() > 0)
-               parser._addAttribute("matrix", fMatrixID);
-       INHERITED::translateGradientUnits(f_gradientUnits);
-       SkString points;
-       points.appendUnichar('[');
-       points.append(f_x1);
-       points.appendUnichar(',');
-       points.append(f_y1);
-       points.appendUnichar(',');
-       points.append(f_x2);
-       points.appendUnichar(',');
-       points.append(f_y2);
-       points.appendUnichar(']');
-       parser._addAttribute("points", points.c_str());
-       INHERITED::translate(parser, defState);
-       parser._endElement();
+    if (fMatrixID.size() == 0)
+        parser.translateMatrix(f_gradientTransform, &fMatrixID);
+    parser._startElement("linearGradient");
+    if (fMatrixID.size() > 0)
+        parser._addAttribute("matrix", fMatrixID);
+    INHERITED::translateGradientUnits(f_gradientUnits);
+    SkString points;
+    points.appendUnichar('[');
+    points.append(f_x1);
+    points.appendUnichar(',');
+    points.append(f_y1);
+    points.appendUnichar(',');
+    points.append(f_x2);
+    points.appendUnichar(',');
+    points.append(f_y2);
+    points.appendUnichar(']');
+    parser._addAttribute("points", points.c_str());
+    INHERITED::translate(parser, defState);
+    parser._endElement();
 }
index fac7aa3..96301d2 100644 (file)
@@ -1,19 +1,36 @@
+/* libs/graphics/svg/SkSVGLinearGradient.h
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #ifndef SkSVGLinearGradient_DEFINED
 #define SkSVGLinearGradient_DEFINED
 
 #include "SkSVGGradient.h"
 
 class SkSVGLinearGradient : public SkSVGGradient {
-       DECLARE_SVG_INFO(LinearGradient);
+    DECLARE_SVG_INFO(LinearGradient);
 private:
-       SkString f_gradientTransform;
-       SkString f_gradientUnits;
-       SkString f_x1;
-       SkString f_x2;
-       SkString f_y1;
-       SkString f_y2;
-       SkString fMatrixID;
-       typedef SkSVGGradient INHERITED;
+    SkString f_gradientTransform;
+    SkString f_gradientUnits;
+    SkString f_x1;
+    SkString f_x2;
+    SkString f_y1;
+    SkString f_y2;
+    SkString fMatrixID;
+    typedef SkSVGGradient INHERITED;
 };
 
 #endif // SkSVGLinearGradient_DEFINED
index cb029d4..dfc9ebf 100644 (file)
@@ -1,24 +1,41 @@
+/* libs/graphics/svg/SkSVGMask.cpp
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #include "SkSVGMask.h"
 #include "SkSVGParser.h"
 
 const SkSVGAttribute SkSVGMask::gAttributes[] = {
-       SVG_ATTRIBUTE(height),
-       SVG_ATTRIBUTE(maskUnits),
-       SVG_ATTRIBUTE(width),
-       SVG_ATTRIBUTE(x),
-       SVG_ATTRIBUTE(y)
+    SVG_ATTRIBUTE(height),
+    SVG_ATTRIBUTE(maskUnits),
+    SVG_ATTRIBUTE(width),
+    SVG_ATTRIBUTE(x),
+    SVG_ATTRIBUTE(y)
 };
 
 DEFINE_SVG_INFO(Mask)
 
 bool SkSVGMask::isDef() {
-       return false;
+    return false;
 }
 
 bool SkSVGMask::isNotDef() {
-       return false;
+    return false;
 }
 
 void SkSVGMask::translate(SkSVGParser& parser, bool defState) {
-       INHERITED::translate(parser, defState);
+    INHERITED::translate(parser, defState);
 }
index 632061e..6a2f3c3 100644 (file)
@@ -1,20 +1,37 @@
+/* libs/graphics/svg/SkSVGMask.h
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #ifndef SkSVGMask_DEFINED
 #define SkSVGMask_DEFINED
 
 #include "SkSVGGroup.h"
 
 class SkSVGMask : public SkSVGGroup {
-       DECLARE_SVG_INFO(Mask);
-       virtual bool isDef();
-       virtual bool isNotDef();
+    DECLARE_SVG_INFO(Mask);
+    virtual bool isDef();
+    virtual bool isNotDef();
 protected:
-       SkString f_height;
-       SkString f_maskUnits;
-       SkString f_width;
-       SkString f_x;
-       SkString f_y;
+    SkString f_height;
+    SkString f_maskUnits;
+    SkString f_width;
+    SkString f_x;
+    SkString f_y;
 private:
-       typedef SkSVGGroup INHERITED;
+    typedef SkSVGGroup INHERITED;
 };
 
 #endif // SkSVGMask_DEFINED
index 3dd8e35..9c305e4 100644 (file)
@@ -1,14 +1,31 @@
+/* libs/graphics/svg/SkSVGMetadata.cpp
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #include "SkSVGMetadata.h"
 #include "SkSVGParser.h"
 
 DEFINE_SVG_NO_INFO(Metadata)
 
 bool SkSVGMetadata::isDef() {
-       return false;
+    return false;
 }
 
 bool SkSVGMetadata::isNotDef() {
-       return false;
+    return false;
 }
 
 void SkSVGMetadata::translate(SkSVGParser& parser, bool defState) {
index c8d0232..8fb42a8 100644 (file)
@@ -1,14 +1,31 @@
+/* libs/graphics/svg/SkSVGMetadata.h
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #ifndef SkSVGMetadata_DEFINED
 #define SkSVGMetadata_DEFINED
 
 #include "SkSVGElements.h"
 
 class SkSVGMetadata : public SkSVGElement {
-       DECLARE_SVG_INFO(Metadata);
-       virtual bool isDef();
-       virtual bool isNotDef();
+    DECLARE_SVG_INFO(Metadata);
+    virtual bool isDef();
+    virtual bool isNotDef();
 private:
-       typedef SkSVGElement INHERITED;
+    typedef SkSVGElement INHERITED;
 };
 
 #endif // SkSVGMetadata_DEFINED
index 50ba21d..eee9f72 100644 (file)
@@ -1,30 +1,47 @@
+/* libs/graphics/svg/SkSVGPaintState.cpp
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #include "SkSVGPaintState.h"
 #include "SkSVGElements.h"
 #include "SkSVGParser.h"
 #include "SkParse.h"
 
 SkSVGAttribute SkSVGPaint::gAttributes[] = {
-       SVG_LITERAL_ATTRIBUTE(clip-path, f_clipPath),
-       SVG_LITERAL_ATTRIBUTE(clip-rule, f_clipRule),
-       SVG_LITERAL_ATTRIBUTE(enable-background, f_enableBackground),
-       SVG_ATTRIBUTE(fill),
-       SVG_LITERAL_ATTRIBUTE(fill-rule, f_fillRule),
-       SVG_ATTRIBUTE(filter),
-       SVG_LITERAL_ATTRIBUTE(font-family, f_fontFamily),
-       SVG_LITERAL_ATTRIBUTE(font-size, f_fontSize),
-       SVG_LITERAL_ATTRIBUTE(letter-spacing, f_letterSpacing),
-       SVG_ATTRIBUTE(mask),
-       SVG_ATTRIBUTE(opacity),
-       SVG_LITERAL_ATTRIBUTE(stop-color, f_stopColor),
-       SVG_LITERAL_ATTRIBUTE(stop-opacity, f_stopOpacity),
-       SVG_ATTRIBUTE(stroke),
-       SVG_LITERAL_ATTRIBUTE(stroke-dasharray, f_strokeDasharray),
-       SVG_LITERAL_ATTRIBUTE(stroke-linecap, f_strokeLinecap),
-       SVG_LITERAL_ATTRIBUTE(stroke-linejoin, f_strokeLinejoin),
-       SVG_LITERAL_ATTRIBUTE(stroke-miterlimit, f_strokeMiterlimit),
-       SVG_LITERAL_ATTRIBUTE(stroke-width, f_strokeWidth),
-       SVG_ATTRIBUTE(style),
-       SVG_ATTRIBUTE(transform)
+    SVG_LITERAL_ATTRIBUTE(clip-path, f_clipPath),
+    SVG_LITERAL_ATTRIBUTE(clip-rule, f_clipRule),
+    SVG_LITERAL_ATTRIBUTE(enable-background, f_enableBackground),
+    SVG_ATTRIBUTE(fill),
+    SVG_LITERAL_ATTRIBUTE(fill-rule, f_fillRule),
+    SVG_ATTRIBUTE(filter),
+    SVG_LITERAL_ATTRIBUTE(font-family, f_fontFamily),
+    SVG_LITERAL_ATTRIBUTE(font-size, f_fontSize),
+    SVG_LITERAL_ATTRIBUTE(letter-spacing, f_letterSpacing),
+    SVG_ATTRIBUTE(mask),
+    SVG_ATTRIBUTE(opacity),
+    SVG_LITERAL_ATTRIBUTE(stop-color, f_stopColor),
+    SVG_LITERAL_ATTRIBUTE(stop-opacity, f_stopOpacity),
+    SVG_ATTRIBUTE(stroke),
+    SVG_LITERAL_ATTRIBUTE(stroke-dasharray, f_strokeDasharray),
+    SVG_LITERAL_ATTRIBUTE(stroke-linecap, f_strokeLinecap),
+    SVG_LITERAL_ATTRIBUTE(stroke-linejoin, f_strokeLinejoin),
+    SVG_LITERAL_ATTRIBUTE(stroke-miterlimit, f_strokeMiterlimit),
+    SVG_LITERAL_ATTRIBUTE(stroke-width, f_strokeWidth),
+    SVG_ATTRIBUTE(style),
+    SVG_ATTRIBUTE(transform)
 };
 
 const int SkSVGPaint::kAttributesSize = SK_ARRAY_COUNT(SkSVGPaint::gAttributes);
@@ -33,414 +50,414 @@ SkSVGPaint::SkSVGPaint() : fNext(nil) {
 }
 
 SkString* SkSVGPaint::operator[](int index) {
-       SkASSERT(index >= 0);
-       SkASSERT(index < &fTerminal - &fInitial);
-       SkASSERT(&fTerminal - &fInitial == kTerminal - kInitial);
-       SkString* result = &fInitial + index + 1;
-       return result;
+    SkASSERT(index >= 0);
+    SkASSERT(index < &fTerminal - &fInitial);
+    SkASSERT(&fTerminal - &fInitial == kTerminal - kInitial);
+    SkString* result = &fInitial + index + 1;
+    return result;
 }
 
 void SkSVGPaint::addAttribute(SkSVGParser& parser, int attrIndex, 
-               const char* attrValue, size_t attrLength) {
-       SkString* attr = (*this)[attrIndex];
-       switch(attrIndex) {
-               case kClipPath:
-               case kClipRule:
-               case kEnableBackground:
-               case kFill:
-               case kFillRule:
-               case kFilter:
-               case kFontFamily:
-               case kFontSize:
-               case kLetterSpacing:
-               case kMask:
-               case kOpacity:
-               case kStopColor:
-               case kStopOpacity:
-               case kStroke:
-               case kStroke_Dasharray:
-               case kStroke_Linecap:
-               case kStroke_Linejoin:
-               case kStroke_Miterlimit:
-               case kStroke_Width:
-               case kTransform:
-                       attr->set(attrValue, attrLength);
-                       return;
-               case kStyle: {
-                       // iterate through colon / semi-colon delimited pairs
-                       int pairs = SkParse::Count(attrValue, ';');
-                       const char* attrEnd = attrValue + attrLength;
-                       do {
-                               const char* end = strchr(attrValue, ';');
-                               if (end == nil)
-                                       end = attrEnd;
-                               const char* delimiter = strchr(attrValue, ':');
-                               SkASSERT(delimiter != 0 && delimiter < end);
-                               int index = parser.findAttribute(this, attrValue, (int) (delimiter - attrValue), true);
-                               SkASSERT(index >= 0);
-                               delimiter++;
-                               addAttribute(parser, index, delimiter, (int) (end - delimiter));
-                               attrValue = end + 1;
-                       } while (--pairs);
-                       return;
-                       }
-               default:
-                       SkASSERT(0);
-       }
+        const char* attrValue, size_t attrLength) {
+    SkString* attr = (*this)[attrIndex];
+    switch(attrIndex) {
+        case kClipPath:
+        case kClipRule:
+        case kEnableBackground:
+        case kFill:
+        case kFillRule:
+        case kFilter:
+        case kFontFamily:
+        case kFontSize:
+        case kLetterSpacing:
+        case kMask:
+        case kOpacity:
+        case kStopColor:
+        case kStopOpacity:
+        case kStroke:
+        case kStroke_Dasharray:
+        case kStroke_Linecap:
+        case kStroke_Linejoin:
+        case kStroke_Miterlimit:
+        case kStroke_Width:
+        case kTransform:
+            attr->set(attrValue, attrLength);
+            return;
+        case kStyle: {
+            // iterate through colon / semi-colon delimited pairs
+            int pairs = SkParse::Count(attrValue, ';');
+            const char* attrEnd = attrValue + attrLength;
+            do {
+                const char* end = strchr(attrValue, ';');
+                if (end == nil)
+                    end = attrEnd;
+                const char* delimiter = strchr(attrValue, ':');
+                SkASSERT(delimiter != 0 && delimiter < end);
+                int index = parser.findAttribute(this, attrValue, (int) (delimiter - attrValue), true);
+                SkASSERT(index >= 0);
+                delimiter++;
+                addAttribute(parser, index, delimiter, (int) (end - delimiter));
+                attrValue = end + 1;
+            } while (--pairs);
+            return;
+            }
+        default:
+            SkASSERT(0);
+    }
 }
 
 bool SkSVGPaint::flush(SkSVGParser& parser, bool isFlushable, bool isDef) {
-       SkSVGPaint current;
-       SkSVGPaint* walking = parser.fHead;
-       int index;
-       while (walking != nil) {
-               for (index = kInitial + 1; index < kTerminal; index++) {
-                       SkString* lastAttr = (*walking)[index];
-                       if (lastAttr->size() == 0)
-                               continue;
-                       if (current[index]->size() > 0)
-                               continue;
-                       current[index]->set(*lastAttr);
-               }
-               walking = walking->fNext;
-       }
-       bool paintChanged = false;
-       SkSVGPaint& lastState = parser.fLastFlush;
-       if (isFlushable == false) {
-               if (isDef == true) {
-                       if (current.f_mask.size() > 0 && current.f_mask.equals(lastState.f_mask) == false) {
-                               SkSVGElement* found;
-                               const char* idStart = strchr(current.f_mask.c_str(), '#');
-                               SkASSERT(idStart);
-                               SkString id(idStart + 1, strlen(idStart) - 2);
-                               bool itsFound = parser.fIDs.find(id.c_str(), &found);
-                               SkASSERT(itsFound);
-                               SkSVGElement* gradient = found->getGradient();
-                               if (gradient) {
-                                       gradient->write(parser, current.f_fill);
-                                       gradient->write(parser, current.f_stroke);
-                               }
-                       }
-               }
-               goto setLast;
-       }
-       {
-               bool changed[kTerminal];
-               memset(changed, 0, sizeof(changed));
-               for (index = kInitial + 1; index < kTerminal; index++) {
-                       if (index == kTransform || index == kClipPath || index == kStopColor || index == kStopOpacity ||
-                                       index == kClipRule || index == kFillRule)
-                               continue;
-                       SkString* lastAttr = lastState[index];
-                       SkString* currentAttr = current[index];
-                       paintChanged |= changed[index] = lastAttr->equals(*currentAttr) == false;
-               }
-               if (paintChanged) {
-                       if (current.f_mask.size() > 0) {
-                               if (current.f_fill.equals("none") == false && strncmp(current.f_fill.c_str(), "url(#", 5) != 0) {
-                                       SkASSERT(current.f_fill.c_str()[0] == '#');
-                                       SkString replacement("url(#mask");
-                                       replacement.append(current.f_fill.c_str() + 1);
-                                       replacement.appendUnichar(')');
-                                       current.f_fill.set(replacement);
-                               }
-                               if (current.f_stroke.equals("none") == false && strncmp(current.f_stroke.c_str(), "url(#", 5) != 0) {
-                                       SkASSERT(current.f_stroke.c_str()[0] == '#');
-                                       SkString replacement("url(#mask");
-                                       replacement.append(current.f_stroke.c_str() + 1);
-                                       replacement.appendUnichar(')');
-                                       current.f_stroke.set(replacement);
-                               }
-                       }
-                       if (current.f_fill.equals("none") && current.f_stroke.equals("none"))
-                               current.f_opacity.set("0");
-                       if (parser.fSuppressPaint == false) {
-                               parser._startElement("paint");
-                               bool success = writeChangedAttributes(parser, current, changed);
-                               if (success == false)
-                                       return paintChanged;
-                               success = writeChangedElements(parser, current, changed);
-                               if (success == false)
-                                       return paintChanged;
-                               parser._endElement(); // paint
-                       }
-               }
-       }
+    SkSVGPaint current;
+    SkSVGPaint* walking = parser.fHead;
+    int index;
+    while (walking != nil) {
+        for (index = kInitial + 1; index < kTerminal; index++) {
+            SkString* lastAttr = (*walking)[index];
+            if (lastAttr->size() == 0)
+                continue;
+            if (current[index]->size() > 0)
+                continue;
+            current[index]->set(*lastAttr);
+        }
+        walking = walking->fNext;
+    }
+    bool paintChanged = false;
+    SkSVGPaint& lastState = parser.fLastFlush;
+    if (isFlushable == false) {
+        if (isDef == true) {
+            if (current.f_mask.size() > 0 && current.f_mask.equals(lastState.f_mask) == false) {
+                SkSVGElement* found;
+                const char* idStart = strchr(current.f_mask.c_str(), '#');
+                SkASSERT(idStart);
+                SkString id(idStart + 1, strlen(idStart) - 2);
+                bool itsFound = parser.fIDs.find(id.c_str(), &found);
+                SkASSERT(itsFound);
+                SkSVGElement* gradient = found->getGradient();
+                if (gradient) {
+                    gradient->write(parser, current.f_fill);
+                    gradient->write(parser, current.f_stroke);
+                }
+            }
+        }
+        goto setLast;
+    }
+    {
+        bool changed[kTerminal];
+        memset(changed, 0, sizeof(changed));
+        for (index = kInitial + 1; index < kTerminal; index++) {
+            if (index == kTransform || index == kClipPath || index == kStopColor || index == kStopOpacity ||
+                    index == kClipRule || index == kFillRule)
+                continue;
+            SkString* lastAttr = lastState[index];
+            SkString* currentAttr = current[index];
+            paintChanged |= changed[index] = lastAttr->equals(*currentAttr) == false;
+        }
+        if (paintChanged) {
+            if (current.f_mask.size() > 0) {
+                if (current.f_fill.equals("none") == false && strncmp(current.f_fill.c_str(), "url(#", 5) != 0) {
+                    SkASSERT(current.f_fill.c_str()[0] == '#');
+                    SkString replacement("url(#mask");
+                    replacement.append(current.f_fill.c_str() + 1);
+                    replacement.appendUnichar(')');
+                    current.f_fill.set(replacement);
+                }
+                if (current.f_stroke.equals("none") == false && strncmp(current.f_stroke.c_str(), "url(#", 5) != 0) {
+                    SkASSERT(current.f_stroke.c_str()[0] == '#');
+                    SkString replacement("url(#mask");
+                    replacement.append(current.f_stroke.c_str() + 1);
+                    replacement.appendUnichar(')');
+                    current.f_stroke.set(replacement);
+                }
+            }
+            if (current.f_fill.equals("none") && current.f_stroke.equals("none"))
+                current.f_opacity.set("0");
+            if (parser.fSuppressPaint == false) {
+                parser._startElement("paint");
+                bool success = writeChangedAttributes(parser, current, changed);
+                if (success == false)
+                    return paintChanged;
+                success = writeChangedElements(parser, current, changed);
+                if (success == false)
+                    return paintChanged;
+                parser._endElement(); // paint
+            }
+        }
+    }
 setLast:
-       for (index = kInitial + 1; index < kTerminal; index++) {
-               SkString* lastAttr = lastState[index];
-               SkString* currentAttr = current[index];
-               lastAttr->set(*currentAttr);
-       }
-       return paintChanged;
+    for (index = kInitial + 1; index < kTerminal; index++) {
+        SkString* lastAttr = lastState[index];
+        SkString* currentAttr = current[index];
+        lastAttr->set(*currentAttr);
+    }
+    return paintChanged;
 }
 
 int SkSVGPaint::getAttributes(const SkSVGAttribute** attrPtr) {
-       *attrPtr = gAttributes;
-       return kAttributesSize;
+    *attrPtr = gAttributes;
+    return kAttributesSize;
 }
 
 void SkSVGPaint::setSave(SkSVGParser& parser) {
-       SkTDArray<SkString*> clips;
-       SkSVGPaint* walking = parser.fHead;
-       int index;
-       SkMatrix sum;
-       sum.reset();
-       while (walking != nil) {
-               for (index = kInitial + 1; index < kTerminal; index++) {
-                       SkString* lastAttr = (*walking)[index];
-                       if (lastAttr->size() == 0)
-                               continue;
-                       if (index == kTransform) {
-                               const char* str = lastAttr->c_str();
-                               SkASSERT(strncmp(str, "matrix(", 7) == 0);
-                               str += 6;
-                               const char* strEnd = strrchr(str, ')');
-                               SkASSERT(strEnd != nil);
-                               SkString mat(str, strEnd - str);
-                               SkSVGParser::ConvertToArray(mat);
-                               SkScalar values[6];
-                               SkParse::FindScalars(mat.c_str() + 1, values, 6);
-                               SkMatrix matrix;
-                               matrix.reset();
-                               matrix.setScaleX(values[0]);
-                               matrix.setSkewY(values[1]);
-                               matrix.setSkewX(values[2]);
-                               matrix.setScaleY(values[3]);
-                               matrix.setTranslateX(values[4]);
-                               matrix.setTranslateY(values[5]);
-                               sum.setConcat(matrix, sum);
-                               continue;
-                       }
-                       if ( index == kClipPath) 
-                               *clips.insert(0) = lastAttr;
-               }
-               walking = walking->fNext;
-       }
-       if ((sum == parser.fLastTransform) == false) {
-               SkMatrix inverse;
-               bool success = parser.fLastTransform.invert(&inverse);
-               SkASSERT(success == true);
-               SkMatrix output;
-               output.setConcat(inverse, sum);
-               parser.fLastTransform = sum;
-               SkString outputStr;
-               outputStr.appendUnichar('[');
-               outputStr.appendScalar(output.getScaleX());
-               outputStr.appendUnichar(',');
-               outputStr.appendScalar(output.getSkewX());
-               outputStr.appendUnichar(',');
-               outputStr.appendScalar(output.getTranslateX());
-               outputStr.appendUnichar(',');
-               outputStr.appendScalar(output.getSkewY());
-               outputStr.appendUnichar(',');
-               outputStr.appendScalar(output.getScaleY());
-               outputStr.appendUnichar(',');
-               outputStr.appendScalar(output.getTranslateY());
-               outputStr.appendUnichar(',');
-               outputStr.appendScalar(output.getPerspX());
-               outputStr.appendUnichar(',');
-               outputStr.appendScalar(output.getPerspY());
-               outputStr.append(",1]");
-               parser._startElement("matrix");
-               parser._addAttributeLen("matrix", outputStr.c_str(), outputStr.size());
-               parser._endElement();
-       }
-#if 0  // incomplete
-       if (parser.fTransformClips.size() > 0) {
-               // need to reset the clip when the 'g' scope is ended
-               parser._startElement("add");
-               const char* start = strchr(current->f_clipPath.c_str(), '#') + 1;
-               SkASSERT(start);
-               parser._addAttributeLen("use", start, strlen(start) - 1);
-               parser._endElement();   // clip
-       }
+    SkTDArray<SkString*> clips;
+    SkSVGPaint* walking = parser.fHead;
+    int index;
+    SkMatrix sum;
+    sum.reset();
+    while (walking != nil) {
+        for (index = kInitial + 1; index < kTerminal; index++) {
+            SkString* lastAttr = (*walking)[index];
+            if (lastAttr->size() == 0)
+                continue;
+            if (index == kTransform) {
+                const char* str = lastAttr->c_str();
+                SkASSERT(strncmp(str, "matrix(", 7) == 0);
+                str += 6;
+                const char* strEnd = strrchr(str, ')');
+                SkASSERT(strEnd != nil);
+                SkString mat(str, strEnd - str);
+                SkSVGParser::ConvertToArray(mat);
+                SkScalar values[6];
+                SkParse::FindScalars(mat.c_str() + 1, values, 6);
+                SkMatrix matrix;
+                matrix.reset();
+                matrix.setScaleX(values[0]);
+                matrix.setSkewY(values[1]);
+                matrix.setSkewX(values[2]);
+                matrix.setScaleY(values[3]);
+                matrix.setTranslateX(values[4]);
+                matrix.setTranslateY(values[5]);
+                sum.setConcat(matrix, sum);
+                continue;
+            }
+            if ( index == kClipPath) 
+                *clips.insert(0) = lastAttr;
+        }
+        walking = walking->fNext;
+    }
+    if ((sum == parser.fLastTransform) == false) {
+        SkMatrix inverse;
+        bool success = parser.fLastTransform.invert(&inverse);
+        SkASSERT(success == true);
+        SkMatrix output;
+        output.setConcat(inverse, sum);
+        parser.fLastTransform = sum;
+        SkString outputStr;
+        outputStr.appendUnichar('[');
+        outputStr.appendScalar(output.getScaleX());
+        outputStr.appendUnichar(',');
+        outputStr.appendScalar(output.getSkewX());
+        outputStr.appendUnichar(',');
+        outputStr.appendScalar(output.getTranslateX());
+        outputStr.appendUnichar(',');
+        outputStr.appendScalar(output.getSkewY());
+        outputStr.appendUnichar(',');
+        outputStr.appendScalar(output.getScaleY());
+        outputStr.appendUnichar(',');
+        outputStr.appendScalar(output.getTranslateY());
+        outputStr.appendUnichar(',');
+        outputStr.appendScalar(output.getPerspX());
+        outputStr.appendUnichar(',');
+        outputStr.appendScalar(output.getPerspY());
+        outputStr.append(",1]");
+        parser._startElement("matrix");
+        parser._addAttributeLen("matrix", outputStr.c_str(), outputStr.size());
+        parser._endElement();
+    }
+#if 0   // incomplete
+    if (parser.fTransformClips.size() > 0) {
+        // need to reset the clip when the 'g' scope is ended
+        parser._startElement("add");
+        const char* start = strchr(current->f_clipPath.c_str(), '#') + 1;
+        SkASSERT(start);
+        parser._addAttributeLen("use", start, strlen(start) - 1);
+        parser._endElement();   // clip
+    }
 #endif
 }
 
 bool SkSVGPaint::writeChangedAttributes(SkSVGParser& parser, 
-               SkSVGPaint& current, bool* changed) {
-       SkSVGPaint& lastState = parser.fLastFlush;
-       for (int index = kInitial + 1; index < kTerminal; index++) {
-               if (changed[index] == false)
-                               continue;
-               SkString* topAttr = current[index];
-               size_t attrLength = topAttr->size();
-               if (attrLength == 0)
-                       continue;
-               const char* attrValue = topAttr->c_str();
-               SkString* lastAttr = lastState[index];
-               switch(index) {
-                       case kClipPath:
-                       case kClipRule:
-                       case kEnableBackground:
-                               break;
-                       case kFill:
-                               if (topAttr->equals("none") == false && lastAttr->equals("none") == true) 
-                                       parser._addAttribute("stroke", "false");
-                               goto fillStrokeAttrCommon;
-                       case kFillRule:
-                       case kFilter:
-                       case kFontFamily:
-                               break;
-                       case kFontSize:
-                               parser._addAttributeLen("textSize", attrValue, attrLength);
-                               break;
-                       case kLetterSpacing:
-                               parser._addAttributeLen("textTracking", attrValue, attrLength);
-                               break;
-                       case kMask:
-                               break;
-                       case kOpacity:
-                               break;
-                       case kStopColor:
-                               break;
-                       case kStopOpacity:
-                               break;
-                       case kStroke:
-                               if (topAttr->equals("none") == false && lastAttr->equals("none") == true) 
-                                       parser._addAttribute("stroke", "true");
+        SkSVGPaint& current, bool* changed) {
+    SkSVGPaint& lastState = parser.fLastFlush;
+    for (int index = kInitial + 1; index < kTerminal; index++) {
+        if (changed[index] == false)
+                continue;
+        SkString* topAttr = current[index];
+        size_t attrLength = topAttr->size();
+        if (attrLength == 0)
+            continue;
+        const char* attrValue = topAttr->c_str();
+        SkString* lastAttr = lastState[index];
+        switch(index) {
+            case kClipPath:
+            case kClipRule:
+            case kEnableBackground:
+                break;
+            case kFill:
+                if (topAttr->equals("none") == false && lastAttr->equals("none") == true) 
+                    parser._addAttribute("stroke", "false");
+                goto fillStrokeAttrCommon;
+            case kFillRule:
+            case kFilter:
+            case kFontFamily:
+                break;
+            case kFontSize:
+                parser._addAttributeLen("textSize", attrValue, attrLength);
+                break;
+            case kLetterSpacing:
+                parser._addAttributeLen("textTracking", attrValue, attrLength);
+                break;
+            case kMask:
+                break;
+            case kOpacity:
+                break;
+            case kStopColor:
+                break;
+            case kStopOpacity:
+                break;
+            case kStroke:
+                if (topAttr->equals("none") == false && lastAttr->equals("none") == true) 
+                    parser._addAttribute("stroke", "true");
 fillStrokeAttrCommon:
-                               if (strncmp(attrValue, "url(", 4) == 0) {
-                                       SkASSERT(attrValue[4] == '#');
-                                       const char* idStart = attrValue + 5;
-                                       char* idEnd = strrchr(attrValue, ')');
-                                       SkASSERT(idStart < idEnd);
-                                       SkString id(idStart, idEnd - idStart);
-                                       SkSVGElement* found;
-                                       if (strncmp(id.c_str(), "mask", 4) != 0) {
-                                               bool itsFound = parser.fIDs.find(id.c_str(), &found);
-                                               SkASSERT(itsFound);
-                                               SkASSERT(found->getType() == SkSVGType_LinearGradient ||
-                                                       found->getType() == SkSVGType_RadialGradient);
-                                       }
-                                       parser._addAttribute("shader", id.c_str());
-                               }
-                               break;
-                       case kStroke_Dasharray:
-                               break;
-                       case kStroke_Linecap:
-                               parser._addAttributeLen("strokeCap", attrValue, attrLength);
-                               break;
-                       case kStroke_Linejoin:
-                               parser._addAttributeLen("strokeJoin", attrValue, attrLength);
-                               break;
-                       case kStroke_Miterlimit:
-                               parser._addAttributeLen("strokeMiter", attrValue, attrLength);
-                               break;
-                       case kStroke_Width:
-                               parser._addAttributeLen("strokeWidth", attrValue, attrLength);
-                       case kStyle:
-                       case kTransform:
-                               break;
-               default:
-                       SkASSERT(0);
-                       return false;
-               }
-       }
-       return true;
+                if (strncmp(attrValue, "url(", 4) == 0) {
+                    SkASSERT(attrValue[4] == '#');
+                    const char* idStart = attrValue + 5;
+                    char* idEnd = strrchr(attrValue, ')');
+                    SkASSERT(idStart < idEnd);
+                    SkString id(idStart, idEnd - idStart);
+                    SkSVGElement* found;
+                    if (strncmp(id.c_str(), "mask", 4) != 0) {
+                        bool itsFound = parser.fIDs.find(id.c_str(), &found);
+                        SkASSERT(itsFound);
+                        SkASSERT(found->getType() == SkSVGType_LinearGradient ||
+                            found->getType() == SkSVGType_RadialGradient);
+                    }
+                    parser._addAttribute("shader", id.c_str());
+                }
+                break;
+            case kStroke_Dasharray:
+                break;
+            case kStroke_Linecap:
+                parser._addAttributeLen("strokeCap", attrValue, attrLength);
+                break;
+            case kStroke_Linejoin:
+                parser._addAttributeLen("strokeJoin", attrValue, attrLength);
+                break;
+            case kStroke_Miterlimit:
+                parser._addAttributeLen("strokeMiter", attrValue, attrLength);
+                break;
+            case kStroke_Width:
+                parser._addAttributeLen("strokeWidth", attrValue, attrLength);
+            case kStyle:
+            case kTransform:
+                break;
+        default:
+            SkASSERT(0);
+            return false;
+        }
+    }
+    return true;
 }
 
 bool SkSVGPaint::writeChangedElements(SkSVGParser& parser,
-               SkSVGPaint& current, bool* changed) {
-       SkSVGPaint& lastState = parser.fLastFlush;
-       for (int index = kInitial + 1; index < kTerminal; index++) {
-               SkString* topAttr = current[index];
-               size_t attrLength = topAttr->size();
-               if (attrLength == 0)
-                       continue;
-               const char* attrValue = topAttr->c_str();
-               SkString* lastAttr = lastState[index];
-               switch(index) {
-                       case kClipPath:
-                       case kClipRule:
-                               // !!! need to add this outside of paint
-                               break;
-                       case kEnableBackground:
-                               // !!! don't know what to do with this
-                               break;
-                       case kFill:
-                               goto addColor;
-                       case kFillRule:
-                       case kFilter:
-                               break;
-                       case kFontFamily:
-                               parser._startElement("typeface");
-                               parser._addAttributeLen("fontName", attrValue, attrLength);
-                               parser._endElement();   // typeface
-                               break;
-                       case kFontSize:
-                       case kLetterSpacing:
-                               break;
-                       case kMask:
-                       case kOpacity:
-                               if (changed[kStroke] == false && changed[kFill] == false) {
-                                       parser._startElement("color");
-                                       SkString& opacity = current.f_opacity;
-                                       parser._addAttributeLen("color", parser.fLastColor.c_str(), parser.fLastColor.size());
-                                       parser._addAttributeLen("alpha", opacity.c_str(), opacity.size());
-                                       parser._endElement();   // color
-                               }
-                               break;
-                       case kStopColor:
-                               break;
-                       case kStopOpacity:
-                               break;
-                       case kStroke:
+        SkSVGPaint& current, bool* changed) {
+    SkSVGPaint& lastState = parser.fLastFlush;
+    for (int index = kInitial + 1; index < kTerminal; index++) {
+        SkString* topAttr = current[index];
+        size_t attrLength = topAttr->size();
+        if (attrLength == 0)
+            continue;
+        const char* attrValue = topAttr->c_str();
+        SkString* lastAttr = lastState[index];
+        switch(index) {
+            case kClipPath:
+            case kClipRule:
+                // !!! need to add this outside of paint
+                break;
+            case kEnableBackground:
+                // !!! don't know what to do with this
+                break;
+            case kFill:
+                goto addColor;
+            case kFillRule:
+            case kFilter:
+                break;
+            case kFontFamily:
+                parser._startElement("typeface");
+                parser._addAttributeLen("fontName", attrValue, attrLength);
+                parser._endElement();   // typeface
+                break;
+            case kFontSize:
+            case kLetterSpacing:
+                break;
+            case kMask:
+            case kOpacity:
+                if (changed[kStroke] == false && changed[kFill] == false) {
+                    parser._startElement("color");
+                    SkString& opacity = current.f_opacity;
+                    parser._addAttributeLen("color", parser.fLastColor.c_str(), parser.fLastColor.size());
+                    parser._addAttributeLen("alpha", opacity.c_str(), opacity.size());
+                    parser._endElement();   // color
+                }
+                break;
+            case kStopColor:
+                break;
+            case kStopOpacity:
+                break;
+            case kStroke:
 addColor:
-                               if (strncmp(lastAttr->c_str(), "url(", 4) == 0 && strncmp(attrValue, "url(", 4) != 0) {
-                                       parser._startElement("shader");
-                                       parser._endElement();
-                               }
-                               if (topAttr->equals(*lastAttr))
-                                       continue;
-                               {
-                                       bool urlRef = strncmp(attrValue, "url(", 4) == 0;
-                                       bool colorNone = strcmp(attrValue, "none") == 0;
-                                       bool lastEqual = parser.fLastColor.equals(attrValue, attrLength);
-                                       bool newColor = urlRef == false && colorNone == false && lastEqual == false;
-                                       if (newColor || changed[kOpacity]) {
-                                               parser._startElement("color");
-                                               if (newColor || changed[kOpacity]) {
-                                                       parser._addAttributeLen("color", attrValue, attrLength);
-                                                       parser.fLastColor.set(attrValue, attrLength);
-                                               }
-                                               if (changed[kOpacity]) {
-                                                       SkString& opacity = current.f_opacity;
-                                                       parser._addAttributeLen("alpha", opacity.c_str(), opacity.size());
-                                               }
-                                               parser._endElement();   // color
-                                       }
-                               }
-                               break;
-                       case kStroke_Dasharray:
-                               parser._startElement("dash");
-                               SkSVGParser::ConvertToArray(*topAttr);
-                               parser._addAttribute("intervals", topAttr->c_str());
-                               parser._endElement();   // dash
-                       break;
-                       case kStroke_Linecap:
-                       case kStroke_Linejoin:
-                       case kStroke_Miterlimit:
-                       case kStroke_Width:
-                       case kStyle:
-                       case kTransform:
-                               break;
-               default:
-                       SkASSERT(0);
-                       return false;
-               }
-       }
-       return true;
+                if (strncmp(lastAttr->c_str(), "url(", 4) == 0 && strncmp(attrValue, "url(", 4) != 0) {
+                    parser._startElement("shader");
+                    parser._endElement();
+                }
+                if (topAttr->equals(*lastAttr))
+                    continue;
+                {
+                    bool urlRef = strncmp(attrValue, "url(", 4) == 0;
+                    bool colorNone = strcmp(attrValue, "none") == 0;
+                    bool lastEqual = parser.fLastColor.equals(attrValue, attrLength);
+                    bool newColor = urlRef == false && colorNone == false && lastEqual == false;
+                    if (newColor || changed[kOpacity]) {
+                        parser._startElement("color");
+                        if (newColor || changed[kOpacity]) {
+                            parser._addAttributeLen("color", attrValue, attrLength);
+                            parser.fLastColor.set(attrValue, attrLength);
+                        }
+                        if (changed[kOpacity]) {
+                            SkString& opacity = current.f_opacity;
+                            parser._addAttributeLen("alpha", opacity.c_str(), opacity.size());
+                        }
+                        parser._endElement();   // color
+                    }
+                }
+                break;
+            case kStroke_Dasharray:
+                parser._startElement("dash");
+                SkSVGParser::ConvertToArray(*topAttr);
+                parser._addAttribute("intervals", topAttr->c_str());
+                parser._endElement();   // dash
+            break;
+            case kStroke_Linecap:
+            case kStroke_Linejoin:
+            case kStroke_Miterlimit:
+            case kStroke_Width:
+            case kStyle:
+            case kTransform:
+                break;
+        default:
+            SkASSERT(0);
+            return false;
+        }
+    }
+    return true;
 }
-                       
+                
 void SkSVGPaint::Push(SkSVGPaint** head, SkSVGPaint* newRecord) {
-       newRecord->fNext = *head;
-       *head = newRecord;
+    newRecord->fNext = *head;
+    *head = newRecord;
 }
 
 void SkSVGPaint::Pop(SkSVGPaint** head) {
-       SkSVGPaint* next = (*head)->fNext;
-       *head = next;
+    SkSVGPaint* next = (*head)->fNext;
+    *head = next;
 }
 
index a31f436..9f9c67b 100644 (file)
@@ -1,3 +1,20 @@
+/* libs/graphics/svg/SkSVGParser.cpp
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #include "SkSVGParser.h"
 #include "SkSVGCircle.h"
 #include "SkSVGClipPath.h"
 static int gGeneratedMatrixID = 0;
 
 SkSVGParser::SkSVGParser() : fHead(&fEmptyPaint), fIDs(256),
-               fXMLWriter(&fStream), fCurrElement(nil), fInSVG(false), fSuppressPaint(false) {
-       fLastTransform.reset();
-       fEmptyPaint.f_fill.set("black");
-       fEmptyPaint.f_stroke.set("none");
-       fEmptyPaint.f_strokeMiterlimit.set("4");
-       fEmptyPaint.f_fillRule.set("winding");
-       fEmptyPaint.f_opacity.set("1");
-       fEmptyPaint.fNext = nil;
-       for (int index = SkSVGPaint::kInitial + 1; index < SkSVGPaint::kTerminal; index++) {
-               SkString* initial = fEmptyPaint[index];
-               if (initial->size() == 0)
-                       continue;
-               fLastFlush[index]->set(*initial);
-       }
+        fXMLWriter(&fStream), fCurrElement(nil), fInSVG(false), fSuppressPaint(false) {
+    fLastTransform.reset();
+    fEmptyPaint.f_fill.set("black");
+    fEmptyPaint.f_stroke.set("none");
+    fEmptyPaint.f_strokeMiterlimit.set("4");
+    fEmptyPaint.f_fillRule.set("winding");
+    fEmptyPaint.f_opacity.set("1");
+    fEmptyPaint.fNext = nil;
+    for (int index = SkSVGPaint::kInitial + 1; index < SkSVGPaint::kTerminal; index++) {
+        SkString* initial = fEmptyPaint[index];
+        if (initial->size() == 0)
+            continue;
+        fLastFlush[index]->set(*initial);
+    }
 }
 
 SkSVGParser::~SkSVGParser() {
 }
 
 void SkSVGParser::Delete(SkTDArray<SkSVGElement*>& fChildren) {
-       SkSVGElement** ptr;
-       for (ptr = fChildren.begin(); ptr < fChildren.end(); ptr++) {
-               Delete((*ptr)->fChildren);
-               delete *ptr;
-       }
+    SkSVGElement** ptr;
+    for (ptr = fChildren.begin(); ptr < fChildren.end(); ptr++) {
+        Delete((*ptr)->fChildren);
+        delete *ptr;
+    }
 }
 
 int SkSVGParser::findAttribute(SkSVGBase* element, const char* attrValue,
-               size_t len, bool isPaint) {
-       const SkSVGAttribute* attributes;
-       int count = element->getAttributes(&attributes);
-       int result = 0;
-       while (result < count) {
-               if (strncmp(attributes->fName, attrValue, len) == 0 && strlen(attributes->fName) == len) {
-                       SkASSERT(result == (attributes->fOffset - 
-                               (isPaint ? sizeof(SkString) : sizeof(SkSVGElement))) / sizeof(SkString));
-                       return result;
-               }
-               attributes++;
-               result++;
-       }
-       return -1;
+        size_t len, bool isPaint) {
+    const SkSVGAttribute* attributes;
+    int count = element->getAttributes(&attributes);
+    int result = 0;
+    while (result < count) {
+        if (strncmp(attributes->fName, attrValue, len) == 0 && strlen(attributes->fName) == len) {
+            SkASSERT(result == (attributes->fOffset - 
+                (isPaint ? sizeof(SkString) : sizeof(SkSVGElement))) / sizeof(SkString));
+            return result;
+        }
+        attributes++;
+        result++;
+    }
+    return -1;
 }
 
 const char* SkSVGParser::getFinal() {
-       _startElement("screenplay");
-       // generate defs
-       SkSVGElement** ptr;
-       for (ptr = fChildren.begin(); ptr < fChildren.end(); ptr++) {
-               SkSVGElement* element = *ptr;
-               translate(element, true);
-       }
-       // generate onLoad
-       _startElement("event");
-       _addAttribute("kind", "onLoad");
-       _startElement("paint");
-       _addAttribute("antiAlias", "true");
-       _endElement();
-       for (ptr = fChildren.begin(); ptr < fChildren.end(); ptr++) {
-               SkSVGElement* element = *ptr;
-               translate(element, false);
-       }
-       _endElement(); // event
-       _endElement(); // screenplay
-       Delete(fChildren);
-       fStream.write("", 1);
-       return fStream.getStream();
+    _startElement("screenplay");
+    // generate defs
+    SkSVGElement** ptr;
+    for (ptr = fChildren.begin(); ptr < fChildren.end(); ptr++) {
+        SkSVGElement* element = *ptr;
+        translate(element, true);
+    }
+    // generate onLoad
+    _startElement("event");
+    _addAttribute("kind", "onLoad");
+    _startElement("paint");
+    _addAttribute("antiAlias", "true");
+    _endElement();
+    for (ptr = fChildren.begin(); ptr < fChildren.end(); ptr++) {
+        SkSVGElement* element = *ptr;
+        translate(element, false);
+    }
+    _endElement(); // event
+    _endElement(); // screenplay
+    Delete(fChildren);
+    fStream.write("", 1);
+    return fStream.getStream();
 }
 
 SkString& SkSVGParser::getPaintLast(SkSVGPaint::Field field) {
-       SkSVGPaint* state = fHead;
-       do {
-               SkString* attr = (*state)[field];
-               SkASSERT(attr);
-               if (attr->size() > 0)
-                       return *attr;
-               state = state->fNext;
-       } while (state);
-       SkASSERT(0);
-       SkASSERT(fEmptyPaint[field]);
-       return *fEmptyPaint[field];
+    SkSVGPaint* state = fHead;
+    do {
+        SkString* attr = (*state)[field];
+        SkASSERT(attr);
+        if (attr->size() > 0)
+            return *attr;
+        state = state->fNext;
+    } while (state);
+    SkASSERT(0);
+    SkASSERT(fEmptyPaint[field]);
+    return *fEmptyPaint[field];
 }
 
-bool SkSVGParser::isStrokeAndFill(     SkSVGPaint** strokeState, SkSVGPaint** fillState) {
-       SkSVGPaint* walking = fHead;
-       bool stroke = false;
-       bool fill = false;
-       bool strokeSet = false;
-       bool fillSet = false;
-       while (walking != nil) {
-               if (strokeSet == false && walking->f_stroke.size() > 0) {
-                       stroke = walking->f_stroke.equals("none") == false;
-                       *strokeState = walking;
-                       strokeSet = true;
-               }
-               if (fillSet == false && walking->f_fill.size() > 0) {
-                       fill = walking->f_fill.equals("none") == false;
-                       *fillState = walking;
-                       fillSet = true;
-               }
-               walking = walking->fNext;
-       }
-       return stroke && fill;
+bool SkSVGParser::isStrokeAndFill(  SkSVGPaint** strokeState, SkSVGPaint** fillState) {
+    SkSVGPaint* walking = fHead;
+    bool stroke = false;
+    bool fill = false;
+    bool strokeSet = false;
+    bool fillSet = false;
+    while (walking != nil) {
+        if (strokeSet == false && walking->f_stroke.size() > 0) {
+            stroke = walking->f_stroke.equals("none") == false;
+            *strokeState = walking;
+            strokeSet = true;
+        }
+        if (fillSet == false && walking->f_fill.size() > 0) {
+            fill = walking->f_fill.equals("none") == false;
+            *fillState = walking;
+            fillSet = true;
+        }
+        walking = walking->fNext;
+    }
+    return stroke && fill;
 }
 
 bool SkSVGParser::onAddAttribute(const char name[], const char value[]) {
-       return onAddAttributeLen(name, value, strlen(value));
+    return onAddAttributeLen(name, value, strlen(value));
 }
 
 bool SkSVGParser::onAddAttributeLen(const char name[], const char value[], size_t len) {
-       if (fCurrElement == nil)        // this signals we should ignore attributes for this element
-               return true;
-       if (fCurrElement->fIsDef == false && fCurrElement->fIsNotDef == false)
-               return true; // also an ignored element
-       size_t nameLen = strlen(name);
-       int attrIndex = findAttribute(fCurrElement, name, nameLen, false);
-       if (attrIndex == -1) {
-               attrIndex = findAttribute(&fCurrElement->fPaintState, name, nameLen, true);
-               if (attrIndex >= 0) {
-                       fCurrElement->fPaintState.addAttribute(*this, attrIndex, value, len);
-                       return false;
-               }
-               if (nameLen == 2 && strncmp("id", name, nameLen) == 0) {
-                       fCurrElement->f_id.set(value, len);
-                       return false;
-               }
-               if (strchr(name, ':') != 0)     // part of a different namespace
-                       return false;
-       }
-       SkASSERT(attrIndex >= 0);
-       fCurrElement->addAttribute(*this, attrIndex, value, len);
-       return false;
+    if (fCurrElement == nil)    // this signals we should ignore attributes for this element
+        return true;
+    if (fCurrElement->fIsDef == false && fCurrElement->fIsNotDef == false)
+        return true; // also an ignored element
+    size_t nameLen = strlen(name);
+    int attrIndex = findAttribute(fCurrElement, name, nameLen, false);
+    if (attrIndex == -1) {
+        attrIndex = findAttribute(&fCurrElement->fPaintState, name, nameLen, true);
+        if (attrIndex >= 0) {
+            fCurrElement->fPaintState.addAttribute(*this, attrIndex, value, len);
+            return false;
+        }
+        if (nameLen == 2 && strncmp("id", name, nameLen) == 0) {
+            fCurrElement->f_id.set(value, len);
+            return false;
+        }
+        if (strchr(name, ':') != 0) // part of a different namespace
+            return false;
+    }
+    SkASSERT(attrIndex >= 0);
+    fCurrElement->addAttribute(*this, attrIndex, value, len);
+    return false;
 }
 
 bool SkSVGParser::onEndElement(const char elem[]) {
-       int parentIndex = fParents.count() - 1;
-       if (parentIndex >= 0) {
-               SkSVGElement* element = fParents[parentIndex];
-               element->onEndElement(*this);
-               fParents.remove(parentIndex);
-       }
-       return false;
+    int parentIndex = fParents.count() - 1;
+    if (parentIndex >= 0) {
+        SkSVGElement* element = fParents[parentIndex];
+        element->onEndElement(*this);
+        fParents.remove(parentIndex);
+    }
+    return false;
 }
 
 bool SkSVGParser::onStartElement(const char name[]) {
-       return onStartElementLen(name, strlen(name));
+    return onStartElementLen(name, strlen(name));
 }
 
 bool SkSVGParser::onStartElementLen(const char name[], size_t len) {
-       if (strncmp(name, "svg", len) == 0) {
-               fInSVG = true;
-       } else if (fInSVG == false)
-               return false;
-       const char* nextColon = strchr(name, ':');
-       if (nextColon && nextColon - name < len)
-               return false;
-       SkSVGTypes type = GetType(name, len);
-       SkASSERT(type >= 0);
-       if (type < 0)
-               return true;
-       SkSVGElement* parent = fParents.count() > 0 ? fParents.top() : nil;
-       SkSVGElement* element = CreateElement(type, parent);
-       bool result = false;
-       if (parent) {
-               element->fParent = parent;
-               result = fParents.top()->onStartElement(element);
-       } else
-               *fChildren.append() = element;
-       if (strncmp(name, "svg", len) != 0)
-               *fParents.append() = element;
-       fCurrElement = element;
-       return result;
+    if (strncmp(name, "svg", len) == 0) {
+        fInSVG = true;
+    } else if (fInSVG == false)
+        return false;
+    const char* nextColon = strchr(name, ':');
+    if (nextColon && nextColon - name < len)
+        return false;
+    SkSVGTypes type = GetType(name, len);
+    SkASSERT(type >= 0);
+    if (type < 0)
+        return true;
+    SkSVGElement* parent = fParents.count() > 0 ? fParents.top() : nil;
+    SkSVGElement* element = CreateElement(type, parent);
+    bool result = false;
+    if (parent) {
+        element->fParent = parent;
+        result = fParents.top()->onStartElement(element);
+    } else
+        *fChildren.append() = element;
+    if (strncmp(name, "svg", len) != 0)
+        *fParents.append() = element;
+    fCurrElement = element;
+    return result;
 }
 
 bool SkSVGParser::onText(const char text[], int len) {
-       if (fInSVG == false)
-               return false;
-       SkSVGTypes type = fCurrElement->getType(); 
-       if (type != SkSVGType_Text && type != SkSVGType_Tspan)
-               return false;
-       SkSVGText* textElement = (SkSVGText*) fCurrElement;
-       textElement->f_text.set(text, len);
-       return false;
+    if (fInSVG == false)
+        return false;
+    SkSVGTypes type = fCurrElement->getType(); 
+    if (type != SkSVGType_Text && type != SkSVGType_Tspan)
+        return false;
+    SkSVGText* textElement = (SkSVGText*) fCurrElement;
+    textElement->f_text.set(text, len);
+    return false;
 }
 
 static S32 strokeFillID = 0;
 
 void SkSVGParser::translate(SkSVGElement* element, bool isDef) {
-       SkSVGPaint::Push(&fHead, &element->fPaintState);
-       bool isFlushable = element->isFlushable();
-       if ((element->fIsDef == false && element->fIsNotDef == false) ||
-               (element->fIsDef && isDef == false && element->fIsNotDef == false) ||
-               (element->fIsDef == false && isDef && element->fIsNotDef)) {
-               isFlushable = false;
-       }
-       SkSVGPaint* strokeState = nil, * fillState = nil;
-       if (isFlushable)
-               element->fPaintState.setSave(*this);
-       if (isFlushable && isStrokeAndFill(&strokeState, &fillState)) {
-               SkString& elementID = element->f_id;
-               if (elementID.size() == 0) {
-                       elementID.set("sf");
-                       elementID.appendS32(++strokeFillID);
-               }
-               SkString saveStroke(strokeState->f_stroke);
-               SkString saveFill(fillState->f_fill);
-               strokeState->f_stroke.set("none");
-               element->fPaintState.flush(*this, isFlushable, isDef);
-               element->translate(*this, isDef);
-               strokeState->f_stroke.set(saveStroke);
-               fillState->f_fill.set("none");
-               if (element->fPaintState.flush(*this, isFlushable, isDef)) {
-                       _startElement("add");
-                       _addAttributeLen("use", elementID.c_str(), elementID.size());
-                       _endElement();  // add
-               }
-               fillState->f_fill.set(saveFill);
-       } else {
-               element->fPaintState.flush(*this, isFlushable, isDef);
-               if (isFlushable || element->isGroup())
-                       element->translate(*this, isDef);
-       }
-       SkSVGPaint::Pop(&fHead);
+    SkSVGPaint::Push(&fHead, &element->fPaintState);
+    bool isFlushable = element->isFlushable();
+    if ((element->fIsDef == false && element->fIsNotDef == false) ||
+        (element->fIsDef && isDef == false && element->fIsNotDef == false) ||
+        (element->fIsDef == false && isDef && element->fIsNotDef)) {
+        isFlushable = false;
+    }
+    SkSVGPaint* strokeState = nil, * fillState = nil;
+    if (isFlushable)
+        element->fPaintState.setSave(*this);
+    if (isFlushable && isStrokeAndFill(&strokeState, &fillState)) {
+        SkString& elementID = element->f_id;
+        if (elementID.size() == 0) {
+            elementID.set("sf");
+            elementID.appendS32(++strokeFillID);
+        }
+        SkString saveStroke(strokeState->f_stroke);
+        SkString saveFill(fillState->f_fill);
+        strokeState->f_stroke.set("none");
+        element->fPaintState.flush(*this, isFlushable, isDef);
+        element->translate(*this, isDef);
+        strokeState->f_stroke.set(saveStroke);
+        fillState->f_fill.set("none");
+        if (element->fPaintState.flush(*this, isFlushable, isDef)) {
+            _startElement("add");
+            _addAttributeLen("use", elementID.c_str(), elementID.size());
+            _endElement();  // add
+        }
+        fillState->f_fill.set(saveFill);
+    } else {
+        element->fPaintState.flush(*this, isFlushable, isDef);
+        if (isFlushable || element->isGroup())
+            element->translate(*this, isDef);
+    }
+    SkSVGPaint::Pop(&fHead);
 }
 
 void SkSVGParser::translateMatrix(SkString& string, SkString* stringID) {
-       if (string.size() == 0)
-               return;
-       if (stringID->size() > 0) {
-               _startElement("add");
-               _addAttribute("use", stringID->c_str());
-               _endElement(); // add
-               return;
-       }
-       SkASSERT(strncmp(string.c_str(), "matrix", 6) == 0);
-       ++gGeneratedMatrixID;
-       _startElement("matrix");
-       char idStr[16];
-       strcpy(idStr, "sk_matrix");
-       char num[8];
-       sprintf(num, "%d", gGeneratedMatrixID);
-       strcat(idStr, num);
-       _addAttribute("id", idStr);
-       stringID->set(idStr);
-       const char* str = string.c_str();
-       SkASSERT(strncmp(str, "matrix(", 7) == 0);
-       str += 6;
-       const char* strEnd = strrchr(str, ')');
-       SkASSERT(strEnd != nil);
-       SkString mat(str, strEnd - str);
-       ConvertToArray(mat);
-       const char* elems[6];
-       static const int order[] = {0, 3, 1, 4, 2, 5};
-       const int* orderPtr = order;
-       str = mat.c_str();
-       strEnd = str + mat.size();
-       while (str < strEnd) {
-               elems[*orderPtr++] = str;
-               while (str < strEnd && *str != ',' )
-                       str++;
-               str++;
-       }
-       string.reset();
-       for (int index = 0; index < 6; index++) {
-               const char* end = strchr(elems[index], ',');
-               if (end == nil)
-                       end= strchr(elems[index], ']');
-               string.append(elems[index], end - elems[index] + 1);
-       }
-       string.remove(string.size() - 1, 1);
-       string.append(",0,0,1]");    
-       _addAttribute("matrix", string);
-       _endElement();  // matrix
+    if (string.size() == 0)
+        return;
+    if (stringID->size() > 0) {
+        _startElement("add");
+        _addAttribute("use", stringID->c_str());
+        _endElement(); // add
+        return;
+    }
+    SkASSERT(strncmp(string.c_str(), "matrix", 6) == 0);
+    ++gGeneratedMatrixID;
+    _startElement("matrix");
+    char idStr[16];
+    strcpy(idStr, "sk_matrix");
+    char num[8];
+    sprintf(num, "%d", gGeneratedMatrixID);
+    strcat(idStr, num);
+    _addAttribute("id", idStr);
+    stringID->set(idStr);
+    const char* str = string.c_str();
+    SkASSERT(strncmp(str, "matrix(", 7) == 0);
+    str += 6;
+    const char* strEnd = strrchr(str, ')');
+    SkASSERT(strEnd != nil);
+    SkString mat(str, strEnd - str);
+    ConvertToArray(mat);
+    const char* elems[6];
+    static const int order[] = {0, 3, 1, 4, 2, 5};
+    const int* orderPtr = order;
+    str = mat.c_str();
+    strEnd = str + mat.size();
+    while (str < strEnd) {
+        elems[*orderPtr++] = str;
+        while (str < strEnd && *str != ',' )
+            str++;
+        str++;
+    }
+    string.reset();
+    for (int index = 0; index < 6; index++) {
+        const char* end = strchr(elems[index], ',');
+        if (end == nil)
+            end= strchr(elems[index], ']');
+        string.append(elems[index], end - elems[index] + 1);
+    }
+    string.remove(string.size() - 1, 1);
+    string.append(",0,0,1]");    
+    _addAttribute("matrix", string);
+    _endElement();  // matrix
 }
 
 static bool is_whitespace(char ch) {
-       return ch > 0 && ch <= ' ';
+    return ch > 0 && ch <= ' ';
 }
 
 void SkSVGParser::ConvertToArray(SkString& vals) {
-       vals.appendUnichar(']');
-       char* valCh = (char*) vals.c_str();
-       valCh[0] = '[';
-       int index = 1;
-       while (valCh[index] != ']') {
-               while (is_whitespace(valCh[index]))
-                       index++;
-               bool foundComma = false;
-               char next;
-               do {
-                       next = valCh[index++];
-                       if (next == ',') {
-                               foundComma = true;
-                               continue;
-                       }
-                       if (next == ']') {
-                               index--;
-                               goto undoLastComma;
-                       }
-                       if (next == ' ')
-                               break;
-                       foundComma = false;
-               } while (is_whitespace(next) == false);
-               if (foundComma == false)
-                       valCh[index - 1] = ',';
-       }
+    vals.appendUnichar(']');
+    char* valCh = (char*) vals.c_str();
+    valCh[0] = '[';
+    int index = 1;
+    while (valCh[index] != ']') {
+        while (is_whitespace(valCh[index]))
+            index++;
+        bool foundComma = false;
+        char next;
+        do {
+            next = valCh[index++];
+            if (next == ',') {
+                foundComma = true;
+                continue;
+            }
+            if (next == ']') {
+                index--;
+                goto undoLastComma;
+            }
+            if (next == ' ')
+                break;
+            foundComma = false;
+        } while (is_whitespace(next) == false);
+        if (foundComma == false)
+            valCh[index - 1] = ',';
+    }
 undoLastComma:
-       while (is_whitespace(valCh[--index]))
-               ;
-       if (valCh[index] == ',')
-               valCh[index] = ' ';
+    while (is_whitespace(valCh[--index]))
+        ;
+    if (valCh[index] == ',')
+        valCh[index] = ' ';
 }
 
 #define CASE_NEW(type) case SkSVGType_##type : created = new SkSVG##type(); break
 
 SkSVGElement* SkSVGParser::CreateElement(SkSVGTypes type, SkSVGElement* parent) {
-       SkSVGElement* created = nil;
-       switch (type) {
-               CASE_NEW(Circle);
-               CASE_NEW(ClipPath);
-               CASE_NEW(Defs);
-               CASE_NEW(Ellipse);
-               CASE_NEW(FeColorMatrix);
-               CASE_NEW(Filter);
-               CASE_NEW(G);
-               CASE_NEW(Image);
-               CASE_NEW(Line);
-               CASE_NEW(LinearGradient);
-               CASE_NEW(Mask);
-               CASE_NEW(Metadata);
-               CASE_NEW(Path);
-               CASE_NEW(Polygon);
-               CASE_NEW(Polyline);
-               CASE_NEW(RadialGradient);
-               CASE_NEW(Rect);
-               CASE_NEW(Stop);
-               CASE_NEW(SVG);
-               CASE_NEW(Symbol);
-               CASE_NEW(Text);
-               CASE_NEW(Tspan);
-               CASE_NEW(Use);
-               default:
-                       SkASSERT(0);
-                       return nil;
-       }
-       created->fParent = parent;
-       bool isDef = created->fIsDef = created->isDef();
-       bool isNotDef = created->fIsNotDef = created->isNotDef();
-       if (isDef) {
-               SkSVGElement* up = parent;
-               while (up && up->fIsDef == false) {
-                       up->fIsDef = true;
-                       up = up->fParent;
-               }
-       }
-       if (isNotDef) {
-               SkSVGElement* up = parent;
-               while (up && up->fIsNotDef == false) {
-                       up->fIsNotDef = true;
-                       up = up->fParent;
-               }
-       }
-       return created;
+    SkSVGElement* created = nil;
+    switch (type) {
+        CASE_NEW(Circle);
+        CASE_NEW(ClipPath);
+        CASE_NEW(Defs);
+        CASE_NEW(Ellipse);
+        CASE_NEW(FeColorMatrix);
+        CASE_NEW(Filter);
+        CASE_NEW(G);
+        CASE_NEW(Image);
+        CASE_NEW(Line);
+        CASE_NEW(LinearGradient);
+        CASE_NEW(Mask);
+        CASE_NEW(Metadata);
+        CASE_NEW(Path);
+        CASE_NEW(Polygon);
+        CASE_NEW(Polyline);
+        CASE_NEW(RadialGradient);
+        CASE_NEW(Rect);
+        CASE_NEW(Stop);
+        CASE_NEW(SVG);
+        CASE_NEW(Symbol);
+        CASE_NEW(Text);
+        CASE_NEW(Tspan);
+        CASE_NEW(Use);
+        default:
+            SkASSERT(0);
+            return nil;
+    }
+    created->fParent = parent;
+    bool isDef = created->fIsDef = created->isDef();
+    bool isNotDef = created->fIsNotDef = created->isNotDef();
+    if (isDef) {
+        SkSVGElement* up = parent;
+        while (up && up->fIsDef == false) {
+            up->fIsDef = true;
+            up = up->fParent;
+        }
+    }
+    if (isNotDef) {
+        SkSVGElement* up = parent;
+        while (up && up->fIsNotDef == false) {
+            up->fIsNotDef = true;
+            up = up->fParent;
+        }
+    }
+    return created;
 }
 
 const SkSVGTypeName gSVGTypeNames[] = {
-       {"circle", SkSVGType_Circle},
-       {"clipPath", SkSVGType_ClipPath},
-       {"defs", SkSVGType_Defs},
-       {"ellipse", SkSVGType_Ellipse},
-       {"feColorMatrix", SkSVGType_FeColorMatrix},
-       {"filter", SkSVGType_Filter},
-       {"g", SkSVGType_G},
-       {"image", SkSVGType_Image},
-       {"line", SkSVGType_Line},
-       {"linearGradient", SkSVGType_LinearGradient},
-       {"mask", SkSVGType_Mask},
-       {"metadata", SkSVGType_Metadata},
-       {"path", SkSVGType_Path},
-       {"polygon", SkSVGType_Polygon},
-       {"polyline", SkSVGType_Polyline},
-       {"radialGradient", SkSVGType_RadialGradient},
-       {"rect", SkSVGType_Rect},
-       {"stop", SkSVGType_Stop},
-       {"svg", SkSVGType_SVG},
-       {"symbol", SkSVGType_Symbol},
-       {"text", SkSVGType_Text},
-       {"tspan", SkSVGType_Tspan},
-       {"use", SkSVGType_Use}
+    {"circle", SkSVGType_Circle},
+    {"clipPath", SkSVGType_ClipPath},
+    {"defs", SkSVGType_Defs},
+    {"ellipse", SkSVGType_Ellipse},
+    {"feColorMatrix", SkSVGType_FeColorMatrix},
+    {"filter", SkSVGType_Filter},
+    {"g", SkSVGType_G},
+    {"image", SkSVGType_Image},
+    {"line", SkSVGType_Line},
+    {"linearGradient", SkSVGType_LinearGradient},
+    {"mask", SkSVGType_Mask},
+    {"metadata", SkSVGType_Metadata},
+    {"path", SkSVGType_Path},
+    {"polygon", SkSVGType_Polygon},
+    {"polyline", SkSVGType_Polyline},
+    {"radialGradient", SkSVGType_RadialGradient},
+    {"rect", SkSVGType_Rect},
+    {"stop", SkSVGType_Stop},
+    {"svg", SkSVGType_SVG},
+    {"symbol", SkSVGType_Symbol},
+    {"text", SkSVGType_Text},
+    {"tspan", SkSVGType_Tspan},
+    {"use", SkSVGType_Use}
 };
 
 const int kSVGTypeNamesSize = SK_ARRAY_COUNT(gSVGTypeNames);
 
 SkSVGTypes SkSVGParser::GetType(const char match[], size_t len ) {
-       int index = SkStrSearch(&gSVGTypeNames[0].fName, kSVGTypeNamesSize, match, 
-               len, sizeof(gSVGTypeNames[0]));
-       return index >= 0 && index < kSVGTypeNamesSize ? gSVGTypeNames[index].fType : 
-               (SkSVGTypes) -1;
+    int index = SkStrSearch(&gSVGTypeNames[0].fName, kSVGTypeNamesSize, match, 
+        len, sizeof(gSVGTypeNames[0]));
+    return index >= 0 && index < kSVGTypeNamesSize ? gSVGTypeNames[index].fType : 
+        (SkSVGTypes) -1;
 }
index be7a45f..b51ef37 100644 (file)
@@ -1,28 +1,45 @@
+/* libs/graphics/svg/SkSVGPath.cpp
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #include "SkSVGPath.h"
 #include "SkSVGParser.h"
 
 const SkSVGAttribute SkSVGPath::gAttributes[] = {
-       SVG_ATTRIBUTE(d)
+    SVG_ATTRIBUTE(d)
 };
 
 DEFINE_SVG_INFO(Path)
 
 void SkSVGPath::translate(SkSVGParser& parser, bool defState) {
-       parser._startElement("path");
-       INHERITED::translate(parser, defState);
-       bool hasMultiplePaths = false;
-       const char* firstZ = strchr(f_d.c_str(), 'z');
-       if (firstZ != nil) {
-               firstZ++; // skip over 'z'
-               while (*firstZ == ' ')
-                       firstZ++;
-               hasMultiplePaths = *firstZ != '\0';
-       }
-       if (hasMultiplePaths) {
-               SkString& fillRule = parser.getPaintLast(SkSVGPaint::kFillRule);
-               if (fillRule.size() > 0) 
-                       parser._addAttribute("fillType", fillRule.equals("evenodd") ? "evenOdd" : "winding");
-       }
-       SVG_ADD_ATTRIBUTE(d);
-       parser._endElement();
+    parser._startElement("path");
+    INHERITED::translate(parser, defState);
+    bool hasMultiplePaths = false;
+    const char* firstZ = strchr(f_d.c_str(), 'z');
+    if (firstZ != nil) {
+        firstZ++; // skip over 'z'
+        while (*firstZ == ' ')
+            firstZ++;
+        hasMultiplePaths = *firstZ != '\0';
+    }
+    if (hasMultiplePaths) {
+        SkString& fillRule = parser.getPaintLast(SkSVGPaint::kFillRule);
+        if (fillRule.size() > 0) 
+            parser._addAttribute("fillType", fillRule.equals("evenodd") ? "evenOdd" : "winding");
+    }
+    SVG_ADD_ATTRIBUTE(d);
+    parser._endElement();
 }
index 1cbff6d..f3be03b 100644 (file)
@@ -1,13 +1,30 @@
+/* libs/graphics/svg/SkSVGPath.h
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #ifndef SkSVGPath_DEFINED
 #define SkSVGPath_DEFINED
 
 #include "SkSVGElements.h"
 
 class SkSVGPath : public SkSVGElement {
-       DECLARE_SVG_INFO(Path);
+    DECLARE_SVG_INFO(Path);
 private:
-       SkString f_d;
-       typedef SkSVGElement INHERITED;
+    SkString f_d;
+    typedef SkSVGElement INHERITED;
 };
 
 #endif // SkSVGPath_DEFINED
index f7e4165..f1ed9ce 100644 (file)
@@ -1,24 +1,41 @@
+/* libs/graphics/svg/SkSVGPolygon.cpp
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #include "SkSVGPolygon.h"
 #include "SkSVGParser.h"
 
 const SkSVGAttribute SkSVGPolygon::gAttributes[] = {
-       SVG_LITERAL_ATTRIBUTE(clip-rule, f_clipRule),
-       SVG_LITERAL_ATTRIBUTE(fill-rule, f_fillRule),
-       SVG_ATTRIBUTE(points)
+    SVG_LITERAL_ATTRIBUTE(clip-rule, f_clipRule),
+    SVG_LITERAL_ATTRIBUTE(fill-rule, f_fillRule),
+    SVG_ATTRIBUTE(points)
 };
 
 DEFINE_SVG_INFO(Polygon)
 
 void SkSVGPolygon::addAttribute(SkSVGParser& parser, int attrIndex, 
-               const char* attrValue, size_t attrLength) {
-       INHERITED::addAttribute(parser, attrIndex, attrValue, attrLength);
+        const char* attrValue, size_t attrLength) {
+    INHERITED::addAttribute(parser, attrIndex, attrValue, attrLength);
 }
 
 void SkSVGPolygon::translate(SkSVGParser& parser, bool defState) {
-       parser._startElement("polygon");
-       SkSVGElement::translate(parser, defState);
-       SVG_ADD_ATTRIBUTE(points);
-       if (f_fillRule.size() > 0) 
-               parser._addAttribute("fillType", f_fillRule.equals("evenodd") ? "evenOdd" : "winding");
-       parser._endElement();
+    parser._startElement("polygon");
+    SkSVGElement::translate(parser, defState);
+    SVG_ADD_ATTRIBUTE(points);
+    if (f_fillRule.size() > 0) 
+        parser._addAttribute("fillType", f_fillRule.equals("evenodd") ? "evenOdd" : "winding");
+    parser._endElement();
 }
index 9cf8619..a01d389 100644 (file)
@@ -1,14 +1,31 @@
+/* libs/graphics/svg/SkSVGPolygon.h
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #ifndef SkSVGPolygon_DEFINED
 #define SkSVGPolygon_DEFINED
 
 #include "SkSVGPolyline.h"
 
 class SkSVGPolygon : public SkSVGPolyline {
-       DECLARE_SVG_INFO(Polygon);
-       virtual void addAttribute(SkSVGParser& , int attrIndex, 
-               const char* attrValue, size_t attrLength);
+    DECLARE_SVG_INFO(Polygon);
+    virtual void addAttribute(SkSVGParser& , int attrIndex, 
+        const char* attrValue, size_t attrLength);
 private:
-       typedef SkSVGPolyline INHERITED;
+    typedef SkSVGPolyline INHERITED;
 };
 
 #endif // SkSVGPolygon_DEFINED
index cc4c197..7e7b575 100644 (file)
@@ -1,34 +1,51 @@
+/* libs/graphics/svg/SkSVGPolyline.cpp
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #include "SkSVGPolyline.h"
 #include "SkSVGParser.h"
 
 enum {
-       kCliipRule,
-       kFillRule,
-       kPoints
+    kCliipRule,
+    kFillRule,
+    kPoints
 };
 
 const SkSVGAttribute SkSVGPolyline::gAttributes[] = {
-       SVG_LITERAL_ATTRIBUTE(clip-rule, f_clipRule),
-       SVG_LITERAL_ATTRIBUTE(fill-rule, f_fillRule),
-       SVG_ATTRIBUTE(points)
+    SVG_LITERAL_ATTRIBUTE(clip-rule, f_clipRule),
+    SVG_LITERAL_ATTRIBUTE(fill-rule, f_fillRule),
+    SVG_ATTRIBUTE(points)
 };
 
 DEFINE_SVG_INFO(Polyline)
 
 void SkSVGPolyline::addAttribute(SkSVGParser& , int attrIndex, 
-               const char* attrValue, size_t attrLength) {
-       if (attrIndex != kPoints)
-               return;
-       f_points.set("[");
-       f_points.append(attrValue, attrLength);
-       SkSVGParser::ConvertToArray(f_points);
+        const char* attrValue, size_t attrLength) {
+    if (attrIndex != kPoints)
+        return;
+    f_points.set("[");
+    f_points.append(attrValue, attrLength);
+    SkSVGParser::ConvertToArray(f_points);
 }
 
 void SkSVGPolyline::translate(SkSVGParser& parser, bool defState) {
-       parser._startElement("polyline");
-       INHERITED::translate(parser, defState);
-       SVG_ADD_ATTRIBUTE(points);
-       if (f_fillRule.size() > 0) 
-               parser._addAttribute("fillType", f_fillRule.equals("evenodd") ? "evenOdd" : "winding");
-       parser._endElement();
+    parser._startElement("polyline");
+    INHERITED::translate(parser, defState);
+    SVG_ADD_ATTRIBUTE(points);
+    if (f_fillRule.size() > 0) 
+        parser._addAttribute("fillType", f_fillRule.equals("evenodd") ? "evenOdd" : "winding");
+    parser._endElement();
 }
index 50840b2..68527e7 100644 (file)
@@ -1,3 +1,20 @@
+/* libs/graphics/svg/SkSVGPolyline.h
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #ifndef SkSVGPolyline_DEFINED
 #define SkSVGPolyline_DEFINED
 
 #include "SkString.h"
 
 class SkSVGPolyline : public SkSVGElement {
-       DECLARE_SVG_INFO(Polyline);
-       virtual void addAttribute(SkSVGParser& , int attrIndex, 
-               const char* attrValue, size_t attrLength);
+    DECLARE_SVG_INFO(Polyline);
+    virtual void addAttribute(SkSVGParser& , int attrIndex, 
+        const char* attrValue, size_t attrLength);
 protected:
-       SkString f_clipRule;
-       SkString f_fillRule;
-       SkString f_points;
-       typedef SkSVGElement INHERITED;
+    SkString f_clipRule;
+    SkString f_fillRule;
+    SkString f_points;
+    typedef SkSVGElement INHERITED;
 };
 
 #endif // SkSVGPolyline_DEFINED
index 8883f36..31bfde6 100644 (file)
@@ -1,33 +1,50 @@
+/* libs/graphics/svg/SkSVGRadialGradient.cpp
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #include "SkSVGRadialGradient.h"
 #include "SkSVGParser.h"
 
 const SkSVGAttribute SkSVGRadialGradient::gAttributes[] = {
-       SVG_ATTRIBUTE(cx),
-       SVG_ATTRIBUTE(cy),
-       SVG_ATTRIBUTE(fx),
-       SVG_ATTRIBUTE(fy),
-       SVG_ATTRIBUTE(gradientTransform),
-       SVG_ATTRIBUTE(gradientUnits),
-       SVG_ATTRIBUTE(r)
+    SVG_ATTRIBUTE(cx),
+    SVG_ATTRIBUTE(cy),
+    SVG_ATTRIBUTE(fx),
+    SVG_ATTRIBUTE(fy),
+    SVG_ATTRIBUTE(gradientTransform),
+    SVG_ATTRIBUTE(gradientUnits),
+    SVG_ATTRIBUTE(r)
 };
 
 DEFINE_SVG_INFO(RadialGradient)
 
 void SkSVGRadialGradient::translate(SkSVGParser& parser, bool defState) {
-       if (fMatrixID.size() == 0)
-               parser.translateMatrix(f_gradientTransform, &fMatrixID);
-       parser._startElement("radialGradient");
-       if (fMatrixID.size() > 0)
-               parser._addAttribute("matrix", fMatrixID);
-       INHERITED::translateGradientUnits(f_gradientUnits);
-       SkString center;
-       center.appendUnichar('[');
-       center.append(f_cx);
-       center.appendUnichar(',');
-       center.append(f_cy);
-       center.appendUnichar(']');
-       parser._addAttribute("center", center);
-       parser._addAttribute("radius", f_r);
-       INHERITED::translate(parser, defState);
-       parser._endElement();
+    if (fMatrixID.size() == 0)
+        parser.translateMatrix(f_gradientTransform, &fMatrixID);
+    parser._startElement("radialGradient");
+    if (fMatrixID.size() > 0)
+        parser._addAttribute("matrix", fMatrixID);
+    INHERITED::translateGradientUnits(f_gradientUnits);
+    SkString center;
+    center.appendUnichar('[');
+    center.append(f_cx);
+    center.appendUnichar(',');
+    center.append(f_cy);
+    center.appendUnichar(']');
+    parser._addAttribute("center", center);
+    parser._addAttribute("radius", f_r);
+    INHERITED::translate(parser, defState);
+    parser._endElement();
 }
index 514523e..cdf2c10 100644 (file)
@@ -1,21 +1,38 @@
+/* libs/graphics/svg/SkSVGRadialGradient.h
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #ifndef SkSVGRadialGradient_DEFINED
 #define SkSVGRadialGradient_DEFINED
 
 #include "SkSVGGradient.h"
 
 class SkSVGRadialGradient : public SkSVGGradient {
-       DECLARE_SVG_INFO(RadialGradient);
+    DECLARE_SVG_INFO(RadialGradient);
 protected:
-       SkString f_cx;
-       SkString f_cy;
-       SkString f_fx;
-       SkString f_fy;
-       SkString f_gradientTransform;
-       SkString f_gradientUnits;
-       SkString f_r;
-       SkString fMatrixID;
+    SkString f_cx;
+    SkString f_cy;
+    SkString f_fx;
+    SkString f_fy;
+    SkString f_gradientTransform;
+    SkString f_gradientUnits;
+    SkString f_r;
+    SkString fMatrixID;
 private:
-       typedef SkSVGGradient INHERITED;
+    typedef SkSVGGradient INHERITED;
 };
 
 #endif // SkSVGRadialGradient_DEFINED
index aff3a63..9f1da07 100644 (file)
@@ -1,26 +1,43 @@
+/* libs/graphics/svg/SkSVGRect.cpp
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #include "SkSVGRect.h"
 #include "SkSVGParser.h"
 
 const SkSVGAttribute SkSVGRect::gAttributes[] = {
-       SVG_ATTRIBUTE(height),
-       SVG_ATTRIBUTE(width),
-       SVG_ATTRIBUTE(x),
-       SVG_ATTRIBUTE(y)
+    SVG_ATTRIBUTE(height),
+    SVG_ATTRIBUTE(width),
+    SVG_ATTRIBUTE(x),
+    SVG_ATTRIBUTE(y)
 };
 
 DEFINE_SVG_INFO(Rect)
 
 SkSVGRect::SkSVGRect() {
-       f_x.set("0");
-       f_y.set("0");
+    f_x.set("0");
+    f_y.set("0");
 }
 
 void SkSVGRect::translate(SkSVGParser& parser, bool defState) {
-       parser._startElement("rectangle");
-       INHERITED::translate(parser, defState);
-       SVG_ADD_ATTRIBUTE_ALIAS(left, x);
-       SVG_ADD_ATTRIBUTE_ALIAS(top, y);
-       SVG_ADD_ATTRIBUTE(width);
-       SVG_ADD_ATTRIBUTE(height);
-       parser._endElement();
+    parser._startElement("rectangle");
+    INHERITED::translate(parser, defState);
+    SVG_ADD_ATTRIBUTE_ALIAS(left, x);
+    SVG_ADD_ATTRIBUTE_ALIAS(top, y);
+    SVG_ADD_ATTRIBUTE(width);
+    SVG_ADD_ATTRIBUTE(height);
+    parser._endElement();
 }
index e6202ec..ac48d8e 100644 (file)
@@ -1,17 +1,34 @@
+/* libs/graphics/svg/SkSVGRect.h
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #ifndef SkSVGRect_DEFINED
 #define SkSVGRect_DEFINED
 
 #include "SkSVGElements.h"
 
 class SkSVGRect : public SkSVGElement {
-       DECLARE_SVG_INFO(Rect);
-       SkSVGRect();
+    DECLARE_SVG_INFO(Rect);
+    SkSVGRect();
 private:
-       SkString f_height;
-       SkString f_width;
-       SkString f_x;
-       SkString f_y;
-       typedef SkSVGElement INHERITED;
+    SkString f_height;
+    SkString f_width;
+    SkString f_x;
+    SkString f_y;
+    typedef SkSVGElement INHERITED;
 };
 
 #endif // SkSVGRect_DEFINED
index b56d2c8..6b0aed3 100644 (file)
@@ -1,65 +1,82 @@
+/* libs/graphics/svg/SkSVGSVG.cpp
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #include "SkSVGSVG.h"
 #include "SkParse.h"
 #include "SkRect.h"
 #include "SkSVGParser.h"
 
 const SkSVGAttribute SkSVGSVG::gAttributes[] = {
-       SVG_LITERAL_ATTRIBUTE(enable-background, f_enable_background),
-       SVG_ATTRIBUTE(height),
-       SVG_ATTRIBUTE(overflow),
-       SVG_ATTRIBUTE(width),
-       SVG_ATTRIBUTE(version),
-       SVG_ATTRIBUTE(viewBox),
-       SVG_LITERAL_ATTRIBUTE(xml:space, f_xml_space),
-       SVG_ATTRIBUTE(xmlns),
-       SVG_LITERAL_ATTRIBUTE(xmlns:xlink, f_xml_xlink)
+    SVG_LITERAL_ATTRIBUTE(enable-background, f_enable_background),
+    SVG_ATTRIBUTE(height),
+    SVG_ATTRIBUTE(overflow),
+    SVG_ATTRIBUTE(width),
+    SVG_ATTRIBUTE(version),
+    SVG_ATTRIBUTE(viewBox),
+    SVG_LITERAL_ATTRIBUTE(xml:space, f_xml_space),
+    SVG_ATTRIBUTE(xmlns),
+    SVG_LITERAL_ATTRIBUTE(xmlns:xlink, f_xml_xlink)
 };
 
 DEFINE_SVG_INFO(SVG)
 
 
 bool SkSVGSVG::isFlushable() {
-       return false;
+    return false;
 }
 
 void SkSVGSVG::translate(SkSVGParser& parser, bool defState) {
-       SkScalar height, width;
-       SkScalar viewBox[4];
-       const char* hSuffix = SkParse::FindScalar(f_height.c_str(), &height);
-       if (strcmp(hSuffix, "pt") == 0)
-               height = SkScalarMulDiv(height, SK_Scalar1 * 72, SK_Scalar1 * 96);
-       const char* wSuffix = SkParse::FindScalar(f_width.c_str(), &width);
-       if (strcmp(wSuffix, "pt") == 0)
-               width = SkScalarMulDiv(width, SK_Scalar1 * 72, SK_Scalar1 * 96);
-       SkParse::FindScalars(f_viewBox.c_str(), viewBox, 4);
-       SkRect box;
-       box.fLeft = SkScalarDiv(viewBox[0], width);
-       box.fTop = SkScalarDiv(viewBox[1], height);
-       box.fRight = SkScalarDiv(viewBox[2], width);
-       box.fBottom = SkScalarDiv(viewBox[3], height);
-       if (box.fLeft == 0 && box.fTop == 0 && 
-               box.fRight == SK_Scalar1 && box.fBottom == SK_Scalar1) 
-                       return;
-       parser._startElement("matrix");
-       if (box.fLeft != 0) {
-               SkString x;
-               x.appendScalar(box.fLeft);
-               parser._addAttributeLen("translateX", x.c_str(), x.size());
-       }
-       if (box.fTop != 0) {
-               SkString y;
-               y.appendScalar(box.fTop);
-               parser._addAttributeLen("translateY", y.c_str(), y.size());
-       }
-       if (box.fRight != SK_Scalar1) {
-               SkString x;
-               x.appendScalar(box.fRight);
-               parser._addAttributeLen("scaleX", x.c_str(), x.size());
-       }
-       if (box.fBottom != SK_Scalar1) {
-               SkString y;
-               y.appendScalar(box.fBottom);
-               parser._addAttributeLen("scaleY", y.c_str(), y.size());
-       }
-       parser._endElement();   
+    SkScalar height, width;
+    SkScalar viewBox[4];
+    const char* hSuffix = SkParse::FindScalar(f_height.c_str(), &height);
+    if (strcmp(hSuffix, "pt") == 0)
+        height = SkScalarMulDiv(height, SK_Scalar1 * 72, SK_Scalar1 * 96);
+    const char* wSuffix = SkParse::FindScalar(f_width.c_str(), &width);
+    if (strcmp(wSuffix, "pt") == 0)
+        width = SkScalarMulDiv(width, SK_Scalar1 * 72, SK_Scalar1 * 96);
+    SkParse::FindScalars(f_viewBox.c_str(), viewBox, 4);
+    SkRect box;
+    box.fLeft = SkScalarDiv(viewBox[0], width);
+    box.fTop = SkScalarDiv(viewBox[1], height);
+    box.fRight = SkScalarDiv(viewBox[2], width);
+    box.fBottom = SkScalarDiv(viewBox[3], height);
+    if (box.fLeft == 0 && box.fTop == 0 && 
+        box.fRight == SK_Scalar1 && box.fBottom == SK_Scalar1) 
+            return;
+    parser._startElement("matrix");
+    if (box.fLeft != 0) {
+        SkString x;
+        x.appendScalar(box.fLeft);
+        parser._addAttributeLen("translateX", x.c_str(), x.size());
+    }
+    if (box.fTop != 0) {
+        SkString y;
+        y.appendScalar(box.fTop);
+        parser._addAttributeLen("translateY", y.c_str(), y.size());
+    }
+    if (box.fRight != SK_Scalar1) {
+        SkString x;
+        x.appendScalar(box.fRight);
+        parser._addAttributeLen("scaleX", x.c_str(), x.size());
+    }
+    if (box.fBottom != SK_Scalar1) {
+        SkString y;
+        y.appendScalar(box.fBottom);
+        parser._addAttributeLen("scaleY", y.c_str(), y.size());
+    }
+    parser._endElement();   
 }
index 0326b46..c8eec08 100644 (file)
@@ -1,22 +1,39 @@
+/* libs/graphics/svg/SkSVGSVG.h
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #ifndef SkSVGSVG_DEFINED
 #define SkSVGSVG_DEFINED
 
 #include "SkSVGElements.h"
 
 class SkSVGSVG : public SkSVGElement {
-       DECLARE_SVG_INFO(SVG);
-       virtual bool isFlushable();
+    DECLARE_SVG_INFO(SVG);
+    virtual bool isFlushable();
 private:
-       SkString f_enable_background;
-       SkString f_height;
-       SkString f_overflow;
-       SkString f_width;
-       SkString f_version;
-       SkString f_viewBox;
-       SkString f_xml_space;
-       SkString f_xmlns;
-       SkString f_xml_xlink;
-       typedef SkSVGElement INHERITED;
+    SkString f_enable_background;
+    SkString f_height;
+    SkString f_overflow;
+    SkString f_width;
+    SkString f_version;
+    SkString f_viewBox;
+    SkString f_xml_space;
+    SkString f_xmlns;
+    SkString f_xml_xlink;
+    typedef SkSVGElement INHERITED;
 };
 
 #endif // SkSVGSVG_DEFINED
index f4d7308..10472d2 100644 (file)
@@ -1,15 +1,32 @@
+/* libs/graphics/svg/SkSVGStop.cpp
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #include "SkSVGStop.h"
 #include "SkSVGParser.h"
 
 const SkSVGAttribute SkSVGStop::gAttributes[] = {
-       SVG_ATTRIBUTE(offset)
+    SVG_ATTRIBUTE(offset)
 };
 
 DEFINE_SVG_INFO(Stop)
 
 void SkSVGStop::translate(SkSVGParser& parser, bool defState) {
-       parser._startElement("color");
-       INHERITED::translate(parser, defState);
-       parser._addAttribute("color", parser.getPaintLast(SkSVGPaint::kStopColor));
-       parser._endElement();
+    parser._startElement("color");
+    INHERITED::translate(parser, defState);
+    parser._addAttribute("color", parser.getPaintLast(SkSVGPaint::kStopColor));
+    parser._endElement();
 }
index e2fe273..50be491 100644 (file)
@@ -1,14 +1,31 @@
+/* libs/graphics/svg/SkSVGStop.h
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #ifndef SkSVGStop_DEFINED
 #define SkSVGStop_DEFINED
 
 #include "SkSVGElements.h"
 
 class SkSVGStop : public SkSVGElement {
-       DECLARE_SVG_INFO(Stop);
+    DECLARE_SVG_INFO(Stop);
 private:
-       SkString f_offset;
-       friend class SkSVGGradient;
-       typedef SkSVGElement INHERITED;
+    SkString f_offset;
+    friend class SkSVGGradient;
+    typedef SkSVGElement INHERITED;
 };
 
 #endif // SkSVGStop_DEFINED
index 5458115..a559397 100644 (file)
@@ -1,13 +1,30 @@
+/* libs/graphics/svg/SkSVGSymbol.cpp
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #include "SkSVGSymbol.h"
 #include "SkSVGParser.h"
 
 const SkSVGAttribute SkSVGSymbol::gAttributes[] = {
-       SVG_ATTRIBUTE(viewBox)
+    SVG_ATTRIBUTE(viewBox)
 };
 
 DEFINE_SVG_INFO(Symbol)
 
 void SkSVGSymbol::translate(SkSVGParser& parser, bool defState) {
-       INHERITED::translate(parser, defState);
-       // !!! children need to be written into document 
+    INHERITED::translate(parser, defState);
+    // !!! children need to be written into document 
 }
index f63d683..08285eb 100644 (file)
@@ -1,13 +1,30 @@
+/* libs/graphics/svg/SkSVGSymbol.h
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #ifndef SkSVGSymbol_DEFINED
 #define SkSVGSymbol_DEFINED
 
 #include "SkSVGElements.h"
 
 class SkSVGSymbol : public SkSVGElement {
-       DECLARE_SVG_INFO(Symbol);
+    DECLARE_SVG_INFO(Symbol);
 private:
-       SkString f_viewBox;
-       typedef SkSVGElement INHERITED;
+    SkString f_viewBox;
+    typedef SkSVGElement INHERITED;
 };
 
 #endif // SkSVGSymbol_DEFINED
index e8d4cd1..930055c 100644 (file)
@@ -1,30 +1,47 @@
+/* libs/graphics/svg/SkSVGText.cpp
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #include "SkSVGText.h"
 #include "SkSVGParser.h"
 
 const SkSVGAttribute SkSVGText::gAttributes[] = {
-       SVG_ATTRIBUTE(x),
-       SVG_ATTRIBUTE(y)
+    SVG_ATTRIBUTE(x),
+    SVG_ATTRIBUTE(y)
 };
 
 DEFINE_SVG_INFO(Text)
 
 void SkSVGText::translate(SkSVGParser& parser, bool defState) {
-       parser._startElement("text");
-       INHERITED::translate(parser, defState);
-       SVG_ADD_ATTRIBUTE(x);
-       SVG_ADD_ATTRIBUTE(y);
-       SVG_ADD_ATTRIBUTE(text);
-       parser._endElement();
+    parser._startElement("text");
+    INHERITED::translate(parser, defState);
+    SVG_ADD_ATTRIBUTE(x);
+    SVG_ADD_ATTRIBUTE(y);
+    SVG_ADD_ATTRIBUTE(text);
+    parser._endElement();
 }
 
 
 const SkSVGAttribute SkSVGTspan::gAttributes[] = {
-       SVG_ATTRIBUTE(x),
-       SVG_ATTRIBUTE(y)
+    SVG_ATTRIBUTE(x),
+    SVG_ATTRIBUTE(y)
 };
 
 DEFINE_SVG_INFO(Tspan)
 
 void SkSVGTspan::translate(SkSVGParser& parser, bool defState) {
-       INHERITED::translate(parser, defState);
+    INHERITED::translate(parser, defState);
 }
index 76703d5..82f0242 100644 (file)
@@ -1,23 +1,40 @@
+/* libs/graphics/svg/SkSVGText.h
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #ifndef SkSVGText_DEFINED
 #define SkSVGText_DEFINED
 
 #include "SkSVGElements.h"
 
 class SkSVGText : public SkSVGElement {
-       DECLARE_SVG_INFO(Text);
+    DECLARE_SVG_INFO(Text);
 protected:
-       SkString f_x;
-       SkString f_y;
-       SkString f_text;        // not an attribute
+    SkString f_x;
+    SkString f_y;
+    SkString f_text;    // not an attribute
 private:
-       typedef SkSVGElement INHERITED;
-       friend class SkSVGParser;
+    typedef SkSVGElement INHERITED;
+    friend class SkSVGParser;
 };
 
 class SkSVGTspan : public SkSVGText {
-       DECLARE_SVG_INFO(Tspan);
+    DECLARE_SVG_INFO(Tspan);
 private:
-       typedef SkSVGText INHERITED;
+    typedef SkSVGText INHERITED;
 };
 
 #endif // SkSVGText_DEFINED
index 4d2a6e4..9c419e0 100644 (file)
@@ -1,21 +1,38 @@
+/* libs/graphics/svg/SkSVGUse.cpp
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #include "SkSVGUse.h"
 #include "SkSVGParser.h"
 
 const SkSVGAttribute SkSVGUse::gAttributes[] = {
-       SVG_ATTRIBUTE(height),
-       SVG_ATTRIBUTE(width),
-       SVG_ATTRIBUTE(x),
-       SVG_LITERAL_ATTRIBUTE(xlink:href, f_xlink_href),
-       SVG_ATTRIBUTE(y)
+    SVG_ATTRIBUTE(height),
+    SVG_ATTRIBUTE(width),
+    SVG_ATTRIBUTE(x),
+    SVG_LITERAL_ATTRIBUTE(xlink:href, f_xlink_href),
+    SVG_ATTRIBUTE(y)
 };
 
 DEFINE_SVG_INFO(Use)
 
 void SkSVGUse::translate(SkSVGParser& parser, bool defState) {
-       INHERITED::translate(parser, defState);
-       parser._startElement("add");
-       const char* start = strchr(f_xlink_href.c_str(), '#') + 1;
-       SkASSERT(start);
-       parser._addAttributeLen("use", start, strlen(start) - 1);
-       parser._endElement();   // clip
+    INHERITED::translate(parser, defState);
+    parser._startElement("add");
+    const char* start = strchr(f_xlink_href.c_str(), '#') + 1;
+    SkASSERT(start);
+    parser._addAttributeLen("use", start, strlen(start) - 1);
+    parser._endElement();   // clip
 }
index 5ea9ac5..1c024d5 100644 (file)
@@ -1,19 +1,36 @@
+/* libs/graphics/svg/SkSVGUse.h
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #ifndef SkSVGUse_DEFINED
 #define SkSVGUse_DEFINED
 
 #include "SkSVGElements.h"
 
 class SkSVGUse : public SkSVGElement {
-       DECLARE_SVG_INFO(Use);
+    DECLARE_SVG_INFO(Use);
 protected:
-       SkString f_height;
-       SkString f_width;
-       SkString f_x;
-       SkString f_xlink_href;
-       SkString f_y;
+    SkString f_height;
+    SkString f_width;
+    SkString f_x;
+    SkString f_xlink_href;
+    SkString f_y;
 private:
-       typedef SkSVGElement INHERITED;
-       friend class SkSVGClipPath;
+    typedef SkSVGElement INHERITED;
+    friend class SkSVGClipPath;
 };
 
 #endif // SkSVGUse_DEFINED
index 0a584b7..8d7b60d 100644 (file)
@@ -1,3 +1,20 @@
+/* libs/graphics/text/ATextEntry.h
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #ifndef ATextEntry_DEFINED
 #define ATextEntry_DEFINED
 
index f7a9648..7d00862 100644 (file)
+/* libs/graphics/views/SkEvent.cpp
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #include "SkEvent.h"
 
 void SkEvent::initialize(const char* type, size_t typeLen) {
-       fType = NULL;
-       setType(type, typeLen);
-       f32 = 0;
+    fType = NULL;
+    setType(type, typeLen);
+    f32 = 0;
 #ifdef SK_DEBUG
-       fTargetID = 0;
-       fTime = 0;
-       fNextEvent = NULL;
+    fTargetID = 0;
+    fTime = 0;
+    fNextEvent = NULL;
 #endif
-       SkDEBUGCODE(fDebugTrace = false;)
+    SkDEBUGCODE(fDebugTrace = false;)
 }
 
 SkEvent::SkEvent()
 {
-       initialize("", 0);
+    initialize("", 0);
 }
 
 SkEvent::SkEvent(const SkEvent& src)
 {
-       *this = src;
-       if (((size_t) fType & 1) == 0)
-               setType(src.fType);
+    *this = src;
+    if (((size_t) fType & 1) == 0)
+        setType(src.fType);
 }
 
 SkEvent::SkEvent(const SkString& type)
 {
-       initialize(type.c_str(), type.size());
+    initialize(type.c_str(), type.size());
 }
 
 SkEvent::SkEvent(const char type[])
 {
-       SkASSERT(type);
-       initialize(type, strlen(type));
+    SkASSERT(type);
+    initialize(type, strlen(type));
 }
 
 SkEvent::~SkEvent()
 {
-       if (((size_t) fType & 1) == 0)
-               sk_free((void*) fType);
+    if (((size_t) fType & 1) == 0)
+        sk_free((void*) fType);
 }
 
 static size_t makeCharArray(char* buffer, size_t compact)
 {
-       size_t bits = (size_t) compact >> 1;
-       memcpy(buffer, &bits, sizeof(compact));
-       buffer[sizeof(compact)] = 0;
-       return strlen(buffer);
+    size_t bits = (size_t) compact >> 1;
+    memcpy(buffer, &bits, sizeof(compact));
+    buffer[sizeof(compact)] = 0;
+    return strlen(buffer);
 }
 
 #if 0
 const char* SkEvent::getType() const 
 { 
-       if ((size_t) fType & 1) {       // not a pointer
-               char chars[sizeof(size_t) + 1];
-               size_t len = makeCharArray(chars, (size_t) fType);
-               fType = (char*) sk_malloc_throw(len);
-               SkASSERT(((size_t) fType & 1) == 0);
-               memcpy(fType, chars, len);
-       }
-       return fType; 
+    if ((size_t) fType & 1) {   // not a pointer
+        char chars[sizeof(size_t) + 1];
+        size_t len = makeCharArray(chars, (size_t) fType);
+        fType = (char*) sk_malloc_throw(len);
+        SkASSERT(((size_t) fType & 1) == 0);
+        memcpy(fType, chars, len);
+    }
+    return fType; 
 }
 #endif
 
 void SkEvent::getType(SkString* str) const 
 { 
-       if (str) 
-       {
-               if ((size_t) fType & 1) // not a pointer
-               {
-                       char chars[sizeof(size_t) + 1];
-                       size_t len = makeCharArray(chars, (size_t) fType);
-                       str->set(chars, len);
-               }
-               else
-                       str->set(fType);
-       }
+    if (str) 
+    {
+        if ((size_t) fType & 1) // not a pointer
+        {
+            char chars[sizeof(size_t) + 1];
+            size_t len = makeCharArray(chars, (size_t) fType);
+            str->set(chars, len);
+        }
+        else
+            str->set(fType);
+    }
 }
 
 bool SkEvent::isType(const SkString& str) const 
 {
-       return this->isType(str.c_str(), str.size()); 
+    return this->isType(str.c_str(), str.size()); 
 }
 
 bool SkEvent::isType(const char type[], size_t typeLen) const 
 { 
-       if (typeLen == 0)
-               typeLen = strlen(type);
-       if ((size_t) fType & 1) {       // not a pointer
-               char chars[sizeof(size_t) + 1];
-               size_t len = makeCharArray(chars, (size_t) fType);
-               return len == typeLen && strncmp(chars, type, typeLen) == 0;
-       }
-       return strncmp(fType, type, typeLen) == 0 && fType[typeLen] == 0; 
+    if (typeLen == 0)
+        typeLen = strlen(type);
+    if ((size_t) fType & 1) {   // not a pointer
+        char chars[sizeof(size_t) + 1];
+        size_t len = makeCharArray(chars, (size_t) fType);
+        return len == typeLen && strncmp(chars, type, typeLen) == 0;
+    }
+    return strncmp(fType, type, typeLen) == 0 && fType[typeLen] == 0; 
 }
 
 void SkEvent::setType(const char type[], size_t typeLen)
 {
-       if (typeLen == 0)
-               typeLen = strlen(type);
-       if (typeLen <= sizeof(fType)) {
-               size_t slot = 0;
-               memcpy(&slot, type, typeLen);
-               if (slot << 1 >> 1 != slot)
-                       goto useCharStar;
-               slot <<= 1;
-               slot |= 1;
-               fType = (char*) slot;
-       } else {
+    if (typeLen == 0)
+        typeLen = strlen(type);
+    if (typeLen <= sizeof(fType)) {
+        size_t slot = 0;
+        memcpy(&slot, type, typeLen);
+        if (slot << 1 >> 1 != slot)
+            goto useCharStar;
+        slot <<= 1;
+        slot |= 1;
+        fType = (char*) slot;
+    } else {
 useCharStar:
-               fType = (char*) sk_malloc_throw(typeLen + 1);
-               SkASSERT(((size_t) fType & 1) == 0);
-               memcpy(fType, type, typeLen);
-               fType[typeLen] = 0;
-       }
+        fType = (char*) sk_malloc_throw(typeLen + 1);
+        SkASSERT(((size_t) fType & 1) == 0);
+        memcpy(fType, type, typeLen);
+        fType[typeLen] = 0;
+    }
 }
 
 void SkEvent::setType(const SkString& type)
 {
-       setType(type.c_str());
+    setType(type.c_str());
 }
 
 ////////////////////////////////////////////////////////////////////////////
@@ -127,127 +144,127 @@ void SkEvent::setType(const SkString& type)
 
 void SkEvent::inflate(const SkDOM& dom, const SkDOM::Node* node)
 {
-       const char* name = dom.findAttr(node, "type");
-       if (name)
-               this->setType(name);
-
-       const char* value;
-       if ((value = dom.findAttr(node, "fast32")) != NULL)
-       {
-               int32_t n;
-               if (SkParse::FindS32(value, &n))
-                       this->setFast32(n);
-       }
-
-       for (node = dom.getFirstChild(node); node; node = dom.getNextSibling(node))
-       {
-               if (strcmp(dom.getName(node), "data"))
-               {
-                       SkDEBUGCODE(SkDebugf("SkEvent::inflate unrecognized subelement <%s>\n", dom.getName(node));)
-                       continue;
-               }
-
-               name = dom.findAttr(node, "name");
-               if (name == NULL)
-               {
-                       SkDEBUGCODE(SkDebugf("SkEvent::inflate missing required \"name\" attribute in <data> subelement\n");)
-                       continue;
-               }
-
-               if ((value = dom.findAttr(node, "s32")) != NULL)
-               {
-                       int32_t n;
-                       if (SkParse::FindS32(value, &n))
-                               this->setS32(name, n);
-               }
-               else if ((value = dom.findAttr(node, "scalar")) != NULL)
-               {
-                       SkScalar x;
-                       if (SkParse::FindScalar(value, &x))
-                               this->setScalar(name, x);
-               }
-               else if ((value = dom.findAttr(node, "string")) != NULL)
-                       this->setString(name, value);
+    const char* name = dom.findAttr(node, "type");
+    if (name)
+        this->setType(name);
+
+    const char* value;
+    if ((value = dom.findAttr(node, "fast32")) != NULL)
+    {
+        int32_t n;
+        if (SkParse::FindS32(value, &n))
+            this->setFast32(n);
+    }
+
+    for (node = dom.getFirstChild(node); node; node = dom.getNextSibling(node))
+    {
+        if (strcmp(dom.getName(node), "data"))
+        {
+            SkDEBUGCODE(SkDebugf("SkEvent::inflate unrecognized subelement <%s>\n", dom.getName(node));)
+            continue;
+        }
+
+        name = dom.findAttr(node, "name");
+        if (name == NULL)
+        {
+            SkDEBUGCODE(SkDebugf("SkEvent::inflate missing required \"name\" attribute in <data> subelement\n");)
+            continue;
+        }
+
+        if ((value = dom.findAttr(node, "s32")) != NULL)
+        {
+            int32_t n;
+            if (SkParse::FindS32(value, &n))
+                this->setS32(name, n);
+        }
+        else if ((value = dom.findAttr(node, "scalar")) != NULL)
+        {
+            SkScalar x;
+            if (SkParse::FindScalar(value, &x))
+                this->setScalar(name, x);
+        }
+        else if ((value = dom.findAttr(node, "string")) != NULL)
+            this->setString(name, value);
 #ifdef SK_DEBUG
-               else
-               {
-                       SkDebugf("SkEvent::inflate <data name=\"%s\"> subelement missing required type attribute [S32 | scalar | string]\n", name);
-               }
+        else
+        {
+            SkDebugf("SkEvent::inflate <data name=\"%s\"> subelement missing required type attribute [S32 | scalar | string]\n", name);
+        }
 #endif
-       }
+    }
 }
 
 #ifdef SK_DEBUG
 
-       #ifndef SkScalarToFloat
-               #define SkScalarToFloat(x)      ((x) / 65536.f)
-       #endif
-
-       void SkEvent::dump(const char title[])
-       {
-               if (title)
-                       SkDebugf("%s ", title);
-                       
-               SkString        etype;
-               this->getType(&etype);
-               SkDebugf("event<%s> fast32=%d", etype.c_str(), this->getFast32());
-
-               const SkMetaData&       md = this->getMetaData();
-               SkMetaData::Iter        iter(md);
-               SkMetaData::Type        mtype;
-               int                                     count;
-               const char*                     name;
-               
-               while ((name = iter.next(&mtype, &count)) != NULL)
-               {
-                       SkASSERT(count > 0);
-
-                       SkDebugf(" <%s>=", name);
-                       switch (mtype) {
-                       case SkMetaData::kS32_Type:             // vector version???
-                               {
-                                       int32_t value;
-                                       md.findS32(name, &value);
-                                       SkDebugf("%d ", value);
-                               }
-                               break;
-                       case SkMetaData::kScalar_Type:
-                               {
-                                       const SkScalar* values = md.findScalars(name, &count, NULL);
-                                       SkDebugf("%f", SkScalarToFloat(values[0]));
-                                       for (int i = 1; i < count; i++)
-                                               SkDebugf(", %f", SkScalarToFloat(values[i]));
-                                       SkDebugf(" ");
-                               }
-                               break;
-                       case SkMetaData::kString_Type:
-                               {
-                                       const char* value = md.findString(name);
-                                       SkASSERT(value);
-                                       SkDebugf("<%s> ", value);
-                               }
-                               break;
-                       case SkMetaData::kPtr_Type:             // vector version???
-                               {
-                                       void*   value;
-                                       md.findPtr(name, &value);
-                                       SkDebugf("%p ", value);
-                               }
-                               break;
-                       case SkMetaData::kBool_Type:    // vector version???
-                               {
-                                       bool    value;
-                                       md.findBool(name, &value);
-                                       SkDebugf("%s ", value ? "true" : "false");
-                               }
-                               break;
-                       default:
-                               SkASSERT(!"unknown metadata type returned from iterator");
-                               break;
-                       }
-               }
-               SkDebugf("\n");
-       }
+    #ifndef SkScalarToFloat
+        #define SkScalarToFloat(x)  ((x) / 65536.f)
+    #endif
+
+    void SkEvent::dump(const char title[])
+    {
+        if (title)
+            SkDebugf("%s ", title);
+            
+        SkString    etype;
+        this->getType(&etype);
+        SkDebugf("event<%s> fast32=%d", etype.c_str(), this->getFast32());
+
+        const SkMetaData&   md = this->getMetaData();
+        SkMetaData::Iter    iter(md);
+        SkMetaData::Type    mtype;
+        int                 count;
+        const char*         name;
+        
+        while ((name = iter.next(&mtype, &count)) != NULL)
+        {
+            SkASSERT(count > 0);
+
+            SkDebugf(" <%s>=", name);
+            switch (mtype) {
+            case SkMetaData::kS32_Type:     // vector version???
+                {
+                    int32_t value;
+                    md.findS32(name, &value);
+                    SkDebugf("%d ", value);
+                }
+                break;
+            case SkMetaData::kScalar_Type:
+                {
+                    const SkScalar* values = md.findScalars(name, &count, NULL);
+                    SkDebugf("%f", SkScalarToFloat(values[0]));
+                    for (int i = 1; i < count; i++)
+                        SkDebugf(", %f", SkScalarToFloat(values[i]));
+                    SkDebugf(" ");
+                }
+                break;
+            case SkMetaData::kString_Type:
+                {
+                    const char* value = md.findString(name);
+                    SkASSERT(value);
+                    SkDebugf("<%s> ", value);
+                }
+                break;
+            case SkMetaData::kPtr_Type:     // vector version???
+                {
+                    void*   value;
+                    md.findPtr(name, &value);
+                    SkDebugf("%p ", value);
+                }
+                break;
+            case SkMetaData::kBool_Type:    // vector version???
+                {
+                    bool    value;
+                    md.findBool(name, &value);
+                    SkDebugf("%s ", value ? "true" : "false");
+                }
+                break;
+            default:
+                SkASSERT(!"unknown metadata type returned from iterator");
+                break;
+            }
+        }
+        SkDebugf("\n");
+    }
 #endif
 
 ///////////////////////////////////////////////////////////////////////////////////////
@@ -257,72 +274,72 @@ void SkEvent::inflate(const SkDOM& dom, const SkDOM::Node* node)
 #endif
 
 #ifdef SK_TRACE_EVENTS
-       static void event_log(const char s[])
-       {
-               SkDEBUGF(("%s\n", s));
-       }
+    static void event_log(const char s[])
+    {
+        SkDEBUGF(("%s\n", s));
+    }
 
-       #define EVENT_LOG(s)            event_log(s)
-       #define EVENT_LOGN(s, n)        do { SkString str(s); str.append(" "); str.appendS32(n); event_log(str.c_str()); } while (0)
+    #define EVENT_LOG(s)        event_log(s)
+    #define EVENT_LOGN(s, n)    do { SkString str(s); str.append(" "); str.appendS32(n); event_log(str.c_str()); } while (0)
 #else
-       #define EVENT_LOG(s)
-       #define EVENT_LOGN(s, n)
+    #define EVENT_LOG(s)
+    #define EVENT_LOGN(s, n)
 #endif
 
 #include "SkGlobals.h"
 #include "SkThread.h"
 #include "SkTime.h"
 
-#define SK_Event_GlobalsTag            SkSetFourByteTag('e', 'v', 'n', 't')
+#define SK_Event_GlobalsTag     SkSetFourByteTag('e', 'v', 'n', 't')
 
 class SkEvent_Globals : public SkGlobals::Rec {
 public:
-       SkMutex         fEventMutex;
-       SkEvent*        fEventQHead, *fEventQTail;
-       SkEvent*        fDelayQHead;
-       SkDEBUGCODE(int fEventCounter;)
+    SkMutex     fEventMutex;
+    SkEvent*    fEventQHead, *fEventQTail;
+    SkEvent*    fDelayQHead;
+    SkDEBUGCODE(int fEventCounter;)
 };
 
 static SkGlobals::Rec* create_globals()
 {
-       SkEvent_Globals* rec = new SkEvent_Globals;
-       rec->fEventQHead = NULL;
-       rec->fEventQTail = NULL;
-       rec->fDelayQHead = NULL;
-       SkDEBUGCODE(rec->fEventCounter = 0;)
-       return rec;
+    SkEvent_Globals* rec = new SkEvent_Globals;
+    rec->fEventQHead = NULL;
+    rec->fEventQTail = NULL;
+    rec->fDelayQHead = NULL;
+    SkDEBUGCODE(rec->fEventCounter = 0;)
+    return rec;
 }
 
 bool SkEvent::Post(SkEvent* evt, SkEventSinkID sinkID, SkMSec delay)
 {
-       if (delay)
-               return SkEvent::PostTime(evt, sinkID, SkTime::GetMSecs() + delay);
+    if (delay)
+        return SkEvent::PostTime(evt, sinkID, SkTime::GetMSecs() + delay);
 
-       SkEvent_Globals& globals = *(SkEvent_Globals*)SkGlobals::Find(SK_Event_GlobalsTag, create_globals);
+    SkEvent_Globals& globals = *(SkEvent_Globals*)SkGlobals::Find(SK_Event_GlobalsTag, create_globals);
 
-       evt->fTargetID = sinkID;
+    evt->fTargetID = sinkID;
 
 #ifdef SK_TRACE_EVENTS
-       {
-               SkString        str("SkEvent::Post(");
-               str.append(evt->getType());
-               str.append(", 0x");
-               str.appendHex(sinkID);
-               str.append(", ");
-               str.appendS32(delay);
-               str.append(")");
-               event_log(str.c_str());
-       }
+    {
+        SkString    str("SkEvent::Post(");
+        str.append(evt->getType());
+        str.append(", 0x");
+        str.appendHex(sinkID);
+        str.append(", ");
+        str.appendS32(delay);
+        str.append(")");
+        event_log(str.c_str());
+    }
 #endif
 
-       globals.fEventMutex.acquire();
-       bool wasEmpty = SkEvent::Enqueue(evt);
-       globals.fEventMutex.release();
+    globals.fEventMutex.acquire();
+    bool wasEmpty = SkEvent::Enqueue(evt);
+    globals.fEventMutex.release();
 
-       // call outside of us holding the mutex
-       if (wasEmpty)
-               SkEvent::SignalNonEmptyQueue();
-       return true;
+    // call outside of us holding the mutex
+    if (wasEmpty)
+        SkEvent::SignalNonEmptyQueue();
+    return true;
 }
 
 #if defined(SK_SIMULATE_FAILED_MALLOC) && defined(SK_FIND_MEMORY_LEAKS)
@@ -332,129 +349,129 @@ SkMSec gMaxDrawTime;
 bool SkEvent::PostTime(SkEvent* evt, SkEventSinkID sinkID, SkMSec time)
 {
 #if defined(SK_SIMULATE_FAILED_MALLOC) && defined(SK_FIND_MEMORY_LEAKS)
-       gMaxDrawTime = time;
+    gMaxDrawTime = time;
 #endif
-       SkEvent_Globals& globals = *(SkEvent_Globals*)SkGlobals::Find(SK_Event_GlobalsTag, create_globals);
+    SkEvent_Globals& globals = *(SkEvent_Globals*)SkGlobals::Find(SK_Event_GlobalsTag, create_globals);
 
-       evt->fTargetID = sinkID;
+    evt->fTargetID = sinkID;
 
 #ifdef SK_TRACE_EVENTS
-       {
-               SkString        str("SkEvent::Post(");
-               str.append(evt->getType());
-               str.append(", 0x");
-               str.appendHex(sinkID);
-               str.append(", ");
-               str.appendS32(time);
-               str.append(")");
-               event_log(str.c_str());
-       }
+    {
+        SkString    str("SkEvent::Post(");
+        str.append(evt->getType());
+        str.append(", 0x");
+        str.appendHex(sinkID);
+        str.append(", ");
+        str.appendS32(time);
+        str.append(")");
+        event_log(str.c_str());
+    }
 #endif
 
-       globals.fEventMutex.acquire();
-       SkMSec queueDelay = SkEvent::EnqueueTime(evt, time);
-       globals.fEventMutex.release();
+    globals.fEventMutex.acquire();
+    SkMSec queueDelay = SkEvent::EnqueueTime(evt, time);
+    globals.fEventMutex.release();
 
-       // call outside of us holding the mutex
-       if ((int32_t)queueDelay != ~0)
-               SkEvent::SignalQueueTimer(queueDelay);
-       return true;
+    // call outside of us holding the mutex
+    if ((int32_t)queueDelay != ~0)
+        SkEvent::SignalQueueTimer(queueDelay);
+    return true;
 }
 
 bool SkEvent::Enqueue(SkEvent* evt)
 {
-       SkEvent_Globals& globals = *(SkEvent_Globals*)SkGlobals::Find(SK_Event_GlobalsTag, create_globals);
-       //      gEventMutex acquired by caller
+    SkEvent_Globals& globals = *(SkEvent_Globals*)SkGlobals::Find(SK_Event_GlobalsTag, create_globals);
+    //  gEventMutex acquired by caller
 
-       SkASSERT(evt);
+    SkASSERT(evt);
 
-       bool wasEmpty = globals.fEventQHead == NULL;
+    bool wasEmpty = globals.fEventQHead == NULL;
 
-       if (globals.fEventQTail)
-               globals.fEventQTail->fNextEvent = evt;
-       globals.fEventQTail = evt;
-       if (globals.fEventQHead == NULL)
-               globals.fEventQHead = evt;
-       evt->fNextEvent = NULL;
+    if (globals.fEventQTail)
+        globals.fEventQTail->fNextEvent = evt;
+    globals.fEventQTail = evt;
+    if (globals.fEventQHead == NULL)
+        globals.fEventQHead = evt;
+    evt->fNextEvent = NULL;
 
-       SkDEBUGCODE(++globals.fEventCounter);
-//     SkDebugf("Enqueue: count=%d\n", gEventCounter);
+    SkDEBUGCODE(++globals.fEventCounter);
+//  SkDebugf("Enqueue: count=%d\n", gEventCounter);
 
-       return wasEmpty;
+    return wasEmpty;
 }
 
 SkEvent* SkEvent::Dequeue(SkEventSinkID* sinkID)
 {
-       SkEvent_Globals& globals = *(SkEvent_Globals*)SkGlobals::Find(SK_Event_GlobalsTag, create_globals);
-       globals.fEventMutex.acquire();
+    SkEvent_Globals& globals = *(SkEvent_Globals*)SkGlobals::Find(SK_Event_GlobalsTag, create_globals);
+    globals.fEventMutex.acquire();
 
-       SkEvent* evt = globals.fEventQHead;
-       if (evt)
-       {
-               SkDEBUGCODE(--globals.fEventCounter);
+    SkEvent* evt = globals.fEventQHead;
+    if (evt)
+    {
+        SkDEBUGCODE(--globals.fEventCounter);
 
-               if (sinkID)
-                       *sinkID = evt->fTargetID;
+        if (sinkID)
+            *sinkID = evt->fTargetID;
 
-               globals.fEventQHead = evt->fNextEvent;
-               if (globals.fEventQHead == NULL)
-                       globals.fEventQTail = NULL;
-       }
-       globals.fEventMutex.release();
+        globals.fEventQHead = evt->fNextEvent;
+        if (globals.fEventQHead == NULL)
+            globals.fEventQTail = NULL;
+    }
+    globals.fEventMutex.release();
 
-//     SkDebugf("Dequeue: count=%d\n", gEventCounter);
+//  SkDebugf("Dequeue: count=%d\n", gEventCounter);
 
-       return evt;
+    return evt;
 }
 
 bool SkEvent::QHasEvents()
 {
-       SkEvent_Globals& globals = *(SkEvent_Globals*)SkGlobals::Find(SK_Event_GlobalsTag, create_globals);
+    SkEvent_Globals& globals = *(SkEvent_Globals*)SkGlobals::Find(SK_Event_GlobalsTag, create_globals);
 
-       // this is not thread accurate, need a semaphore for that
-       return globals.fEventQHead != NULL;
+    // this is not thread accurate, need a semaphore for that
+    return globals.fEventQHead != NULL;
 }
 
 #ifdef SK_TRACE_EVENTS
-       static int gDelayDepth;
+    static int gDelayDepth;
 #endif
 
 SkMSec SkEvent::EnqueueTime(SkEvent* evt, SkMSec time)
 {
 #ifdef SK_TRACE_EVENTS
-       SkDebugf("enqueue-delay %s %d (%d)", evt->getType(), time, gDelayDepth);
-       const char* idStr = evt->findString("id");
-       if (idStr)
-               SkDebugf(" (%s)", idStr);
-       SkDebugf("\n");
-       ++gDelayDepth;
+    SkDebugf("enqueue-delay %s %d (%d)", evt->getType(), time, gDelayDepth);
+    const char* idStr = evt->findString("id");
+    if (idStr)
+        SkDebugf(" (%s)", idStr);
+    SkDebugf("\n");
+    ++gDelayDepth;
 #endif
 
-       SkEvent_Globals& globals = *(SkEvent_Globals*)SkGlobals::Find(SK_Event_GlobalsTag, create_globals);
-       //      gEventMutex acquired by caller
-
-       SkEvent* curr = globals.fDelayQHead;
-       SkEvent* prev = NULL;
-
-       while (curr)
-       {
-               if (SkMSec_LT(time, curr->fTime))
-                       break;
-               prev = curr;
-               curr = curr->fNextEvent;
-       }
-
-       evt->fTime = time;
-       evt->fNextEvent = curr;
-       if (prev == NULL)
-               globals.fDelayQHead = evt;
-       else
-               prev->fNextEvent = evt;
-
-       SkMSec delay = globals.fDelayQHead->fTime - SkTime::GetMSecs();
-       if ((int32_t)delay <= 0)
-               delay = 1;
-       return delay;
+    SkEvent_Globals& globals = *(SkEvent_Globals*)SkGlobals::Find(SK_Event_GlobalsTag, create_globals);
+    //  gEventMutex acquired by caller
+
+    SkEvent* curr = globals.fDelayQHead;
+    SkEvent* prev = NULL;
+
+    while (curr)
+    {
+        if (SkMSec_LT(time, curr->fTime))
+            break;
+        prev = curr;
+        curr = curr->fNextEvent;
+    }
+
+    evt->fTime = time;
+    evt->fNextEvent = curr;
+    if (prev == NULL)
+        globals.fDelayQHead = evt;
+    else
+        prev->fNextEvent = evt;
+
+    SkMSec delay = globals.fDelayQHead->fTime - SkTime::GetMSecs();
+    if ((int32_t)delay <= 0)
+        delay = 1;
+    return delay;
 }
 
 //////////////////////////////////////////////////////////////////////////////
@@ -463,60 +480,60 @@ SkMSec SkEvent::EnqueueTime(SkEvent* evt, SkMSec time)
 
 bool SkEvent::ProcessEvent()
 {
-       SkEventSinkID   sinkID;
-       SkEvent*                evt = SkEvent::Dequeue(&sinkID);
-       SkAutoTDelete<SkEvent>  autoDelete(evt);
-       bool                    again = false;
-
-       EVENT_LOGN("ProcessEvent", (int32_t)evt);
-
-       if (evt)
-       {
-               (void)SkEventSink::DoEvent(*evt, sinkID);
-               again = SkEvent::QHasEvents();
-       }
-       return again;
+    SkEventSinkID   sinkID;
+    SkEvent*        evt = SkEvent::Dequeue(&sinkID);
+    SkAutoTDelete<SkEvent>  autoDelete(evt);
+    bool            again = false;
+
+    EVENT_LOGN("ProcessEvent", (int32_t)evt);
+
+    if (evt)
+    {
+        (void)SkEventSink::DoEvent(*evt, sinkID);
+        again = SkEvent::QHasEvents();
+    }
+    return again;
 }
 
 void SkEvent::ServiceQueueTimer()
 {
-       SkEvent_Globals& globals = *(SkEvent_Globals*)SkGlobals::Find(SK_Event_GlobalsTag, create_globals);
+    SkEvent_Globals& globals = *(SkEvent_Globals*)SkGlobals::Find(SK_Event_GlobalsTag, create_globals);
 
-       globals.fEventMutex.acquire();
+    globals.fEventMutex.acquire();
 
-       bool            wasEmpty = false;
-       SkMSec          now = SkTime::GetMSecs();
-       SkEvent*        evt = globals.fDelayQHead;
+    bool        wasEmpty = false;
+    SkMSec      now = SkTime::GetMSecs();
+    SkEvent*    evt = globals.fDelayQHead;
 
-       while (evt)
-       {
-               if (SkMSec_LT(now, evt->fTime))
-                       break;
+    while (evt)
+    {
+        if (SkMSec_LT(now, evt->fTime))
+            break;
 
 #ifdef SK_TRACE_EVENTS
-               --gDelayDepth;
-               SkDebugf("dequeue-delay %s (%d)", evt->getType(), gDelayDepth);
-               const char* idStr = evt->findString("id");
-               if (idStr)
-                       SkDebugf(" (%s)", idStr);
-               SkDebugf("\n");
+        --gDelayDepth;
+        SkDebugf("dequeue-delay %s (%d)", evt->getType(), gDelayDepth);
+        const char* idStr = evt->findString("id");
+        if (idStr)
+            SkDebugf(" (%s)", idStr);
+        SkDebugf("\n");
 #endif
 
-               SkEvent* next = evt->fNextEvent;
-               if (SkEvent::Enqueue(evt))
-                       wasEmpty = true;
-               evt = next;
-       }
-       globals.fDelayQHead = evt;
+        SkEvent* next = evt->fNextEvent;
+        if (SkEvent::Enqueue(evt))
+            wasEmpty = true;
+        evt = next;
+    }
+    globals.fDelayQHead = evt;
 
-       SkMSec time = evt ? evt->fTime - now : 0;
+    SkMSec time = evt ? evt->fTime - now : 0;
 
-       globals.fEventMutex.release();
+    globals.fEventMutex.release();
 
-       if (wasEmpty)
-               SkEvent::SignalNonEmptyQueue();
+    if (wasEmpty)
+        SkEvent::SignalNonEmptyQueue();
 
-       SkEvent::SignalQueueTimer(time);
+    SkEvent::SignalQueueTimer(time);
 }
 
 ////////////////////////////////////////////////////////////////
@@ -527,22 +544,22 @@ void SkEvent::Init()
 
 void SkEvent::Term()
 {
-       SkEvent_Globals& globals = *(SkEvent_Globals*)SkGlobals::Find(SK_Event_GlobalsTag, create_globals);
-
-       SkEvent* evt = globals.fEventQHead;
-       while (evt)
-       {
-               SkEvent* next = evt->fNextEvent;
-               delete evt;
-               evt = next;
-       }
-
-       evt = globals.fDelayQHead;
-       while (evt)
-       {
-               SkEvent* next = evt->fNextEvent;
-               delete evt;
-               evt = next;
-       }
+    SkEvent_Globals& globals = *(SkEvent_Globals*)SkGlobals::Find(SK_Event_GlobalsTag, create_globals);
+
+    SkEvent* evt = globals.fEventQHead;
+    while (evt)
+    {
+        SkEvent* next = evt->fNextEvent;
+        delete evt;
+        evt = next;
+    }
+
+    evt = globals.fDelayQHead;
+    while (evt)
+    {
+        SkEvent* next = evt->fNextEvent;
+        delete evt;
+        evt = next;
+    }
 }
 
index e2a45f0..45cfe6a 100644 (file)
@@ -1,3 +1,20 @@
+/* libs/graphics/views/SkEventSink.cpp
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #include "SkEventSink.h"
 #include "SkTagList.h"
 #include "SkThread.h"
 #include "SkThread.h"
 #include "SkTime.h"
 
-#define SK_EventSink_GlobalsTag                SkSetFourByteTag('e', 'v', 's', 'k')
+#define SK_EventSink_GlobalsTag     SkSetFourByteTag('e', 'v', 's', 'k')
 
 class SkEventSink_Globals : public SkGlobals::Rec {
 public:
-       SkMutex                 fSinkMutex;
-       SkEventSinkID   fNextSinkID;
-       SkEventSink*    fSinkHead;
+    SkMutex         fSinkMutex;
+    SkEventSinkID   fNextSinkID;
+    SkEventSink*    fSinkHead;
 };
 
 static SkGlobals::Rec* create_globals()
 {
-       SkEventSink_Globals* rec = new SkEventSink_Globals;
-       rec->fNextSinkID = 0;
-       rec->fSinkHead = nil;
-       return rec;
+    SkEventSink_Globals* rec = new SkEventSink_Globals;
+    rec->fNextSinkID = 0;
+    rec->fSinkHead = nil;
+    return rec;
 }
 
 SkEventSink::SkEventSink() : fTagHead(nil)
 {
-       SkEventSink_Globals& globals = *(SkEventSink_Globals*)SkGlobals::Find(SK_EventSink_GlobalsTag, create_globals);
+    SkEventSink_Globals& globals = *(SkEventSink_Globals*)SkGlobals::Find(SK_EventSink_GlobalsTag, create_globals);
 
-       globals.fSinkMutex.acquire();
+    globals.fSinkMutex.acquire();
 
-       fID = ++globals.fNextSinkID;
-       fNextSink = globals.fSinkHead;
-       globals.fSinkHead = this;
+    fID = ++globals.fNextSinkID;
+    fNextSink = globals.fSinkHead;
+    globals.fSinkHead = this;
 
-       globals.fSinkMutex.release();
+    globals.fSinkMutex.release();
 }
 
 SkEventSink::~SkEventSink()
 {
-       SkEventSink_Globals& globals = *(SkEventSink_Globals*)SkGlobals::Find(SK_EventSink_GlobalsTag, create_globals);
-
-       if (fTagHead)
-               SkTagList::DeleteAll(fTagHead);
-
-       globals.fSinkMutex.acquire();
-
-       SkEventSink* sink = globals.fSinkHead;
-       SkEventSink* prev = nil;
-
-       for (;;)
-       {
-               SkEventSink* next = sink->fNextSink;
-               if (sink == this)
-               {
-                       if (prev)
-                               prev->fNextSink = next;
-                       else
-                               globals.fSinkHead = next;
-                       break;
-               }
-               prev = sink;
-               sink = next;
-       }
-       globals.fSinkMutex.release();
+    SkEventSink_Globals& globals = *(SkEventSink_Globals*)SkGlobals::Find(SK_EventSink_GlobalsTag, create_globals);
+
+    if (fTagHead)
+        SkTagList::DeleteAll(fTagHead);
+
+    globals.fSinkMutex.acquire();
+
+    SkEventSink* sink = globals.fSinkHead;
+    SkEventSink* prev = nil;
+
+    for (;;)
+    {
+        SkEventSink* next = sink->fNextSink;
+        if (sink == this)
+        {
+            if (prev)
+                prev->fNextSink = next;
+            else
+                globals.fSinkHead = next;
+            break;
+        }
+        prev = sink;
+        sink = next;
+    }
+    globals.fSinkMutex.release();
 }
 
 bool SkEventSink::doEvent(const SkEvent& evt)
 {
-       return this->onEvent(evt);
+    return this->onEvent(evt);
 }
 
 bool SkEventSink::doQuery(SkEvent* evt)
 {
-       SkASSERT(evt);
-       return this->onQuery(evt);
+    SkASSERT(evt);
+    return this->onQuery(evt);
 }
 
 bool SkEventSink::onEvent(const SkEvent&)
 {
-       return false;
+    return false;
 }
 
 bool SkEventSink::onQuery(SkEvent*)
 {
-       return false;
+    return false;
 }
 
 ///////////////////////////////////////////////////////////////////////////////
 
 SkTagList* SkEventSink::findTagList(U8CPU tag) const
 {
-       return fTagHead ? SkTagList::Find(fTagHead, tag) : nil;
+    return fTagHead ? SkTagList::Find(fTagHead, tag) : nil;
 }
 
 void SkEventSink::addTagList(SkTagList* rec)
 {
-       SkASSERT(rec);
-       SkASSERT(fTagHead == nil || SkTagList::Find(fTagHead, rec->fTag) == nil);
+    SkASSERT(rec);
+    SkASSERT(fTagHead == nil || SkTagList::Find(fTagHead, rec->fTag) == nil);
 
-       rec->fNext = fTagHead;
-       fTagHead = rec;
+    rec->fNext = fTagHead;
+    fTagHead = rec;
 }
 
 void SkEventSink::removeTagList(U8CPU tag)
 {
-       if (fTagHead)
-               SkTagList::DeleteTag(&fTagHead, tag);
+    if (fTagHead)
+        SkTagList::DeleteTag(&fTagHead, tag);
 }
 
 ///////////////////////////////////////////////////////////////////////////////
 
 struct SkListenersTagList : SkTagList {
-       SkListenersTagList(U16CPU count) : SkTagList(kListeners_SkTagList)
-       {
-               fExtra16 = SkToU16(count);
-               fIDs = (SkEventSinkID*)sk_malloc_throw(count * sizeof(SkEventSinkID));
-       }
-       virtual ~SkListenersTagList()
-       {
-               sk_free(fIDs);
-       }
-
-       int     countListners() const { return fExtra16; }
-
-       int find(SkEventSinkID id) const
-       {
-               const SkEventSinkID* idptr = fIDs;
-               for (int i = fExtra16 - 1; i >= 0; --i)
-                       if (idptr[i] == id)
-                               return i;
-               return -1;
-       }
-
-       SkEventSinkID*  fIDs;
+    SkListenersTagList(U16CPU count) : SkTagList(kListeners_SkTagList)
+    {
+        fExtra16 = SkToU16(count);
+        fIDs = (SkEventSinkID*)sk_malloc_throw(count * sizeof(SkEventSinkID));
+    }
+    virtual ~SkListenersTagList()
+    {
+        sk_free(fIDs);
+    }
+
+    int countListners() const { return fExtra16; }
+
+    int find(SkEventSinkID id) const
+    {
+        const SkEventSinkID* idptr = fIDs;
+        for (int i = fExtra16 - 1; i >= 0; --i)
+            if (idptr[i] == id)
+                return i;
+        return -1;
+    }
+
+    SkEventSinkID*  fIDs;
 };
 
 void SkEventSink::addListenerID(SkEventSinkID id)
 {
-       if (id == 0)
-               return;
-
-       SkListenersTagList* prev = (SkListenersTagList*)this->findTagList(kListeners_SkTagList);
-       int                                     count = 0;
-
-       if (prev)
-       {
-               if (prev->find(id) >= 0)
-                       return;
-               count = prev->countListners();
-       }
-
-       SkListenersTagList* next = SkNEW_ARGS(SkListenersTagList, (count + 1));
-
-       if (prev)
-       {
-               memcpy(next->fIDs, prev->fIDs, count * sizeof(SkEventSinkID));
-               this->removeTagList(kListeners_SkTagList);
-       }
-       next->fIDs[count] = id;
-       this->addTagList(next);
+    if (id == 0)
+        return;
+
+    SkListenersTagList* prev = (SkListenersTagList*)this->findTagList(kListeners_SkTagList);
+    int                 count = 0;
+
+    if (prev)
+    {
+        if (prev->find(id) >= 0)
+            return;
+        count = prev->countListners();
+    }
+
+    SkListenersTagList* next = SkNEW_ARGS(SkListenersTagList, (count + 1));
+
+    if (prev)
+    {
+        memcpy(next->fIDs, prev->fIDs, count * sizeof(SkEventSinkID));
+        this->removeTagList(kListeners_SkTagList);
+    }
+    next->fIDs[count] = id;
+    this->addTagList(next);
 }
 
 void SkEventSink::copyListeners(const SkEventSink& sink) 
 {
-       SkListenersTagList* sinkList = (SkListenersTagList*)sink.findTagList(kListeners_SkTagList);
-       if (sinkList == nil)
-               return;
-       SkASSERT(sinkList->countListners() > 0);
-       const SkEventSinkID* iter = sinkList->fIDs;
-       const SkEventSinkID* stop = iter + sinkList->countListners();
-       while (iter < stop)
-               addListenerID(*iter++);
+    SkListenersTagList* sinkList = (SkListenersTagList*)sink.findTagList(kListeners_SkTagList);
+    if (sinkList == nil)
+        return;
+    SkASSERT(sinkList->countListners() > 0);
+    const SkEventSinkID* iter = sinkList->fIDs;
+    const SkEventSinkID* stop = iter + sinkList->countListners();
+    while (iter < stop)
+        addListenerID(*iter++);
 }
 
 void SkEventSink::removeListenerID(SkEventSinkID id)
 {
-       if (id == 0)
-               return;
-
-       SkListenersTagList* list = (SkListenersTagList*)this->findTagList(kListeners_SkTagList);
-
-       if (list == nil)
-               return;
-
-       int index = list->find(id);
-       if (index >= 0)
-       {
-               int count = list->countListners();
-               SkASSERT(count > 0);
-               if (count == 1)
-                       this->removeTagList(kListeners_SkTagList);
-               else
-               {
-                       // overwrite without resize/reallocating our struct (for speed)
-                       list->fIDs[index] = list->fIDs[count - 1];
-                       list->fExtra16 = SkToU16(count - 1);
-               }
-       }
+    if (id == 0)
+        return;
+
+    SkListenersTagList* list = (SkListenersTagList*)this->findTagList(kListeners_SkTagList);
+
+    if (list == nil)
+        return;
+
+    int index = list->find(id);
+    if (index >= 0)
+    {
+        int count = list->countListners();
+        SkASSERT(count > 0);
+        if (count == 1)
+            this->removeTagList(kListeners_SkTagList);
+        else
+        {
+            // overwrite without resize/reallocating our struct (for speed)
+            list->fIDs[index] = list->fIDs[count - 1];
+            list->fExtra16 = SkToU16(count - 1);
+        }
+    }
 }
 
 bool SkEventSink::hasListeners() const
 {
-       return this->findTagList(kListeners_SkTagList) != nil;
+    return this->findTagList(kListeners_SkTagList) != nil;
 }
 
 void SkEventSink::postToListeners(const SkEvent& evt, SkMSec delay)
 {
-       SkListenersTagList* list = (SkListenersTagList*)this->findTagList(kListeners_SkTagList);
-       if (list)
-       {
-               SkASSERT(list->countListners() > 0);
-               const SkEventSinkID* iter = list->fIDs;
-               const SkEventSinkID* stop = iter + list->countListners();
-               while (iter < stop)
-                       (SkNEW_ARGS(SkEvent, (evt)))->post(*iter++, delay);
-       }
+    SkListenersTagList* list = (SkListenersTagList*)this->findTagList(kListeners_SkTagList);
+    if (list)
+    {
+        SkASSERT(list->countListners() > 0);
+        const SkEventSinkID* iter = list->fIDs;
+        const SkEventSinkID* stop = iter + list->countListners();
+        while (iter < stop)
+            (SkNEW_ARGS(SkEvent, (evt)))->post(*iter++, delay);
+    }
 }
 
 ///////////////////////////////////////////////////////////////////////////////
 
 SkEventSink::EventResult SkEventSink::DoEvent(const SkEvent& evt, SkEventSinkID sinkID)
 {
-       SkEventSink* sink = SkEventSink::FindSink(sinkID);
+    SkEventSink* sink = SkEventSink::FindSink(sinkID);
 
-       if (sink)
-       {
+    if (sink)
+    {
 #ifdef SK_DEBUG
-               if (evt.isDebugTrace())
-               {
-                       SkString        etype;
-                       evt.getType(&etype);
-                       SkDebugf("SkEventTrace: dispatching event <%s> to 0x%x", etype.c_str(), sinkID);
-                       const char* idStr = evt.findString("id");
-                       if (idStr)
-                               SkDebugf(" (%s)", idStr);
-                       SkDebugf("\n");
-               }
+        if (evt.isDebugTrace())
+        {
+            SkString    etype;
+            evt.getType(&etype);
+            SkDebugf("SkEventTrace: dispatching event <%s> to 0x%x", etype.c_str(), sinkID);
+            const char* idStr = evt.findString("id");
+            if (idStr)
+                SkDebugf(" (%s)", idStr);
+            SkDebugf("\n");
+        }
 #endif
-               return sink->doEvent(evt) ? kHandled_EventResult : kNotHandled_EventResult;
-       }
-       else
-       {
+        return sink->doEvent(evt) ? kHandled_EventResult : kNotHandled_EventResult;
+    }
+    else
+    {
 #ifdef SK_DEBUG
-               if (sinkID)
-                       SkDebugf("DoEvent: Can't find sink for ID(%x)\n", sinkID);
-               else
-                       SkDebugf("Event sent to 0 sinkID\n");
-
-               if (evt.isDebugTrace())
-               {
-                       SkString        etype;
-                       evt.getType(&etype);
-                       SkDebugf("SkEventTrace: eventsink not found <%s> for 0x%x\n", etype.c_str(), sinkID);
-               }
+        if (sinkID)
+            SkDebugf("DoEvent: Can't find sink for ID(%x)\n", sinkID);
+        else
+            SkDebugf("Event sent to 0 sinkID\n");
+
+        if (evt.isDebugTrace())
+        {
+            SkString    etype;
+            evt.getType(&etype);
+            SkDebugf("SkEventTrace: eventsink not found <%s> for 0x%x\n", etype.c_str(), sinkID);
+        }
 #endif
-               return kSinkNotFound_EventResult;
-       }
+        return kSinkNotFound_EventResult;
+    }
 }
 
 SkEventSink* SkEventSink::FindSink(SkEventSinkID sinkID)
 {
-       if (sinkID == 0)
-               return 0;
-
-       SkEventSink_Globals&    globals = *(SkEventSink_Globals*)SkGlobals::Find(SK_EventSink_GlobalsTag, create_globals);
-       SkAutoMutexAcquire              ac(globals.fSinkMutex);
-       SkEventSink*                    sink = globals.fSinkHead;
-
-       while (sink)
-       {
-               if (sink->getSinkID() == sinkID)
-                       return sink;
-               sink = sink->fNextSink;
-       }
-       return nil;
+    if (sinkID == 0)
+        return 0;
+
+    SkEventSink_Globals&    globals = *(SkEventSink_Globals*)SkGlobals::Find(SK_EventSink_GlobalsTag, create_globals);
+    SkAutoMutexAcquire      ac(globals.fSinkMutex);
+    SkEventSink*            sink = globals.fSinkHead;
+
+    while (sink)
+    {
+        if (sink->getSinkID() == sinkID)
+            return sink;
+        sink = sink->fNextSink;
+    }
+    return nil;
 }
 
 ////////////////////////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////////////////////////
 
-#if 0  // experimental, not tested
+#if 0   // experimental, not tested
 
 #include "SkThread.h"
 #include "SkTDict.h"
 
-#define kMinStringBufferSize   128
-static SkMutex                                 gNamedSinkMutex;
-static SkTDict<SkEventSinkID>  gNamedSinkIDs(kMinStringBufferSize);
+#define kMinStringBufferSize    128
+static SkMutex                  gNamedSinkMutex;
+static SkTDict<SkEventSinkID>   gNamedSinkIDs(kMinStringBufferSize);
 
-/**    Register a name/id pair with the system. If the name already exists,
-       replace its ID with the new id. This pair will persist until UnregisterNamedSink()
-       is called.
+/** Register a name/id pair with the system. If the name already exists,
+    replace its ID with the new id. This pair will persist until UnregisterNamedSink()
+    is called.
 */
 void SkEventSink::RegisterNamedSinkID(const char name[], SkEventSinkID id)
 {
-       if (id && name && *name)
-       {
-               SkAutoMutexAcquire      ac(gNamedSinkMutex);
-               gNamedSinkIDs.set(name, id);
-       }
+    if (id && name && *name)
+    {
+        SkAutoMutexAcquire  ac(gNamedSinkMutex);
+        gNamedSinkIDs.set(name, id);
+    }
 }
 
-/**    Return the id that matches the specified name (from a previous call to
-       RegisterNamedSinkID(). If no match is found, return 0
+/** Return the id that matches the specified name (from a previous call to
+    RegisterNamedSinkID(). If no match is found, return 0
 */
 SkEventSinkID SkEventSink::FindNamedSinkID(const char name[])
 {
-       SkEventSinkID id = 0;
-
-       if (name && *name)
-       {
-               SkAutoMutexAcquire      ac(gNamedSinkMutex);
-               (void)gNamedSinkIDs.find(name, &id);
-       }
-       return id;
+    SkEventSinkID id = 0;
+
+    if (name && *name)
+    {
+        SkAutoMutexAcquire  ac(gNamedSinkMutex);
+        (void)gNamedSinkIDs.find(name, &id);
+    }
+    return id;
 }
 
-/**    Remove all name/id pairs from the system. This is call internally
-       on shutdown, to ensure no memory leaks. It should not be called
-       before shutdown.
+/** Remove all name/id pairs from the system. This is call internally
+    on shutdown, to ensure no memory leaks. It should not be called
+    before shutdown.
 */
 void SkEventSink::RemoveAllNamedSinkIDs()
 {
-       SkAutoMutexAcquire      ac(gNamedSinkMutex);
-       (void)gNamedSinkIDs.reset();
+    SkAutoMutexAcquire  ac(gNamedSinkMutex);
+    (void)gNamedSinkIDs.reset();
 }
 #endif
index 8692979..1d423a4 100644 (file)
@@ -1,3 +1,20 @@
+/* libs/graphics/views/SkMetaData.cpp
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #include "SkMetaData.h"
 
 SkMetaData::SkMetaData() : fRec(NULL)
@@ -6,294 +23,294 @@ SkMetaData::SkMetaData() : fRec(NULL)
 
 SkMetaData::SkMetaData(const SkMetaData& src) : fRec(NULL)
 {
-       *this = src;
+    *this = src;
 }
 
 SkMetaData::~SkMetaData()
 {
-       this->reset();
+    this->reset();
 }
 
 void SkMetaData::reset()
 {
-       Rec* rec = fRec;
-       while (rec)
-       {
-               Rec* next = rec->fNext;
-               Rec::Free(rec);
-               rec = next;
-       }
-       fRec = NULL;
+    Rec* rec = fRec;
+    while (rec)
+    {
+        Rec* next = rec->fNext;
+        Rec::Free(rec);
+        rec = next;
+    }
+    fRec = NULL;
 }
 
-SkMetaData&    SkMetaData::operator=(const SkMetaData& src)
+SkMetaData& SkMetaData::operator=(const SkMetaData& src)
 {
-       this->reset();
-
-       const Rec* rec = src.fRec;
-       while (rec)
-       {
-               this->set(rec->name(), rec->data(), rec->fDataLen, (Type)rec->fType, rec->fDataCount);
-               rec = rec->fNext;
-       }
-       return *this;
+    this->reset();
+
+    const Rec* rec = src.fRec;
+    while (rec)
+    {
+        this->set(rec->name(), rec->data(), rec->fDataLen, (Type)rec->fType, rec->fDataCount);
+        rec = rec->fNext;
+    }
+    return *this;
 }
 
 void SkMetaData::setS32(const char name[], int32_t value)
 {
-       (void)this->set(name, &value, sizeof(int32_t), kS32_Type, 1);
+    (void)this->set(name, &value, sizeof(int32_t), kS32_Type, 1);
 }
 
 void SkMetaData::setScalar(const char name[], SkScalar value)
 {
-       (void)this->set(name, &value, sizeof(SkScalar), kScalar_Type, 1);
+    (void)this->set(name, &value, sizeof(SkScalar), kScalar_Type, 1);
 }
 
 SkScalar* SkMetaData::setScalars(const char name[], int count, const SkScalar values[])
 {
-       SkASSERT(count > 0);
-       if (count > 0)
-               return (SkScalar*)this->set(name, values, sizeof(SkScalar), kScalar_Type, count);
-       return NULL;
+    SkASSERT(count > 0);
+    if (count > 0)
+        return (SkScalar*)this->set(name, values, sizeof(SkScalar), kScalar_Type, count);
+    return NULL;
 }
 
 void SkMetaData::setString(const char name[], const char value[])
 {
-       (void)this->set(name, value, sizeof(char), kString_Type, strlen(value) + 1);
+    (void)this->set(name, value, sizeof(char), kString_Type, strlen(value) + 1);
 }
 
 void SkMetaData::setPtr(const char name[], void* ptr)
 {
-       (void)this->set(name, &ptr, sizeof(void*), kPtr_Type, 1);
+    (void)this->set(name, &ptr, sizeof(void*), kPtr_Type, 1);
 }
 
 void SkMetaData::setBool(const char name[], bool value)
 {
-       (void)this->set(name, &value, sizeof(bool), kBool_Type, 1);
+    (void)this->set(name, &value, sizeof(bool), kBool_Type, 1);
 }
 
 void* SkMetaData::set(const char name[], const void* data, size_t dataSize, Type type, int count)
 {
-       SkASSERT(name);
-       SkASSERT(dataSize);
-       SkASSERT(count > 0);
+    SkASSERT(name);
+    SkASSERT(dataSize);
+    SkASSERT(count > 0);
 
-       (void)this->remove(name, type);
+    (void)this->remove(name, type);
 
-       size_t  len = strlen(name);
-       Rec*    rec = Rec::Alloc(sizeof(Rec) + dataSize * count + len + 1);
+    size_t  len = strlen(name);
+    Rec*    rec = Rec::Alloc(sizeof(Rec) + dataSize * count + len + 1);
 
 #ifndef SK_DEBUG
-       rec->fType = SkToU8(type);
+    rec->fType = SkToU8(type);
 #else
-       rec->fType = type;
+    rec->fType = type;
 #endif
-       rec->fDataLen = SkToU8(dataSize);
-       rec->fDataCount = SkToU16(count);
-       if (data)
-               memcpy(rec->data(), data, dataSize * count);
-       memcpy(rec->name(), name, len + 1);
+    rec->fDataLen = SkToU8(dataSize);
+    rec->fDataCount = SkToU16(count);
+    if (data)
+        memcpy(rec->data(), data, dataSize * count);
+    memcpy(rec->name(), name, len + 1);
 
 #ifdef SK_DEBUG
-       rec->fName = rec->name();
-       switch (type) {
-       case kS32_Type:
-               rec->fData.fS32 = *(const int32_t*)rec->data();
-               break;
-       case kScalar_Type:
-               rec->fData.fScalar = *(const SkScalar*)rec->data();
-               break;
-       case kString_Type:
-               rec->fData.fString = (const char*)rec->data();
-               break;
-       case kPtr_Type:
-               rec->fData.fPtr = *(void**)rec->data();
-               break;
-       case kBool_Type:
-               rec->fData.fBool = *(const bool*)rec->data();
-               break;
-       default:
-               SkASSERT(!"bad type");
-               break;
-       }
+    rec->fName = rec->name();
+    switch (type) {
+    case kS32_Type:
+        rec->fData.fS32 = *(const int32_t*)rec->data();
+        break;
+    case kScalar_Type:
+        rec->fData.fScalar = *(const SkScalar*)rec->data();
+        break;
+    case kString_Type:
+        rec->fData.fString = (const char*)rec->data();
+        break;
+    case kPtr_Type:
+        rec->fData.fPtr = *(void**)rec->data();
+        break;
+    case kBool_Type:
+        rec->fData.fBool = *(const bool*)rec->data();
+        break;
+    default:
+        SkASSERT(!"bad type");
+        break;
+    }
 #endif
 
-       rec->fNext = fRec;
-       fRec = rec;
-       return rec->data();
+    rec->fNext = fRec;
+    fRec = rec;
+    return rec->data();
 }
 
 bool SkMetaData::findS32(const char name[], int32_t* value) const
 {
-       const Rec* rec = this->find(name, kS32_Type);
-       if (rec)
-       {
-               SkASSERT(rec->fDataCount == 1);
-               if (value)
-                       *value = *(const int32_t*)rec->data();
-               return true;
-       }
-       return false;
+    const Rec* rec = this->find(name, kS32_Type);
+    if (rec)
+    {
+        SkASSERT(rec->fDataCount == 1);
+        if (value)
+            *value = *(const int32_t*)rec->data();
+        return true;
+    }
+    return false;
 }
 
 bool SkMetaData::findScalar(const char name[], SkScalar* value) const
 {
-       const Rec* rec = this->find(name, kScalar_Type);
-       if (rec)
-       {
-               SkASSERT(rec->fDataCount == 1);
-               if (value)
-                       *value = *(const SkScalar*)rec->data();
-               return true;
-       }
-       return false;
+    const Rec* rec = this->find(name, kScalar_Type);
+    if (rec)
+    {
+        SkASSERT(rec->fDataCount == 1);
+        if (value)
+            *value = *(const SkScalar*)rec->data();
+        return true;
+    }
+    return false;
 }
 
 const SkScalar* SkMetaData::findScalars(const char name[], int* count, SkScalar values[]) const
 {
-       const Rec* rec = this->find(name, kScalar_Type);
-       if (rec)
-       {
-               if (count)
-                       *count = rec->fDataCount;
-               if (values)
-                       memcpy(values, rec->data(), rec->fDataCount * rec->fDataLen);
-               return (const SkScalar*)rec->data();
-       }
-       return NULL;
+    const Rec* rec = this->find(name, kScalar_Type);
+    if (rec)
+    {
+        if (count)
+            *count = rec->fDataCount;
+        if (values)
+            memcpy(values, rec->data(), rec->fDataCount * rec->fDataLen);
+        return (const SkScalar*)rec->data();
+    }
+    return NULL;
 }
 
 bool SkMetaData::findPtr(const char name[], void** value) const
 {
-       const Rec* rec = this->find(name, kPtr_Type);
-       if (rec)
-       {
-               SkASSERT(rec->fDataCount == 1);
-               if (value)
-                       *value = *(void**)rec->data();
-               return true;
-       }
-       return false;
+    const Rec* rec = this->find(name, kPtr_Type);
+    if (rec)
+    {
+        SkASSERT(rec->fDataCount == 1);
+        if (value)
+            *value = *(void**)rec->data();
+        return true;
+    }
+    return false;
 }
 
 const char* SkMetaData::findString(const char name[]) const
 {
-       const Rec* rec = this->find(name, kString_Type);
-       SkASSERT(rec == NULL || rec->fDataLen == sizeof(char));
-       return rec ? (const char*)rec->data() : NULL;
+    const Rec* rec = this->find(name, kString_Type);
+    SkASSERT(rec == NULL || rec->fDataLen == sizeof(char));
+    return rec ? (const char*)rec->data() : NULL;
 }
 
 bool SkMetaData::findBool(const char name[], bool* value) const
 {
-       const Rec* rec = this->find(name, kBool_Type);
-       if (rec)
-       {
-               SkASSERT(rec->fDataCount == 1);
-               if (value)
-                       *value = *(const bool*)rec->data();
-               return true;
-       }
-       return false;
+    const Rec* rec = this->find(name, kBool_Type);
+    if (rec)
+    {
+        SkASSERT(rec->fDataCount == 1);
+        if (value)
+            *value = *(const bool*)rec->data();
+        return true;
+    }
+    return false;
 }
 
 const SkMetaData::Rec* SkMetaData::find(const char name[], Type type) const
 {
-       const Rec* rec = fRec;
-       while (rec)
-       {
-               if (rec->fType == type && !strcmp(rec->name(), name))
-                       return rec;
-               rec = rec->fNext;
-       }
-       return NULL;
+    const Rec* rec = fRec;
+    while (rec)
+    {
+        if (rec->fType == type && !strcmp(rec->name(), name))
+            return rec;
+        rec = rec->fNext;
+    }
+    return NULL;
 }
 
 bool SkMetaData::remove(const char name[], Type type)
 {
-       Rec* rec = fRec;
-       Rec* prev = NULL;
-       while (rec)
-       {
-               Rec* next = rec->fNext;
-               if (rec->fType == type && !strcmp(rec->name(), name))
-               {
-                       if (prev)
-                               prev->fNext = next;
-                       else
-                               fRec = next;
-                       Rec::Free(rec);
-                       return true;
-               }
-               prev = rec;
-               rec = next;
-       }
-       return false;
+    Rec* rec = fRec;
+    Rec* prev = NULL;
+    while (rec)
+    {
+        Rec* next = rec->fNext;
+        if (rec->fType == type && !strcmp(rec->name(), name))
+        {
+            if (prev)
+                prev->fNext = next;
+            else
+                fRec = next;
+            Rec::Free(rec);
+            return true;
+        }
+        prev = rec;
+        rec = next;
+    }
+    return false;
 }
 
 bool SkMetaData::removeS32(const char name[])
 {
-       return this->remove(name, kS32_Type);
+    return this->remove(name, kS32_Type);
 }
 
 bool SkMetaData::removeScalar(const char name[])
 {
-       return this->remove(name, kScalar_Type);
+    return this->remove(name, kScalar_Type);
 }
 
 bool SkMetaData::removeString(const char name[])
 {
-       return this->remove(name, kString_Type);
+    return this->remove(name, kString_Type);
 }
 
 bool SkMetaData::removePtr(const char name[])
 {
-       return this->remove(name, kPtr_Type);
+    return this->remove(name, kPtr_Type);
 }
 
 bool SkMetaData::removeBool(const char name[])
 {
-       return this->remove(name, kBool_Type);
+    return this->remove(name, kBool_Type);
 }
 
 ///////////////////////////////////////////////////////////////////////////////////
 
 SkMetaData::Iter::Iter(const SkMetaData& metadata)
 {
-       fRec = metadata.fRec;
+    fRec = metadata.fRec;
 }
 
 void SkMetaData::Iter::reset(const SkMetaData& metadata)
 {
-       fRec = metadata.fRec;
+    fRec = metadata.fRec;
 }
 
 const char* SkMetaData::Iter::next(SkMetaData::Type* t, int* count)
 {
-       const char* name = NULL;
-
-       if (fRec)
-       {
-               if (t)
-                       *t = (SkMetaData::Type)fRec->fType;
-               if (count)
-                       *count = fRec->fDataCount;
-               name = fRec->name();
-
-               fRec = fRec->fNext;
-       }
-       return name;
+    const char* name = NULL;
+
+    if (fRec)
+    {
+        if (t)
+            *t = (SkMetaData::Type)fRec->fType;
+        if (count)
+            *count = fRec->fDataCount;
+        name = fRec->name();
+
+        fRec = fRec->fNext;
+    }
+    return name;
 }
 
 ///////////////////////////////////////////////////////////////////////////////////
 
 SkMetaData::Rec* SkMetaData::Rec::Alloc(size_t size)
 {
-       return (Rec*)sk_malloc_throw(size);
+    return (Rec*)sk_malloc_throw(size);
 }
 
 void SkMetaData::Rec::Free(Rec* rec)
 {
-       sk_free(rec);
+    sk_free(rec);
 }
 
 ///////////////////////////////////////////////////////////////////////////////////
@@ -304,82 +321,82 @@ void SkMetaData::Rec::Free(Rec* rec)
 void SkMetaData::UnitTest()
 {
 #ifdef SK_SUPPORT_UNITTEST
-       SkMetaData      m1;
-
-       SkASSERT(!m1.findS32("int"));
-       SkASSERT(!m1.findScalar("scalar"));
-       SkASSERT(!m1.findString("hello"));
-       SkASSERT(!m1.removeS32("int"));
-       SkASSERT(!m1.removeScalar("scalar"));
-       SkASSERT(!m1.removeString("hello"));
-       SkASSERT(!m1.removeString("true"));
-       SkASSERT(!m1.removeString("false"));
-
-       m1.setS32("int", 12345);
-       m1.setScalar("scalar", SK_Scalar1 * 42);
-       m1.setString("hello", "world");
-       m1.setPtr("ptr", &m1);
-       m1.setBool("true", true);
-       m1.setBool("false", false);
-
-       int32_t     n;
-       SkScalar        s;
-
-       m1.setScalar("scalar", SK_Scalar1/2);
-
-       SkASSERT(m1.findS32("int", &n) && n == 12345);
-       SkASSERT(m1.findScalar("scalar", &s) && s == SK_Scalar1/2);
-       SkASSERT(!strcmp(m1.findString("hello"), "world"));
-       SkASSERT(m1.hasBool("true", true));
-       SkASSERT(m1.hasBool("false", false));
-
-       Iter    iter(m1);
-       const char*     name;
-
-       static const struct {
-               const char*                     fName;
-               SkMetaData::Type        fType;
-               int                                     fCount;
-       } gElems[] = {
-               { "int",        SkMetaData::kS32_Type,          1 },
-               { "scalar",     SkMetaData::kScalar_Type,       1 },
-               { "ptr",        SkMetaData::kPtr_Type,          1 },
-               { "hello",      SkMetaData::kString_Type,       sizeof("world") },
-               { "true",       SkMetaData::kBool_Type,         1 },
-               { "false",      SkMetaData::kBool_Type,         1 }
-       };
-
-       int                                     loop = 0;
-       int count;
-       SkMetaData::Type        t;
-       while ((name = iter.next(&t, &count)) != NULL)
-       {
-               int match = 0;
-               for (unsigned i = 0; i < SK_ARRAY_COUNT(gElems); i++)
-               {
-                       if (!strcmp(name, gElems[i].fName))
-                       {
-                               match += 1;
-                               SkASSERT(gElems[i].fType == t);
-                               SkASSERT(gElems[i].fCount == count);
-                       }
-               }
-               SkASSERT(match == 1);
-               loop += 1;
-       }
-       SkASSERT(loop == SK_ARRAY_COUNT(gElems));
-
-       SkASSERT(m1.removeS32("int"));
-       SkASSERT(m1.removeScalar("scalar"));
-       SkASSERT(m1.removeString("hello"));
-       SkASSERT(m1.removeBool("true"));
-       SkASSERT(m1.removeBool("false"));
-
-       SkASSERT(!m1.findS32("int"));
-       SkASSERT(!m1.findScalar("scalar"));
-       SkASSERT(!m1.findString("hello"));
-       SkASSERT(!m1.findBool("true"));
-       SkASSERT(!m1.findBool("false"));
+    SkMetaData  m1;
+
+    SkASSERT(!m1.findS32("int"));
+    SkASSERT(!m1.findScalar("scalar"));
+    SkASSERT(!m1.findString("hello"));
+    SkASSERT(!m1.removeS32("int"));
+    SkASSERT(!m1.removeScalar("scalar"));
+    SkASSERT(!m1.removeString("hello"));
+    SkASSERT(!m1.removeString("true"));
+    SkASSERT(!m1.removeString("false"));
+
+    m1.setS32("int", 12345);
+    m1.setScalar("scalar", SK_Scalar1 * 42);
+    m1.setString("hello", "world");
+    m1.setPtr("ptr", &m1);
+    m1.setBool("true", true);
+    m1.setBool("false", false);
+
+    int32_t     n;
+    SkScalar    s;
+
+    m1.setScalar("scalar", SK_Scalar1/2);
+
+    SkASSERT(m1.findS32("int", &n) && n == 12345);
+    SkASSERT(m1.findScalar("scalar", &s) && s == SK_Scalar1/2);
+    SkASSERT(!strcmp(m1.findString("hello"), "world"));
+    SkASSERT(m1.hasBool("true", true));
+    SkASSERT(m1.hasBool("false", false));
+
+    Iter    iter(m1);
+    const char* name;
+
+    static const struct {
+        const char*         fName;
+        SkMetaData::Type    fType;
+        int                 fCount;
+    } gElems[] = {
+        { "int",    SkMetaData::kS32_Type,      1 },
+        { "scalar", SkMetaData::kScalar_Type,   1 },
+        { "ptr",    SkMetaData::kPtr_Type,      1 },
+        { "hello",  SkMetaData::kString_Type,   sizeof("world") },
+        { "true",   SkMetaData::kBool_Type,     1 },
+        { "false",  SkMetaData::kBool_Type,     1 }
+    };
+
+    int                 loop = 0;
+    int count;
+    SkMetaData::Type    t;
+    while ((name = iter.next(&t, &count)) != NULL)
+    {
+        int match = 0;
+        for (unsigned i = 0; i < SK_ARRAY_COUNT(gElems); i++)
+        {
+            if (!strcmp(name, gElems[i].fName))
+            {
+                match += 1;
+                SkASSERT(gElems[i].fType == t);
+                SkASSERT(gElems[i].fCount == count);
+            }
+        }
+        SkASSERT(match == 1);
+        loop += 1;
+    }
+    SkASSERT(loop == SK_ARRAY_COUNT(gElems));
+
+    SkASSERT(m1.removeS32("int"));
+    SkASSERT(m1.removeScalar("scalar"));
+    SkASSERT(m1.removeString("hello"));
+    SkASSERT(m1.removeBool("true"));
+    SkASSERT(m1.removeBool("false"));
+
+    SkASSERT(!m1.findS32("int"));
+    SkASSERT(!m1.findScalar("scalar"));
+    SkASSERT(!m1.findString("hello"));
+    SkASSERT(!m1.findBool("true"));
+    SkASSERT(!m1.findBool("false"));
 #endif
 }
 
index 42a3503..9ca2373 100644 (file)
@@ -1,3 +1,20 @@
+/* libs/graphics/views/SkTagList.cpp
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #include "SkTagList.h"
 
 SkTagList::~SkTagList()
@@ -6,49 +23,49 @@ SkTagList::~SkTagList()
 
 SkTagList* SkTagList::Find(SkTagList* rec, U8CPU tag)
 {
-       SkASSERT(tag < kSkTagListCount);
-
-       while (rec != nil)
-       {
-               if (rec->fTag == tag)
-                       break;
-               rec = rec->fNext;
-       }
-       return rec;
+    SkASSERT(tag < kSkTagListCount);
+
+    while (rec != nil)
+    {
+        if (rec->fTag == tag)
+            break;
+        rec = rec->fNext;
+    }
+    return rec;
 }
 
 void SkTagList::DeleteTag(SkTagList** head, U8CPU tag)
 {
-       SkASSERT(tag < kSkTagListCount);
-
-       SkTagList* rec = *head;
-       SkTagList* prev = nil;
-
-       while (rec != nil)
-       {
-               SkTagList* next = rec->fNext;
-
-               if (rec->fTag == tag)
-               {
-                       if (prev)
-                               prev->fNext = next;
-                       else
-                               *head = next;
-                       delete rec;
-                       break;
-               }
-               prev = rec;
-               rec = next;
-       }
+    SkASSERT(tag < kSkTagListCount);
+
+    SkTagList* rec = *head;
+    SkTagList* prev = nil;
+
+    while (rec != nil)
+    {
+        SkTagList* next = rec->fNext;
+
+        if (rec->fTag == tag)
+        {
+            if (prev)
+                prev->fNext = next;
+            else
+                *head = next;
+            delete rec;
+            break;
+        }
+        prev = rec;
+        rec = next;
+    }
 }
 
 void SkTagList::DeleteAll(SkTagList* rec)
 {
-       while (rec)
-       {
-               SkTagList* next = rec->fNext;
-               delete rec;
-               rec = next;
-       }
+    while (rec)
+    {
+        SkTagList* next = rec->fNext;
+        delete rec;
+        rec = next;
+    }
 }
 
index 937c030..f7fa2f0 100644 (file)
@@ -1,34 +1,51 @@
+/* libs/graphics/views/SkTagList.h
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #ifndef SkTagList_DEFINED
 #define SkTagList_DEFINED
 
 #include "SkTypes.h"
 
 enum SkTagListEnum {
-       kListeners_SkTagList,
-       kViewLayout_SkTagList,
-       kViewArtist_SkTagList,
+    kListeners_SkTagList,
+    kViewLayout_SkTagList,
+    kViewArtist_SkTagList,
 
-       kSkTagListCount
+    kSkTagListCount
 };
 
 struct SkTagList {
-       SkTagList*      fNext;
-       U16                     fExtra16;
-       U8                      fExtra8;
-       U8                      fTag;
-
-       SkTagList(U8CPU tag) : fTag(SkToU8(tag))
-       {
-               SkASSERT(tag < kSkTagListCount);
-               fNext           = nil;
-               fExtra16        = 0;
-               fExtra8         = 0;
-       }
-       virtual ~SkTagList();
-
-       static SkTagList*       Find(SkTagList* head, U8CPU tag);
-       static void                     DeleteTag(SkTagList** headptr, U8CPU tag);
-       static void                     DeleteAll(SkTagList* head);
+    SkTagList*  fNext;
+    U16         fExtra16;
+    U8          fExtra8;
+    U8          fTag;
+
+    SkTagList(U8CPU tag) : fTag(SkToU8(tag))
+    {
+        SkASSERT(tag < kSkTagListCount);
+        fNext       = nil;
+        fExtra16    = 0;
+        fExtra8     = 0;
+    }
+    virtual ~SkTagList();
+
+    static SkTagList*   Find(SkTagList* head, U8CPU tag);
+    static void         DeleteTag(SkTagList** headptr, U8CPU tag);
+    static void         DeleteAll(SkTagList* head);
 };
 
 #endif
index 01d5dbe..bb29596 100644 (file)
+/* libs/graphics/views/SkTextBox.cpp
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #include "SkTextBox.h"
 #include "SkGlyphCache.h"
 #include "SkUtils.h"
 
 static inline int is_ws(int c)
 {
-       return !((c - 1) >> 5);
+    return !((c - 1) >> 5);
 }
 
 static size_t linebreak(const char text[], const char stop[], const SkPaint& paint, SkScalar margin)
 {
-       const char* start = text;
+    const char* start = text;
 
-       SkAutoGlyphCache        ac(paint, nil);
-       SkGlyphCache*           cache = ac.getCache();
-       SkFixed                         w = 0;
-       SkFixed                         limit = SkScalarToFixed(margin);
+    SkAutoGlyphCache    ac(paint, nil);
+    SkGlyphCache*       cache = ac.getCache();
+    SkFixed             w = 0;
+    SkFixed             limit = SkScalarToFixed(margin);
 
-       const char* word_start = text;
-       int                     prevWS = true;
+    const char* word_start = text;
+    int         prevWS = true;
 
-       while (text < stop)
-       {
+    while (text < stop)
+    {
         const char* prevText = text;
-               SkUnichar       uni = SkUTF8_NextUnichar(&text);
-               int                     currWS = is_ws(uni);
-
-               if (!currWS && prevWS)
-                       word_start = prevText;
-               prevWS = currWS;
-
-               w += cache->getMetrics(uni).fAdvanceX;
-               if (w > limit)
-               {
-                       if (currWS)     // eat the rest of the whitespace
-                       {
-                               while (text < stop && is_ws(SkUTF8_ToUnichar(text)))
-                                       text += SkUTF8_CountUTF8Bytes(text);
-                       }
-                       else    // backup until a whitespace (or 1 char)
-                       {
-                               if (word_start == start)
+        SkUnichar   uni = SkUTF8_NextUnichar(&text);
+        int         currWS = is_ws(uni);
+
+        if (!currWS && prevWS)
+            word_start = prevText;
+        prevWS = currWS;
+
+        w += cache->getUnicharMetrics(uni).fAdvanceX;
+        if (w > limit)
+        {
+            if (currWS) // eat the rest of the whitespace
+            {
+                while (text < stop && is_ws(SkUTF8_ToUnichar(text)))
+                    text += SkUTF8_CountUTF8Bytes(text);
+            }
+            else    // backup until a whitespace (or 1 char)
+            {
+                if (word_start == start)
                 {
                     if (prevText > start)
                         text = prevText;
                 }
                 else
                     text = word_start;
-                       }
-                       break;
-               }
-       }
-       return text - start;
+            }
+            break;
+        }
+    }
+    return text - start;
 }
 
 int SkTextLineBreaker::CountLines(const char text[], size_t len, const SkPaint& paint, SkScalar width)
 {
-       const char* stop = text + len;
-       int                     count = 0;
-
-       if (width > 0)
-       {
-               do {
-                       count += 1;
-                       text += linebreak(text, stop, paint, width);
-               } while (text < stop);
-       }
-       return count;
+    const char* stop = text + len;
+    int         count = 0;
+
+    if (width > 0)
+    {
+        do {
+            count += 1;
+            text += linebreak(text, stop, paint, width);
+        } while (text < stop);
+    }
+    return count;
 }
 
 //////////////////////////////////////////////////////////////////////////////
 
 SkTextBox::SkTextBox()
 {
-       fBox.setEmpty();
-       fSpacingMul = SK_Scalar1;
-       fSpacingAdd = 0;
-       fMode = kLineBreak_Mode;
-       fSpacingAlign = kStart_SpacingAlign;
+    fBox.setEmpty();
+    fSpacingMul = SK_Scalar1;
+    fSpacingAdd = 0;
+    fMode = kLineBreak_Mode;
+    fSpacingAlign = kStart_SpacingAlign;
 }
 
 void SkTextBox::setMode(Mode mode)
 {
-       SkASSERT((unsigned)mode < kModeCount);
-       fMode = SkToU8(mode);
+    SkASSERT((unsigned)mode < kModeCount);
+    fMode = SkToU8(mode);
 }
 
 void SkTextBox::setSpacingAlign(SpacingAlign align)
 {
-       SkASSERT((unsigned)align < kSpacingAlignCount);
-       fSpacingAlign = SkToU8(align);
+    SkASSERT((unsigned)align < kSpacingAlignCount);
+    fSpacingAlign = SkToU8(align);
 }
 
 void SkTextBox::getBox(SkRect* box) const
 {
-       if (box)
-               *box = fBox;
+    if (box)
+        *box = fBox;
 }
 
 void SkTextBox::setBox(const SkRect& box)
 {
-       fBox = box;
+    fBox = box;
 }
 
 void SkTextBox::setBox(SkScalar left, SkScalar top, SkScalar right, SkScalar bottom)
 {
-       fBox.set(left, top, right, bottom);
+    fBox.set(left, top, right, bottom);
 }
 
 void SkTextBox::getSpacing(SkScalar* mul, SkScalar* add) const
 {
-       if (mul)
-               *mul = fSpacingMul;
-       if (add)
-               *add = fSpacingAdd;
+    if (mul)
+        *mul = fSpacingMul;
+    if (add)
+        *add = fSpacingAdd;
 }
 
 void SkTextBox::setSpacing(SkScalar mul, SkScalar add)
 {
-       fSpacingMul = mul;
-       fSpacingAdd = add;
+    fSpacingMul = mul;
+    fSpacingAdd = add;
 }
 
 /////////////////////////////////////////////////////////////////////////////////////////////
 
 void SkTextBox::draw(SkCanvas* canvas, const char text[], size_t len, const SkPaint& paint)
 {
-       SkASSERT(canvas && &paint && (text || len == 0));
-
-       SkScalar marginWidth = fBox.width();
-
-       if (marginWidth <= 0 || len == 0)
-               return;
-
-       const char*     textStop = text + len;
-
-       SkScalar        x, y, spacing, height, before, after;
-
-       switch (paint.getTextAlign()) {
-       case SkPaint::kLeft_Align:
-               x = 0;
-               break;
-       case SkPaint::kCenter_Align:
-               x = SkScalarHalf(marginWidth);
-               break;
-       default:
-               x = marginWidth;
-               break;
-       }
-       x += fBox.fLeft;
-
-       paint.measureText(nil, 0, &before, &after);
-       spacing = SkScalarMul(after - before, fSpacingMul) + fSpacingAdd;
-       height = fBox.height();
-
-       //      compute Y position for first line
-       {
-               SkScalar textHeight = after - before;
-
-               if (fMode == kLineBreak_Mode && fSpacingAlign != kStart_SpacingAlign)
-               {
-                       int count = SkTextLineBreaker::CountLines(text, textStop - text, paint, marginWidth);
-                       SkASSERT(count > 0);
-                       textHeight += spacing * (count - 1);
-               }
-
-               switch (fSpacingAlign) {
-               case kStart_SpacingAlign:
-                       y = 0;
-                       break;
-               case kCenter_SpacingAlign:
-                       y = SkScalarHalf(height - textHeight);
-                       break;
-               default:
-                       SkASSERT(fSpacingAlign == kEnd_SpacingAlign);
-                       y = height - textHeight;
-                       break;
-               }
-               y += fBox.fTop - before;
-       }
-
-       for (;;)
-       {
-               len = linebreak(text, textStop, paint, marginWidth);
-               if (y + after > 0)
-                       canvas->drawText(text, len, x, y, paint);
-               text += len;
-               if (text >= textStop)
-                       break;
-               y += spacing;
-               if (y + before >= height)
-                       break;
-       
+    SkASSERT(canvas && &paint && (text || len == 0));
+
+    SkScalar marginWidth = fBox.width();
+
+    if (marginWidth <= 0 || len == 0)
+        return;
+
+    const char* textStop = text + len;
+
+    SkScalar    x, y, spacing, height, before, after;
+
+    switch (paint.getTextAlign()) {
+    case SkPaint::kLeft_Align:
+        x = 0;
+        break;
+    case SkPaint::kCenter_Align:
+        x = SkScalarHalf(marginWidth);
+        break;
+    default:
+        x = marginWidth;
+        break;
+    }
+    x += fBox.fLeft;
+
+    paint.measureText(nil, 0, &before, &after);
+    spacing = SkScalarMul(after - before, fSpacingMul) + fSpacingAdd;
+    height = fBox.height();
+
+    //  compute Y position for first line
+    {
+        SkScalar textHeight = after - before;
+
+        if (fMode == kLineBreak_Mode && fSpacingAlign != kStart_SpacingAlign)
+        {
+            int count = SkTextLineBreaker::CountLines(text, textStop - text, paint, marginWidth);
+            SkASSERT(count > 0);
+            textHeight += spacing * (count - 1);
+        }
+
+        switch (fSpacingAlign) {
+        case kStart_SpacingAlign:
+            y = 0;
+            break;
+        case kCenter_SpacingAlign:
+            y = SkScalarHalf(height - textHeight);
+            break;
+        default:
+            SkASSERT(fSpacingAlign == kEnd_SpacingAlign);
+            y = height - textHeight;
+            break;
+        }
+        y += fBox.fTop - before;
+    }
+
+    for (;;)
+    {
+        len = linebreak(text, textStop, paint, marginWidth);
+        if (y + after > 0)
+            canvas->drawText(text, len, x, y, paint);
+        text += len;
+        if (text >= textStop)
+            break;
+        y += spacing;
+        if (y + before >= height)
+            break;
+    } 
 }
 
index b23c4de..2d17d87 100644 (file)
@@ -1,16 +1,33 @@
+/* libs/graphics/xml/SkBML_Verbs.h
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #ifndef SkBML_Verbs_DEFINED
 #define SkBML_Verbs_DEFINED
 
 enum Verbs {
-       kStartElem_Value_Verb,
-       kStartElem_Index_Verb,
-       kEndElem_Verb,
-       kAttr_Value_Value_Verb,
-       kAttr_Value_Index_Verb,
-       kAttr_Index_Value_Verb,
-       kAttr_Index_Index_Verb,
+    kStartElem_Value_Verb,
+    kStartElem_Index_Verb,
+    kEndElem_Verb,
+    kAttr_Value_Value_Verb,
+    kAttr_Value_Index_Verb,
+    kAttr_Index_Value_Verb,
+    kAttr_Index_Index_Verb,
 
-       kVerbCount
+    kVerbCount
 };
 
 #endif // SkBML_Verbs_DEFINED
index 7901565..37e874e 100644 (file)
@@ -1,3 +1,20 @@
+/* libs/graphics/xml/SkBML_XMLParser.cpp
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #include "SkBML_XMLParser.h"
 #include "SkBML_Verbs.h"
 #include "SkStream.h"
 
 static U8 rbyte(SkStream& s)
 {
-       U8 b;
-       size_t size = s.read(&b, 1);
-       SkASSERT(size == 1);
-       return b;
+    U8 b;
+    size_t size = s.read(&b, 1);
+    SkASSERT(size == 1);
+    return b;
 }
 
 static int rdata(SkStream& s, int data)
 {
-       SkASSERT((data & ~31) == 0);
-       if (data == 31)
-       {
-               data = rbyte(s);
-               if (data == 0xFF)
-               {
-                       data = rbyte(s);
-                       data = (data << 8) | rbyte(s);
-               }
-       }
-       return data;
+    SkASSERT((data & ~31) == 0);
+    if (data == 31)
+    {
+        data = rbyte(s);
+        if (data == 0xFF)
+        {
+            data = rbyte(s);
+            data = (data << 8) | rbyte(s);
+        }
+    }
+    return data;
 }
 
 static void set(char* array[256], int index, SkStream& s, int data)
 {
-       SkASSERT((unsigned)index <= 255);
+    SkASSERT((unsigned)index <= 255);
 
-       size_t size = rdata(s, data);
+    size_t size = rdata(s, data);
 
-       if (array[index] == nil)
-               array[index] = (char*)sk_malloc_throw(size + 1);
-       else
-       {
-               if (strlen(array[index]) < size)
-                       array[index] = (char*)sk_realloc_throw(array[index], size + 1);
-       }
+    if (array[index] == nil)
+        array[index] = (char*)sk_malloc_throw(size + 1);
+    else
+    {
+        if (strlen(array[index]) < size)
+            array[index] = (char*)sk_realloc_throw(array[index], size + 1);
+    }
 
-       s.read(array[index], size);
-       array[index][size] = 0;
+    s.read(array[index], size);
+    array[index][size] = 0;
 }
 
 static void freeAll(char* array[256])
 {
-       for (int i = 0; i < 256; i++)
-               sk_free(array[i]);
+    for (int i = 0; i < 256; i++)
+        sk_free(array[i]);
 }
 
 struct BMLW {
-       char*   fElems[256];
-       char*   fNames[256];
-       char*   fValues[256];
-
-       // important that these are U8, so we get automatic wrap-around
-       U8      fNextElem, fNextName, fNextValue;
-
-       BMLW()
-       {
-               memset(fElems, 0, sizeof(fElems));
-               memset(fNames, 0, sizeof(fNames));
-               memset(fValues, 0, sizeof(fValues));
-
-               fNextElem = fNextName = fNextValue = 0;
-       }
-       ~BMLW()
-       {
-               freeAll(fElems);
-               freeAll(fNames);
-               freeAll(fValues);
-       }
+    char*   fElems[256];
+    char*   fNames[256];
+    char*   fValues[256];
+
+    // important that these are U8, so we get automatic wrap-around
+    U8  fNextElem, fNextName, fNextValue;
+
+    BMLW()
+    {
+        memset(fElems, 0, sizeof(fElems));
+        memset(fNames, 0, sizeof(fNames));
+        memset(fValues, 0, sizeof(fValues));
+
+        fNextElem = fNextName = fNextValue = 0;
+    }
+    ~BMLW()
+    {
+        freeAll(fElems);
+        freeAll(fNames);
+        freeAll(fValues);
+    }
 };
 
 static void rattr(unsigned verb, SkStream& s, BMLW& rec, SkXMLWriter& writer)
 {
-       int     data = verb & 31;
-       verb >>= 5;
-
-       int     nameIndex, valueIndex;
-
-       switch (verb) {
-       case kAttr_Value_Value_Verb:
-               nameIndex = rec.fNextName;              // record before the ++
-               set(rec.fNames, rec.fNextName++, s, data);
-               valueIndex = rec.fNextValue;    // record before the ++
-               set(rec.fValues, rec.fNextValue++, s, 31);
-               break;
-       case kAttr_Value_Index_Verb:
-               nameIndex = rec.fNextName;              // record before the ++
-               set(rec.fNames, rec.fNextName++, s, data);
-               valueIndex = rbyte(s);
-               break;
-       case kAttr_Index_Value_Verb:
-               nameIndex = rdata(s, data);
-               valueIndex = rec.fNextValue;    // record before the ++
-               set(rec.fValues, rec.fNextValue++, s, 31);
-               break;
-       case kAttr_Index_Index_Verb:
-               nameIndex = rdata(s, data);
-               valueIndex = rbyte(s);
-               break;
-       default:
-               SkASSERT(!"bad verb");
-               return;
-       }
-       writer.addAttribute(rec.fNames[nameIndex], rec.fValues[valueIndex]);
+    int data = verb & 31;
+    verb >>= 5;
+
+    int nameIndex, valueIndex;
+
+    switch (verb) {
+    case kAttr_Value_Value_Verb:
+        nameIndex = rec.fNextName;      // record before the ++
+        set(rec.fNames, rec.fNextName++, s, data);
+        valueIndex = rec.fNextValue;    // record before the ++
+        set(rec.fValues, rec.fNextValue++, s, 31);
+        break;
+    case kAttr_Value_Index_Verb:
+        nameIndex = rec.fNextName;      // record before the ++
+        set(rec.fNames, rec.fNextName++, s, data);
+        valueIndex = rbyte(s);
+        break;
+    case kAttr_Index_Value_Verb:
+        nameIndex = rdata(s, data);
+        valueIndex = rec.fNextValue;    // record before the ++
+        set(rec.fValues, rec.fNextValue++, s, 31);
+        break;
+    case kAttr_Index_Index_Verb:
+        nameIndex = rdata(s, data);
+        valueIndex = rbyte(s);
+        break;
+    default:
+        SkASSERT(!"bad verb");
+        return;
+    }
+    writer.addAttribute(rec.fNames[nameIndex], rec.fValues[valueIndex]);
 }
 
 static void relem(unsigned verb, SkStream& s, BMLW& rec, SkXMLWriter& writer)
 {
-       int     data = verb & 31;
-       verb >>= 5;
-
-       int     elemIndex;
-
-       if (verb == kStartElem_Value_Verb)
-       {
-               elemIndex = rec.fNextElem;              // record before the ++
-               set(rec.fElems, rec.fNextElem++, s, data);
-       }
-       else
-       {
-               SkASSERT(verb == kStartElem_Index_Verb);
-               elemIndex = rdata(s, data);
-       }
-
-       writer.startElement(rec.fElems[elemIndex]);
-
-       for (;;)
-       {
-               verb = rbyte(s);
-               switch (verb >> 5) {
-               case kAttr_Value_Value_Verb:
-               case kAttr_Value_Index_Verb:
-               case kAttr_Index_Value_Verb:
-               case kAttr_Index_Index_Verb:
-                       rattr(verb, s, rec, writer);
-                       break;
-               case kStartElem_Value_Verb:
-               case kStartElem_Index_Verb:
-                       relem(verb, s, rec, writer);
-                       break;
-               case kEndElem_Verb:
-                       writer.endElement();
-                       return;
-               default:
-                       SkASSERT(!"bad verb");
-               }
-       }
+    int data = verb & 31;
+    verb >>= 5;
+
+    int elemIndex;
+
+    if (verb == kStartElem_Value_Verb)
+    {
+        elemIndex = rec.fNextElem;      // record before the ++
+        set(rec.fElems, rec.fNextElem++, s, data);
+    }
+    else
+    {
+        SkASSERT(verb == kStartElem_Index_Verb);
+        elemIndex = rdata(s, data);
+    }
+
+    writer.startElement(rec.fElems[elemIndex]);
+
+    for (;;)
+    {
+        verb = rbyte(s);
+        switch (verb >> 5) {
+        case kAttr_Value_Value_Verb:
+        case kAttr_Value_Index_Verb:
+        case kAttr_Index_Value_Verb:
+        case kAttr_Index_Index_Verb:
+            rattr(verb, s, rec, writer);
+            break;
+        case kStartElem_Value_Verb:
+        case kStartElem_Index_Verb:
+            relem(verb, s, rec, writer);
+            break;
+        case kEndElem_Verb:
+            writer.endElement();
+            return;
+        default:
+            SkASSERT(!"bad verb");
+        }
+    }
 }
 
 void BML_XMLParser::Read(SkStream& s, SkXMLWriter& writer)
 {
-       BMLW rec;
-       writer.writeHeader();
-       relem(rbyte(s), s, rec, writer);
+    BMLW rec;
+    writer.writeHeader();
+    relem(rbyte(s), s, rec, writer);
 }
 
 void BML_XMLParser::Read(SkStream& s, SkWStream& output)
 {
-       SkXMLStreamWriter writer(&output);
-       Read(s, writer);
+    SkXMLStreamWriter writer(&output);
+    Read(s, writer);
 }
 
 void BML_XMLParser::Read(SkStream& s, SkXMLParser& output)
 {
-       SkXMLParserWriter writer(&output);
-       Read(s, writer);
+    SkXMLParserWriter writer(&output);
+    Read(s, writer);
 }
 
 
index 431d781..1aca5d2 100644 (file)
@@ -1,3 +1,20 @@
+/* libs/graphics/xml/SkDOM.cpp
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #include "SkDOM.h"
 
 /////////////////////////////////////////////////////////////////////////
 
 bool SkXMLParser::parse(const SkDOM& dom, const SkDOMNode* node)
 {
-       const char* elemName = dom.getName(node);
+    const char* elemName = dom.getName(node);
 
-       if (this->startElement(elemName))
-               return false;
-       
-       SkDOM::AttrIter iter(dom, node);
-       const char*             name, *value;
-       
-       while ((name = iter.next(&value)) != nil)
-               if (this->addAttribute(name, value))
-                       return false;
+    if (this->startElement(elemName))
+        return false;
+    
+    SkDOM::AttrIter iter(dom, node);
+    const char*     name, *value;
+    
+    while ((name = iter.next(&value)) != nil)
+        if (this->addAttribute(name, value))
+            return false;
 
-       if ((node = dom.getFirstChild(node)) != nil)
-               do {
-                       if (!this->parse(dom, node))
-                               return false;
-               } while ((node = dom.getNextSibling(node)) != nil);
-       
-       return !this->endElement(elemName);
+    if ((node = dom.getFirstChild(node)) != nil)
+        do {
+            if (!this->parse(dom, node))
+                return false;
+        } while ((node = dom.getNextSibling(node)) != nil);
+    
+    return !this->endElement(elemName);
 }
 
 /////////////////////////////////////////////////////////////////////////
 
 struct SkDOMAttr {
-       const char*     fName;
-       const char*     fValue;
+    const char* fName;
+    const char* fValue;
 };
 
 struct SkDOMNode {
-       const char*     fName;
-       SkDOMNode*      fFirstChild;
-       SkDOMNode*      fNextSibling;
-       U16                     fAttrCount;
-       U8                      fType;
-       U8                      fPad;
-
-       const SkDOMAttr* attrs() const
-       {
-               return (const SkDOMAttr*)(this + 1);
-       }
-       SkDOMAttr* attrs()
-       {
-               return (SkDOMAttr*)(this + 1);
-       }
+    const char* fName;
+    SkDOMNode*  fFirstChild;
+    SkDOMNode*  fNextSibling;
+    U16         fAttrCount;
+    U8          fType;
+    U8          fPad;
+
+    const SkDOMAttr* attrs() const
+    {
+        return (const SkDOMAttr*)(this + 1);
+    }
+    SkDOMAttr* attrs()
+    {
+        return (SkDOMAttr*)(this + 1);
+    }
 };
 
 /////////////////////////////////////////////////////////////////////////
 
-#define kMinChunkSize  512
+#define kMinChunkSize   512
 
 SkDOM::SkDOM() : fAlloc(kMinChunkSize), fRoot(nil)
 {
@@ -66,61 +83,61 @@ SkDOM::~SkDOM()
 
 const SkDOM::Node* SkDOM::getRootNode() const
 {
-       return fRoot;
+    return fRoot;
 }
 
 const SkDOM::Node* SkDOM::getFirstChild(const Node* node, const char name[]) const
 {
-       SkASSERT(node);
-       const Node* child = node->fFirstChild;
+    SkASSERT(node);
+    const Node* child = node->fFirstChild;
 
-       if (name)
-       {
-               for (; child != nil; child = child->fNextSibling)
-                       if (!strcmp(name, child->fName))
-                               break;
-       }
-       return child;
+    if (name)
+    {
+        for (; child != nil; child = child->fNextSibling)
+            if (!strcmp(name, child->fName))
+                break;
+    }
+    return child;
 }
 
 const SkDOM::Node* SkDOM::getNextSibling(const Node* node, const char name[]) const
 {
-       SkASSERT(node);
-       const Node* sibling = node->fNextSibling;
-       if (name)
-       {
-               for (; sibling != nil; sibling = sibling->fNextSibling)
-                       if (!strcmp(name, sibling->fName))
-                               break;
-       }
-       return sibling;
+    SkASSERT(node);
+    const Node* sibling = node->fNextSibling;
+    if (name)
+    {
+        for (; sibling != nil; sibling = sibling->fNextSibling)
+            if (!strcmp(name, sibling->fName))
+                break;
+    }
+    return sibling;
 }
 
 SkDOM::Type SkDOM::getType(const Node* node) const
 {
-       SkASSERT(node);
-       return (Type)node->fType;
+    SkASSERT(node);
+    return (Type)node->fType;
 }
 
 const char* SkDOM::getName(const Node* node) const
 {
-       SkASSERT(node);
-       return node->fName;
+    SkASSERT(node);
+    return node->fName;
 }
 
 const char* SkDOM::findAttr(const Node* node, const char name[]) const
 {
-       SkASSERT(node);
-       const Attr*     attr = node->attrs();
-       const Attr* stop = attr + node->fAttrCount;
+    SkASSERT(node);
+    const Attr* attr = node->attrs();
+    const Attr* stop = attr + node->fAttrCount;
 
-       while (attr < stop)
-       {
-               if (!strcmp(attr->fName, name))
-                       return attr->fValue;
-               attr += 1;
-       }
-       return nil;
+    while (attr < stop)
+    {
+        if (!strcmp(attr->fName, name))
+            return attr->fValue;
+        attr += 1;
+    }
+    return nil;
 }
 
 /////////////////////////////////////////////////////////////////////////////////////
@@ -156,23 +173,23 @@ const char* SkDOM::getAttrValue(const Node* node, const Attr* attr) const
 
 SkDOM::AttrIter::AttrIter(const SkDOM&, const SkDOM::Node* node)
 {
-       SkASSERT(node);
-       fAttr = node->attrs();
-       fStop = fAttr + node->fAttrCount;
+    SkASSERT(node);
+    fAttr = node->attrs();
+    fStop = fAttr + node->fAttrCount;
 }
 
 const char* SkDOM::AttrIter::next(const char** value)
 {
-       const char* name = nil;
+    const char* name = nil;
 
-       if (fAttr < fStop)
-       {
-               name = fAttr->fName;
-               if (value)
-                       *value = fAttr->fValue;
-               fAttr += 1;
-       }
-       return name;
+    if (fAttr < fStop)
+    {
+        name = fAttr->fName;
+        if (value)
+            *value = fAttr->fValue;
+        fAttr += 1;
+    }
+    return name;
 }
 
 //////////////////////////////////////////////////////////////////////////////
@@ -182,168 +199,168 @@ const char* SkDOM::AttrIter::next(const char** value)
 
 static char* dupstr(SkChunkAlloc* chunk, const char src[])
 {
-       SkASSERT(chunk && src);
-       size_t  len = strlen(src);
-       char*   dst = (char*)chunk->alloc(len + 1, SkChunkAlloc::kThrow_AllocFailType);
-       memcpy(dst, src, len + 1);
-       return dst;
+    SkASSERT(chunk && src);
+    size_t  len = strlen(src);
+    char*   dst = (char*)chunk->alloc(len + 1, SkChunkAlloc::kThrow_AllocFailType);
+    memcpy(dst, src, len + 1);
+    return dst;
 }
 
 class SkDOMParser : public SkXMLParser {
-       bool fNeedToFlush;
+    bool fNeedToFlush;
 public:
-       SkDOMParser(SkChunkAlloc* chunk) : SkXMLParser(&fParserError), fAlloc(chunk)
-       {
-               fRoot = nil;
-               fLevel = 0;
-               fNeedToFlush = true;
-       }
-       SkDOM::Node* getRoot() const { return fRoot; }
-       SkXMLParserError fParserError;
+    SkDOMParser(SkChunkAlloc* chunk) : SkXMLParser(&fParserError), fAlloc(chunk)
+    {
+        fRoot = nil;
+        fLevel = 0;
+        fNeedToFlush = true;
+    }
+    SkDOM::Node* getRoot() const { return fRoot; }
+    SkXMLParserError fParserError;
 protected:
-       void flushAttributes()
-       {
-               int     attrCount = fAttrs.count();
-
-               SkDOM::Node* node = (SkDOM::Node*)fAlloc->alloc(sizeof(SkDOM::Node) + attrCount * sizeof(SkDOM::Attr),
-                                                                                                               SkChunkAlloc::kThrow_AllocFailType);
-
-               node->fName = fElemName;
-               node->fFirstChild = nil;
-               node->fAttrCount = SkToU16(attrCount);
-               node->fType = SkDOM::kElement_Type;
-
-               if (fRoot == nil)
-               {
-                       node->fNextSibling = nil;
-                       fRoot = node;
-               }
-               else    // this adds siblings in reverse order. gets corrected in onEndElement()
-               {
-                       SkDOM::Node* parent = fParentStack.top();
-                       SkASSERT(fRoot && parent);
-                       node->fNextSibling = parent->fFirstChild;
-                       parent->fFirstChild = node;
-               }
-               *fParentStack.push() = node;
-
-               memcpy(node->attrs(), fAttrs.begin(), attrCount * sizeof(SkDOM::Attr));
-               fAttrs.reset();
-
-       }
-       virtual bool onStartElement(const char elem[])
-       {
-               if (fLevel > 0 && fNeedToFlush)
-                       this->flushAttributes();
-               fNeedToFlush = true;
-               fElemName = dupstr(fAlloc, elem);
-               ++fLevel;
-               return false;
-       }
-       virtual bool onAddAttribute(const char name[], const char value[])
-       {
-               SkDOM::Attr* attr = fAttrs.append();
-               attr->fName = dupstr(fAlloc, name);
-               attr->fValue = dupstr(fAlloc, value);
-               return false;
-       }
-       virtual bool onEndElement(const char elem[])
-       {
-               --fLevel;
-               if (fNeedToFlush)
-                       this->flushAttributes();
-               fNeedToFlush = false;
-
-               SkDOM::Node* parent;
-
-               fParentStack.pop(&parent);
-
-               SkDOM::Node* child = parent->fFirstChild;
-               SkDOM::Node* prev = nil;
-               while (child)
-               {
-                       SkDOM::Node* next = child->fNextSibling;
-                       child->fNextSibling = prev;
-                       prev = child;
-                       child = next;
-               }
-               parent->fFirstChild = prev;
-               return false;
-       }
+    void flushAttributes()
+    {
+        int attrCount = fAttrs.count();
+
+        SkDOM::Node* node = (SkDOM::Node*)fAlloc->alloc(sizeof(SkDOM::Node) + attrCount * sizeof(SkDOM::Attr),
+                                                        SkChunkAlloc::kThrow_AllocFailType);
+
+        node->fName = fElemName;
+        node->fFirstChild = nil;
+        node->fAttrCount = SkToU16(attrCount);
+        node->fType = SkDOM::kElement_Type;
+
+        if (fRoot == nil)
+        {
+            node->fNextSibling = nil;
+            fRoot = node;
+        }
+        else    // this adds siblings in reverse order. gets corrected in onEndElement()
+        {
+            SkDOM::Node* parent = fParentStack.top();
+            SkASSERT(fRoot && parent);
+            node->fNextSibling = parent->fFirstChild;
+            parent->fFirstChild = node;
+        }
+        *fParentStack.push() = node;
+
+        memcpy(node->attrs(), fAttrs.begin(), attrCount * sizeof(SkDOM::Attr));
+        fAttrs.reset();
+
+    }
+    virtual bool onStartElement(const char elem[])
+    {
+        if (fLevel > 0 && fNeedToFlush)
+            this->flushAttributes();
+        fNeedToFlush = true;
+        fElemName = dupstr(fAlloc, elem);
+        ++fLevel;
+        return false;
+    }
+    virtual bool onAddAttribute(const char name[], const char value[])
+    {
+        SkDOM::Attr* attr = fAttrs.append();
+        attr->fName = dupstr(fAlloc, name);
+        attr->fValue = dupstr(fAlloc, value);
+        return false;
+    }
+    virtual bool onEndElement(const char elem[])
+    {
+        --fLevel;
+        if (fNeedToFlush)
+            this->flushAttributes();
+        fNeedToFlush = false;
+
+        SkDOM::Node* parent;
+
+        fParentStack.pop(&parent);
+
+        SkDOM::Node* child = parent->fFirstChild;
+        SkDOM::Node* prev = nil;
+        while (child)
+        {
+            SkDOM::Node* next = child->fNextSibling;
+            child->fNextSibling = prev;
+            prev = child;
+            child = next;
+        }
+        parent->fFirstChild = prev;
+        return false;
+    }
 private:
-       SkTDArray<SkDOM::Node*> fParentStack;
-       SkChunkAlloc*   fAlloc;
-       SkDOM::Node*    fRoot;
-
-       // state needed for flushAttributes()
-       SkTDArray<SkDOM::Attr>  fAttrs;
-       char*                                   fElemName;
-       int                                             fLevel;
+    SkTDArray<SkDOM::Node*> fParentStack;
+    SkChunkAlloc*   fAlloc;
+    SkDOM::Node*    fRoot;
+
+    // state needed for flushAttributes()
+    SkTDArray<SkDOM::Attr>  fAttrs;
+    char*                   fElemName;
+    int                     fLevel;
 };
 
 const SkDOM::Node* SkDOM::build(const char doc[], size_t len)
 {
-       fAlloc.reset();
-       SkDOMParser     parser(&fAlloc);
-       if (!parser.parse(doc, len))
-       {
-               SkDEBUGCODE(SkDebugf("xml parse error, line %d\n", parser.fParserError.getLineNumber());)
-               fRoot = nil;
-               fAlloc.reset();
-               return nil;
-       }
-       fRoot = parser.getRoot();
-       return fRoot;
+    fAlloc.reset();
+    SkDOMParser parser(&fAlloc);
+    if (!parser.parse(doc, len))
+    {
+        SkDEBUGCODE(SkDebugf("xml parse error, line %d\n", parser.fParserError.getLineNumber());)
+        fRoot = nil;
+        fAlloc.reset();
+        return nil;
+    }
+    fRoot = parser.getRoot();
+    return fRoot;
 }
 
 ///////////////////////////////////////////////////////////////////////////
 
 static void walk_dom(const SkDOM& dom, const SkDOM::Node* node, SkXMLParser* parser)
 {
-       const char* elem = dom.getName(node);
+    const char* elem = dom.getName(node);
 
-       parser->startElement(elem);
-       
-       SkDOM::AttrIter iter(dom, node);
-       const char*             name;
-       const char*             value;
-       while ((name = iter.next(&value)) != nil)
-               parser->addAttribute(name, value);
+    parser->startElement(elem);
+    
+    SkDOM::AttrIter iter(dom, node);
+    const char*     name;
+    const char*     value;
+    while ((name = iter.next(&value)) != nil)
+        parser->addAttribute(name, value);
 
-       node = dom.getFirstChild(node, nil);
-       while (node)
-       {
-               walk_dom(dom, node, parser);
-               node = dom.getNextSibling(node, nil);
-       }
+    node = dom.getFirstChild(node, nil);
+    while (node)
+    {
+        walk_dom(dom, node, parser);
+        node = dom.getNextSibling(node, nil);
+    }
 
-       parser->endElement(elem);
+    parser->endElement(elem);
 }
 
 const SkDOM::Node* SkDOM::copy(const SkDOM& dom, const SkDOM::Node* node)
 {
-       fAlloc.reset();
-       SkDOMParser     parser(&fAlloc);
+    fAlloc.reset();
+    SkDOMParser parser(&fAlloc);
 
-       walk_dom(dom, node, &parser);
+    walk_dom(dom, node, &parser);
 
-       fRoot = parser.getRoot();
-       return fRoot;
+    fRoot = parser.getRoot();
+    return fRoot;
 }
 
 //////////////////////////////////////////////////////////////////////////
 
 int SkDOM::countChildren(const Node* node, const char elem[]) const
 {
-       int count = 0;
+    int count = 0;
 
-       node = this->getFirstChild(node, elem);
-       while (node)
-       {
-               count += 1;
-               node = this->getNextSibling(node, elem);
-       }
-       return count;
+    node = this->getFirstChild(node, elem);
+    while (node)
+    {
+        count += 1;
+        node = this->getNextSibling(node, elem);
+    }
+    return count;
 }
 
 //////////////////////////////////////////////////////////////////////////
@@ -352,66 +369,66 @@ int SkDOM::countChildren(const Node* node, const char elem[]) const
 
 bool SkDOM::findS32(const Node* node, const char name[], int32_t* value) const
 {
-       const char* vstr = this->findAttr(node, name);
-       return vstr && SkParse::FindS32(vstr, value);
+    const char* vstr = this->findAttr(node, name);
+    return vstr && SkParse::FindS32(vstr, value);
 }
 
 bool SkDOM::findScalars(const Node* node, const char name[], SkScalar value[], int count) const
 {
-       const char* vstr = this->findAttr(node, name);
-       return vstr && SkParse::FindScalars(vstr, value, count);
+    const char* vstr = this->findAttr(node, name);
+    return vstr && SkParse::FindScalars(vstr, value, count);
 }
 
 bool SkDOM::findHex(const Node* node, const char name[], uint32_t* value) const
 {
-       const char* vstr = this->findAttr(node, name);
-       return vstr && SkParse::FindHex(vstr, value);
+    const char* vstr = this->findAttr(node, name);
+    return vstr && SkParse::FindHex(vstr, value);
 }
 
 bool SkDOM::findBool(const Node* node, const char name[], bool* value) const
 {
-       const char* vstr = this->findAttr(node, name);
-       return vstr && SkParse::FindBool(vstr, value);
+    const char* vstr = this->findAttr(node, name);
+    return vstr && SkParse::FindBool(vstr, value);
 }
 
 int SkDOM::findList(const Node* node, const char name[], const char list[]) const
 {
-       const char* vstr = this->findAttr(node, name);
-       return vstr ? SkParse::FindList(vstr, list) : -1;
+    const char* vstr = this->findAttr(node, name);
+    return vstr ? SkParse::FindList(vstr, list) : -1;
 }
 
 bool SkDOM::hasAttr(const Node* node, const char name[], const char value[]) const
 {
-       const char* vstr = this->findAttr(node, name);
-       return vstr && !strcmp(vstr, value);
+    const char* vstr = this->findAttr(node, name);
+    return vstr && !strcmp(vstr, value);
 }
 
 bool SkDOM::hasS32(const Node* node, const char name[], int32_t target) const
 {
-       const char* vstr = this->findAttr(node, name);
-       int32_t     value;
-       return vstr && SkParse::FindS32(vstr, &value) && value == target;
+    const char* vstr = this->findAttr(node, name);
+    int32_t     value;
+    return vstr && SkParse::FindS32(vstr, &value) && value == target;
 }
 
 bool SkDOM::hasScalar(const Node* node, const char name[], SkScalar target) const
 {
-       const char* vstr = this->findAttr(node, name);
-       SkScalar        value;
-       return vstr && SkParse::FindScalar(vstr, &value) && value == target;
+    const char* vstr = this->findAttr(node, name);
+    SkScalar    value;
+    return vstr && SkParse::FindScalar(vstr, &value) && value == target;
 }
 
 bool SkDOM::hasHex(const Node* node, const char name[], uint32_t target) const
 {
-       const char* vstr = this->findAttr(node, name);
-       uint32_t        value;
-       return vstr && SkParse::FindHex(vstr, &value) && value == target;
+    const char* vstr = this->findAttr(node, name);
+    uint32_t    value;
+    return vstr && SkParse::FindHex(vstr, &value) && value == target;
 }
 
 bool SkDOM::hasBool(const Node* node, const char name[], bool target) const
 {
-       const char* vstr = this->findAttr(node, name);
-       bool            value;
-       return vstr && SkParse::FindBool(vstr, &value) && value == target;
+    const char* vstr = this->findAttr(node, name);
+    bool        value;
+    return vstr && SkParse::FindBool(vstr, &value) && value == target;
 }
 
 //////////////////////////////////////////////////////////////////////////
@@ -420,74 +437,74 @@ bool SkDOM::hasBool(const Node* node, const char name[], bool target) const
 
 static void tab(int level)
 {
-       while (--level >= 0)
-               SkDebugf("\t");
+    while (--level >= 0)
+        SkDebugf("\t");
 }
 
 void SkDOM::dump(const Node* node, int level) const
 {
-       if (node == nil)
-               node = this->getRootNode();
-       if (node)
-       {
-               tab(level);
-               SkDebugf("<%s", this->getName(node));
-
-               const Attr* attr = node->attrs();
-               const Attr* stop = attr + node->fAttrCount;
-               for (; attr < stop; attr++)
-                       SkDebugf(" %s=\"%s\"", attr->fName, attr->fValue);
-
-               const Node* child = this->getFirstChild(node);
-               if (child)
-               {
-                       SkDebugf(">\n");
-                       while (child)
-                       {
-                               this->dump(child, level+1);
-                               child = this->getNextSibling(child);
-                       }
-                       tab(level);
-                       SkDebugf("</%s>\n", node->fName);
-               }
-               else
-                       SkDebugf("/>\n");
-       }
+    if (node == nil)
+        node = this->getRootNode();
+    if (node)
+    {
+        tab(level);
+        SkDebugf("<%s", this->getName(node));
+
+        const Attr* attr = node->attrs();
+        const Attr* stop = attr + node->fAttrCount;
+        for (; attr < stop; attr++)
+            SkDebugf(" %s=\"%s\"", attr->fName, attr->fValue);
+
+        const Node* child = this->getFirstChild(node);
+        if (child)
+        {
+            SkDebugf(">\n");
+            while (child)
+            {
+                this->dump(child, level+1);
+                child = this->getNextSibling(child);
+            }
+            tab(level);
+            SkDebugf("</%s>\n", node->fName);
+        }
+        else
+            SkDebugf("/>\n");
+    }
 }
 
 void SkDOM::UnitTest()
 {
 #ifdef SK_SUPPORT_UNITTEST
-       static const char gDoc[] = 
-               "<root a='1' b='2'>"
-                       "<elem1 c='3' />"
-                       "<elem2 d='4' />"
-                       "<elem3 e='5'>"
-                               "<subelem1/>"
-                               "<subelem2 f='6' g='7'/>"
-                       "</elem3>"
-                       "<elem4 h='8'/>"
-               "</root>"
-               ;
-
-       SkDOM   dom;
-
-       SkASSERT(dom.getRootNode() == nil);
-
-       const Node* root = dom.build(gDoc, sizeof(gDoc) - 1);
-       SkASSERT(root && dom.getRootNode() == root);
-
-       const char* v = dom.findAttr(root, "a");
-       SkASSERT(v && !strcmp(v, "1"));
-       v = dom.findAttr(root, "b");
-       SkASSERT(v && !strcmp(v, "2"));
-       v = dom.findAttr(root, "c");
-       SkASSERT(v == nil);
-
-       SkASSERT(dom.getFirstChild(root, "elem1"));
-       SkASSERT(!dom.getFirstChild(root, "subelem1"));
-
-       dom.dump();
+    static const char gDoc[] = 
+        "<root a='1' b='2'>"
+            "<elem1 c='3' />"
+            "<elem2 d='4' />"
+            "<elem3 e='5'>"
+                "<subelem1/>"
+                "<subelem2 f='6' g='7'/>"
+            "</elem3>"
+            "<elem4 h='8'/>"
+        "</root>"
+        ;
+
+    SkDOM   dom;
+
+    SkASSERT(dom.getRootNode() == nil);
+
+    const Node* root = dom.build(gDoc, sizeof(gDoc) - 1);
+    SkASSERT(root && dom.getRootNode() == root);
+
+    const char* v = dom.findAttr(root, "a");
+    SkASSERT(v && !strcmp(v, "1"));
+    v = dom.findAttr(root, "b");
+    SkASSERT(v && !strcmp(v, "2"));
+    v = dom.findAttr(root, "c");
+    SkASSERT(v == nil);
+
+    SkASSERT(dom.getFirstChild(root, "elem1"));
+    SkASSERT(!dom.getFirstChild(root, "subelem1"));
+
+    dom.dump();
 #endif
 }
 
index 06e7e83..2ded20d 100644 (file)
@@ -1,3 +1,20 @@
+/* libs/graphics/xml/SkJS.cpp
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #include <jsapi.h>
 
 #include "SkJS.h"
 
 #ifdef _WIN32_WCE
 extern "C" {
-       void abort() {
-               SkASSERT(0);
-       }
-
-       unsigned int _control87(unsigned int _new, unsigned int mask ) {
-               SkASSERT(0);
-               return 0;
-       }
-
-       time_t mktime(struct tm *timeptr ) {
-               SkASSERT(0);
-               return 0;
-       }
-
-//     int errno;
-
-       char *strdup(const char *) {
-               SkASSERT(0);
-               return 0;
-       }
-
-       char *strerror(int errnum) {
-               SkASSERT(0);
-               return 0;
-       }
-
-       int isatty(void* fd) {
-               SkASSERT(0);
-               return 0;
-       }
-
-       int putenv(const char *envstring) {
-               SkASSERT(0);
-               return 0;
-       }
-
-       char *getenv(const char *varname) {
-               SkASSERT(0);
-               return 0;
-       }
-
-       void GetSystemTimeAsFileTime(LPFILETIME lpSystemTimeAsFileTime) {
-               SkASSERT(0);
-       }
-
-       struct tm * localtime(const time_t *timer) {
-               SkASSERT(0);
-               return 0;
-       }
-
-       size_t strftime(char *strDest, size_t maxsize, const char *format,
-               const struct tm *timeptr ) {
-               SkASSERT(0);
-               return 0;
-       }
+    void abort() {
+        SkASSERT(0);
+    }
+
+    unsigned int _control87(unsigned int _new, unsigned int mask ) {
+        SkASSERT(0);
+        return 0;
+    }
+
+    time_t mktime(struct tm *timeptr ) {
+        SkASSERT(0);
+        return 0;
+    }
+
+//  int errno;
+
+    char *strdup(const char *) {
+        SkASSERT(0);
+        return 0;
+    }
+
+    char *strerror(int errnum) {
+        SkASSERT(0);
+        return 0;
+    }
+
+    int isatty(void* fd) {
+        SkASSERT(0);
+        return 0;
+    }
+
+    int putenv(const char *envstring) {
+        SkASSERT(0);
+        return 0;
+    }
+
+    char *getenv(const char *varname) {
+        SkASSERT(0);
+        return 0;
+    }
+
+    void GetSystemTimeAsFileTime(LPFILETIME lpSystemTimeAsFileTime) {
+        SkASSERT(0);
+    }
+
+    struct tm * localtime(const time_t *timer) {
+        SkASSERT(0);
+        return 0;
+    }
+
+    size_t strftime(char *strDest, size_t maxsize, const char *format,
+        const struct tm *timeptr ) {
+        SkASSERT(0);
+        return 0;
+    }
 
 }
 #endif
@@ -150,70 +167,71 @@ JSClass global_class = {
 };
 
 SkJS::SkJS(void* hwnd) : SkOSWindow(hwnd) {
-       if ((fRuntime = JS_NewRuntime(0x100000)) == nil) {
-               SkASSERT(0);
-               return;
-       }
-       if ((fContext = JS_NewContext(fRuntime, 0x1000)) == nil) {
-               SkASSERT(0);
-               return;
-       }
-       ;
-       if ((fGlobal = JS_NewObject(fContext, &global_class, NULL, NULL)) == nil) {
-               SkASSERT(0);
-               return;
-       }
-       if (JS_InitStandardClasses(fContext, fGlobal) == nil) {
-               SkASSERT(0);
-               return;
-       }
-       setConfig(SkBitmap::kARGB32_Config);
-       updateSize();
-       setVisibleP(true);
-       InitializeDisplayables(getBitmap(), fContext, fGlobal, NULL);
+    if ((fRuntime = JS_NewRuntime(0x100000)) == nil) {
+        SkASSERT(0);
+        return;
+    }
+    if ((fContext = JS_NewContext(fRuntime, 0x1000)) == nil) {
+        SkASSERT(0);
+        return;
+    }
+    ;
+    if ((fGlobal = JS_NewObject(fContext, &global_class, NULL, NULL)) == nil) {
+        SkASSERT(0);
+        return;
+    }
+    if (JS_InitStandardClasses(fContext, fGlobal) == nil) {
+        SkASSERT(0);
+        return;
+    }
+    setConfig(SkBitmap::kARGB32_Config);
+    updateSize();
+    setVisibleP(true);
+    InitializeDisplayables(getBitmap(), fContext, fGlobal, NULL);
 }
 
 SkJS::~SkJS() {
-       DisposeDisplayables();
+    DisposeDisplayables();
     JS_DestroyContext(fContext);
     JS_DestroyRuntime(fRuntime);
     JS_ShutDown();
 }
 
 SkBool SkJS::EvaluateScript(const char* script, jsval* rVal) {
-       return JS_EvaluateScript(fContext, fGlobal, script, strlen(script),
-               "memory" /* no file name */, 0 /* no line number */, rVal);
+    return JS_EvaluateScript(fContext, fGlobal, script, strlen(script),
+        "memory" /* no file name */, 0 /* no line number */, rVal);
 }
 
 SkBool SkJS::ValueToString(jsval value, SkString* string) {
-        JSString* str = JS_ValueToString(fContext, value);
-        if (str == NULL)
-                return false;
-        string->set(JS_GetStringBytes(str));
-        return true;
+     JSString* str = JS_ValueToString(fContext, value);
+     if (str == NULL)
+         return false;
+     string->set(JS_GetStringBytes(str));
+     return true;
 }
 
 #ifdef SK_DEBUG
 void SkJS::Test(void* hwnd) {
-       SkJS js(hwnd);
-       jsval val;
-       SkBool success = js.EvaluateScript("22/7", &val);
-       SkASSERT(success);
-       SkString string;
-       success = js.ValueToString(val, &string);
-       SkASSERT(success);
-       SkASSERT(strcmp(string.c_str(), "3.142857142857143") == 0);
-       success = js.EvaluateScript(
-               "var rect = new rectangle();"
-               "rect.left = 4;"
-               "rect.top = 10;"
-               "rect.right = 20;"
-               "rect.bottom = 30;"
-               "rect.width = rect.height + 20;"
-               "rect.draw();"
-               , &val);
-       SkASSERT(success);
-       success = js.ValueToString(val, &string);
-       SkASSERT(success);
+    SkJS js(hwnd);
+    jsval val;
+    SkBool success = js.EvaluateScript("22/7", &val);
+    SkASSERT(success);
+    SkString string;
+    success = js.ValueToString(val, &string);
+    SkASSERT(success);
+    SkASSERT(strcmp(string.c_str(), "3.142857142857143") == 0);
+    success = js.EvaluateScript(
+        "var rect = new rectangle();"
+        "rect.left = 4;"
+        "rect.top = 10;"
+        "rect.right = 20;"
+        "rect.bottom = 30;"
+        "rect.width = rect.height + 20;"
+        "rect.draw();"
+        , &val);
+    SkASSERT(success);
+    success = js.ValueToString(val, &string);
+    SkASSERT(success);
 }
-#endif
\ No newline at end of file
+#endifASSERT(success);
+
index 6d5e10f..76a9cd1 100644 (file)
@@ -1,3 +1,20 @@
+/* libs/graphics/xml/SkJSDisplayable.cpp
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #include <jsapi.h>
 #include "SkJS.h"
 #include "SkDisplayType.h"
 
 class SkJSDisplayable {
 public:
-       SkJSDisplayable() : fDisplayable(nil) {}
-       ~SkJSDisplayable() { delete fDisplayable; }
-       static void Destructor(JSContext *cx, JSObject *obj);
-       static JSBool GetProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp);
-       static JSBool SetProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp);
-       static SkCanvas* gCanvas;
-       static SkPaint* gPaint;
-       static JSBool Draw(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval);
-       SkDisplayable* fDisplayable;
+    SkJSDisplayable() : fDisplayable(nil) {}
+    ~SkJSDisplayable() { delete fDisplayable; }
+    static void Destructor(JSContext *cx, JSObject *obj);
+    static JSBool GetProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp);
+    static JSBool SetProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp);
+    static SkCanvas* gCanvas;
+    static SkPaint* gPaint;
+    static JSBool Draw(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval);
+    SkDisplayable* fDisplayable;
 };
 
 SkCanvas* SkJSDisplayable::gCanvas;
 SkPaint* SkJSDisplayable::gPaint;
 
 JSBool SkJSDisplayable::Draw(JSContext *cx, JSObject *obj, uintN argc,
-                                                                       jsval *argv, jsval *rval)
+                                    jsval *argv, jsval *rval)
 {
     SkJSDisplayable *p = (SkJSDisplayable*) JS_GetPrivate(cx, obj);
     SkASSERT(p->fDisplayable->isDrawable());
-       SkDrawable* drawable = (SkDrawable*) p->fDisplayable;
-       SkAnimateMaker maker(nil, gCanvas, gPaint);
-       drawable->draw(maker);
-       return JS_TRUE;
+    SkDrawable* drawable = (SkDrawable*) p->fDisplayable;
+    SkAnimateMaker maker(nil, gCanvas, gPaint);
+    drawable->draw(maker);
+    return JS_TRUE;
 }
 
 
 JSFunctionSpec SkJSDisplayable_methods[] = 
 {
-       { "draw", SkJSDisplayable::Draw, 1, 0, 0 },
-       { 0 }
+    { "draw", SkJSDisplayable::Draw, 1, 0, 0 },
+    { 0 }
 };
 
 static JSPropertySpec* gDisplayableProperties[kNumberOfTypes];
@@ -85,18 +102,18 @@ static JSClass gDisplayableClasses[kNumberOfTypes];
 
 #define JS_INIT(_prefix, _class) \
 static JSBool _class##Constructor(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) { \
-       SkJSDisplayable* jsDisplayable = new SkJSDisplayable(); \
-       jsDisplayable->fDisplayable = new _prefix##_class(); \
-       JS_SetPrivate(cx, obj, (void*) jsDisplayable); \
-       return JS_TRUE; \
+    SkJSDisplayable* jsDisplayable = new SkJSDisplayable(); \
+    jsDisplayable->fDisplayable = new _prefix##_class(); \
+    JS_SetPrivate(cx, obj, (void*) jsDisplayable); \
+    return JS_TRUE; \
 } \
-       \
+    \
 static JSObject* _class##Init(JSContext *cx, JSObject *obj, JSObject *proto) { \
-       JSObject *newProtoObj = JS_InitClass(cx, obj, proto, &gDisplayableClasses[SkType_##_class], \
-               _class##Constructor, 0, \
-               NULL, SkJSDisplayable_methods , \
-               NULL, NULL); \
-       JS_DefineProperties(cx, newProtoObj, gDisplayableProperties[SkType_##_class]); \
+    JSObject *newProtoObj = JS_InitClass(cx, obj, proto, &gDisplayableClasses[SkType_##_class], \
+        _class##Constructor, 0, \
+        NULL, SkJSDisplayable_methods , \
+        NULL, NULL); \
+    JS_DefineProperties(cx, newProtoObj, gDisplayableProperties[SkType_##_class]); \
     return newProtoObj; \
 }
 
@@ -174,282 +191,282 @@ JS_INIT(Sk, Translate)
 
 #if SK_USE_CONDENSED_INFO == 0
 static void GenerateTables() {
-       for (int index = 0; index < kTypeNamesSize; index++) {
-               int infoCount;
-               SkDisplayTypes type = gTypeNames[index].fType;
-               const SkMemberInfo* info = SkDisplayType::GetMembers(nil /* fMaker */, type, &infoCount);
-               if (info == nil)
-                       continue;
-               gDisplayableProperties[type] = new JSPropertySpec[infoCount + 1];
-               JSPropertySpec* propertySpec = gDisplayableProperties[type];
-               memset(propertySpec, 0, sizeof (JSPropertySpec) * (infoCount + 1));
-               for (int inner = 0; inner < infoCount; inner++) {
-                       if (info[inner].fType == SkType_BaseClassInfo)
-                               continue;
-                       propertySpec[inner].name = info[inner].fName;
-                       propertySpec[inner].tinyid = inner;
-                       propertySpec[inner].flags = JSPROP_ENUMERATE;
-               }
-               gDisplayableClasses[type].name = gTypeNames[index].fName;
-               gDisplayableClasses[type].flags = JSCLASS_HAS_PRIVATE;
-               gDisplayableClasses[type].addProperty = JS_PropertyStub;
-               gDisplayableClasses[type].delProperty = JS_PropertyStub;
-               gDisplayableClasses[type].getProperty = SkJSDisplayable::GetProperty;
-               gDisplayableClasses[type].setProperty = SkJSDisplayable::SetProperty;
-               gDisplayableClasses[type].enumerate = JS_EnumerateStub;
-               gDisplayableClasses[type].resolve = JS_ResolveStub;
-               gDisplayableClasses[type].convert = JS_ConvertStub;
-               gDisplayableClasses[type].finalize = SkJSDisplayable::Destructor;
-       }
+    for (int index = 0; index < kTypeNamesSize; index++) {
+        int infoCount;
+        SkDisplayTypes type = gTypeNames[index].fType;
+        const SkMemberInfo* info = SkDisplayType::GetMembers(nil /* fMaker */, type, &infoCount);
+        if (info == nil)
+            continue;
+        gDisplayableProperties[type] = new JSPropertySpec[infoCount + 1];
+        JSPropertySpec* propertySpec = gDisplayableProperties[type];
+        memset(propertySpec, 0, sizeof (JSPropertySpec) * (infoCount + 1));
+        for (int inner = 0; inner < infoCount; inner++) {
+            if (info[inner].fType == SkType_BaseClassInfo)
+                continue;
+            propertySpec[inner].name = info[inner].fName;
+            propertySpec[inner].tinyid = inner;
+            propertySpec[inner].flags = JSPROP_ENUMERATE;
+        }
+        gDisplayableClasses[type].name = gTypeNames[index].fName;
+        gDisplayableClasses[type].flags = JSCLASS_HAS_PRIVATE;
+        gDisplayableClasses[type].addProperty = JS_PropertyStub;
+        gDisplayableClasses[type].delProperty = JS_PropertyStub;
+        gDisplayableClasses[type].getProperty = SkJSDisplayable::GetProperty;
+        gDisplayableClasses[type].setProperty = SkJSDisplayable::SetProperty;
+        gDisplayableClasses[type].enumerate = JS_EnumerateStub;
+        gDisplayableClasses[type].resolve = JS_ResolveStub;
+        gDisplayableClasses[type].convert = JS_ConvertStub;
+        gDisplayableClasses[type].finalize = SkJSDisplayable::Destructor;
+    }
 }
 #endif
 
 void SkJSDisplayable::Destructor(JSContext *cx, JSObject *obj) {
-       delete (SkJSDisplayable*) JS_GetPrivate(cx, obj);
+    delete (SkJSDisplayable*) JS_GetPrivate(cx, obj);
 }
 
 JSBool SkJSDisplayable::GetProperty(JSContext *cx, JSObject *obj, jsval id,
-                                                                jsval *vp)
+                                 jsval *vp)
 {
-       if (JSVAL_IS_INT(id) == 0)
-               return JS_TRUE; 
-       SkJSDisplayable *p = (SkJSDisplayable *) JS_GetPrivate(cx, obj);
-       SkDisplayable* displayable = p->fDisplayable;
-       SkDisplayTypes displayableType = displayable->getType();
-       int members;
-       const SkMemberInfo* info = SkDisplayType::GetMembers(nil /* fMaker */, displayableType, &members);
-       int idIndex = JSVAL_TO_INT(id);
-       SkASSERT(idIndex >= 0 && idIndex < members);
-       info = &info[idIndex];
-       SkDisplayTypes infoType = (SkDisplayTypes) info->fType;
-       SkScalar scalar = 0;
-       S32 s32 = 0;
-       SkString* string= nil;
-       JSString *str;
-       if (infoType == SkType_MemberProperty) {
-               infoType = info->propertyType();
-               switch (infoType) {
-                       case SkType_Scalar: {
-                               SkScriptValue scriptValue;
-                               bool success = displayable->getProperty(info->propertyIndex(), &scriptValue);
-                               SkASSERT(scriptValue.fType == SkType_Scalar);
-                               scalar = scriptValue.fOperand.fScalar;
-                               } break;
-                       default:
-                               SkASSERT(0); // !!! unimplemented
-               }
-       } else {
-               SkASSERT(info->fCount == 1);
-               switch (infoType) {
-                       case SkType_Boolean:
-                       case SkType_Color:
-                       case SkType_S32:
-                               s32 = *(S32*) info->memberData(displayable);
-                               break;
-                       case SkType_String:
-                               info->getString(displayable, &string);
-                               break;
-                       case SkType_Scalar:
-                               SkOperand operand;
-                               info->getValue(displayable, &operand, 1);
-                               scalar = operand.fScalar;
-                               break;
-                       default:
-                               SkASSERT(0); // !!! unimplemented
-               }
-       }
-       switch (infoType) {
-               case SkType_Boolean:
-                       *vp = BOOLEAN_TO_JSVAL(s32);
-                       break;
-               case SkType_Color:
-               case SkType_S32:
-                       *vp = INT_TO_JSVAL(s32);
-                       break;
-               case SkType_Scalar:
-                       if (SkScalarFraction(scalar) == 0)
-                               *vp = INT_TO_JSVAL(SkScalarFloor(scalar));
-                       else
+    if (JSVAL_IS_INT(id) == 0)
+        return JS_TRUE; 
+    SkJSDisplayable *p = (SkJSDisplayable *) JS_GetPrivate(cx, obj);
+    SkDisplayable* displayable = p->fDisplayable;
+    SkDisplayTypes displayableType = displayable->getType();
+    int members;
+    const SkMemberInfo* info = SkDisplayType::GetMembers(nil /* fMaker */, displayableType, &members);
+    int idIndex = JSVAL_TO_INT(id);
+    SkASSERT(idIndex >= 0 && idIndex < members);
+    info = &info[idIndex];
+    SkDisplayTypes infoType = (SkDisplayTypes) info->fType;
+    SkScalar scalar = 0;
+    S32 s32 = 0;
+    SkString* string= nil;
+    JSString *str;
+    if (infoType == SkType_MemberProperty) {
+        infoType = info->propertyType();
+        switch (infoType) {
+            case SkType_Scalar: {
+                SkScriptValue scriptValue;
+                bool success = displayable->getProperty(info->propertyIndex(), &scriptValue);
+                SkASSERT(scriptValue.fType == SkType_Scalar);
+                scalar = scriptValue.fOperand.fScalar;
+                } break;
+            default:
+                SkASSERT(0); // !!! unimplemented
+        }
+    } else {
+        SkASSERT(info->fCount == 1);
+        switch (infoType) {
+            case SkType_Boolean:
+            case SkType_Color:
+            case SkType_S32:
+                s32 = *(S32*) info->memberData(displayable);
+                break;
+            case SkType_String:
+                info->getString(displayable, &string);
+                break;
+            case SkType_Scalar:
+                SkOperand operand;
+                info->getValue(displayable, &operand, 1);
+                scalar = operand.fScalar;
+                break;
+            default:
+                SkASSERT(0); // !!! unimplemented
+        }
+    }
+    switch (infoType) {
+        case SkType_Boolean:
+            *vp = BOOLEAN_TO_JSVAL(s32);
+            break;
+        case SkType_Color:
+        case SkType_S32:
+            *vp = INT_TO_JSVAL(s32);
+            break;
+        case SkType_Scalar:
+            if (SkScalarFraction(scalar) == 0)
+                *vp = INT_TO_JSVAL(SkScalarFloor(scalar));
+            else
 #ifdef SK_SCALAR_IS_FLOAT
-                       *vp = DOUBLE_TO_JSVAL(scalar);
+            *vp = DOUBLE_TO_JSVAL(scalar);
 #else
-                       *vp = DOUBLE_TO_JSVAL(scalar / 65536.0f );
+            *vp = DOUBLE_TO_JSVAL(scalar / 65536.0f );
 #endif
-                       break;
-               case SkType_String:
-                       str = JS_NewStringCopyN(cx, string->c_str(), string->size());
-                       *vp = STRING_TO_JSVAL(str);
-                       break;
-               default:
-                       SkASSERT(0); // !!! unimplemented
-       }
+            break;
+        case SkType_String:
+            str = JS_NewStringCopyN(cx, string->c_str(), string->size());
+            *vp = STRING_TO_JSVAL(str);
+            break;
+        default:
+            SkASSERT(0); // !!! unimplemented
+    }
     return JS_TRUE;
 }
 
 JSBool SkJSDisplayable::SetProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp) {
-       if (JSVAL_IS_INT(id) == 0)
-               return JS_TRUE; 
-       SkJSDisplayable *p = (SkJSDisplayable *) JS_GetPrivate(cx, obj);
-       SkDisplayable* displayable = p->fDisplayable;
-       SkDisplayTypes displayableType = displayable->getType();
-       int members;
-       const SkMemberInfo* info = SkDisplayType::GetMembers(nil /* fMaker */, displayableType, &members);
-       int idIndex = JSVAL_TO_INT(id);
-       SkASSERT(idIndex >= 0 && idIndex < members);
-       info = &info[idIndex];
-       SkDisplayTypes infoType = info->getType();
-       SkScalar scalar = 0;
-       S32 s32 = 0;
-       SkString string;
-       JSString* str;
-       jsval value = *vp;
-       switch (infoType) {
-               case SkType_Boolean:
-                       s32 = JSVAL_TO_BOOLEAN(value);
-                       break;
-               case SkType_Color:
-               case SkType_S32:
-                       s32 = JSVAL_TO_INT(value);
-                       break;
-               case SkType_Scalar:
-                       if (JSVAL_IS_INT(value))
-                               scalar = SkIntToScalar(JSVAL_TO_INT(value));
-                       else {
-                               SkASSERT(JSVAL_IS_DOUBLE(value));
+    if (JSVAL_IS_INT(id) == 0)
+        return JS_TRUE; 
+    SkJSDisplayable *p = (SkJSDisplayable *) JS_GetPrivate(cx, obj);
+    SkDisplayable* displayable = p->fDisplayable;
+    SkDisplayTypes displayableType = displayable->getType();
+    int members;
+    const SkMemberInfo* info = SkDisplayType::GetMembers(nil /* fMaker */, displayableType, &members);
+    int idIndex = JSVAL_TO_INT(id);
+    SkASSERT(idIndex >= 0 && idIndex < members);
+    info = &info[idIndex];
+    SkDisplayTypes infoType = info->getType();
+    SkScalar scalar = 0;
+    S32 s32 = 0;
+    SkString string;
+    JSString* str;
+    jsval value = *vp;
+    switch (infoType) {
+        case SkType_Boolean:
+            s32 = JSVAL_TO_BOOLEAN(value);
+            break;
+        case SkType_Color:
+        case SkType_S32:
+            s32 = JSVAL_TO_INT(value);
+            break;
+        case SkType_Scalar:
+            if (JSVAL_IS_INT(value))
+                scalar = SkIntToScalar(JSVAL_TO_INT(value));
+            else {
+                SkASSERT(JSVAL_IS_DOUBLE(value));
 #ifdef SK_SCALAR_IS_FLOAT
-                               scalar = (float) *(double*) JSVAL_TO_DOUBLE(value);
+                scalar = (float) *(double*) JSVAL_TO_DOUBLE(value);
 #else
-                               scalar = (SkFixed)  (*(double*)JSVAL_TO_DOUBLE(value) * 65536.0);
+                scalar = (SkFixed)  (*(double*)JSVAL_TO_DOUBLE(value) * 65536.0);
 #endif
-                       }
-                       break;
-               case SkType_String:
-                       str = JS_ValueToString(cx, value);
-                       string.set(JS_GetStringBytes(str));
-                       break;
-               default:
-                       SkASSERT(0); // !!! unimplemented
-       }
-       if (info->fType == SkType_MemberProperty) {
-               switch (infoType) {
-                       case SkType_Scalar: {
-                               SkScriptValue scriptValue;
-                               scriptValue.fType = SkType_Scalar;
-                               scriptValue.fOperand.fScalar = scalar;
-                               displayable->setProperty(-1 - (int) info->fOffset, scriptValue);
-                               } break;
-                       default:
-                               SkASSERT(0); // !!! unimplemented
-               }
-       } else {
-               SkASSERT(info->fCount == 1);
-               switch (infoType) {
-                       case SkType_Boolean:
-                       case SkType_Color:
-                       case SkType_S32:
-                               s32 = *(S32*) ((const char*) displayable + info->fOffset);
-                               break;
-                       case SkType_String:
-                               info->setString(displayable, &string);
-                               break;
-                       case SkType_Scalar:
-                               SkOperand operand;
-                               operand.fScalar = scalar;
-                               info->setValue(displayable, &operand, 1);
-                               break;
-                       default:
-                               SkASSERT(0); // !!! unimplemented
-               }
-       }
+            }
+            break;
+        case SkType_String:
+            str = JS_ValueToString(cx, value);
+            string.set(JS_GetStringBytes(str));
+            break;
+        default:
+            SkASSERT(0); // !!! unimplemented
+    }
+    if (info->fType == SkType_MemberProperty) {
+        switch (infoType) {
+            case SkType_Scalar: {
+                SkScriptValue scriptValue;
+                scriptValue.fType = SkType_Scalar;
+                scriptValue.fOperand.fScalar = scalar;
+                displayable->setProperty(-1 - (int) info->fOffset, scriptValue);
+                } break;
+            default:
+                SkASSERT(0); // !!! unimplemented
+        }
+    } else {
+        SkASSERT(info->fCount == 1);
+        switch (infoType) {
+            case SkType_Boolean:
+            case SkType_Color:
+            case SkType_S32:
+                s32 = *(S32*) ((const char*) displayable + info->fOffset);
+                break;
+            case SkType_String:
+                info->setString(displayable, &string);
+                break;
+            case SkType_Scalar:
+                SkOperand operand;
+                operand.fScalar = scalar;
+                info->setValue(displayable, &operand, 1);
+                break;
+            default:
+                SkASSERT(0); // !!! unimplemented
+        }
+    }
     return JS_TRUE;
 }
 
 void SkJS::InitializeDisplayables(const SkBitmap& bitmap, JSContext *cx, JSObject *obj, JSObject *proto) {
-       SkJSDisplayable::gCanvas = new SkCanvas(bitmap);
-       SkJSDisplayable::gPaint = new SkPaint();
+    SkJSDisplayable::gCanvas = new SkCanvas(bitmap);
+    SkJSDisplayable::gPaint = new SkPaint();
 #if SK_USE_CONDENSED_INFO == 0
-       GenerateTables();
+    GenerateTables();
 #else
-       SkASSERT(0); // !!! compressed version hasn't been implemented
+    SkASSERT(0); // !!! compressed version hasn't been implemented
 #endif
-       AddInit(cx, obj, proto);
-       AddCircleInit(cx, obj, proto);
-       AddOvalInit(cx, obj, proto);
-       AddPathInit(cx, obj, proto);
-       AddRectangleInit(cx, obj, proto);
-       AddRoundRectInit(cx, obj, proto);
-//     AfterInit(cx, obj, proto);
-       ApplyInit(cx, obj, proto);
-       // AnimateInit(cx, obj, proto);
-//     AnimateColorInit(cx, obj, proto);
-       AnimateFieldInit(cx, obj, proto);
-//     AnimateRotateInit(cx, obj, proto);
-//     AnimateScaleInit(cx, obj, proto);
-//     AnimateTranslateInit(cx, obj, proto);
-       BitmapInit(cx, obj, proto);
-//     BaseBitmapInit(cx, obj, proto);
-//     BeforeInit(cx, obj, proto);
-       BitmapShaderInit(cx, obj, proto);
-       BlurInit(cx, obj, proto);
-       ClipInit(cx, obj, proto);
-       ColorInit(cx, obj, proto);
-       CubicToInit(cx, obj, proto);
-       DashInit(cx, obj, proto);
-       DataInit(cx, obj, proto);
-//     DimensionsInit(cx, obj, proto);
-       DiscreteInit(cx, obj, proto);
-       DrawToInit(cx, obj, proto);
-       EmbossInit(cx, obj, proto);
-       EventInit(cx, obj, proto);
-//     FontInit(cx, obj, proto);
-//     FocusInit(cx, obj, proto);
-       ImageInit(cx, obj, proto);
-       IncludeInit(cx, obj, proto);
-//     InputInit(cx, obj, proto);
-       LineInit(cx, obj, proto);
-       LinearGradientInit(cx, obj, proto);
-       LineToInit(cx, obj, proto);
-       MatrixInit(cx, obj, proto);
-       MoveInit(cx, obj, proto);
-       MoveToInit(cx, obj, proto);
-       OvalInit(cx, obj, proto);
-       PathInit(cx, obj, proto);
-       PaintInit(cx, obj, proto);
-       DrawPointInit(cx, obj, proto);
-       PolyToPolyInit(cx, obj, proto);
-       PolygonInit(cx, obj, proto);
-       PolylineInit(cx, obj, proto);
-       PostInit(cx, obj, proto);
-       QuadToInit(cx, obj, proto);
-       RadialGradientInit(cx, obj, proto);
-       RandomInit(cx, obj, proto);
-       RectToRectInit(cx, obj, proto);
-       RectangleInit(cx, obj, proto);
-       RemoveInit(cx, obj, proto);
-       ReplaceInit(cx, obj, proto);
-       RotateInit(cx, obj, proto);
-       RoundRectInit(cx, obj, proto);
-       ScaleInit(cx, obj, proto);
-       SetInit(cx, obj, proto);
-       SkewInit(cx, obj, proto);
-       // 3D_CameraInit(cx, obj, proto);
-       // 3D_PatchInit(cx, obj, proto);
-       #ifdef SK_SUPPORT_IMAGE_ENCODE
-       SnapshotInit(cx, obj, proto);
-       #endif
-//     StrokeInit(cx, obj, proto);
-       TextInit(cx, obj, proto);
-       TextOnPathInit(cx, obj, proto);
-       TextToPathInit(cx, obj, proto);
-       TranslateInit(cx, obj, proto);
-//     UseInit(cx, obj, proto);
+    AddInit(cx, obj, proto);
+    AddCircleInit(cx, obj, proto);
+    AddOvalInit(cx, obj, proto);
+    AddPathInit(cx, obj, proto);
+    AddRectangleInit(cx, obj, proto);
+    AddRoundRectInit(cx, obj, proto);
+//  AfterInit(cx, obj, proto);
+    ApplyInit(cx, obj, proto);
+    // AnimateInit(cx, obj, proto);
+//  AnimateColorInit(cx, obj, proto);
+    AnimateFieldInit(cx, obj, proto);
+//  AnimateRotateInit(cx, obj, proto);
+//  AnimateScaleInit(cx, obj, proto);
+//  AnimateTranslateInit(cx, obj, proto);
+    BitmapInit(cx, obj, proto);
+//  BaseBitmapInit(cx, obj, proto);
+//  BeforeInit(cx, obj, proto);
+    BitmapShaderInit(cx, obj, proto);
+    BlurInit(cx, obj, proto);
+    ClipInit(cx, obj, proto);
+    ColorInit(cx, obj, proto);
+    CubicToInit(cx, obj, proto);
+    DashInit(cx, obj, proto);
+    DataInit(cx, obj, proto);
+//  DimensionsInit(cx, obj, proto);
+    DiscreteInit(cx, obj, proto);
+    DrawToInit(cx, obj, proto);
+    EmbossInit(cx, obj, proto);
+    EventInit(cx, obj, proto);
+//  FontInit(cx, obj, proto);
+//  FocusInit(cx, obj, proto);
+    ImageInit(cx, obj, proto);
+    IncludeInit(cx, obj, proto);
+//  InputInit(cx, obj, proto);
+    LineInit(cx, obj, proto);
+    LinearGradientInit(cx, obj, proto);
+    LineToInit(cx, obj, proto);
+    MatrixInit(cx, obj, proto);
+    MoveInit(cx, obj, proto);
+    MoveToInit(cx, obj, proto);
+    OvalInit(cx, obj, proto);
+    PathInit(cx, obj, proto);
+    PaintInit(cx, obj, proto);
+    DrawPointInit(cx, obj, proto);
+    PolyToPolyInit(cx, obj, proto);
+    PolygonInit(cx, obj, proto);
+    PolylineInit(cx, obj, proto);
+    PostInit(cx, obj, proto);
+    QuadToInit(cx, obj, proto);
+    RadialGradientInit(cx, obj, proto);
+    RandomInit(cx, obj, proto);
+    RectToRectInit(cx, obj, proto);
+    RectangleInit(cx, obj, proto);
+    RemoveInit(cx, obj, proto);
+    ReplaceInit(cx, obj, proto);
+    RotateInit(cx, obj, proto);
+    RoundRectInit(cx, obj, proto);
+    ScaleInit(cx, obj, proto);
+    SetInit(cx, obj, proto);
+    SkewInit(cx, obj, proto);
+    // 3D_CameraInit(cx, obj, proto);
+    // 3D_PatchInit(cx, obj, proto);
+    #ifdef SK_SUPPORT_IMAGE_ENCODE
+    SnapshotInit(cx, obj, proto);
+    #endif
+//  StrokeInit(cx, obj, proto);
+    TextInit(cx, obj, proto);
+    TextOnPathInit(cx, obj, proto);
+    TextToPathInit(cx, obj, proto);
+    TranslateInit(cx, obj, proto);
+//  UseInit(cx, obj, proto);
 }
 
 void SkJS::DisposeDisplayables() {
-       delete SkJSDisplayable::gPaint;
-       delete SkJSDisplayable::gCanvas;
-       for (int index = 0; index < kTypeNamesSize; index++) {
-               SkDisplayTypes type = gTypeNames[index].fType;
-               delete[] gDisplayableProperties[type];
-       }
+    delete SkJSDisplayable::gPaint;
+    delete SkJSDisplayable::gCanvas;
+    for (int index = 0; index < kTypeNamesSize; index++) {
+        SkDisplayTypes type = gTypeNames[index].fType;
+        delete[] gDisplayableProperties[type];
+    }
 }
index b7d312c..12b0d3c 100644 (file)
+/* libs/graphics/xml/SkParse.cpp
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #include "SkParse.h"
 
 static inline bool is_between(int c, int min, int max)
 {
-       return (unsigned)(c - min) <= (unsigned)(max - min);
+    return (unsigned)(c - min) <= (unsigned)(max - min);
 }
 
 static inline bool is_ws(int c)
 {
-       return is_between(c, 1, 32);
+    return is_between(c, 1, 32);
 }
 
 static inline bool is_digit(int c)
 {
-       return is_between(c, '0', '9');
+    return is_between(c, '0', '9');
 }
 
 static inline bool is_sep(int c)
 {
-       return is_ws(c) || c == ',' || c == ';';
+    return is_ws(c) || c == ',' || c == ';';
 }
 
 static int to_hex(int c)
 {
-       if (is_digit(c))
-               return c - '0';
-
-       c |= 0x20;      // make us lower-case
-       if (is_between(c, 'a', 'f'))
-               return c + 10 - 'a';
-       else
-               return -1;
+    if (is_digit(c))
+        return c - '0';
+
+    c |= 0x20;  // make us lower-case
+    if (is_between(c, 'a', 'f'))
+        return c + 10 - 'a';
+    else
+        return -1;
 }
 
 static inline bool is_hex(int c)
 {
-       return to_hex(c) >= 0;
+    return to_hex(c) >= 0;
 }
 
 static const char* skip_ws(const char str[])
 {
-       SkASSERT(str);
-       while (is_ws(*str))
-               str++;
-       return str;
+    SkASSERT(str);
+    while (is_ws(*str))
+        str++;
+    return str;
 }
 
 static const char* skip_sep(const char str[])
 {
-       SkASSERT(str);
-       while (is_sep(*str))
-               str++;
-       return str;
+    SkASSERT(str);
+    while (is_sep(*str))
+        str++;
+    return str;
 }
 
 int SkParse::Count(const char str[]) 
 {
-       char c;
-       int count = 0;
-       goto skipLeading;
-       do {
-               count++;
-               do {
-                       if ((c = *str++) == '\0')
-                               goto goHome;
-               } while (is_sep(c) == false);
+    char c;
+    int count = 0;
+    goto skipLeading;
+    do {
+        count++;
+        do {
+            if ((c = *str++) == '\0')
+                goto goHome;
+        } while (is_sep(c) == false);
 skipLeading:
-               do {
-                       if ((c = *str++) == '\0')
-                               goto goHome;
-               } while (is_sep(c));
-       } while (true);
+        do {
+            if ((c = *str++) == '\0')
+                goto goHome;
+        } while (is_sep(c));
+    } while (true);
 goHome:
-       return count;
+    return count;
 }
 
 int SkParse::Count(const char str[], char separator) 
 {
-       char c;
-       int count = 0;
-       goto skipLeading;
-       do {
-               count++;
-               do {
-                       if ((c = *str++) == '\0')
-                               goto goHome;
-               } while (c != separator);
+    char c;
+    int count = 0;
+    goto skipLeading;
+    do {
+        count++;
+        do {
+            if ((c = *str++) == '\0')
+                goto goHome;
+        } while (c != separator);
 skipLeading:
-               do {
-                       if ((c = *str++) == '\0')
-                               goto goHome;
-               } while (c == separator);
-       } while (true);
+        do {
+            if ((c = *str++) == '\0')
+                goto goHome;
+        } while (c == separator);
+    } while (true);
 goHome:
-       return count;
+    return count;
 }
 
 const char* SkParse::FindHex(const char str[], uint32_t* value)
 {
-       SkASSERT(str);
-       str = skip_ws(str);
-
-       if (!is_hex(*str))
-               return nil;
-
-       U32     n = 0;
-       int max_digits = 8;
-       int digit;
-
-       while ((digit = to_hex(*str)) >= 0)
-       {
-               if (--max_digits < 0)
-                       return nil;
-               n = (n << 4) | digit;
-               str += 1;
-       }
-
-       if (*str == 0 || is_ws(*str))
-       {
-               if (value)
-                       *value = n;
-               return str;
-       }
-       return false;
+    SkASSERT(str);
+    str = skip_ws(str);
+
+    if (!is_hex(*str))
+        return nil;
+
+    U32 n = 0;
+    int max_digits = 8;
+    int digit;
+
+    while ((digit = to_hex(*str)) >= 0)
+    {
+        if (--max_digits < 0)
+            return nil;
+        n = (n << 4) | digit;
+        str += 1;
+    }
+
+    if (*str == 0 || is_ws(*str))
+    {
+        if (value)
+            *value = n;
+        return str;
+    }
+    return false;
 }
 
 const char* SkParse::FindS32(const char str[], int32_t* value)
 {
-       SkASSERT(str);
-       str = skip_ws(str);
-
-       int sign = 0;
-       if (*str == '-')
-       {
-               sign = -1;
-               str += 1;
-       }
-
-       if (!is_digit(*str))
-               return nil;
-
-       int     n = 0;
-       while (is_digit(*str))
-       {
-               n = 10*n + *str - '0';
-               str += 1;
-       }
-       if (value)
-               *value = (n ^ sign) - sign;
-       return str;
+    SkASSERT(str);
+    str = skip_ws(str);
+
+    int sign = 0;
+    if (*str == '-')
+    {
+        sign = -1;
+        str += 1;
+    }
+
+    if (!is_digit(*str))
+        return nil;
+
+    int n = 0;
+    while (is_digit(*str))
+    {
+        n = 10*n + *str - '0';
+        str += 1;
+    }
+    if (value)
+        *value = (n ^ sign) - sign;
+    return str;
 }
 
 const char* SkParse::FindMSec(const char str[], SkMSec* value)
 {
-       SkASSERT(str);
-       str = skip_ws(str);
-
-       int sign = 0;
-       if (*str == '-')
-       {
-               sign = -1;
-               str += 1;
-       }
-
-       if (!is_digit(*str))
-               return nil;
-
-       int     n = 0;
-       while (is_digit(*str))
-       {
-               n = 10*n + *str - '0';
-               str += 1;
-       }
-       int remaining10s = 3;
-       if (*str == '.') {
-               str++;
-               while (is_digit(*str))
-               {
-                       n = 10*n + *str - '0';
-                       str += 1;
-                       if (--remaining10s == 0)
-                               break;
-               }
-       }
-       while (--remaining10s >= 0)
-               n *= 10;
-       if (value)
-               *value = (n ^ sign) - sign;
-       return str;
+    SkASSERT(str);
+    str = skip_ws(str);
+
+    int sign = 0;
+    if (*str == '-')
+    {
+        sign = -1;
+        str += 1;
+    }
+
+    if (!is_digit(*str))
+        return nil;
+
+    int n = 0;
+    while (is_digit(*str))
+    {
+        n = 10*n + *str - '0';
+        str += 1;
+    }
+    int remaining10s = 3;
+    if (*str == '.') {
+        str++;
+        while (is_digit(*str))
+        {
+            n = 10*n + *str - '0';
+            str += 1;
+            if (--remaining10s == 0)
+                break;
+        }
+    }
+    while (--remaining10s >= 0)
+        n *= 10;
+    if (value)
+        *value = (n ^ sign) - sign;
+    return str;
 }
 
 const char* SkParse::FindScalar(const char str[], SkScalar* value)
 {
-       SkASSERT(str);
-       str = skip_ws(str);
-
-       int sign = 0;
-       if (*str == '-')
-       {
-               sign = -1;
-               str += 1;
-       }
-
-       if (!is_digit(*str) && *str != '.')
-               return nil;
-
-       int     n = 0;
-       while (is_digit(*str))
-       {
-               n = 10*n + *str - '0';
-               if (n > 0x7FFF)
-                       return nil;
-               str += 1;
-       }
-       n <<= 16;
-
-       if (*str == '.')
-       {
-               static const int gFractions[] = { (1 << 24)  / 10, (1 << 24)  / 100, (1 << 24)  / 1000, 
-                       (1 << 24)  / 10000, (1 << 24)  / 100000 };
-               str += 1;
-               int d = 0;
-               const int* fraction = gFractions;
-               const int* end = &fraction[SK_ARRAY_COUNT(gFractions)];
-               while (is_digit(*str) && fraction < end)
-                       d += (*str++ - '0') * *fraction++;
-               d += 0x80; // round
-               n += d >> 8;
-       }
-       while (is_digit(*str))
-               str += 1;
-       if (value)
-       {
-               n = (n ^ sign) - sign;  // apply the sign
-               *value = SkFixedToScalar(n);
-       }
-       return str;
+    SkASSERT(str);
+    str = skip_ws(str);
+
+    int sign = 0;
+    if (*str == '-')
+    {
+        sign = -1;
+        str += 1;
+    }
+
+    if (!is_digit(*str) && *str != '.')
+        return nil;
+
+    int n = 0;
+    while (is_digit(*str))
+    {
+        n = 10*n + *str - '0';
+        if (n > 0x7FFF)
+            return nil;
+        str += 1;
+    }
+    n <<= 16;
+
+    if (*str == '.')
+    {
+        static const int gFractions[] = { (1 << 24)  / 10, (1 << 24)  / 100, (1 << 24)  / 1000, 
+            (1 << 24)  / 10000, (1 << 24)  / 100000 };
+        str += 1;
+        int d = 0;
+        const int* fraction = gFractions;
+        const int* end = &fraction[SK_ARRAY_COUNT(gFractions)];
+        while (is_digit(*str) && fraction < end)
+            d += (*str++ - '0') * *fraction++;
+        d += 0x80; // round
+        n += d >> 8;
+    }
+    while (is_digit(*str))
+        str += 1;
+    if (value)
+    {
+        n = (n ^ sign) - sign;  // apply the sign
+        *value = SkFixedToScalar(n);
+    }
+    return str;
 }
 
 const char* SkParse::FindScalars(const char str[], SkScalar value[], int count)
 {
-       SkASSERT(count >= 0);
-
-       if (count > 0)
-       {
-               for (;;)
-               {
-                       str = SkParse::FindScalar(str, value);
-                       if (--count == 0 || str == nil)
-                               break;
-
-                       // keep going
-                       str = skip_sep(str);
-                       if (value)
-                               value += 1;
-               }
-       }
-       return str;
+    SkASSERT(count >= 0);
+
+    if (count > 0)
+    {
+        for (;;)
+        {
+            str = SkParse::FindScalar(str, value);
+            if (--count == 0 || str == nil)
+                break;
+
+            // keep going
+            str = skip_sep(str);
+            if (value)
+                value += 1;
+        }
+    }
+    return str;
 }
 
 static bool lookup_str(const char str[], const char** table, int count)
 {
-       while (--count >= 0)
-               if (!strcmp(str, table[count]))
-                       return true;
-       return false;
+    while (--count >= 0)
+        if (!strcmp(str, table[count]))
+            return true;
+    return false;
 }
 
 bool SkParse::FindBool(const char str[], bool* value)
 {
-       static const char* gYes[] = { "yes", "1", "true" };
-       static const char* gNo[] = { "no", "0", "false" };
-
-       if (lookup_str(str, gYes, SK_ARRAY_COUNT(gYes)))
-       {
-               if (value) *value = true;
-               return true;
-       }
-       else if (lookup_str(str, gNo, SK_ARRAY_COUNT(gNo)))
-       {
-               if (value) *value = false;
-               return true;
-       }
-       return false;
+    static const char* gYes[] = { "yes", "1", "true" };
+    static const char* gNo[] = { "no", "0", "false" };
+
+    if (lookup_str(str, gYes, SK_ARRAY_COUNT(gYes)))
+    {
+        if (value) *value = true;
+        return true;
+    }
+    else if (lookup_str(str, gNo, SK_ARRAY_COUNT(gNo)))
+    {
+        if (value) *value = false;
+        return true;
+    }
+    return false;
 }
 
 int SkParse::FindList(const char target[], const char list[])
 {
-       size_t  len = strlen(target);
-       int             index = 0;
-
-       for (;;)
-       {
-               const char* end = strchr(list, ',');
-               size_t          entryLen;
-
-               if (end == nil) // last entry
-                       entryLen = strlen(list);
-               else
-                       entryLen = end - list;
-
-               if (entryLen == len && memcmp(target, list, len) == 0)
-                       return index;
-               if (end == nil)
-                       break;
-
-               list = end + 1; // skip the ','
-               index += 1;
-       }
-       return -1;
+    size_t  len = strlen(target);
+    int     index = 0;
+
+    for (;;)
+    {
+        const char* end = strchr(list, ',');
+        size_t      entryLen;
+
+        if (end == nil) // last entry
+            entryLen = strlen(list);
+        else
+            entryLen = end - list;
+
+        if (entryLen == len && memcmp(target, list, len) == 0)
+            return index;
+        if (end == nil)
+            break;
+
+        list = end + 1; // skip the ','
+        index += 1;
+    }
+    return -1;
 }
 
 #ifdef SK_SUPPORT_UNITTEST
 void SkParse::UnitTest() 
 {
-       // !!! additional parse tests go here
-       SkParse::TestColor();
+    // !!! additional parse tests go here
+    SkParse::TestColor();
 }
 #endif
index 75da7f4..4f1a293 100644 (file)
+/* libs/graphics/xml/SkParseColor.cpp
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #include "SkParse.h"
 
 #ifdef SK_DEBUG
 #include "SkString.h"
 
-       // compress names 6 chars per long (packed 5 bits/char )
-               // note: little advantage to splitting chars across longs, since 3 longs at 2 unused bits each 
-               // allow for one additional split char (vs. the 18 unsplit chars in the three longs)
-       // use extra two bits to represent:
-               // 00 : final 6 (or fewer) chars (if 'a' is 0x01, zero could have special meaning)
-               // 01 : not final 6 chars
-               // 10 : color
-               // 11 : unused, except as debugging sentinal? (could be -1 for easier test)
-       // !!! the bit to end the word (last) is at the low bit for binary search
-       // lookup first character in offset for quick start
-               // offset is 27-entry table of bytes(?) that trims linear search to at most 21 entries ('d')
-       // shift match into long; set bit 30 if it all doesn't fit
-       // while longs don't match, march forward
-               // if they do match, and bit 30 is set, advance match, clearing bit 30 if
-               // final chars, and advance to next test
-               // if they do match, and bit 30 is clear, get next long (color) and return it
-       // stop at lookup of first char + 1
+    // compress names 6 chars per long (packed 5 bits/char )
+        // note: little advantage to splitting chars across longs, since 3 longs at 2 unused bits each 
+        // allow for one additional split char (vs. the 18 unsplit chars in the three longs)
+    // use extra two bits to represent:
+        // 00 : final 6 (or fewer) chars (if 'a' is 0x01, zero could have special meaning)
+        // 01 : not final 6 chars
+        // 10 : color
+        // 11 : unused, except as debugging sentinal? (could be -1 for easier test)
+    // !!! the bit to end the word (last) is at the low bit for binary search
+    // lookup first character in offset for quick start
+        // offset is 27-entry table of bytes(?) that trims linear search to at most 21 entries ('d')
+    // shift match into long; set bit 30 if it all doesn't fit
+    // while longs don't match, march forward
+        // if they do match, and bit 30 is set, advance match, clearing bit 30 if
+        // final chars, and advance to next test
+        // if they do match, and bit 30 is clear, get next long (color) and return it
+    // stop at lookup of first char + 1
 static const struct SkNameRGB {
-       const char* name;
-       int rgb;
+    const char* name;
+    int rgb;
 } colorNames[] = {
-       { "aliceblue",            0xF0F8FF },
-       { "antiquewhite",         0xFAEBD7 },
-       { "aqua",                 0x00FFFF },
-       { "aquamarine",           0x7FFFD4 },
-       { "azure",                0xF0FFFF },
-       { "beige",                0xF5F5DC },
-       { "bisque",               0xFFE4C4 },
-       { "black",                0x000000 },
-       { "blanchedalmond",       0xFFEBCD },
-       { "blue",                 0x0000FF },
-       { "blueviolet",           0x8A2BE2 },
-       { "brown",                0xA52A2A },
-       { "burlywood",            0xDEB887 },
-       { "cadetblue",            0x5F9EA0 },
-       { "chartreuse",           0x7FFF00 },
-       { "chocolate",            0xD2691E },
-       { "coral",                0xFF7F50 },
-       { "cornflowerblue",       0x6495ED },
-       { "cornsilk",             0xFFF8DC },
-       { "crimson",              0xDC143C },
-       { "cyan",                 0x00FFFF },
-       { "darkblue",             0x00008B },
-       { "darkcyan",             0x008B8B },
-       { "darkgoldenrod",        0xB8860B },
-       { "darkgray",             0xA9A9A9 },
-       { "darkgreen",            0x006400 },
-       { "darkkhaki",            0xBDB76B },
-       { "darkmagenta",          0x8B008B },
-       { "darkolivegreen",       0x556B2F },
-       { "darkorange",           0xFF8C00 },
-       { "darkorchid",           0x9932CC },
-       { "darkred",              0x8B0000 },
-       { "darksalmon",           0xE9967A },
-       { "darkseagreen",         0x8FBC8F },
-       { "darkslateblue",        0x483D8B },
-       { "darkslategray",        0x2F4F4F },
-       { "darkturquoise",        0x00CED1 },
-       { "darkviolet",           0x9400D3 },
-       { "deeppink",             0xFF1493 },
-       { "deepskyblue",          0x00BFFF },
-       { "dimgray",              0x696969 },
-       { "dodgerblue",           0x1E90FF },
-       { "firebrick",            0xB22222 },
-       { "floralwhite",          0xFFFAF0 },
-       { "forestgreen",          0x228B22 },
-       { "fuchsia",              0xFF00FF },
-       { "gainsboro",            0xDCDCDC },
-       { "ghostwhite",           0xF8F8FF },
-       { "gold",                 0xFFD700 },
-       { "goldenrod",            0xDAA520 },
-       { "gray",                 0x808080 },
-       { "green",                0x008000 },
-       { "greenyellow",          0xADFF2F },
-       { "honeydew",             0xF0FFF0 },
-       { "hotpink",              0xFF69B4 },
-       { "indianred",            0xCD5C5C },
-       { "indigo",               0x4B0082 },
-       { "ivory",                0xFFFFF0 },
-       { "khaki",                0xF0E68C },
-       { "lavender",             0xE6E6FA },
-       { "lavenderblush",        0xFFF0F5 },
-       { "lawngreen",            0x7CFC00 },
-       { "lemonchiffon",         0xFFFACD },
-       { "lightblue",            0xADD8E6 },
-       { "lightcoral",           0xF08080 },
-       { "lightcyan",            0xE0FFFF },
-       { "lightgoldenrodyellow", 0xFAFAD2 },
-       { "lightgreen",           0x90EE90 },
-       { "lightgrey",            0xD3D3D3 },
-       { "lightpink",            0xFFB6C1 },
-       { "lightsalmon",          0xFFA07A },
-       { "lightseagreen",        0x20B2AA },
-       { "lightskyblue",         0x87CEFA },
-       { "lightslategray",       0x778899 },
-       { "lightsteelblue",       0xB0C4DE },
-       { "lightyellow",          0xFFFFE0 },
-       { "lime",                 0x00FF00 },
-       { "limegreen",            0x32CD32 },
-       { "linen",                0xFAF0E6 },
-       { "magenta",              0xFF00FF },
-       { "maroon",               0x800000 },
-       { "mediumaquamarine",     0x66CDAA },
-       { "mediumblue",           0x0000CD },
-       { "mediumorchid",         0xBA55D3 },
-       { "mediumpurple",         0x9370DB },
-       { "mediumseagreen",       0x3CB371 },
-       { "mediumslateblue",      0x7B68EE },
-       { "mediumspringgreen",    0x00FA9A },
-       { "mediumturquoise",      0x48D1CC },
-       { "mediumvioletred",      0xC71585 },
-       { "midnightblue",         0x191970 },
-       { "mintcream",            0xF5FFFA },
-       { "mistyrose",            0xFFE4E1 },
-       { "moccasin",             0xFFE4B5 },
-       { "navajowhite",          0xFFDEAD },
-       { "navy",                 0x000080 },
-       { "oldlace",              0xFDF5E6 },
-       { "olive",                0x808000 },
-       { "olivedrab",            0x6B8E23 },
-       { "orange",               0xFFA500 },
-       { "orangered",            0xFF4500 },
-       { "orchid",               0xDA70D6 },
-       { "palegoldenrod",        0xEEE8AA },
-       { "palegreen",            0x98FB98 },
-       { "paleturquoise",        0xAFEEEE },
-       { "palevioletred",        0xDB7093 },
-       { "papayawhip",           0xFFEFD5 },
-       { "peachpuff",            0xFFDAB9 },
-       { "peru",                 0xCD853F },
-       { "pink",                 0xFFC0CB },
-       { "plum",                 0xDDA0DD },
-       { "powderblue",           0xB0E0E6 },
-       { "purple",               0x800080 },
-       { "red",                  0xFF0000 },
-       { "rosybrown",            0xBC8F8F },
-       { "royalblue",            0x4169E1 },
-       { "saddlebrown",          0x8B4513 },
-       { "salmon",               0xFA8072 },
-       { "sandybrown",           0xF4A460 },
-       { "seagreen",             0x2E8B57 },
-       { "seashell",             0xFFF5EE },
-       { "sienna",               0xA0522D },
-       { "silver",               0xC0C0C0 },
-       { "skyblue",              0x87CEEB },
-       { "slateblue",            0x6A5ACD },
-       { "slategray",            0x708090 },
-       { "snow",                 0xFFFAFA },
-       { "springgreen",          0x00FF7F },
-       { "steelblue",            0x4682B4 },
-       { "tan",                  0xD2B48C },
-       { "teal",                 0x008080 },
-       { "thistle",              0xD8BFD8 },
-       { "tomato",               0xFF6347 },
-       { "turquoise",            0x40E0D0 },
-       { "violet",               0xEE82EE },
-       { "wheat",                0xF5DEB3 },
-       { "white",                0xFFFFFF },
-       { "whitesmoke",           0xF5F5F5 },
-       { "yellow",               0xFFFF00 },
-       { "yellowgreen",          0x9ACD32 }
+    { "aliceblue",            0xF0F8FF },
+    { "antiquewhite",         0xFAEBD7 },
+    { "aqua",                 0x00FFFF },
+    { "aquamarine",           0x7FFFD4 },
+    { "azure",                0xF0FFFF },
+    { "beige",                0xF5F5DC },
+    { "bisque",               0xFFE4C4 },
+    { "black",                0x000000 },
+    { "blanchedalmond",       0xFFEBCD },
+    { "blue",                 0x0000FF },
+    { "blueviolet",           0x8A2BE2 },
+    { "brown",                0xA52A2A },
+    { "burlywood",            0xDEB887 },
+    { "cadetblue",            0x5F9EA0 },
+    { "chartreuse",           0x7FFF00 },
+    { "chocolate",            0xD2691E },
+    { "coral",                0xFF7F50 },
+    { "cornflowerblue",       0x6495ED },
+    { "cornsilk",             0xFFF8DC },
+    { "crimson",              0xDC143C },
+    { "cyan",                 0x00FFFF },
+    { "darkblue",             0x00008B },
+    { "darkcyan",             0x008B8B },
+    { "darkgoldenrod",        0xB8860B },
+    { "darkgray",             0xA9A9A9 },
+    { "darkgreen",            0x006400 },
+    { "darkkhaki",            0xBDB76B },
+    { "darkmagenta",          0x8B008B },
+    { "darkolivegreen",       0x556B2F },
+    { "darkorange",           0xFF8C00 },
+    { "darkorchid",           0x9932CC },
+    { "darkred",              0x8B0000 },
+    { "darksalmon",           0xE9967A },
+    { "darkseagreen",         0x8FBC8F },
+    { "darkslateblue",        0x483D8B },
+    { "darkslategray",        0x2F4F4F },
+    { "darkturquoise",        0x00CED1 },
+    { "darkviolet",           0x9400D3 },
+    { "deeppink",             0xFF1493 },
+    { "deepskyblue",          0x00BFFF },
+    { "dimgray",              0x696969 },
+    { "dodgerblue",           0x1E90FF },
+    { "firebrick",            0xB22222 },
+    { "floralwhite",          0xFFFAF0 },
+    { "forestgreen",          0x228B22 },
+    { "fuchsia",              0xFF00FF },
+    { "gainsboro",            0xDCDCDC },
+    { "ghostwhite",           0xF8F8FF },
+    { "gold",                 0xFFD700 },
+    { "goldenrod",            0xDAA520 },
+    { "gray",                 0x808080 },
+    { "green",                0x008000 },
+    { "greenyellow",          0xADFF2F },
+    { "honeydew",             0xF0FFF0 },
+    { "hotpink",              0xFF69B4 },
+    { "indianred",            0xCD5C5C },
+    { "indigo",               0x4B0082 },
+    { "ivory",                0xFFFFF0 },
+    { "khaki",                0xF0E68C },
+    { "lavender",             0xE6E6FA },
+    { "lavenderblush",        0xFFF0F5 },
+    { "lawngreen",            0x7CFC00 },
+    { "lemonchiffon",         0xFFFACD },
+    { "lightblue",            0xADD8E6 },
+    { "lightcoral",           0xF08080 },
+    { "lightcyan",            0xE0FFFF },
+    { "lightgoldenrodyellow", 0xFAFAD2 },
+    { "lightgreen",           0x90EE90 },
+    { "lightgrey",            0xD3D3D3 },
+    { "lightpink",            0xFFB6C1 },
+    { "lightsalmon",          0xFFA07A },
+    { "lightseagreen",        0x20B2AA },
+    { "lightskyblue",         0x87CEFA },
+    { "lightslategray",       0x778899 },
+    { "lightsteelblue",       0xB0C4DE },
+    { "lightyellow",          0xFFFFE0 },
+    { "lime",                 0x00FF00 },
+    { "limegreen",            0x32CD32 },
+    { "linen",                0xFAF0E6 },
+    { "magenta",              0xFF00FF },
+    { "maroon",               0x800000 },
+    { "mediumaquamarine",     0x66CDAA },
+    { "mediumblue",           0x0000CD },
+    { "mediumorchid",         0xBA55D3 },
+    { "mediumpurple",         0x9370DB },
+    { "mediumseagreen",       0x3CB371 },
+    { "mediumslateblue",      0x7B68EE },
+    { "mediumspringgreen",    0x00FA9A },
+    { "mediumturquoise",      0x48D1CC },
+    { "mediumvioletred",      0xC71585 },
+    { "midnightblue",         0x191970 },
+    { "mintcream",            0xF5FFFA },
+    { "mistyrose",            0xFFE4E1 },
+    { "moccasin",             0xFFE4B5 },
+    { "navajowhite",          0xFFDEAD },
+    { "navy",                 0x000080 },
+    { "oldlace",              0xFDF5E6 },
+    { "olive",                0x808000 },
+    { "olivedrab",            0x6B8E23 },
+    { "orange",               0xFFA500 },
+    { "orangered",            0xFF4500 },
+    { "orchid",               0xDA70D6 },
+    { "palegoldenrod",        0xEEE8AA },
+    { "palegreen",            0x98FB98 },
+    { "paleturquoise",        0xAFEEEE },
+    { "palevioletred",        0xDB7093 },
+    { "papayawhip",           0xFFEFD5 },
+    { "peachpuff",            0xFFDAB9 },
+    { "peru",                 0xCD853F },
+    { "pink",                 0xFFC0CB },
+    { "plum",                 0xDDA0DD },
+    { "powderblue",           0xB0E0E6 },
+    { "purple",               0x800080 },
+    { "red",                  0xFF0000 },
+    { "rosybrown",            0xBC8F8F },
+    { "royalblue",            0x4169E1 },
+    { "saddlebrown",          0x8B4513 },
+    { "salmon",               0xFA8072 },
+    { "sandybrown",           0xF4A460 },
+    { "seagreen",             0x2E8B57 },
+    { "seashell",             0xFFF5EE },
+    { "sienna",               0xA0522D },
+    { "silver",               0xC0C0C0 },
+    { "skyblue",              0x87CEEB },
+    { "slateblue",            0x6A5ACD },
+    { "slategray",            0x708090 },
+    { "snow",                 0xFFFAFA },
+    { "springgreen",          0x00FF7F },
+    { "steelblue",            0x4682B4 },
+    { "tan",                  0xD2B48C },
+    { "teal",                 0x008080 },
+    { "thistle",              0xD8BFD8 },
+    { "tomato",               0xFF6347 },
+    { "turquoise",            0x40E0D0 },
+    { "violet",               0xEE82EE },
+    { "wheat",                0xF5DEB3 },
+    { "white",                0xFFFFFF },
+    { "whitesmoke",           0xF5F5F5 },
+    { "yellow",               0xFFFF00 },
+    { "yellowgreen",          0x9ACD32 }
 };
 
 int colorNamesSize = sizeof(colorNames) / sizeof(colorNames[0]);
 
 static void CreateTable() {
-       SkString comment;
-       size_t originalSize = 0;
-       int replacement = 0;
-       for (int index = 0; index < colorNamesSize; index++) {
-               SkNameRGB nameRGB =  colorNames[index];
-               const char* name = nameRGB.name;
-               size_t len = strlen(name);
-               originalSize += len + 9;
-               bool first = true;
-               bool last = false;
-               do {
-                       int compressed = 0;
-                       const char* start = name;
-                       for (int chIndex = 0; chIndex < 6; chIndex++) {
-                               compressed <<= 5;
-                               compressed |= *name ? *name++ - 'a' + 1 : 0 ;
-                       }
-                       replacement += sizeof(int);
-                       compressed <<= 1;
-                       compressed |= 1;
-                       if (first) {
-                               compressed |= 0x80000000;
-                               first = false;
-                       }
-                       if (len <= 6) { // last
-                               compressed &= ~1;
-                               last = true;
-                       }
-                       len -= 6;
-                       SkDebugf("0x%08x, ", compressed);
-                       comment.append(start, name - start);
-               } while (last == false);
-               replacement += sizeof(int);
-               SkDebugf("0x%08x, ", nameRGB.rgb);
-               SkDebugf("// %s\n", comment.c_str());
-               comment.reset();
-       }
-       SkDebugf("// original = %d : replacement = %d\n", originalSize, replacement);
-       SkASSERT(0); // always stop after creating table
+    SkString comment;
+    size_t originalSize = 0;
+    int replacement = 0;
+    for (int index = 0; index < colorNamesSize; index++) {
+        SkNameRGB nameRGB =  colorNames[index];
+        const char* name = nameRGB.name;
+        size_t len = strlen(name);
+        originalSize += len + 9;
+        bool first = true;
+        bool last = false;
+        do {
+            int compressed = 0;
+            const char* start = name;
+            for (int chIndex = 0; chIndex < 6; chIndex++) {
+                compressed <<= 5;
+                compressed |= *name ? *name++ - 'a' + 1 : 0 ;
+            }
+            replacement += sizeof(int);
+            compressed <<= 1;
+            compressed |= 1;
+            if (first) {
+                compressed |= 0x80000000;
+                first = false;
+            }
+            if (len <= 6) { // last
+                compressed &= ~1;
+                last = true;
+            }
+            len -= 6;
+            SkDebugf("0x%08x, ", compressed);
+            comment.append(start, name - start);
+        } while (last == false);
+        replacement += sizeof(int);
+        SkDebugf("0x%08x, ", nameRGB.rgb);
+        SkDebugf("// %s\n", comment.c_str());
+        comment.reset();
+    }
+    SkDebugf("// original = %d : replacement = %d\n", originalSize, replacement);
+    SkASSERT(0); // always stop after creating table
 }
 
 #endif
@@ -357,173 +374,173 @@ static const unsigned int gColorNames[] = {
 
 
 const char* SkParse::FindNamedColor(const char* name, size_t len, SkColor* color) {
-       const char* namePtr = name;
-       unsigned int sixMatches[4];
-       unsigned int* sixMatchPtr = sixMatches;
-       bool first = true;
-       bool last = false;
-       char ch;
-       do {
-               unsigned int sixMatch = 0;
-               for (int chIndex = 0; chIndex < 6; chIndex++) {
-                       sixMatch <<= 5;
-                       ch = *namePtr  | 0x20;
-                       if (ch < 'a' || ch > 'z')
-                               ch = 0;
-                       else {
-                               ch = ch - 'a' + 1;
-                               namePtr++;
-                       }
-                       sixMatch |= ch ;  // turn 'A' (0x41) into 'a' (0x61);
-               }
-               sixMatch <<= 1;
-               sixMatch |= 1;
-               if (first) {
-                       sixMatch |= 0x80000000;
-                       first = false;
-               }
-               ch = *namePtr | 0x20;
-               last = ch < 'a' || ch > 'z';
-               if (last) 
-                       sixMatch &= ~1;
-               len -= 6;
-               *sixMatchPtr++ = sixMatch;
-       } while (last == false && len > 0);
-       const int colorNameSize = sizeof(gColorNames) / sizeof(unsigned int);
-       int lo = 0;
-       int hi = colorNameSize - 3;     // back off to beginning of yellowgreen
-       while (lo <= hi) {
-               int mid = (hi + lo) >> 1;
-               while ((int) gColorNames[mid] >= 0)
-                       --mid;
-               sixMatchPtr = sixMatches;
-               while (gColorNames[mid] == *sixMatchPtr) {
-                       ++mid;
-                       if ((*sixMatchPtr & 1) == 0) { // last
-                               *color = gColorNames[mid] | 0xFF000000;
-                               return namePtr;
-                       }
-                       ++sixMatchPtr;
-               }
-               int sixMask = *sixMatchPtr & ~0x80000000;
-               int midMask = gColorNames[mid] & ~0x80000000;
-               if (sixMask > midMask) {
-                       lo = mid + 2;   // skip color
-                       while ((int) gColorNames[lo] >= 0)
-                               ++lo;
-               } else if (hi == mid)
-                       return nil;
-               else
-                       hi = mid;
-       }
-       return nil;
+    const char* namePtr = name;
+    unsigned int sixMatches[4];
+    unsigned int* sixMatchPtr = sixMatches;
+    bool first = true;
+    bool last = false;
+    char ch;
+    do {
+        unsigned int sixMatch = 0;
+        for (int chIndex = 0; chIndex < 6; chIndex++) {
+            sixMatch <<= 5;
+            ch = *namePtr  | 0x20;
+            if (ch < 'a' || ch > 'z')
+                ch = 0;
+            else {
+                ch = ch - 'a' + 1;
+                namePtr++;
+            }
+            sixMatch |= ch ;  // turn 'A' (0x41) into 'a' (0x61);
+        }
+        sixMatch <<= 1;
+        sixMatch |= 1;
+        if (first) {
+            sixMatch |= 0x80000000;
+            first = false;
+        }
+        ch = *namePtr | 0x20;
+        last = ch < 'a' || ch > 'z';
+        if (last) 
+            sixMatch &= ~1;
+        len -= 6;
+        *sixMatchPtr++ = sixMatch;
+    } while (last == false && len > 0);
+    const int colorNameSize = sizeof(gColorNames) / sizeof(unsigned int);
+    int lo = 0;
+    int hi = colorNameSize - 3; // back off to beginning of yellowgreen
+    while (lo <= hi) {
+        int mid = (hi + lo) >> 1;
+        while ((int) gColorNames[mid] >= 0)
+            --mid;
+        sixMatchPtr = sixMatches;
+        while (gColorNames[mid] == *sixMatchPtr) {
+            ++mid;
+            if ((*sixMatchPtr & 1) == 0) { // last
+                *color = gColorNames[mid] | 0xFF000000;
+                return namePtr;
+            }
+            ++sixMatchPtr;
+        }
+        int sixMask = *sixMatchPtr & ~0x80000000;
+        int midMask = gColorNames[mid] & ~0x80000000;
+        if (sixMask > midMask) {
+            lo = mid + 2;   // skip color
+            while ((int) gColorNames[lo] >= 0)
+                ++lo;
+        } else if (hi == mid)
+            return nil;
+        else
+            hi = mid;
+    }
+    return nil;
 }
 
 // !!! move to char utilities
 //static int count_separators(const char* str, const char* sep) {
-//     char c;
-//     int separators = 0;
-//     while ((c = *str++) != '\0') {
-//             if (strchr(sep, c) == nil)
-//                     continue;
-//             do {
-//                     if ((c = *str++) == '\0')
-//                             goto goHome;
-//             } while (strchr(sep, c) != nil);
-//             separators++;
-//     }
+//  char c;
+//  int separators = 0;
+//  while ((c = *str++) != '\0') {
+//      if (strchr(sep, c) == nil)
+//          continue;
+//      do {
+//          if ((c = *str++) == '\0')
+//              goto goHome;
+//      } while (strchr(sep, c) != nil);
+//      separators++;
+//  }
 //goHome:
-//     return separators;
+//  return separators;
 //}
 
 static inline unsigned nib2byte(unsigned n)
 {
-       SkASSERT((n & ~0xF) == 0);
-       return (n << 4) | n;
+    SkASSERT((n & ~0xF) == 0);
+    return (n << 4) | n;
 }
 
 const char* SkParse::FindColor(const char* value, SkColor* colorPtr) {
-       unsigned int oldAlpha = SkColorGetA(*colorPtr);
-       if (value[0] == '#') {
-               uint32_t        hex;
-               const char* end = SkParse::FindHex(value + 1, &hex);
-//             SkASSERT(end);
-               if (end == nil)
-                       return end;
-               size_t len = end - value - 1;
-               if (len == 3 || len == 4) {
-                       unsigned a = len == 4 ? nib2byte(hex >> 12) : oldAlpha;
-                       unsigned r = nib2byte((hex >> 8) & 0xF);
-                       unsigned g = nib2byte((hex >> 4) & 0xF);
-                       unsigned b = nib2byte(hex & 0xF);
-                       *colorPtr = SkColorSetARGB(a, r, g, b);
-                       return end;
-               } else if (len == 6 || len == 8) {
-                       if (len == 6)
-                               hex |= oldAlpha << 24;
-                       *colorPtr = hex;
-                       return end;
-               } else {
-//                     SkASSERT(0);
-                       return nil;
-               }
-//     } else if (strchr(value, ',')) {
-//             SkScalar array[4];
-//             int count = count_separators(value, ",") + 1; // !!! count commas, add 1
-//             SkASSERT(count == 3 || count == 4);
-//             array[0] = SK_Scalar1 * 255;
-//             const char* end = SkParse::FindScalars(value, &array[4 - count], count);
-//             if (end == nil)
-//                     return nil;
-               // !!! range check for errors?
-//             *colorPtr = SkColorSetARGB(SkScalarRound(array[0]), SkScalarRound(array[1]), 
-//                     SkScalarRound(array[2]), SkScalarRound(array[3]));
-//             return end;
-       } else
-               return FindNamedColor(value, strlen(value), colorPtr);
+    unsigned int oldAlpha = SkColorGetA(*colorPtr);
+    if (value[0] == '#') {
+        uint32_t    hex;
+        const char* end = SkParse::FindHex(value + 1, &hex);
+//      SkASSERT(end);
+        if (end == nil)
+            return end;
+        size_t len = end - value - 1;
+        if (len == 3 || len == 4) {
+            unsigned a = len == 4 ? nib2byte(hex >> 12) : oldAlpha;
+            unsigned r = nib2byte((hex >> 8) & 0xF);
+            unsigned g = nib2byte((hex >> 4) & 0xF);
+            unsigned b = nib2byte(hex & 0xF);
+            *colorPtr = SkColorSetARGB(a, r, g, b);
+            return end;
+        } else if (len == 6 || len == 8) {
+            if (len == 6)
+                hex |= oldAlpha << 24;
+            *colorPtr = hex;
+            return end;
+        } else {
+//          SkASSERT(0);
+            return nil;
+        }
+//  } else if (strchr(value, ',')) {
+//      SkScalar array[4];
+//      int count = count_separators(value, ",") + 1; // !!! count commas, add 1
+//      SkASSERT(count == 3 || count == 4);
+//      array[0] = SK_Scalar1 * 255;
+//      const char* end = SkParse::FindScalars(value, &array[4 - count], count);
+//      if (end == nil)
+//          return nil;
+        // !!! range check for errors?
+//      *colorPtr = SkColorSetARGB(SkScalarRound(array[0]), SkScalarRound(array[1]), 
+//          SkScalarRound(array[2]), SkScalarRound(array[3]));
+//      return end;
+    } else
+        return FindNamedColor(value, strlen(value), colorPtr);
 }
 
 #ifdef SK_DEBUG
 void SkParse::TestColor() {
-       if (false)
-               CreateTable();  // regenerates data table in the output window
-       SkColor result;
-       int index;
-       for (index = 0; index < colorNamesSize; index++) {
-               result = SK_ColorBLACK;
-               SkNameRGB nameRGB = colorNames[index];
-               SkASSERT(FindColor(nameRGB.name, &result) != nil);
-               SkASSERT(result == (SkColor) (nameRGB.rgb | 0xFF000000));
-       }
-       for (index = 0; index < colorNamesSize; index++) {
-               result = SK_ColorBLACK;
-               SkNameRGB nameRGB = colorNames[index];
-               char bad[24];
-               size_t len = strlen(nameRGB.name);
-               memcpy(bad, nameRGB.name, len);
-               bad[len - 1] -= 1; 
-               SkASSERT(FindColor(bad, &result) == false);
-               bad[len - 1] += 2; 
-               SkASSERT(FindColor(bad, &result) == false);
-       }
-       result = SK_ColorBLACK;
-       SkASSERT(FindColor("lightGrey", &result));
-       SkASSERT(result == 0xffd3d3d3);
-//     SkASSERT(FindColor("12,34,56,78", &result));
-//     SkASSERT(result == ((12 << 24) | (34 << 16) | (56 << 8) | (78 << 0)));
-       result = SK_ColorBLACK;
-       SkASSERT(FindColor("#ABCdef", &result));
-       SkASSERT(result == 0XFFABCdef);
-       SkASSERT(FindColor("#12ABCdef", &result));
-       SkASSERT(result == 0X12ABCdef);
-       result = SK_ColorBLACK;
-       SkASSERT(FindColor("#123", &result));
-       SkASSERT(result == 0Xff112233);
-       SkASSERT(FindColor("#abcd", &result));
-       SkASSERT(result == 0Xaabbccdd);
-       result = SK_ColorBLACK;
-//     SkASSERT(FindColor("71,162,253", &result));
-//     SkASSERT(result == ((0xFF << 24) | (71 << 16) | (162 << 8) | (253 << 0)));
+    if (false)
+        CreateTable();  // regenerates data table in the output window
+    SkColor result;
+    int index;
+    for (index = 0; index < colorNamesSize; index++) {
+        result = SK_ColorBLACK;
+        SkNameRGB nameRGB = colorNames[index];
+        SkASSERT(FindColor(nameRGB.name, &result) != nil);
+        SkASSERT(result == (SkColor) (nameRGB.rgb | 0xFF000000));
+    }
+    for (index = 0; index < colorNamesSize; index++) {
+        result = SK_ColorBLACK;
+        SkNameRGB nameRGB = colorNames[index];
+        char bad[24];
+        size_t len = strlen(nameRGB.name);
+        memcpy(bad, nameRGB.name, len);
+        bad[len - 1] -= 1; 
+        SkASSERT(FindColor(bad, &result) == false);
+        bad[len - 1] += 2; 
+        SkASSERT(FindColor(bad, &result) == false);
+    }
+    result = SK_ColorBLACK;
+    SkASSERT(FindColor("lightGrey", &result));
+    SkASSERT(result == 0xffd3d3d3);
+//  SkASSERT(FindColor("12,34,56,78", &result));
+//  SkASSERT(result == ((12 << 24) | (34 << 16) | (56 << 8) | (78 << 0)));
+    result = SK_ColorBLACK;
+    SkASSERT(FindColor("#ABCdef", &result));
+    SkASSERT(result == 0XFFABCdef);
+    SkASSERT(FindColor("#12ABCdef", &result));
+    SkASSERT(result == 0X12ABCdef);
+    result = SK_ColorBLACK;
+    SkASSERT(FindColor("#123", &result));
+    SkASSERT(result == 0Xff112233);
+    SkASSERT(FindColor("#abcd", &result));
+    SkASSERT(result == 0Xaabbccdd);
+    result = SK_ColorBLACK;
+//  SkASSERT(FindColor("71,162,253", &result));
+//  SkASSERT(result == ((0xFF << 24) | (71 << 16) | (162 << 8) | (253 << 0)));
 }
 #endif
 
index fa050b0..0259ac7 100644 (file)
@@ -1,42 +1,59 @@
+/* libs/graphics/xml/SkXMLParser.cpp
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #include "SkXMLParser.h"
 
 static char const* const gErrorStrings[] = {
-       "empty or missing file ",
-       "unknown element ",
-       "unknown attribute name ",
-       "error in attribute value ",
-       "duplicate ID ",
-       "unknown error "
+    "empty or missing file ",
+    "unknown element ",
+    "unknown attribute name ",
+    "error in attribute value ",
+    "duplicate ID ",
+    "unknown error "
 };
 
 SkXMLParserError::SkXMLParserError() : fCode(kNoError), fLineNumber(-1),
-       fNativeCode(-1)
+    fNativeCode(-1)
 {
-       reset();
+    reset();
 }
 
 SkXMLParserError::~SkXMLParserError()
 {
-       // need a virtual destructor for our subclasses
+    // need a virtual destructor for our subclasses
 }
 
 void SkXMLParserError::getErrorString(SkString* str) const
 {
-       SkASSERT(str);
-       SkString temp;
-       if (fCode != kNoError) {
-               if ((unsigned)fCode < SK_ARRAY_COUNT(gErrorStrings))
-                       temp.set(gErrorStrings[fCode - 1]);
-               temp.append(fNoun);
-       } else
-               SkXMLParser::GetNativeErrorString(fNativeCode, &temp);
-       str->append(temp);
+    SkASSERT(str);
+    SkString temp;
+    if (fCode != kNoError) {
+        if ((unsigned)fCode < SK_ARRAY_COUNT(gErrorStrings))
+            temp.set(gErrorStrings[fCode - 1]);
+        temp.append(fNoun);
+    } else
+        SkXMLParser::GetNativeErrorString(fNativeCode, &temp);
+    str->append(temp);
 }
 
 void SkXMLParserError::reset() {
-       fCode = kNoError;
-       fLineNumber = -1;
-       fNativeCode = -1;
+    fCode = kNoError;
+    fLineNumber = -1;
+    fNativeCode = -1;
 }
 
 
@@ -52,22 +69,22 @@ SkXMLParser::~SkXMLParser()
 
 bool SkXMLParser::startElement(const char elem[])
 {
-       return this->onStartElement(elem);
+    return this->onStartElement(elem);
 }
 
 bool SkXMLParser::addAttribute(const char name[], const char value[])
 {
-       return this->onAddAttribute(name, value);
+    return this->onAddAttribute(name, value);
 }
 
 bool SkXMLParser::endElement(const char elem[])
 {
-       return this->onEndElement(elem);
+    return this->onEndElement(elem);
 }
 
 bool SkXMLParser::text(const char text[], int len) 
 {
-       return this->onText(text, len);
+    return this->onText(text, len);
 }
 
 ////////////////////////////////////////////////////////////////////////////////
index b0430d6..c66f9f9 100644 (file)
@@ -1,3 +1,20 @@
+/* libs/graphics/xml/SkXMLWriter.cpp
+**
+** Copyright 2006, Google Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+
 #include "SkXMLWriter.h"
 #include "SkStream.h"
 
@@ -7,177 +24,177 @@ SkXMLWriter::SkXMLWriter(bool doEscapeMarkup) : fDoEscapeMarkup(doEscapeMarkup)
 
 SkXMLWriter::~SkXMLWriter()
 {
-       SkASSERT(fElems.count() == 0);
+    SkASSERT(fElems.count() == 0);
 }
 
 void SkXMLWriter::flush()
 {
-       while (fElems.count())
-               this->endElement();
+    while (fElems.count())
+        this->endElement();
 }
 
 void SkXMLWriter::addAttribute(const char name[], const char value[])
 {
-       this->addAttributeLen(name, value, strlen(value));
+    this->addAttributeLen(name, value, strlen(value));
 }
 
 void SkXMLWriter::addS32Attribute(const char name[], S32 value)
 {
-       SkString        tmp;
-       tmp.appendS32(value);
-       this->addAttribute(name, tmp.c_str());
+    SkString    tmp;
+    tmp.appendS32(value);
+    this->addAttribute(name, tmp.c_str());
 }
 
 void SkXMLWriter::addHexAttribute(const char name[], U32 value, int minDigits)
 {
-       SkString        tmp("0x");
-       tmp.appendHex(value, minDigits);
-       this->addAttribute(name, tmp.c_str());
+    SkString    tmp("0x");
+    tmp.appendHex(value, minDigits);
+    this->addAttribute(name, tmp.c_str());
 }
 
 void SkXMLWriter::addScalarAttribute(const char name[], SkScalar value)
 {
-       SkString        tmp;
-       tmp.appendScalar(value);
-       this->addAttribute(name, tmp.c_str());
+    SkString    tmp;
+    tmp.appendScalar(value);
+    this->addAttribute(name, tmp.c_str());
 }
 
 void SkXMLWriter::doEnd(Elem* elem)
 {
-       delete elem;
+    delete elem;
 }
 
 bool SkXMLWriter::doStart(const char name[], size_t length)
 {
-       int     level = fElems.count();
-       bool firstChild = level > 0 && !fElems[level-1]->fHasChildren;
-       if (firstChild)
-               fElems[level-1]->fHasChildren = true;
-       Elem** elem = fElems.push();
-       *elem = new Elem;
-       (*elem)->fName.set(name, length);
-       (*elem)->fHasChildren = 0;
-       return firstChild;
+    int level = fElems.count();
+    bool firstChild = level > 0 && !fElems[level-1]->fHasChildren;
+    if (firstChild)
+        fElems[level-1]->fHasChildren = true;
+    Elem** elem = fElems.push();
+    *elem = new Elem;
+    (*elem)->fName.set(name, length);
+    (*elem)->fHasChildren = 0;
+    return firstChild;
 }
 
 SkXMLWriter::Elem* SkXMLWriter::getEnd() 
 {
-       Elem* elem;
-       fElems.pop(&elem);
-       return elem;
+    Elem* elem;
+    fElems.pop(&elem);
+    return elem;
 }
 
 const char* SkXMLWriter::getHeader()
 {
-       static const char gHeader[] = "<?xml version=\"1.0\" encoding=\"utf-8\" ?>";
-       return gHeader;
+    static const char gHeader[] = "<?xml version=\"1.0\" encoding=\"utf-8\" ?>";
+    return gHeader;
 }
 
 void SkXMLWriter::startElement(const char name[])
 {
-       this->startElementLen(name, strlen(name));
+    this->startElementLen(name, strlen(name));
 }
 
 static const char* escape_char(char c, char storage[2])
 {
-       static const char* gEscapeChars[] = {
-               "<&lt;",
-               ">&gt;",
-               //"\"&quot;",
-               //"'&apos;",
-               "&&amp;"
-       };
-
-       const char** array = gEscapeChars;
-       for (unsigned i = 0; i < SK_ARRAY_COUNT(gEscapeChars); i++)
-       {
-               if (array[i][0] == c)
-                       return &array[i][1];
-       }
-       storage[0] = c;
-       storage[1] = 0;
-       return storage;
+    static const char* gEscapeChars[] = {
+        "<&lt;",
+        ">&gt;",
+        //"\"&quot;",
+        //"'&apos;",
+        "&&amp;"
+    };
+
+    const char** array = gEscapeChars;
+    for (unsigned i = 0; i < SK_ARRAY_COUNT(gEscapeChars); i++)
+    {
+        if (array[i][0] == c)
+            return &array[i][1];
+    }
+    storage[0] = c;
+    storage[1] = 0;
+    return storage;
 }
 
 static size_t escape_markup(char dst[], const char src[], size_t length)
 {
-       size_t          extra = 0;
-       const char*     stop = src + length;
+    size_t      extra = 0;
+    const char* stop = src + length;
 
-       while (src < stop)
-       {
-               char            orig[2];
-               const char* seq = escape_char(*src, orig);
-               size_t          seqSize = strlen(seq);
+    while (src < stop)
+    {
+        char        orig[2];
+        const char* seq = escape_char(*src, orig);
+        size_t      seqSize = strlen(seq);
 
-               if (dst)
-               {
-                       memcpy(dst, seq, seqSize);
-                       dst += seqSize;
-               }
+        if (dst)
+        {
+            memcpy(dst, seq, seqSize);
+            dst += seqSize;
+        }
 
-               // now record the extra size needed
-               extra += seqSize - 1;   // minus one to subtract the original char
+        // now record the extra size needed
+        extra += seqSize - 1;   // minus one to subtract the original char
 
-               // bump to the next src char
-               src += 1;
-       }
-       return extra;
+        // bump to the next src char
+        src += 1;
+    }
+    return extra;
 }
 
 void SkXMLWriter::addAttributeLen(const char name[], const char value[], size_t length)
 {
-       SkString valueStr;
+    SkString valueStr;
 
-       if (fDoEscapeMarkup)
-       {
-               size_t   extra = escape_markup(nil, value, length);
-               if (extra)
-               {
-                       valueStr.resize(length + extra);
-                       (void)escape_markup(valueStr.writable_str(), value, length);
-                       value = valueStr.c_str();
-                       length += extra;
-               }
-       }
-       this->onAddAttributeLen(name, value, length);
+    if (fDoEscapeMarkup)
+    {
+        size_t   extra = escape_markup(nil, value, length);
+        if (extra)
+        {
+            valueStr.resize(length + extra);
+            (void)escape_markup(valueStr.writable_str(), value, length);
+            value = valueStr.c_str();
+            length += extra;
+        }
+    }
+    this->onAddAttributeLen(name, value, length);
 }
 
 void SkXMLWriter::startElementLen(const char elem[], size_t length)
 {
-       this->onStartElementLen(elem, length);
+    this->onStartElementLen(elem, length);
 }
 
 ////////////////////////////////////////////////////////////////////////////////////////
 
 static void write_dom(const SkDOM& dom, const SkDOM::Node* node, SkXMLWriter* w, bool skipRoot)
 {
-       if (!skipRoot)
-       {
-               w->startElement(dom.getName(node));
+    if (!skipRoot)
+    {
+        w->startElement(dom.getName(node));
 
-               SkDOM::AttrIter iter(dom, node);
-               const char*     name;
-               const char* value;
-               while ((name = iter.next(&value)) != nil)
-                       w->addAttribute(name, value);
-       }
+        SkDOM::AttrIter iter(dom, node);
+        const char* name;
+        const char* value;
+        while ((name = iter.next(&value)) != nil)
+            w->addAttribute(name, value);
+    }
 
-       node = dom.getFirstChild(node, nil);
-       while (node)
-       {
-               write_dom(dom, node, w, false);
-               node = dom.getNextSibling(node, nil);
-       }
+    node = dom.getFirstChild(node, nil);
+    while (node)
+    {
+        write_dom(dom, node, w, false);
+        node = dom.getNextSibling(node, nil);
+    }
 
-       if (!skipRoot)
-               w->endElement();
+    if (!skipRoot)
+        w->endElement();
 }
 
 void SkXMLWriter::writeDOM(const SkDOM& dom, const SkDOM::Node* node, bool skipRoot)
 {
-       if (node)
-               write_dom(dom, node, this, skipRoot);
+    if (node)
+        write_dom(dom, node, this, skipRoot);
 }
 
 void SkXMLWriter::writeHeader()
@@ -188,8 +205,8 @@ void SkXMLWriter::writeHeader()
 
 static void tab(SkWStream& stream, int level)
 {
-       for (int i = 0; i < level; i++)
-               stream.writeText("\t");
+    for (int i = 0; i < level; i++)
+        stream.writeText("\t");
 }
 
 SkXMLStreamWriter::SkXMLStreamWriter(SkWStream* stream) : fStream(*stream)
@@ -198,55 +215,55 @@ SkXMLStreamWriter::SkXMLStreamWriter(SkWStream* stream) : fStream(*stream)
 
 SkXMLStreamWriter::~SkXMLStreamWriter()
 {
-       this->flush();
+    this->flush();
 }
 
 void SkXMLStreamWriter::onAddAttributeLen(const char name[], const char value[], size_t length)
 {
-       SkASSERT(!fElems.top()->fHasChildren);
-       fStream.writeText(" ");
-       fStream.writeText(name);
-       fStream.writeText("=\"");
-       fStream.write(value, length);
-       fStream.writeText("\"");
+    SkASSERT(!fElems.top()->fHasChildren);
+    fStream.writeText(" ");
+    fStream.writeText(name);
+    fStream.writeText("=\"");
+    fStream.write(value, length);
+    fStream.writeText("\"");
 }
 
 void SkXMLStreamWriter::onEndElement()
 {
-       Elem* elem = getEnd();
-       if (elem->fHasChildren)
-       {
-               tab(fStream, fElems.count());
-               fStream.writeText("</");
-               fStream.writeText(elem->fName.c_str());
-               fStream.writeText(">");
-       }
-       else
-               fStream.writeText("/>");
-       fStream.newline();
-       doEnd(elem);
+    Elem* elem = getEnd();
+    if (elem->fHasChildren)
+    {
+        tab(fStream, fElems.count());
+        fStream.writeText("</");
+        fStream.writeText(elem->fName.c_str());
+        fStream.writeText(">");
+    }
+    else
+        fStream.writeText("/>");
+    fStream.newline();
+    doEnd(elem);
 }
 
 void SkXMLStreamWriter::onStartElementLen(const char name[], size_t length)
 {
-       int level = fElems.count();
-       if (this->doStart(name, length))
-       {
-               // the first child, need to close with >
-               fStream.writeText(">");
-               fStream.newline();
-       }
+    int level = fElems.count();
+    if (this->doStart(name, length))
+    {
+        // the first child, need to close with >
+        fStream.writeText(">");
+        fStream.newline();
+    }
 
-       tab(fStream, level);
-       fStream.writeText("<");
-       fStream.write(name, length);
+    tab(fStream, level);
+    fStream.writeText("<");
+    fStream.write(name, length);
 }
 
 void SkXMLStreamWriter::writeHeader()
 {
-       const char* header = getHeader();
-       fStream.write(header, strlen(header));
-       fStream.newline();
+    const char* header = getHeader();
+    fStream.write(header, strlen(header));
+    fStream.newline();
 }
 
 ////////////////////////////////////////////////////////////////////////////////////////////////
@@ -254,34 +271,34 @@ void SkXMLStreamWriter::writeHeader()
 #include "SkXMLParser.h"
 
 SkXMLParserWriter::SkXMLParserWriter(SkXMLParser* parser)
-       : SkXMLWriter(false), fParser(*parser)
+    : SkXMLWriter(false), fParser(*parser)
 {
 }
 
 SkXMLParserWriter::~SkXMLParserWriter()
 {
-       this->flush();
+    this->flush();
 }
 
 void SkXMLParserWriter::onAddAttributeLen(const char name[], const char value[], size_t length)
 {
-       SkASSERT(fElems.count() == 0 || !fElems.top()->fHasChildren);
-       SkString str(value, length);
-       fParser.addAttribute(name, str.c_str());
+    SkASSERT(fElems.count() == 0 || !fElems.top()->fHasChildren);
+    SkString str(value, length);
+    fParser.addAttribute(name, str.c_str());
 }
 
 void SkXMLParserWriter::onEndElement()
 {
-       Elem* elem = this->getEnd();
-       fParser.endElement(elem->fName.c_str());
-       this->doEnd(elem);
+    Elem* elem = this->getEnd();
+    fParser.endElement(elem->fName.c_str());
+    this->doEnd(elem);
 }
 
 void SkXMLParserWriter::onStartElementLen(const char name[], size_t length)
 {
-       (void)this->doStart(name, length);
-       SkString str(name, length);
-       fParser.startElement(str.c_str());
+    (void)this->doStart(name, length);
+    SkString str(name, length);
+    fParser.startElement(str.c_str());
 }
 
 
@@ -293,31 +310,31 @@ void SkXMLParserWriter::onStartElementLen(const char name[], size_t length)
 void SkXMLStreamWriter::UnitTest()
 {
 #ifdef SK_SUPPORT_UNITTEST
-       SkDebugWStream  s;
-       SkXMLStreamWriter               w(&s);
+    SkDebugWStream  s;
+    SkXMLStreamWriter       w(&s);
 
-       w.startElement("elem0");
-       w.addAttribute("hello", "world");
-       w.addS32Attribute("dec", 42);
-       w.addHexAttribute("hex", 0x42, 3);
+    w.startElement("elem0");
+    w.addAttribute("hello", "world");
+    w.addS32Attribute("dec", 42);
+    w.addHexAttribute("hex", 0x42, 3);
 #ifdef SK_SCALAR_IS_FLOAT
-       w.addScalarAttribute("scalar", -4.2f);
+    w.addScalarAttribute("scalar", -4.2f);
 #endif
-       w.startElement("elem1");
-               w.endElement();
-               w.startElement("elem1");
-               w.addAttribute("name", "value");
-               w.endElement();
-               w.startElement("elem1");
-                       w.startElement("elem2");
-                               w.startElement("elem3");
-                               w.addAttribute("name", "value");
-                               w.endElement();
-                       w.endElement();
-                       w.startElement("elem2");
-                       w.endElement();
-               w.endElement();
-       w.endElement();
+    w.startElement("elem1");
+        w.endElement();
+        w.startElement("elem1");
+        w.addAttribute("name", "value");
+        w.endElement();
+        w.startElement("elem1");
+            w.startElement("elem2");
+                w.startElement("elem3");
+                w.addAttribute("name", "value");
+                w.endElement();
+            w.endElement();
+            w.startElement("elem2");
+            w.endElement();
+        w.endElement();
+    w.endElement();
 #endif
 }