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

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: Created 6 years, 5 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*) SK_OVERRI DE; 21 virtual void onDraw(SkCanvas*, SkScalar, SkScalar, const SkPaint*) SK_OVERRI DE;
22 virtual void onDrawRectToRect(SkCanvas*, const SkRect*, const SkRect&, const SkPaint*) SK_OVERRIDE; 22 virtual void onDrawRectToRect(SkCanvas*, const SkRect*, const SkRect&, const SkPaint*) SK_OVERRIDE;
23 23
24 virtual bool isOpaque() const SK_OVERRIDE;
25
24 private: 26 private:
25 SkData* fEncodedData; 27 SkData* fEncodedData;
26 SkBitmap fBitmap; 28 SkBitmap fBitmap;
27 29
28 typedef SkImage_Base INHERITED; 30 typedef SkImage_Base INHERITED;
29 }; 31 };
30 32
31 /////////////////////////////////////////////////////////////////////////////// 33 ///////////////////////////////////////////////////////////////////////////////
32 34
33 SkImage_Codec::SkImage_Codec(SkData* data, int width, int height) : INHERITED(wi dth, height) { 35 SkImage_Codec::SkImage_Codec(SkData* data, int width, int height) : INHERITED(wi dth, height) {
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 } 68 }
67 69
68 SkBitmap bitmap; 70 SkBitmap bitmap;
69 if (!SkImageDecoder::DecodeMemory(data->bytes(), data->size(), &bitmap, kUnk nown_SkColorType, 71 if (!SkImageDecoder::DecodeMemory(data->bytes(), data->size(), &bitmap, kUnk nown_SkColorType,
70 SkImageDecoder::kDecodeBounds_Mode)) { 72 SkImageDecoder::kDecodeBounds_Mode)) {
71 return NULL; 73 return NULL;
72 } 74 }
73 75
74 return SkNEW_ARGS(SkImage_Codec, (data, bitmap.width(), bitmap.height())); 76 return SkNEW_ARGS(SkImage_Codec, (data, bitmap.width(), bitmap.height()));
75 } 77 }
78
79
80 bool SkImage_Codec::isOpaque() const {
81 if (!fBitmap.pixelRef()) {
82 return SkImage::isOpaque();
reed1 2014/07/18 20:50:02 This will return false, even if the bitmap is opaq
Rémi Piotaix 2014/07/18 21:12:50 Yep. I made this method const so SkImageDecoder::D
scroggo 2014/07/18 21:39:14 It does seem to me that fBitmap is logically mutab
83 }
84
85 return fBitmap.isOpaque();
86 }
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