Bug 1246756 - part 3 - update Skia to m49 branch. r=jrmuizel
authorLee Salzman <lsalzman@mozilla.com>
Tue, 09 Feb 2016 13:38:06 -0500
changeset 283697 159e0a5a653f2789e0c9b94f41501a4a44f7cb34
parent 283696 e6731baa8120d7089a00d326617fb1c46ed539a4
child 283698 26bab04db70b4613a47ad7817da24252e1774cf9
push id29988
push usercbook@mozilla.com
push dateWed, 10 Feb 2016 10:47:59 +0000
treeherdermozilla-central@7042e8a19f94 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjrmuizel
bugs1246756
milestone47.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1246756 - part 3 - update Skia to m49 branch. r=jrmuizel
CLOBBER
gfx/skia/skia/include/codec/SkAndroidCodec.h
gfx/skia/skia/include/codec/SkCodec.h
gfx/skia/skia/include/core/SkBitmap.h
gfx/skia/skia/include/core/SkCanvas.h
gfx/skia/skia/include/core/SkColorFilter.h
gfx/skia/skia/include/core/SkDevice.h
gfx/skia/skia/include/core/SkDither.h
gfx/skia/skia/include/core/SkDocument.h
gfx/skia/skia/include/core/SkDrawFilter.h
gfx/skia/skia/include/core/SkFixed.h
gfx/skia/skia/include/core/SkFlattenable.h
gfx/skia/skia/include/core/SkImage.h
gfx/skia/skia/include/core/SkImageDecoder.h
gfx/skia/skia/include/core/SkImageEncoder.h
gfx/skia/skia/include/core/SkImageFilter.h
gfx/skia/skia/include/core/SkImageGenerator.h
gfx/skia/skia/include/core/SkMask.h
gfx/skia/skia/include/core/SkMaskFilter.h
gfx/skia/skia/include/core/SkMatrix.h
gfx/skia/skia/include/core/SkOSFile.h
gfx/skia/skia/include/core/SkPaint.h
gfx/skia/skia/include/core/SkPath.h
gfx/skia/skia/include/core/SkPathMeasure.h
gfx/skia/skia/include/core/SkPathRef.h
gfx/skia/skia/include/core/SkPixelRef.h
gfx/skia/skia/include/core/SkPixelSerializer.h
gfx/skia/skia/include/core/SkPostConfig.h
gfx/skia/skia/include/core/SkPreConfig.h
gfx/skia/skia/include/core/SkRRect.h
gfx/skia/skia/include/core/SkRect.h
gfx/skia/skia/include/core/SkRefCnt.h
gfx/skia/skia/include/core/SkShader.h
gfx/skia/skia/include/core/SkStream.h
gfx/skia/skia/include/core/SkString.h
gfx/skia/skia/include/core/SkTArray.h
gfx/skia/skia/include/core/SkTDArray.h
gfx/skia/skia/include/core/SkTDict.h
gfx/skia/skia/include/core/SkTLazy.h
gfx/skia/skia/include/core/SkTSearch.h
gfx/skia/skia/include/core/SkTime.h
gfx/skia/skia/include/core/SkTypes.h
gfx/skia/skia/include/core/SkWriter32.h
gfx/skia/skia/include/effects/Sk1DPathEffect.h
gfx/skia/skia/include/effects/Sk2DPathEffect.h
gfx/skia/skia/include/effects/SkAlphaThresholdFilter.h
gfx/skia/skia/include/effects/SkBlurDrawLooper.h
gfx/skia/skia/include/effects/SkBlurImageFilter.h
gfx/skia/skia/include/effects/SkColorCubeFilter.h
gfx/skia/skia/include/effects/SkColorFilterImageFilter.h
gfx/skia/skia/include/effects/SkColorMatrixFilter.h
gfx/skia/skia/include/effects/SkCornerPathEffect.h
gfx/skia/skia/include/effects/SkDashPathEffect.h
gfx/skia/skia/include/effects/SkDiscretePathEffect.h
gfx/skia/skia/include/effects/SkDisplacementMapEffect.h
gfx/skia/skia/include/effects/SkDropShadowImageFilter.h
gfx/skia/skia/include/effects/SkEmbossMaskFilter.h
gfx/skia/skia/include/effects/SkLightingImageFilter.h
gfx/skia/skia/include/effects/SkMatrixConvolutionImageFilter.h
gfx/skia/skia/include/effects/SkModeColorFilter.h
gfx/skia/skia/include/effects/SkMorphologyImageFilter.h
gfx/skia/skia/include/effects/SkOffsetImageFilter.h
gfx/skia/skia/include/effects/SkPaintImageFilter.h
gfx/skia/skia/include/effects/SkPerlinNoiseShader.h
gfx/skia/skia/include/effects/SkRectShaderImageFilter.h
gfx/skia/skia/include/effects/SkTileImageFilter.h
gfx/skia/skia/include/effects/SkXfermodeImageFilter.h
gfx/skia/skia/include/gpu/GrCaps.h
gfx/skia/skia/include/gpu/GrClip.h
gfx/skia/skia/include/gpu/GrConfig.h
gfx/skia/skia/include/gpu/GrContext.h
gfx/skia/skia/include/gpu/GrContextOptions.h
gfx/skia/skia/include/gpu/GrDrawContext.h
gfx/skia/skia/include/gpu/GrRect.h
gfx/skia/skia/include/gpu/GrResourceKey.h
gfx/skia/skia/include/gpu/GrTestUtils.h
gfx/skia/skia/include/gpu/GrTextureAccess.h
gfx/skia/skia/include/gpu/GrTextureProvider.h
gfx/skia/skia/include/gpu/GrTypes.h
gfx/skia/skia/include/gpu/GrTypesPriv.h
gfx/skia/skia/include/gpu/SkGrPixelRef.h
gfx/skia/skia/include/gpu/effects/GrPorterDuffXferProcessor.h
gfx/skia/skia/include/gpu/gl/SkGLContext.h
gfx/skia/skia/include/gpu/gl/SkNullGLContext.h
gfx/skia/skia/include/gpu/gl/angle/SkANGLEGLContext.h
gfx/skia/skia/include/gpu/gl/command_buffer/SkCommandBufferGLContext.h
gfx/skia/skia/include/pipe/SkGPipe.h
gfx/skia/skia/include/ports/SkFontMgr.h
gfx/skia/skia/include/private/GrAuditTrail.h
gfx/skia/skia/include/private/GrSingleOwner.h
gfx/skia/skia/include/private/SkFloatingPoint.h
gfx/skia/skia/include/private/SkRecords.h
gfx/skia/skia/include/private/SkTDict.h
gfx/skia/skia/include/private/SkTLogic.h
gfx/skia/skia/include/private/SkTSearch.h
gfx/skia/skia/include/private/SkTemplates.h
gfx/skia/skia/include/private/SkUniquePtr.h
gfx/skia/skia/include/private/SkUtility.h
gfx/skia/skia/include/svg/parser/SkSVGParser.h
gfx/skia/skia/include/utils/SkCubicInterval.h
gfx/skia/skia/include/utils/SkCullPoints.h
gfx/skia/skia/include/utils/SkDumpCanvas.h
gfx/skia/skia/include/utils/SkInterpolator.h
gfx/skia/skia/include/utils/SkLuaCanvas.h
gfx/skia/skia/include/utils/SkNWayCanvas.h
gfx/skia/skia/include/utils/SkNoSaveLayerCanvas.h
gfx/skia/skia/include/utils/SkPaintFilterCanvas.h
gfx/skia/skia/include/utils/SkParsePaint.h
gfx/skia/skia/include/utils/SkRTConf.h
gfx/skia/skia/include/utils/win/SkHRESULT.h
gfx/skia/skia/include/views/SkOSWindow_SDL.h
gfx/skia/skia/include/views/SkParsePaint.h
gfx/skia/skia/include/views/SkView.h
gfx/skia/skia/include/views/SkViewInflate.h
gfx/skia/skia/src/android/SkBitmapRegionCanvas.cpp
gfx/skia/skia/src/android/SkBitmapRegionCanvas.h
gfx/skia/skia/src/android/SkBitmapRegionCodec.cpp
gfx/skia/skia/src/animator/SkDisplayType.h
gfx/skia/skia/src/animator/SkDisplayTypes.h
gfx/skia/skia/src/animator/SkMemberInfo.h
gfx/skia/skia/src/animator/SkOperandIterpolator.cpp
gfx/skia/skia/src/animator/SkScript.h
gfx/skia/skia/src/animator/SkScript2.h
gfx/skia/skia/src/animator/SkTime.cpp
gfx/skia/skia/src/codec/SkAndroidCodec.cpp
gfx/skia/skia/src/codec/SkBmpCodec.cpp
gfx/skia/skia/src/codec/SkBmpCodec.h
gfx/skia/skia/src/codec/SkBmpRLECodec.cpp
gfx/skia/skia/src/codec/SkBmpRLECodec.h
gfx/skia/skia/src/codec/SkBmpStandardCodec.cpp
gfx/skia/skia/src/codec/SkBmpStandardCodec.h
gfx/skia/skia/src/codec/SkCodec.cpp
gfx/skia/skia/src/codec/SkCodecImageGenerator.cpp
gfx/skia/skia/src/codec/SkCodecImageGenerator.h
gfx/skia/skia/src/codec/SkCodecPriv.h
gfx/skia/skia/src/codec/SkCodec_libgif.cpp
gfx/skia/skia/src/codec/SkCodec_libgif.h
gfx/skia/skia/src/codec/SkCodec_libico.cpp
gfx/skia/skia/src/codec/SkCodec_libico.h
gfx/skia/skia/src/codec/SkCodec_libpng.cpp
gfx/skia/skia/src/codec/SkCodec_libpng.h
gfx/skia/skia/src/codec/SkCodec_wbmp.cpp
gfx/skia/skia/src/codec/SkCodec_wbmp.h
gfx/skia/skia/src/codec/SkGifCodec.cpp
gfx/skia/skia/src/codec/SkGifCodec.h
gfx/skia/skia/src/codec/SkIcoCodec.cpp
gfx/skia/skia/src/codec/SkIcoCodec.h
gfx/skia/skia/src/codec/SkJpegCodec.cpp
gfx/skia/skia/src/codec/SkJpegCodec.h
gfx/skia/skia/src/codec/SkMaskSwizzler.cpp
gfx/skia/skia/src/codec/SkMaskSwizzler.h
gfx/skia/skia/src/codec/SkSampledCodec.cpp
gfx/skia/skia/src/codec/SkSampledCodec.h
gfx/skia/skia/src/codec/SkSampler.h
gfx/skia/skia/src/codec/SkSwizzler.cpp
gfx/skia/skia/src/codec/SkSwizzler.h
gfx/skia/skia/src/codec/SkWbmpCodec.cpp
gfx/skia/skia/src/codec/SkWbmpCodec.h
gfx/skia/skia/src/codec/SkWebpAdapterCodec.cpp
gfx/skia/skia/src/codec/SkWebpAdapterCodec.h
gfx/skia/skia/src/codec/SkWebpCodec.cpp
gfx/skia/skia/src/codec/SkWebpCodec.h
gfx/skia/skia/src/core/Sk4px.h
gfx/skia/skia/src/core/SkAAClip.cpp
gfx/skia/skia/src/core/SkAntiRun.h
gfx/skia/skia/src/core/SkBitmap.cpp
gfx/skia/skia/src/core/SkBitmapController.cpp
gfx/skia/skia/src/core/SkBitmapDevice.cpp
gfx/skia/skia/src/core/SkBitmapFilter.cpp
gfx/skia/skia/src/core/SkBitmapFilter.h
gfx/skia/skia/src/core/SkBitmapProcShader.cpp
gfx/skia/skia/src/core/SkBitmapProcShader.h
gfx/skia/skia/src/core/SkBitmapProcState.cpp
gfx/skia/skia/src/core/SkBitmapProcState.h
gfx/skia/skia/src/core/SkBitmapProcState_matrixProcs.cpp
gfx/skia/skia/src/core/SkBitmapProcState_matrix_template.h
gfx/skia/skia/src/core/SkBitmapProcState_procs.h
gfx/skia/skia/src/core/SkBitmapProcState_sample.h
gfx/skia/skia/src/core/SkBitmapProcState_shaderproc.h
gfx/skia/skia/src/core/SkBitmapScaler.cpp
gfx/skia/skia/src/core/SkBitmapScaler.h
gfx/skia/skia/src/core/SkBlitMask.h
gfx/skia/skia/src/core/SkBlitMask_D32.cpp
gfx/skia/skia/src/core/SkBlitter.cpp
gfx/skia/skia/src/core/SkBlitter_ARGB32.cpp
gfx/skia/skia/src/core/SkBlitter_RGB16.cpp
gfx/skia/skia/src/core/SkBuffer.cpp
gfx/skia/skia/src/core/SkCanvas.cpp
gfx/skia/skia/src/core/SkColorFilter.cpp
gfx/skia/skia/src/core/SkColorFilterShader.cpp
gfx/skia/skia/src/core/SkColorFilterShader.h
gfx/skia/skia/src/core/SkColorShader.h
gfx/skia/skia/src/core/SkComposeShader.cpp
gfx/skia/skia/src/core/SkConvolver.cpp
gfx/skia/skia/src/core/SkConvolver.h
gfx/skia/skia/src/core/SkCubicClipper.cpp
gfx/skia/skia/src/core/SkCubicClipper.h
gfx/skia/skia/src/core/SkDevice.cpp
gfx/skia/skia/src/core/SkDistanceFieldGen.cpp
gfx/skia/skia/src/core/SkDither.h
gfx/skia/skia/src/core/SkDraw.cpp
gfx/skia/skia/src/core/SkEdge.cpp
gfx/skia/skia/src/core/SkEdge.h
gfx/skia/skia/src/core/SkEdgeClipper.cpp
gfx/skia/skia/src/core/SkFDot6.h
gfx/skia/skia/src/core/SkFilterShader.cpp
gfx/skia/skia/src/core/SkFilterShader.h
gfx/skia/skia/src/core/SkFindAndPlaceGlyph.h
gfx/skia/skia/src/core/SkFloatBits.cpp
gfx/skia/skia/src/core/SkGeometry.cpp
gfx/skia/skia/src/core/SkGlobalInitialization_core.cpp
gfx/skia/skia/src/core/SkImageCacherator.cpp
gfx/skia/skia/src/core/SkImageCacherator.h
gfx/skia/skia/src/core/SkImageFilter.cpp
gfx/skia/skia/src/core/SkImageGenerator.cpp
gfx/skia/skia/src/core/SkLightingShader.cpp
gfx/skia/skia/src/core/SkLocalMatrixImageFilter.cpp
gfx/skia/skia/src/core/SkLocalMatrixShader.cpp
gfx/skia/skia/src/core/SkMaskFilter.cpp
gfx/skia/skia/src/core/SkMatrix.cpp
gfx/skia/skia/src/core/SkMatrixImageFilter.cpp
gfx/skia/skia/src/core/SkMatrixImageFilter.h
gfx/skia/skia/src/core/SkMatrixUtils.h
gfx/skia/skia/src/core/SkModeColorFilter.cpp
gfx/skia/skia/src/core/SkModeColorFilter.h
gfx/skia/skia/src/core/SkMultiPictureDraw.cpp
gfx/skia/skia/src/core/SkNx.h
gfx/skia/skia/src/core/SkOpts.cpp
gfx/skia/skia/src/core/SkOpts.h
gfx/skia/skia/src/core/SkPaint.cpp
gfx/skia/skia/src/core/SkPath.cpp
gfx/skia/skia/src/core/SkPathEffect.cpp
gfx/skia/skia/src/core/SkPathMeasure.cpp
gfx/skia/skia/src/core/SkPathPriv.h
gfx/skia/skia/src/core/SkPathRef.cpp
gfx/skia/skia/src/core/SkPictureFlat.h
gfx/skia/skia/src/core/SkPictureImageGenerator.cpp
gfx/skia/skia/src/core/SkPicturePlayback.cpp
gfx/skia/skia/src/core/SkPictureRecord.cpp
gfx/skia/skia/src/core/SkPictureRecord.h
gfx/skia/skia/src/core/SkPictureShader.cpp
gfx/skia/skia/src/core/SkPictureShader.h
gfx/skia/skia/src/core/SkPixelRef.cpp
gfx/skia/skia/src/core/SkPixmap.cpp
gfx/skia/skia/src/core/SkPx.h
gfx/skia/skia/src/core/SkRRect.cpp
gfx/skia/skia/src/core/SkRWBuffer.cpp
gfx/skia/skia/src/core/SkRasterizer.cpp
gfx/skia/skia/src/core/SkRecord.cpp
gfx/skia/skia/src/core/SkRecord.h
gfx/skia/skia/src/core/SkRecordDraw.cpp
gfx/skia/skia/src/core/SkRecordOpts.cpp
gfx/skia/skia/src/core/SkRecorder.cpp
gfx/skia/skia/src/core/SkRecorder.h
gfx/skia/skia/src/core/SkRemote.cpp
gfx/skia/skia/src/core/SkRemote.h
gfx/skia/skia/src/core/SkScaleToSides.h
gfx/skia/skia/src/core/SkScan.h
gfx/skia/skia/src/core/SkScan_AntiPath.cpp
gfx/skia/skia/src/core/SkScan_Antihair.cpp
gfx/skia/skia/src/core/SkScan_Hairline.cpp
gfx/skia/skia/src/core/SkScan_Path.cpp
gfx/skia/skia/src/core/SkShader.cpp
gfx/skia/skia/src/core/SkStream.cpp
gfx/skia/skia/src/core/SkString.cpp
gfx/skia/skia/src/core/SkStroke.cpp
gfx/skia/skia/src/core/SkTLList.h
gfx/skia/skia/src/core/SkTaskGroup.cpp
gfx/skia/skia/src/core/SkTaskGroup.h
gfx/skia/skia/src/core/SkTime.cpp
gfx/skia/skia/src/core/SkUtils.cpp
gfx/skia/skia/src/core/SkValue.h
gfx/skia/skia/src/core/SkVarAlloc.cpp
gfx/skia/skia/src/core/SkWriteBuffer.cpp
gfx/skia/skia/src/device/xps/SkXPSDevice.cpp
gfx/skia/skia/src/doc/SkDocument_PDF.cpp
gfx/skia/skia/src/effects/GrCircleBlurFragmentProcessor.cpp
gfx/skia/skia/src/effects/SkAlphaThresholdFilter.cpp
gfx/skia/skia/src/effects/SkArithmeticMode_gpu.cpp
gfx/skia/skia/src/effects/SkBlurImageFilter.cpp
gfx/skia/skia/src/effects/SkBlurMask.h
gfx/skia/skia/src/effects/SkBlurMaskFilter.cpp
gfx/skia/skia/src/effects/SkColorCubeFilter.cpp
gfx/skia/skia/src/effects/SkColorFilterImageFilter.cpp
gfx/skia/skia/src/effects/SkColorFilters.cpp
gfx/skia/skia/src/effects/SkColorMatrixFilter.cpp
gfx/skia/skia/src/effects/SkComposeImageFilter.cpp
gfx/skia/skia/src/effects/SkDisplacementMapEffect.cpp
gfx/skia/skia/src/effects/SkDropShadowImageFilter.cpp
gfx/skia/skia/src/effects/SkEmbossMaskFilter.cpp
gfx/skia/skia/src/effects/SkGpuBlurUtils.cpp
gfx/skia/skia/src/effects/SkGpuBlurUtils.h
gfx/skia/skia/src/effects/SkLightingImageFilter.cpp
gfx/skia/skia/src/effects/SkLumaColorFilter.cpp
gfx/skia/skia/src/effects/SkMagnifierImageFilter.cpp
gfx/skia/skia/src/effects/SkMatrixConvolutionImageFilter.cpp
gfx/skia/skia/src/effects/SkMorphologyImageFilter.cpp
gfx/skia/skia/src/effects/SkOffsetImageFilter.cpp
gfx/skia/skia/src/effects/SkPaintImageFilter.cpp
gfx/skia/skia/src/effects/SkPerlinNoiseShader.cpp
gfx/skia/skia/src/effects/SkRectShaderImageFilter.cpp
gfx/skia/skia/src/effects/SkTableColorFilter.cpp
gfx/skia/skia/src/effects/SkTileImageFilter.cpp
gfx/skia/skia/src/effects/SkXfermodeImageFilter.cpp
gfx/skia/skia/src/effects/gradients/SkClampRange.h
gfx/skia/skia/src/effects/gradients/SkGradientShader.cpp
gfx/skia/skia/src/effects/gradients/SkGradientShaderPriv.h
gfx/skia/skia/src/effects/gradients/SkLinearGradient.cpp
gfx/skia/skia/src/effects/gradients/SkLinearGradient.h
gfx/skia/skia/src/effects/gradients/SkRadialGradient.cpp
gfx/skia/skia/src/effects/gradients/SkRadialGradient.h
gfx/skia/skia/src/effects/gradients/SkRadialGradient_Table.h
gfx/skia/skia/src/effects/gradients/SkSweepGradient.cpp
gfx/skia/skia/src/effects/gradients/SkSweepGradient.h
gfx/skia/skia/src/effects/gradients/SkTwoPointConicalGradient.cpp
gfx/skia/skia/src/effects/gradients/SkTwoPointConicalGradient_gpu.cpp
gfx/skia/skia/src/gpu/GrAtlasTextBlob.cpp
gfx/skia/skia/src/gpu/GrAtlasTextBlob.h
gfx/skia/skia/src/gpu/GrAtlasTextContext.cpp
gfx/skia/skia/src/gpu/GrAtlasTextContext.h
gfx/skia/skia/src/gpu/GrAuditTrail.cpp
gfx/skia/skia/src/gpu/GrAutoLocaleSetter.h
gfx/skia/skia/src/gpu/GrBatchFontCache.cpp
gfx/skia/skia/src/gpu/GrBatchFontCache.h
gfx/skia/skia/src/gpu/GrCaps.cpp
gfx/skia/skia/src/gpu/GrClipMaskManager.cpp
gfx/skia/skia/src/gpu/GrContext.cpp
gfx/skia/skia/src/gpu/GrContextFactory.cpp
gfx/skia/skia/src/gpu/GrContextFactory.h
gfx/skia/skia/src/gpu/GrDefaultGeoProcFactory.cpp
gfx/skia/skia/src/gpu/GrDrawContext.cpp
gfx/skia/skia/src/gpu/GrDrawTarget.cpp
gfx/skia/skia/src/gpu/GrDrawTarget.h
gfx/skia/skia/src/gpu/GrDrawingManager.cpp
gfx/skia/skia/src/gpu/GrDrawingManager.h
gfx/skia/skia/src/gpu/GrFontScaler.cpp
gfx/skia/skia/src/gpu/GrFontScaler.h
gfx/skia/skia/src/gpu/GrFragmentProcessor.cpp
gfx/skia/skia/src/gpu/GrGpu.cpp
gfx/skia/skia/src/gpu/GrGpu.h
gfx/skia/skia/src/gpu/GrImageIDTextureAdjuster.cpp
gfx/skia/skia/src/gpu/GrImageIDTextureAdjuster.h
gfx/skia/skia/src/gpu/GrLayerHoister.cpp
gfx/skia/skia/src/gpu/GrMemoryPool.cpp
gfx/skia/skia/src/gpu/GrMemoryPool.h
gfx/skia/skia/src/gpu/GrOvalRenderer.cpp
gfx/skia/skia/src/gpu/GrPath.h
gfx/skia/skia/src/gpu/GrPathProcessor.cpp
gfx/skia/skia/src/gpu/GrPathUtils.cpp
gfx/skia/skia/src/gpu/GrPipeline.cpp
gfx/skia/skia/src/gpu/GrPipeline.h
gfx/skia/skia/src/gpu/GrProgramDesc.h
gfx/skia/skia/src/gpu/GrRecordReplaceDraw.cpp
gfx/skia/skia/src/gpu/GrRect.h
gfx/skia/skia/src/gpu/GrResourceCache.h
gfx/skia/skia/src/gpu/GrResourceProvider.cpp
gfx/skia/skia/src/gpu/GrResourceProvider.h
gfx/skia/skia/src/gpu/GrSWMaskHelper.cpp
gfx/skia/skia/src/gpu/GrSoftwarePathRenderer.cpp
gfx/skia/skia/src/gpu/GrStencilAndCoverTextContext.cpp
gfx/skia/skia/src/gpu/GrStencilAndCoverTextContext.h
gfx/skia/skia/src/gpu/GrSwizzle.h
gfx/skia/skia/src/gpu/GrTessellator.cpp
gfx/skia/skia/src/gpu/GrTessellator.h
gfx/skia/skia/src/gpu/GrTest.cpp
gfx/skia/skia/src/gpu/GrTest.h
gfx/skia/skia/src/gpu/GrTextBlobCache.cpp
gfx/skia/skia/src/gpu/GrTextBlobCache.h
gfx/skia/skia/src/gpu/GrTextContext.cpp
gfx/skia/skia/src/gpu/GrTextContext.h
gfx/skia/skia/src/gpu/GrTextureAccess.cpp
gfx/skia/skia/src/gpu/GrTextureParamsAdjuster.cpp
gfx/skia/skia/src/gpu/GrTextureParamsAdjuster.h
gfx/skia/skia/src/gpu/GrTextureProvider.cpp
gfx/skia/skia/src/gpu/GrTracing.h
gfx/skia/skia/src/gpu/GrTransferBuffer.h
gfx/skia/skia/src/gpu/SkGpuDevice.cpp
gfx/skia/skia/src/gpu/SkGpuDevice.h
gfx/skia/skia/src/gpu/SkGpuDevice_drawTexture.cpp
gfx/skia/skia/src/gpu/SkGrPixelRef.cpp
gfx/skia/skia/src/gpu/batches/GrAAConvexPathRenderer.cpp
gfx/skia/skia/src/gpu/batches/GrAAConvexTessellator.cpp
gfx/skia/skia/src/gpu/batches/GrAADistanceFieldPathRenderer.cpp
gfx/skia/skia/src/gpu/batches/GrAAHairLinePathRenderer.cpp
gfx/skia/skia/src/gpu/batches/GrAALinearizingConvexPathRenderer.cpp
gfx/skia/skia/src/gpu/batches/GrAtlasTextBatch.cpp
gfx/skia/skia/src/gpu/batches/GrAtlasTextBatch.h
gfx/skia/skia/src/gpu/batches/GrBatch.h
gfx/skia/skia/src/gpu/batches/GrClearBatch.h
gfx/skia/skia/src/gpu/batches/GrCopySurfaceBatch.h
gfx/skia/skia/src/gpu/batches/GrDashLinePathRenderer.cpp
gfx/skia/skia/src/gpu/batches/GrDefaultPathRenderer.cpp
gfx/skia/skia/src/gpu/batches/GrDiscardBatch.h
gfx/skia/skia/src/gpu/batches/GrDrawBatch.h
gfx/skia/skia/src/gpu/batches/GrDrawPathBatch.cpp
gfx/skia/skia/src/gpu/batches/GrDrawPathBatch.h
gfx/skia/skia/src/gpu/batches/GrStencilAndCoverPathRenderer.cpp
gfx/skia/skia/src/gpu/batches/GrStencilPathBatch.h
gfx/skia/skia/src/gpu/batches/GrTessellatingPathRenderer.cpp
gfx/skia/skia/src/gpu/effects/GrBezierEffect.cpp
gfx/skia/skia/src/gpu/effects/GrBicubicEffect.cpp
gfx/skia/skia/src/gpu/effects/GrBitmapTextGeoProc.cpp
gfx/skia/skia/src/gpu/effects/GrConfigConversionEffect.cpp
gfx/skia/skia/src/gpu/effects/GrConstColorProcessor.cpp
gfx/skia/skia/src/gpu/effects/GrConvexPolyEffect.cpp
gfx/skia/skia/src/gpu/effects/GrConvolutionEffect.cpp
gfx/skia/skia/src/gpu/effects/GrCoverageSetOpXP.cpp
gfx/skia/skia/src/gpu/effects/GrCustomXfermode.cpp
gfx/skia/skia/src/gpu/effects/GrDashingEffect.cpp
gfx/skia/skia/src/gpu/effects/GrDisableColorXP.cpp
gfx/skia/skia/src/gpu/effects/GrDistanceFieldGeoProc.cpp
gfx/skia/skia/src/gpu/effects/GrDistanceFieldGeoProc.h
gfx/skia/skia/src/gpu/effects/GrDitherEffect.cpp
gfx/skia/skia/src/gpu/effects/GrMatrixConvolutionEffect.cpp
gfx/skia/skia/src/gpu/effects/GrOvalEffect.cpp
gfx/skia/skia/src/gpu/effects/GrPorterDuffXferProcessor.cpp
gfx/skia/skia/src/gpu/effects/GrRRectEffect.cpp
gfx/skia/skia/src/gpu/effects/GrSimpleTextureEffect.cpp
gfx/skia/skia/src/gpu/effects/GrTextureDomain.cpp
gfx/skia/skia/src/gpu/effects/GrTextureDomain.h
gfx/skia/skia/src/gpu/effects/GrXfermodeFragmentProcessor.cpp
gfx/skia/skia/src/gpu/effects/GrYUVtoRGBEffect.cpp
gfx/skia/skia/src/gpu/gl/GrGLAssembleInterface.cpp
gfx/skia/skia/src/gpu/gl/GrGLBufferImpl.cpp
gfx/skia/skia/src/gpu/gl/GrGLBufferImpl.h
gfx/skia/skia/src/gpu/gl/GrGLCaps.cpp
gfx/skia/skia/src/gpu/gl/GrGLCaps.h
gfx/skia/skia/src/gpu/gl/GrGLDefines.h
gfx/skia/skia/src/gpu/gl/GrGLGpu.cpp
gfx/skia/skia/src/gpu/gl/GrGLGpu.h
gfx/skia/skia/src/gpu/gl/GrGLIndexBuffer.cpp
gfx/skia/skia/src/gpu/gl/GrGLInterface.cpp
gfx/skia/skia/src/gpu/gl/GrGLNameAllocator.cpp
gfx/skia/skia/src/gpu/gl/GrGLNameAllocator.h
gfx/skia/skia/src/gpu/gl/GrGLPath.cpp
gfx/skia/skia/src/gpu/gl/GrGLPathRendering.cpp
gfx/skia/skia/src/gpu/gl/GrGLPathRendering.h
gfx/skia/skia/src/gpu/gl/GrGLProgram.cpp
gfx/skia/skia/src/gpu/gl/GrGLProgram.h
gfx/skia/skia/src/gpu/gl/GrGLProgramDataManager.cpp
gfx/skia/skia/src/gpu/gl/GrGLProgramDataManager.h
gfx/skia/skia/src/gpu/gl/GrGLProgramDesc.cpp
gfx/skia/skia/src/gpu/gl/GrGLProgramDesc.h
gfx/skia/skia/src/gpu/gl/GrGLTransferBuffer.cpp
gfx/skia/skia/src/gpu/gl/GrGLTransferBuffer.h
gfx/skia/skia/src/gpu/gl/GrGLUniformHandler.cpp
gfx/skia/skia/src/gpu/gl/GrGLUniformHandler.h
gfx/skia/skia/src/gpu/gl/GrGLUtil.cpp
gfx/skia/skia/src/gpu/gl/GrGLUtil.h
gfx/skia/skia/src/gpu/gl/GrGLVaryingHandler.h
gfx/skia/skia/src/gpu/gl/GrGLVertexBuffer.cpp
gfx/skia/skia/src/gpu/gl/SkGLContext.cpp
gfx/skia/skia/src/gpu/gl/SkNullGLContext.cpp
gfx/skia/skia/src/gpu/gl/angle/GrGLCreateANGLEInterface.cpp
gfx/skia/skia/src/gpu/gl/angle/SkANGLEGLContext.cpp
gfx/skia/skia/src/gpu/gl/builders/GrGLProgramBuilder.cpp
gfx/skia/skia/src/gpu/gl/builders/GrGLProgramBuilder.h
gfx/skia/skia/src/gpu/gl/command_buffer/SkCommandBufferGLContext.cpp
gfx/skia/skia/src/gpu/gl/debug/GrGLCreateDebugInterface.cpp
gfx/skia/skia/src/gpu/gl/debug/SkDebugGLContext.h
gfx/skia/skia/src/gpu/gl/egl/SkCreatePlatformGLContext_egl.cpp
gfx/skia/skia/src/gpu/gl/mesa/SkMesaGLContext.h
gfx/skia/skia/src/gpu/glsl/GrGLSL.h
gfx/skia/skia/src/gpu/glsl/GrGLSLCaps.cpp
gfx/skia/skia/src/gpu/glsl/GrGLSLCaps.h
gfx/skia/skia/src/gpu/glsl/GrGLSLFragmentProcessor.cpp
gfx/skia/skia/src/gpu/glsl/GrGLSLFragmentProcessor.h
gfx/skia/skia/src/gpu/glsl/GrGLSLFragmentShaderBuilder.cpp
gfx/skia/skia/src/gpu/glsl/GrGLSLFragmentShaderBuilder.h
gfx/skia/skia/src/gpu/glsl/GrGLSLGeometryProcessor.cpp
gfx/skia/skia/src/gpu/glsl/GrGLSLGeometryProcessor.h
gfx/skia/skia/src/gpu/glsl/GrGLSLPrimitiveProcessor.cpp
gfx/skia/skia/src/gpu/glsl/GrGLSLPrimitiveProcessor.h
gfx/skia/skia/src/gpu/glsl/GrGLSLProgramBuilder.cpp
gfx/skia/skia/src/gpu/glsl/GrGLSLProgramBuilder.h
gfx/skia/skia/src/gpu/glsl/GrGLSLShaderBuilder.cpp
gfx/skia/skia/src/gpu/glsl/GrGLSLShaderBuilder.h
gfx/skia/skia/src/gpu/glsl/GrGLSLTextureSampler.h
gfx/skia/skia/src/gpu/glsl/GrGLSLUniformHandler.h
gfx/skia/skia/src/gpu/glsl/GrGLSLVertexShaderBuilder.cpp
gfx/skia/skia/src/gpu/glsl/GrGLSLVertexShaderBuilder.h
gfx/skia/skia/src/gpu/glsl/GrGLSLXferProcessor.cpp
gfx/skia/skia/src/gpu/glsl/GrGLSLXferProcessor.h
gfx/skia/skia/src/gpu/text/GrAtlasTextBlob.cpp
gfx/skia/skia/src/gpu/text/GrAtlasTextBlob.h
gfx/skia/skia/src/gpu/text/GrAtlasTextContext.cpp
gfx/skia/skia/src/gpu/text/GrAtlasTextContext.h
gfx/skia/skia/src/gpu/text/GrBatchFontCache.cpp
gfx/skia/skia/src/gpu/text/GrBatchFontCache.h
gfx/skia/skia/src/gpu/text/GrDistanceFieldAdjustTable.cpp
gfx/skia/skia/src/gpu/text/GrDistanceFieldAdjustTable.h
gfx/skia/skia/src/gpu/text/GrFontScaler.cpp
gfx/skia/skia/src/gpu/text/GrFontScaler.h
gfx/skia/skia/src/gpu/text/GrStencilAndCoverTextContext.cpp
gfx/skia/skia/src/gpu/text/GrStencilAndCoverTextContext.h
gfx/skia/skia/src/gpu/text/GrTextBlobCache.cpp
gfx/skia/skia/src/gpu/text/GrTextBlobCache.h
gfx/skia/skia/src/gpu/text/GrTextContext.cpp
gfx/skia/skia/src/gpu/text/GrTextContext.h
gfx/skia/skia/src/gpu/text/GrTextUtils.cpp
gfx/skia/skia/src/gpu/text/GrTextUtils.h
gfx/skia/skia/src/image/SkImage.cpp
gfx/skia/skia/src/image/SkImagePriv.h
gfx/skia/skia/src/image/SkImage_Base.h
gfx/skia/skia/src/image/SkImage_Generator.cpp
gfx/skia/skia/src/image/SkImage_Gpu.cpp
gfx/skia/skia/src/image/SkImage_Gpu.h
gfx/skia/skia/src/image/SkImage_Raster.cpp
gfx/skia/skia/src/image/SkSurface_Raster.cpp
gfx/skia/skia/src/images/SkDecodingImageGenerator.cpp
gfx/skia/skia/src/images/SkImageDecoder_libgif.cpp
gfx/skia/skia/src/images/SkImageDecoder_libico.cpp
gfx/skia/skia/src/images/SkImageDecoder_libjpeg.cpp
gfx/skia/skia/src/images/SkImageDecoder_libpng.cpp
gfx/skia/skia/src/images/SkImageDecoder_libwebp.cpp
gfx/skia/skia/src/images/SkImageEncoder.cpp
gfx/skia/skia/src/opts/Sk4px_NEON.h
gfx/skia/skia/src/opts/Sk4px_SSE2.h
gfx/skia/skia/src/opts/Sk4px_none.h
gfx/skia/skia/src/opts/SkBitmapProcState_arm_neon.cpp
gfx/skia/skia/src/opts/SkBitmapProcState_opts_SSE2.cpp
gfx/skia/skia/src/opts/SkBitmapProcState_opts_SSE2.h
gfx/skia/skia/src/opts/SkBitmapProcState_opts_SSSE3.cpp
gfx/skia/skia/src/opts/SkBitmapProcState_opts_SSSE3.h
gfx/skia/skia/src/opts/SkBitmapProcState_opts_mips_dsp.cpp
gfx/skia/skia/src/opts/SkBlitRow_opts_arm_neon.cpp
gfx/skia/skia/src/opts/SkColorCubeFilter_opts.h
gfx/skia/skia/src/opts/SkNx_avx.h
gfx/skia/skia/src/opts/SkNx_neon.h
gfx/skia/skia/src/opts/SkNx_sse.h
gfx/skia/skia/src/opts/SkOpts_neon.cpp
gfx/skia/skia/src/opts/SkOpts_sse2.cpp
gfx/skia/skia/src/opts/SkOpts_sse41.cpp
gfx/skia/skia/src/opts/SkPx_neon.h
gfx/skia/skia/src/opts/SkPx_none.h
gfx/skia/skia/src/opts/SkPx_sse.h
gfx/skia/skia/src/opts/SkSwizzler_opts.h
gfx/skia/skia/src/opts/SkXfermode_opts.h
gfx/skia/skia/src/opts/opts_check_x86.cpp
gfx/skia/skia/src/pathops/SkDLineIntersection.cpp
gfx/skia/skia/src/pathops/SkOpAngle.cpp
gfx/skia/skia/src/pathops/SkOpCoincidence.cpp
gfx/skia/skia/src/pathops/SkOpSegment.cpp
gfx/skia/skia/src/pathops/SkPathOpsLine.cpp
gfx/skia/skia/src/pathops/SkPathOpsQuad.cpp
gfx/skia/skia/src/pathops/SkPathOpsTSect.h
gfx/skia/skia/src/pathops/SkPathOpsTypes.cpp
gfx/skia/skia/src/pathops/SkPathOpsTypes.h
gfx/skia/skia/src/pathops/SkReduceOrder.cpp
gfx/skia/skia/src/pdf/SkPDFBitmap.cpp
gfx/skia/skia/src/pdf/SkPDFBitmap.h
gfx/skia/skia/src/pdf/SkPDFCanon.h
gfx/skia/skia/src/pdf/SkPDFDevice.cpp
gfx/skia/skia/src/pdf/SkPDFFont.cpp
gfx/skia/skia/src/pdf/SkPDFMetadata.cpp
gfx/skia/skia/src/pipe/SkGPipePriv.h
gfx/skia/skia/src/pipe/SkGPipeRead.cpp
gfx/skia/skia/src/pipe/SkGPipeWrite.cpp
gfx/skia/skia/src/pipe/utils/SamplePipeControllers.cpp
gfx/skia/skia/src/pipe/utils/SamplePipeControllers.h
gfx/skia/skia/src/ports/SkFontMgr_android_parser.cpp
gfx/skia/skia/src/ports/SkFontMgr_android_parser.h
gfx/skia/skia/src/ports/SkGlobalInitialization_chromium.cpp
gfx/skia/skia/src/ports/SkGlobalInitialization_default.cpp
gfx/skia/skia/src/ports/SkImageDecoder_empty.cpp
gfx/skia/skia/src/ports/SkImageGenerator_skia.cpp
gfx/skia/skia/src/ports/SkOSEnvironment.cpp
gfx/skia/skia/src/ports/SkOSEnvironment.h
gfx/skia/skia/src/ports/SkOSFile_stdio.cpp
gfx/skia/skia/src/ports/SkTime_Unix.cpp
gfx/skia/skia/src/ports/SkTime_win.cpp
gfx/skia/skia/src/svg/parser/SkSVG.cpp
gfx/skia/skia/src/utils/SkCubicInterval.cpp
gfx/skia/skia/src/utils/SkCullPoints.cpp
gfx/skia/skia/src/utils/SkDashPath.cpp
gfx/skia/skia/src/utils/SkDumpCanvas.cpp
gfx/skia/skia/src/utils/SkFrontBufferedStream.cpp
gfx/skia/skia/src/utils/SkInterpolator.cpp
gfx/skia/skia/src/utils/SkLua.cpp
gfx/skia/skia/src/utils/SkLuaCanvas.cpp
gfx/skia/skia/src/utils/SkNWayCanvas.cpp
gfx/skia/skia/src/utils/SkPaintFilterCanvas.cpp
gfx/skia/skia/src/utils/SkParsePath.cpp
gfx/skia/skia/src/utils/SkTFitsIn.h
gfx/skia/skia/src/utils/android/SkAndroidSDKCanvas.cpp
gfx/skia/skia/src/utils/android/SkAndroidSDKCanvas.h
gfx/skia/skia/src/utils/debugger/SkDebugCanvas.cpp
gfx/skia/skia/src/utils/debugger/SkDebugCanvas.h
gfx/skia/skia/src/utils/debugger/SkDrawCommand.cpp
gfx/skia/skia/src/utils/debugger/SkDrawCommand.h
gfx/skia/skia/src/utils/debugger/SkObjectParser.cpp
gfx/skia/skia/src/utils/debugger/SkObjectParser.h
gfx/skia/skia/src/views/SkView.cpp
gfx/skia/skia/src/views/sdl/SkOSWindow_SDL.cpp
gfx/skia/skia/src/xml/SkDOM.cpp
--- a/CLOBBER
+++ b/CLOBBER
@@ -17,10 +17,10 @@
 #
 # Modifying this file will now automatically clobber the buildbot machines \o/
 #
 
 # Are you updating CLOBBER because you think it's needed for your WebIDL
 # changes to stick? As of bug 928195, this shouldn't be necessary! Please
 # don't change CLOBBER for WebIDL changes any more.
 
