Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(23)

Issue 1321433002: Add subsetting to SkScaledCodec (Closed)

Created:
5 years, 3 months ago by msarett
Modified:
5 years, 1 month ago
Reviewers:
scroggo
CC:
reviews_skia.org
Base URL:
https://skia.googlesource.com/skia.git@gif-scan
Target Ref:
refs/heads/master
Project:
skia
Visibility:
Public.

Description

Add subsetting to SkScaledCodec API Changes: startScanlineDecoder() now takes a subsetLeft and a subsetWidth as a parameter in order to decode partial scanlines. getScaledSubsetDimensions() has been created in order to allow the client to request and perform valid subset decodes. Major Changes: SkScaledCodec.cpp onGetPixels() has been significantly refactored and rewritten. SkBitmapRegionCodec.cpp implements SkBitmapRegionDecoderInterface using an SkScaledCodec. Minor Changes: Many files have been touched to allow SkSwizzler to know about subsetLeft and subsetWidth. BUG=skia:4209

Patch Set 1 : #

Total comments: 24

Patch Set 2 : Rebase - it compiles but I'm sure everything is broken #

Unified diffs Side-by-side diffs Delta from patch set Stats (+905 lines, -323 lines) Patch
M bench/BitmapRegionDecoderBench.cpp View 1 1 chunk +3 lines, -0 lines 0 comments Download
M dm/DM.cpp View 1 4 chunks +19 lines, -6 lines 0 comments Download
M dm/DMSrcSink.cpp View 1 3 chunks +6 lines, -2 lines 0 comments Download
M gyp/tools.gyp View 1 chunk +1 line, -0 lines 0 comments Download
M include/codec/SkCodec.h View 1 7 chunks +89 lines, -29 lines 0 comments Download
M include/codec/SkScaledCodec.h View 1 3 chunks +10 lines, -1 line 0 comments Download
M src/codec/SkBmpCodec.h View 1 3 chunks +10 lines, -3 lines 0 comments Download
M src/codec/SkBmpCodec.cpp View 1 3 chunks +14 lines, -3 lines 0 comments Download
M src/codec/SkBmpMaskCodec.cpp View 1 chunk +2 lines, -2 lines 0 comments Download
M src/codec/SkBmpRLECodec.cpp View 1 2 chunks +2 lines, -2 lines 0 comments Download
M src/codec/SkBmpStandardCodec.cpp View 1 2 chunks +3 lines, -4 lines 0 comments Download
M src/codec/SkCodec.cpp View 1 4 chunks +70 lines, -3 lines 0 comments Download
M src/codec/SkCodecPriv.h View 1 2 chunks +16 lines, -3 lines 0 comments Download
M src/codec/SkCodec_libgif.h View 1 2 chunks +6 lines, -2 lines 0 comments Download
M src/codec/SkCodec_libgif.cpp View 1 10 chunks +21 lines, -16 lines 0 comments Download
M src/codec/SkCodec_libpng.h View 1 4 chunks +1 line, -4 lines 0 comments Download
M src/codec/SkCodec_libpng.cpp View 1 5 chunks +12 lines, -11 lines 0 comments Download
M src/codec/SkCodec_wbmp.h View 1 2 chunks +3 lines, -2 lines 0 comments Download
M src/codec/SkCodec_wbmp.cpp View 1 5 chunks +9 lines, -8 lines 0 comments Download
M src/codec/SkJpegCodec.h View 1 1 chunk +1 line, -1 line 0 comments Download
M src/codec/SkJpegCodec.cpp View 1 3 chunks +10 lines, -10 lines 0 comments Download
M src/codec/SkMaskSwizzler.h View 1 3 chunks +6 lines, -7 lines 0 comments Download
M src/codec/SkMaskSwizzler.cpp View 1 4 chunks +10 lines, -9 lines 0 comments Download
M src/codec/SkScaledCodec.cpp View 1 10 chunks +250 lines, -100 lines 0 comments Download
M src/codec/SkSwizzler.h View 1 2 chunks +20 lines, -7 lines 0 comments Download
M src/codec/SkSwizzler.cpp View 1 3 chunks +17 lines, -20 lines 0 comments Download
M src/codec/SkWebpCodec.h View 1 1 chunk +2 lines, -0 lines 0 comments Download
M src/codec/SkWebpCodec.cpp View 1 3 chunks +23 lines, -10 lines 0 comments Download
M tools/SkBitmapRegionCanvas.h View 1 chunk +2 lines, -0 lines 0 comments Download
M tools/SkBitmapRegionCanvas.cpp View 10 chunks +31 lines, -43 lines 0 comments Download
A + tools/SkBitmapRegionCodec.h View 2 chunks +9 lines, -9 lines 0 comments Download
A tools/SkBitmapRegionCodec.cpp View 1 chunk +160 lines, -0 lines 0 comments Download
M tools/SkBitmapRegionDecoderInterface.h View 2 chunks +7 lines, -1 line 0 comments Download
M tools/SkBitmapRegionDecoderInterface.cpp View 4 chunks +15 lines, -4 lines 0 comments Download
A tools/SkBitmapRegionDecoderPriv.h View 1 chunk +35 lines, -0 lines 0 comments Download
M tools/SkBitmapRegionSampler.h View 1 chunk +8 lines, -0 lines 0 comments Download
M tools/SkBitmapRegionSampler.cpp View 2 chunks +2 lines, -1 line 0 comments Download

Messages

Total messages: 16 (11 generated)
msarett
As promised (well a little later than promised), here is this WIP CL. https://codereview.chromium.org/1321433002/diff/120001/src/codec/SkScaledCodec.cpp File ...
5 years, 3 months ago (2015-09-23 13:32:01 UTC) #7
msarett
Any suggestions for renaming SkScaledCodec (after this lands)? I'm not sure about SkScaledSubsetCodec. Also, this ...
5 years, 2 months ago (2015-10-02 14:49:15 UTC) #13
scroggo
On 2015/10/02 14:49:15, msarett wrote: > Any suggestions for renaming SkScaledCodec (after this > lands)? ...
5 years, 2 months ago (2015-10-02 18:27:03 UTC) #14
msarett
"I have a high-level request: This CL does makes two big changes: - implements subsetting ...
5 years, 2 months ago (2015-10-06 23:01:27 UTC) #15
scroggo
5 years, 2 months ago (2015-10-07 17:49:39 UTC) #16
On 2015/10/06 23:01:27, msarett wrote:
> "I have a high-level request: This CL does makes two big changes:
> - implements subsetting in SkScaledCodec
> - implements subsetting in scanline decoding
> 
> Would it be possible to split that into two CLs (ideally which build on
> crrev.com/1372973002, which I hope to land soon)? The first one will implement
> subsets in SkScaledCodec, which we need to do to replace SkImageDecoder. It
can
> do the simple thing of swizzling the whole row and copying the piece that's
> needed. Then we can add the second step, which is really just an
optimization."
> 
> I'm happy to split this up if that would make it easier to review.  I'm not
> convinced that the order you've suggested is the best way to do it.  I think
it
> seems kind of nasty to write a bunch of code with memcpy() that we will sweep
> away anyway.  Any objection to starting with subsetting in SkScanlineDecoder? 
> I'm kind of leaning that way.
> 
> I know that the other piece is more important to replace SkImageDecoder...but
I
> think we'll absolutely have to land both anyway.

I don't think we absolutely have to land both. Subsetting in SkScaledCodec gets
us a step closer to replacing BRD's implementation. subsetting in scanline
decoding seems like an optimization to me.

https://codereview.chromium.org/1321433002/diff/190001/include/codec/SkCodec.h
File include/codec/SkCodec.h (right):

https://codereview.chromium.org/1321433002/diff/190001/include/codec/SkCodec....
include/codec/SkCodec.h:193: SkISize         fScaledDimensions;
On 2015/10/06 23:01:27, msarett wrote:
> On 2015/10/02 18:27:03, scroggo wrote:
> > For fSubset, we decided to make it an unowned pointer, so that a client that
> > does not want to specify it need not pay the cost of initializing the
SkIRect.
> I
> > think we should make the same decision for all three options.
> 
> I'll change to be consistent.
> 
> My concern is that a client will pass nullptr for these fields, since we are
> responsible for initializing them.  We can't really deal with that because we
> want the client to own the memory.
> 
> Not sure if it would seem to strange to a client to need to pass in valid
> pointers to uninitialized objects.

I don't think it's so bad. In this case it will just be an out variable from one
method (we do follow this pattern in other places, where we pass an
uninitialized variable into a method, which returns true if it initialized it),
and then an input variable to another (onGetPixels, I think?).

https://codereview.chromium.org/1321433002/diff/190001/src/codec/SkSwizzler.cpp
File src/codec/SkSwizzler.cpp (left):

https://codereview.chromium.org/1321433002/diff/190001/src/codec/SkSwizzler.c...
src/codec/SkSwizzler.cpp:235: // greater than 1. The below loop relies on the
fact that src remains unchanged.
On 2015/10/06 23:01:27, msarett wrote:
> On 2015/10/02 18:27:03, scroggo wrote:
> > Does the below loop not need to be updated to take this into account?
> 
> Don't think so...

Can you help me understand why that is? I thought we previously ran into a
problem where the loop did not match, causing problems...

See Emmalee's comment https://codereview.chromium.org/1260673002#msg92. It looks
like we had to revert patch set 32, and the fix included this assert.

Put another way, did we update dstWidth to take the offset into account? Because
if not, it seems like the memcpy will copy too much, and then the loop will read
too much.

https://codereview.chromium.org/1321433002/diff/190001/tools/SkBitmapRegionCa...
File tools/SkBitmapRegionCanvas.cpp (right):

https://codereview.chromium.org/1321433002/diff/190001/tools/SkBitmapRegionCa...
tools/SkBitmapRegionCanvas.cpp:36: if (sampleSize < 1) {
On 2015/10/06 23:01:27, msarett wrote:
> On 2015/10/02 18:27:03, scroggo wrote:
> > Is this just in case? Or were you seeing bad input?
> 
> The Android code likes to call decodeRegion with sampleSize = 0 when it really
> means 1.  Of course, since Android is not a client of code right now, this
seems
> unnecessary.

Oh, weird, it looks like BitmapFactory.Options.inSampleSize never gets a default
value, so it is 0, and SkImageDecoder does this same fix.

If we do not account for it here, we'll need to make sure the Android code does
not rely on it. I think it's reasonable to account for it here though, in the
interest of being robust.

Powered by Google App Engine
This is Rietveld 408576698