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 "SkBitmap.h" | 8 #include "SkBitmap.h" |
9 #include "SkCanvas.h" | 9 #include "SkCanvas.h" |
10 #include "SkImagePriv.h" | 10 #include "SkImagePriv.h" |
11 #include "SkImage_Base.h" | 11 #include "SkImage_Base.h" |
12 | 12 |
13 SK_DEFINE_INST_COUNT(SkImage) | 13 SK_DEFINE_INST_COUNT(SkImage) |
14 | 14 |
15 bool operator==(const SkImageInfo& lhs, const SkImageInfo& rhs) { | |
16 return 0 == memcmp(&lhs, &rhs, sizeof(SkImageInfo)); | |
17 } | |
18 bool operator!=(const SkImageInfo& lhs, const SkImageInfo& rhs) { | |
19 return 0 != memcmp(&lhs, &rhs, sizeof(SkImageInfo)); | |
20 } | |
21 | |
22 | |
23 static SkImage_Base* as_IB(SkImage* image) { | 15 static SkImage_Base* as_IB(SkImage* image) { |
24 return static_cast<SkImage_Base*>(image); | 16 return static_cast<SkImage_Base*>(image); |
25 } | 17 } |
26 | 18 |
27 static const SkImage_Base* as_IB(const SkImage* image) { | 19 static const SkImage_Base* as_IB(const SkImage* image) { |
28 return static_cast<const SkImage_Base*>(image); | 20 return static_cast<const SkImage_Base*>(image); |
29 } | 21 } |
30 | 22 |
31 uint32_t SkImage::NextUniqueID() { | 23 uint32_t SkImage::NextUniqueID() { |
32 static int32_t gUniqueID; | 24 static int32_t gUniqueID; |
(...skipping 20 matching lines...) Expand all Loading... |
53 return as_IB(this)->onGetTexture(); | 45 return as_IB(this)->onGetTexture(); |
54 } | 46 } |
55 | 47 |
56 SkData* SkImage::encode(SkImageEncoder::Type type, int quality) const { | 48 SkData* SkImage::encode(SkImageEncoder::Type type, int quality) const { |
57 SkBitmap bm; | 49 SkBitmap bm; |
58 if (as_IB(this)->getROPixels(&bm)) { | 50 if (as_IB(this)->getROPixels(&bm)) { |
59 return SkImageEncoder::EncodeData(bm, type, quality); | 51 return SkImageEncoder::EncodeData(bm, type, quality); |
60 } | 52 } |
61 return NULL; | 53 return NULL; |
62 } | 54 } |
OLD | NEW |