-Bug 1237983 - Investigate and remove the Bagheera Client implementation.
+Bug 1246756 - Update Skia to m49 branch.
 
--- a/gfx/skia/skia/include/codec/SkAndroidCodec.h
+++ b/gfx/skia/skia/include/codec/SkAndroidCodec.h
@@ -45,17 +45,35 @@ public:
     virtual ~SkAndroidCodec() {}
 
 
     const SkImageInfo& getInfo() const { return fInfo; }
 
     /**
      *  Format of the encoded data.
      */
-    SkEncodedFormat getEncodedFormat() const { return this->onGetEncodedFormat(); }
+    SkEncodedFormat getEncodedFormat() const { return fCodec->getEncodedFormat(); }
+
+    /**
+     *  @param requestedColorType Color type requested by the client
+     *
+     *  If it is possible to decode to requestedColorType, this returns
+     *  requestedColorType.  Otherwise, this returns whichever color type
+     *  is suggested by the codec as the best match for the encoded data.
+     */
+    SkColorType computeOutputColorType(SkColorType requestedColorType);
+
+    /**
+     *  @param requestedUnpremul  Indicates if the client requested
+     *                            unpremultiplied output
+     *
+     *  Returns the appropriate alpha type to decode to.  If the image
+     *  has alpha, the value of requestedUnpremul will be honored.
+     */
+    SkAlphaType computeOutputAlphaType(bool requestedUnpremul);
 
     /**
      *  Returns the dimensions of the scaled output image, for an input
      *  sampleSize.
      *
      *  When the sample size divides evenly into the original dimensions, the
      *  scaled output dimensions will simply be equal to the original
      *  dimensions divided by the sample size.
@@ -205,26 +223,28 @@ public:
      *
      *  This will return an error if the info is kIndex_8_SkColorType and also will not perform
      *  any scaling or subsetting.
      */
     SkCodec::Result getAndroidPixels(const SkImageInfo& info, void* pixels, size_t rowBytes);
 
 protected:
 
-    SkAndroidCodec(const SkImageInfo&);
+    SkAndroidCodec(SkCodec*);
 
-    virtual SkEncodedFormat onGetEncodedFormat() const = 0;
+    SkCodec* codec() const { return fCodec.get(); }
 
     virtual SkISize onGetSampledDimensions(int sampleSize) const = 0;
 
     virtual bool onGetSupportedSubset(SkIRect* desiredSubset) const = 0;
 
     virtual SkCodec::Result onGetAndroidPixels(const SkImageInfo& info, void* pixels,
             size_t rowBytes, const AndroidOptions& options) = 0;
 
 private:
 
     // This will always be a reference to the info that is contained by the
     // embedded SkCodec.
     const SkImageInfo& fInfo;
+
+    SkAutoTDelete<SkCodec> fCodec;
 };
 #endif // SkAndroidCodec_DEFINED
--- a/gfx/skia/skia/include/codec/SkCodec.h
+++ b/gfx/skia/skia/include/codec/SkCodec.h
@@ -21,19 +21,44 @@ class SkPngChunkReader;
 class SkSampler;
 
 /**
  *  Abstraction layer directly on top of an image codec.
  */
 class SkCodec : SkNoncopyable {
 public:
     /**
+     *  Minimum number of bytes that must be buffered in SkStream input.
+     *
+     *  An SkStream passed to NewFromStream must be able to use this many
+     *  bytes to determine the image type. Then the same SkStream must be
+     *  passed to the correct decoder to read from the beginning.
+     *
+     *  This can be accomplished by implementing peek() to support peeking
+     *  this many bytes, or by implementing rewind() to be able to rewind()
+     *  after reading this many bytes.
+     */
+    static size_t MinBufferedBytesNeeded();
+
+    /**
      *  If this stream represents an encoded image that we know how to decode,
      *  return an SkCodec that can decode it. Otherwise return NULL.
      *
+     *  As stated above, this call must be able to peek or read
+     *  MinBufferedBytesNeeded to determine the correct format, and then start
+     *  reading from the beginning. First it will attempt to peek, and it
+     *  assumes that if less than MinBufferedBytesNeeded bytes (but more than
+     *  zero) are returned, this is because the stream is shorter than this,
+     *  so falling back to reading would not provide more data. If peek()
+     *  returns zero bytes, this call will instead attempt to read(). This
+     *  will require that the stream can be rewind()ed.
+     *
+     *  If SkPngChunkReader is not NULL, take a ref and pass it to libpng if
+     *  the image is a png.
+     *
      *  If the SkPngChunkReader is not NULL then:
      *      If the image is not a PNG, the SkPngChunkReader will be ignored.
      *      If the image is a PNG, the SkPngChunkReader will be reffed.
      *      If the PNG has unknown chunks, the SkPngChunkReader will be used
      *      to handle these chunks.  SkPngChunkReader will be called to read
      *      any unknown chunk at any point during the creation of the codec
      *      or the decode.  Note that if SkPngChunkReader fails to read a
      *      chunk, this could result in a failure to create the codec or a
@@ -248,28 +273,16 @@ public:
 
     /**
      *  Simplified version of getPixels() that asserts that info is NOT kIndex8_SkColorType and
      *  uses the default Options.
      */
     Result getPixels(const SkImageInfo& info, void* pixels, size_t rowBytes);
 
     /**
-     *  Some images may initially report that they have alpha due to the format
-     *  of the encoded data, but then never use any colors which have alpha
-     *  less than 100%. This function can be called *after* decoding to
-     *  determine if such an image truly had alpha. Calling it before decoding
-     *  is undefined.
-     *  FIXME: see skbug.com/3582.
-     */
-    bool reallyHasAlpha() const {
-        return this->onReallyHasAlpha();
-    }
-
-    /**
      * The remaining functions revolve around decoding scanlines.
      */
 
     /**
      *  Prepare for a scanline decode with the specified options.
      *
      *  After this call, this class will be ready to decode the first scanline.
      *
@@ -395,34 +408,36 @@ public:
          * Interlaced pngs are an example.
          */
         kNone_SkScanlineOrder,
     };
 
     /**
      *  An enum representing the order in which scanlines will be returned by
      *  the scanline decoder.
+     *
+     *  This is undefined before startScanlineDecode() is called.
      */
     SkScanlineOrder getScanlineOrder() const { return this->onGetScanlineOrder(); }
 
     /**
      *  Returns the y-coordinate of the next row to be returned by the scanline
      *  decoder.
      *
      *  This will equal fCurrScanline, except in the case of strangely
      *  encoded image types (bottom-up bmps, interlaced gifs).
      *
      *  Results are undefined when not in scanline decoding mode.
      */
     int nextScanline() const { return this->outputScanline(fCurrScanline); }
 
     /**
-     * Returns the output y-coordinate of the row that corresponds to an input
-     * y-coordinate.  The input y-coordinate represents where the scanline
-     * is located in the encoded data.
+     *  Returns the output y-coordinate of the row that corresponds to an input
+     *  y-coordinate.  The input y-coordinate represents where the scanline
+     *  is located in the encoded data.
      *
      *  This will equal inputScanline, except in the case of strangely
      *  encoded image types (bottom-up bmps, interlaced gifs).
      */
     int outputScanline(int inputScanline) const;
 
 protected:
     SkCodec(const SkImageInfo&, SkStream*);
@@ -454,18 +469,16 @@ protected:
                                SkPMColor ctable[], int* ctableCount,
                                int* rowsDecoded) = 0;
 
     virtual bool onGetValidSubset(SkIRect* /* desiredSubset */) const {
         // By default, subsets are not supported.
         return false;
     }
 
-    virtual bool onReallyHasAlpha() const { return false; }
-
     /**
      *  If the stream was previously read, attempt to rewind.
      *
      *  If the stream needed to be rewound, call onRewind.
      *  @returns true if the codec is at the right position and can be used.
      *      false if there was a failure to rewind.
      *
      *  This is called by getPixels() and start(). Subclasses may call if they
@@ -524,24 +537,32 @@ protected:
      */
 
     /**
      *  Most images types will be kTopDown and will not need to override this function.
      */
     virtual SkScanlineOrder onGetScanlineOrder() const { return kTopDown_SkScanlineOrder; }
 
     /**
-     *  Update the next scanline. Used by interlaced png.
+     *  Update the current scanline. Used by interlaced png.
      */
-    void updateNextScanline(int newY) { fCurrScanline = newY; }
+    void updateCurrScanline(int newY) { fCurrScanline = newY; }
 
     const SkImageInfo& dstInfo() const { return fDstInfo; }
 
     const SkCodec::Options& options() const { return fOptions; }
 
+    /**
+     *  Returns the number of scanlines that have been decoded so far.
+     *  This is unaffected by the SkScanlineOrder.
+     *
+     *  Returns -1 if we have not started a scanline decode.
+     */
+    int currScanline() const { return fCurrScanline; }
+
     virtual int onOutputScanline(int inputScanline) const;
 
 private:
     const SkImageInfo       fSrcInfo;
     SkAutoTDelete<SkStream> fStream;
     bool                    fNeedsRewind;
     // These fields are only meaningful during scanline decodes.
     SkImageInfo             fDstInfo;
@@ -605,10 +626,11 @@ private:
      *  May create a sampler, if one is not currently being used. Otherwise, does
      *  not affect ownership.
      *
      *  Only valid during scanline decoding.
      */
     virtual SkSampler* getSampler(bool /*createIfNecessary*/) { return nullptr; }
 
     friend class SkSampledCodec;
+    friend class SkIcoCodec;
 };
 #endif // SkCodec_DEFINED
--- a/gfx/skia/skia/include/core/SkBitmap.h
+++ b/gfx/skia/skia/include/core/SkBitmap.h
@@ -49,22 +49,34 @@ public:
      *  Copy the settings from the src into this bitmap. If the src has pixels
      *  allocated, they will be shared, not copied, so that the two bitmaps will
      *  reference the same memory for the pixels. If a deep copy is needed,
      *  where the new bitmap has its own separate copy of the pixels, use
      *  deepCopyTo().
      */
     SkBitmap(const SkBitmap& src);
 
+    /**
+     *  Copy the settings from the src into this bitmap. If the src has pixels
+     *  allocated, ownership of the pixels will be taken.
+     */
+    SkBitmap(SkBitmap&& src);
+
     ~SkBitmap();
 
-    /** Copies the src bitmap into this bitmap. Ownership of the src bitmap's pixels remains
-        with the src bitmap.
+    /** Copies the src bitmap into this bitmap. Ownership of the src
+        bitmap's pixels is shared with the src bitmap.
     */
     SkBitmap& operator=(const SkBitmap& src);
+
+    /** Copies the src bitmap into this bitmap. Takes ownership of the src
+        bitmap's pixels.
+    */
+    SkBitmap& operator=(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);
 
     ///////////////////////////////////////////////////////////////////////////
 
     const SkImageInfo& info() const { return fInfo; }
