28fcae2ec7
Reason for revert: Want to reland the original CL. Original issue's description: > Revert of Rename kPMColor_SkColorType to kN32_SkColorType. (https://codereview.chromium.org/227433009/) > > Reason for revert: > breaking the Chrome deps roll. > http://build.chromium.org/p/chromium.linux/builders/Linux%20GN%20%28dbg%29/builds/839/steps/compile/logs/stdio > > Original issue's description: > > Rename kPMColor_SkColorType to kN32_SkColorType. > > > > The new name better represents what this flag means. > > > > BUG=skia:2384 > > > > Committed: http://code.google.com/p/skia/source/detail?r=14117 > > TBR=reed@google.com,scroggo@google.com > NOTREECHECKS=true > NOTRY=true > BUG=skia:2384 > > Committed: http://code.google.com/p/skia/source/detail?r=14144 R=reed@google.com, bensong@google.com TBR=bensong@google.com, reed@google.com NOTREECHECKS=true NOTRY=true BUG=skia:2384 Author: scroggo@google.com Review URL: https://codereview.chromium.org/235523003 git-svn-id: http://skia.googlecode.com/svn/trunk@14156 2bbb7eff-a529-9590-31e7-b0007b416f81
52 lines
1.7 KiB
C++
52 lines
1.7 KiB
C++
/*
|
|
* Copyright 2013 Google Inc.
|
|
*
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
* found in the LICENSE file.
|
|
*/
|
|
|
|
#include "SkBitmap.h"
|
|
|
|
#include "Test.h"
|
|
|
|
static void test_bigwidth(skiatest::Reporter* reporter) {
|
|
SkBitmap bm;
|
|
int width = 1 << 29; // *4 will be the high-bit of 32bit int
|
|
|
|
SkImageInfo info = SkImageInfo::Make(width, 1, kAlpha_8_SkColorType,
|
|
kPremul_SkAlphaType);
|
|
REPORTER_ASSERT(reporter, bm.setConfig(info));
|
|
info.fColorType = kRGB_565_SkColorType;
|
|
REPORTER_ASSERT(reporter, bm.setConfig(info));
|
|
|
|
// for a 4-byte config, this width will compute a rowbytes of 0x80000000,
|
|
// which does not fit in a int32_t. setConfig should detect this, and fail.
|
|
|
|
// TODO: perhaps skia can relax this, and only require that rowBytes fit
|
|
// in a uint32_t (or larger), but for now this is the constraint.
|
|
|
|
info.fColorType = kN32_SkColorType;
|
|
REPORTER_ASSERT(reporter, !bm.setConfig(info));
|
|
}
|
|
|
|
/**
|
|
* This test contains basic sanity checks concerning bitmaps.
|
|
*/
|
|
DEF_TEST(Bitmap, reporter) {
|
|
// Zero-sized bitmaps are allowed
|
|
for (int width = 0; width < 2; ++width) {
|
|
for (int height = 0; height < 2; ++height) {
|
|
SkBitmap bm;
|
|
bool setConf = bm.setConfig(SkImageInfo::MakeN32Premul(width,
|
|
height));
|
|
REPORTER_ASSERT(reporter, setConf);
|
|
if (setConf) {
|
|
REPORTER_ASSERT(reporter, bm.allocPixels(NULL));
|
|
}
|
|
REPORTER_ASSERT(reporter, SkToBool(width & height) != bm.empty());
|
|
}
|
|
}
|
|
|
|
test_bigwidth(reporter);
|
|
}
|