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 #include "SkSurface.h" |
12 | 13 |
13 static SkImage_Base* as_IB(SkImage* image) { | 14 static SkImage_Base* as_IB(SkImage* image) { |
14 return static_cast<SkImage_Base*>(image); | 15 return static_cast<SkImage_Base*>(image); |
15 } | 16 } |
16 | 17 |
17 static const SkImage_Base* as_IB(const SkImage* image) { | 18 static const SkImage_Base* as_IB(const SkImage* image) { |
18 return static_cast<const SkImage_Base*>(image); | 19 return static_cast<const SkImage_Base*>(image); |
19 } | 20 } |
20 | 21 |
21 uint32_t SkImage::NextUniqueID() { | 22 uint32_t SkImage::NextUniqueID() { |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 } | 85 } |
85 | 86 |
86 SkData* SkImage::encode(SkImageEncoder::Type type, int quality) const { | 87 SkData* SkImage::encode(SkImageEncoder::Type type, int quality) const { |
87 SkBitmap bm; | 88 SkBitmap bm; |
88 if (as_IB(this)->getROPixels(&bm)) { | 89 if (as_IB(this)->getROPixels(&bm)) { |
89 return SkImageEncoder::EncodeData(bm, type, quality); | 90 return SkImageEncoder::EncodeData(bm, type, quality); |
90 } | 91 } |
91 return NULL; | 92 return NULL; |
92 } | 93 } |
93 | 94 |
| 95 SkSurface* SkImage::newSurface(const SkImageInfo& info, const SkSurfaceProps& pr
ops) const { |
| 96 return as_IB(this)->onNewSurface(info, props); |
| 97 } |
| 98 |
94 /////////////////////////////////////////////////////////////////////////////// | 99 /////////////////////////////////////////////////////////////////////////////// |
95 | 100 |
96 static bool raster_canvas_supports(const SkImageInfo& info) { | 101 static bool raster_canvas_supports(const SkImageInfo& info) { |
97 switch (info.colorType()) { | 102 switch (info.colorType()) { |
98 case kN32_SkColorType: | 103 case kN32_SkColorType: |
99 return kUnpremul_SkAlphaType != info.alphaType(); | 104 return kUnpremul_SkAlphaType != info.alphaType(); |
100 case kRGB_565_SkColorType: | 105 case kRGB_565_SkColorType: |
101 return true; | 106 return true; |
102 case kAlpha_8_SkColorType: | 107 case kAlpha_8_SkColorType: |
103 return true; | 108 return true; |
(...skipping 27 matching lines...) Expand all Loading... |
131 | 136 |
132 SkCanvas canvas(*bitmap); | 137 SkCanvas canvas(*bitmap); |
133 | 138 |
134 SkPaint paint; | 139 SkPaint paint; |
135 paint.setXfermodeMode(SkXfermode::kClear_Mode); | 140 paint.setXfermodeMode(SkXfermode::kClear_Mode); |
136 canvas.drawRect(dstR, paint); | 141 canvas.drawRect(dstR, paint); |
137 | 142 |
138 canvas.drawImageRect(this, &srcR, dstR); | 143 canvas.drawImageRect(this, &srcR, dstR); |
139 return true; | 144 return true; |
140 } | 145 } |
OLD | NEW |