@@ -290,16 +302,24 @@ public:
      *  caller must ensure that the specified pixels are valid for the lifetime
      *  of the created bitmap (and its pixelRef).
      */
     bool installPixels(const SkImageInfo& info, void* pixels, size_t rowBytes) {
         return this->installPixels(info, pixels, rowBytes, NULL, NULL, NULL);
     }
 
     /**
+     *  Call installPixels with no ReleaseProc specified. This means
+     *  that the caller must ensure that the specified pixels and
+     *  colortable are valid for the lifetime of the created bitmap
+     *  (and its pixelRef).
+     */
+    bool installPixels(const SkPixmap&);
+
+    /**
      *  Calls installPixels() with the value in the SkMask. The caller must
      *  ensure that the specified mask pixels are valid for the lifetime
      *  of the created bitmap (and its pixelRef).
      */
     bool installMaskPixels(const SkMask&);
 
     /** Use this to assign a new pixel address for an existing bitmap. This
         will automatically release any pixelref previously installed. Only call
--- a/gfx/skia/skia/include/core/SkCanvas.h
+++ b/gfx/skia/skia/include/core/SkCanvas.h
@@ -32,32 +32,46 @@ class SkPath;
 class SkPicture;
 class SkPixmap;
 class SkRRect;
 struct SkRSXform;
 class SkSurface;
 class SkSurface_Base;
 class SkTextBlob;
 
+/*
+ *  If you want the legacy cliptolayer flag (i.e. android), then you must have the new
+ *  legacy saveflags.
+ */
+#ifdef SK_SUPPORT_LEGACY_CLIPTOLAYERFLAG
+#ifndef SK_SUPPORT_LEGACY_SAVEFLAGS
+    #define SK_SUPPORT_LEGACY_SAVEFLAGS
+#endif
+#endif
+
 /** \class SkCanvas
 
     A Canvas encapsulates all of the state about drawing into a device (bitmap).
     This includes a reference to the device itself, and a stack of matrix/clip
     values. For any given draw call (e.g. drawRect), the geometry of the object
     being drawn is transformed by the concatenation of all the matrices in the
     stack. The transformed geometry is clipped by the intersection of all of
     the clips in the stack.
 
     While the Canvas holds the state of the drawing device, the state (style)
     of the object being drawn is held by the Paint, which is provided as a
     parameter to each of the draw() methods. The Paint holds attributes such as
     color, typeface, textSize, strokeWidth, shader (e.g. gradients, patterns),
     etc.
 */
 class SK_API SkCanvas : public SkRefCnt {
+    enum PrivateSaveLayerFlags {
+        kDontClipToLayer_PrivateSaveLayerFlag   = 1 << 31,
+    };
+    
 public:
     /**
      *  Attempt to allocate raster canvas, matching the ImageInfo, that will draw directly into the
      *  specified pixels. To access the pixels after drawing to them, the caller should call
      *  flush() or call peekPixels(...).
      *
      *  On failure, return NULL. This can fail for several reasons:
      *  1. invalid ImageInfo (e.g. negative dimensions)
@@ -276,16 +290,17 @@ public:
     /**
      *  Helper for calling writePixels(info, ...) by passing its pixels and rowbytes. If the bitmap
      *  is just wrapping a texture, returns false and does nothing.
      */
     bool writePixels(const SkBitmap& bitmap, int x, int y);
 
     ///////////////////////////////////////////////////////////////////////////
 
+#ifdef SK_SUPPORT_LEGACY_SAVEFLAGS
     enum SaveFlags {
         /** save the matrix state, restoring it on restore() */
         // [deprecated] kMatrix_SaveFlag            = 0x01,
         kMatrix_SaveFlag            = 0x01,
         /** save the clip state, restoring it on restore() */
         // [deprecated] kClip_SaveFlag              = 0x02,
         kClip_SaveFlag              = 0x02,
         /** the layer needs to support per-pixel alpha */
@@ -302,16 +317,17 @@ public:
         // helper masks for common choices
         // [deprecated] kMatrixClip_SaveFlag        = 0x03,
         kMatrixClip_SaveFlag        = 0x03,
 #ifdef SK_SUPPORT_LEGACY_CLIPTOLAYERFLAG
         kARGB_NoClipLayer_SaveFlag  = 0x0F,
 #endif
         kARGB_ClipLayer_SaveFlag    = 0x1F
     };
+#endif
 
     /** This call saves the current matrix, clip, and drawFilter, and pushes a
         copy onto a private stack. Subsequent calls to translate, scale,
         rotate, skew, concat or clipRect, clipPath, and setDrawFilter all
         operate on this copy.
         When the balancing call to restore() is made, the previous matrix, clip,
         and drawFilter are restored.
 
@@ -331,16 +347,24 @@ public:
                      offscreen when restore() is called
         @return The value to pass to restoreToCount() to balance this save()
     */
     int saveLayer(const SkRect* bounds, const SkPaint* paint);
     int saveLayer(const SkRect& bounds, const SkPaint* paint) {
         return this->saveLayer(&bounds, paint);
     }
 
+    /**
+     *  Temporary name.
+     *  Will allow any requests for LCD text to be respected, so the caller must be careful to
+     *  only draw on top of opaque sections of the layer to get good results.
+     */
+    int saveLayerPreserveLCDTextRequests(const SkRect* bounds, const SkPaint* paint);
+
+#ifdef SK_SUPPORT_LEGACY_SAVEFLAGS
     /** DEPRECATED - use saveLayer(const SkRect*, const SkPaint*) instead.
 
         This behaves the same as saveLayer(const SkRect*, const SkPaint*),
         but it allows fine-grained control of which state bits to be saved
         (and subsequently restored).
 
         @param bounds (may be null) This rect, if non-null, is used as a hint to
                       limit the size of the offscreen, and thus drawing may be
@@ -348,46 +372,85 @@ public:
                       happen. If exact clipping is desired, use clipRect().
         @param paint (may be null) This is copied, and is applied to the
                      offscreen when restore() is called
         @param flags  LayerFlags
         @return The value to pass to restoreToCount() to balance this save()
     */
     SK_ATTR_EXTERNALLY_DEPRECATED("SaveFlags use is deprecated")
     int saveLayer(const SkRect* bounds, const SkPaint* paint, SaveFlags flags);
+#endif
 
     /** 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).
         @param bounds (may be null) This rect, if non-null, is used as a hint to
                       limit the size of the offscreen, and thus drawing may be
                       clipped to it, though that clipping is not guaranteed to
                       happen. If exact clipping is desired, use clipRect().
         @param alpha  This is applied to the offscreen when restore() is called.
         @return The value to pass to restoreToCount() to balance this save()
     */
     int saveLayerAlpha(const SkRect* bounds, U8CPU alpha);
 
+#ifdef SK_SUPPORT_LEGACY_SAVEFLAGS
     /** DEPRECATED - use saveLayerAlpha(const SkRect*, U8CPU) instead.
 
         This behaves the same as saveLayerAlpha(const SkRect*, U8CPU),
         but it allows fine-grained control of which state bits to be saved
         (and subsequently restored).
 
         @param bounds (may be null) This rect, if non-null, is used as a hint to
                       limit the size of the offscreen, and thus drawing may be
                       clipped to it, though that clipping is not guaranteed to
                       happen. If exact clipping is desired, use clipRect().
         @param alpha  This is applied to the offscreen when restore() is called.
         @param flags  LayerFlags
         @return The value to pass to restoreToCount() to balance this save()
     */
     SK_ATTR_EXTERNALLY_DEPRECATED("SaveFlags use is deprecated")
     int saveLayerAlpha(const SkRect* bounds, U8CPU alpha, SaveFlags flags);
+#endif
+
+    enum {
+        kIsOpaque_SaveLayerFlag         = 1 << 0,
+        kPreserveLCDText_SaveLayerFlag  = 1 << 1,
+
+#ifdef SK_SUPPORT_LEGACY_CLIPTOLAYERFLAG
+        kDontClipToLayer_Legacy_SaveLayerFlag = kDontClipToLayer_PrivateSaveLayerFlag,
+#endif
+    };
+    typedef uint32_t SaveLayerFlags;
+
+    struct SaveLayerRec {
+        SaveLayerRec()
+            : fBounds(nullptr), fPaint(nullptr), fBackdrop(nullptr), fSaveLayerFlags(0)
+        {}
+        SaveLayerRec(const SkRect* bounds, const SkPaint* paint, SaveLayerFlags saveLayerFlags = 0)
+            : fBounds(bounds)
+            , fPaint(paint)
+            , fBackdrop(nullptr)
+            , fSaveLayerFlags(saveLayerFlags)
+        {}
+        SaveLayerRec(const SkRect* bounds, const SkPaint* paint, const SkImageFilter* backdrop,
+                     SaveLayerFlags saveLayerFlags)
+            : fBounds(bounds)
+            , fPaint(paint)
+            , fBackdrop(backdrop)
+            , fSaveLayerFlags(saveLayerFlags)
+        {}
+
+        const SkRect*           fBounds;    // optional
+        const SkPaint*          fPaint;     // optional
+        const SkImageFilter*    fBackdrop;  // optional
+        SaveLayerFlags          fSaveLayerFlags;
+    };
+
+    int saveLayer(const SaveLayerRec&);
 
     /** This call balances a previous call to save(), and is used to remove all
         modifications to the matrix/clip/drawFilter state since the last save
         call.
         It is an error to call restore() more times than save() was called.
     */
     void restore();
 
@@ -601,28 +664,28 @@ public:
     void clear(SkColor color) {
         this->drawColor(color, SkXfermode::kSrc_Mode);
     }
 
     /**
      * This makes the contents of the canvas undefined. Subsequent calls that
      * require reading the canvas contents will produce undefined results. Examples
      * include blending and readPixels. The actual implementation is backend-
-     * dependent and one legal implementation is to do nothing. Like clear(), this
-     * ignores the clip.
+     * dependent and one legal implementation is to do nothing. This method
+     * ignores the current clip.
      *
      * This function should only be called if the caller intends to subsequently
      * draw to the canvas. The canvas may do real work at discard() time in order
      * to optimize performance on subsequent draws. Thus, if you call this and then
      * never draw to the canvas subsequently you may pay a perfomance penalty.
      */
     void discard() { this->onDiscard(); }
 
     /**
-     *  Fill the entire canvas' bitmap (restricted to the current clip) with the
+     *  Fill the entire canvas (restricted to the current clip) with the
      *  specified paint.
      *  @param paint    The paint used to fill the canvas
      */
     void drawPaint(const SkPaint& paint);
 
     enum PointMode {
         /** drawPoints draws each point separately */
         kPoints_PointMode,
@@ -899,29 +962,16 @@ public:
      *  - The center is stretched in both axes.
      * Else, for each axis where dst < bitmap,
      *  - The corners shrink proportionally
      *  - The sides (along the shrink axis) and center are not drawn
      */
     void drawBitmapNine(const SkBitmap& bitmap, const SkIRect& center, const SkRect& dst,
                         const SkPaint* paint = NULL);
 
-    /** Draw the specified bitmap, with its top/left corner at (x,y),
-        NOT transformed by the current matrix. Note: if the paint
-        contains a maskfilter that generates a mask which extends beyond the
-        bitmap's original width/height, then the bitmap will be drawn as if it
-        were in a Shader with CLAMP mode. Thus the color outside of the original
-        width/height will be the edge color replicated.
-        @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, or NULL
-    */
-    void drawSprite(const SkBitmap& bitmap, int left, int top, const SkPaint* paint = NULL);
-
     /** 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)
     */
@@ -1218,24 +1268,25 @@ protected:
     virtual SkSurface* onNewSurface(const SkImageInfo&, const SkSurfaceProps&);
 
     // default impl defers to its device
     virtual bool onPeekPixels(SkPixmap*);
     virtual bool onAccessTopLayerPixels(SkPixmap*);
 
     // Subclass save/restore notifiers.
     // Overriders should call the corresponding INHERITED method up the inheritance chain.
-    // willSaveLayer()'s return value may suppress full layer allocation.
+    // getSaveLayerStrategy()'s return value may suppress full layer allocation.
     enum SaveLayerStrategy {
         kFullLayer_SaveLayerStrategy,
-        kNoLayer_SaveLayerStrategy
+        kNoLayer_SaveLayerStrategy,
     };
 
     virtual void willSave() {}
-    virtual SaveLayerStrategy willSaveLayer(const SkRect*, const SkPaint*, SaveFlags) {
+    // Overriders should call the corresponding INHERITED method up the inheritance chain.
+    virtual SaveLayerStrategy getSaveLayerStrategy(const SaveLayerRec&) {
         return kFullLayer_SaveLayerStrategy;
     }
     virtual void willRestore() {}
     virtual void didRestore() {}
     virtual void didConcat(const SkMatrix&) {}
     virtual void didSetMatrix(const SkMatrix&) {}
 
     virtual void onDrawDRRect(const SkRRect&, const SkRRect&, const SkPaint&);
@@ -1280,17 +1331,16 @@ protected:
     virtual void onDrawImageNine(const SkImage*, const SkIRect& center, const SkRect& dst,
                                  const SkPaint*);
 
     virtual void onDrawBitmap(const SkBitmap&, SkScalar dx, SkScalar dy, const SkPaint*);
     virtual void onDrawBitmapRect(const SkBitmap&, const SkRect*, const SkRect&, const SkPaint*,
                                   SrcRectConstraint);
     virtual void onDrawBitmapNine(const SkBitmap&, const SkIRect& center, const SkRect& dst,
                                   const SkPaint*);
-    virtual void onDrawSprite(const SkBitmap&, int left, int top, const SkPaint*);
 
     enum ClipEdgeStyle {
         kHard_ClipEdgeStyle,
         kSoft_ClipEdgeStyle
     };
 
     virtual void onClipRect(const SkRect& rect, SkRegion::Op op, ClipEdgeStyle edgeStyle);
     virtual void onClipRRect(const SkRRect& rrect, SkRegion::Op op, ClipEdgeStyle edgeStyle);
@@ -1306,21 +1356,31 @@ protected:
     // need to overload this method. The impl must keep track of this, as it
     // is not released or deleted by the caller.
     virtual SkCanvas* canvasForDrawIter();
 
     // Clip rectangle bounds. Called internally by saveLayer.
     // returns false if the entire rectangle is entirely clipped out
     // If non-NULL, The imageFilter parameter will be used to expand the clip
     // and offscreen bounds for any margin required by the filter DAG.
-    bool clipRectBounds(const SkRect* bounds, SaveFlags flags,
-                        SkIRect* intersection,
+    bool clipRectBounds(const SkRect* bounds, SaveLayerFlags, SkIRect* intersection,
                         const SkImageFilter* imageFilter = NULL);
 
+#ifdef SK_SUPPORT_LEGACY_SAVEFLAGS
+    // Needed by SkiaCanvasProxy in Android. Make sure that class is updated
+    // before removing this method.
+    static uint32_t SaveLayerFlagsToSaveFlags(SaveLayerFlags);
+#endif
 private:
+    static bool BoundsAffectsClip(SaveLayerFlags);
+#ifdef SK_SUPPORT_LEGACY_SAVEFLAGS
+    static uint32_t SaveFlagsToSaveLayerFlags(SaveFlags);
+#endif
+    static SaveLayerFlags LegacySaveFlagsToSaveLayerFlags(uint32_t legacySaveFlags);
+
     enum ShaderOverrideOpacity {
         kNone_ShaderOverrideOpacity,        //!< there is no overriding shader (bitmap or image)
         kOpaque_ShaderOverrideOpacity,      //!< the overriding shader is opaque
         kNotOpaque_ShaderOverrideOpacity,   //!< the overriding shader may not be opaque
     };
 
     // notify our surface (if we have one) that we are about to draw, so it
     // can perform copy-on-write or invalidate any cached images
@@ -1370,16 +1430,17 @@ private:
     friend class AutoDrawLooper;
     friend class SkLua;             // needs top layer size and offset
     friend class SkDebugCanvas;     // needs experimental fAllowSimplifyClip
     friend class SkSurface_Raster;  // needs getDevice()
     friend class SkRecorder;        // InitFlags
     friend class SkNoSaveLayerCanvas;   // InitFlags
     friend class SkPictureImageFilter;  // SkCanvas(SkBaseDevice*, SkSurfaceProps*, InitFlags)
     friend class SkPictureRecord;   // predrawNotify (why does it need it? <reed>)
+    friend class SkPicturePlayback; // SaveFlagsToSaveLayerFlags
 
     enum InitFlags {
         kDefault_InitFlags                  = 0,
         kConservativeRasterClip_InitFlag    = 1 << 0,
     };
     SkCanvas(const SkIRect& bounds, InitFlags);
     SkCanvas(SkBaseDevice* device, InitFlags);
 
@@ -1401,17 +1462,17 @@ private:
      */
     SkISize getTopLayerSize() const;
     SkIPoint getTopLayerOrigin() const;
 
     void internalDrawBitmapRect(const SkBitmap& bitmap, const SkRect* src,
                                 const SkRect& dst, const SkPaint* paint,
                                 SrcRectConstraint);
     void internalDrawPaint(const SkPaint& paint);
-    void internalSaveLayer(const SkRect* bounds, const SkPaint*, SaveFlags, SaveLayerStrategy);
+    void internalSaveLayer(const SaveLayerRec&, SaveLayerStrategy);
     void internalDrawDevice(SkBaseDevice*, int x, int y, const SkPaint*, bool isBitmapDevice);
 
     // shared by save() and saveLayer()
     void internalSave();
     void internalRestore();
     static void DrawRect(const SkDraw& draw, const SkPaint& paint,
                          const SkRect& r, SkScalar textSize);
     static void DrawTextDecorations(const SkDraw& draw, const SkPaint& paint,
@@ -1423,16 +1484,20 @@ private:
 
     /*
      *  Returns true if drawing the specified rect (or all if it is null) with the specified
      *  paint (or default if null) would overwrite the entire root device of the canvas
      *  (i.e. the canvas' surface if it had one).
      */
     bool wouldOverwriteEntireSurface(const SkRect*, const SkPaint*, ShaderOverrideOpacity) const;
 
+    /**
+     *  Returns true if the paint's imagefilter can be invoked directly, without needed a layer.
+     */
+    bool canDrawBitmapAsSprite(SkScalar x, SkScalar y, int w, int h, const SkPaint&);
 
     /*  These maintain a cache of the clip bounds in local coordinates,
         (converted to 2s-compliment if floats are slow).
      */
     mutable SkRect fCachedLocalClipBounds;
     mutable bool   fCachedLocalClipBoundsDirty;
     bool fAllowSoftClip;
     bool fAllowSimplifyClip;
@@ -1500,69 +1565,28 @@ public:
     }
 
 private:
     SkCanvas*   fCanvas;
     int         fSaveCount;
 };
 #define SkAutoCanvasRestore(...) SK_REQUIRE_LOCAL_VAR(SkAutoCanvasRestore)
 
-/**
- *  If the caller wants read-only access to the pixels in a canvas, it can just
- *  call canvas->peekPixels(), since that is the fastest way to "peek" at the
- *  pixels on a raster-backed canvas.
- *
- *  If the canvas has pixels, but they are not readily available to the CPU
- *  (e.g. gpu-backed), then peekPixels() will fail, but readPixels() will
- *  succeed (though be slower, since it will return a copy of the pixels).
- *
- *  SkAutoROCanvasPixels encapsulates these two techniques, trying first to call
- *  peekPixels() (for performance), but if that fails, calling readPixels() and
- *  storing the copy locally.
- *
- *  The caller must respect the restrictions associated with peekPixels(), since
- *  that may have been called: The returned information is invalidated if...
- *      - any API is called on the canvas (or its parent surface if present)
- *      - the canvas goes out of scope
- */
-class SkAutoROCanvasPixels : SkNoncopyable {
-public:
-    SkAutoROCanvasPixels(SkCanvas* canvas);
-
-    // returns NULL on failure
-    const void* addr() const { return fAddr; }
-
-    // undefined if addr() == NULL
-    size_t rowBytes() const { return fRowBytes; }
-
-    // undefined if addr() == NULL
-    const SkImageInfo& info() const { return fInfo; }
-
-    // helper that, if returns true, installs the pixels into the bitmap. Note
-    // that the bitmap may reference the address returned by peekPixels(), so
-    // the caller must respect the restrictions associated with peekPixels().
-    bool asROBitmap(SkBitmap*) const;
-
-private:
-    SkBitmap    fBitmap;    // used if peekPixels() fails
-    const void* fAddr;      // NULL on failure
-    SkImageInfo fInfo;
-    size_t      fRowBytes;
-};
-
+#ifdef SK_SUPPORT_LEGACY_SAVEFLAGS
 static inline SkCanvas::SaveFlags operator|(const SkCanvas::SaveFlags lhs,
                                             const SkCanvas::SaveFlags rhs) {
     return static_cast<SkCanvas::SaveFlags>(static_cast<int>(lhs) | static_cast<int>(rhs));
 }
 
 static inline SkCanvas::SaveFlags& operator|=(SkCanvas::SaveFlags& lhs,
                                               const SkCanvas::SaveFlags rhs) {
     lhs = lhs | rhs;
     return lhs;
 }
+#endif
 
 class SkCanvasClipVisitor {
 public:
     virtual ~SkCanvasClipVisitor();
     virtual void clipRect(const SkRect&, SkRegion::Op, bool antialias) = 0;
     virtual void clipRRect(const SkRRect&, SkRegion::Op, bool antialias) = 0;
     virtual void clipPath(const SkPath&, SkRegion::Op, bool antialias) = 0;
 };
--- a/gfx/skia/skia/include/core/SkColorFilter.h
+++ b/gfx/skia/skia/include/core/SkColorFilter.h
@@ -101,23 +101,16 @@ public:
         @param c    The source color used with the specified mode
         @param mode The xfermode mode that is applied to each color in
                         the colorfilter's filterSpan[16,32] methods
         @return colorfilter object that applies the src color and mode,
                     or NULL if the mode will have no effect.
     */
     static SkColorFilter* CreateModeFilter(SkColor c, SkXfermode::Mode mode);
 
-    /** Create a colorfilter that multiplies the RGB channels by one color, and
-        then adds a second color, pinning the result for each component to
-        [0..255]. The alpha components of the mul and add arguments
-        are ignored.
-    */
-    static SkColorFilter* CreateLightingFilter(SkColor mul, SkColor add);
-
     /** Construct a colorfilter whose effect is to first apply the inner filter and then apply
      *  the outer filter to the result of the inner's.
      *  The reference counts for outer and inner are incremented.
      *
      *  Due to internal limits, it is possible that this will return NULL, so the caller must
      *  always check.
      */
     static SkColorFilter* CreateComposeFilter(SkColorFilter* outer, SkColorFilter* inner);
--- a/gfx/skia/skia/include/core/SkDevice.h
+++ b/gfx/skia/skia/include/core/SkDevice.h
@@ -328,26 +328,36 @@ protected:
      *  perform its own rendering pass. It is acceptable for the backend
      *  to perform some device-specific warm up tasks and then let SkCanvas
      *  perform the main rendering loop (by return false from here).
      */
     virtual bool EXPERIMENTAL_drawPicture(SkCanvas*, const SkPicture*, const SkMatrix*,
                                           const SkPaint*);
 
     struct CreateInfo {
-        static SkPixelGeometry AdjustGeometry(const SkImageInfo&, TileUsage, SkPixelGeometry);
+        static SkPixelGeometry AdjustGeometry(const SkImageInfo&, TileUsage, SkPixelGeometry,
+                                              bool preserveLCDText);
 
         // The constructor may change the pixel geometry based on other parameters.
         CreateInfo(const SkImageInfo& info,
                    TileUsage tileUsage,
-                   SkPixelGeometry geo,
-                   bool forImageFilter = false)
+                   SkPixelGeometry geo)
             : fInfo(info)
             , fTileUsage(tileUsage)
-            , fPixelGeometry(AdjustGeometry(info, tileUsage, geo))
+            , fPixelGeometry(AdjustGeometry(info, tileUsage, geo, false))
+            , fForImageFilter(false) {}
+
+        CreateInfo(const SkImageInfo& info,
+                   TileUsage tileUsage,
+                   SkPixelGeometry geo,
+                   bool preserveLCDText,
+                   bool forImageFilter)
+            : fInfo(info)
+            , fTileUsage(tileUsage)
+            , fPixelGeometry(AdjustGeometry(info, tileUsage, geo, preserveLCDText))
             , fForImageFilter(forImageFilter) {}
 
         const SkImageInfo       fInfo;
         const TileUsage         fTileUsage;
         const SkPixelGeometry   fPixelGeometry;
         const bool              fForImageFilter;
     };
 
@@ -369,18 +379,22 @@ protected:
 private:
     friend class SkCanvas;
     friend struct DeviceCM; //for setMatrixClip
     friend class SkDraw;
     friend class SkDrawIter;
     friend class SkDeviceFilteredPaint;
     friend class SkImageFilter::DeviceProxy;
     friend class SkNoPixelsBitmapDevice;
+    friend class SkSurface_Raster;
 
-    friend class SkSurface_Raster;
+    /**
+     *  Calls through to drawSprite, processing imagefilter as needed.
+     */
+    void drawBitmapAsSprite(const SkDraw&, const SkBitmap&, int x, int y, const SkPaint&);
 
     // used to change the backend's pixels (and possibly config/rowbytes)
     // but cannot change the width/height, so there should be no change to
     // any clip information.
     // TODO: move to SkBitmapDevice
     virtual void replaceBitmapBackendForRasterSurface(const SkBitmap&) {}
 
     virtual bool forceConservativeRasterClip() const { return false; }
--- a/gfx/skia/skia/include/core/SkDocument.h
+++ b/gfx/skia/skia/include/core/SkDocument.h
@@ -11,16 +11,17 @@
 #include "SkBitmap.h"
 #include "SkPicture.h"
 #include "SkRect.h"
 #include "SkRefCnt.h"
 #include "SkString.h"
 #include "SkTime.h"
 
 class SkCanvas;
+class SkPixelSerializer;
 class SkWStream;
 
 /** SK_ScalarDefaultDPI is 72 DPI.
 */
 #define SK_ScalarDefaultRasterDPI           72.0f
 
 /**
  *  High-level API for creating a document-based canvas. To use..
@@ -53,16 +54,34 @@ public:
      *         or sent online or to printer.
      *  @returns NULL if there is an error, otherwise a newly created
      *           PDF-backed SkDocument.
      */
     static SkDocument* CreatePDF(SkWStream*,
                                  SkScalar dpi = SK_ScalarDefaultRasterDPI);
 
     /**
+     *  @param jpegEncoder For PDF documents, if a jpegEncoder is set,
+     *         use it to encode SkImages and SkBitmaps as [JFIF]JPEGs.
+     *         This feature is deprecated and is only supplied for
+     *         backwards compatability.
+     *
+     *         The prefered method to create PDFs with JPEG images is
+     *         to use SkImage::NewFromEncoded() and not jpegEncoder.
+     *         Chromium uses NewFromEncoded.
+     *
+     *         If the encoder is unset, or if jpegEncoder->onEncode()
+     *         returns NULL, fall back on encoding images losslessly
+     *         with Deflate.
+     */
+    static SkDocument* CreatePDF(SkWStream*,
+                                 SkScalar dpi,
+                                 SkPixelSerializer* jpegEncoder);
+
+    /**
      *  Create a PDF-backed document, writing the results into a file.
      */
     static SkDocument* CreatePDF(const char outputFilePath[],
                                  SkScalar dpi = SK_ScalarDefaultRasterDPI);
 
     /**
      *  Create a XPS-backed document, writing the results into the stream.
      *  Returns NULL if XPS is not supported.
--- a/gfx/skia/skia/include/core/SkDrawFilter.h
+++ b/gfx/skia/skia/include/core/SkDrawFilter.h
@@ -11,16 +11,18 @@
 #define SkDrawFilter_DEFINED
 
 #include "SkRefCnt.h"
 
 class SkCanvas;
 class SkPaint;
 
 /**
+ *  DEPRECATED - use SkPaintFilterCanvas instead.
+ *
  *  Right before something is being draw, filter() is called with the
  *  paint. The filter may modify the paint as it wishes, which will then be
  *  used for the actual drawing. Note: this modification only lasts for the
  *  current draw, as a temporary copy of the paint is used.
  */
 class SK_API SkDrawFilter : public SkRefCnt {
 public:
     enum Type {
--- a/gfx/skia/skia/include/core/SkFixed.h
+++ b/gfx/skia/skia/include/core/SkFixed.h
@@ -81,19 +81,19 @@ typedef int32_t             SkFixed;
 
 #define SkFixedAbs(x)       SkAbs32(x)
 #define SkFixedAve(a, b)    (((a) + (b)) >> 1)
 
 // Blink layout tests are baselined to Clang optimizing through undefined behavior in SkDivBits.
 #if defined(SK_SUPPORT_LEGACY_DIVBITS_UB)
     #define SkFixedDiv(numer, denom) SkDivBits(numer, denom, 16)
 #else
-    // TODO(reed): this clamp shouldn't be needed.  Use SkToS32().
+    // The divide may exceed 32 bits. Clamp to a signed 32 bit result.
     #define SkFixedDiv(numer, denom) \
-        SkTPin<int32_t>(((int64_t)numer << 16) / denom, SK_MinS32, SK_MaxS32)
+        SkToS32(SkTPin<int64_t>((SkLeftShift((int64_t)numer, 16) / denom), SK_MinS32, SK_MaxS32))
 #endif
 
 //////////////////////////////////////////////////////////////////////////////////////////////////////
 // Now look for ASM overrides for our portable versions (should consider putting this in its own file)
 
 inline SkFixed SkFixedMul_longlong(SkFixed a, SkFixed b) {
     return (SkFixed)((int64_t)a * b >> 16);
 }
@@ -140,19 +140,19 @@ inline SkFixed SkFixedMul_longlong(SkFix
     #undef SkFloatToFixed
     #define SkFloatToFixed(x)  SkFloatToFixed_arm(x)
 #endif
 
 ///////////////////////////////////////////////////////////////////////////////
 
 typedef int64_t SkFixed3232;   // 32.32
 
-#define SkIntToFixed3232(x)       ((SkFixed3232)(x) << 32)
+#define SkIntToFixed3232(x)       (SkLeftShift((SkFixed3232)(x), 32))
 #define SkFixed3232ToInt(x)       ((int)((x) >> 32))
-#define SkFixedToFixed3232(x)     ((SkFixed3232)(x) << 16)
+#define SkFixedToFixed3232(x)     (SkLeftShift((SkFixed3232)(x), 16))
 #define SkFixed3232ToFixed(x)     ((SkFixed)((x) >> 16))
 #define SkFloatToFixed3232(x)     ((SkFixed3232)((x) * (65536.0f * 65536.0f)))
 
 #define SkScalarToFixed3232(x)    SkFloatToFixed3232(x)
 
 ///////////////////////////////////////////////////////////////////////////////
 
 // 64bits wide, with a 16bit bias. Useful when accumulating lots of 16.16 so
--- a/gfx/skia/skia/include/core/SkFlattenable.h
+++ b/gfx/skia/skia/include/core/SkFlattenable.h
@@ -44,17 +44,17 @@ class SkPrivateEffectInitializer;
 
 #define SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(flattenable) \
     SkFlattenable::Register(#flattenable, flattenable::CreateProc, \
                             flattenable::GetFlattenableType());
 
 #define SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(flattenable)    \
     private:                                                                \
     static SkFlattenable* CreateProc(SkReadBuffer&);                        \
-    friend class ::SkPrivateEffectInitializer;                              \
+    friend class SkFlattenable::PrivateInitializer;                         \
     public:                                                                 \
     Factory getFactory() const override { return CreateProc; }
 
 /** For SkFlattenable derived objects with a valid type
     This macro should only be used in base class objects in core
   */
 #define SK_DEFINE_FLATTENABLE_TYPE(flattenable) \
     static Type GetFlattenableType() { \
@@ -103,16 +103,23 @@ public:
     static void Register(const char name[], Factory, Type);
 
     /**
      *  Override this if your subclass needs to record data that it will need to recreate itself
      *  from its CreateProc (returned by getFactory()).
      */
     virtual void flatten(SkWriteBuffer&) const {}
 
+protected:
+    class PrivateInitializer {
+    public:
+        static void InitCore();
+        static void InitEffects();
+    };
+
 private:
     static void InitializeFlattenablesIfNeeded();
 
     friend class SkGraphics;
 
     typedef SkRefCnt INHERITED;
 };
 
--- a/gfx/skia/skia/include/core/SkImage.h
+++ b/gfx/skia/skia/include/core/SkImage.h
@@ -262,17 +262,17 @@ public:
      */
     SkData* encode(SkImageEncoder::Type, int quality) const;
 
     /**
      *  Encode the image and return the result as a caller-managed SkData.  This will
      *  attempt to reuse existing encoded data (as returned by refEncoded).
      *
      *  We defer to the SkPixelSerializer both for vetting existing encoded data
-     *  (useEncodedData) and for encoding the image (encodePixels) when no such data is
+     *  (useEncodedData) and for encoding the image (encode) when no such data is
      *  present or is rejected by the serializer.
      *
      *  If not specified, we use a default serializer which 1) always accepts existing data
      *  (in any format) and 2) encodes to PNG.
      *
      *  If no compatible encoded data exists and encoding fails, this method will also
      *  fail (return NULL).
      */
@@ -319,38 +319,16 @@ public:
     bool asLegacyBitmap(SkBitmap*, LegacyBitmapMode) const;
     
     /**
      *  Returns true if the image is backed by an image-generator or other src that creates
      *  (and caches) its pixels / texture on-demand.
      */
     bool isLazyGenerated() const;
 
-    /**
-     *  Apply the specified filter to this image, and return the result as a new image.
-     *
-     *  if forceResultToOriginalSize is true, then the resulting image will be the same size as the
-     *  src, regardless of the normal output of the filter.
-     *
-     *  If offset is non-null, it is set to the relative offset needed to draw the resulting image
-     *  in the same logical place as the original.
-     *
-     *  e.g.
-     *      If the filter makes the result larger by a margin of 4 the output would be:
-     *          result->width()  == this->width + 8
-     *          result->height() == this->height + 8
-     *          offset.x()       == -4
-     *          offset.y()       == -4
-     *
-     *  If the filter fails to create a resulting image, null is returned, and the offset parameter
-     *  (if specified) will be undefined.
-     */
-    SkImage* applyFilter(SkImageFilter* filter, SkIPoint* offset,
-                         bool forceResultToOriginalSize) const;
-
 protected:
     SkImage(int width, int height, uint32_t uniqueID);
 
 private:
     const int       fWidth;
     const int       fHeight;
     const uint32_t  fUniqueID;
 
--- a/gfx/skia/skia/include/core/SkImageDecoder.h
+++ b/gfx/skia/skia/include/core/SkImageDecoder.h
@@ -11,18 +11,16 @@
 #include "SkBitmap.h"
 #include "SkImage.h"
 #include "SkPngChunkReader.h"
 #include "SkRect.h"
 #include "SkRefCnt.h"
 #include "SkTRegistry.h"
 #include "SkTypes.h"
 
-//#define SK_LEGACY_PEEKER
-
 class SkStream;
 class SkStreamRewindable;
 
 /** \class SkImageDecoder
 
     Base class for decoding compressed images into a SkBitmap
 */
 class SkImageDecoder : SkNoncopyable {
@@ -124,28 +122,16 @@ public:
         fRequireUnpremultipliedColors = request;
     }
 
     /** Returns true if the decoder will only return bitmaps with unpremultiplied
         colors.
     */
     bool getRequireUnpremultipliedColors() const { return fRequireUnpremultipliedColors; }
 
-#ifdef SK_LEGACY_PEEKER
-    // Android subclasses SkImageDecoder::Peeker, which has been changed into SkPngChunkReader.
-    // Temporarily use this class until Android can be updated to directly inherit from
-    // SkPngChunkReader.
-    class Peeker : public SkPngChunkReader {
-    public:
-        bool readChunk(const char tag[], const void* data, size_t length) final {
-            return this->peek(tag, data, length);
-        }
-        virtual bool peek(const char tag[], const void* data, size_t length) = 0;
-    };
-#endif
     SkPngChunkReader* getPeeker() const { return fPeeker; }
     SkPngChunkReader* setPeeker(SkPngChunkReader*);
 
     /**
      *  By default, the codec will try to comply with the "pref" colortype
      *  that is passed to decode() or decodeSubset(). However, this can be called
      *  to override that, causing the codec to try to match the src depth instead
      *  (as shown below).
--- a/gfx/skia/skia/include/core/SkImageEncoder.h
+++ b/gfx/skia/skia/include/core/SkImageEncoder.h
@@ -7,16 +7,18 @@
 
 #ifndef SkImageEncoder_DEFINED
 #define SkImageEncoder_DEFINED
 
 #include "SkImageInfo.h"
 #include "SkTRegistry.h"
 
 class SkBitmap;
+class SkPixelSerializer;
+class SkPixmap;
 class SkData;
 class SkWStream;
 
 class SkImageEncoder {
 public:
     // TODO (scroggo): Merge with SkEncodedFormat.
     enum Type {
         kUnknown_Type,
@@ -59,21 +61,27 @@ public:
      * range 0-100). Returns false on failure.
      */
     bool encodeStream(SkWStream* stream, const SkBitmap& bm, int quality);
 
     static SkData* EncodeData(const SkImageInfo&, const void* pixels, size_t rowBytes,
                               Type, int quality);
     static SkData* EncodeData(const SkBitmap&, Type, int quality);
 
+    static SkData* EncodeData(const SkPixmap&, Type, int quality);
+
     static bool EncodeFile(const char file[], const SkBitmap&, Type,
                            int quality);
     static bool EncodeStream(SkWStream*, const SkBitmap&, Type,
                            int quality);
 
+    /** Uses SkImageEncoder to serialize images that are not already
+        encoded as SkImageEncoder::kPNG_Type images. */
+    static SkPixelSerializer* CreatePixelSerializer();
+
 protected:
     /**
      * Encode bitmap 'bm' in the desired format, writing results to
      * stream 'stream', at quality level 'quality' (which can be in
      * range 0-100).
      *
      * This must be overridden by each SkImageEncoder implementation.
      */
--- a/gfx/skia/skia/include/core/SkImageFilter.h
+++ b/gfx/skia/skia/include/core/SkImageFilter.h
@@ -37,43 +37,35 @@ public:
     public:
         struct Key;
         virtual ~Cache() {}
         static Cache* Create(size_t maxBytes);
         static Cache* Get();
         virtual bool get(const Key& key, SkBitmap* result, SkIPoint* offset) const = 0;
         virtual void set(const Key& key, const SkBitmap& result, const SkIPoint& offset) = 0;
         virtual void purge() {}
-    };
-
-    enum SizeConstraint {
-        kExact_SizeConstraint,
-        kApprox_SizeConstraint,
+        virtual void purgeByImageFilterId(uint32_t) {}
     };
 
     class Context {
     public:
-        Context(const SkMatrix& ctm, const SkIRect& clipBounds, Cache* cache,
-                SizeConstraint constraint)
+        Context(const SkMatrix& ctm, const SkIRect& clipBounds, Cache* cache)
             : fCTM(ctm)
             , fClipBounds(clipBounds)
             , fCache(cache)
-            , fSizeConstraint(constraint)
         {}
 
         const SkMatrix& ctm() const { return fCTM; }
         const SkIRect& clipBounds() const { return fClipBounds; }
         Cache* cache() const { return fCache; }
-        SizeConstraint sizeConstraint() const { return fSizeConstraint; }
 
     private:
         SkMatrix        fCTM;
         SkIRect         fClipBounds;
         Cache*          fCache;
-        SizeConstraint  fSizeConstraint;
     };
 
     class CropRect {
     public:
         enum CropEdge {
             kHasLeft_CropEdge   = 0x01,
             kHasTop_CropEdge    = 0x02,
             kHasWidth_CropEdge  = 0x04,
@@ -101,34 +93,41 @@ public:
          */
         bool applyTo(const SkIRect& imageBounds, const Context&, SkIRect* cropped) const;
 
     private:
         SkRect fRect;
         uint32_t fFlags;
     };
 
+    enum TileUsage {
+        kPossible_TileUsage,    //!< the created device may be drawn tiled
+        kNever_TileUsage,       //!< the created device will never be drawn tiled
+    };
+
     class Proxy {
     public:
         virtual ~Proxy() {}
 
-        virtual SkBaseDevice* createDevice(int width, int height) = 0;
+        virtual SkBaseDevice* createDevice(int width, int height,
+                                           TileUsage usage = kNever_TileUsage) = 0;
 
         // Returns true if the proxy handled the filter itself. If this returns
         // false then the filter's code will be called.
         virtual bool filterImage(const SkImageFilter*, const SkBitmap& src,
                                  const SkImageFilter::Context&,
                                  SkBitmap* result, SkIPoint* offset) = 0;
     };
 
     class DeviceProxy : public Proxy {
     public:
         DeviceProxy(SkBaseDevice* device) : fDevice(device) {}
 
-        SkBaseDevice* createDevice(int width, int height) override;
+        SkBaseDevice* createDevice(int width, int height,
+                                   TileUsage usage = kNever_TileUsage) override;
 
         // Returns true if the proxy handled the filter itself. If this returns
         // false then the filter's code will be called.
         bool filterImage(const SkImageFilter*, const SkBitmap& src, const SkImageFilter::Context&,
                          SkBitmap* result, SkIPoint* offset) override;
 
     private:
         SkBaseDevice* fDevice;
@@ -194,22 +193,17 @@ public:
         return this->isColorFilterNode(filterPtr);
     }
 
     /**
      *  Returns true (and optionally returns a ref'd filter) if this imagefilter can be completely
      *  replaced by the returned colorfilter. i.e. the two effects will affect drawing in the
      *  same way.
      */
-    bool asAColorFilter(SkColorFilter** filterPtr) const {
-        return this->countInputs() > 0 &&
-               NULL == this->getInput(0) &&
-               !this->affectsTransparentBlack() &&
-               this->isColorFilterNode(filterPtr);
-    }
+    bool asAColorFilter(SkColorFilter** filterPtr) const;
 
     /**
      *  Returns the number of inputs this filter will accept (some inputs can
      *  be NULL).
      */
     int countInputs() const { return fInputCount; }
 
     /**
@@ -235,45 +229,40 @@ public:
     bool cropRectIsSet() const { return fCropRect.flags() != 0x0; }
 
     CropRect getCropRect() const { return fCropRect; }
 
     // Default impl returns union of all input bounds.
     virtual void computeFastBounds(const SkRect&, SkRect*) const;
 
     // Can this filter DAG compute the resulting bounds of an object-space rectangle?
-    bool canComputeFastBounds() const;
+    virtual bool canComputeFastBounds() const;
 
     /**
      *  If this filter can be represented by another filter + a localMatrix, return that filter,
      *  else return null.
      */
     SkImageFilter* newWithLocalMatrix(const SkMatrix& matrix) const;
 
     /**
      * Create an SkMatrixImageFilter, which transforms its input by the given matrix.
      */
     static SkImageFilter* CreateMatrixFilter(const SkMatrix& matrix,
                                              SkFilterQuality,
                                              SkImageFilter* input = NULL);
 
 #if SK_SUPPORT_GPU
-    /**
-     * Wrap the given texture in a texture-backed SkBitmap.
-     */
-    static void WrapTexture(GrTexture* texture, int width, int height, SkBitmap* result);
-
     // Helper function which invokes GPU filter processing on the
     // input at the specified "index". If the input is null, it leaves
     // "result" and "offset" untouched, and returns true. If the input
     // has a GPU implementation, it will be invoked directly.
     // Otherwise, the filter will be processed in software and
     // uploaded to the GPU.
     bool filterInputGPU(int index, SkImageFilter::Proxy* proxy, const SkBitmap& src, const Context&,
-                        SkBitmap* result, SkIPoint* offset, bool relaxSizeConstraint = true) const;
+                        SkBitmap* result, SkIPoint* offset) const;
 #endif
 
     SK_TO_STRING_PUREVIRT()
     SK_DEFINE_FLATTENABLE_TYPE(SkImageFilter)
 
 protected:
     class Common {
     public:
@@ -346,24 +335,43 @@ protected:
     // Given the bounds of the destination rect to be filled in device
     // coordinates (first parameter), and the CTM, compute (conservatively)
     // which rect of the source image would be required (third parameter).
     // Used for clipping and temp-buffer allocations, so the result need not
     // be exact, but should never be smaller than the real answer. The default
     // implementation recursively unions all input bounds, or returns false if
     // no inputs.
     virtual bool onFilterBounds(const SkIRect&, const SkMatrix&, SkIRect*) const;
+    enum MapDirection {
+        kForward_MapDirection,
+        kReverse_MapDirection
+    };
+
+    /**
+     * Performs a forwards or reverse mapping of the given rect to accommodate
+     * this filter's margin requirements. kForward_MapDirection is used to
+     * determine the destination pixels which would be touched by filtering
+     * the given given source rect (e.g., given source bitmap bounds,
+     * determine the optimal bounds of the filtered offscreen bitmap).
+     * kReverse_MapDirection is used to determine which pixels of the
+     * input(s) would be required to fill the given destination rect
+     * (e.g., clip bounds). NOTE: these operations may not be the
+     * inverse of the other. For example, blurring expands the given rect
+     * in both forward and reverse directions. Unlike
+     * onFilterBounds(), this function is non-recursive.
+     */
+    virtual void onFilterNodeBounds(const SkIRect&, const SkMatrix&, SkIRect*, MapDirection) const;
 
     // Helper function which invokes filter processing on the input at the
     // specified "index". If the input is null, it leaves "result" and
     // "offset" untouched, and returns true. If the input is non-null, it
     // calls filterImage() on that input, and returns true on success.
     // i.e., return !getInput(index) || getInput(index)->filterImage(...);
     bool filterInput(int index, Proxy*, const SkBitmap& src, const Context&,
-                     SkBitmap* result, SkIPoint* offset, bool relaxSizeConstraint = true) const;
+                     SkBitmap* result, SkIPoint* offset) const;
 
     /**
      *  Return true (and return a ref'd colorfilter) if this node in the DAG is just a
      *  colorfilter w/o CropRect constraints.
      */
     virtual bool onIsColorFilterNode(SkColorFilter** /*filterPtr*/) const {
         return false;
     }
@@ -406,22 +414,22 @@ protected:
      *  parameters before they are used in the effect. Note that this function
      *  will be called with (NULL, NULL, SkMatrix::I()) to query for support,
      *  so returning "true" indicates support for all possible matrices.
      */
     virtual bool asFragmentProcessor(GrFragmentProcessor**, GrTexture*, const SkMatrix&,
                                      const SkIRect& bounds) const;
 
     /**
-     * Returns true if this filter can cause transparent black pixels to become
-     * visible (ie., alpha > 0). The default implementation returns false. This
-     * function is non-recursive, i.e., only queries this filter and not its
-     * inputs.
+     *  Creates a modified Context for use when recursing up the image filter DAG.
+     *  The clip bounds are adjusted to accommodate any margins that this
+     *  filter requires by calling this node's
+     *  onFilterNodeBounds(..., kReverse_MapDirection).
      */
-    virtual bool affectsTransparentBlack() const;
+    Context mapContext(const Context& ctx) const;
 
 private:
     friend class SkGraphics;
     static void PurgeCache();
 
     bool usesSrcInput() const { return fUsesSrcInput; }
 
     typedef SkFlattenable INHERITED;
--- a/gfx/skia/skia/include/core/SkImageGenerator.h
+++ b/gfx/skia/skia/include/core/SkImageGenerator.h
@@ -17,16 +17,22 @@ class GrTexture;
 class GrTextureParams;
 class SkBitmap;
 class SkData;
 class SkImageGenerator;
 class SkMatrix;
 class SkPaint;
 class SkPicture;
 
+#ifdef SK_SUPPORT_LEGACY_REFENCODEDDATA_NOCTX
+    #define SK_REFENCODEDDATA_CTXPARAM
+#else
+    #define SK_REFENCODEDDATA_CTXPARAM  GrContext* ctx
+#endif
+
 /**
  *  Takes ownership of SkImageGenerator.  If this method fails for
  *  whatever reason, it will return false and immediatetely delete
  *  the generator.  If it succeeds, it will modify destination
  *  bitmap.
  *
  *  If generator is NULL, will safely return false.
  *
@@ -59,22 +65,30 @@ public:
      *  will call the image generator's destructor.
      */
     virtual ~SkImageGenerator() { }
 
     uint32_t uniqueID() const { return fUniqueID; }
 
     /**
      *  Return a ref to the encoded (i.e. compressed) representation,
-     *  of this data.
+     *  of this data. If the GrContext is non-null, then the caller is only interested in
+     *  gpu-specific formats, so the impl may return null even if they have encoded data,
+     *  assuming they know it is not suitable for the gpu.
      *
      *  If non-NULL is returned, the caller is responsible for calling
      *  unref() on the data when it is finished.
      */
-    SkData* refEncodedData() { return this->onRefEncodedData(); }
+    SkData* refEncodedData(GrContext* ctx = nullptr) {
+#ifdef SK_SUPPORT_LEGACY_REFENCODEDDATA_NOCTX
+        return this->onRefEncodedData();
+#else
+        return this->onRefEncodedData(ctx);
+#endif
+    }
 
     /**
      *  Return the ImageInfo associated with this generator.
      */
     const SkImageInfo& getInfo() const { return fInfo; }
 
     /**
      *  Decode into the given pixels, a block of memory of size at
@@ -225,17 +239,17 @@ public:
         if (!this->tryGenerateBitmap(bm, &info, nullptr)) {
             sk_throw();
         }
     }
 
 protected:
     SkImageGenerator(const SkImageInfo& info);
 
-    virtual SkData* onRefEncodedData();
+    virtual SkData* onRefEncodedData(SK_REFENCODEDDATA_CTXPARAM);
 
     virtual bool onGetPixels(const SkImageInfo& info, void* pixels, size_t rowBytes,
                              SkPMColor ctable[], int* ctableCount);
     virtual bool onGetYUV8Planes(SkISize sizes[3], void* planes[3], size_t rowBytes[3]);
     virtual bool onGetYUV8Planes(SkISize sizes[3], void* planes[3], size_t rowBytes[3],
                                  SkYUVColorSpace* colorSpace);
 
     virtual GrTexture* onGenerateTexture(GrContext*, const SkIRect*) {
--- a/gfx/skia/skia/include/core/SkMask.h
+++ b/gfx/skia/skia/include/core/SkMask.h
@@ -12,16 +12,18 @@
 
 #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.
 */
 struct SkMask {
+    SkMask() : fImage(nullptr) {}
+
     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
         kARGB32_Format,         //!< SkPMColor
         kLCD16_Format,          //!< 565 alpha for r/g/b
     };
 
--- a/gfx/skia/skia/include/core/SkMaskFilter.h
+++ b/gfx/skia/skia/include/core/SkMaskFilter.h
@@ -179,19 +179,17 @@ protected:
     enum FilterReturn {
         kFalse_FilterReturn,
         kTrue_FilterReturn,
         kUnimplemented_FilterReturn
     };
 
     class NinePatch : ::SkNoncopyable {
     public:
-        NinePatch() : fCache(NULL) {
-            fMask.fImage = NULL;
-        }
+        NinePatch() : fCache(nullptr) { }
         ~NinePatch();
 
         SkMask      fMask;      // fBounds must have [0,0] in its top-left
         SkIRect     fOuterRect; // width/height must be >= fMask.fBounds'
         SkIPoint    fCenter;    // identifies center row/col for stretching
         SkCachedData* fCache;
     };
 
--- a/gfx/skia/skia/include/core/SkMatrix.h
+++ b/gfx/skia/skia/include/core/SkMatrix.h
@@ -630,36 +630,38 @@ public:
      */
     size_t readFromMemory(const void* buffer, size_t length);
 
     void dump() const;
     void toString(SkString*) const;
 
     /**
      * Calculates the minimum scaling factor of the matrix as computed from the SVD of the upper
-     * left 2x2. If the matrix has perspective -1 is returned.
+     * left 2x2. If the max scale factor cannot be computed (for example overflow or perspective)
+     * -1 is returned.
      *
-     * @return minumum scale factor
+     * @return minimum scale factor
      */
     SkScalar getMinScale() const;
 
     /**
      * Calculates the maximum scaling factor of the matrix as computed from the SVD of the upper
-     * left 2x2. If the matrix has perspective -1 is returned.
+     * left 2x2. If the max scale factor cannot be computed (for example overflow or perspective)
+     * -1 is returned.
      *
      * @return maximum scale factor
      */
     SkScalar getMaxScale() const;
 
     /**
      * Gets both the min and max scale factors. The min scale factor is scaleFactors[0] and the max
-     * is scaleFactors[1]. If the matrix has perspective false will be returned and scaleFactors
-     * will be unchanged.
+     * is scaleFactors[1]. If the min/max scale factors cannot be computed false is returned and the
+     * values of scaleFactors[] are undefined.
      */
-    bool getMinMaxScales(SkScalar scaleFactors[2]) const;
+    bool SK_WARN_UNUSED_RESULT getMinMaxScales(SkScalar scaleFactors[2]) const;
 
     /**
      *  Attempt to decompose this matrix into a scale-only component and whatever remains, where
      *  the scale component is to be applied first.
      *
      *  M -> Remaining * Scale
      *
      *  On success, return true and assign the scale and remaining components (assuming their
--- a/gfx/skia/skia/include/core/SkOSFile.h
+++ b/gfx/skia/skia/include/core/SkOSFile.h
@@ -36,16 +36,17 @@ size_t  sk_fgetsize(FILE*);
 bool    sk_frewind(FILE*);
 
 size_t  sk_fread(void* buffer, size_t byteCount, FILE*);
 size_t  sk_fwrite(const void* buffer, size_t byteCount, FILE*);
 
 char*   sk_fgets(char* str, int size, FILE* f);
 
 void    sk_fflush(FILE*);
+void    sk_fsync(FILE*);
 
 bool    sk_fseek(FILE*, size_t);
 bool    sk_fmove(FILE*, long);
 size_t  sk_ftell(FILE*);
 
 /** Maps a file into memory. Returns the address and length on success, NULL otherwise.
  *  The mapping is read only.
  *  When finished with the mapping, free the returned pointer with sk_fmunmap.
--- a/gfx/skia/skia/include/core/SkPaint.h
+++ b/gfx/skia/skia/include/core/SkPaint.h
@@ -627,23 +627,16 @@ public:
 
     SkImageFilter* getImageFilter() const { return fImageFilter; }
     SkImageFilter* setImageFilter(SkImageFilter*);
 
     SkAnnotation* getAnnotation() const { return fAnnotation; }
     SkAnnotation* setAnnotation(SkAnnotation*);
 
     /**
-     *  Returns true if there is an annotation installed on this paint, and
-     *  the annotation specifics no-drawing.
-     */
-    SK_ATTR_DEPRECATED("use getAnnotation and check for non-null")
-    bool isNoDrawAnnotation() const { return this->getAnnotation() != NULL; }
-
-    /**
      *  Return the paint's SkDrawLooper (if any). Does not affect the looper's
      *  reference count.
      */
     SkDrawLooper* getLooper() const { return fLooper; }
 
     /**
      *  Set or clear the looper object.
      *  <p />
@@ -1084,21 +1077,20 @@ private:
         return kMag2Max;
     }
 
     friend class SkAutoGlyphCache;
     friend class SkAutoGlyphCacheNoGamma;
     friend class SkCanvas;
     friend class SkDraw;
     friend class SkPDFDevice;
-    friend class GrBitmapTextContext;
+    friend class GrAtlasTextBlob;
     friend class GrAtlasTextContext;
-    friend class GrDistanceFieldTextContext;
     friend class GrStencilAndCoverTextContext;
     friend class GrPathRendering;
-    friend class GrTextContext;
+    friend class GrTextUtils;
     friend class GrGLPathRendering;
     friend class SkScalerContext;
     friend class SkTextToPathIter;
     friend class SkCanonicalizePaint;
 };
 
 #endif
--- a/gfx/skia/skia/include/core/SkPath.h
+++ b/gfx/skia/skia/include/core/SkPath.h
@@ -951,16 +951,24 @@ public:
             @param  pts The points representing the current verb and/or segment
                         This must not be NULL.
             @return The verb for the current segment
         */
         Verb next(SkPoint pts[4]) {
             return (Verb) fRawIter.next(pts);
         }
 
+        /** Return what the next verb will be, but do not visit the next segment.
+
+            @return The verb for the next segment
+        */
+        Verb peek() const {
+            return (Verb) fRawIter.peek();
+        }
+
         SkScalar conicWeight() const {
             return fRawIter.conicWeight();
         }
 
     private:
         SkPathRef::Iter fRawIter;
         friend class SkPath;
     };
--- a/gfx/skia/skia/include/core/SkPathMeasure.h
+++ b/gfx/skia/skia/include/core/SkPathMeasure.h
@@ -84,18 +84,22 @@ private:
     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; // index into the fPts array
+        unsigned    fPtIndex; // index into the fPts array
+#ifdef SK_SUPPORT_LEGACY_PATH_MEASURE_TVALUE
         unsigned    fTValue : 15;
+#else
+        unsigned    fTValue : 30;
+#endif
         unsigned    fType : 2;
 
         SkScalar getScalarT() const;
     };
     SkTDArray<Segment>  fSegments;
     SkTDArray<SkPoint>  fPts; // Points used to define the segments
 
     static const Segment* NextSegment(const Segment*);
--- a/gfx/skia/skia/include/core/SkPathRef.h
+++ b/gfx/skia/skia/include/core/SkPathRef.h
@@ -119,16 +119,17 @@ public:
         /** Return the next verb in this iteration of the path. When all
             segments have been visited, return kDone_Verb.
 
             @param  pts The points representing the current verb and/or segment
                         This must not be NULL.
             @return The verb for the current segment
         */
         uint8_t next(SkPoint pts[4]);
+        uint8_t peek() const;
 
         SkScalar conicWeight() const { return *fConicWeights; }
 
     private:
         const SkPoint*  fPts;
         const uint8_t*  fVerbs;
         const uint8_t*  fVerbStop;
         const SkScalar* fConicWeights;
--- a/gfx/skia/skia/include/core/SkPixelRef.h
+++ b/gfx/skia/skia/include/core/SkPixelRef.h
@@ -220,17 +220,18 @@ public:
      *  If colorSpace is not NULL, the YUV color space of the data should be stored in the address
      *  it points at.
      */
     bool getYUV8Planes(SkISize sizes[3], void* planes[3], size_t rowBytes[3],
                        SkYUVColorSpace* colorSpace) {
         return this->onGetYUV8Planes(sizes, planes, rowBytes, colorSpace);
     }
 
-    bool readPixels(SkBitmap* dst, const SkIRect* subset = NULL);
+    /** Populates dst with the pixels of this pixelRef, converting them to colorType. */
+    bool readPixels(SkBitmap* dst, SkColorType colorType, const SkIRect* subset = NULL);
 
     /**
      *  Makes a deep copy of this PixelRef, respecting the requested config.
      *  @param colorType Desired colortype.
      *  @param profileType Desired colorprofiletype.
      *  @param subset Subset of this PixelRef to copy. Must be fully contained within the bounds of
      *         of this PixelRef.
      *  @return A new SkPixelRef, or NULL if either there is an error (e.g. the destination could
@@ -294,17 +295,17 @@ protected:
     virtual bool onLockPixelsAreWritable() const;
 
     /**
      *  For pixelrefs that don't have access to their raw pixels, they may be
      *  able to make a copy of them (e.g. if the pixels are on the GPU).
      *
      *  The base class implementation returns false;
      */
-    virtual bool onReadPixels(SkBitmap* dst, const SkIRect* subsetOrNull);
+    virtual bool onReadPixels(SkBitmap* dst, SkColorType colorType, const SkIRect* subsetOrNull);
 
     // default impl returns NULL.
     virtual SkData* onRefEncodedData();
 
     // default impl does nothing.
     virtual void onNotifyPixelsChanged();
 
     // default impl returns false.
--- a/gfx/skia/skia/include/core/SkPixelSerializer.h
+++ b/gfx/skia/skia/include/core/SkPixelSerializer.h
@@ -4,19 +4,19 @@
  * Use of this source code is governed by a BSD-style license that can be
  * found in the LICENSE file.
  */
 
 #ifndef SkPixelSerializer_DEFINED
 #define SkPixelSerializer_DEFINED
 
 #include "SkRefCnt.h"
+#include "SkPixmap.h"
 
 class SkData;
-struct SkImageInfo;
 
 /**
  *  Interface for serializing pixels, e.g. SkBitmaps in an SkPicture.
  */
 class SkPixelSerializer : public SkRefCnt {
 public:
     virtual ~SkPixelSerializer() {}
 
@@ -27,26 +27,24 @@ public:
     bool useEncodedData(const void* data, size_t len) {
         return this->onUseEncodedData(data, len);
     }
 
     /**
      *  Call to get the client's version of encoding these pixels. If it
      *  returns NULL, serialize the raw pixels.
      */
-    SkData* encodePixels(const SkImageInfo& info, const void* pixels, size_t rowBytes) {
-        return this->onEncodePixels(info, pixels, rowBytes);
-    }
+    SkData* encode(const SkPixmap& pixmap) { return this->onEncode(pixmap); }
 
 protected:
     /**
      *  Return true if you want to serialize the encoded data, false if you want
-     *  another version serialized (e.g. the result of encodePixels).
+     *  another version serialized (e.g. the result of this->encode()).
      */
     virtual bool onUseEncodedData(const void* data, size_t len) = 0;
 
     /**
      *  If you want to encode these pixels, return the encoded data as an SkData
      *  Return null if you want to serialize the raw pixels.
      */
-    virtual SkData* onEncodePixels(const SkImageInfo&, const void* pixels, size_t rowBytes) = 0;
+    virtual SkData* onEncode(const SkPixmap&) = 0;
 };
 #endif // SkPixelSerializer_DEFINED
--- a/gfx/skia/skia/include/core/SkPostConfig.h
+++ b/gfx/skia/skia/include/core/SkPostConfig.h
@@ -295,24 +295,16 @@
 #if !defined(SK_ALWAYS_INLINE)
 #  if defined(SK_BUILD_FOR_WIN)
 #    define SK_ALWAYS_INLINE __forceinline
 #  else
 #    define SK_ALWAYS_INLINE SK_ATTRIBUTE(always_inline) inline
 #  endif
 #endif
 
-#if defined(_MSC_VER) && SK_CPU_SSE_LEVEL >= SK_CPU_SSE_LEVEL_SSE2
-    #define SK_VECTORCALL __vectorcall
-#elif defined(SK_CPU_ARM32)
-    #define SK_VECTORCALL __attribute__((pcs("aapcs-vfp")))
-#else
-    #define SK_VECTORCALL
-#endif
-
 //////////////////////////////////////////////////////////////////////
 
 #if SK_CPU_SSE_LEVEL >= SK_CPU_SSE_LEVEL_SSE1
     #define SK_PREFETCH(ptr)       _mm_prefetch(reinterpret_cast<const char*>(ptr), _MM_HINT_T0)
     #define SK_WRITE_PREFETCH(ptr) _mm_prefetch(reinterpret_cast<const char*>(ptr), _MM_HINT_T0)
 #elif defined(__GNUC__)
     #define SK_PREFETCH(ptr)       __builtin_prefetch(ptr)
     #define SK_WRITE_PREFETCH(ptr) __builtin_prefetch(ptr, 1)
--- a/gfx/skia/skia/include/core/SkPreConfig.h
+++ b/gfx/skia/skia/include/core/SkPreConfig.h
@@ -25,17 +25,18 @@
     #endif
 
     #if defined(WIN32) || defined(__SYMBIAN32__)
         #define SK_BUILD_FOR_WIN32
     #elif defined(ANDROID)
         #define SK_BUILD_FOR_ANDROID
     #elif defined(linux) || defined(__linux) || defined(__FreeBSD__) || \
           defined(__OpenBSD__) || defined(__sun) || defined(__NetBSD__) || \
-          defined(__DragonFly__) || defined(__GLIBC__) || defined(__GNU__)
+          defined(__DragonFly__) || defined(__GLIBC__) || defined(__GNU__) || \
+          defined(__unix__)
         #define SK_BUILD_FOR_UNIX
     #elif TARGET_OS_IPHONE || TARGET_IPHONE_SIMULATOR
         #define SK_BUILD_FOR_IOS
     #else
         #define SK_BUILD_FOR_MAC
     #endif
 
 #endif
--- a/gfx/skia/skia/include/core/SkRRect.h
+++ b/gfx/skia/skia/include/core/SkRRect.h
@@ -148,16 +148,22 @@ public:
     }
     
     static SkRRect MakeOval(const SkRect& oval) {
         SkRRect rr;
         rr.setOval(oval);
         return rr;
     }
 
+    static SkRRect MakeRectXY(const SkRect& rect, SkScalar xRad, SkScalar yRad) {
+        SkRRect rr;
+        rr.setRectXY(rect, xRad, yRad);
+        return rr;
+    }
+
     /**
      * Set this RR to match the supplied oval. All x radii will equal half the
      * width and all y radii will equal half the height.
      */
     void setOval(const SkRect& oval) {
         fRect = oval;
         fRect.sort();
 
--- a/gfx/skia/skia/include/core/SkRect.h
+++ b/gfx/skia/skia/include/core/SkRect.h
@@ -820,34 +820,16 @@ public:
      */
     void round(SkIRect* dst) const {
         SkASSERT(dst);
         dst->set(SkScalarRoundToInt(fLeft), SkScalarRoundToInt(fTop),
                  SkScalarRoundToInt(fRight), SkScalarRoundToInt(fBottom));
     }
 
     /**
-     *  Variant of round() that explicitly performs the rounding step (i.e. floor(x + 0.5)) using
-     *  double instead of SkScalar (float). It does this by calling SkDScalarRoundToInt(), which
-     *  may be slower than calling SkScalarRountToInt(), but gives slightly more accurate results.
-     *
-     *  e.g.
-     *      SkScalar x = 0.49999997f;
-     *      int ix = SkScalarRoundToInt(x);
-     *      SkASSERT(0 == ix);  // <--- fails
-     *      ix = SkDScalarRoundToInt(x);
-     *      SkASSERT(0 == ix);  // <--- succeeds
-     */
-    void dround(SkIRect* dst) const {
-        SkASSERT(dst);
-        dst->set(SkDScalarRoundToInt(fLeft), SkDScalarRoundToInt(fTop),
-                 SkDScalarRoundToInt(fRight), SkDScalarRoundToInt(fBottom));
-    }
-
-    /**
      *  Set the dst rectangle by rounding "out" this rectangle, choosing the
      *  SkScalarFloor of top and left, and the SkScalarCeil of right and bottom.
      */
     void roundOut(SkIRect* dst) const {
         SkASSERT(dst);
         dst->set(SkScalarFloorToInt(fLeft), SkScalarFloorToInt(fTop),
                  SkScalarCeilToInt(fRight), SkScalarCeilToInt(fBottom));
     }
--- a/gfx/skia/skia/include/core/SkRefCnt.h
+++ b/gfx/skia/skia/include/core/SkRefCnt.h
@@ -211,17 +211,17 @@ public:
     //   - ref() doesn't need any barrier;
     //   - unref() needs a release barrier, and an acquire if it's going to call delete.
 
     bool unique() const { return 1 == sk_atomic_load(&fRefCnt, sk_memory_order_acquire); }
     void    ref() const { (void)sk_atomic_fetch_add(&fRefCnt, +1, sk_memory_order_relaxed); }
     void  unref() const {
         if (1 == sk_atomic_fetch_add(&fRefCnt, -1, sk_memory_order_acq_rel)) {
             SkDEBUGCODE(fRefCnt = 1;)  // restore the 1 for our destructor's assert
-                    delete (const Derived*)this;
+            delete (const Derived*)this;
         }
     }
     void  deref() const { this->unref(); }
 
 private:
     mutable int32_t fRefCnt;
 };
 
--- a/gfx/skia/skia/include/core/SkShader.h
+++ b/gfx/skia/skia/include/core/SkShader.h
@@ -10,16 +10,17 @@
 
 #include "SkBitmap.h"
 #include "SkFlattenable.h"
 #include "SkMask.h"
 #include "SkMatrix.h"
 #include "SkPaint.h"
 #include "../gpu/GrColor.h"
 
+class SkColorFilter;
 class SkPath;
 class SkPicture;
 class SkXfermode;
 class GrContext;
 class GrFragmentProcessor;
 
 /** \class SkShader
  *
@@ -67,41 +68,24 @@ public:
     enum {
         kTileModeCount = kMirror_TileMode + 1
     };
 
     // override these in your subclass
 
     enum Flags {
         //!< set if all of the colors will be opaque
-        kOpaqueAlpha_Flag  = 0x01,
-
-        //! set if this shader's shadeSpan16() method can be called
-        kHasSpan16_Flag = 0x02,
-
-        /** Set this bit if the shader's native data type is instrinsically 16
-            bit, meaning that calling the 32bit shadeSpan() entry point will
-            mean the the impl has to up-sample 16bit data into 32bit. Used as a
-            a means of clearing a dither request if the it will have no effect
-        */
-        kIntrinsicly16_Flag = 0x04,
+        kOpaqueAlpha_Flag = 1 << 0,
 
         /** set if the spans only vary in X (const in Y).
             e.g. an Nx1 bitmap that is being tiled in Y, or a linear-gradient
             that varies from left-to-right. This flag specifies this for
             shadeSpan().
          */
-        kConstInY32_Flag = 0x08,
-
-        /** same as kConstInY32_Flag, but is set if this is true for shadeSpan16
-            which may not always be the case, since shadeSpan16 may be
-            predithered, which would mean it was not const in Y, even though
-            the 32bit shadeSpan() would be const.
-         */
-        kConstInY16_Flag = 0x10
+        kConstInY32_Flag = 1 << 1,
     };
 
     /**
      *  Returns true if the shader is guaranteed to produce only opaque
      *  colors, subject to the SkPaint using the shader to apply an opaque
      *  alpha value. Subclasses should override this to allow some
      *  optimizations.
      */
