diff options
author | Brian Osman <brianosman@google.com> | 2017-01-14 23:43:24 +0000 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2017-01-15 00:15:34 +0000 |
commit | 7a6c9f7be115031a8a86fdae20e8869fd973fdb6 (patch) | |
tree | cfea263ca408161e7b57aee4dd31c26372fbc985 /gm/showmiplevels.cpp | |
parent | 8bbdd49805bd77fec61e6e31f59d31a361e8be30 (diff) |
Revert "Add SkImageInfoValidConversion() and SkImageInfoIsValid"
This reverts commit cf5d6caff7a58f1c7ecc36d9a91ccdada5fc7b78.
Reason for revert: Chrome DEPS roll failing, based on the unit tests, I suspect this is the cause.
Original change's description:
> Add SkImageInfoValidConversion() and SkImageInfoIsValid
>
> The idea is share these standards for the following:
> SkImage::readPixels()
> SkCanvas::readPixels()
> SkCanvas::writePixels()
> SkBitmap::readPixels()
> SkPixmap::readPixels()
>
> On the raster side, SkPixmap::readPixels() is the right
> place to check, because all raster calls go through
> there eventually. Then at lower levels (ex: SkPixelInfo),
> we can assert.
>
> There's not really a unifying location for gpu calls,
> so I've added this in multiple places. I haven't really
> dug into the gpu code to SkASSERT() on invalid cases
> that we will have already caught.
>
> Follow-up work:
> Similar refactor for SkReadPixelRec::trim().
> Code cleanup in SkPixelInfo::CopyPixels()
>
> BUG=skia:6021
>
> Change-Id: I91ecce10e46c1a6530f0af24a9eb8226dbecaaa2
> Reviewed-on: https://skia-review.googlesource.com/6887
> Reviewed-by: Brian Osman <brianosman@google.com>
> Reviewed-by: Mike Reed <reed@google.com>
>
TBR=mtklein@google.com,msarett@google.com,brianosman@google.com,reed@google.com,reviews@skia.org
# Not skipping CQ checks because original CL landed > 1 day ago.
BUG=skia:6021
Change-Id: I63b88e90bdbb3051a14de00ac73a8351ab776d25
Reviewed-on: https://skia-review.googlesource.com/7095
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
Diffstat (limited to 'gm/showmiplevels.cpp')
-rw-r--r-- | gm/showmiplevels.cpp | 42 |
1 files changed, 1 insertions, 41 deletions
diff --git a/gm/showmiplevels.cpp b/gm/showmiplevels.cpp index 0394b57318..a4fd16404f 100644 --- a/gm/showmiplevels.cpp +++ b/gm/showmiplevels.cpp @@ -216,46 +216,6 @@ DEF_GM( return new ShowMipLevels(256); ) /////////////////////////////////////////////////////////////////////////////////////////////////// -static void copy_32_to_g8(void* dst, size_t dstRB, const void* src, const SkImageInfo& srcInfo, - size_t srcRB) { - uint8_t* dst8 = (uint8_t*)dst; - const uint32_t* src32 = (const uint32_t*)src; - - const int w = srcInfo.width(); - const int h = srcInfo.height(); - const bool isBGRA = (kBGRA_8888_SkColorType == srcInfo.colorType()); - - for (int y = 0; y < h; ++y) { - if (isBGRA) { - // BGRA - for (int x = 0; x < w; ++x) { - uint32_t s = src32[x]; - dst8[x] = SkComputeLuminance((s >> 16) & 0xFF, (s >> 8) & 0xFF, s & 0xFF); - } - } else { - // RGBA - for (int x = 0; x < w; ++x) { - uint32_t s = src32[x]; - dst8[x] = SkComputeLuminance(s & 0xFF, (s >> 8) & 0xFF, (s >> 16) & 0xFF); - } - } - src32 = (const uint32_t*)((const char*)src32 + srcRB); - dst8 += dstRB; - } -} - -void copy_to(SkBitmap* dst, SkColorType dstColorType, const SkBitmap& src) { - if (kGray_8_SkColorType == dstColorType) { - SkImageInfo grayInfo = src.info().makeColorType(kGray_8_SkColorType); - dst->allocPixels(grayInfo); - copy_32_to_g8(dst->getPixels(), dst->rowBytes(), src.getPixels(), src.info(), - src.rowBytes()); - return; - } - - src.copyTo(dst, dstColorType); -} - /** * Show mip levels that were built, for all supported colortypes */ @@ -323,7 +283,7 @@ protected: for (auto ctype : ctypes) { SkBitmap bm; - copy_to(&bm, ctype, orig); + orig.copyTo(&bm, ctype); drawLevels(canvas, bm); canvas->translate(orig.width()/2 + 8.0f, 0); } |