OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2008 The Android Open Source Project | 3 * Copyright 2008 The Android Open Source Project |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
7 */ | 7 */ |
8 | 8 |
9 | 9 |
10 #include "SkCanvas.h" | 10 #include "SkCanvas.h" |
(...skipping 2287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2298 return *paint; | 2298 return *paint; |
2299 } | 2299 } |
2300 | 2300 |
2301 const SkRegion& SkCanvas::LayerIter::clip() const { return fImpl->getClip(); } | 2301 const SkRegion& SkCanvas::LayerIter::clip() const { return fImpl->getClip(); } |
2302 int SkCanvas::LayerIter::x() const { return fImpl->getX(); } | 2302 int SkCanvas::LayerIter::x() const { return fImpl->getX(); } |
2303 int SkCanvas::LayerIter::y() const { return fImpl->getY(); } | 2303 int SkCanvas::LayerIter::y() const { return fImpl->getY(); } |
2304 | 2304 |
2305 /////////////////////////////////////////////////////////////////////////////// | 2305 /////////////////////////////////////////////////////////////////////////////// |
2306 | 2306 |
2307 SkCanvas::ClipVisitor::~ClipVisitor() { } | 2307 SkCanvas::ClipVisitor::~ClipVisitor() { } |
| 2308 |
| 2309 /////////////////////////////////////////////////////////////////////////////// |
| 2310 |
| 2311 static bool supported_for_raster_canvas(const SkImageInfo& info) { |
| 2312 switch (info.alphaType()) { |
| 2313 case kPremul_SkAlphaType: |
| 2314 case kOpaque_SkAlphaType: |
| 2315 break; |
| 2316 default: |
| 2317 return false; |
| 2318 } |
| 2319 |
| 2320 switch (info.colorType()) { |
| 2321 case kAlpha_8_SkColorType: |
| 2322 case kRGB_565_SkColorType: |
| 2323 case kPMColor_SkColorType: |
| 2324 break; |
| 2325 default: |
| 2326 return false; |
| 2327 } |
| 2328 |
| 2329 return true; |
| 2330 } |
| 2331 |
| 2332 SkCanvas* SkCanvas::NewRaster(const SkImageInfo& info) { |
| 2333 if (!supported_for_raster_canvas(info)) { |
| 2334 return NULL; |
| 2335 } |
| 2336 |
| 2337 SkBitmap bitmap; |
| 2338 if (!bitmap.allocPixels(info)) { |
| 2339 return NULL; |
| 2340 } |
| 2341 |
| 2342 // should this functionality be moved into allocPixels()? |
| 2343 if (!bitmap.info().isOpaque()) { |
| 2344 bitmap.eraseColor(0); |
| 2345 } |
| 2346 return SkNEW_ARGS(SkCanvas, (bitmap)); |
| 2347 } |
OLD | NEW |