OLD | NEW |
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 "SkImageDecoder.h" |
9 #include "SkImage_Base.h" | 9 #include "SkImage_Base.h" |
10 #include "SkBitmap.h" | 10 #include "SkBitmap.h" |
11 #include "SkCanvas.h" | 11 #include "SkCanvas.h" |
12 #include "SkData.h" | 12 #include "SkData.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*) const SK_
OVERRIDE; | 21 virtual void onDraw(SkCanvas*, SkScalar, SkScalar, const SkPaint*) const SK_
OVERRIDE; |
22 virtual void onDrawRectToRect(SkCanvas*, const SkRect*, const SkRect&, | 22 virtual void onDrawRectToRect(SkCanvas*, const SkRect*, const SkRect&, |
23 const SkPaint*) const SK_OVERRIDE; | 23 const SkPaint*) const SK_OVERRIDE; |
24 | 24 |
| 25 virtual bool isOpaque() const SK_OVERRIDE; |
| 26 |
25 private: | 27 private: |
26 SkData* fEncodedData; | 28 SkData* fEncodedData; |
27 SkBitmap fBitmap; | 29 SkBitmap fBitmap; |
28 | 30 |
29 typedef SkImage_Base INHERITED; | 31 typedef SkImage_Base INHERITED; |
30 }; | 32 }; |
31 | 33 |
32 /////////////////////////////////////////////////////////////////////////////// | 34 /////////////////////////////////////////////////////////////////////////////// |
33 | 35 |
34 SkImage_Codec::SkImage_Codec(SkData* data, int width, int height) : INHERITED(wi
dth, height) { | 36 SkImage_Codec::SkImage_Codec(SkData* data, int width, int height) : INHERITED(wi
dth, height) { |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
71 } | 73 } |
72 | 74 |
73 SkBitmap bitmap; | 75 SkBitmap bitmap; |
74 if (!SkImageDecoder::DecodeMemory(data->bytes(), data->size(), &bitmap, kUnk
nown_SkColorType, | 76 if (!SkImageDecoder::DecodeMemory(data->bytes(), data->size(), &bitmap, kUnk
nown_SkColorType, |
75 SkImageDecoder::kDecodeBounds_Mode)) { | 77 SkImageDecoder::kDecodeBounds_Mode)) { |
76 return NULL; | 78 return NULL; |
77 } | 79 } |
78 | 80 |
79 return SkNEW_ARGS(SkImage_Codec, (data, bitmap.width(), bitmap.height())); | 81 return SkNEW_ARGS(SkImage_Codec, (data, bitmap.width(), bitmap.height())); |
80 } | 82 } |
| 83 |
| 84 |
| 85 bool SkImage_Codec::isOpaque() const { |
| 86 return fBitmap.isOpaque(); |
| 87 } |
OLD | NEW |