skia2/samplecode
mtklein 00b621cfc0 Add sk_parallel_for()
This should be a drop-in replacement for most for-loops to make them run in parallel:
   for (int i = 0; i < N; i++) { code... }
   ~~~>
   sk_parallel_for(N, [&](int i) { code... });

This is just syntax sugar over SkTaskGroup to make this use case really easy to write.
There's no more overhead that we weren't already forced to add using an interface like batch(),
and no extra heap allocations.

I've replaced 3 uses of SkTaskGroup with sk_parallel_for:
  1) My unit tests for SkOnce.
  2) Cary's path fuzzer.
  3) SkMultiPictureDraw.
Performance should be the same.  Please compare left and right for readability. :)

BUG=skia:

No public API changes.
TBR=reed@google.com

Review URL: https://codereview.chromium.org/1184373003
2015-06-17 15:26:15 -07:00
..
ClockFaceView.cpp C++11 override should now be supported by all of {bots,Chrome,Android,Mozilla} 2015-03-25 18:17:32 -07:00
GMSampleView.cpp move GMSampleView into its own cpp 2015-02-21 09:36:50 -08:00
GMSampleView.h C++11 override should now be supported by all of {bots,Chrome,Android,Mozilla} 2015-03-25 18:17:32 -07:00
OverView.cpp C++11 override should now be supported by all of {bots,Chrome,Android,Mozilla} 2015-03-25 18:17:32 -07:00
OverView.h Add a header for OverView.cpp as well. 2012-09-18 01:52:20 +00:00
Sample2PtRadial.cpp remove redundant/deprecated TwoPointRadial gradiet -- use TwoPointConical 2015-05-04 08:32:51 -07:00
SampleAAClip.cpp replace SkBitmap::Config with SkColorType in gms 2014-02-17 21:21:46 +00:00
SampleAARectModes.cpp Move SkShader::fLocalMatrix into SkShader constructor. 2014-04-28 14:55:39 +00:00
SampleAARects.cpp use SkColorType instead of SkBitmap::Config in samplecode 2014-02-17 02:55:57 +00:00
SampleAll.cpp delete (unused) TransparentShader 2015-06-05 11:31:26 -07:00
SampleAnimator.cpp Make SkStream *not* ref counted. 2015-01-21 12:09:53 -08:00
SampleAnimBlur.cpp C++11 override should now be supported by all of {bots,Chrome,Android,Mozilla} 2015-03-25 18:17:32 -07:00
SampleApp.cpp Use SkPaintFilterCanvas for SampleApp paint filtering 2015-06-15 07:07:32 -07:00
SampleApp.h Use SkPaintFilterCanvas for SampleApp paint filtering 2015-06-15 07:07:32 -07:00
SampleArc.cpp C++11 override should now be supported by all of {bots,Chrome,Android,Mozilla} 2015-03-25 18:17:32 -07:00
SampleBigBlur.cpp move common blur types into central header 2014-04-28 16:25:35 +00:00
SampleBigGradient.cpp Sanitizing source files in Skia_Periodic_House_Keeping 2013-01-26 07:06:02 +00:00
SampleBitmapRect.cpp C++11 override should now be supported by all of {bots,Chrome,Android,Mozilla} 2015-03-25 18:17:32 -07:00
SampleBlur.cpp move common blur types into central header 2014-04-28 16:25:35 +00:00
SampleBox.cpp Sanitizing source files in Skia_Periodic_House_Keeping 2013-01-26 07:06:02 +00:00
SampleCamera.cpp C++11 override should now be supported by all of {bots,Chrome,Android,Mozilla} 2015-03-25 18:17:32 -07:00
SampleChart.cpp C++11 override should now be supported by all of {bots,Chrome,Android,Mozilla} 2015-03-25 18:17:32 -07:00
SampleCircle.cpp add peekPixels to SkCanvas and SkSurface 2014-02-13 17:14:46 +00:00
SampleClamp.cpp Sanitizing source files in Skia_Periodic_House_Keeping 2013-01-26 07:06:02 +00:00
SampleClip.cpp Change old PRG to be SkLCGRandom; change new one to SkRandom 2013-09-09 20:09:12 +00:00
SampleClipDrawMatch.cpp C++11 override should now be supported by all of {bots,Chrome,Android,Mozilla} 2015-03-25 18:17:32 -07:00
SampleClock.cpp C++11 override should now be supported by all of {bots,Chrome,Android,Mozilla} 2015-03-25 18:17:32 -07:00
SampleCode.h C++11 override should now be supported by all of {bots,Chrome,Android,Mozilla} 2015-03-25 18:17:32 -07:00
SampleColorFilter.cpp s/sk_tools::DrawCheckerboard/sk_tool_utils::draw_checkerboard/ 2015-01-26 12:49:00 -08:00
SampleComplexClip.cpp fix more 64bit warnings 2014-01-27 13:42:58 +00:00
SampleConcavePaths.cpp Sanitizing source files in Skia_Periodic_House_Keeping 2013-01-26 07:06:02 +00:00
SampleCull.cpp deprecate SkScalarRound (and its ilk), use SkScalarRound[ToInt,ToScalar]. #define SK_SUPPORT_DEPRECATED_SCALARROUND for legacy clients 2013-12-17 19:22:07 +00:00
SampleDash.cpp Move SkShader::fLocalMatrix into SkShader constructor. 2014-04-28 14:55:39 +00:00
SampleDegenerateTwoPtRadials.cpp C++11 override should now be supported by all of {bots,Chrome,Android,Mozilla} 2015-03-25 18:17:32 -07:00
SampleDither.cpp add new copyTo version to SkBitmap, which takes SkColorType 2014-02-23 03:59:35 +00:00
SampleDitherBitmap.cpp remove alphatype from colortable 2014-09-29 12:10:27 -07:00
SampleDraw.cpp Sanitizing source files in Skia_Periodic_House_Keeping 2013-01-26 07:06:02 +00:00
SampleEffects.cpp move common blur types into central header 2014-04-28 16:25:35 +00:00
SampleEmboss.cpp remove unused Kernel33MaskFilter 2014-05-12 13:35:55 +00:00
SampleEmptyPath.cpp Clean up SkTypes.h. 2013-10-11 18:50:45 +00:00
SampleEncode.cpp add ImageGenerator::NewFromData to porting layer 2015-01-07 18:04:45 -08:00
SampleFatBits.cpp C++11 override should now be supported by all of {bots,Chrome,Android,Mozilla} 2015-03-25 18:17:32 -07:00
SampleFillType.cpp Sanitizing source files in Skia_Periodic_House_Keeping 2013-01-26 07:06:02 +00:00
SampleFilter2.cpp SkPaint::FilterLevel -> SkFilterQuality 2015-03-16 10:08:34 -07:00
SampleFilter.cpp SkPaint::FilterLevel -> SkFilterQuality 2015-03-16 10:08:34 -07:00
SampleFilterFuzz.cpp Move SkMatrixImageFilter into core, and add a factory fn for it. 2015-03-20 06:38:17 -07:00
SampleFilterQuality.cpp C++11 override should now be supported by all of {bots,Chrome,Android,Mozilla} 2015-03-25 18:17:32 -07:00
SampleFontCache.cpp use SkColorType instead of SkBitmap::Config in samplecode 2014-02-17 02:55:57 +00:00
SampleFontScalerTest.cpp remove SkFloatToScalar macro 2013-11-25 19:44:07 +00:00
SampleFuzz.cpp move common blur types into central header 2014-04-28 16:25:35 +00:00
SampleGradients.cpp remove redundant/deprecated TwoPointRadial gradiet -- use TwoPointConical 2015-05-04 08:32:51 -07:00
SampleHairCurves.cpp Change old PRG to be SkLCGRandom; change new one to SkRandom 2013-09-09 20:09:12 +00:00
SampleHairline.cpp C++11 override should now be supported by all of {bots,Chrome,Android,Mozilla} 2015-03-25 18:17:32 -07:00
SampleHairModes.cpp Move SkShader::fLocalMatrix into SkShader constructor. 2014-04-28 14:55:39 +00:00
SampleHT.cpp C++11 override should now be supported by all of {bots,Chrome,Android,Mozilla} 2015-03-25 18:17:32 -07:00
SampleIdentityScale.cpp C++11 override should now be supported by all of {bots,Chrome,Android,Mozilla} 2015-03-25 18:17:32 -07:00
SampleLayerMask.cpp Reduce internal explicit SaveFlags usage. 2014-04-18 14:19:31 +00:00
SampleLayers.cpp C++11 override should now be supported by all of {bots,Chrome,Android,Mozilla} 2015-03-25 18:17:32 -07:00
SampleLCD.cpp Sanitizing source files in Skia_Periodic_House_Keeping 2013-01-26 07:06:02 +00:00
SampleLines.cpp C++11 override should now be supported by all of {bots,Chrome,Android,Mozilla} 2015-03-25 18:17:32 -07:00
SampleLua.cpp C++11 override should now be supported by all of {bots,Chrome,Android,Mozilla} 2015-03-25 18:17:32 -07:00
SampleManyRects.cpp C++11 override should now be supported by all of {bots,Chrome,Android,Mozilla} 2015-03-25 18:17:32 -07:00
SampleMeasure.cpp remove (unused) scale parameter from measureText 2014-08-26 11:30:01 -07:00
SamplePatch.cpp C++11 override should now be supported by all of {bots,Chrome,Android,Mozilla} 2015-03-25 18:17:32 -07:00
SamplePath.cpp C++11 override should now be supported by all of {bots,Chrome,Android,Mozilla} 2015-03-25 18:17:32 -07:00
SamplePathClip.cpp C++11 override should now be supported by all of {bots,Chrome,Android,Mozilla} 2015-03-25 18:17:32 -07:00
SamplePathEffects.cpp C++11 override should now be supported by all of {bots,Chrome,Android,Mozilla} 2015-03-25 18:17:32 -07:00
SamplePathFill.cpp Sanitizing source files in Skia_Periodic_House_Keeping 2013-01-26 07:06:02 +00:00
SamplePathFuzz.cpp Add sk_parallel_for() 2015-06-17 15:26:15 -07:00
SamplePdfFileViewer.cpp remove remaining references to Sk64 (obsolete) 2014-01-13 14:53:55 +00:00
SamplePictFile.cpp C++11 override should now be supported by all of {bots,Chrome,Android,Mozilla} 2015-03-25 18:17:32 -07:00
SamplePicture.cpp C++11 override should now be supported by all of {bots,Chrome,Android,Mozilla} 2015-03-25 18:17:32 -07:00
SamplePoints.cpp remove unused Kernel33MaskFilter 2014-05-12 13:35:55 +00:00
SamplePolyToPoly.cpp remove SkFloatToScalar macro 2013-11-25 19:44:07 +00:00
SampleQuadStroker.cpp remove SK_LEGACY_STROKE_CURVES 2015-05-22 06:26:52 -07:00
SampleRectanizer.cpp C++11 override should now be supported by all of {bots,Chrome,Android,Mozilla} 2015-03-25 18:17:32 -07:00
SampleRegion.cpp C++11 override should now be supported by all of {bots,Chrome,Android,Mozilla} 2015-03-25 18:17:32 -07:00
SampleRepeatTile.cpp C++11 override should now be supported by all of {bots,Chrome,Android,Mozilla} 2015-03-25 18:17:32 -07:00
SampleShaders.cpp delete (unused) TransparentShader 2015-06-05 11:31:26 -07:00
SampleShaderText.cpp remove redundant/deprecated TwoPointRadial gradiet -- use TwoPointConical 2015-05-04 08:32:51 -07:00
SampleSkLayer.cpp deprecate SkScalarRound (and its ilk), use SkScalarRound[ToInt,ToScalar]. #define SK_SUPPORT_DEPRECATED_SCALARROUND for legacy clients 2013-12-17 19:22:07 +00:00
SampleSlides.cpp remove redundant/deprecated TwoPointRadial gradiet -- use TwoPointConical 2015-05-04 08:32:51 -07:00
SampleStringArt.cpp Revert of Revert of stop calling SkScalarDiv (patchset #1 id:1 of https://codereview.chromium.org/1138263002/) 2015-05-12 10:37:34 -07:00
SampleStrokePath.cpp C++11 override should now be supported by all of {bots,Chrome,Android,Mozilla} 2015-03-25 18:17:32 -07:00
SampleStrokeRect.cpp Sanitizing source files in Skia_Periodic_House_Keeping 2013-01-26 07:06:02 +00:00
SampleSubpixelTranslate.cpp C++11 override should now be supported by all of {bots,Chrome,Android,Mozilla} 2015-03-25 18:17:32 -07:00
SampleText.cpp C++11 override should now be supported by all of {bots,Chrome,Android,Mozilla} 2015-03-25 18:17:32 -07:00
SampleTextAlpha.cpp C++11 override should now be supported by all of {bots,Chrome,Android,Mozilla} 2015-03-25 18:17:32 -07:00
SampleTextBox.cpp Sanitizing source files in Skia_Periodic_House_Keeping 2013-01-26 07:06:02 +00:00
SampleTextOnPath.cpp C++11 override should now be supported by all of {bots,Chrome,Android,Mozilla} 2015-03-25 18:17:32 -07:00
SampleTextureDomain.cpp SkPaint::FilterLevel -> SkFilterQuality 2015-03-16 10:08:34 -07:00
SampleTiling.cpp SkPaint::FilterLevel -> SkFilterQuality 2015-03-16 10:08:34 -07:00
SampleTinyBitmap.cpp use SkColorType instead of SkBitmap::Config in samplecode 2014-02-17 02:55:57 +00:00
SampleUnpremul.cpp C++11 override should now be supported by all of {bots,Chrome,Android,Mozilla} 2015-03-25 18:17:32 -07:00
SampleVertices.cpp C++11 override should now be supported by all of {bots,Chrome,Android,Mozilla} 2015-03-25 18:17:32 -07:00
SampleWritePixels.cpp use SkColorType instead of SkBitmap::Config in samplecode 2014-02-17 02:55:57 +00:00
SampleXfermodesBlur.cpp Revert "Revert of add colortable support to imagegenerator (https://codereview.chromium.org/304443003/)" 2014-05-29 15:57:20 +00:00
vertexdump.cpp remove SkFloatToScalar macro 2013-11-25 19:44:07 +00:00