Modernize and trim down SkOnce.
authormtklein <mtklein@chromium.org>
Mon, 18 Apr 2016 15:09:11 +0000 (08:09 -0700)
committerCommit bot <commit-bot@chromium.org>
Mon, 18 Apr 2016 15:09:11 +0000 (08:09 -0700)
commitd9dd4282118fc14eac735e6fa0b3ec53047b457f
treeb88bce11cbcec3100e428b713df49e1fcd83f8d2
parentf7142e71d7c0a7d8406679e207ff766085499d2e
Modernize and trim down SkOnce.

The API and implementation are very much simplified.
You may not want to bother reading the diff.

As is our trend, SkOnce now uses <atomic> directly.

Member initialization means we don't need SK_DECLARE_STATIC_ONCE.
SkSpinlock already works this same way.

All uses of the old API taking an external bool* and Lock* were pessimal,
so I have not carried this sort of API forward.  It's simpler, faster,
and more space-efficient to always use this single SkOnce class interface.

SkOnce weighs 2 bytes: a done bool and an SkSpinlock, also a bool internally.
This API refactoring opens up the opportunity to fuse those into a single
three-state byte if we'd like.

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

BUG=skia:
GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1894893002

Review URL: https://codereview.chromium.org/1894893002
15 files changed:
include/effects/SkColorCubeFilter.h
include/gpu/GrResourceKey.h
include/ports/SkFontMgr_indirect.h
include/private/SkOnce.h
src/core/SkGlobalInitialization_core.cpp
src/core/SkOpts.cpp
src/core/SkTaskGroup.cpp
src/effects/SkColorCubeFilter.cpp
src/effects/gradients/SkGradientShader.cpp
src/effects/gradients/SkGradientShaderPriv.h
src/fonts/SkFontMgr_indirect.cpp
src/gpu/GrProgramElement.cpp
src/utils/win/SkDWrite.cpp
tests/OnceTest.cpp
tools/gpu/gl/command_buffer/GLTestContext_command_buffer.cpp