@@ -132,52 +116,36 @@ public:
          *  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() const { 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 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;
 
-        typedef void (*ShadeProc)(void* ctx, int x, int y, SkPMColor[], int count);
+        /**
+         * The const void* ctx is only const because all the implementations are const.
+         * This can be changed to non-const if a new shade proc needs to change the ctx.
+         */
+        typedef void (*ShadeProc)(const void* ctx, int x, int y, SkPMColor[], int count);
         virtual ShadeProc asAShadeProc(void** ctx);
 
         /**
-         *  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());
-        }
-
         // Notification from blitter::blitMask in case we need to see the non-alpha channels
         virtual void set3DMask(const SkMask*) {}
 
     protected:
         // Reference to shader, so we don't have to dupe information.
         const SkShader& fShader;
 
         enum MatrixClass {
@@ -211,23 +179,16 @@ public:
      *  Return the size of a Context returned by createContext.
      *
      *  Override this if your subclass overrides createContext, to return the correct size of
      *  your subclass' context.
      */
     virtual size_t contextSize() const;
 
     /**
-     *  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;
-    }
-
-    /**
      *  Returns true if this shader is just a bitmap, and if not null, returns the bitmap,
      *  localMatrix, and tilemodes. If this is not a bitmap, returns false and ignores the
      *  out-parameters.
      */
     bool isABitmap(SkBitmap* outTexture, SkMatrix* outMatrix, TileMode xy[2]) const {
         return this->onIsABitmap(outTexture, outMatrix, xy);
     }
 
@@ -337,18 +298,33 @@ public:
     /**
      *  If the shader is a custom shader which has data the caller might want, call this function
      *  to get that data.
      */
     virtual bool asACustomShader(void** /* customData */) const { return false; }
 #endif
 
     //////////////////////////////////////////////////////////////////////////
+    //  Methods to create combinations or variants of shaders
+
+    /**
+     *  Return a shader that will apply the specified localMatrix to this shader.
+     *  The specified matrix will be applied before any matrix associated with this shader.
+     */
+    SkShader* newWithLocalMatrix(const SkMatrix&) const;
+
+    /**
+     *  Create a new shader that produces the same colors as invoking this shader and then applying
+     *  the colorfilter.
+     */
+    SkShader* newWithColorFilter(SkColorFilter*) const;
+    
+    //////////////////////////////////////////////////////////////////////////
     //  Factory methods for stock shaders
-
+    
     /**
      *  Call this to create a new "empty" shader, that will not draw anything.
      */
     static SkShader* CreateEmptyShader();
 
     /**
      *  Call this to create a new shader that just draws the specified color. This should always
      *  draw the same as a paint with this color (and no shader).
@@ -390,24 +366,16 @@ public:
      *  @return     Returns a new shader object. Note: this function never returns null.
     */
     static SkShader* CreatePictureShader(const SkPicture* src,
                                          TileMode tmx, TileMode tmy,
                                          const SkMatrix* localMatrix,
                                          const SkRect* tile);
 
     /**
-     *  Return a shader that will apply the specified localMatrix to the proxy shader.
-     *  The specified matrix will be applied before any matrix associated with the proxy.
-     *
-     *  Note: ownership of the proxy is not transferred (though a ref is taken).
-     */
-    static SkShader* CreateLocalMatrixShader(SkShader* proxy, const SkMatrix& localMatrix);
-
-    /**
      *  If this shader can be represented by another shader + a localMatrix, return that shader
      *  and, if not NULL, the localMatrix. If not, return NULL and ignore the localMatrix parameter.
      *
      *  Note: the returned shader (if not NULL) will have been ref'd, and it is the responsibility
      *  of the caller to balance that with unref() when they are done.
      */
     virtual SkShader* refAsALocalMatrixShader(SkMatrix* localMatrix) const;
 
--- a/gfx/skia/skia/include/core/SkStream.h
+++ b/gfx/skia/skia/include/core/SkStream.h
@@ -60,27 +60,28 @@ public:
      *  @return the actual number bytes that could be skipped.
      */
     size_t skip(size_t size) {
         return this->read(NULL, size);
     }
 
     /**
      *  Attempt to peek at size bytes.
-     *  If this stream supports peeking, and it can peek size bytes, copy size
-     *  bytes into buffer, and return true.
-     *  If the stream does not support peeking, or cannot peek size bytes,
-     *  return false and leave buffer unchanged.
+     *  If this stream supports peeking, copy min(size, peekable bytes) into
+     *  buffer, and return the number of bytes copied.
+     *  If the stream does not support peeking, or cannot peek any bytes,
+     *  return 0 and leave buffer unchanged.
      *  The stream is guaranteed to be in the same visible state after this
      *  call, regardless of success or failure.
-     *  @param buffer Must not be NULL. Destination to copy bytes.
+     *  @param buffer Must not be NULL, and must be at least size bytes. Destination
+     *      to copy bytes.
      *  @param size Number of bytes to copy.
-     *  @return Whether the peek was performed.
+     *  @return The number of bytes peeked/copied.
      */
-    virtual bool peek(void* /* buffer */, size_t /* size */) const { return false; }
+    virtual size_t peek(void* /*buffer*/, size_t /*size*/) const { return 0; }
 
     /** Returns true when all the bytes in the stream have been read.
      *  This may return true early (when there are no more bytes to be read)
      *  or late (after the first unsuccessful read).
      */
     virtual bool isAtEnd() const = 0;
 
     int8_t   readS8();
@@ -320,17 +321,17 @@ public:
     SkData* setData(SkData*);
 
     void skipToAlign4();
     const void* getAtPos();
 
     size_t read(void* buffer, size_t size) override;
     bool isAtEnd() const override;
 
-    bool peek(void* buffer, size_t size) const override;
+    size_t peek(void* buffer, size_t size) const override;
 
     bool rewind() override;
     SkMemoryStream* duplicate() const override;
 
     size_t getPosition() const override;
     bool seek(size_t position) override;
     bool move(long offset) override;
     SkMemoryStream* fork() const override;
@@ -354,16 +355,17 @@ public:
     virtual ~SkFILEWStream();
 
     /** Returns true if the current path could be opened.
     */
     bool isValid() const { return fFILE != NULL; }
 
     bool write(const void* buffer, size_t size) override;
     void flush() override;
+    void fsync();
     size_t bytesWritten() const override;
 
 private:
     FILE* fFILE;
 
     typedef SkWStream INHERITED;
 };
 
