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

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

Issue 406673003: Add the method isOpaque() to SkImage (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Rebase master Created 6 years, 4 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
« no previous file with comments | « include/core/SkImage.h ('k') | src/image/SkImage_Gpu.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 "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
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 }
OLDNEW
« no previous file with comments | « include/core/SkImage.h ('k') | src/image/SkImage_Gpu.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698