Commit ea6f43fb authored by yunchao.he@intel.com's avatar yunchao.he@intel.com

Don't update MemoryCache during drawImage if the image is decoded into DiscardableMemory

Profiling data from perf for content_shell on android shows that ImageResource::didDraw 
is a bottleneck when drawImage APIs are frequently called in Canvas2D benchmarks.

ImageResource::didDraw update info (access time, etc) in MemoryCache and prune the cache if 
necessary. But Images are decoded into DiscardableMemory, which is another cache mechanism 
except for MemoryCache. Images are not in MemoryCache at all, so we don't need to update the 
info in MemoryCache for these resources.

This small CL avoid updating MemoryCache during drawImage to improve performance. Table below 
lists how much BitmapResource::didDraw costs in the whole render process w/ or w/o this CL. 
All benchmarks are tested on Nexus 7.
benchmark           original percentage       CL applied percentage
speedReading               6.9 %                  0.05 % 
GM3 bitmap                 4.5 %                  0.04 %

The FPS of speedReading improved more than 5%. The FPS of GM3_Bitmap improved a little, because 
the original FPS is as high as 58. For other Canvas2D benchmarks(FishIETank, Galactic, etc), 
BitmapResource::didDraw costs ~1.5%. After this CL is applied, it costs about 0.02%. The FPS 
of these benchmarks basically keeps the same because didDraw in these cases is not as heavy as 
it is in speedReading/GM3_Bitmap.

BUG=410663

Review URL: https://codereview.chromium.org/534963003

git-svn-id: svn://svn.chromium.org/blink/trunk@181430 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 4246ef93
...@@ -430,7 +430,11 @@ void ImageResource::didDraw(const blink::Image* image) ...@@ -430,7 +430,11 @@ void ImageResource::didDraw(const blink::Image* image)
{ {
if (!image || image != m_image) if (!image || image != m_image)
return; return;
Resource::didAccessDecodedData(); // decodedSize() == 0 indicates that the image is decoded into DiscardableMemory,
// not in MemoryCache. So we don't need to call Resource::didAccessDecodedData()
// to update MemoryCache.
if (decodedSize() != 0)
Resource::didAccessDecodedData();
} }
bool ImageResource::shouldPauseAnimation(const blink::Image* image) bool ImageResource::shouldPauseAnimation(const blink::Image* image)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment