Commit Graph

5 Commits

Author SHA1 Message Date
scroggo
9b2cdbf481 Allow creating multiple scanline decoders.
Make getScanlineDecoder return a new object each time, which is
owned by the caller, and independent from any existing scanline
decoders and the SkCodec itself.

Since the SkCodec already contains the entire state machine, and it
is used by the scanline decoders, simply create a new SkCodec which
is now owned by the scanline decoder.

Move code that cleans up after using a scanline decoder into its
destructor

One side effect is that creating the first scanline decoder requires
a duplication of the stream and re-reading the header. (With some
more complexity/changes, we could pass the state machine to the
scanline decoder and make the SkCodec recreate its own state machine
instead.) The typical client of the scanline decoder (region decoder)
uses an SkMemoryStream, so the duplication is cheap, although we
should consider the extra time to reread the header/recreate the state
machine. (If/when we use the scanline decoder for other purposes,
where the stream may not be cheaply duplicated, we should consider
passing the state machine.)

One (intended) result of this change is that a client can create a
new scanline decoder in a new thread, and decode different pieces of
the image simultaneously.

In SkPngCodec::decodePalette, use fBitDepth rather than a parameter.

Review URL: https://codereview.chromium.org/1230033004
2015-07-10 12:07:02 -07:00
scroggo
eb602a5c94 SkCodec no longer inherits from SkImageGenerator.
SkImageGenerator makes some assumptions that are not necessarily valid
for SkCodec. For example, SkCodec does not assume that it can always be
rewound.

We also have an ongoing question of what an SkCodec should report as
its default settings (i.e. the return from getInfo). It makes sense for
an SkCodec to report that its pixels are unpremultiplied, if that is
the case for the underlying data, but if a client of SkImageGenerator
uses the default settings (as many do), they will receive
unpremultiplied pixels which cannot (currently) be drawn with Skia. We
may ultimately decide to revisit SkCodec reporting an SkImageInfo, but
I have left it unchanged for now.

Import features of SkImageGenerator used by SkCodec into SkCodec.

I have left SkImageGenerator unchanged for now, but it no longer needs
Result or Options. This will require changes to Chromium.

Manually handle the lifetime of fScanlineDecoder, so SkScanlineDecoder.h
can include SkCodec.h (where Result is), and SkCodec.h does not need
to include it (to delete fScanlineDecoder).

In many places, make the following simple changes:
- Now include SkScanlineDecoder.h, which is no longer included by
  SkCodec.h
- Use the enums in SkCodec, rather than SkImageGenerator
- Stop including SkImageGenerator.h where no longer needed

Review URL: https://codereview.chromium.org/1220733013
2015-07-09 08:16:03 -07:00
msarett
7f6283bdf8 Fix CodecSubset benches seg faults for kIndex8
All of the CodecSubset benches fail when the color type is
kIndex8.  We need to pass a color table to allocPixels()
when we want to decode to kIndex8 or it will throw a failure.

BUG=skia:

Review URL: https://codereview.chromium.org/1213983003
2015-06-30 13:29:37 -07:00
msarett
ab80e35fbd Improved subset benchmarks
I think these changes to the subset benchmarks cover what we discussed yesterday.

I removed the divisor benchmarks (2x2, 3x3) and changed the single subset benchmarks.

Also, we will no longer benchmark subset decodes on small images.

BUG=skia:

Review URL: https://codereview.chromium.org/1188223002
2015-06-17 10:28:22 -07:00
msarett
b23e6aa676 Subset decoding benchmarks
It was my goal to create benchmarks that could measure all
of the use cases that we have identified.  I think single
subsets, translating, and scaling are the important ones.

It might be a good idea to discuss the document in greater
detail as well.  I just wanted to share this to aid the
discussion.
https://docs.google.com/a/google.com/document/d/1OxW96GDMAlw6dnzNXmiNX-F9oDBBlGXzSsgd0DMIkbI/edit?usp=sharing

BUG=skia:

Review URL: https://codereview.chromium.org/1160953002
2015-06-09 13:56:10 -07:00