--- a/gfx/skia/skia/include/core/SkString.h
+++ b/gfx/skia/skia/include/core/SkString.h
@@ -262,12 +262,27 @@ private:
 SkString SkStringPrintf(const char* format, ...);
 
 // Specialized to take advantage of SkString's fast swap path. The unspecialized function is
 // declared in SkTypes.h and called by SkTSort.
 template <> inline void SkTSwap(SkString& a, SkString& b) {
     a.swap(b);
 }
 
+enum SkStrSplitMode {
+    // Strictly return all results. If the input is ",," and the separator is ',' this will return
+    // an array of three empty strings.
+    kStrict_SkStrSplitMode,
+
+    // Only nonempty results will be added to the results. Multiple separators will be
+    // coalesced. Separators at the beginning and end of the input will be ignored.  If the input is
+    // ",," and the separator is ',', this will return an empty vector.
+    kCoalesce_SkStrSplitMode
+};
+
 // Split str on any characters in delimiters into out.  (Think, strtok with a sane API.)
-void SkStrSplit(const char* str, const char* delimiters, SkTArray<SkString>* out);
+void SkStrSplit(const char* str, const char* delimiters, SkStrSplitMode splitMode,
+                SkTArray<SkString>* out);
+inline void SkStrSplit(const char* str, const char* delimiters, SkTArray<SkString>* out) {
+    SkStrSplit(str, delimiters, kCoalesce_SkStrSplitMode, out);
+}
 
 #endif
--- a/gfx/skia/skia/include/core/SkTArray.h
+++ b/gfx/skia/skia/include/core/SkTArray.h
@@ -7,32 +7,33 @@
 
 #ifndef SkTArray_DEFINED
 #define SkTArray_DEFINED
 
 #include "../private/SkTemplates.h"
 #include "SkTypes.h"
 
 #include <new>
+#include <utility>
 
 template <typename T, bool MEM_COPY = false> class SkTArray;
 
 namespace SkTArrayExt {
 
 template<typename T>
 inline void copy(SkTArray<T, true>* self, int dst, int src) {
     memcpy(&self->fItemArray[dst], &self->fItemArray[src], sizeof(T));
 }
 template<typename T>
 inline void copy(SkTArray<T, true>* self, const T* array) {
-    memcpy(self->fMemArray, array, self->fCount * sizeof(T));
+    sk_careful_memcpy(self->fMemArray, array, self->fCount * sizeof(T));
 }
 template<typename T>
 inline void copyAndDelete(SkTArray<T, true>* self, char* newMemArray) {
-    memcpy(newMemArray, self->fMemArray, self->fCount * sizeof(T));
+    sk_careful_memcpy(newMemArray, self->fMemArray, self->fCount * sizeof(T));
 }
 
 template<typename T>
 inline void copy(SkTArray<T, false>* self, int dst, int src) {
     new (&self->fItemArray[dst]) T(self->fItemArray[src]);
 }
 template<typename T>
 inline void copy(SkTArray<T, false>* self, const T* array) {
@@ -193,17 +194,17 @@ public:
         return *newT;
     }
 
     /**
      *  Construct a new T at the back of this array.
      */
     template<class... Args> T& emplace_back(Args&&... args) {
         T* newT = reinterpret_cast<T*>(this->push_back_raw(1));
-        return *new (newT) T(skstd::forward<Args>(args)...);
+        return *new (newT) T(std::forward<Args>(args)...);
     }
 
     /**
      * Allocates n more default-initialized T values, and returns the address of
      * the start of that new range. Note: this address is only valid until the
      * next API call made on the array that might add or remove elements.
      */
     T* push_back_n(int n) {
--- a/gfx/skia/skia/include/core/SkTDArray.h
+++ b/gfx/skia/skia/include/core/SkTDArray.h
@@ -40,17 +40,17 @@ public:
     }
 
     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);
+                sk_careful_memcpy(fArray, src.fArray, sizeof(T) * src.fCount);
                 fCount = src.fCount;
             }
         }
         return *this;
     }
 
     friend bool operator==(const SkTDArray<T>& a, const SkTDArray<T>& b) {
         return  a.fCount == b.fCount &&
--- a/gfx/skia/skia/include/core/SkTLazy.h
+++ b/gfx/skia/skia/include/core/SkTLazy.h
@@ -6,16 +6,17 @@
  */
 
 #ifndef SkTLazy_DEFINED
 #define SkTLazy_DEFINED
 
 #include "../private/SkTemplates.h"
 #include "SkTypes.h"
 #include <new>
+#include <utility>
 
 /**
  *  Efficient way to defer allocating/initializing a class until it is needed
  *  (if ever).
  */
 template <typename T> class SkTLazy {
 public:
     SkTLazy() : fPtr(NULL) {}
@@ -45,17 +46,17 @@ public:
      *  If a previous instance had been initialized (either from init() or
      *  set()) it will first be destroyed, so that a freshly initialized
      *  instance is always returned.
      */
     template <typename... Args> T* init(Args&&... args) {
         if (this->isValid()) {
             fPtr->~T();
         }
-        fPtr = new (SkTCast<T*>(fStorage.get())) T(skstd::forward<Args>(args)...);
+        fPtr = new (SkTCast<T*>(fStorage.get())) T(std::forward<Args>(args)...);
         return fPtr;
     }
 
     /**
      *  Copy src into this, and return a pointer to a copy of it. Note this
      *  will always return the same pointer, so if it is called on a lazy that
      *  has already been initialized, then this will copy over the previous
      *  contents.
@@ -125,16 +126,18 @@ private:
  *
  * consume_a_thing(thing); // could be constThing or a modified copy.
  */
 template <typename T>
 class SkTCopyOnFirstWrite {
 public:
     SkTCopyOnFirstWrite(const T& initial) : fObj(&initial) {}
 
+    SkTCopyOnFirstWrite(const T* initial) : fObj(initial) {}
+
     // Constructor for delayed initialization.
     SkTCopyOnFirstWrite() : fObj(NULL) {}
 
     // Should only be called once, and only if the default constructor was used.
     void init(const T& initial) {
         SkASSERT(NULL == fObj);
         SkASSERT(!fLazy.isValid());
         fObj = &initial;
--- a/gfx/skia/skia/include/core/SkTime.h
+++ b/gfx/skia/skia/include/core/SkTime.h
@@ -33,20 +33,16 @@ public:
         void toISO8601(SkString* dst) const;
     };
     static void GetDateTime(DateTime*);
 
     static SkMSec GetMSecs() { return (SkMSec)(GetNSecs() * 1e-6); }
     static double GetNSecs();
 };
 
-#if defined(SK_DEBUG) && defined(SK_BUILD_FOR_WIN32)
-    extern SkMSec gForceTickCount;
-#endif
-
 #define SK_TIME_FACTOR      1
 
 ///////////////////////////////////////////////////////////////////////////////
 
 class SkAutoTime {
 public:
     // The label is not deep-copied, so its address must remain valid for the
     // lifetime of this object
--- a/gfx/skia/skia/include/core/SkTypes.h
+++ b/gfx/skia/skia/include/core/SkTypes.h
@@ -19,16 +19,38 @@
     #include <arm_neon.h>
 #elif SK_CPU_SSE_LEVEL >= SK_CPU_SSE_LEVEL_SSE2
     #include <immintrin.h>
 #endif
 // IWYU pragma: end_exports
 
 #include <string.h>
 
+/**
+ *  sk_careful_memcpy() is just like memcpy(), but guards against undefined behavior.
+ *
+ * It is undefined behavior to call memcpy() with null dst or src, even if len is 0.
+ * If an optimizer is "smart" enough, it can exploit this to do unexpected things.
+ *     memcpy(dst, src, 0);
+ *     if (src) {
+ *         printf("%x\n", *src);
+ *     }
+ * In this code the compiler can assume src is not null and omit the if (src) {...} check,
+ * unconditionally running the printf, crashing the program if src really is null.
+ * Of the compilers we pay attention to only GCC performs this optimization in practice.
+ */
+static inline void* sk_careful_memcpy(void* dst, const void* src, size_t len) {
+    // When we pass >0 len we had better already be passing valid pointers.
+    // So we just need to skip calling memcpy when len == 0.
+    if (len) {
+        memcpy(dst,src,len);
+    }
+    return dst;
+}
+
 /** \file SkTypes.h
 */
 
 /** See SkGraphics::GetVersion() to retrieve these at runtime
  */
 #define SKIA_VERSION_MAJOR  1
 #define SKIA_VERSION_MINOR  0
 #define SKIA_VERSION_PATCH  0
@@ -73,17 +95,20 @@ SK_API extern void sk_free(void*);
 SK_API extern void* sk_calloc(size_t size);
 
 /** Same as sk_calloc, but throws an exception instead of returning NULL on failure.
  */
 SK_API extern void* sk_calloc_throw(size_t size);
 
 // bzero is safer than memset, but we can't rely on it, so... sk_bzero()
 static inline void sk_bzero(void* buffer, size_t size) {
-    memset(buffer, 0, size);
+    // Please c.f. sk_careful_memcpy.  It's undefined behavior to call memset(null, 0, 0).
+    if (size) {
+        memset(buffer, 0, size);
+    }
 }
 
 ///////////////////////////////////////////////////////////////////////////////
 
 #ifdef override_GLOBAL_NEW
 #include <new>
 
 inline void* operator new(size_t size) {
@@ -218,22 +243,16 @@ typedef int S16CPU;
 
 /**
  *  Fast type for unsigned 16 bits. Use for parameter passing and local
  *  variables, not for storage
  */
 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 uint8_t SkBool8;
 
 #ifdef SK_DEBUG
     SK_API int8_t      SkToS8(intmax_t);
     SK_API uint8_t     SkToU8(uintmax_t);
     SK_API int16_t     SkToS16(intmax_t);
@@ -252,17 +271,17 @@ typedef uint8_t SkBool8;
     #define SkToU32(x)  ((uint32_t)(x))
     #define SkToInt(x)  ((int)(x))
     #define SkToUInt(x) ((unsigned)(x))
     #define SkToSizeT(x) ((size_t)(x))
 #endif
 
 /** Returns 0 or 1 based on the condition
 */
-#define SkToBool(cond)  ((cond) != 0)
+#define SkToBool(cond)  (!!(cond))
 
 #define SK_MaxS16   32767
 #define SK_MinS16   -32767
 #define SK_MaxU16   0xFFFF
 #define SK_MinU16   0
 #define SK_MaxS32   0x7FFFFFFF
 #define SK_MinS32   -SK_MaxS32
 #define SK_MaxU32   0xFFFFFFFF
@@ -276,16 +295,24 @@ static inline bool SkIsS16(long x) {
 }
 
 /** Returns true if the value can be represented with unsigned 16bits
  */
 static inline bool SkIsU16(long x) {
     return (uint16_t)x == x;
 }
 
+static inline int32_t SkLeftShift(int32_t value, int32_t shift) {
+    return (int32_t) ((uint32_t) value << shift);
+}
+
+static inline int64_t SkLeftShift(int64_t value, int32_t shift) {
+    return (int64_t) ((uint64_t) value << shift);
+}
+
 //////////////////////////////////////////////////////////////////////////////
 
 /** Returns the number of entries in an array (not a pointer) */
 template <typename T, size_t N> char (&SkArrayCountHelper(T (&array)[N]))[N];
 #define SK_ARRAY_COUNT(array) (sizeof(SkArrayCountHelper(array)))
 
 // Can be used to bracket data types that must be dense, e.g. hash keys.
 #if defined(__clang__)  // This should work on GCC too, but GCC diagnostic pop didn't seem to work!
@@ -403,27 +430,16 @@ static inline int32_t SkFastMin32(int32_
     return value;
 }
 
 /** Returns value pinned between min and max, inclusively. */
 template <typename T> static inline const T& SkTPin(const T& value, const T& min, const T& max) {
     return SkTMax(SkTMin(value, max), min);
 }
 
-static inline uint32_t SkSetClearShift(uint32_t bits, bool cond,
-                                       unsigned shift) {
-    SkASSERT((int)cond == 0 || (int)cond == 1);
-    return (bits & ~(1 << shift)) | ((int)cond << shift);
-}
-
-static inline uint32_t SkSetClearMask(uint32_t bits, bool cond,
-                                      uint32_t mask) {
-    return cond ? bits | mask : bits & ~mask;
-}
-
 ///////////////////////////////////////////////////////////////////////////////
 
 /** Use to combine multiple bits in a bitmask in a type safe way.
  */
 template <typename T>
 T SkTBitOr(T a, T b) {
     return (T)(a | b);
 }
--- a/gfx/skia/skia/include/core/SkWriter32.h
+++ b/gfx/skia/skia/include/core/SkWriter32.h
@@ -160,17 +160,17 @@ public:
     }
 
     /**
      *  Write size bytes from values. size must be a multiple of 4, though
      *  values need not be 4-byte aligned.
      */
     void write(const void* values, size_t size) {
         SkASSERT(SkAlign4(size) == size);
-        memcpy(this->reserve(size), values, size);
+        sk_careful_memcpy(this->reserve(size), values, size);
     }
 
     /**
      *  Reserve size bytes. Does not need to be 4 byte aligned. The remaining space (if any) will be
      *  filled in with zeroes.
      */
     uint32_t* reservePad(size_t size) {
         size_t alignedSize = SkAlign4(size);
@@ -181,17 +181,17 @@ public:
         }
         return p;
     }
 
     /**
      *  Write size bytes from src, and pad to 4 byte alignment with zeroes.
      */
     void writePad(const void* src, size_t size) {
-        memcpy(this->reservePad(size), src, size);
+        sk_careful_memcpy(this->reservePad(size), src, size);
     }
 
     /**
      *  Writes a string to the writer, which can be retrieved with
      *  SkReader32::readString().
      *  The length can be specified, or if -1 is passed, it will be computed by
      *  calling strlen(). The length must be < max size_t.
      *
--- a/gfx/skia/skia/include/effects/Sk1DPathEffect.h
+++ b/gfx/skia/skia/include/effects/Sk1DPathEffect.h
@@ -51,18 +51,17 @@ public:
 
     /** Dash by replicating the specified path.
         @param path The path to replicate (dash)
         @param advance The space between instances of path
         @param phase distance (mod advance) along path for its initial position
         @param style how to transform path at each point (based on the current
                      position and tangent)
     */
-    static SkPath1DPathEffect* Create(const SkPath& path, SkScalar advance, SkScalar phase,
-                                      Style style) {
+    static SkPathEffect* Create(const SkPath& path, SkScalar advance, SkScalar phase, Style style) {
         return new SkPath1DPathEffect(path, advance, phase, style);
     }
 
     virtual bool filterPath(SkPath*, const SkPath&,
                             SkStrokeRec*, const SkRect*) const override;
 
     SK_TO_STRING_OVERRIDE()
     SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkPath1DPathEffect)
--- a/gfx/skia/skia/include/effects/Sk2DPathEffect.h
+++ b/gfx/skia/skia/include/effects/Sk2DPathEffect.h
@@ -50,17 +50,17 @@ private:
     Sk2DPathEffect& operator=(const Sk2DPathEffect&);
 
     friend class Sk2DPathEffectBlitter;
     typedef SkPathEffect INHERITED;
 };
 
 class SK_API SkLine2DPathEffect : public Sk2DPathEffect {
 public:
-    static SkLine2DPathEffect* Create(SkScalar width, const SkMatrix& matrix) {
+    static SkPathEffect* Create(SkScalar width, const SkMatrix& matrix) {
         return new SkLine2DPathEffect(width, matrix);
     }
 
     virtual bool filterPath(SkPath* dst, const SkPath& src,
                             SkStrokeRec*, const SkRect*) const override;
 
     SK_TO_STRING_OVERRIDE()
     SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkLine2DPathEffect)
@@ -79,17 +79,17 @@ private:
 };
 
 class SK_API SkPath2DPathEffect : public Sk2DPathEffect {
 public:
     /**
      *  Stamp the specified path to fill the shape, using the matrix to define
      *  the latice.
      */
-    static SkPath2DPathEffect* Create(const SkMatrix& matrix, const SkPath& path) {
+    static SkPathEffect* Create(const SkMatrix& matrix, const SkPath& path) {
         return new SkPath2DPathEffect(matrix, path);
     }
 
     SK_TO_STRING_OVERRIDE()
     SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkPath2DPathEffect)
 
 protected:
     SkPath2DPathEffect(const SkMatrix&, const SkPath&);
--- a/gfx/skia/skia/include/effects/SkAlphaThresholdFilter.h
+++ b/gfx/skia/skia/include/effects/SkAlphaThresholdFilter.h
@@ -17,11 +17,12 @@ public:
      * Creates an image filter that samples a region. If the sample is inside the
      * region the alpha of the image is boosted up to a threshold value. If it is
      * outside the region then the alpha is decreased to the threshold value.
      * The 0,0 point of the region corresponds to the upper left corner of the
      * source image.
      */
     static SkImageFilter* Create(const SkRegion& region, SkScalar innerThreshold,
                                  SkScalar outerThreshold, SkImageFilter* input = NULL);
+    SK_DECLARE_FLATTENABLE_REGISTRAR_GROUP();
 };
 
 #endif
--- a/gfx/skia/skia/include/effects/SkBlurDrawLooper.h
+++ b/gfx/skia/skia/include/effects/SkBlurDrawLooper.h
@@ -30,18 +30,18 @@ public:
         */
         kIgnoreTransform_BlurFlag   = 0x01,
         kOverrideColor_BlurFlag     = 0x02,
         kHighQuality_BlurFlag       = 0x04,
         /** mask for all blur flags */
         kAll_BlurFlag               = 0x07
     };
 
-    static SkBlurDrawLooper* Create(SkColor color, SkScalar sigma, SkScalar dx, SkScalar dy,
-                                    uint32_t flags = kNone_BlurFlag) {
+    static SkDrawLooper* Create(SkColor color, SkScalar sigma, SkScalar dx, SkScalar dy,
+                                uint32_t flags = kNone_BlurFlag) {
         return new SkBlurDrawLooper(color, sigma, dx, dy, flags);
     }
 
     virtual ~SkBlurDrawLooper();
 
     SkDrawLooper::Context* createContext(SkCanvas*, void* storage) const override;
 
     size_t contextSize() const override { return sizeof(BlurDrawLooperContext); }
--- a/gfx/skia/skia/include/effects/SkBlurImageFilter.h
+++ b/gfx/skia/skia/include/effects/SkBlurImageFilter.h
@@ -10,29 +10,33 @@
 
 #include "SkImageFilter.h"
 #include "SkSize.h"
 
 class SK_API SkBlurImageFilter : public SkImageFilter {
 public:
     static SkImageFilter* Create(SkScalar sigmaX, SkScalar sigmaY, SkImageFilter* input = NULL,
                                  const CropRect* cropRect = NULL) {
+        if (0 == sigmaX && 0 == sigmaY && nullptr == cropRect) {
+            return SkSafeRef(input);
+        }
         return new SkBlurImageFilter(sigmaX, sigmaY, input, cropRect);
     }
 
     void computeFastBounds(const SkRect&, SkRect*) const override;
 
     SK_TO_STRING_OVERRIDE()
     SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkBlurImageFilter)
 
 protected:
     void flatten(SkWriteBuffer&) const override;
     bool onFilterImage(Proxy*, const SkBitmap& src, const Context&, SkBitmap* result,
                        SkIPoint* offset) const override;
-    bool onFilterBounds(const SkIRect& src, const SkMatrix&, SkIRect* dst) const override;
+    void onFilterNodeBounds(const SkIRect& src, const SkMatrix&,
+                            SkIRect* dst, MapDirection) const override;
     bool canFilterImageGPU() const override { return true; }
     bool filterImageGPU(Proxy* proxy, const SkBitmap& src, const Context& ctx, SkBitmap* result,
                         SkIPoint* offset) const override;
 
 private:
     SkBlurImageFilter(SkScalar sigmaX,
                       SkScalar sigmaY,
                       SkImageFilter* input,
--- a/gfx/skia/skia/include/effects/SkColorCubeFilter.h
+++ b/gfx/skia/skia/include/effects/SkColorCubeFilter.h
@@ -6,16 +6,17 @@
  */
 
 #ifndef SkColorCubeFilter_DEFINED
 #define SkColorCubeFilter_DEFINED
 
 #include "SkColorFilter.h"
 #include "SkData.h"
 #include "../private/SkMutex.h"
+#include "../private/SkTemplates.h"
 
 class SK_API SkColorCubeFilter : public SkColorFilter {
 public:
     /** cubeData must containt a 3D data in the form of cube of the size:
      *  cubeDimension * cubeDimension * cubeDimension * sizeof(SkColor)
      *  This cube contains a transform where (x,y,z) maps to the (r,g,b).
      *  The alpha components of the colors must be 0xFF.
      */
@@ -50,17 +51,17 @@ private:
 
     private:
         // Working pointers. If any of these is NULL,
         // we need to recompute the corresponding cache values.
         int* fColorToIndex[2];
         SkScalar* fColorToFactors[2];
         SkScalar* fColorToScalar;
 
-        SkAutoMalloc fLutStorage;
+        SkAutoTMalloc<uint8_t> fLutStorage;
 
         const int fCubeDimension;
 
         // Make sure we only initialize the caches once.
         SkMutex fLutsMutex;
         bool fLutsInited;
 
         static void initProcessingLuts(ColorCubeProcesingCache* cache);
--- a/gfx/skia/skia/include/effects/SkColorFilterImageFilter.h
+++ b/gfx/skia/skia/include/effects/SkColorFilterImageFilter.h
@@ -20,17 +20,17 @@ public:
     SK_TO_STRING_OVERRIDE()
     SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkColorFilterImageFilter)
 
 protected:
     void flatten(SkWriteBuffer&) const override;
     bool onFilterImage(Proxy*, const SkBitmap& src, const Context&, SkBitmap* result,
                        SkIPoint* loc) const override;
     bool onIsColorFilterNode(SkColorFilter**) const override;
-    bool affectsTransparentBlack() const override;
+    bool canComputeFastBounds() const override;
 
 private:
     SkColorFilterImageFilter(SkColorFilter* cf,
                              SkImageFilter* input,
                              const CropRect* cropRect);
     virtual ~SkColorFilterImageFilter();
 
     SkColorFilter*  fColorFilter;
--- a/gfx/skia/skia/include/effects/SkColorMatrixFilter.h
+++ b/gfx/skia/skia/include/effects/SkColorMatrixFilter.h
@@ -8,55 +8,52 @@
 #ifndef SkColorMatrixFilter_DEFINED
 #define SkColorMatrixFilter_DEFINED
 
 #include "SkColorFilter.h"
 #include "SkColorMatrix.h"
 
 class SK_API SkColorMatrixFilter : public SkColorFilter {
 public:
-    static SkColorMatrixFilter* Create(const SkColorMatrix& cm) {
+    static SkColorFilter* Create(const SkColorMatrix& cm) {
         return new SkColorMatrixFilter(cm);
     }
-    static SkColorMatrixFilter* Create(const SkScalar array[20]) {
+    static SkColorFilter* Create(const SkScalar array[20]) {
         return new SkColorMatrixFilter(array);
     }
 
+    /**
+     *  Create a colorfilter that multiplies the RGB channels by one color, and
+     *  then adds a second color, pinning the result for each component to
+     *  [0..255]. The alpha components of the mul and add arguments
+     *  are ignored.
+     */
+    static SkColorFilter* CreateLightingFilter(SkColor mul, SkColor add);
+
     void filterSpan(const SkPMColor src[], int count, SkPMColor[]) const override;
     uint32_t getFlags() const override;
     bool asColorMatrix(SkScalar matrix[20]) const override;
     SkColorFilter* newComposed(const SkColorFilter*) const override;
 
 #if SK_SUPPORT_GPU
     const GrFragmentProcessor* asFragmentProcessor(GrContext*) const override;
 #endif
 
-    struct State {
-        int32_t fArray[20];
-        int     fShift;
-    };
-
     SK_TO_STRING_OVERRIDE()
 
     SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkColorMatrixFilter)
 
 protected:
     explicit SkColorMatrixFilter(const SkColorMatrix&);
     explicit SkColorMatrixFilter(const SkScalar array[20]);
     void flatten(SkWriteBuffer&) const override;
 
 private:
     SkColorMatrix   fMatrix;
     float           fTranspose[SkColorMatrix::kCount]; // for Sk4s
-
-    typedef void (*Proc)(const State&, unsigned r, unsigned g, unsigned b,
-                         unsigned a, int32_t result[4]);
-
-    Proc        fProc;
-    State       fState;
-    uint32_t    fFlags;
+    uint32_t        fFlags;
 
     void initState(const SkScalar array[20]);
 
     typedef SkColorFilter INHERITED;
 };
 
 #endif
--- a/gfx/skia/skia/include/effects/SkCornerPathEffect.h
+++ b/gfx/skia/skia/include/effects/SkCornerPathEffect.h
@@ -15,30 +15,31 @@
     SkCornerPathEffect is a subclass of SkPathEffect that can turn sharp corners
     into various treatments (e.g. rounded corners)
 */
 class SK_API SkCornerPathEffect : public SkPathEffect {
 public:
     /** radius must be > 0 to have an effect. It specifies the distance from each corner
         that should be "rounded".
     */
-    static SkCornerPathEffect* Create(SkScalar radius) { return new SkCornerPathEffect(radius); }
-    virtual ~SkCornerPathEffect();
+    static SkPathEffect* Create(SkScalar radius) { return new SkCornerPathEffect(radius); }
 
     virtual bool filterPath(SkPath* dst, const SkPath& src,
                             SkStrokeRec*, const SkRect*) const override;
 
     SK_TO_STRING_OVERRIDE()
     SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkCornerPathEffect)
 
 #ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK
     bool exposedInAndroidJavaAPI() const override { return true; }
 #endif
 
 protected:
+    virtual ~SkCornerPathEffect();
+
     explicit SkCornerPathEffect(SkScalar radius);
     void flatten(SkWriteBuffer&) const override;
 
 private:
     SkScalar    fRadius;
 
     typedef SkPathEffect INHERITED;
 };
--- a/gfx/skia/skia/include/effects/SkDashPathEffect.h
+++ b/gfx/skia/skia/include/effects/SkDashPathEffect.h
@@ -31,18 +31,17 @@ public:
          10 pixels on
          20 pixels off
          ...
         A phase of -5, 25, 55, 85, etc. would all result in the same path,
          because the sum of all the intervals is 30.
 
         Note: only affects stroked paths.
     */
-    static SkDashPathEffect* Create(const SkScalar intervals[], int count,
-                                    SkScalar phase) {
+    static SkPathEffect* Create(const SkScalar intervals[], int count, SkScalar phase) {
         return new SkDashPathEffect(intervals, count, phase);
     }
     virtual ~SkDashPathEffect();
 
     virtual bool filterPath(SkPath* dst, const SkPath& src,
                             SkStrokeRec*, const SkRect*) const override;
 
     virtual bool asPoints(PointData* results, const SkPath& src,
--- a/gfx/skia/skia/include/effects/SkDiscretePathEffect.h
+++ b/gfx/skia/skia/include/effects/SkDiscretePathEffect.h
@@ -24,19 +24,17 @@ public:
                           the seed value that is used to randomize the path
                           segments' endpoints. If not supplied it defaults to 0,
                           in which case filtering a path multiple times will
                           result in the same set of segments (this is useful for
                           testing). If a caller does not want this behaviour
                           they can pass in a different seedAssist to get a
                           different set of path segments.
     */
-    static SkDiscretePathEffect* Create(SkScalar segLength,
-                                        SkScalar deviation,
-                                        uint32_t seedAssist=0) {
+    static SkPathEffect* Create(SkScalar segLength, SkScalar deviation, uint32_t seedAssist = 0) {
         return new SkDiscretePathEffect(segLength, deviation, seedAssist);
     }
 
     virtual bool filterPath(SkPath* dst, const SkPath& src,
                             SkStrokeRec*, const SkRect*) const override;
 
     SK_TO_STRING_OVERRIDE()
     SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkDiscretePathEffect)
--- a/gfx/skia/skia/include/effects/SkDisplacementMapEffect.h
+++ b/gfx/skia/skia/include/effects/SkDisplacementMapEffect.h
@@ -18,33 +18,34 @@ public:
         kR_ChannelSelectorType,
         kG_ChannelSelectorType,
         kB_ChannelSelectorType,
         kA_ChannelSelectorType
     };
 
     ~SkDisplacementMapEffect();
 
-    static SkDisplacementMapEffect* Create(ChannelSelectorType xChannelSelector,
-                                           ChannelSelectorType yChannelSelector,
-                                           SkScalar scale, SkImageFilter* displacement,
-                                           SkImageFilter* color = NULL,
-                                           const CropRect* cropRect = NULL);
+    static SkImageFilter* Create(ChannelSelectorType xChannelSelector,
+                                 ChannelSelectorType yChannelSelector,
+                                 SkScalar scale, SkImageFilter* displacement,
+                                 SkImageFilter* color = NULL,
+                                 const CropRect* cropRect = NULL);
 
     SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkDisplacementMapEffect)
 
     virtual bool onFilterImage(Proxy* proxy,
                                const SkBitmap& src,
                                const Context& ctx,
                                SkBitmap* dst,
                                SkIPoint* offset) const override;
     void computeFastBounds(const SkRect& src, SkRect* dst) const override;
 
     virtual bool onFilterBounds(const SkIRect& src, const SkMatrix&,
                                 SkIRect* dst) const override;
+    void onFilterNodeBounds(const SkIRect&, const SkMatrix&, SkIRect*, MapDirection) const override;
 
 #if SK_SUPPORT_GPU
     bool canFilterImageGPU() const override { return true; }
     virtual bool filterImageGPU(Proxy* proxy, const SkBitmap& src, const Context& ctx,
                                 SkBitmap* result, SkIPoint* offset) const override;
 #endif
 
     SK_TO_STRING_OVERRIDE()
--- a/gfx/skia/skia/include/effects/SkDropShadowImageFilter.h
+++ b/gfx/skia/skia/include/effects/SkDropShadowImageFilter.h
@@ -30,17 +30,18 @@ public:
     void computeFastBounds(const SkRect&, SkRect*) const override;
     SK_TO_STRING_OVERRIDE()
     SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkDropShadowImageFilter)
 
 protected:
     void flatten(SkWriteBuffer&) const override;
     bool onFilterImage(Proxy*, const SkBitmap& source, const Context&, SkBitmap* result,
                        SkIPoint* loc) const override;
-    bool onFilterBounds(const SkIRect& src, const SkMatrix&, SkIRect* dst) const override;
+    void onFilterNodeBounds(const SkIRect& src, const SkMatrix&,
+                            SkIRect* dst, MapDirection) const override;
 
 private:
     SkDropShadowImageFilter(SkScalar dx, SkScalar dy, SkScalar sigmaX, SkScalar sigmaY, SkColor,
                             ShadowMode shadowMode, SkImageFilter* input, const CropRect* cropRect);
 
     SkScalar fDx, fDy, fSigmaX, fSigmaY;
     SkColor fColor;
     ShadowMode fShadowMode;
--- a/gfx/skia/skia/include/effects/SkEmbossMaskFilter.h
+++ b/gfx/skia/skia/include/effects/SkEmbossMaskFilter.h
@@ -18,24 +18,24 @@ class SK_API SkEmbossMaskFilter : public
 public:
     struct Light {
         SkScalar    fDirection[3];  // x,y,z
         uint16_t    fPad;
         uint8_t     fAmbient;
         uint8_t     fSpecular;      // exponent, 4.4 right now
     };
 
-    static SkEmbossMaskFilter* Create(SkScalar blurSigma, const Light& light);
+    static SkMaskFilter* Create(SkScalar blurSigma, const Light& light);
 
     // overrides from SkMaskFilter
     //  This method is not exported to java.
     SkMask::Format getFormat() const override;
     //  This method is not exported to java.
-    virtual bool filterMask(SkMask* dst, const SkMask& src, const SkMatrix&,
-                            SkIPoint* margin) const override;
+    bool filterMask(SkMask* dst, const SkMask& src, const SkMatrix&,
+                    SkIPoint* margin) const override;
 
     SK_TO_STRING_OVERRIDE()
     SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkEmbossMaskFilter)
 
 protected:
     SkEmbossMaskFilter(SkScalar blurSigma, const Light& light);
     void flatten(SkWriteBuffer&) const override;
 
