diff options
author | msarett <msarett@google.com> | 2015-06-30 13:29:37 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-06-30 13:29:37 -0700 |
commit | 7f6283bdf8926f72b886389588e3e2d3bc0ea066 (patch) | |
tree | 84977e601181d660f3736f2124c292765bbb6fa1 /bench/subset/SubsetBenchPriv.h | |
parent | d3e259a16cf85454f629f5fe75b60b9863c1e138 (diff) |
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
Diffstat (limited to 'bench/subset/SubsetBenchPriv.h')
-rw-r--r-- | bench/subset/SubsetBenchPriv.h | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/bench/subset/SubsetBenchPriv.h b/bench/subset/SubsetBenchPriv.h index e0eb2ff826..d2c3410e16 100644 --- a/bench/subset/SubsetBenchPriv.h +++ b/bench/subset/SubsetBenchPriv.h @@ -32,4 +32,19 @@ static const char* get_color_name(SkColorType colorType) { } } +/* + * If we plan to decode to kIndex8, we must create a color table and pass it to the + * bitmap when we allocate pixels. Otherwise, we simply allocate pixels using the + * decode info. + */ +static inline void alloc_pixels(SkBitmap* bitmap, const SkImageInfo& info, SkPMColor* colors, + int colorCount) { + if (kIndex_8_SkColorType == info.colorType()) { + SkAutoTUnref<SkColorTable> colorTable(SkNEW_ARGS(SkColorTable, (colors, colorCount))); + bitmap->allocPixels(info, NULL, colorTable); + } else { + bitmap->allocPixels(info); + } +} + #endif // SubsetBenchPriv_DEFINED |