Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(346)

Issue 5877044: Implement image filtering in SkCanvas::drawSprite() (Closed)

Can't Edit
Can't Publish+Mail
Start Review
Created:
13 years, 3 months ago by Stephen White
Modified:
13 years, 2 months ago
Reviewers:
reed, bsalomon, reed1
Base URL:
http://skia.googlecode.com/svn/trunk/
Visibility:
Public.

Description

This change implements image filter processing during SkCanvas::drawSprite(), similar to how it's done in SkCanvas::drawDevice(). On the GPU side, all of the image filtering code was moved from SkGpuDevice::drawSprite() (which no longer needs to do it, since it's handled at the SkCanvas level) to SkGpuDevice::filterImage(). By performing image filtering directly in filterImage(), we can save one texture allocation and draw by returning a texture-backed bitmap instead. By calling drawSprite() directly in the GM samples instead of using saveLayer()/restore(), we save another texture allocation and draw. I also made SkGpuDevice::drawSprite() avoid locking pixels when called with a texture-backed bitmap, an idea I cribbed from SkGpuDevice::internalDrawBitmap(). This gave a 3X speedup on one sample (I'm guessing it's avoiding a readback in that case). All told, these changes improve GPU performance on the morphology sample by 13X, and improve CPU performance by about 3%. On the imageblur sample, GPU performance is improved by 46X, and CPU performance by 2.2X (the latter is a bit of an apples-to-oranges comparsion, though, since some of the gain comes from cacheing the source bitmap and only doing the blur in onDraw()). Finally, I fixed command line parsing of test names in SampleApp, and added a 'q' hotkey for exiting SampleApp (there didn't seem to be any way to exit it cleanly on Linux, needed for profiling). These could be moved to another patch if desired.

Patch Set 1 #

Patch Set 2 : Mike's + option1 (filters supported on GPU side in drawSprite, drawDevice, filterImage) #

Patch Set 3 : Mike's + option2 (filters supported on GPU side only in filterImage) #

Unified diffs Side-by-side diffs Delta from patch set Stats (+210 lines, -128 lines) Patch
gm/imageblur.cpp View 1 3 chunks +18 lines, -4 lines 0 comments Download
gm/morphology.cpp View 1 1 chunk +1 line, -6 lines 0 comments Download
gyp/gmslides.gypi View 1 1 chunk +1 line, -0 lines 0 comments Download
include/core/SkCanvas.h View 1 2 chunks +4 lines, -2 lines 0 comments Download
include/core/SkDevice.h View 1 1 chunk +15 lines, -6 lines 0 comments Download
include/core/SkImageFilter.h View 1 1 chunk +4 lines, -2 lines 0 comments Download
include/gpu/SkGpuDevice.h View 1 1 chunk +3 lines, -3 lines 0 comments Download
samplecode/SampleApp.cpp View 1 1 chunk +3 lines, -0 lines 0 comments Download
src/core/SkCanvas.cpp View 1 2 11 chunks +97 lines, -47 lines 0 comments Download
src/core/SkDevice.cpp View 1 1 chunk +7 lines, -3 lines 0 comments Download
src/gpu/SkGpuDevice.cpp View 1 2 3 chunks +57 lines, -55 lines 0 comments Download

Messages

Total messages: 8
Stephen White
13 years, 3 months ago (2012-03-22 01:11:33 UTC) #1
reed1
I have a similar CL that implements filters for all drawing calls, not just drawSprite. ...
13 years, 3 months ago (2012-03-22 12:36:27 UTC) #2
bsalomon
On 2012/03/22 12:36:27, reed1 wrote: > I have a similar CL that implements filters for ...
13 years, 3 months ago (2012-03-22 13:14:38 UTC) #3
Stephen White
On 2012/03/22 12:36:27, reed1 wrote: > I have a similar CL that implements filters for ...
13 years, 3 months ago (2012-03-22 13:49:08 UTC) #4
Stephen White
On 2012/03/22 13:14:38, bsalomon wrote: > On 2012/03/22 12:36:27, reed1 wrote: > > I have ...
13 years, 3 months ago (2012-03-22 13:49:37 UTC) #5
Stephen White
Mike's + option1 (filters supported on GPU side in drawSprite, drawDevice, filterImage)
13 years, 3 months ago (2012-03-22 23:15:03 UTC) #6
Stephen White
Mike's + option2 (filters supported on GPU side only in filterImage)
13 years, 3 months ago (2012-03-22 23:17:48 UTC) #7
Stephen White
13 years, 2 months ago (2012-04-06 20:19:46 UTC) #8
Sign in to reply to this message.

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b