diff options
author | commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2014-02-10 18:29:10 +0000 |
---|---|---|
committer | commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2014-02-10 18:29:10 +0000 |
commit | 50b393a768c0311b3210f723325fd27bf161136b (patch) | |
tree | bd202eac46cbfdc0dcb81a617133a3dfc203e56e /tests | |
parent | 9985ef5ed8c0b5cf3530ccf13c0774c6ef6256dd (diff) |
SkPictureRecord: silently do nothing for non-drawable SkBitmaps.
BUG=skia:2135
R=reed@google.com
Author: mtklein@google.com
Review URL: https://codereview.chromium.org/154083004
git-svn-id: http://skia.googlecode.com/svn/trunk@13386 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'tests')
-rw-r--r-- | tests/PictureTest.cpp | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/tests/PictureTest.cpp b/tests/PictureTest.cpp index 7665b13d7e..002fe8f441 100644 --- a/tests/PictureTest.cpp +++ b/tests/PictureTest.cpp @@ -1031,3 +1031,38 @@ DEF_TEST(Picture, reporter) { test_clip_expansion(reporter); test_hierarchical(reporter); } + +static void draw_bitmaps(const SkBitmap bitmap, SkCanvas* canvas) { + const SkPaint paint; + const SkRect rect = { 5.0f, 5.0f, 8.0f, 8.0f }; + const SkIRect irect = { 2, 2, 3, 3 }; + + // Don't care what these record, as long as they're legal. + canvas->drawBitmap(bitmap, 0.0f, 0.0f, &paint); + canvas->drawBitmapRectToRect(bitmap, &rect, rect, &paint, SkCanvas::kNone_DrawBitmapRectFlag); + canvas->drawBitmapMatrix(bitmap, SkMatrix::I(), &paint); + canvas->drawBitmapNine(bitmap, irect, rect, &paint); + canvas->drawSprite(bitmap, 1, 1); +} + +static void test_draw_bitmaps(SkCanvas* canvas) { + SkBitmap empty; + draw_bitmaps(empty, canvas); + empty.setConfig(SkBitmap::kARGB_8888_Config, 10, 10); + draw_bitmaps(empty, canvas); +} + +DEF_TEST(Picture_EmptyBitmap, r) { + SkPicture picture; + test_draw_bitmaps(picture.beginRecording(10, 10)); + picture.endRecording(); +} + +DEF_TEST(Canvas_EmptyBitmap, r) { + SkBitmap dst; + dst.setConfig(SkBitmap::kARGB_8888_Config, 10, 10); + dst.allocPixels(); + SkCanvas canvas(dst); + + test_draw_bitmaps(&canvas); +} |