Fixing leaky handling of SkImage in SkDeferredCanvas.
authorjunov <junov@chromium.org>
Tue, 2 Jun 2015 18:47:45 +0000 (11:47 -0700)
committerCommit bot <commit-bot@chromium.org>
Tue, 2 Jun 2015 18:47:45 +0000 (11:47 -0700)
commitd26c9fa66c45b5a050580772acfbcc1b5271543e
tree8704bc7f574c6300f57819e21613856c1bc75396
parenta66cc7e1e01bab8590fdcfafb269e21bfe8782fa
Fixing leaky handling of SkImage in SkDeferredCanvas.

Long lived SkImageHeap objects currently accumulate refs indefinitely.
This leads to massive memory leaks in the gpu-accelerated 2D canvas
code path. This CL does not implement a general fix for SkGPipe, but
it resolves the leak in SkDeferredCanvas (currently the only user
of SkGPipe) by resetting the image heap when the deferral queue is
flushed. This change also fixes the accounting of bytes allocated
by referenced images in order to trigger flushing heuristics
appropriately.

BUG=crbug.com/494148

Review URL: https://codereview.chromium.org/1145893007
include/pipe/SkGPipe.h
src/pipe/SkGPipePriv.h
src/pipe/SkGPipeWrite.cpp
src/utils/SkDeferredCanvas.cpp
tests/DeferredCanvasTest.cpp