--- a/gfx/skia/skia/include/effects/SkLightingImageFilter.h
+++ b/gfx/skia/skia/include/effects/SkLightingImageFilter.h
@@ -44,17 +44,17 @@ public:
 protected:
     SkLightingImageFilter(SkImageFilterLight* light,
                           SkScalar surfaceScale,
                           SkImageFilter* input,
                           const CropRect* cropRect);
     void flatten(SkWriteBuffer&) const override;
     const SkImageFilterLight* light() const { return fLight.get(); }
     SkScalar surfaceScale() const { return fSurfaceScale; }
-    bool affectsTransparentBlack() const override { return true; }
+    bool canComputeFastBounds() const override { return false; }
 
 private:
     typedef SkImageFilter INHERITED;
     SkAutoTUnref<SkImageFilterLight> fLight;
     SkScalar fSurfaceScale;
 };
 
 #endif
--- a/gfx/skia/skia/include/effects/SkMatrixConvolutionImageFilter.h
+++ b/gfx/skia/skia/include/effects/SkMatrixConvolutionImageFilter.h
@@ -47,25 +47,25 @@ public:
                               TileMode).
         @param convolveAlpha  If true, all channels are convolved.  If false,
                               only the RGB channels are convolved, and
                               alpha is copied from the source image.
         @param input          The input image filter.  If NULL, the src bitmap
                               passed to filterImage() is used instead.
         @param cropRect       The rectangle to which the output processing will be limited.
     */
-    static SkMatrixConvolutionImageFilter* Create(const SkISize& kernelSize,
-                                                  const SkScalar* kernel,
-                                                  SkScalar gain,
-                                                  SkScalar bias,
-                                                  const SkIPoint& kernelOffset,
-                                                  TileMode tileMode,
-                                                  bool convolveAlpha,
-                                                  SkImageFilter* input = NULL,
-                                                  const CropRect* cropRect = NULL);
+    static SkImageFilter* Create(const SkISize& kernelSize,
+                                 const SkScalar* kernel,
+                                 SkScalar gain,
+                                 SkScalar bias,
+                                 const SkIPoint& kernelOffset,
+                                 TileMode tileMode,
+                                 bool convolveAlpha,
+                                 SkImageFilter* input = NULL,
+                                 const CropRect* cropRect = NULL);
 
     SK_TO_STRING_OVERRIDE()
     SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkMatrixConvolutionImageFilter)
 
 protected:
     SkMatrixConvolutionImageFilter(const SkISize& kernelSize,
                                    const SkScalar* kernel,
                                    SkScalar gain,
@@ -74,18 +74,18 @@ protected:
                                    TileMode tileMode,
                                    bool convolveAlpha,
                                    SkImageFilter* input,
                                    const CropRect* cropRect);
     void flatten(SkWriteBuffer&) const override;
 
     bool onFilterImage(Proxy*, const SkBitmap& src, const Context&,
                        SkBitmap* result, SkIPoint* loc) const override;
-    bool onFilterBounds(const SkIRect&, const SkMatrix&, SkIRect*) const override;
-
+    void onFilterNodeBounds(const SkIRect&, const SkMatrix&, SkIRect*, MapDirection) const override;
+    bool canComputeFastBounds() const override;
 
 #if SK_SUPPORT_GPU
     bool asFragmentProcessor(GrFragmentProcessor**, GrTexture*, const SkMatrix&,
                              const SkIRect& bounds) const override;
 #endif
 
 private:
     SkISize   fKernelSize;
deleted file mode 100644
--- a/gfx/skia/skia/include/effects/SkModeColorFilter.h
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * Copyright 2015 Google Inc.
- *
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#ifndef SkModeColorFilter_DEFINED
-#define SkModeColorFilter_DEFINED
-
-#include "SkColorFilter.h"
-#include "SkColorPriv.h"
-#include "SkString.h"
-#include "SkXfermode.h"
-
-class SkModeColorFilter : public SkColorFilter {
-public:
-    static SkColorFilter* Create(SkColor color, SkXfermode::Mode mode) {
-        return new SkModeColorFilter(color, mode);
-    }
-
-    SkColor getColor() const { return fColor; }
-    SkXfermode::Mode getMode() const { return fMode; }
-    SkPMColor getPMColor() const { return fPMColor; }
-
-    bool asColorMode(SkColor*, SkXfermode::Mode*) const override;
-    uint32_t getFlags() const override;
-    void filterSpan(const SkPMColor shader[], int count, SkPMColor result[]) const override;
-
-#ifndef SK_IGNORE_TO_STRING
-    void toString(SkString* str) const override {
-        str->append("SkModeColorFilter: color: 0x");
-        str->appendHex(fColor);
-        str->append(" mode: ");
-        str->append(SkXfermode::ModeName(fMode));
-    }
-#endif
-
-#if SK_SUPPORT_GPU
-    const GrFragmentProcessor* asFragmentProcessor(GrContext*) const override;
-#endif
-    SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkModeColorFilter)
-
-protected:
-    SkModeColorFilter(SkColor color, SkXfermode::Mode mode) {
-        fColor = color;
-        fMode = mode;
-        this->updateCache();
-    };
-
-    void flatten(SkWriteBuffer&) const override;
-
-private:
-    SkColor             fColor;
-    SkXfermode::Mode    fMode;
-    // cache
-    SkPMColor           fPMColor;
-    SkXfermodeProc      fProc;
-
-    void updateCache();
-
-    typedef SkColorFilter INHERITED;
-};
-
-#endif
--- a/gfx/skia/skia/include/effects/SkMorphologyImageFilter.h
+++ b/gfx/skia/skia/include/effects/SkMorphologyImageFilter.h
@@ -11,17 +11,18 @@
 
 #include "SkColor.h"
 #include "SkImageFilter.h"
 #include "SkSize.h"
 
 class SK_API SkMorphologyImageFilter : public SkImageFilter {
 public:
     void computeFastBounds(const SkRect& src, SkRect* dst) const override;
-    bool onFilterBounds(const SkIRect& src, const SkMatrix& ctm, SkIRect* dst) const override;
+    void onFilterNodeBounds(const SkIRect& src, const SkMatrix& ctm,
+                            SkIRect* dst, MapDirection) const override;
 
     /**
      * All morphology procs have the same signature: src is the source buffer, dst the
      * destination buffer, radius is the morphology radius, width and height are the bounds
      * of the destination buffer (in pixels), and srcStride and dstStride are the
      * number of pixels per row in each buffer. All buffers are 8888.
      */
 
--- a/gfx/skia/skia/include/effects/SkOffsetImageFilter.h
+++ b/gfx/skia/skia/include/effects/SkOffsetImageFilter.h
@@ -25,17 +25,17 @@ public:
 
     SK_TO_STRING_OVERRIDE()
     SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkOffsetImageFilter)
 
 protected:
     void flatten(SkWriteBuffer&) const override;
     bool onFilterImage(Proxy*, const SkBitmap& src, const Context&, SkBitmap* result,
                        SkIPoint* loc) const override;
-    bool onFilterBounds(const SkIRect&, const SkMatrix&, SkIRect*) const override;
+    void onFilterNodeBounds(const SkIRect&, const SkMatrix&, SkIRect*, MapDirection) const override;
 
 private:
     SkOffsetImageFilter(SkScalar dx, SkScalar dy, SkImageFilter* input, const CropRect*);
 
     SkVector fOffset;
 
     typedef SkImageFilter INHERITED;
 };
new file mode 100644
--- /dev/null
+++ b/gfx/skia/skia/include/effects/SkPaintImageFilter.h
@@ -0,0 +1,45 @@
+/*
+ * Copyright 2016 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#ifndef SkPaintImageFilter_DEFINED
+#define SkPaintImageFilter_DEFINED
+
+#include "SkImageFilter.h"
+#include "SkPaint.h"
+
+class SK_API SkPaintImageFilter : public SkImageFilter {
+public:
+    /** Create a new image filter which fills the given rectangle using the
+     *  given paint. If no rectangle is specified, an output is produced with
+     *  the same bounds as the input primitive (even though the input
+     *  primitive's pixels are not used for processing).
+     *  @param paint  Paint to use when filling the rect.
+     *  @param rect   Rectangle of output pixels. If NULL or a given crop edge is
+     *                not specified, the source primitive's bounds are used
+     *                instead.
+     */
+    static SkImageFilter* Create(const SkPaint& paint, const CropRect* rect = NULL);
+
+    bool canComputeFastBounds() const override;
+
+    SK_TO_STRING_OVERRIDE()
+    SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkPaintImageFilter)
+
+protected:
+    void flatten(SkWriteBuffer&) const override;
+    bool onFilterImage(Proxy*, const SkBitmap& src, const Context&, SkBitmap* result,
+                       SkIPoint* loc) const override;
+
+private:
+    SkPaintImageFilter(const SkPaint& paint, const CropRect* rect);
+
+    SkPaint fPaint;
+
+    typedef SkImageFilter INHERITED;
+};
+
+#endif
--- a/gfx/skia/skia/include/effects/SkPerlinNoiseShader.h
+++ b/gfx/skia/skia/include/effects/SkPerlinNoiseShader.h
@@ -75,17 +75,16 @@ public:
     size_t contextSize() const override;
 
     class PerlinNoiseShaderContext : public SkShader::Context {
     public:
         PerlinNoiseShaderContext(const SkPerlinNoiseShader& shader, const ContextRec&);
         virtual ~PerlinNoiseShaderContext();
 
         void shadeSpan(int x, int y, SkPMColor[], int count) override;
-        void shadeSpan16(int x, int y, uint16_t[], int count) override;
 
     private:
         SkPMColor shade(const SkPoint& point, StitchData& stitchData) const;
         SkScalar calculateTurbulenceValueForPoint(
             int channel,
             StitchData& stitchData, const SkPoint& point) const;
         SkScalar noise2D(int channel,
                          const StitchData& stitchData, const SkPoint& noiseVector) const;
deleted file mode 100644
--- a/gfx/skia/skia/include/effects/SkRectShaderImageFilter.h
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Copyright 2013 Google Inc.
- *
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#ifndef SkRectShaderImageFilter_DEFINED
-#define SkRectShaderImageFilter_DEFINED
-
-#include "SkImageFilter.h"
-#include "SkRect.h"
-
-class SkShader;
-
-class SK_API SkRectShaderImageFilter : public SkImageFilter {
-public:
-    /** Create a new image filter which fills the given rectangle with pixels
-     *  produced by the given SkShader. If no rectangle is specified, an output
-     *  is produced with the same bounds as the input primitive (even though
-     *  the input primitive's pixels are not used for processing).
-     *  @param s     Shader to call for processing. Cannot be NULL. Will be
-     *               ref'ed by the new image filter.
-     *  @param rect  Rectangle of output pixels in which to apply the shader.
-     *               If NULL or a given crop edge is not specified, the source
-     *               primitive's bounds are used instead.
-     */
-    SK_ATTR_DEPRECATED("use Create(SkShader*, const CropRect*)")
-    static SkImageFilter* Create(SkShader* s, const SkRect& rect);
-    static SkImageFilter* Create(SkShader* s, const CropRect* rect = NULL);
-
-    bool affectsTransparentBlack() const override;
-
-    SK_TO_STRING_OVERRIDE()
-    SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkRectShaderImageFilter)
-
-protected:
-    virtual ~SkRectShaderImageFilter();
-
-    void flatten(SkWriteBuffer&) const override;
-    bool onFilterImage(Proxy*, const SkBitmap& src, const Context&, SkBitmap* result,
-                       SkIPoint* loc) const override;
-
-private:
-    SkRectShaderImageFilter(SkShader* s, const CropRect* rect);
-
-    SkShader*  fShader;
-
-    typedef SkImageFilter INHERITED;
-};
-
-#endif
--- a/gfx/skia/skia/include/effects/SkTileImageFilter.h
+++ b/gfx/skia/skia/include/effects/SkTileImageFilter.h
@@ -20,16 +20,17 @@ public:
         @param input    Input from which the subregion defined by srcRect will be tiled
     */
     static SkImageFilter* Create(const SkRect& src, const SkRect& dst, SkImageFilter* input);
 
     bool onFilterImage(Proxy* proxy, const SkBitmap& src, const Context& ctx,
                        SkBitmap* dst, SkIPoint* offset) const override;
     bool onFilterBounds(const SkIRect& src, const SkMatrix&,
                         SkIRect* dst) const override;
+    void onFilterNodeBounds(const SkIRect&, const SkMatrix&, SkIRect*, MapDirection) const override;
     void computeFastBounds(const SkRect& src, SkRect* dst) const override;
 
     SK_TO_STRING_OVERRIDE()
     SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkTileImageFilter)
 
 protected:
     void flatten(SkWriteBuffer& buffer) const override;
 
--- a/gfx/skia/skia/include/effects/SkXfermodeImageFilter.h
+++ b/gfx/skia/skia/include/effects/SkXfermodeImageFilter.h
@@ -18,19 +18,19 @@ class SK_API SkXfermodeImageFilter : pub
      * This filter takes an xfermode, and uses it to composite the foreground
      * over the background.  If foreground or background is NULL, the input
      * bitmap (src) is used instead.
       */
 
 public:
     virtual ~SkXfermodeImageFilter();
 
-    static SkXfermodeImageFilter* Create(SkXfermode* mode, SkImageFilter* background,
-                                         SkImageFilter* foreground = NULL,
-                                         const CropRect* cropRect = NULL) {
+    static SkImageFilter* Create(SkXfermode* mode, SkImageFilter* background,
+                                 SkImageFilter* foreground = NULL,
+                                 const CropRect* cropRect = NULL) {
         SkImageFilter* inputs[2] = { background, foreground };
         return new SkXfermodeImageFilter(mode, inputs, cropRect);
     }
 
     SK_TO_STRING_OVERRIDE()
     SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkXfermodeImageFilter)
 
     bool onFilterImage(Proxy* proxy,
--- a/gfx/skia/skia/include/gpu/GrCaps.h
+++ b/gfx/skia/skia/include/gpu/GrCaps.h
@@ -65,17 +65,17 @@ public:
 
     /**
     * Get the precision info for a variable of type kFloat_GrSLType, kVec2f_GrSLType, etc in a
     * given shader type. If the shader type is not supported or the precision level is not
     * supported in that shader type then the returned struct will report false when supported() is
     * called.
     */
     const PrecisionInfo& getFloatShaderPrecisionInfo(GrShaderType shaderType,
-        GrSLPrecision precision) const {
+                                                     GrSLPrecision precision) const {
         return fFloatPrecisions[shaderType][precision];
     };
 
     /**
     * Is there any difference between the float shader variable precision types? If this is true
     * then unless the shader type is not supported, any call to getFloatShaderPrecisionInfo() would
     * report the same info for all precisions in all shader types.
     */
@@ -113,21 +113,17 @@ public:
 
     bool npotTextureTileSupport() const { return fNPOTTextureTileSupport; }
     /** To avoid as-yet-unnecessary complexity we don't allow any partial support of MIP Maps (e.g.
         only for POT textures) */
     bool mipMapSupport() const { return fMipMapSupport; }
     bool twoSidedStencilSupport() const { return fTwoSidedStencilSupport; }
     bool stencilWrapOpsSupport() const { return  fStencilWrapOpsSupport; }
     bool discardRenderTargetSupport() const { return fDiscardRenderTargetSupport; }
-#if GR_FORCE_GPU_TRACE_DEBUGGING
-    bool gpuTracingSupport() const { return true; }
-#else
     bool gpuTracingSupport() const { return fGpuTracingSupport; }
-#endif
     bool compressedTexSubImageSupport() const { return fCompressedTexSubImageSupport; }
     bool oversizedStencilSupport() const { return fOversizedStencilSupport; }
     bool textureBarrierSupport() const { return fTextureBarrierSupport; }
     bool mixedSamplesSupport() const { return fMixedSamplesSupport; }
 
     bool useDrawInsteadOfClear() const { return fUseDrawInsteadOfClear; }
     bool useDrawInsteadOfPartialRenderTargetWrite() const {
         return fUseDrawInsteadOfPartialRenderTargetWrite;
@@ -189,25 +185,18 @@ public:
     int maxTextureSize() const { return fMaxTextureSize; }
     /** This is the maximum tile size to use by GPU devices for rendering sw-backed images/bitmaps.
         It is usually the max texture size, unless we're overriding it for testing. */
     int maxTileSize() const { SkASSERT(fMaxTileSize <= fMaxTextureSize); return fMaxTileSize; }
 
     // Will be 0 if MSAA is not supported
     int maxSampleCount() const { return fMaxSampleCount; }
 
-    bool isConfigRenderable(GrPixelConfig config, bool withMSAA) const {
-        SkASSERT(kGrPixelConfigCnt > config);
-        return fConfigRenderSupport[config][withMSAA];
-    }
-
-    bool isConfigTexturable(GrPixelConfig config) const {
-        SkASSERT(kGrPixelConfigCnt > config);
-        return fConfigTextureSupport[config];
-    }
+    virtual bool isConfigTexturable(GrPixelConfig config) const = 0;
+    virtual bool isConfigRenderable(GrPixelConfig config, bool withMSAA) const = 0;
 
     bool suppressPrints() const { return fSuppressPrints; }
 
     bool immediateFlush() const { return fImmediateFlush; }
 
     bool drawPathMasksToCompressedTexturesSupport() const {
         return fDrawPathMasksToCompressedTextureSupport;
     }
@@ -265,20 +254,16 @@ protected:
     uint32_t fMapBufferFlags;
     int fGeometryBufferMapThreshold;
 
     int fMaxRenderTargetSize;
     int fMaxTextureSize;
     int fMaxTileSize;
     int fMaxSampleCount;
 
-    // The first entry for each config is without msaa and the second is with.
-    bool fConfigRenderSupport[kGrPixelConfigCnt][2];
-    bool fConfigTextureSupport[kGrPixelConfigCnt];
-
 private:
     virtual void onApplyOptionsOverrides(const GrContextOptions&) {};
 
     bool fSuppressPrints : 1;
     bool fImmediateFlush: 1;
     bool fDrawPathMasksToCompressedTextureSupport : 1;
 
     typedef SkRefCnt INHERITED;
--- a/gfx/skia/skia/include/gpu/GrClip.h
+++ b/gfx/skia/skia/include/gpu/GrClip.h
@@ -80,17 +80,17 @@ public:
                 } else {
                     return this->clipStack() == other.clipStack();
                 }
                 break;
             case kIRect_ClipType:
                 return this->irect() == other.irect();
                 break;
         }
