diff --git a/dm/DM.cpp b/dm/DM.cpp index 043d00b9ae..e055b833b4 100644 --- a/dm/DM.cpp +++ b/dm/DM.cpp @@ -888,7 +888,7 @@ static bool gather_srcs() { return false; } - for (auto image : images) { + for (const SkString& image : images) { push_codec_srcs(image); } @@ -897,7 +897,7 @@ static bool gather_srcs() { return false; } - for (auto colorImage : colorImages) { + for (const SkString& colorImage : colorImages) { push_src("colorImage", "decode_native", new ColorCodecSrc(colorImage, false)); push_src("colorImage", "decode_to_dst", new ColorCodecSrc(colorImage, true)); } diff --git a/gm/all_bitmap_configs.cpp b/gm/all_bitmap_configs.cpp index 0d808e25c2..3b3dfb278f 100644 --- a/gm/all_bitmap_configs.cpp +++ b/gm/all_bitmap_configs.cpp @@ -242,7 +242,7 @@ DEF_SIMPLE_GM(all_variants_8888, canvas, 4 * SCALE + 30, 2 * SCALE + 10) { SkColorSpace::MakeSRGB(), nullptr, }; - for (auto colorSpace : colorSpaces) { + for (const sk_sp& colorSpace : colorSpaces) { canvas->save(); for (auto alphaType : {kPremul_SkAlphaType, kUnpremul_SkAlphaType}) { canvas->save(); diff --git a/gm/color4f.cpp b/gm/color4f.cpp index 8a99c14253..3b9dfe42fc 100644 --- a/gm/color4f.cpp +++ b/gm/color4f.cpp @@ -81,7 +81,7 @@ DEF_SIMPLE_GM(color4f, canvas, 1024, 260) { nullptr, SkColorSpace::MakeSRGB() }; - for (auto colorSpace : colorSpaces) { + for (const sk_sp& colorSpace : colorSpaces) { const SkImageInfo info = SkImageInfo::Make(1024, 100, kN32_SkColorType, kPremul_SkAlphaType, colorSpace); auto surface(SkSurface::MakeRaster(info)); diff --git a/gm/drawatlas.cpp b/gm/drawatlas.cpp index 1c70e7e2ac..2ea54bb11e 100644 --- a/gm/drawatlas.cpp +++ b/gm/drawatlas.cpp @@ -340,7 +340,7 @@ DEF_SIMPLE_GM(compare_atlas_vertices, canvas, 560, 585) { for (float alpha : { 1.0f, 0.5f }) { paint.setAlphaf(alpha); canvas->save(); - for (auto cf : filters) { + for (const sk_sp& cf : filters) { paint.setColorFilter(cf); canvas->drawAtlas(image, &xform, &tex, &color, 1, mode, &tex, &paint); diff --git a/gm/encode_srgb.cpp b/gm/encode_srgb.cpp index 0db8dc1079..380bb7fe64 100644 --- a/gm/encode_srgb.cpp +++ b/gm/encode_srgb.cpp @@ -129,7 +129,7 @@ protected: for (SkColorType colorType : colorTypes) { for (SkAlphaType alphaType : alphaTypes) { canvas->save(); - for (sk_sp colorSpace : colorSpaces) { + for (const sk_sp& colorSpace : colorSpaces) { make(&bitmap, colorType, alphaType, colorSpace); auto image = SkImage::MakeFromEncoded(encode_data(bitmap, fEncodedFormat)); canvas->drawImage(image.get(), 0.0f, 0.0f); diff --git a/gm/image.cpp b/gm/image.cpp index c4c417d8da..2d66e86655 100644 --- a/gm/image.cpp +++ b/gm/image.cpp @@ -366,8 +366,8 @@ DEF_SIMPLE_GPU_GM(new_texture_image, context, rtc, canvas, 280, 60) { constexpr SkScalar kPad = 5.f; canvas->translate(kPad, kPad); - for (auto factory : imageFactories) { - auto image(factory()); + for (const auto& factory : imageFactories) { + sk_sp image(factory()); if (image) { sk_sp texImage(image->makeTextureImage(direct)); if (texImage) { diff --git a/gm/patheffects.cpp b/gm/patheffects.cpp index 695d5e24f0..7d82f85b12 100644 --- a/gm/patheffects.cpp +++ b/gm/patheffects.cpp @@ -218,9 +218,9 @@ protected: paint.setColor(0xFF8888FF); paint.setAntiAlias(true); - for (auto& path : { path0, path1 }) { + for (const SkPath& path : { path0, path1 }) { canvas->save(); - for (auto pe : effects) { + for (const sk_sp& pe : effects) { paint.setPathEffect(pe); canvas->drawPath(path, paint); canvas->drawPath(path, wireframe); diff --git a/gm/readpixels.cpp b/gm/readpixels.cpp index 1fad98fc3f..6095865263 100644 --- a/gm/readpixels.cpp +++ b/gm/readpixels.cpp @@ -158,7 +158,7 @@ protected: make_small_gamut(), }; - for (sk_sp dstColorSpace : colorSpaces) { + for (const sk_sp& dstColorSpace : colorSpaces) { for (SkColorType srcColorType : colorTypes) { canvas->save(); sk_sp image = make_raster_image(srcColorType); @@ -227,7 +227,7 @@ protected: }; sk_sp image = make_codec_image(); - for (sk_sp dstColorSpace : colorSpaces) { + for (const sk_sp& dstColorSpace : colorSpaces) { canvas->save(); for (SkColorType dstColorType : colorTypes) { for (SkAlphaType dstAlphaType : alphaTypes) { @@ -293,8 +293,8 @@ protected: SkImage::kDisallow_CachingHint, }; - for (sk_sp image : images) { - for (sk_sp dstColorSpace : colorSpaces) { + for (const sk_sp& image : images) { + for (const sk_sp& dstColorSpace : colorSpaces) { canvas->save(); for (SkColorType dstColorType : colorTypes) { for (SkAlphaType dstAlphaType : alphaTypes) { diff --git a/src/gpu/GrDrawOpAtlas.cpp b/src/gpu/GrDrawOpAtlas.cpp index ffea3e10b3..39bb49b187 100644 --- a/src/gpu/GrDrawOpAtlas.cpp +++ b/src/gpu/GrDrawOpAtlas.cpp @@ -262,7 +262,7 @@ GrDrawOpAtlas::GrDrawOpAtlas( } inline void GrDrawOpAtlas::processEviction(PlotLocator plotLocator) { - for (auto evictor : fEvictionCallbacks) { + for (EvictionCallback* evictor : fEvictionCallbacks) { evictor->evict(plotLocator); } diff --git a/src/gpu/ccpr/GrCCPathCache.cpp b/src/gpu/ccpr/GrCCPathCache.cpp index b1037bb61a..cb86b55435 100644 --- a/src/gpu/ccpr/GrCCPathCache.cpp +++ b/src/gpu/ccpr/GrCCPathCache.cpp @@ -106,7 +106,7 @@ GrCCPathCache::~GrCCPathCache() { // Now take all the atlas textures we just invalidated and purge them from the GrResourceCache. // We just purge via message bus since we don't have any access to the resource cache right now. - for (sk_sp& proxy : fInvalidatedProxies) { + for (const sk_sp& proxy : fInvalidatedProxies) { SkMessageBus::Post( GrUniqueKeyInvalidatedMessage(proxy->getUniqueKey(), fContextUniqueID)); } @@ -295,7 +295,7 @@ void GrCCPathCache::purgeEntriesOlderThan(GrProxyProvider* proxyProvider, } void GrCCPathCache::purgeInvalidatedAtlasTextures(GrOnFlushResourceProvider* onFlushRP) { - for (sk_sp& proxy : fInvalidatedProxies) { + for (const sk_sp& proxy : fInvalidatedProxies) { onFlushRP->removeUniqueKeyFromProxy(proxy.get()); } fInvalidatedProxies.reset(); @@ -307,7 +307,7 @@ void GrCCPathCache::purgeInvalidatedAtlasTextures(GrOnFlushResourceProvider* onF } void GrCCPathCache::purgeInvalidatedAtlasTextures(GrProxyProvider* proxyProvider) { - for (sk_sp& proxy : fInvalidatedProxies) { + for (const sk_sp& proxy : fInvalidatedProxies) { proxyProvider->removeUniqueKeyFromProxy(proxy.get()); } fInvalidatedProxies.reset(); diff --git a/src/gpu/dawn/GrDawnCaps.cpp b/src/gpu/dawn/GrDawnCaps.cpp index eeea8eb014..eddad52a3c 100644 --- a/src/gpu/dawn/GrDawnCaps.cpp +++ b/src/gpu/dawn/GrDawnCaps.cpp @@ -214,7 +214,7 @@ std::vector GrDawnCaps::getTestingCombin }; #ifdef SK_DEBUG - for (auto combo : combos) { + for (const GrCaps::TestFormatColorTypeCombination& combo : combos) { SkASSERT(this->onAreColorTypeAndFormatCompatible(combo.fColorType, combo.fFormat)); } #endif diff --git a/src/gpu/mock/GrMockCaps.cpp b/src/gpu/mock/GrMockCaps.cpp index de9e39b90d..cdf9d9fa37 100644 --- a/src/gpu/mock/GrMockCaps.cpp +++ b/src/gpu/mock/GrMockCaps.cpp @@ -75,7 +75,7 @@ std::vector GrMockCaps::getTestingCombin }; #ifdef SK_DEBUG - for (auto combo : combos) { + for (const GrCaps::TestFormatColorTypeCombination& combo : combos) { SkASSERT(this->onAreColorTypeAndFormatCompatible(combo.fColorType, combo.fFormat)); } #endif diff --git a/src/pathops/SkPathOpsAsWinding.cpp b/src/pathops/SkPathOpsAsWinding.cpp index 763427ff23..500dc35309 100644 --- a/src/pathops/SkPathOpsAsWinding.cpp +++ b/src/pathops/SkPathOpsAsWinding.cpp @@ -325,7 +325,7 @@ public: SkPathPriv::Iterate iterate(fPath); auto iter = iterate.begin(); int verbCount = 0; - for (auto contour : contours) { + for (const Contour& contour : contours) { SkPath reverse; SkPath* temp = contour.fReverse ? &reverse : result; for (; iter != iterate.end() && verbCount < contour.fVerbEnd; ++iter, ++verbCount) { diff --git a/src/pdf/SkPDFTag.cpp b/src/pdf/SkPDFTag.cpp index 3b6688dbaa..5cb7da2fec 100644 --- a/src/pdf/SkPDFTag.cpp +++ b/src/pdf/SkPDFTag.cpp @@ -184,7 +184,7 @@ void SkPDF::AttributeList::appendStringArray( std::unique_ptr attrDict = SkPDFMakeDict(); attrDict->insertName("O", owner); std::unique_ptr pdfArray = SkPDFMakeArray(); - for (SkString element : values) { + for (const SkString& element : values) { pdfArray->appendString(element); } attrDict->insertObject(name, std::move(pdfArray)); diff --git a/tests/CopySurfaceTest.cpp b/tests/CopySurfaceTest.cpp index 2780daf7da..58ca6cc885 100644 --- a/tests/CopySurfaceTest.cpp +++ b/tests/CopySurfaceTest.cpp @@ -75,9 +75,9 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(CopySurface, reporter, ctxInfo) { for (auto dOrigin : {kBottomLeft_GrSurfaceOrigin, kTopLeft_GrSurfaceOrigin}) { for (auto sRenderable : {GrRenderable::kYes, GrRenderable::kNo}) { for (auto dRenderable : {GrRenderable::kYes, GrRenderable::kNo}) { - for (auto srcRect : kSrcRects) { - for (auto dstPoint : kDstPoints) { - for (auto ii: kImageInfos) { + for (const SkIRect& srcRect : kSrcRects) { + for (const SkIPoint& dstPoint : kDstPoints) { + for (const SkImageInfo& ii: kImageInfos) { auto src = sk_gpu_test::MakeTextureProxyFromData( direct, sRenderable, sOrigin, ii, srcPixels.get(), kRowBytes); diff --git a/tests/GrSurfaceTest.cpp b/tests/GrSurfaceTest.cpp index 216ce0eb21..fc9bb6334b 100644 --- a/tests/GrSurfaceTest.cpp +++ b/tests/GrSurfaceTest.cpp @@ -105,9 +105,9 @@ DEF_GPUTEST_FOR_ALL_CONTEXTS(GrSurfaceRenderability, reporter, ctxInfo) { static constexpr SkISize kDims = {64, 64}; const std::vector& combos = - caps->getTestingCombinations(); + caps->getTestingCombinations(); - for (auto combo : combos) { + for (const GrCaps::TestFormatColorTypeCombination& combo : combos) { SkASSERT(combo.fColorType != GrColorType::kUnknown); SkASSERT(combo.fFormat.isValid()); @@ -209,9 +209,9 @@ DEF_GPUTEST(InitialTextureClear, reporter, baseOptions) { const GrCaps* caps = context->priv().caps(); const std::vector& combos = - caps->getTestingCombinations(); + caps->getTestingCombinations(); - for (auto combo : combos) { + for (const GrCaps::TestFormatColorTypeCombination& combo : combos) { SkASSERT(combo.fColorType != GrColorType::kUnknown); SkASSERT(combo.fFormat.isValid()); diff --git a/tests/GradientTest.cpp b/tests/GradientTest.cpp index 7d2b5e5a81..ba80793dbe 100644 --- a/tests/GradientTest.cpp +++ b/tests/GradientTest.cpp @@ -456,7 +456,7 @@ static void test_linear_fuzzer(skiatest::Reporter*) { SkPaint paint; - for (auto colorSpace : colorSpaces) { + for (const SkColorSpace* colorSpace : colorSpaces) { sk_sp surface = SkSurface::MakeRaster(SkImageInfo::Make(100, 100, kN32_SkColorType, diff --git a/tests/ImageTest.cpp b/tests/ImageTest.cpp index ef25c61a1a..1340d64195 100644 --- a/tests/ImageTest.cpp +++ b/tests/ImageTest.cpp @@ -393,7 +393,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(SkImage_makeTextureImage, reporter, contextIn return otherContextImage; }}; for (auto mipMapped : {GrMipmapped::kNo, GrMipmapped::kYes}) { - for (auto factory : imageFactories) { + for (const auto& factory : imageFactories) { sk_sp image(factory()); if (!image) { ERRORF(reporter, "Error creating image."); @@ -458,7 +458,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(SkImage_makeNonTextureImage, reporter, contex create_picture_image, [context] { return create_gpu_image(context); }, }; - for (auto factory : imageFactories) { + for (const auto& factory : imageFactories) { sk_sp image = factory(); if (!image->isTextureBacked()) { REPORTER_ASSERT(reporter, image->makeNonTextureImage().get() == image.get()); @@ -1064,11 +1064,12 @@ DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(makeBackendTexture, reporter, ctxInfo) { auto createLarge = [context] { return create_image_large(context->priv().caps()->maxTextureSize()); }; - struct { - std::function ()> fImageFactory; - bool fExpectation; - bool fCanTakeDirectly; - } testCases[] = { + struct TestCase { + std::function()> fImageFactory; + bool fExpectation; + bool fCanTakeDirectly; + }; + TestCase testCases[] = { { create_image, true, false }, { create_codec_image, true, false }, { create_data_image, true, false }, @@ -1085,7 +1086,7 @@ DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(makeBackendTexture, reporter, ctxInfo) { { createLarge, false, false } }; - for (auto testCase : testCases) { + for (const TestCase& testCase : testCases) { sk_sp image(testCase.fImageFactory()); if (!image) { ERRORF(reporter, "Failed to create image!"); diff --git a/tests/PromiseImageTest.cpp b/tests/PromiseImageTest.cpp index 3a41b62d67..126b44b43c 100644 --- a/tests/PromiseImageTest.cpp +++ b/tests/PromiseImageTest.cpp @@ -263,7 +263,7 @@ DEF_GPUTEST(PromiseImageTextureShutdown, reporter, ctxInfo) { continue; } DeathFn contextKillers[] = {destroy, abandon, releaseResourcesAndAbandon}; - for (auto contextDeath : contextKillers) { + for (const DeathFn& contextDeath : contextKillers) { sk_gpu_test::GrContextFactory factory; auto ctx = factory.get(contextType); if (!ctx) { diff --git a/tests/ReadPixelsTest.cpp b/tests/ReadPixelsTest.cpp index 60f1e1eac1..490edacf5c 100644 --- a/tests/ReadPixelsTest.cpp +++ b/tests/ReadPixelsTest.cpp @@ -565,11 +565,11 @@ DEF_TEST(ReadPixels_ValidConversion, reporter) { }; for (SkColorType dstCT : kColorTypes) { - for (SkAlphaType dstAT: kAlphaTypes) { - for (sk_sp dstCS : kColorSpaces) { + for (SkAlphaType dstAT : kAlphaTypes) { + for (const sk_sp& dstCS : kColorSpaces) { for (SkColorType srcCT : kColorTypes) { - for (SkAlphaType srcAT: kAlphaTypes) { - for (sk_sp srcCS : kColorSpaces) { + for (SkAlphaType srcAT : kAlphaTypes) { + for (const sk_sp& srcCS : kColorSpaces) { test_conversion(reporter, SkImageInfo::Make(kNumPixels, 1, dstCT, dstAT, dstCS), SkImageInfo::Make(kNumPixels, 1, srcCT, srcAT, srcCS)); diff --git a/tests/SkColorSpaceXformStepsTest.cpp b/tests/SkColorSpaceXformStepsTest.cpp index c3308ab947..d89a8da682 100644 --- a/tests/SkColorSpaceXformStepsTest.cpp +++ b/tests/SkColorSpaceXformStepsTest.cpp @@ -20,7 +20,7 @@ DEF_TEST(SkColorSpaceXformSteps, r) { opaque = kOpaque_SkAlphaType, unpremul = kUnpremul_SkAlphaType; - struct { + struct Test { sk_sp src, dst; SkAlphaType srcAT, dstAT; @@ -30,7 +30,8 @@ DEF_TEST(SkColorSpaceXformSteps, r) { bool encode; bool premul; - } tests[] = { + }; + Test tests[] = { // The general case is converting between two color spaces with different gamuts // and different transfer functions. There's no optimization possible here. { adobe, srgb, premul, premul, @@ -130,7 +131,7 @@ DEF_TEST(SkColorSpaceXformSteps, r) { }; uint32_t tested = 0x00000000; - for (auto t : tests) { + for (const Test& t : tests) { SkColorSpaceXformSteps steps{t.src.get(), t.srcAT, t.dst.get(), t.dstAT}; REPORTER_ASSERT(r, steps.flags.unpremul == t.unpremul); diff --git a/tests/StreamBufferTest.cpp b/tests/StreamBufferTest.cpp index ce3c5f9a41..a6b71f6621 100644 --- a/tests/StreamBufferTest.cpp +++ b/tests/StreamBufferTest.cpp @@ -90,10 +90,12 @@ DEF_TEST(StreamBuffer, r) { writer.write(gText, size); } - struct { + struct Factory { std::function()> createStream; bool skipIfNoTmpDir; - } factories[] = { + }; + + Factory factories[] = { { [&data]() { return std::make_unique(data); }, false }, { [&data]() { return std::make_unique(data); }, false }, { [&path]() { return path.isEmpty() @@ -101,7 +103,7 @@ DEF_TEST(StreamBuffer, r) { : std::make_unique(path.c_str()); }, true }, }; - for (auto f : factories) { + for (const Factory& f : factories) { if (tmpDir.isEmpty() && f.skipIfNoTmpDir) { continue; } diff --git a/tools/viewer/SkSLSlide.cpp b/tools/viewer/SkSLSlide.cpp index 00f0a14d88..94edbbee7e 100644 --- a/tools/viewer/SkSLSlide.cpp +++ b/tools/viewer/SkSLSlide.cpp @@ -162,7 +162,7 @@ void SkSLSlide::draw(SkCanvas* canvas) { } } - for (const auto [i, name] : SkMakeEnumerate(fEffect->children())) { + for (const auto& [i, name] : SkMakeEnumerate(fEffect->children())) { auto curShader = std::find_if(fShaders.begin(), fShaders.end(), [tgt = fChildren[i]](auto p) { return p.second == tgt; }); SkASSERT(curShader!= fShaders.end());