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

Side by Side Diff: src/image/SkImage_Codec.cpp

Issue 15806010: Separate core and images project. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Change FORCE_LINKING to be more specific. Created 7 years, 6 months 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 | Annotate | Revision Log
« no previous file with comments | « src/image/SkImage.cpp ('k') | src/images/SkForceLinking.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2012 Google Inc. 2 * Copyright 2012 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 "SkImageDecoder.h"
8 #include "SkImage_Base.h" 9 #include "SkImage_Base.h"
9 #include "SkBitmap.h" 10 #include "SkBitmap.h"
10 #include "SkCanvas.h" 11 #include "SkCanvas.h"
11 #include "SkData.h" 12 #include "SkData.h"
12 #include "../images/SkImageDecoder.h"
13 13
14 class SkImage_Codec : public SkImage_Base { 14 class SkImage_Codec : public SkImage_Base {
15 public: 15 public:
16 static SkImage* NewEmpty(); 16 static SkImage* NewEmpty();
17 17
18 SkImage_Codec(SkData* encodedData, int width, int height); 18 SkImage_Codec(SkData* encodedData, int width, int height);
19 virtual ~SkImage_Codec(); 19 virtual ~SkImage_Codec();
20 20
21 virtual void onDraw(SkCanvas*, SkScalar, SkScalar, const SkPaint*) SK_OVERRI DE; 21 virtual void onDraw(SkCanvas*, SkScalar, SkScalar, const SkPaint*) SK_OVERRI DE;
22 22
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 57
58 SkBitmap bitmap; 58 SkBitmap bitmap;
59 if (!SkImageDecoder::DecodeMemory(data->bytes(), data->size(), &bitmap, 59 if (!SkImageDecoder::DecodeMemory(data->bytes(), data->size(), &bitmap,
60 SkBitmap::kNo_Config, 60 SkBitmap::kNo_Config,
61 SkImageDecoder::kDecodeBounds_Mode)) { 61 SkImageDecoder::kDecodeBounds_Mode)) {
62 return NULL; 62 return NULL;
63 } 63 }
64 64
65 return SkNEW_ARGS(SkImage_Codec, (data, bitmap.width(), bitmap.height())); 65 return SkNEW_ARGS(SkImage_Codec, (data, bitmap.width(), bitmap.height()));
66 } 66 }
67
68 ///////////////////////////////////////////////////////////////////////////////
69
70 // FIXME: Temporarily move this here so chromium can still build until we truly
71 // fix the core/images dependency issue (https://code.google.com/p/skia/issues/d etail?id=1275)
72 #include "SkImage.h"
73 #include "../images/SkImageEncoder.h"
74
75 static const SkImage_Base* asIB(const SkImage* image) {
76 return static_cast<const SkImage_Base*>(image);
77 }
78
79 static const struct {
80 SkImageEncoder::Type fIE;
81 SkImage::EncodeType fET;
82 } gTable[] = {
83 { SkImageEncoder::kBMP_Type, SkImage::kBMP_EncodeType },
84 { SkImageEncoder::kGIF_Type, SkImage::kGIF_EncodeType },
85 { SkImageEncoder::kICO_Type, SkImage::kICO_EncodeType },
86 { SkImageEncoder::kJPEG_Type, SkImage::kJPEG_EncodeType },
87 { SkImageEncoder::kPNG_Type, SkImage::kPNG_EncodeType },
88 { SkImageEncoder::kWBMP_Type, SkImage::kWBMP_EncodeType },
89 { SkImageEncoder::kWEBP_Type, SkImage::kWEBP_EncodeType },
90 };
91
92 SkData* SkImage::encode(EncodeType et, int quality) const {
93 for (size_t i = 0; i < SK_ARRAY_COUNT(gTable); ++i) {
94 if (gTable[i].fET == et) {
95 SkBitmap bm;
96 if (asIB(this)->getROPixels(&bm)) {
97 return SkImageEncoder::EncodeData(bm, gTable[i].fIE, quality);
98 }
99 break;
100 }
101 }
102 return NULL;
103 }
OLDNEW
« no previous file with comments | « src/image/SkImage.cpp ('k') | src/images/SkForceLinking.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698