| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 Google Inc. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 #include "SkAndroidCodec.h" | 8 #include "SkAndroidCodec.h" |
| 9 #include "SkBitmapRegionCodec.h" | 9 #include "SkBitmapRegionCodec.h" |
| 10 #include "SkBitmapRegionDecoderPriv.h" | 10 #include "SkBitmapRegionDecoderPriv.h" |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 108 | 108 |
| 109 // Decode into the destination bitmap | 109 // Decode into the destination bitmap |
| 110 SkAndroidCodec::AndroidOptions options; | 110 SkAndroidCodec::AndroidOptions options; |
| 111 options.fSampleSize = sampleSize; | 111 options.fSampleSize = sampleSize; |
| 112 options.fSubset = ⊂ | 112 options.fSubset = ⊂ |
| 113 options.fColorPtr = colors; | 113 options.fColorPtr = colors; |
| 114 options.fColorCount = &maxColors; | 114 options.fColorCount = &maxColors; |
| 115 options.fZeroInitialized = zeroInit; | 115 options.fZeroInitialized = zeroInit; |
| 116 void* dst = bitmap->getAddr(scaledOutX, scaledOutY); | 116 void* dst = bitmap->getAddr(scaledOutX, scaledOutY); |
| 117 | 117 |
| 118 // FIXME: skbug.com/4538 | 118 SkCodec::Result result = fCodec->getAndroidPixels(decodeInfo, dst, bitmap->r
owBytes(), |
| 119 // It is important that we use the rowBytes on the pixelRef. They may not b
e | 119 &options); |
| 120 // set properly on the bitmap. | |
| 121 SkPixelRef* pr = SkRef(bitmap->pixelRef()); | |
| 122 size_t rowBytes = pr->rowBytes(); | |
| 123 bitmap->setInfo(outInfo, rowBytes); | |
| 124 bitmap->setPixelRef(pr)->unref(); | |
| 125 bitmap->lockPixels(); | |
| 126 SkCodec::Result result = fCodec->getAndroidPixels(decodeInfo, dst, rowBytes,
&options); | |
| 127 if (SkCodec::kSuccess != result && SkCodec::kIncompleteInput != result) { | 120 if (SkCodec::kSuccess != result && SkCodec::kIncompleteInput != result) { |
| 128 SkCodecPrintf("Error: Could not get pixels.\n"); | 121 SkCodecPrintf("Error: Could not get pixels.\n"); |
| 129 return false; | 122 return false; |
| 130 } | 123 } |
| 131 | 124 |
| 132 // Intialize the color table | 125 // Intialize the color table |
| 133 if (kIndex_8_SkColorType == dstColorType) { | 126 if (kIndex_8_SkColorType == dstColorType) { |
| 134 colorTable->dangerous_overwriteColors(colors, maxColors); | 127 colorTable->dangerous_overwriteColors(colors, maxColors); |
| 135 } | 128 } |
| 136 | 129 |
| 137 return true; | 130 return true; |
| 138 } | 131 } |
| 139 | 132 |
| 140 bool SkBitmapRegionCodec::conversionSupported(SkColorType colorType) { | 133 bool SkBitmapRegionCodec::conversionSupported(SkColorType colorType) { |
| 141 // FIXME: Call virtual function when it lands. | 134 // FIXME: Call virtual function when it lands. |
| 142 SkImageInfo info = SkImageInfo::Make(0, 0, colorType, fCodec->getInfo().alph
aType(), | 135 SkImageInfo info = SkImageInfo::Make(0, 0, colorType, fCodec->getInfo().alph
aType(), |
| 143 fCodec->getInfo().profileType()); | 136 fCodec->getInfo().profileType()); |
| 144 return conversion_possible(info, fCodec->getInfo()); | 137 return conversion_possible(info, fCodec->getInfo()); |
| 145 } | 138 } |
| OLD | NEW |