diff options
author | commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2014-01-14 20:51:26 +0000 |
---|---|---|
committer | commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2014-01-14 20:51:26 +0000 |
commit | 19382421b916aab00be7265815ba4e2690adf2c9 (patch) | |
tree | 8e69446ccf2e3548e9f2986a5eba67a641e76b59 /src/utils/SkCanvasStateUtils.cpp | |
parent | b638a3a941fc9514b3f26165bfaaa7b48a580139 (diff) |
Convert SkWriter32 to use an SkTDArray for its internal storage.
This reduces the allocation overhead of a null picture (create, beginRecording(), endRecording) from about 18K to about 1.9K. (There's still lots more to prune.)
SkPictureFlat can exploit the fact that Writer32 is contiguous simplify its memory management. The Writer32 itself becomes the scratch buffer.
Remove lots and lots of arbitrary magic numbers that were size guesses and minimum allocation sizes. Keep your eyes open for the big obvious DUH why we save 16K per picture! (Spoiler alert. It's because that first save we issue in beginRecording() forces the old SkWriter32 to allocate 16K.)
Tests passing, DM passing.
bench --match writer: ~20% faster
null bench_record: ~30% faster
bench_record on buildbot .skps: ~3-6% slower, ranging 25% faster to 20% slower
bench_pictures on buildbot .skps: ~1-2% faster, ranging 13% faster to 28% slower
BUG=skia:1850
R=reed@google.com
Author: mtklein@google.com
Review URL: https://codereview.chromium.org/137433003
git-svn-id: http://skia.googlecode.com/svn/trunk@13073 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src/utils/SkCanvasStateUtils.cpp')
-rw-r--r-- | src/utils/SkCanvasStateUtils.cpp | 8 |
1 files changed, 2 insertions, 6 deletions
diff --git a/src/utils/SkCanvasStateUtils.cpp b/src/utils/SkCanvasStateUtils.cpp index 9c7d8fab3a..eb92c37b19 100644 --- a/src/utils/SkCanvasStateUtils.cpp +++ b/src/utils/SkCanvasStateUtils.cpp @@ -155,9 +155,7 @@ static void setup_MC_state(SkMCState* state, const SkMatrix& matrix, const SkReg * and some more common complex clips (e.g. a clipRect with a sub-rect * clipped out of its interior) without needing to malloc any additional memory. */ - const int clipBufferSize = 4 * sizeof(ClipRect); - char clipBuffer[clipBufferSize]; - SkWriter32 clipWriter(sizeof(ClipRect), clipBuffer, clipBufferSize); + SkSWriter32<4*sizeof(ClipRect)> clipWriter; if (!clip.isEmpty()) { // only returns the b/w clip so aa clips fail @@ -201,9 +199,7 @@ SkCanvasState* SkCanvasStateUtils::CaptureCanvasState(SkCanvas* canvas) { * some view systems (e.g. Android) that a few non-clipped layers are present * and we will not need to malloc any additional memory in those cases. */ - const int layerBufferSize = 3 * sizeof(SkCanvasLayerState); - char layerBuffer[layerBufferSize]; - SkWriter32 layerWriter(sizeof(SkCanvasLayerState), layerBuffer, layerBufferSize); + SkSWriter32<3*sizeof(SkCanvasLayerState)> layerWriter; int layerCount = 0; for (SkCanvas::LayerIter layer(canvas, true/*skipEmptyClips*/); !layer.done(); layer.next()) { |