• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2024 Google Inc.
3  *
4  * Use of this source code is governed by a BSD-style license that can be
5  * found in the LICENSE file.
6  */
7 
8 #include "src/codec/SkPngCompositeChunkReader.h"
9 #include <cstring>
10 
11 class SkData;
12 
readChunk(const char tag[],const void * data,size_t length)13 bool SkPngCompositeChunkReader::readChunk(const char tag[], const void* data, size_t length) {
14     if (fChunkReader && !fChunkReader->readChunk(tag, data, length)) {
15         //  Only fail if the client's chunk reader failed; If we don't have a
16         //  chunk reader we would still need to grab gainmap chunks
17         return false;
18     }
19 
20     if (strcmp("gmAP", tag) == 0) {
21         SkMemoryStream stream(data, length);
22         sk_sp<SkData> streamData = stream.getData();
23         SkGainmapInfo info;
24         if (SkGainmapInfo::Parse(streamData.get(), info)) {
25             fGainmapInfo.emplace(std::move(info));
26         }
27     } else if (strcmp("gdAT", tag) == 0) {
28         fGainmapStream = SkMemoryStream::MakeCopy(data, length);
29     }
30 
31     return true;
32 }
33