OLD | NEW |
(Empty) | |
| 1 /* |
| 2 * Copyright 2015 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 "SkCodecImageGenerator.h" |
| 9 |
| 10 SkImageGenerator* SkCodecImageGenerator::NewFromEncodedCodec(SkData* data) { |
| 11 SkCodec* codec = SkCodec::NewFromData(data); |
| 12 if (nullptr == codec) { |
| 13 return nullptr; |
| 14 } |
| 15 |
| 16 return new SkCodecImageGenerator(codec, data); |
| 17 } |
| 18 |
| 19 SkCodecImageGenerator::SkCodecImageGenerator(SkCodec* codec, SkData* data) |
| 20 : INHERITED(codec->getInfo()) |
| 21 , fCodec(codec) |
| 22 , fData(SkRef(data)) |
| 23 {} |
| 24 |
| 25 SkData* SkCodecImageGenerator::onRefEncodedData(SK_REFENCODEDDATA_CTXPARAM) { |
| 26 return SkRef(fData.get()); |
| 27 } |
| 28 |
| 29 bool SkCodecImageGenerator::onGetPixels(const SkImageInfo& info, void* pixels, s
ize_t rowBytes, |
| 30 SkPMColor ctable[], int* ctableCount) { |
| 31 |
| 32 SkCodec::Result result = fCodec->getPixels(info, pixels, rowBytes, nullptr,
ctable, |
| 33 ctableCount); |
| 34 switch (result) { |
| 35 case SkCodec::kSuccess: |
| 36 case SkCodec::kIncompleteInput: |
| 37 return true; |
| 38 default: |
| 39 return false; |
| 40 } |
| 41 } |
| 42 |
| 43 bool SkCodecImageGenerator::onGetYUV8Planes(SkISize sizes[3], void* planes[3], s
ize_t rowBytes[3], |
| 44 SkYUVColorSpace* colorSpace) { |
| 45 return false; |
| 46 } |
OLD | NEW |