-
+        SkFAIL("This should not occur\n");
         return false;
     }
 
     bool operator!=(const GrClip& other) const {
         return !(*this == other);
     }
 
     const SkClipStack* clipStack() const {
--- a/gfx/skia/skia/include/gpu/GrConfig.h
+++ b/gfx/skia/skia/include/gpu/GrConfig.h
@@ -181,16 +181,16 @@ typedef unsigned __int64 uint64_t;
         template <> class GR_STATIC_ASSERT_FAILURE<true> {};
         #define GR_STATIC_ASSERT(CONDITION) \
             enum {GR_CONCAT(X,__LINE__) = \
             sizeof(GR_STATIC_ASSERT_FAILURE<CONDITION>)}
     #endif
 #endif
 
 /**
- * GR_FORCE_GPU_TRACE_DEBUGGING will force gpu tracing/debug markers to be turned on. The trace
- * markers will be printed out instead of making the backend calls to push and pop them.
+ * Enable batch debugging output as json.  The enabler of this flag is responsible for making sure
+ * GrAuditTrail is reset occasionally.
+ * TODO make this runtime configurable
  */
-#if !defined(GR_FORCE_GPU_TRACE_DEBUGGING)
-    #define GR_FORCE_GPU_TRACE_DEBUGGING 0
+#if !defined(GR_BATCH_DEBUGGING_OUTPUT)
+    #define GR_BATCH_DEBUGGING_OUTPUT 0
 #endif
-
 #endif
--- a/gfx/skia/skia/include/gpu/GrContext.h
+++ b/gfx/skia/skia/include/gpu/GrContext.h
@@ -10,19 +10,21 @@
 
 #include "GrCaps.h"
 #include "GrClip.h"
 #include "GrColor.h"
 #include "GrPaint.h"
 #include "GrRenderTarget.h"
 #include "GrTextureProvider.h"
 #include "SkMatrix.h"
-#include "../private/SkMutex.h"
 #include "SkPathEffect.h"
 #include "SkTypes.h"
+#include "../private/GrAuditTrail.h"
+#include "../private/GrSingleOwner.h"
+#include "../private/SkMutex.h"
 
 struct GrBatchAtlasConfig;
 class GrBatchFontCache;
 struct GrContextOptions;
 class GrDrawingManager;
 class GrDrawContext;
 class GrDrawTarget;
 class GrFragmentProcessor;
@@ -349,19 +351,23 @@ public:
 
     /** Specify the sizes of the GrAtlasTextContext atlases.  The configs pointer below should be
         to an array of 3 entries */
     void setTextContextAtlasSizes_ForTesting(const GrBatchAtlasConfig* configs);
 
     /** Enumerates all cached GPU resources and dumps their memory to traceMemoryDump. */
     void dumpMemoryStatistics(SkTraceMemoryDump* traceMemoryDump) const;
 
-    /** Draw font cache texture to render target */
-    void drawFontCache(const SkRect& rect, GrMaskFormat format, const SkPaint& paint,
-                       GrRenderTarget* target);
+    /** Get pointer to atlas texture for given mask format */
+    GrTexture* getFontAtlasTexture(GrMaskFormat format);
+
+    GrAuditTrail* getAuditTrail() { return &fAuditTrail; }
+
+    /** This is only useful for debug purposes */
+    SkDEBUGCODE(GrSingleOwner* debugSingleOwner() const { return &fSingleOwner; } )
 
 private:
     GrGpu*                          fGpu;
     const GrCaps*                   fCaps;
     GrResourceCache*                fResourceCache;
     // this union exists because the inheritance of GrTextureProvider->GrResourceProvider
     // is in a private header.
     union {
@@ -386,27 +392,34 @@ private:
     // of fReadPixelsMutex and use a separate mutex to guard it. When it re-enters
     // readSurfacePixels it will grab fReadPixelsMutex and release it before the outer
     // readSurfacePixels proceeds to grab it.
     // TODO: Stop pretending to make GrContext thread-safe for sw rasterization and provide
     // a mechanism to make a SkPicture safe for multithreaded sw rasterization.
     SkMutex                         fReadPixelsMutex;
     SkMutex                         fTestPMConversionsMutex;
 
+    // In debug builds we guard against improper thread handling
+    // This guard is passed to the GrDrawingManager and, from there to all the
+    // GrDrawContexts.  It is also passed to the GrTextureProvider and SkGpuDevice.
+    mutable GrSingleOwner fSingleOwner;
+
     struct CleanUpData {
         PFCleanUpFunc fFunc;
         void*         fInfo;
     };
 
     SkTDArray<CleanUpData>          fCleanUpData;
 
     const uint32_t                  fUniqueID;
 
     SkAutoTDelete<GrDrawingManager> fDrawingManager;
 
+    GrAuditTrail                    fAuditTrail;
+
     // TODO: have the CMM use drawContexts and rm this friending
     friend class GrClipMaskManager; // the CMM is friended just so it can call 'drawingManager'
     friend class GrDrawingManager;  // for access to drawingManager for ProgramUnitTest
     GrDrawingManager* drawingManager() { return fDrawingManager; }
 
     GrContext(); // init must be called after the constructor.
     bool init(GrBackend, GrBackendContext, const GrContextOptions& options);
 
--- a/gfx/skia/skia/include/gpu/GrContextOptions.h
+++ b/gfx/skia/skia/include/gpu/GrContextOptions.h
@@ -16,16 +16,18 @@ struct GrContextOptions {
         , fSuppressPrints(false)
         , fMaxTextureSizeOverride(SK_MaxS32)
         , fMaxTileSizeOverride(0)
         , fSuppressDualSourceBlending(false)
         , fGeometryBufferMapThreshold(-1)
         , fUseDrawInsteadOfPartialRenderTargetWrite(false)
         , fImmediateMode(false)
         , fClipBatchToBounds(false)
+        , fDrawBatchBounds(false)
+        , fMaxBatchLookback(-1)
         , fUseShaderSwizzling(false) {}
 
     // EXPERIMENTAL
     // May be removed in the future, or may become standard depending
     // on the outcomes of a variety of internal tests.
     bool fDrawPathToCompressedTexture;
 
     // Suppress prints for the GrContext.
@@ -52,14 +54,22 @@ struct GrContextOptions {
     /** The GrContext operates in immediate mode. It will issue all draws to the backend API
         immediately. Intended to ease debugging. */
     bool fImmediateMode;
 
     /** For debugging purposes turn each GrBatch's bounds into a clip rect. This is used to
         verify that the clip bounds are conservative. */
     bool fClipBatchToBounds;
 
+    /** For debugging purposes draw a wireframe device bounds rect for each GrBatch. The wire
+        frame rect is draw before the GrBatch in order to visualize batches that draw outside
+        of their dev bounds. */
+    bool fDrawBatchBounds;
+
+    /** For debugging, override the default maximum look-back window for GrBatch combining. */
+    int fMaxBatchLookback;
+
     /** Force us to do all swizzling manually in the shader and don't rely on extensions to do
         swizzling. */
     bool fUseShaderSwizzling;
 };
 
 #endif
--- a/gfx/skia/skia/include/gpu/GrDrawContext.h
+++ b/gfx/skia/skia/include/gpu/GrDrawContext.h
@@ -7,26 +7,27 @@
 
 #ifndef GrDrawContext_DEFINED
 #define GrDrawContext_DEFINED
 
 #include "GrColor.h"
 #include "GrRenderTarget.h"
 #include "SkRefCnt.h"
 #include "SkSurfaceProps.h"
+#include "../private/GrSingleOwner.h"
 
+class GrAuditTrail;
 class GrClip;
 class GrContext;
 class GrDrawBatch;
+class GrDrawPathBatchBase;
 class GrDrawingManager;
 class GrDrawTarget;
 class GrPaint;
 class GrPathProcessor;
-class GrPathRange;
-class GrPathRangeDraw;
 class GrPipelineBuilder;
 class GrRenderTarget;
 class GrStrokeInfo;
 class GrSurface;
 class GrTextContext;
 class SkDrawFilter;
 struct SkIPoint;
 struct SkIRect;
@@ -58,27 +59,16 @@ public:
                      const SkMatrix& viewMatrix, const char text[], size_t byteLength,
                      const SkScalar pos[], int scalarsPerPosition,
                      const SkPoint& offset, const SkIRect& clipBounds);
     void drawTextBlob(const GrClip&, const SkPaint&,
                       const SkMatrix& viewMatrix, const SkTextBlob*,
                       SkScalar x, SkScalar y,
                       SkDrawFilter*, const SkIRect& clipBounds);
 
-    // drawPathsFromRange is thanks to GrStencilAndCoverTextContext
-    // TODO: remove once path batches can be created external to GrDrawTarget.
-    void drawPathsFromRange(const GrPipelineBuilder*,
-                            const SkMatrix& viewMatrix,
-                            const SkMatrix& localMatrix,
-                            GrColor color,
-                            GrPathRange* range,
-                            GrPathRangeDraw* draw,
-                            int /*GrPathRendering::FillType*/ fill,
-                            const SkRect& bounds);
-
     /**
      * Provides a perfomance hint that the render target's contents are allowed
      * to become undefined.
      */
     void discard();
 
     /**
      * Clear the entire or rect of the render target, ignoring any clips.
@@ -269,27 +259,42 @@ public:
     /**
      * Draws a batch
      *
      * @param paint    describes how to color pixels.
      * @param batch    the batch to draw
      */
     void drawBatch(const GrClip&, const GrPaint&, GrDrawBatch*);
 
+    /**
+     * Draws a path batch. This needs to be separate from drawBatch because we install path stencil
+     * settings late.
+     *
+     * TODO: Figure out a better model that allows us to roll this method into drawBatch.
+     */
+    void drawPathBatch(const GrPipelineBuilder&, GrDrawPathBatchBase*);
+
     int width() const { return fRenderTarget->width(); }
     int height() const { return fRenderTarget->height(); }
     int numColorSamples() const { return fRenderTarget->numColorSamples(); }
 
+    GrRenderTarget* accessRenderTarget() { return fRenderTarget; }
+
+    ///////////////////////////////////////////////////////////////////////////////////////////////
+    // Functions intended for internal use only.
+    void internal_drawBatch(const GrPipelineBuilder& pipelineBuilder, GrDrawBatch* batch);
+
 private:
-    friend class GrAtlasTextContext; // for access to drawBatch
+    friend class GrAtlasTextBlob; // for access to drawBatch
     friend class GrDrawingManager; // for ctor
 
     SkDEBUGCODE(void validate() const;)
 
-    GrDrawContext(GrDrawingManager*, GrRenderTarget*, const SkSurfaceProps* surfaceProps);
+    GrDrawContext(GrDrawingManager*, GrRenderTarget*, const SkSurfaceProps* surfaceProps,
+                  GrAuditTrail*, GrSingleOwner*);
 
     void internalDrawPath(GrPipelineBuilder*,
                           const SkMatrix& viewMatrix,
                           GrColor,
                           bool useAA,
                           const SkPath&,
                           const GrStrokeInfo&);
 
@@ -303,11 +308,15 @@ private:
     GrRenderTarget*   fRenderTarget;
 
     // In MDB-mode the drawTarget can be closed by some other drawContext that has picked
     // it up. For this reason, the drawTarget should only ever be accessed via 'getDrawTarget'.
     GrDrawTarget*     fDrawTarget;
     GrTextContext*    fTextContext; // lazily gotten from GrContext::DrawingManager
 
     SkSurfaceProps    fSurfaceProps;
+    GrAuditTrail*     fAuditTrail;
+
+    // In debug builds we guard against improper thread handling
+    SkDEBUGCODE(mutable GrSingleOwner* fSingleOwner;)
 };
 
 #endif
--- a/gfx/skia/skia/include/gpu/GrResourceKey.h
+++ b/gfx/skia/skia/include/gpu/GrResourceKey.h
@@ -288,21 +288,23 @@ private:
  * is unique. These macros create such a key in a thread safe manner so the key can be truly global
  * and only constructed once.
  */
 
 /** Place outside of function/class definitions. */
 #define GR_DECLARE_STATIC_UNIQUE_KEY(name) SK_DECLARE_STATIC_ONCE(name##_once)
 
 /** Place inside function where the key is used. */
-#define GR_DEFINE_STATIC_UNIQUE_KEY(name)                           \
-    static GrUniqueKey name;                                        \
-    SkOnce(&name##_once, gr_init_static_unique_key_once, &name)
+#define GR_DEFINE_STATIC_UNIQUE_KEY(name)                                                       \
+    static SkAlignedSTStorage<1, GrUniqueKey> name##_storage;                                   \
+    SkOnce(&name##_once, gr_init_static_unique_key_once, &name##_storage);                      \
+    static const GrUniqueKey& name = *reinterpret_cast<GrUniqueKey*>(name##_storage.get());
 
-static inline void gr_init_static_unique_key_once(GrUniqueKey* key) {
+static inline void gr_init_static_unique_key_once(SkAlignedSTStorage<1,GrUniqueKey>* keyStorage) {
+    GrUniqueKey* key = new (keyStorage->get()) GrUniqueKey;
     GrUniqueKey::Builder builder(key, GrUniqueKey::GenerateDomain(), 0);
 }
 
 // The cache listens for these messages to purge junk resources proactively.
 class GrUniqueKeyInvalidatedMessage {
 public:
     explicit GrUniqueKeyInvalidatedMessage(const GrUniqueKey& key) : fKey(key) {}
 
--- a/gfx/skia/skia/include/gpu/GrTestUtils.h
+++ b/gfx/skia/skia/include/gpu/GrTestUtils.h
@@ -86,16 +86,17 @@ static inline uint8_t GrRandomCoverage(S
         kLast_CoverageMode = kRandom_CoverageMode
     };
 
     CoverageMode colorMode = CoverageMode(random->nextULessThan(kLast_CoverageMode + 1));
     uint8_t coverage;
     switch (colorMode) {
         case kZero_CoverageMode:
             coverage = 0;
+            break;
         case kAllOnes_CoverageMode:
             coverage = 0xff;
             break;
         case kRandom_CoverageMode:
             coverage = random->nextULessThan(256);
             break;
     }
     return coverage;
--- a/gfx/skia/skia/include/gpu/GrTextureAccess.h
+++ b/gfx/skia/skia/include/gpu/GrTextureAccess.h
@@ -9,95 +9,56 @@
 #define GrTextureAccess_DEFINED
 
 #include "GrGpuResourceRef.h"
 #include "GrTexture.h"
 #include "GrTextureParams.h"
 #include "SkRefCnt.h"
 #include "SkShader.h"
 
-/** A class representing the swizzle access pattern for a texture. Note that if the texture is
- *  an alpha-only texture then the alpha channel is substituted for other components. Any mangling
- *  to handle the r,g,b->a conversions for alpha textures is automatically included in the stage
- *  key. However, if a GrProcessor uses different swizzles based on its input then it must
- *  consider that variation in its key-generation.
+/** 
+ * Used to represent a texture that is required by a GrProcessor. It holds a GrTexture along with
+ * an associated GrTextureParams
  */
 class GrTextureAccess : public SkNoncopyable {
 public:
     /**
-     * A default GrTextureAccess must have reset() called on it in a GrProcessor subclass's
-     * constructor if it will be accessible via GrProcessor::textureAccess().
+     * Must be initialized before adding to a GrProcessor's texture access list.
      */
     GrTextureAccess();
 
-    /**
-     * Uses the default swizzle, "rgba".
-     */
     GrTextureAccess(GrTexture*, const GrTextureParams&);
+
     explicit GrTextureAccess(GrTexture*,
                              GrTextureParams::FilterMode = GrTextureParams::kNone_FilterMode,
                              SkShader::TileMode tileXAndY = SkShader::kClamp_TileMode);
 
-    /**
-     * swizzle must be a string between one and four (inclusive) characters containing only 'r',
-     * 'g', 'b',  and/or 'a'.
-     */
-    GrTextureAccess(GrTexture*, const char* swizzle, const GrTextureParams&);
-    GrTextureAccess(GrTexture*,
-                    const char* swizzle,
-                    GrTextureParams::FilterMode = GrTextureParams::kNone_FilterMode,
-                    SkShader::TileMode tileXAndY = SkShader::kClamp_TileMode);
-
     void reset(GrTexture*, const GrTextureParams&);
     void reset(GrTexture*,
                GrTextureParams::FilterMode = GrTextureParams::kNone_FilterMode,
                SkShader::TileMode tileXAndY = SkShader::kClamp_TileMode);
-    void reset(GrTexture*, const char* swizzle, const GrTextureParams&);
-    void reset(GrTexture*,
-               const char* swizzle,
-               GrTextureParams::FilterMode = GrTextureParams::kNone_FilterMode,
-               SkShader::TileMode tileXAndY = SkShader::kClamp_TileMode);
 
-    bool operator== (const GrTextureAccess& other) const {
-#ifdef SK_DEBUG
-        // below assumes all chars in fSwizzle are initialized even if string is < 4 chars long.
-        SkASSERT(memcmp(fSwizzle, other.fSwizzle, sizeof(fSwizzle)-1) ==
-                 strcmp(fSwizzle, other.fSwizzle));
-#endif
-        return fParams == other.fParams &&
-               (this->getTexture() == other.getTexture()) &&
-               (0 == memcmp(fSwizzle, other.fSwizzle, sizeof(fSwizzle)-1));
+    bool operator==(const GrTextureAccess& that) const {
+        return this->getTexture() == that.getTexture() && fParams == that.fParams;
     }
 
-    bool operator!= (const GrTextureAccess& other) const { return !(*this == other); }
+    bool operator!=(const GrTextureAccess& other) const { return !(*this == other); }
 
     GrTexture* getTexture() const { return fTexture.get(); }
 
     /**
      * For internal use by GrProcessor.
      */
     const GrGpuResourceRef* getProgramTexture() const { return &fTexture; }
 
-    /**
-     * Returns a string representing the swizzle. The string is is null-terminated.
-     */
-    const char* getSwizzle() const { return fSwizzle; }
-
-    /** Returns a mask indicating which components are referenced in the swizzle. The return
-        is a bitfield of GrColorComponentFlags. */
-    uint32_t swizzleMask() const { return fSwizzleMask; }
-
     const GrTextureParams& getParams() const { return fParams; }
 
 private:
-    void setSwizzle(const char*);
 
     typedef GrTGpuResourceRef<GrTexture> ProgramTexture;
 
     ProgramTexture                  fTexture;
     GrTextureParams                 fParams;
-    uint32_t                        fSwizzleMask;
-    char                            fSwizzle[5];
 
     typedef SkNoncopyable INHERITED;
 };
 
 #endif
--- a/gfx/skia/skia/include/gpu/GrTextureProvider.h
+++ b/gfx/skia/skia/include/gpu/GrTextureProvider.h
@@ -6,16 +6,18 @@
  */
 
 #ifndef GrTextureProvider_DEFINED
 #define GrTextureProvider_DEFINED
 
 #include "GrTexture.h"
 #include "SkImageFilter.h"
 
+class GrSingleOwner;
+
 class SK_API GrTextureProvider {
 public:
     ///////////////////////////////////////////////////////////////////////////
     // Textures
 
     /**
      * Creates a new texture in the resource cache and returns it. The caller owns a
      * ref on the returned texture which must be balanced by a call to unref.
@@ -37,25 +39,17 @@ public:
 
     /** Assigns a unique key to the texture. The texture will be findable via this key using
         findTextureByUniqueKey(). If an existing texture has this key, it's key will be removed. */
     void assignUniqueKeyToTexture(const GrUniqueKey& key, GrTexture* texture) {
         this->assignUniqueKeyToResource(key, texture);
     }
 
     /** Finds a texture by unique key. If the texture is found it is ref'ed and returned. */
-    GrTexture* findAndRefTextureByUniqueKey(const GrUniqueKey& key) {
-        GrGpuResource* resource = this->findAndRefResourceByUniqueKey(key);
-        if (resource) {
-            GrTexture* texture = static_cast<GrSurface*>(resource)->asTexture();
-            SkASSERT(texture);
-            return texture;
-        }
-        return NULL;
-    }
+    GrTexture* findAndRefTextureByUniqueKey(const GrUniqueKey& key);
 
     /**
      * Determines whether a texture is associated with the unique key. If the texture is found it
      * will not be locked or returned. This call does not affect the priority of the resource for
      * deletion.
      */
     bool existsTextureWithUniqueKey(const GrUniqueKey& key) const {
         return this->existsResourceWithUniqueKey(key);
@@ -65,41 +59,16 @@ public:
      * Finds a texture that approximately matches the descriptor. Will be at least as large in width
      * and height as desc specifies. If desc specifies that the texture should be a render target
      * then result will be a render target. Format and sample count will always match the request.
      * The contents of the texture are undefined. The caller owns a ref on the returned texture and
      * must balance with a call to unref.
      */
     GrTexture* createApproxTexture(const GrSurfaceDesc&);
 
-    enum SizeConstraint {
-        kExact_SizeConstraint,
-        kApprox_SizeConstraint,
-    };
-
-    GrTexture* createTexture(const GrSurfaceDesc& desc, SizeConstraint constraint) {
-        switch (constraint) {
-            case kExact_SizeConstraint:
-                return this->createTexture(desc, true);
-            case kApprox_SizeConstraint:
-                return this->createApproxTexture(desc);
-        }
-        sk_throw();
-        return nullptr;
-    }
-
-    static SizeConstraint FromImageFilter(SkImageFilter::SizeConstraint constraint) {
-        if (SkImageFilter::kExact_SizeConstraint == constraint) {
-            return kExact_SizeConstraint;
-        } else {
-            SkASSERT(SkImageFilter::kApprox_SizeConstraint == constraint);
-            return kApprox_SizeConstraint;
-        }
-    }
-
     /** Legacy function that no longer should be used. */
     enum ScratchTexMatch {
         kExact_ScratchTexMatch,
         kApprox_ScratchTexMatch
     };
     GrTexture* refScratchTexture(const GrSurfaceDesc& desc, ScratchTexMatch match) {
         if (kApprox_ScratchTexMatch == match) {
             return this->createApproxTexture(desc);
@@ -129,17 +98,17 @@ public:
      * the client will resolve to a texture). Currently wrapped render targets
      * always use the kBorrow_GrWrapOwnership semantics.
      *
      * @return GrTexture object or NULL on failure.
      */
      GrRenderTarget* wrapBackendRenderTarget(const GrBackendRenderTargetDesc& desc);
 
 protected:
-    GrTextureProvider(GrGpu* gpu, GrResourceCache* cache) : fCache(cache), fGpu(gpu) {}
+    GrTextureProvider(GrGpu* gpu, GrResourceCache* cache, GrSingleOwner* singleOwner);
 
     /**
      * Assigns a unique key to a resource. If the key is associated with another resource that
      * association is removed and replaced by this resource.
      */
     void assignUniqueKeyToResource(const GrUniqueKey&, GrGpuResource*);
 
     /**
@@ -181,11 +150,14 @@ protected:
     bool isAbandoned() const {
         SkASSERT(SkToBool(fGpu) == SkToBool(fCache));
         return !SkToBool(fCache);
     }
 
 private:
     GrResourceCache* fCache;
     GrGpu* fGpu;
+
+    // In debug builds we guard against improper thread handling
+    SkDEBUGCODE(mutable GrSingleOwner* fSingleOwner;)
 };
 
 #endif
--- a/gfx/skia/skia/include/gpu/GrTypes.h
+++ b/gfx/skia/skia/include/gpu/GrTypes.h
@@ -358,36 +358,16 @@ static inline size_t GrBytesPerPixel(GrP
             return 8;
         case kRGBA_float_GrPixelConfig:
             return 16;
         default:
             return 0;
     }
 }
 
-static inline size_t GrUnpackAlignment(GrPixelConfig config) {
-    SkASSERT(!GrPixelConfigIsCompressed(config));
-    switch (config) {
-        case kAlpha_8_GrPixelConfig:
-            return 1;
-        case kRGB_565_GrPixelConfig:
-        case kRGBA_4444_GrPixelConfig:
-        case kAlpha_half_GrPixelConfig:
-        case kRGBA_half_GrPixelConfig:
-            return 2;
-        case kRGBA_8888_GrPixelConfig:
-        case kBGRA_8888_GrPixelConfig:
-        case kSRGBA_8888_GrPixelConfig:
-        case kRGBA_float_GrPixelConfig:
-            return 4;
-        default:
-            return 0;
-    }
-}
-
 static inline bool GrPixelConfigIsOpaque(GrPixelConfig config) {
     switch (config) {
         case kETC1_GrPixelConfig:
         case kRGB_565_GrPixelConfig:
             return true;
         default:
             return false;
     }
--- a/gfx/skia/skia/include/gpu/GrTypesPriv.h
+++ b/gfx/skia/skia/include/gpu/GrTypesPriv.h
@@ -7,32 +7,33 @@
 
 #ifndef GrTypesPriv_DEFINED
 #define GrTypesPriv_DEFINED
 
 #include "GrTypes.h"
 #include "SkTArray.h"
 #include "SkRect.h"
 
-/**
- * Types of shader-language-specific boxed variables we can create. (Currently only GrGLShaderVars,
- * but should be applicable to other shader languages.)
- */
+ /**
+  * Types of shader-language-specific boxed variables we can create. (Currently only GrGLShaderVars,
+  * but should be applicable to other shader languages.)
+  */
 enum GrSLType {
     kVoid_GrSLType,
     kFloat_GrSLType,
     kVec2f_GrSLType,
     kVec3f_GrSLType,
     kVec4f_GrSLType,
     kMat33f_GrSLType,
     kMat44f_GrSLType,
     kSampler2D_GrSLType,
     kSamplerExternal_GrSLType,
+    kSampler2DRect_GrSLType,
 
-    kLast_GrSLType = kSamplerExternal_GrSLType
+    kLast_GrSLType = kSampler2DRect_GrSLType
 };
 static const int kGrSLTypeCount = kLast_GrSLType + 1;
 
 enum GrShaderType {
     kVertex_GrShaderType,
     kGeometry_GrShaderType,
     kFragment_GrShaderType,
 
@@ -59,28 +60,29 @@ enum GrSLPrecision {
 
 static const int kGrSLPrecisionCount = kLast_GrSLPrecision + 1;
 
 /**
  * Gets the vector size of the SLType. Returns -1 for void, matrices, and samplers.
  */
 static inline int GrSLTypeVectorCount(GrSLType type) {
     SkASSERT(type >= 0 && type < static_cast<GrSLType>(kGrSLTypeCount));
-    static const int kCounts[] = { -1, 1, 2, 3, 4, -1, -1, -1, -1 };
+    static const int kCounts[] = { -1, 1, 2, 3, 4, -1, -1, -1, -1, -1 };
     return kCounts[type];
 
     GR_STATIC_ASSERT(0 == kVoid_GrSLType);
     GR_STATIC_ASSERT(1 == kFloat_GrSLType);
     GR_STATIC_ASSERT(2 == kVec2f_GrSLType);
     GR_STATIC_ASSERT(3 == kVec3f_GrSLType);
     GR_STATIC_ASSERT(4 == kVec4f_GrSLType);
     GR_STATIC_ASSERT(5 == kMat33f_GrSLType);
     GR_STATIC_ASSERT(6 == kMat44f_GrSLType);
     GR_STATIC_ASSERT(7 == kSampler2D_GrSLType);
     GR_STATIC_ASSERT(8 == kSamplerExternal_GrSLType);
+    GR_STATIC_ASSERT(9 == kSampler2DRect_GrSLType);
     GR_STATIC_ASSERT(SK_ARRAY_COUNT(kCounts) == kGrSLTypeCount);
 }
 
 /** Return the type enum for a vector of floats of length n (1..4),
  e.g. 1 -> kFloat_GrSLType, 2 -> kVec2_GrSLType, ... */
 static inline GrSLType GrSLFloatVectorType(int count) {
     SkASSERT(count > 0 && count <= 4);
     return (GrSLType)(count);
@@ -100,18 +102,59 @@ static inline bool GrSLTypeIsFloatType(G
     GR_STATIC_ASSERT(1 == kFloat_GrSLType);
     GR_STATIC_ASSERT(2 == kVec2f_GrSLType);
     GR_STATIC_ASSERT(3 == kVec3f_GrSLType);
     GR_STATIC_ASSERT(4 == kVec4f_GrSLType);
     GR_STATIC_ASSERT(5 == kMat33f_GrSLType);
     GR_STATIC_ASSERT(6 == kMat44f_GrSLType);
     GR_STATIC_ASSERT(7 == kSampler2D_GrSLType);
     GR_STATIC_ASSERT(8 == kSamplerExternal_GrSLType);
-    GR_STATIC_ASSERT(9 == kGrSLTypeCount);
+    GR_STATIC_ASSERT(9 == kSampler2DRect_GrSLType);
+    GR_STATIC_ASSERT(10 == kGrSLTypeCount);
 }
+
+/** Returns the size in bytes for floating point GrSLTypes. For non floating point type returns 0 */
+static inline size_t GrSLTypeSize(GrSLType type) {
+    SkASSERT(GrSLTypeIsFloatType(type));
+    static const size_t kSizes[] = {
+        0,                        // kVoid_GrSLType
+        sizeof(float),            // kFloat_GrSLType
+        2 * sizeof(float),        // kVec2f_GrSLType
+        3 * sizeof(float),        // kVec3f_GrSLType
+        4 * sizeof(float),        // kVec4f_GrSLType
+        9 * sizeof(float),        // kMat33f_GrSLType
+        16 * sizeof(float),       // kMat44f_GrSLType
+        0,                        // kSampler2D_GrSLType
+        0,                         // kSamplerExternal_GrSLType
+        0                         // kSampler2DRect_GrSLType
+    };
+    return kSizes[type];
+
+    GR_STATIC_ASSERT(0 == kVoid_GrSLType);
+    GR_STATIC_ASSERT(1 == kFloat_GrSLType);
+    GR_STATIC_ASSERT(2 == kVec2f_GrSLType);
+    GR_STATIC_ASSERT(3 == kVec3f_GrSLType);
+    GR_STATIC_ASSERT(4 == kVec4f_GrSLType);
+    GR_STATIC_ASSERT(5 == kMat33f_GrSLType);
+    GR_STATIC_ASSERT(6 == kMat44f_GrSLType);
+    GR_STATIC_ASSERT(7 == kSampler2D_GrSLType);
+    GR_STATIC_ASSERT(8 == kSamplerExternal_GrSLType);
+    GR_STATIC_ASSERT(9 == kSampler2DRect_GrSLType);
+    GR_STATIC_ASSERT(10 == kGrSLTypeCount);
+}
+
+static inline bool GrSLTypeIsSamplerType(GrSLType type) {
+    SkASSERT(type >= 0 && type < static_cast<GrSLType>(kGrSLTypeCount));
+    return type >= 7 && type <= 9;
+
+    GR_STATIC_ASSERT(7 == kSampler2D_GrSLType);
+    GR_STATIC_ASSERT(8 == kSamplerExternal_GrSLType);
+    GR_STATIC_ASSERT(9 == kSampler2DRect_GrSLType);
+}
+
 //////////////////////////////////////////////////////////////////////////////
 
 /**
  * Types used to describe format of vertices in arrays.
   */
 enum GrVertexAttribType {
     kFloat_GrVertexAttribType = 0,
     kVec2f_GrVertexAttribType,
@@ -173,16 +216,17 @@ static inline size_t GrVertexAttribTypeS
 
 /**
  * converts a GrVertexAttribType to a GrSLType
  */
 static inline GrSLType GrVertexAttribTypeToSLType(GrVertexAttribType type) {
     switch (type) {
         default:
             SkFAIL("Unsupported type conversion");
+            return kVoid_GrSLType;
         case kUByte_GrVertexAttribType:
         case kFloat_GrVertexAttribType:
             return kFloat_GrSLType;
         case kVec2s_GrVertexAttribType:
         case kVec2f_GrVertexAttribType:
             return kVec2f_GrSLType;
         case kVec3f_GrVertexAttribType:
             return kVec3f_GrSLType;
@@ -262,16 +306,27 @@ struct GrScissorState {
     bool enabled() const { return fEnabled; }
     const SkIRect& rect() const { return fRect; }
 
 private:
     bool    fEnabled;
     SkIRect fRect;
 };
 
+/**
+ * Indicates the transfer direction for a transfer buffer
+ */
+enum TransferType {
+    /** Caller intends to use the buffer to transfer data to the GPU */
+    kCpuToGpu_TransferType,
+    /** Caller intends to use the buffer to transfer data from the GPU */
+    kGpuToCpu_TransferType
+};
+
+
 #ifdef SK_DEBUG
 // Takes a pointer to a GrCaps, and will suppress prints if required
 #define GrCapsDebugf(caps, ...)         \
     if (!caps->suppressPrints()) {      \
         SkDebugf(__VA_ARGS__);          \
     }
 #else
 #define GrCapsDebugf(caps, ...)
--- a/gfx/skia/skia/include/gpu/SkGrPixelRef.h
+++ b/gfx/skia/skia/include/gpu/SkGrPixelRef.h
@@ -44,17 +44,17 @@ public:
     SkGrPixelRef(const SkImageInfo&, GrSurface*);
     virtual ~SkGrPixelRef();
 
     // override from SkPixelRef
     GrTexture* getTexture() override;
 
 protected:
     // overrides from SkPixelRef
-    bool onReadPixels(SkBitmap* dst, const SkIRect* subset) override;
+    bool onReadPixels(SkBitmap* dst, SkColorType, const SkIRect* subset) override;
     SkPixelRef* deepCopy(SkColorType, SkColorProfileType,
                          const SkIRect* subset) override;
     void onNotifyPixelsChanged() override;
 
 private:
     GrSurface*  fSurface;
     typedef SkROLockPixelsPixelRef INHERITED;
 };
--- a/gfx/skia/skia/include/gpu/effects/GrPorterDuffXferProcessor.h
+++ b/gfx/skia/skia/include/gpu/effects/GrPorterDuffXferProcessor.h
@@ -16,20 +16,26 @@ class GrProcOptInfo;
 
 class GrPorterDuffXPFactory : public GrXPFactory {
 public:
     static GrXPFactory* Create(SkXfermode::Mode mode); 
 
     void getInvariantBlendedColor(const GrProcOptInfo& colorPOI,
                                   GrXPFactory::InvariantBlendedColor*) const override;
 
+
+    /** Because src-over is so common we special case it for performance reasons. If this returns
+        null then the SimpleSrcOverXP() below should be used. */
     static GrXferProcessor* CreateSrcOverXferProcessor(const GrCaps& caps,
                                                        const GrPipelineOptimizations& optimizations,
                                                        bool hasMixedSamples,
                                                        const GrXferProcessor::DstTexture*);
+    /** This XP implements non-LCD src-over using hw blend with no optimizations. It is returned
+        by reference because it is global and its ref-cnting methods are not thread safe. */
+    static const GrXferProcessor& SimpleSrcOverXP();
 
     static inline void SrcOverInvariantBlendedColor(
                                                 GrColor inputColor,
                                                 GrColorComponentFlags validColorFlags,
                                                 bool isOpaque,
                                                 GrXPFactory::InvariantBlendedColor* blendedColor) {
         if (!isOpaque) {
             blendedColor->fWillBlendWithDst = true;
--- a/gfx/skia/skia/include/gpu/gl/SkGLContext.h
+++ b/gfx/skia/skia/include/gpu/gl/SkGLContext.h
@@ -12,19 +12,19 @@
 #include "../private/SkGpuFenceSync.h"
 
 /**
  * Create an offscreen opengl context with an RGBA8 / 8bit stencil FBO.
  * Provides a GrGLInterface struct of function pointers for the context.
  * This class is intended for Skia's testing needs and not for general
  * use.
  */
-class SK_API SkGLContext : public SkRefCnt {
+class SK_API SkGLContext : public SkNoncopyable {
 public:
-    ~SkGLContext() override;
+    virtual ~SkGLContext();
 
     bool isValid() const { return NULL != gl(); }
 
     const GrGLInterface* gl() const { return fGL.get(); }
 
     bool fenceSyncSupport() const { return SkToBool(fFenceSync); }
 
     bool getMaxGpuFrameLag(int* maxFrameLag) const {
@@ -36,16 +36,21 @@ public:
     }
 
     void makeCurrent() const;
 
     /** Used for testing EGLImage integration. Take a GL_TEXTURE_2D and wraps it in an EGL Image */
     virtual GrEGLImage texture2DToEGLImage(GrGLuint /*texID*/) const { return 0; }
     virtual void destroyEGLImage(GrEGLImage) const {}
 
+    /** Used for testing GL_TEXTURE_RECTANGLE integration. */
+    GrGLint createTextureRectangle(int width, int height, GrGLenum internalFormat,
+                                   GrGLenum externalFormat, GrGLenum externalType,
+                                   GrGLvoid* data);
+
     /**
      * Used for testing EGLImage integration. Takes a EGLImage and wraps it in a
      * GL_TEXTURE_EXTERNAL_OES.
      */
     virtual GrGLuint eglImageToExternalTexture(GrEGLImage) const { return 0; }
 
     /**
      * The only purpose of this function it to provide a means of scheduling
@@ -101,18 +106,16 @@ private:
     SkPlatformGpuFence            fFrameFences[kMaxFrameLag - 1];
     int                           fCurrentFenceIdx;
 
     /** Subclass provides the gl interface object if construction was
      *  successful. */
     SkAutoTUnref<const GrGLInterface> fGL;
 
     friend class GLFenceSync;  // For onPlatformGetProcAddress.
-
-    typedef SkRefCnt INHERITED;
 };
 
 /** Creates platform-dependent GL context object
  * Returns a valid gl context object or NULL if such can not be created.
  * Note: If Skia embedder needs a custom GL context that sets up the GL
  * interface, this function should be implemented by the embedder.
  * Otherwise, the default implementation for the platform should be compiled in
  * the library.
--- a/gfx/skia/skia/include/gpu/gl/SkNullGLContext.h
+++ b/gfx/skia/skia/include/gpu/gl/SkNullGLContext.h
@@ -9,17 +9,22 @@
 #define SkNullGLContext_DEFINED
 
 #include "gl/SkGLContext.h"
 
 class SK_API SkNullGLContext : public SkGLContext {
 public:
     ~SkNullGLContext() override;
 
-    static SkNullGLContext* Create(GrGLStandard);
+    static SkNullGLContext* Create();
+    // FIXME: remove once Chromium has been updated.
+    static SkNullGLContext* Create(GrGLStandard forcedAPI) {
+        SkASSERT(forcedAPI == kNone_GrGLStandard);
+        (void)forcedAPI;        return Create();
+    }
 
     class ContextState;
 
 private:
     SkNullGLContext();
 
     void onPlatformMakeCurrent() const override;
     void onPlatformSwapBuffers() const override {}
--- a/gfx/skia/skia/include/gpu/gl/angle/SkANGLEGLContext.h
+++ b/gfx/skia/skia/include/gpu/gl/angle/SkANGLEGLContext.h
@@ -10,28 +10,35 @@
 
 #if SK_ANGLE
 
 #include "gl/SkGLContext.h"
 
 class SkANGLEGLContext : public SkGLContext {
 public:
     ~SkANGLEGLContext() override;
-
-    static SkANGLEGLContext* Create(GrGLStandard forcedGpuAPI, bool useGLBackend) {
-        if (kGL_GrGLStandard == forcedGpuAPI) {
-            return NULL;
-        }
-        SkANGLEGLContext* ctx = new SkANGLEGLContext(useGLBackend);
+#ifdef SK_BUILD_FOR_WIN
+    static SkANGLEGLContext* CreateDirectX() {
+        SkANGLEGLContext* ctx = new SkANGLEGLContext(false);
         if (!ctx->isValid()) {
             delete ctx;
             return NULL;
         }
         return ctx;
     }
+#endif
+    static SkANGLEGLContext* CreateOpenGL() {
+        SkANGLEGLContext* ctx = new SkANGLEGLContext(true);
+        if (!ctx->isValid()) {
+            delete ctx;
+            return NULL;
+        }
+        return ctx;
+    }
+
     GrEGLImage texture2DToEGLImage(GrGLuint texID) const override;
     void destroyEGLImage(GrEGLImage) const override;
     GrGLuint eglImageToExternalTexture(GrEGLImage) const override;
     SkGLContext* createNew() const override;
 
     // The param is an EGLNativeDisplayType and the return is an EGLDispay.
     static void* GetD3DEGLDisplay(void* nativeDisplay, bool useGLBackend);
 
--- a/gfx/skia/skia/include/gpu/gl/command_buffer/SkCommandBufferGLContext.h
+++ b/gfx/skia/skia/include/gpu/gl/command_buffer/SkCommandBufferGLContext.h
@@ -11,20 +11,17 @@
 #if SK_COMMAND_BUFFER
 
 #include "gl/SkGLContext.h"
 
 class SkCommandBufferGLContext : public SkGLContext {
 public:
     ~SkCommandBufferGLContext() override;
 
-    static SkCommandBufferGLContext* Create(GrGLStandard forcedGpuAPI) {
-        if (kGL_GrGLStandard == forcedGpuAPI) {
-            return nullptr;
-        }
+    static SkCommandBufferGLContext* Create() {
         SkCommandBufferGLContext* ctx = new SkCommandBufferGLContext;
         if (!ctx->isValid()) {
             delete ctx;
             return nullptr;
         }
         return ctx;
     }
 
deleted file mode 100644
--- a/gfx/skia/skia/include/pipe/SkGPipe.h
+++ /dev/null
@@ -1,174 +0,0 @@
-/*
- * Copyright 2011 Google Inc.
- *
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-
-
-#ifndef SkGPipe_DEFINED
-#define SkGPipe_DEFINED
-
-#include "SkFlattenable.h"
-#include "SkPicture.h"
-#include "SkWriter32.h"
-
-class SkCanvas;
-
-// XLib.h might have defined Status already (ugh)
-#ifdef Status
-    #undef Status
-#endif
-
-class SkGPipeReader {
-public:
-    SkGPipeReader();
-    SkGPipeReader(SkCanvas* target);
-    ~SkGPipeReader();
-
-    enum Status {
-        kDone_Status,   //!< no more data expected from reader
-        kEOF_Status,    //!< need more data from reader
-        kError_Status,  //!< encountered error
-        kReadAtom_Status//!< finished reading an atom
-    };
-
-    enum PlaybackFlags {
-        kReadAtom_PlaybackFlag = 0x1, //!< playback a single command from the stream
-        kSilent_PlaybackFlag   = 0x2, //!< playback without drawing
-    };
-
-    void setCanvas(SkCanvas*);
-
-    /**
-     *  Set a function for decoding bitmaps that have encoded data.
-     */
-    void setBitmapDecoder(SkPicture::InstallPixelRefProc proc) { fProc = proc; }
-
-    // data must be 4-byte aligned
-    // length must be a multiple of 4
-    Status playback(const void* data, size_t length, uint32_t playbackFlags = 0,
-                    size_t* bytesRead = NULL);
-private:
-    SkCanvas*                       fCanvas;
-    class SkGPipeState*             fState;
-    SkPicture::InstallPixelRefProc  fProc;
-};
-
-///////////////////////////////////////////////////////////////////////////////
-
-class SkGPipeCanvas;
-
-class SkGPipeController {
-public:
-    SkGPipeController() : fCanvas(NULL) {}
-    virtual ~SkGPipeController();
-
-    /**
-     *  Called periodically by the writer, to get a working buffer of RAM to
-     *  write into. The actual size of the block is also returned, and must be
-     *  actual >= minRequest. If NULL is returned, then actual is ignored and
-     *  writing will stop.
-     *
-     *  The returned block must be 4-byte aligned, and actual must be a
-     *  multiple of 4.
-     *  minRequest will always be a multiple of 4.
-     */
-    virtual void* requestBlock(size_t minRequest, size_t* actual) = 0;
-
-    /**
-     *  This is called each time some atomic portion of the data has been
-     *  written to the block (most recently returned by requestBlock()).
-     *  If bytes == 0, then the writer has finished.
-     *
-     *  bytes will always be a multiple of 4.
-     */
-    virtual void notifyWritten(size_t bytes) = 0;
-    virtual int numberOfReaders() const { return 1; }
-
-    /**
-     *  Release resource references that are held in internal caches.
-     *  This must only be called after the pipe has been completely flushed.
-     */
-    void purgeCaches();
-
-private:
-    friend class SkGPipeWriter;
-    void setCanvas(SkGPipeCanvas*);
-
-    SkGPipeCanvas* fCanvas;
-};
-
-class SkGPipeWriter {
-public:
-    SkGPipeWriter();
-    ~SkGPipeWriter();
-
-    bool isRecording() const { return SkToBool(fCanvas); }
-
-    enum Flags {
-        /**
-         *  Tells the writer that the reader will be in a different process, so
-         *  (for example) we cannot put function pointers in the stream.
-         */
-        kCrossProcess_Flag              = 1 << 0,
-
-        /**
-         *  Only meaningful if kCrossProcess_Flag is set. Tells the writer that
-         *  in spite of being cross process, it will have shared address space
-         *  with the reader, so the two can share large objects (like SkBitmaps).
-         */
-        kSharedAddressSpace_Flag        = 1 << 1,
-
-        /**
-         *  Tells the writer that there will be multiple threads reading the stream
-         *  simultaneously.
-         */
-        kSimultaneousReaders_Flag       = 1 << 2,
-    };
-
-    SkCanvas* startRecording(SkGPipeController*, uint32_t flags = 0,
-        uint32_t width = kDefaultRecordingCanvasSize,
-        uint32_t height = kDefaultRecordingCanvasSize);
-
-    // called in destructor, but can be called sooner once you know there
-    // should be no more drawing calls made into the recording canvas.
-    void endRecording();
-
-    /**
-     *  Tells the writer to commit all recorded draw commands to the
-     *  controller immediately.
-     *  @param detachCurrentBlock Set to true to request that the next draw
-     *      command be recorded in a new block.
-     */
-    void flushRecording(bool detachCurrentBlock);
-
-    /**
-     * Return the amount of bytes being used for recording. Note that this
-     * does not include the amount of storage written to the stream, which is
-     * controlled by the SkGPipeController.
-     * Currently only returns the amount used for SkBitmaps, since they are
-     * potentially unbounded (if the client is not calling playback).
-     */
-    size_t storageAllocatedForRecording() const;
-
-    /**
-     * Attempt to reduce the storage allocated for recording by evicting
-     * cache resources.
-     * @param bytesToFree minimum number of bytes that should be attempted to
-     *   be freed.
-     * @return number of bytes actually freed.
-     */
-    size_t freeMemoryIfPossible(size_t bytesToFree);
-
-private:
-    enum {
-        kDefaultRecordingCanvasSize = 32767,
-    };
-
-    SkGPipeCanvas* fCanvas;
-    SkWriter32     fWriter;
-};
-
-#endif
--- a/gfx/skia/skia/include/ports/SkFontMgr.h
+++ b/gfx/skia/skia/include/ports/SkFontMgr.h
@@ -38,41 +38,49 @@ public:
     int countFamilies() const;
     void getFamilyName(int index, SkString* familyName) const;
     SkFontStyleSet* createStyleSet(int index) const;
 
     /**
      *  The caller must call unref() on the returned object.
      *  Never returns NULL; will return an empty set if the name is not found.
      *
+     *  Passing |nullptr| as the parameter will return the default system font.
+     *
      *  It is possible that this will return a style set not accessible from
      *  createStyleSet(int) due to hidden or auto-activated fonts.
      */
     SkFontStyleSet* matchFamily(const char familyName[]) const;
 
     /**
      *  Find the closest matching typeface to the specified familyName and style
      *  and return a ref to it. The caller must call unref() on the returned
      *  object. Will never return NULL, as it will return the default font if
      *  no matching font is found.
      *
+     *  Passing |nullptr| as the parameter for |familyName| will return the
+     *  default system font.
+     *
      *  It is possible that this will return a style set not accessible from
      *  createStyleSet(int) or matchFamily(const char[]) due to hidden or
      *  auto-activated fonts.
      */
     SkTypeface* matchFamilyStyle(const char familyName[], const SkFontStyle&) const;
 
     /**
      *  Use the system fallback to find a typeface for the given character.
      *  Note that bcp47 is a combination of ISO 639, 15924, and 3166-1 codes,
      *  so it is fine to just pass a ISO 639 here.
      *
      *  Will return NULL if no family can be found for the character
      *  in the system fallback.
      *
+     *  Passing |nullptr| as the parameter for |familyName| will return the
+     *  default system font.
+     *
      *  bcp47[0] is the least significant fallback, bcp47[bcp47Count-1] is the
      *  most significant. If no specified bcp47 codes match, any font with the
      *  requested character will be matched.
      */
     SkTypeface* matchFamilyStyleCharacter(const char familyName[], const SkFontStyle&,
                                           const char* bcp47[], int bcp47Count,
                                           SkUnichar character) const;
 
new file mode 100644
--- /dev/null
+++ b/gfx/skia/skia/include/private/GrAuditTrail.h
@@ -0,0 +1,116 @@
+/*
+ * Copyright 2016 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#ifndef GrAuditTrail_DEFINED
+#define GrAuditTrail_DEFINED
+
+#include "GrConfig.h"
+#include "SkRect.h"
+#include "SkString.h"
+#include "SkTArray.h"
+
+/*
+ * GrAuditTrail collects a list of draw ops, detailed information about those ops, and can dump them
+ * to json.
+ */
+class GrAuditTrail {
+public:
+    GrAuditTrail() : fUniqueID(0) {}
+
+    class AutoFrame {
+    public:
+        AutoFrame(GrAuditTrail* auditTrail, const char* name)
+            : fAuditTrail(auditTrail) {
+            if (GR_BATCH_DEBUGGING_OUTPUT) {
+                fAuditTrail->pushFrame(name);
+            }
+        }
+
+        ~AutoFrame() {
+            if (GR_BATCH_DEBUGGING_OUTPUT) {
+                fAuditTrail->popFrame();
+            }
+        }
+
+    private:
+        GrAuditTrail* fAuditTrail;
+    };
+
+    void pushFrame(const char* name) {
+        SkASSERT(GR_BATCH_DEBUGGING_OUTPUT);
+        Frame* frame = new Frame;
+        if (fStack.empty()) {
+            fFrames.emplace_back(frame);
+        } else {
+            fStack.back()->fChildren.emplace_back(frame);
+        }
+
+        frame->fUniqueID = fUniqueID++;
+        frame->fName = name;
+        fStack.push_back(frame);
+    }
+
+    void popFrame() {
+        SkASSERT(GR_BATCH_DEBUGGING_OUTPUT);
+        fStack.pop_back();
+    }
+
+    void addBatch(const char* name, const SkRect& bounds) {
+        SkASSERT(GR_BATCH_DEBUGGING_OUTPUT && !fStack.empty());
+        Batch* batch = new Batch;
+        fStack.back()->fChildren.emplace_back(batch);
+        batch->fName = name;
+        batch->fBounds = bounds;
+    }
+
+    SkString toJson() const;
+
+    void reset() { SkASSERT(GR_BATCH_DEBUGGING_OUTPUT && fStack.empty()); fFrames.reset(); }
+
+private:
+    // TODO if performance becomes an issue, we can move to using SkVarAlloc
+    struct Event {
+        virtual ~Event() {}
+        virtual SkString toJson() const=0;
+
+        const char* fName;
+        uint64_t fUniqueID;
+    };
+
+    typedef SkTArray<SkAutoTDelete<Event>, true> FrameArray;
+    struct Frame : public Event {
+        SkString toJson() const override;
+        FrameArray fChildren;
+    };
+
+    struct Batch : public Event {
+        SkString toJson() const override;
+        SkRect fBounds;
+    };
+
+    static void JsonifyTArray(SkString* json, const char* name, const FrameArray& array);
+
+    FrameArray fFrames;
+    SkTArray<Frame*> fStack;
+    uint64_t fUniqueID;
+};
+
+#define GR_AUDIT_TRAIL_INVOKE_GUARD(invoke, ...) \
+    if (GR_BATCH_DEBUGGING_OUTPUT) {             \
+        invoke(__VA_ARGS__);                     \
+    }
+
+#define GR_AUDIT_TRAIL_AUTO_FRAME(audit_trail, framename) \
+    GrAuditTrail::AutoFrame SK_MACRO_APPEND_LINE(auto_frame)(audit_trail, framename);
+
+#define GR_AUDIT_TRAIL_RESET(audit_trail) \
+    GR_AUDIT_TRAIL_INVOKE_GUARD(audit_trail->reset);
+
+#define GR_AUDIT_TRAIL_ADDBATCH(audit_trail, batchname, bounds) \
+    GR_AUDIT_TRAIL_INVOKE_GUARD(audit_trail->addBatch, batchname, bounds);
+
+#endif
new file mode 100644
--- /dev/null
+++ b/gfx/skia/skia/include/private/GrSingleOwner.h
@@ -0,0 +1,55 @@
+/*
+ * Copyright 2016 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#ifndef GrSingleOwner_DEFINED
+#define GrSingleOwner_DEFINED
+
+#include "SkTypes.h"
+
+#ifdef SK_DEBUG
+#include "SkMutex.h"
+#include "SkThreadID.h"
+
+// This is a debug tool to verify an object is only being used from one thread at a time.
+class GrSingleOwner {
+public:
+     GrSingleOwner() : fOwner(kIllegalThreadID), fReentranceCount(0) {}
+
+     struct AutoEnforce {
+         AutoEnforce(GrSingleOwner* so) : fSO(so) { fSO->enter(); }
+         ~AutoEnforce() { fSO->exit(); }
+
+         GrSingleOwner* fSO;
+     };
+
+private:
+     void enter() {
+         SkAutoMutexAcquire lock(fMutex);
+         SkThreadID self = SkGetThreadID();
+         SkASSERT(fOwner == self || fOwner == kIllegalThreadID);
+         fReentranceCount++;
+         fOwner = self;
+     }
+
+     void exit() {
+         SkAutoMutexAcquire lock(fMutex);
+         SkASSERT(fOwner == SkGetThreadID());
+         fReentranceCount--;
+         if (fReentranceCount == 0) {
+             fOwner = kIllegalThreadID;
+         }
+     }
+
+     SkMutex fMutex;
+     SkThreadID fOwner;    // guarded by fMutex
+     int fReentranceCount; // guarded by fMutex
+};
+#else
+class GrSingleOwner {}; // Provide a dummy implementation so we can pass pointers to constructors
+#endif
+
+#endif
--- a/gfx/skia/skia/include/private/SkFloatingPoint.h
+++ b/gfx/skia/skia/include/private/SkFloatingPoint.h
@@ -7,17 +7,17 @@
  */
 
 
 #ifndef SkFloatingPoint_DEFINED
 #define SkFloatingPoint_DEFINED
 
 #include "SkTypes.h"
 
-#include <math.h>
+#include <cmath>
 #include <float.h>
 
 // For _POSIX_VERSION
 #if defined(__unix__) || (defined(__APPLE__) && defined(__MACH__))
 #include <unistd.h>
 #endif
 
 #include "SkFloatBits.h"
@@ -90,19 +90,19 @@ static inline float sk_float_copysign(fl
 #ifdef SK_BUILD_FOR_WIN
     #define sk_float_isfinite(x)    _finite(x)
     #define sk_float_isnan(x)       _isnan(x)
     static inline int sk_float_isinf(float x) {
         int32_t bits = SkFloat2Bits(x);
         return (bits << 1) == (0xFF << 24);
     }
 #else
-    #define sk_float_isfinite(x)    isfinite(x)
-    #define sk_float_isnan(x)       isnan(x)
-    #define sk_float_isinf(x)       isinf(x)
+    #define sk_float_isfinite(x)    std::isfinite(x)
+    #define sk_float_isnan(x)       std::isnan(x)
+    #define sk_float_isinf(x)       std::isinf(x)
 #endif
 
 #define sk_double_isnan(a)          sk_float_isnan(a)
 
 #ifdef SK_USE_FLOATBITS
     #define sk_float_floor2int(x)   SkFloatToIntFloor(x)
     #define sk_float_round2int(x)   SkFloatToIntRound(x)
     #define sk_float_ceil2int(x)    SkFloatToIntCeil(x)
--- a/gfx/skia/skia/include/private/SkRecords.h
+++ b/gfx/skia/skia/include/private/SkRecords.h
@@ -5,16 +5,17 @@
  * found in the LICENSE file.
  */
 
 #ifndef SkRecords_DEFINED
 #define SkRecords_DEFINED
 
 #include "SkCanvas.h"
 #include "SkDrawable.h"
+#include "SkImageFilter.h"
 #include "SkMatrix.h"
 #include "SkPath.h"
 #include "SkPicture.h"
 #include "SkRect.h"
 #include "SkRRect.h"
 #include "SkRSXform.h"
 #include "SkTextBlob.h"
 
@@ -58,17 +59,16 @@ namespace SkRecords {
     M(DrawPicture)                                                  \
     M(DrawPoints)                                                   \
     M(DrawPosText)                                                  \
     M(DrawPosTextH)                                                 \
     M(DrawText)                                                     \
     M(DrawTextOnPath)                                               \
     M(DrawRRect)                                                    \
     M(DrawRect)                                                     \
-    M(DrawSprite)                                                   \
     M(DrawTextBlob)                                                 \
     M(DrawAtlas)                                                    \
     M(DrawVertices)
 
 // Defines SkRecords::Type, an enum of all record types.
 #define ENUM(T) T##_Type,
 enum Type { SK_RECORD_TYPES(ENUM) };
 #undef ENUM
@@ -193,17 +193,18 @@ RECORD(NoOp, 0);
 RECORD(Restore, 0,
         SkIRect devBounds;
         TypedMatrix matrix);
 RECORD(Save, 0);
 
 RECORD(SaveLayer, 0,
        Optional<SkRect> bounds;
        Optional<SkPaint> paint;
-       SkCanvas::SaveFlags flags);
+       RefBox<const SkImageFilter> backdrop;
+       SkCanvas::SaveLayerFlags saveLayerFlags);
 
 RECORD(SetMatrix, 0,
         TypedMatrix matrix);
 RECORD(Concat, 0,
         TypedMatrix matrix);
 
 struct RegionOpAndAA {
     RegionOpAndAA() {}
@@ -310,21 +311,16 @@ RECORD(DrawPosTextH, kDraw_Tag|kHasText_
         SkScalar y;
         PODArray<SkScalar> xpos);
 RECORD(DrawRRect, kDraw_Tag,
         SkPaint paint;
         SkRRect rrect);
 RECORD(DrawRect, kDraw_Tag,
         SkPaint paint;
         SkRect rect);
-RECORD(DrawSprite, kDraw_Tag|kHasImage_Tag,
-        Optional<SkPaint> paint;
-        ImmutableBitmap bitmap;
-        int left;
-        int top);
 RECORD(DrawText, kDraw_Tag|kHasText_Tag,
         SkPaint paint;
         PODArray<char> text;
         size_t byteLength;
         SkScalar x;
         SkScalar y);
 RECORD(DrawTextBlob, kDraw_Tag|kHasText_Tag,
         SkPaint paint;
rename from gfx/skia/skia/include/core/SkTDict.h
rename to gfx/skia/skia/include/private/SkTDict.h
--- a/gfx/skia/skia/include/private/SkTLogic.h
+++ b/gfx/skia/skia/include/private/SkTLogic.h
@@ -1,209 +1,155 @@
 /*
  * Copyright 2013 Google Inc.
  *
  * Use of this source code is governed by a BSD-style license that can be
  * found in the LICENSE file.
  *
  *
- * This header provides some of the helpers (std::integral_constant) and
- * type transformations (std::conditional) which will become available with
- * C++11 in the type_traits header.
+ * This header provides some of the helpers (like std::enable_if_t) which will
+ * become available with C++14 in the type_traits header (in the skstd
+ * namespace). This header also provides several Skia specific additions such
+ * as SK_WHEN and the sknonstd namespace.
  */
 
 #ifndef SkTLogic_DEFINED
 #define SkTLogic_DEFINED
 
 #include "SkTypes.h"
 
 #include <stddef.h>
 #include <stdint.h>
+#include <utility>
+
+#if SKIA_IMPLEMENTATION
+#include <algorithm>
+#endif
+
+#ifdef MOZ_SKIA
+#include "mozilla/Move.h"
+#include "mozilla/TypeTraits.h"
+
+#if SKIA_IMPLEMENTATION
+#include "mozilla/Function.h"
+#endif
+
+namespace std {
+    using mozilla::Forward;
+    #define forward Forward
+
+#if SKIA_IMPLEMENTATION
+    using mozilla::IntegralConstant;
+    using mozilla::IsEmpty;
+    using mozilla::FalseType;
+    using mozilla::TrueType;
+    #define integral_constant IntegralConstant
+    #define is_empty IsEmpty
+    #define false_type FalseType
+    #define true_type TrueType
+
+    using mozilla::Function;
+    #define function Function
+#endif
+}
 
 namespace skstd {
 
-using nullptr_t = decltype(nullptr);
+template <bool B> using bool_constant = mozilla::IntegralConstant<bool, B>;
 
-template <typename T, T v> struct integral_constant {
-    static const/*expr*/ T value = v;
-    using value_type = T;
-    using type = integral_constant<T, v>;
-    //constexpr operator value_type() const noexcept { return value; }
-    //constexpr value_type operator()() const noexcept { return value; }
-};
-
-template <bool B> using bool_constant = integral_constant<bool, B>;
-
-using true_type = bool_constant<true>;
-using false_type = bool_constant<false>;
-
-template <bool B, typename T, typename F> struct conditional { using type = T; };
-template <typename T, typename F> struct conditional<false, T, F> { using type = F; };
-template <bool B, typename T, typename F> using conditional_t = typename conditional<B, T, F>::type;
+template <bool B, typename T, typename F> using conditional_t = typename mozilla::Conditional<B, T, F>::Type;
+template <bool B, typename T = void> using enable_if_t = typename mozilla::EnableIf<B, T>::Type;
 
-template <bool B, typename T = void> struct enable_if { using type = T; };
-template <typename T> struct enable_if<false, T> {};
-template <bool B, typename T = void> using enable_if_t = typename enable_if<B, T>::type;
-
-template <typename T> struct remove_const { using type = T; };
-template <typename T> struct remove_const<const T> { using type = T; };
-template <typename T> using remove_const_t = typename remove_const<T>::type;
-
-template <typename T> struct remove_volatile { using type = T; };
-template <typename T> struct remove_volatile<volatile T> { using type = T; };
-template <typename T> using remove_volatile_t = typename remove_volatile<T>::type;
+}
 
-template <typename T> struct remove_cv { using type = remove_volatile_t<remove_const_t<T>>; };
-template <typename T> using remove_cv_t = typename remove_cv<T>::type;
+#else /* !MOZ_SKIA */
 
-template <typename T> struct remove_reference { using type = T; };
-template <typename T> struct remove_reference<T&> { using type = T; };
-template <typename T> struct remove_reference<T&&> { using type = T; };
-template <typename T> using remove_reference_t = typename remove_reference<T>::type;
-
-template <typename T> struct remove_extent { using type = T; };
-template <typename T> struct remove_extent<T[]> { using type = T; };
-template <typename T, size_t N> struct remove_extent<T[N]> { using type = T;};
-template <typename T> using remove_extent_t = typename remove_extent<T>::type;
+#include <type_traits>
+#include <functional>
 
-template <typename T, typename U> struct is_same : false_type {};
-template <typename T> struct is_same<T, T> : true_type {};
-
-template <typename T> struct is_void : is_same<void, remove_cv_t<T>> {};
-
-template <typename T> struct is_const : false_type {};
-template <typename T> struct is_const<const T> : true_type {};
-
-template <typename T> struct is_volatile : false_type {};
-template <typename T> struct is_volatile<volatile T> : true_type {};
+namespace skstd {
 
-template <typename T> struct is_pointer_detector : false_type {};
-template <typename T> struct is_pointer_detector<T*> : true_type {};
-template <typename T> struct is_pointer : is_pointer_detector<remove_cv_t<T>> {};
+template <bool B> using bool_constant = std::integral_constant<bool, B>;
 
-template <typename T> struct is_reference : false_type {};
-template <typename T> struct is_reference<T&> : true_type {};
-template <typename T> struct is_reference<T&&> : true_type {};
-
-template <typename T> struct is_lvalue_reference : false_type {};
-template <typename T> struct is_lvalue_reference<T&> : true_type {};
+template <bool B, typename T, typename F> using conditional_t = typename std::conditional<B, T, F>::type;
+template <bool B, typename T = void> using enable_if_t = typename std::enable_if<B, T>::type;
 
-template <typename T> struct is_rvalue_reference : false_type {};
-template <typename T> struct is_rvalue_reference<T&&> : true_type {};
-
-template <typename T> struct is_class_detector {
-    using yes_type = uint8_t;
-    using no_type = uint16_t;
-    template <typename U> static yes_type clazz(int U::*);
-    template <typename U> static no_type clazz(...);
-    static const/*expr*/ bool value = sizeof(clazz<T>(0)) == sizeof(yes_type) /*&& !is_union<T>::value*/;
-};
-template <typename T> struct is_class : bool_constant<is_class_detector<T>::value> {};
-
-template <typename T, bool = is_class<T>::value> struct is_empty_detector {
-    struct Derived : public T { char unused; };
-    static const/*expr*/ bool value = sizeof(Derived) == sizeof(char);
-};
-template <typename T> struct is_empty_detector<T, false> {
-    static const/*expr*/ bool value = false;
-};
-template <typename T> struct is_empty : bool_constant<is_empty_detector<T>::value> {};
-
-template <typename T> struct is_array : false_type {};
-template <typename T> struct is_array<T[]> : true_type {};
-template <typename T, size_t N> struct is_array<T[N]> : true_type {};
+template <typename T> using remove_const_t = typename std::remove_const<T>::type;
+template <typename T> using remove_volatile_t = typename std::remove_volatile<T>::type;
+template <typename T> using remove_cv_t = typename std::remove_cv<T>::type;
+template <typename T> using remove_pointer_t = typename std::remove_pointer<T>::type;
+template <typename T> using remove_reference_t = typename std::remove_reference<T>::type;
+template <typename T> using remove_extent_t = typename std::remove_extent<T>::type;
 
 // template<typename R, typename... Args> struct is_function<
-//     R [calling-convention] (Args...[, ...]) [const] [volatile] [&|&&]> : true_type {};
+//     R [calling-convention] (Args...[, ...]) [const] [volatile] [&|&&]> : std::true_type {};
 // The cv and ref-qualified versions are strange types we're currently avoiding, so not supported.
+// These aren't supported in msvc either until vs2015u2.
 // On all platforms, variadic functions only exist in the c calling convention.
-template <typename> struct is_function : false_type { };
+// mcvc 2013 introduced __vectorcall, but it wan't until 2015 that it was added to is_function.
+template <typename> struct is_function : std::false_type {};
 #if !defined(SK_BUILD_FOR_WIN)
-template <typename R, typename... Args> struct is_function<R(Args...)> : true_type {};
+template <typename R, typename... Args> struct is_function<R(Args...)> : std::true_type {};
 #else
-template <typename R, typename... Args> struct is_function<R __cdecl (Args...)> : true_type {};
+template <typename R, typename... Args> struct is_function<R __cdecl (Args...)> : std::true_type {};
 #if defined(_M_IX86)
-template <typename R, typename... Args> struct is_function<R __stdcall (Args...)> : true_type {};
-template <typename R, typename... Args> struct is_function<R __fastcall (Args...)> : true_type {};
+template <typename R, typename... Args> struct is_function<R __stdcall (Args...)> : std::true_type {};
+template <typename R, typename... Args>