OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2008 The Android Open Source Project | 2 * Copyright 2008 The Android Open Source Project |
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 "SkCanvas.h" | 8 #include "SkCanvas.h" |
9 #include "SkCanvasDrawable.h" | 9 #include "SkCanvasDrawable.h" |
10 #include "SkCanvasPriv.h" | 10 #include "SkCanvasPriv.h" |
(...skipping 2511 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2522 case kRGB_565_SkColorType: | 2522 case kRGB_565_SkColorType: |
2523 case kN32_SkColorType: | 2523 case kN32_SkColorType: |
2524 break; | 2524 break; |
2525 default: | 2525 default: |
2526 return false; | 2526 return false; |
2527 } | 2527 } |
2528 | 2528 |
2529 return true; | 2529 return true; |
2530 } | 2530 } |
2531 | 2531 |
| 2532 SkCanvas* SkCanvas::NewRaster(const SkImageInfo& info) { |
| 2533 if (!supported_for_raster_canvas(info)) { |
| 2534 return NULL; |
| 2535 } |
| 2536 |
| 2537 SkBitmap bitmap; |
| 2538 if (!bitmap.tryAllocPixels(info)) { |
| 2539 return NULL; |
| 2540 } |
| 2541 |
| 2542 // should this functionality be moved into allocPixels()? |
| 2543 if (!bitmap.info().isOpaque()) { |
| 2544 bitmap.eraseColor(0); |
| 2545 } |
| 2546 return SkNEW_ARGS(SkCanvas, (bitmap)); |
| 2547 } |
| 2548 |
2532 SkCanvas* SkCanvas::NewRasterDirect(const SkImageInfo& info, void* pixels, size_
t rowBytes) { | 2549 SkCanvas* SkCanvas::NewRasterDirect(const SkImageInfo& info, void* pixels, size_
t rowBytes) { |
2533 if (!supported_for_raster_canvas(info)) { | 2550 if (!supported_for_raster_canvas(info)) { |
2534 return NULL; | 2551 return NULL; |
2535 } | 2552 } |
2536 | 2553 |
2537 SkBitmap bitmap; | 2554 SkBitmap bitmap; |
2538 if (!bitmap.installPixels(info, pixels, rowBytes)) { | 2555 if (!bitmap.installPixels(info, pixels, rowBytes)) { |
2539 return NULL; | 2556 return NULL; |
2540 } | 2557 } |
2541 return SkNEW_ARGS(SkCanvas, (bitmap)); | 2558 return SkNEW_ARGS(SkCanvas, (bitmap)); |
(...skipping 17 matching lines...) Expand all Loading... |
2559 } | 2576 } |
2560 | 2577 |
2561 if (matrix) { | 2578 if (matrix) { |
2562 canvas->concat(*matrix); | 2579 canvas->concat(*matrix); |
2563 } | 2580 } |
2564 } | 2581 } |
2565 | 2582 |
2566 SkAutoCanvasMatrixPaint::~SkAutoCanvasMatrixPaint() { | 2583 SkAutoCanvasMatrixPaint::~SkAutoCanvasMatrixPaint() { |
2567 fCanvas->restoreToCount(fSaveCount); | 2584 fCanvas->restoreToCount(fSaveCount); |
2568 } | 2585 } |
OLD | NEW |