| 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 "SkBitmapRegionCanvas.h" |  | 
| 9 #include "SkBitmapRegionCodec.h" |  | 
| 10 #include "SkBitmapRegionDecoder.h" |  | 
| 11 #include "SkAndroidCodec.h" |  | 
| 12 #include "SkCodec.h" |  | 
| 13 #include "SkCodecPriv.h" |  | 
| 14 #include "SkImageDecoder.h" |  | 
| 15 |  | 
| 16 SkBitmapRegionDecoder* SkBitmapRegionDecoder::Create( |  | 
| 17         SkData* data, Strategy strategy) { |  | 
| 18     return SkBitmapRegionDecoder::Create(new SkMemoryStream(data), |  | 
| 19             strategy); |  | 
| 20 } |  | 
| 21 |  | 
| 22 SkBitmapRegionDecoder* SkBitmapRegionDecoder::Create( |  | 
| 23         SkStreamRewindable* stream, Strategy strategy) { |  | 
| 24     SkAutoTDelete<SkStreamRewindable> streamDeleter(stream); |  | 
| 25     switch (strategy) { |  | 
| 26         case kCanvas_Strategy: { |  | 
| 27             SkAutoTDelete<SkCodec> codec(SkCodec::NewFromStream(streamDeleter.de
    tach())); |  | 
| 28             if (nullptr == codec) { |  | 
| 29                 SkCodecPrintf("Error: Failed to create decoder.\n"); |  | 
| 30                 return nullptr; |  | 
| 31             } |  | 
| 32 |  | 
| 33             if (SkEncodedFormat::kWEBP_SkEncodedFormat == codec->getEncodedForma
    t()) { |  | 
| 34                 // FIXME: Support webp using a special case.  Webp does not supp
    ort |  | 
| 35                 //        scanline decoding. |  | 
| 36                 return nullptr; |  | 
| 37             } |  | 
| 38 |  | 
| 39             switch (codec->getScanlineOrder()) { |  | 
| 40                 case SkCodec::kTopDown_SkScanlineOrder: |  | 
| 41                 case SkCodec::kNone_SkScanlineOrder: |  | 
| 42                     break; |  | 
| 43                 default: |  | 
| 44                     SkCodecPrintf("Error: Scanline ordering not supported.\n"); |  | 
| 45                     return nullptr; |  | 
| 46             } |  | 
| 47             return new SkBitmapRegionCanvas(codec.detach()); |  | 
| 48         } |  | 
| 49         case kAndroidCodec_Strategy: { |  | 
| 50             SkAutoTDelete<SkAndroidCodec> codec = |  | 
| 51                     SkAndroidCodec::NewFromStream(streamDeleter.detach()); |  | 
| 52             if (NULL == codec) { |  | 
| 53                 SkCodecPrintf("Error: Failed to create codec.\n"); |  | 
| 54                 return NULL; |  | 
| 55             } |  | 
| 56             return new SkBitmapRegionCodec(codec.detach()); |  | 
| 57         } |  | 
| 58         default: |  | 
| 59             SkASSERT(false); |  | 
| 60             return nullptr; |  | 
| 61     } |  | 
| 62 } |  | 
| OLD | NEW | 
|---|