Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(164)

Side by Side Diff: tools/SkBitmapRegionDecoder.cpp

Issue 1417393004: Reorganize BRD code in new tools directory (Closed) Base URL: https://skia.googlesource.com/skia.git@delete-imdec
Patch Set: tools/android Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « tools/SkBitmapRegionDecoder.h ('k') | tools/SkCodecTools.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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 }
OLDNEW
« no previous file with comments | « tools/SkBitmapRegionDecoder.h ('k') | tools/SkCodecTools.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698