Store ninepatch chunks in the png header in CodexTest
We are making a change in Android to store ninepatch chunks in the png header. Thus, our ninepatch test should match the Android framework's use. https://googleplex-android-review.git.corp.google.com/#/c/832067/ BUG=skia: GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1553303003 Review URL: https://codereview.chromium.org/1553303003
This commit is contained in:
parent
c7e211acd0
commit
133eaaacdd
@ -259,8 +259,9 @@ static bool read_header(SkStream* stream, SkPngChunkReader* chunkReader,
|
|||||||
png_set_read_fn(png_ptr, static_cast<void*>(stream), sk_read_fn);
|
png_set_read_fn(png_ptr, static_cast<void*>(stream), sk_read_fn);
|
||||||
|
|
||||||
#ifdef PNG_READ_UNKNOWN_CHUNKS_SUPPORTED
|
#ifdef PNG_READ_UNKNOWN_CHUNKS_SUPPORTED
|
||||||
// FIXME: Does this need to be installed so early?
|
// Hookup our chunkReader so we can see any user-chunks the caller may be interested in.
|
||||||
// hookup our chunkReader so we can see any user-chunks the caller may be interested in
|
// This needs to be installed before we read the png header. Android may store ninepatch
|
||||||
|
// chunks in the header.
|
||||||
if (chunkReader) {
|
if (chunkReader) {
|
||||||
png_set_keep_unknown_chunks(png_ptr, PNG_HANDLE_CHUNK_ALWAYS, (png_byte*)"", 0);
|
png_set_keep_unknown_chunks(png_ptr, PNG_HANDLE_CHUNK_ALWAYS, (png_byte*)"", 0);
|
||||||
png_set_read_user_chunk_fn(png_ptr, (png_voidp) chunkReader, sk_read_user_chunk);
|
png_set_read_user_chunk_fn(png_ptr, (png_voidp) chunkReader, sk_read_user_chunk);
|
||||||
|
@ -742,17 +742,17 @@ DEF_TEST(Codec_pngChunkReader, r) {
|
|||||||
|
|
||||||
// Create some chunks that match the Android framework's use.
|
// Create some chunks that match the Android framework's use.
|
||||||
static png_unknown_chunk gUnknowns[] = {
|
static png_unknown_chunk gUnknowns[] = {
|
||||||
{ "npOl", (png_byte*)"outline", sizeof("outline"), PNG_HAVE_PLTE },
|
{ "npOl", (png_byte*)"outline", sizeof("outline"), PNG_HAVE_IHDR },
|
||||||
{ "npLb", (png_byte*)"layoutBounds", sizeof("layoutBounds"), PNG_HAVE_PLTE },
|
{ "npLb", (png_byte*)"layoutBounds", sizeof("layoutBounds"), PNG_HAVE_IHDR },
|
||||||
{ "npTc", (png_byte*)"ninePatchData", sizeof("ninePatchData"), PNG_HAVE_PLTE },
|
{ "npTc", (png_byte*)"ninePatchData", sizeof("ninePatchData"), PNG_HAVE_IHDR },
|
||||||
};
|
};
|
||||||
|
|
||||||
png_set_keep_unknown_chunks(png, PNG_HANDLE_CHUNK_ALWAYS, (png_byte*)"npOl\0npLb\0npTc\0", 3);
|
png_set_keep_unknown_chunks(png, PNG_HANDLE_CHUNK_ALWAYS, (png_byte*)"npOl\0npLb\0npTc\0", 3);
|
||||||
png_set_unknown_chunks(png, info, gUnknowns, SK_ARRAY_COUNT(gUnknowns));
|
png_set_unknown_chunks(png, info, gUnknowns, SK_ARRAY_COUNT(gUnknowns));
|
||||||
#if PNG_LIBPNG_VER < 10600
|
#if PNG_LIBPNG_VER < 10600
|
||||||
/* Deal with unknown chunk location bug in 1.5.x and earlier */
|
/* Deal with unknown chunk location bug in 1.5.x and earlier */
|
||||||
png_set_unknown_chunk_location(png, info, 0, PNG_HAVE_PLTE);
|
png_set_unknown_chunk_location(png, info, 0, PNG_HAVE_IHDR);
|
||||||
png_set_unknown_chunk_location(png, info, 1, PNG_HAVE_PLTE);
|
png_set_unknown_chunk_location(png, info, 1, PNG_HAVE_IHDR);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
png_write_info(png, info);
|
png_write_info(png, info);
|
||||||
|
Loading…
Reference in New Issue
Block a user